using MapoSDK; using System.Collections.Generic; namespace IOB_WIN_NEXT.IobOpc { public class OpcUaEwonBLM : OpcUaEwon { #region Public Constructors /// /// Estende l'init della classe base, impiegando il pacchetto Nuget OPC-UA foundation con la /// gestione specifica per EWON (es Monti, Tenditalia) /// https://github.com/OPCFoundation/UA-.NETStandard /// /// /// public OpcUaEwonBLM(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) { lgInfo("Init Ewon versione BLM (Mecart)"); // inizializzo classe base... if (!string.IsNullOrEmpty(getOptPar("CHANGE_ODL_MODE"))) { CHANGE_ODL_MODE = getOptPar("CHANGE_ODL_MODE"); } sendKeyRichiesta = true; } #endregion Public Constructors #region Protected Methods /// /// Effettua vera scrittura parametri /// /// protected override void plcWriteParams(ref List updatedPar) { base.plcWriteParams(ref updatedPar); #if false // se DEVO gestire setup Mecolpress... if (opcUaParams.SetupConf.SetupMode == IOB_UT_NEXT.MachineSetupMode.MECOLPRESS) { List nodes2Write = new List(); // faccio un check tra i valori in memoria che devono corrispondere e se NON // corrispondono --> metto valore in scrittura... int numDiff = 0; foreach (var item in opcUaParams.SetupConf.checkParList) { // cerco la memoria corrispondente... var memorieMes = dataItemMem.Where(x => x.Key.Contains(item.Key)).ToList(); var memorieMac = dataItemMem.Where(x => x.Key.Contains(item.Value)).ToList(); // se ho trovato qualcosa verifico se corrispondono... if (memorieMes.Count > 0 && memorieMes.Count > 0) { // controllo primo record con primo record if (memorieMes.FirstOrDefault().Value.value != memorieMac.FirstOrDefault().Value.value) { numDiff++; } } } // ciclo le condizioni di uscita foreach (var item in opcUaParams.SetupConf.writeParAction) { WriteValue commWriteVal = new WriteValue(); commWriteVal.NodeId = new NodeId(item.TargetParam); commWriteVal.AttributeId = Attributes.Value; commWriteVal.Value = new DataValue(); // se ho differenze --> scrivo richiesta attrezzaggio... if (numDiff > 0) { commWriteVal.Value.Value = item.TargetValNotEqual; } else { commWriteVal.Value.Value = item.TargetValEqual; } // accodo x scrittura nodes2Write.Add(commWriteVal); lgInfo($"richiesta scrittura valore | nodeId: {commWriteVal.NodeId} | targetPar: {item.TargetParam} | val {commWriteVal.Value.Value}"); } // x ora NON eseguo if (opcUaParams.SetupConf.EnableAdvSetup) { // ora scrivo! if (nodes2Write.Count > 0) { UA_ref.WriteNodes(nodes2Write); } } } #endif } #endregion Protected Methods } }