From 47e9ba742d0bfda68eb606f23573aa43bd583a4c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 27 Nov 2024 18:35:56 +0100 Subject: [PATCH] OPC-UA + MTConnect - deadband threshold: conversione INT a float --- IOB-UT-NEXT/ToMapo.cs | 4 ++-- IOB-WIN-NEXT/Iob/MTConnect.cs | 12 ++++++------ IOB-WIN-NEXT/IobOpc/OpcUa.cs | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/IOB-UT-NEXT/ToMapo.cs b/IOB-UT-NEXT/ToMapo.cs index 0aac33ec..7f3ef95b 100644 --- a/IOB-UT-NEXT/ToMapo.cs +++ b/IOB-UT-NEXT/ToMapo.cs @@ -405,12 +405,12 @@ namespace IOB_UT_NEXT /// /// Dictionary dei nomi da cercare come "endsWith" a cui applicare la soglia indicata /// - public Dictionary paramsEndThresh { get; set; } = new Dictionary(); + public Dictionary paramsEndThresh { get; set; } = new Dictionary(); /// /// Dictionary dei nomi da cercare come "contains" a cui applicare la soglia indicata /// - public Dictionary paramsContainsThresh { get; set; } = new Dictionary(); + public Dictionary paramsContainsThresh { get; set; } = new Dictionary(); /// /// Indica se il ping sia un criterio valido x determinare powerON impianto diff --git a/IOB-WIN-NEXT/Iob/MTConnect.cs b/IOB-WIN-NEXT/Iob/MTConnect.cs index e280ace0..a4eb03ad 100644 --- a/IOB-WIN-NEXT/Iob/MTConnect.cs +++ b/IOB-WIN-NEXT/Iob/MTConnect.cs @@ -525,7 +525,7 @@ namespace IOB_WIN_NEXT.Iob // provo a creare oggetot in memoria... List elencoDataItems = new List(); int dSamplePeriod = 0; - int threshDBand = 0; + float threshDBand = 0; string uuid = ""; var currDataItem = formatDataItem(ref dSamplePeriod, ref threshDBand, ref uuid, newValue); // aggiungo @@ -622,7 +622,7 @@ namespace IOB_WIN_NEXT.Iob { List elencoDataItems = new List(); int dSamplePeriod = 0; - int threshDBand = 0; + float threshDBand = 0; string uuid = ""; var currDataItem = formatDataItem(ref dSamplePeriod, ref threshDBand, ref uuid, newValue); // aggiungo @@ -688,7 +688,7 @@ namespace IOB_WIN_NEXT.Iob machDataItem currMapoDataItem = null; List elencoDataItems = new List(); int dSamplePeriod = 0; - int threshDBand = 0; + float threshDBand = 0; string uuid = ""; if (document != null) { @@ -1195,7 +1195,7 @@ namespace IOB_WIN_NEXT.Iob /// /// /// - private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref int threshDBand, ref string uuid, MTConnectStreams.Sample DISample) + private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref float threshDBand, ref string uuid, MTConnectStreams.Sample DISample) { // creo il nuovo dataitem da sample... MTConnectDevices.DataItem newDataItem = new MTConnectDevices.DataItem() @@ -1219,7 +1219,7 @@ namespace IOB_WIN_NEXT.Iob /// /// /// - private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref int threshDBand, ref string uuid, MTConnectStreams.DataItem DIGen) + private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref float threshDBand, ref string uuid, MTConnectStreams.DataItem DIGen) { // creo il nuovo dataitem da sample... MTConnectDevices.DataItem newDataItem = new MTConnectDevices.DataItem() @@ -1241,7 +1241,7 @@ namespace IOB_WIN_NEXT.Iob /// /// /// - private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref int threshDBand, ref string uuid, MTConnectDevices.DataItem dataItem) + private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref float threshDBand, ref string uuid, MTConnectDevices.DataItem dataItem) { MtcDataItemExt currDataItem; // uuid e parametri secondo categoria... diff --git a/IOB-WIN-NEXT/IobOpc/OpcUa.cs b/IOB-WIN-NEXT/IobOpc/OpcUa.cs index 3c7eadf8..4c330408 100644 --- a/IOB-WIN-NEXT/IobOpc/OpcUa.cs +++ b/IOB-WIN-NEXT/IobOpc/OpcUa.cs @@ -913,8 +913,11 @@ namespace IOB_WIN_NEXT.IobOpc string varDef = item.Value.memAddr.Substring(iPos + 1); string convVal = ConvBArr(rByte, varDef, opcUaParams.memDelim); // metto in array currData... - upsertKey(item.Key, convVal); - accodaFLog($"mMapRead | {item.Key} | {convVal}", qEncodeFLog(item.Key, convVal)); + if (upsertKey(item.Key, convVal)) + { + // accodo se variato! + accodaFLog($"mMapRead | {item.Key} | {convVal}", qEncodeFLog(item.Key, convVal)); + } } } } @@ -940,8 +943,11 @@ namespace IOB_WIN_NEXT.IobOpc string varDef = item.Value.memAddr.Substring(iPos + 1); string convVal = ConvBArr(rByte, varDef, opcUaParams.memDelim); // metto in array currData... - upsertKey(item.Key, convVal); - accodaFLog($"mMapRead | {item.Key} | {convVal}", qEncodeFLog(item.Key, convVal)); + if (upsertKey(item.Key, convVal)) + { + // accodo se variato! + accodaFLog($"mMapRead | {item.Key} | {convVal}", qEncodeFLog(item.Key, convVal)); + } } } } @@ -1475,7 +1481,7 @@ namespace IOB_WIN_NEXT.IobOpc try { int dSamplePeriod = 0; - int threshDBand = 0; + float threshDBand = 0; uuid = ""; var currDataItem = formatDataItem(ref dSamplePeriod, ref threshDBand, ref uuid, dataItem); // sistemo valore/periodo @@ -2149,7 +2155,7 @@ namespace IOB_WIN_NEXT.IobOpc subscribedItems = UA_ref.SubscribeToDataChanges(selectedItemList); // aggiungo come DataItems int dSamplePeriod = 0; - int threshDBand = 0; + float threshDBand = 0; string uuid = ""; foreach (var item in subscribedItems) { @@ -2246,7 +2252,7 @@ namespace IOB_WIN_NEXT.IobOpc /// /// /// - private OpcUaDataItemExt formatDataItem(ref int dSamplePeriod, ref int threshDBand, ref string uuid, Opc.Ua.Client.MonitoredItem dataItem) + private OpcUaDataItemExt formatDataItem(ref int dSamplePeriod, ref float threshDBand, ref string uuid, Opc.Ua.Client.MonitoredItem dataItem) { OpcUaDataItemExt currDataItem; // calcolo parametri secondo conf UniqueID