Merge branch 'release/TestMecolpressSetup'
This commit is contained in:
@@ -21,6 +21,17 @@ namespace IOB_UT_NEXT
|
||||
OR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modalità gestione setup macchina
|
||||
/// </summary>
|
||||
public enum MachineSetupMode
|
||||
{
|
||||
ND=0,
|
||||
|
||||
// Modalità Mecolpress (3 parametri IN, se variati --> porto a 1 la variabile di controllo)
|
||||
MECOLPRESS = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco MODI CNC
|
||||
/// </summary>
|
||||
@@ -324,6 +335,11 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
OpcUaEwonMonti,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon x Mecolpress / Stil
|
||||
/// </summary>
|
||||
OpcUaEwonMecolpress,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OSAI CNDEX (Cndex)
|
||||
/// </summary>
|
||||
|
||||
+56
-1
@@ -351,6 +351,56 @@ namespace IOB_UT_NEXT
|
||||
public int MaxVal { get; set; } = 9999;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definizione parametri di setup incrociato...
|
||||
/// </summary>
|
||||
public class MachineSetupConf
|
||||
{
|
||||
/// <summary>
|
||||
/// Modalità gestione setup
|
||||
/// </summary>
|
||||
public MachineSetupMode SetupMode { get; set; } = MachineSetupMode.ND;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei parametri di corrispondenza tra variabili MES e variabili Macchina
|
||||
/// MES = scritte dal MES
|
||||
/// Macchina = scritte da macchina
|
||||
/// </summary>
|
||||
public Dictionary<string, string> checkParList { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei parametri da scrivere quando si rilevano differenze tra i parametri MES/Macchina
|
||||
/// string (key) --> memoria da scrivere
|
||||
/// tuple<int isEqual,int notEqual> --> valori da scrivere quando uguali o diversi
|
||||
/// </summary>
|
||||
public List<MachineSetupAction> writeParAction { get; set; } = new List<MachineSetupAction>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe x definizione delle azioni in fase di setup macchina
|
||||
/// </summary>
|
||||
public class MachineSetupAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Parametro target dell'azione
|
||||
/// </summary>
|
||||
public string TargetParam { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// parametro da impostare SE il check da esito EQUAL
|
||||
/// </summary>
|
||||
public int TargetValEqual { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// parametro da impostare SE il check da esito NOT EQUAL
|
||||
/// </summary>
|
||||
public int TargetValNotEqual { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se vada disabilitato il contapezzi quando la condizione NotEqual sia soddisfatta
|
||||
/// </summary>
|
||||
public bool DisablePzCountNotEqual { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione configurazione parametri specifici OPC-UA da BaseParamConf
|
||||
/// </summary>
|
||||
@@ -440,7 +490,12 @@ namespace IOB_UT_NEXT
|
||||
/// <summary>
|
||||
/// Conf Gestione WatchDog
|
||||
/// </summary>
|
||||
public WatchDogConf WatchDog{get;set;} = new WatchDogConf();
|
||||
public WatchDogConf WatchDog {get;set;} = new WatchDogConf();
|
||||
|
||||
/// <summary>
|
||||
/// Conf gestione setup macchina
|
||||
/// </summary>
|
||||
public MachineSetupConf SetupConf { get; set; } = new MachineSetupConf();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -1223,6 +1223,11 @@ namespace IOB_WIN_NEXT
|
||||
start.Enabled = true;
|
||||
break;
|
||||
|
||||
case tipoAdapter.OpcUaEwonMecolpress:
|
||||
iobObj = new IobOpcUaEwonMecolpress(this, IOBConf);
|
||||
start.Enabled = true;
|
||||
break;
|
||||
|
||||
case tipoAdapter.PingWatchdog:
|
||||
iobObj = new IobPing(this, IOBConf);
|
||||
start.Enabled = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;Configurazione IOB-WIN
|
||||
[IOB]
|
||||
;Centro di lavoro OpcUa
|
||||
CNCTYPE=OpcUaEwon
|
||||
CNCTYPE=OpcUaEwonMecolpress
|
||||
PING_MS_TIMEOUT=500
|
||||
|
||||
[MACHINE]
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
"tipoMem": "Int",
|
||||
"memAddr": "ns=4;s=tomach_6_quantity",
|
||||
"index": 0,
|
||||
"size": -1
|
||||
"size": 4
|
||||
},
|
||||
"setComm": {
|
||||
"name": "setComm",
|
||||
@@ -144,8 +144,23 @@
|
||||
],
|
||||
"WatchDog": {
|
||||
"IsEnabled": true,
|
||||
"MemConfRead": "tomes_ 1_Watchdog",
|
||||
"MemConfWrite": "tomach_1_watchdog",
|
||||
"MemConfRead": "ns=4;s=tomes_1_Watchdog",
|
||||
"MemConfWrite": "ns=4;s=tomach_1_watchdog",
|
||||
"MaxVal": 9999
|
||||
},
|
||||
"SetupConf": {
|
||||
"SetupMode": "MECOLPRESS",
|
||||
"checkParList": {
|
||||
"tomach_3_code_die": "tomes_20_code_die",
|
||||
"tomach_4_prod_order": "tomes_21_order"
|
||||
},
|
||||
"writeParAction": [
|
||||
{
|
||||
"TargetParam": "ns=4;s=tomach_2_new_prod",
|
||||
"TargetValEqual": 0,
|
||||
"TargetValNotEqual": 1,
|
||||
"DisablePzCountNotEqual": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,7 @@
|
||||
<Compile Include="..\VersGen\VersGen.cs">
|
||||
<Link>VersGen.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="IobOpcUaEwonMecolpress.cs" />
|
||||
<Compile Include="IobOpcUaEwonMonti.cs" />
|
||||
<Compile Include="TcAdsClient.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Struttura dove vengono memorizzati i dataitem ed i rispettivi valori x processing
|
||||
/// </summary>
|
||||
private Dictionary<string, OpcUaDataItemExt> dataItemMem = new Dictionary<string, OpcUaDataItemExt>();
|
||||
protected Dictionary<string, OpcUaDataItemExt> dataItemMem = new Dictionary<string, OpcUaDataItemExt>();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco degli items da monitorare come risultato del browse iniziale
|
||||
@@ -325,7 +325,7 @@ namespace IOB_WIN_NEXT
|
||||
await application.CheckApplicationInstanceCertificate(silent: false, minimumKeySize: 0).ConfigureAwait(false);
|
||||
|
||||
lgInfo($"Chiamata UAClient con configurazione standard: {application.ApplicationConfiguration.ApplicationName}");
|
||||
UA_ref = new UAClient(application.ApplicationConfiguration, cIobConf.codIOB, ClientBase.ValidateResponse);
|
||||
UA_ref = new UAClient(application.ApplicationConfiguration, cIobConf.codIOB, isVerboseLog, ClientBase.ValidateResponse);
|
||||
|
||||
lgInfo($"Chiamata apertura OpcUa Client: {cIobConf.cncIpAddr}:{port}");
|
||||
UA_ref.ServerUrl = $"opc.tcp://{cIobConf.cncIpAddr}:{port}";
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace IOB_WIN_NEXT
|
||||
DateTime adesso = DateTime.Now;
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
lgInfo("decodeToBaseBitmap 01");
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* STATE MACHINE 60 STD / SIMULA
|
||||
@@ -121,7 +120,6 @@ namespace IOB_WIN_NEXT
|
||||
// se abilitato watchdog...
|
||||
if (opcUaParams.WatchDog.IsEnabled)
|
||||
{
|
||||
lgInfo("WatchDog 01");
|
||||
if (adesso.Subtract(lastWatchDogPLC).TotalSeconds > 2)
|
||||
{
|
||||
lastWatchDogPLC = adesso;
|
||||
@@ -131,7 +129,6 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo($"WatchDog val: {WatchDog}");
|
||||
try
|
||||
{
|
||||
|
||||
WriteValue commWriteVal = new WriteValue();
|
||||
commWriteVal.NodeId = new NodeId(opcUaParams.WatchDog.MemConfWrite);
|
||||
commWriteVal.AttributeId = Attributes.Value;
|
||||
@@ -140,8 +137,8 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
List<WriteValue> nodes2Write = new List<WriteValue>();
|
||||
nodes2Write.Add(commWriteVal);
|
||||
|
||||
UA_ref.WriteNodes(nodes2Write);
|
||||
lgInfo("Effettuata scrittura WatchDog");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaEwonMecolpress : IobOpcUaEwon
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="IOBConf"></param>
|
||||
public IobOpcUaEwonMecolpress(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
lgInfo("Init Ewon versione Mecolpress (STEL)");
|
||||
|
||||
// inizializzo classe base...
|
||||
if (!string.IsNullOrEmpty(getOptPar("CHANGE_ODL_MODE")))
|
||||
{
|
||||
CHANGE_ODL_MODE = getOptPar("CHANGE_ODL_MODE");
|
||||
}
|
||||
sendKeyRichiesta = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vera scrittura parametri
|
||||
/// </summary>
|
||||
/// <param name="updatedPar"></param>
|
||||
protected override void plcWriteParams(ref List<objItem> updatedPar)
|
||||
{
|
||||
base.plcWriteParams(ref updatedPar);
|
||||
|
||||
// se DEVO gestire setup Mecolpress...
|
||||
if (opcUaParams.SetupConf.SetupMode == IOB_UT_NEXT.MachineSetupMode.MECOLPRESS)
|
||||
{
|
||||
List<WriteValue> nodes2Write = new List<WriteValue>();
|
||||
// ora controllo la specifica condizione Mecolpress x il setup SE i parametri FOSSERO quelli di setup...
|
||||
dataConf currMem = null;
|
||||
// faccio un check tra i valori in memoria che devono corrispondere e se NON corrispondono --> metto valore in scrittura...
|
||||
bool needWrite = false;
|
||||
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 (false)
|
||||
{
|
||||
// ora scrivo!
|
||||
if (nodes2Write.Count > 0)
|
||||
{
|
||||
UA_ref.WriteNodes(nodes2Write);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace IOB_WIN_NEXT
|
||||
/// <param name="IOBConf"></param>
|
||||
public IobOpcUaEwonMonti(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
lgInfo("Init Ewon versione Monti (tenditalia)");
|
||||
lgInfo("Init Ewon versione Monti (Tenditalia)");
|
||||
// inizializzo classe base...
|
||||
if (!string.IsNullOrEmpty(getOptPar("CHANGE_ODL_MODE")))
|
||||
{
|
||||
@@ -39,24 +39,6 @@ namespace IOB_WIN_NEXT
|
||||
/// <param name="updatedPar"></param>
|
||||
protected override void plcWriteParams(ref List<objItem> updatedPar)
|
||||
{
|
||||
#if false
|
||||
if (!testDone)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UA_ref != null)
|
||||
{
|
||||
UA_ref.WriteTestNodes();
|
||||
testDone = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione in WriteTestNodes{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
dataConf currMem = null;
|
||||
int byteSize = 0;
|
||||
string memAddrWrite = "";
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace IOB_WIN_NEXT
|
||||
#region Protected Fields
|
||||
|
||||
protected static Logger lg;
|
||||
protected static bool isLogVerbose = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
@@ -89,11 +90,12 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the UAClient class.
|
||||
/// </summary>
|
||||
public UAClient(ApplicationConfiguration configuration, string codIOB, Action<IList, IList> validateResponse)
|
||||
public UAClient(ApplicationConfiguration configuration, string codIOB, bool verboseLog, Action<IList, IList> validateResponse)
|
||||
{
|
||||
m_validateResponse = validateResponse;
|
||||
currIob = codIOB;
|
||||
lg = LogManager.GetCurrentClassLogger();
|
||||
isLogVerbose = verboseLog;
|
||||
m_configuration = configuration;
|
||||
m_configuration.CertificateValidator.CertificateValidation += CertificateValidation;
|
||||
}
|
||||
@@ -198,7 +200,10 @@ namespace IOB_WIN_NEXT
|
||||
protected void lgInfo(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Info(message);
|
||||
if (isLogVerbose)
|
||||
{
|
||||
lg.Info(message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
Reference in New Issue
Block a user