Skip to content

Commit

Permalink
OPC-DA Client: add parameters to tag auto creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
riclolsen committed Aug 4, 2024
1 parent 5e7c495 commit 1214014
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
15 changes: 10 additions & 5 deletions src/OPC-DA-Client/AsduReceiveHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.RegularExpressions;
using Technosoftware.DaAeHdaClient;
using Technosoftware.DaAeHdaClient.Da;

Expand Down Expand Up @@ -277,7 +278,7 @@ public static void processValueResults(ref OPCDA_connection srv, ref TsCDaItemVa
if (LogLevel > LogLevelDetailed)
Log($"{srv.name} - {itemValues[i].ItemName} {valueString} {itemValues[i].Quality} {itemValues[i].Value.GetType().Name}", LogLevelDetailed);

var common_address = "";
var common_address = "@root";
var lstDot = itemValues[i].ItemName.LastIndexOf(".");
var spl = itemValues[i].ItemName.Split(".");
string group2 = "@root", group3 = "", ungroupedDescription = itemValues[i].ItemName.Substring(lstDot + 1);
Expand Down Expand Up @@ -314,14 +315,18 @@ public static void processValueResults(ref OPCDA_connection srv, ref TsCDaItemVa
conn_name = srv.name,
common_address = common_address,
display_name = itemValues[i].ItemName,
group1 = srv.name,
group2 = group2,
group3 = group3,
ungroupedDescription = ungroupedDescription,
};

if (firstExecution && srv.autoCreateTags && !srv.InsertedAddresses.Contains(itemValues[i].ItemName))
{
ov.group1 = srv.name;
ov.group2 = group2;
ov.group3 = group3;
ov.ungroupedDescription = ungroupedDescription;
ov.protocolSourcePublishingInterval = srv.autoCreateTagPublishingInterval;
ov.protocolSourceSamplingInterval = srv.autoCreateTagSamplingInterval;
ov.protocolSourceQueueSize = srv.autoCreateTagQueueSize;

var id = srv.LastNewKeyCreated + 1;
srv.LastNewKeyCreated = id;

Expand Down
3 changes: 3 additions & 0 deletions src/OPC-DA-Client/Common_srv_cli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public struct OPC_Value
public string group2;
public string group3;
public string ungroupedDescription;
public double protocolSourcePublishingInterval;
public double protocolSourceSamplingInterval;
public double protocolSourceQueueSize;
}
public class rtFilt
{
Expand Down
3 changes: 1 addition & 2 deletions src/OPC-DA-Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
using System.Threading.Tasks;
using Technosoftware.DaAeHdaClient;
using Technosoftware.DaAeHdaClient.Da;
using static MongoDB.Driver.WriteConcern;

namespace OPCDAClientDriver
{
Expand Down Expand Up @@ -413,7 +412,7 @@ public static void Main(string[] args)
var subscrState = new TsCDaSubscriptionState
{
Name = "JsonScadaGroup1",
UpdateRate = (int)srv.autoCreateTagSamplingInterval,
UpdateRate = (int)srv.autoCreateTagPublishingInterval * 1000,
Deadband = (float)srv.deadBand,
// TimeBias = (int)(srv.hoursShift * 60)
// KeepAlive = (int)srv.giInterval/2,
Expand Down
18 changes: 9 additions & 9 deletions src/OPC-DA-Client/TagsCreation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ public static rtData newRealtimeDoc(OPC_Value iv, double _id)
protocolSourceObjectAddress = iv.address,
protocolSourceCommandUseSBO = false,
protocolSourceCommandDuration = 0.0,
protocolSourcePublishingInterval = 5.0,
protocolSourceSamplingInterval = 2.0,
protocolSourceQueueSize = 10.0,
protocolSourcePublishingInterval = iv.protocolSourcePublishingInterval,
protocolSourceSamplingInterval = iv.protocolSourceSamplingInterval,
protocolSourceQueueSize = iv.protocolSourceQueueSize,
protocolSourceDiscardOldest = true,
alarmState = 2.0,
description = iv.group1 + "~" + iv.group2 + "~" + iv.display_name,
Expand Down Expand Up @@ -269,9 +269,9 @@ public static rtData newRealtimeDoc(OPC_Value iv, double _id)
protocolSourceObjectAddress = iv.address,
protocolSourceCommandUseSBO = false,
protocolSourceCommandDuration = 0.0,
protocolSourcePublishingInterval = 5.0,
protocolSourceSamplingInterval = 2.0,
protocolSourceQueueSize = 10.0,
protocolSourcePublishingInterval = iv.protocolSourcePublishingInterval,
protocolSourceSamplingInterval = iv.protocolSourceSamplingInterval,
protocolSourceQueueSize = iv.protocolSourceQueueSize,
protocolSourceDiscardOldest = true,
alarmState = -1.0,
description = iv.group1 + "~" + iv.group2 + "~" + iv.display_name,
Expand Down Expand Up @@ -344,9 +344,9 @@ public static rtData newRealtimeDoc(OPC_Value iv, double _id)
protocolSourceObjectAddress = iv.address,
protocolSourceCommandUseSBO = false,
protocolSourceCommandDuration = 0.0,
protocolSourcePublishingInterval = 5.0,
protocolSourceSamplingInterval = 2.0,
protocolSourceQueueSize = 10.0,
protocolSourcePublishingInterval = iv.protocolSourcePublishingInterval,
protocolSourceSamplingInterval = iv.protocolSourceSamplingInterval,
protocolSourceQueueSize = iv.protocolSourceQueueSize,
protocolSourceDiscardOldest = true,
alarmState = -1.0,
description = iv.group1 + "~" + iv.group2 + "~" + iv.display_name,
Expand Down

0 comments on commit 1214014

Please sign in to comment.