diff --git a/IOB-UT-NEXT/Config/Base/IobDto.cs b/IOB-UT-NEXT/Config/Base/IobDto.cs index 48a51958..4130ce70 100644 --- a/IOB-UT-NEXT/Config/Base/IobDto.cs +++ b/IOB-UT-NEXT/Config/Base/IobDto.cs @@ -51,9 +51,9 @@ namespace IOB_UT_NEXT.Config.Base public string MultiIobList { get; set; } = ""; /// - /// Tempo di attesa (in minuti) x lettura contapezzi standard + /// Tempo di attesa (in minuti) x lettura contapezzi standard (default 30 sec) /// - public double DelayReadPzCount { get; set; } = 0; + public double DelayReadPzCount { get; set; } = 0.5; /// /// Disabilitazione invio DynData di WDST (WatchDogStateTransfer) diff --git a/IOB-UT-NEXT/Enums.cs b/IOB-UT-NEXT/Enums.cs index daa90d57..a27dc83b 100644 --- a/IOB-UT-NEXT/Enums.cs +++ b/IOB-UT-NEXT/Enums.cs @@ -581,6 +581,11 @@ namespace IOB_UT_NEXT /// OpcUaSiemensRama, + /// + /// Adapter OPC-UA macchne SW + /// + OpcUaSiemensSW, + /// /// Adapter OPC-UA Ulma (packaging, Giacovelli) /// diff --git a/IOB-UT-NEXT/ToMapo.cs b/IOB-UT-NEXT/ToMapo.cs index 3691924f..564c866a 100644 --- a/IOB-UT-NEXT/ToMapo.cs +++ b/IOB-UT-NEXT/ToMapo.cs @@ -401,6 +401,18 @@ namespace IOB_UT_NEXT /// public string keyPartCount { get; set; } = ""; +#if true + /// + /// Indica se sia una macchina MULTI (con varie Tavole/Pallet) + /// + public bool isMulti { get; set; } = false; + + /// + /// Dizionario variabili x pezzi FATTI se multi tavola + /// + public Dictionary keyPartCountTav { get; set; } = null; +#endif + /// /// Nome variabile x Codice Articolo /// @@ -804,6 +816,16 @@ namespace IOB_UT_NEXT /// public diCheckCondSetup condSetup { get; set; } = new diCheckCondSetup(); + /// + /// Struttura dati x check condizione Tavola 1 attiva + /// + public diCheckCondSetup condActTav1 { get; set; } = new diCheckCondSetup(); + + /// + /// Struttura dati x check condizione Tavola 2 attiva + /// + public diCheckCondSetup condActTav2 { get; set; } = new diCheckCondSetup(); + /// /// Struttura dati x check condizione WarmUp - CoolDown /// diff --git a/IOB-WIN-FORM/AdapterForm.cs b/IOB-WIN-FORM/AdapterForm.cs index ffc3a5f7..196d9d84 100644 --- a/IOB-WIN-FORM/AdapterForm.cs +++ b/IOB-WIN-FORM/AdapterForm.cs @@ -1355,644 +1355,644 @@ namespace IOB_WIN_FORM private delegate void SafeCallDelegate(string text); - #endregion Private Delegates + #endregion Private Delegates - #region Private Methods + #region Private Methods - private void btnForceAutoOdl_Click(object sender, EventArgs e) - { - iobObj.forceResetOdl(); - } - - private void BtnOpenLog_Click(object sender, EventArgs e) - { - try + private void btnForceAutoOdl_Click(object sender, EventArgs e) { - string logPath = $"{System.AppDomain.CurrentDomain.BaseDirectory}logs\\{CurrIOB}\\{DateTime.Today:yyyy-MM-dd}.log"; - Process.Start(logPath); + iobObj.forceResetOdl(); } - catch (Exception exc) + + private void BtnOpenLog_Click(object sender, EventArgs e) { - lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}"); - } - } - - private void BtnSendPLC_Click(object sender, EventArgs e) - { - // invia a MES il parametro selezionato (es ART / ODL / PRG NAME, come task2exe..) - Dictionary forcedTask = new Dictionary(); - // guardo i parametri... - if (!string.IsNullOrEmpty(txtValue.Text)) - { - forcedTask.Add(cmbParamValues.SelectedValue.ToString(), txtValue.Text); - } - // chiedo esecuzione task! - iobObj.processTask(forcedTask); - chkEdit.Checked = false; - toggleEditMes2Plc(); - } - - private void checkAssignSize() - { - int valSize = 0; - int.TryParse(txtMReadSize.Text, out valSize); - // verifico sia valida con lenght array... - int maxSize = iobObj.RawInput.Length - iobObj.RawDataInputStart; - valSize = valSize > maxSize ? maxSize : valSize; - // riporto - iobObj.RawDataInputSize = valSize; - } - - private void checkAssignStart() - { - int valStart = 0; - int.TryParse(txtMReadStart.Text, out valStart); - // verifico sia valida con start/lenght array... - int maxStart = iobObj.RawInput.Length - 1; - valStart = valStart > maxStart ? maxStart : valStart; - // riporto - iobObj.RawDataInputStart = valStart; - } - - private void checkEditMes2Plc() - { - cmbParamValues.Enabled = enableEditMes2Plc; - txtValue.Enabled = enableEditMes2Plc; - if (enableEditMes2Plc) - { - // aggiorno (se possibile) i parametri selezionabili... - fixComboParameters(); - } - } - - /// - /// Verifica scadenza task - /// - /// - private void checkScad() - { - DateTime adesso = DateTime.Now; - bool sendDone = false; - // ciclo su tutti i timers enum superiori a VHF - var priorities = (gatherCycle[])Enum.GetValues(typeof(gatherCycle)); - // prendo solo > VHF e ordino discendenti x dare priorità ai più rari... - var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x); - foreach (gatherCycle item in ordered) - { - if (TimersVeto.ContainsKey(item)) - { - if (TimersVeto[item] <= adesso) - { - // se non ho già processato a questo giro... - if (!sendDone) - { - TimersCycleCount[item]++; - Stopwatch sw = new Stopwatch(); - sw.Start(); - // se scaduto processo! - iobObj.getAndSend(item); - sendDone = true; - sw.Stop(); - TimersCycleElaps[item] += sw.Elapsed.TotalMilliseconds; - // metto nuova scadenza perturbata 10% - TimersVeto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1)); - } - // log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec - int limMs = 10000; - if (TimersCycleCount[item] >= 100 || (TimersCycleElaps.ContainsKey(item) && TimersCycleElaps[item] > limMs)) - { - var nCount = TimersCycleCount[item]; - nCount = nCount > 0 ? nCount : 1; - lgDebug($"checkScad | {item} | {TimersCycleElaps[item] / nCount:F1}ms x {nCount}"); - TimersCycleCount[item] = 0; - TimersCycleElaps[item] = 0; - } - } - } - else - { - TimersVeto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0))); - TimersCycleCount.Add(item, 0); - } - } - } - - private void checkSampleMem() - { - // decremento contatore... - sampleMemCount--; - if (sampleMemCount <= 0) - { - sampleMemCount = utils.CRI("sampleMemCount"); - // avvio fase raccolta dati e invio con adapter - iobObj.saveMemDump(dumpType.SAMPLE); - } - } - - private void ChkEdit_CheckedChanged(object sender, EventArgs e) - { - toggleEditMes2Plc(); - } - - /// - /// Chiusura adapter - /// - private void closeAdapter() - { - lgDebug("closeAdapter | true | false | true | false"); - fermaTutto(true, false, true, false); - } - - private void displTimer_Tick(object sender, EventArgs e) - { - } - - /// - /// Ferma tutti i componenti adapter + update buttons - /// - /// - /// indica se fermare il timer (gather) principale (solo se non si chiude) - /// - /// indica se tentare di riconnettersi - /// indica se sia richiesto di SVUOTARE le code delle info - /// indica se si debba aggiornare la form (no se si sta chiudendo...) - private void fermaTutto(bool stopTimer, bool tryRestart, bool forceDequeue, bool updateForm) - { - try - { - iobObj.stopAdapter(tryRestart, forceDequeue); - - stop.Enabled = false; - start.Enabled = true; - restart.Enabled = false; - - if (stopTimer) - { - gather.Enabled = false; - } - - newDisplayData currDispData = new newDisplayData(); - currDispData.semIn = Semaforo.SS; - currDispData.semOut = Semaforo.SS; - if (updateForm) - { - updateFormDisplay(currDispData); - } - } - catch (Exception exc) - { - lgError($"Errore in chiusura:{Environment.NewLine}{exc}"); - } - } - - private void fixComboParameters() - { - if (iobObj != null) - { - if (iobObj.memMap != null) - { - if (iobObj.memMap.mMapWrite != null) - { - if (iobObj.memMap.mMapWrite.Count > 0) - { - var oldParams = cmbParamValues.DataSource; - List parametri = new List(); - foreach (var item in iobObj.memMap.mMapWrite) - { - parametri.Add(item.Key); - } - // salvo selezione - int oldIdx = cmbParamValues.SelectedIndex; - // riassegno e ri-seleziono - cmbParamValues.DataSource = parametri; - cmbParamValues.SelectedIndex = oldIdx >= 0 ? oldIdx : 0; - } - } - } - } - } - - /// - /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata - /// - private Dictionary TimersVeto = new Dictionary(); - /// - /// Contatore chiamate timers x debug timing - /// - private Dictionary TimersCycleCount = new Dictionary(); - /// - /// Contatore durata exec x debug timing - /// - private Dictionary TimersCycleElaps = new Dictionary(); - - /// - /// Evento principale scadenza del timer interno MsUI da cui scaturire le varie esecuzioni - /// - /// - /// - private void gather_Tick(object sender, EventArgs e) - { - bool doLog = false; - if (iobObj != null) - { - // fermo il timer... - gather.Stop(); - // procedo! - if (iobObj.periodicLog) - { - doLog = true; - } try { - refreshFormData(); - // check esecuzione SendTask (MsVHF) COMUNQUE... - iobObj.getAndSend(gatherCycle.VHF); - // eseguo cicli attivi SOLO se adapter è in EFFETTIVO running... - if (iobObj.adpRunning) + string logPath = $"{System.AppDomain.CurrentDomain.BaseDirectory}logs\\{CurrIOB}\\{DateTime.Today:yyyy-MM-dd}.log"; + Process.Start(logPath); + } + catch (Exception exc) + { + lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}"); + } + } + + private void BtnSendPLC_Click(object sender, EventArgs e) + { + // invia a MES il parametro selezionato (es ART / ODL / PRG NAME, come task2exe..) + Dictionary forcedTask = new Dictionary(); + // guardo i parametri... + if (!string.IsNullOrEmpty(txtValue.Text)) + { + forcedTask.Add(cmbParamValues.SelectedValue.ToString(), txtValue.Text); + } + // chiedo esecuzione task! + iobObj.processTask(forcedTask); + chkEdit.Checked = false; + toggleEditMes2Plc(); + } + + private void checkAssignSize() + { + int valSize = 0; + int.TryParse(txtMReadSize.Text, out valSize); + // verifico sia valida con lenght array... + int maxSize = iobObj.RawInput.Length - iobObj.RawDataInputStart; + valSize = valSize > maxSize ? maxSize : valSize; + // riporto + iobObj.RawDataInputSize = valSize; + } + + private void checkAssignStart() + { + int valStart = 0; + int.TryParse(txtMReadStart.Text, out valStart); + // verifico sia valida con start/lenght array... + int maxStart = iobObj.RawInput.Length - 1; + valStart = valStart > maxStart ? maxStart : valStart; + // riporto + iobObj.RawDataInputStart = valStart; + } + + private void checkEditMes2Plc() + { + cmbParamValues.Enabled = enableEditMes2Plc; + txtValue.Enabled = enableEditMes2Plc; + if (enableEditMes2Plc) + { + // aggiorno (se possibile) i parametri selezionabili... + fixComboParameters(); + } + } + + /// + /// Verifica scadenza task + /// + /// + private void checkScad() + { + DateTime adesso = DateTime.Now; + bool sendDone = false; + // ciclo su tutti i timers enum superiori a VHF + var priorities = (gatherCycle[])Enum.GetValues(typeof(gatherCycle)); + // prendo solo > VHF e ordino discendenti x dare priorità ai più rari... + var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x); + foreach (gatherCycle item in ordered) + { + if (TimersVeto.ContainsKey(item)) { - if (iobObj.connectionOk) + if (TimersVeto[item] <= adesso) { - // se richiesto faccio memory DUMP INIZIALE! - if (iobObj.doStartMemDump) + // se non ho già processato a questo giro... + if (!sendDone) { - lgInfo("Inizio dump memoria"); - iobObj.saveMemDump(dumpType.STARTUP); - // fatto! non ripeto... - iobObj.doStartMemDump = false; - lgInfo("Finito dump memoria"); + TimersCycleCount[item]++; + Stopwatch sw = new Stopwatch(); + sw.Start(); + // se scaduto processo! + iobObj.getAndSend(item); + sendDone = true; + sw.Stop(); + TimersCycleElaps[item] += sw.Elapsed.TotalMilliseconds; + // metto nuova scadenza perturbata 10% + TimersVeto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1)); } - // controllo se sia abilitato sampleDump della meoria (periodico) - if (iobObj.doSampleMemory) + // log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec + int limMs = 10000; + if (TimersCycleCount[item] >= 100 || (TimersCycleElaps.ContainsKey(item) && TimersCycleElaps[item] > limMs)) { - checkSampleMem(); - } - // controllo TUTTE le scadenze... - checkScad(); - if (utils.CRI("waitEndCycle") > 0) - { - Thread.Sleep(utils.CRI("waitEndCycle")); - } - } - else - { - // qui attende meno... - DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2); - if (iobObj.adpTryRestart && (DateTime.Now > dtVeto)) - { - if (doLog) - { - lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect"); - } - lastStartTry = DateTime.Now; - iobObj.tryConnect(); + var nCount = TimersCycleCount[item]; + nCount = nCount > 0 ? nCount : 1; + lgDebug($"checkScad | {item} | {TimersCycleElaps[item] / nCount:F1}ms x {nCount}"); + TimersCycleCount[item] = 0; + TimersCycleElaps[item] = 0; } } } else { - if (doLog) - { - lgInfo("Adapter stopped"); - } - // verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart - // e non ho riprovato x oltre waitRecMSec - DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec); - if (iobObj.adpTryRestart && (DateTime.Now > dtVeto)) - { - lastStartTry = DateTime.Now; - avviaAdapter(chkForceDequeue.Checked); - } + TimersVeto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0))); + TimersCycleCount.Add(item, 0); } } - catch (Exception exc) + } + + private void checkSampleMem() + { + // decremento contatore... + sampleMemCount--; + if (sampleMemCount <= 0) { - lgError(string.Format("Eccezione in fase di gatherTick: {0}{1}", Environment.NewLine, exc)); + sampleMemCount = utils.CRI("sampleMemCount"); + // avvio fase raccolta dati e invio con adapter + iobObj.saveMemDump(dumpType.SAMPLE); } - - // riavvio il timer... - gather.Start(); } - } - /// - /// Init oggetti datamonitor - /// - private void initDatamonitor() - { - for (int i = 0; i < 4; i++) + private void ChkEdit_CheckedChanged(object sender, EventArgs e) { - dMonDisplVetoVeto.Add(i, DateTime.Now); - dMonValues.Add(i, new List()); + toggleEditMes2Plc(); } - } - /// - /// Carica file ini della configurazione richiesta - /// - /// - private void loadIniFile(string iniConfFile) - { - // out di cosa faccio... - displayTaskAndLog($"[STARTUP] Loading ConfFile: {iniConfFile}"); - var appVers = Assembly.GetExecutingAssembly().GetName().Version; - string path = fileMover.GetExecutingDirectoryName(); // Directory.GetCurrentDirectory(); - string fileName = Path.GetFileName(iniConfFile).Replace(".ini", ".iob"); - string dirPath = Path.Combine(path, "DATA", "CONF_RUN"); - // verifica directory - baseUtils.checkDir(dirPath); - string fullPath = Path.Combine(dirPath, fileName); - // preparazione file conf con nuovo formato e salvataggio... - IOBConfFull = IobConfTree.LoadFromINI(iniConfFile); - if (IOBConfFull.General.FileName.EndsWith("ini")) + /// + /// Chiusura adapter + /// + private void closeAdapter() { - IOBConfFull.General.FileName = IOBConfFull.General.FileName.Replace("ini", "yaml"); + lgDebug("closeAdapter | true | false | true | false"); + fermaTutto(true, false, true, false); } - // salvo anche yaml... - IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml")); - // carico IOB - loadIobType(); - // invio file di conf! - IOBConfFull.SendConfYaml(iobObj.urlSaveConfYaml); - - // avvio macchina con adapter specificato... - if (utils.CRB("autoStartOnLoad")) + private void displTimer_Tick(object sender, EventArgs e) { - displayTaskAndLog("Auto Starting...", true); - // avvio! - avviaAdapter(chkForceDequeue.Checked); - displayTaskAndLog("Auto Started!", true); } - } - /// - /// Carica file yaml della configurazione richiesta - /// - /// - private void loadYamlFile(string yamlConfFile) - { - // out di cosa faccio... - displayTaskAndLog($"[STARTUP] Loading yamlConfFile: {yamlConfFile}"); - // leggo file - IniFile fIni = new IniFile(yamlConfFile); - - // carivo vettore parametri opzionai - Dictionary optParRead = new Dictionary(); - string[] optParRows = fIni.ReadSection("OPTPAR"); - if (optParRows.Length > 0) + /// + /// Ferma tutti i componenti adapter + update buttons + /// + /// + /// indica se fermare il timer (gather) principale (solo se non si chiude) + /// + /// indica se tentare di riconnettersi + /// indica se sia richiesto di SVUOTARE le code delle info + /// indica se si debba aggiornare la form (no se si sta chiudendo...) + private void fermaTutto(bool stopTimer, bool tryRestart, bool forceDequeue, bool updateForm) { try { - string[] kvp; - foreach (var item in optParRows) + iobObj.stopAdapter(tryRestart, forceDequeue); + + stop.Enabled = false; + start.Enabled = true; + restart.Enabled = false; + + if (stopTimer) { - kvp = item.Split('='); - optParRead.Add(kvp[0], kvp[1]); + gather.Enabled = false; + } + + newDisplayData currDispData = new newDisplayData(); + currDispData.semIn = Semaforo.SS; + currDispData.semOut = Semaforo.SS; + if (updateForm) + { + updateFormDisplay(currDispData); } - lgDebug($"Caricati {optParRead.Count} parametri opzionali da OPTPAR"); } catch (Exception exc) { - lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc)); + lgError($"Errore in chiusura:{Environment.NewLine}{exc}"); } } - var appVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; - loadIobType(); - // avvio macchina con adapter specificato... - if (utils.CRB("autoStartOnLoad")) + private void fixComboParameters() { - displayTaskAndLog("Auto Starting...", true); - // avvio! - avviaAdapter(chkForceDequeue.Checked); - displayTaskAndLog("Auto Started!", true); + if (iobObj != null) + { + if (iobObj.memMap != null) + { + if (iobObj.memMap.mMapWrite != null) + { + if (iobObj.memMap.mMapWrite.Count > 0) + { + var oldParams = cmbParamValues.DataSource; + List parametri = new List(); + foreach (var item in iobObj.memMap.mMapWrite) + { + parametri.Add(item.Key); + } + // salvo selezione + int oldIdx = cmbParamValues.SelectedIndex; + // riassegno e ri-seleziono + cmbParamValues.DataSource = parametri; + cmbParamValues.SelectedIndex = oldIdx >= 0 ? oldIdx : 0; + } + } + } + } } - } + /// + /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata + /// + private Dictionary TimersVeto = new Dictionary(); + /// + /// Contatore chiamate timers x debug timing + /// + private Dictionary TimersCycleCount = new Dictionary(); + /// + /// Contatore durata exec x debug timing + /// + private Dictionary TimersCycleElaps = new Dictionary(); - /// - /// Verifica se il log di un dato errore sia permesso - /// - /// ID del valore log da loggare/verificare - /// - private bool logValuePermit(string logKey) - { - bool doLog = false; - if (vetoLogError.ContainsKey(logKey)) + /// + /// Evento principale scadenza del timer interno MsUI da cui scaturire le varie esecuzioni + /// + /// + /// + private void gather_Tick(object sender, EventArgs e) { - // verifico se veto scaduto... - if (DateTime.Now > vetoLogError[logKey]) + bool doLog = false; + if (iobObj != null) + { + // fermo il timer... + gather.Stop(); + // procedo! + if (iobObj.periodicLog) + { + doLog = true; + } + try + { + refreshFormData(); + // check esecuzione SendTask (MsVHF) COMUNQUE... + iobObj.getAndSend(gatherCycle.VHF); + // eseguo cicli attivi SOLO se adapter è in EFFETTIVO running... + if (iobObj.adpRunning) + { + if (iobObj.connectionOk) + { + // se richiesto faccio memory DUMP INIZIALE! + if (iobObj.doStartMemDump) + { + lgInfo("Inizio dump memoria"); + iobObj.saveMemDump(dumpType.STARTUP); + // fatto! non ripeto... + iobObj.doStartMemDump = false; + lgInfo("Finito dump memoria"); + } + // controllo se sia abilitato sampleDump della meoria (periodico) + if (iobObj.doSampleMemory) + { + checkSampleMem(); + } + // controllo TUTTE le scadenze... + checkScad(); + if (utils.CRI("waitEndCycle") > 0) + { + Thread.Sleep(utils.CRI("waitEndCycle")); + } + } + else + { + // qui attende meno... + DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2); + if (iobObj.adpTryRestart && (DateTime.Now > dtVeto)) + { + if (doLog) + { + lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect"); + } + lastStartTry = DateTime.Now; + iobObj.tryConnect(); + } + } + } + else + { + if (doLog) + { + lgInfo("Adapter stopped"); + } + // verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart + // e non ho riprovato x oltre waitRecMSec + DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec); + if (iobObj.adpTryRestart && (DateTime.Now > dtVeto)) + { + lastStartTry = DateTime.Now; + avviaAdapter(chkForceDequeue.Checked); + } + } + } + catch (Exception exc) + { + lgError(string.Format("Eccezione in fase di gatherTick: {0}{1}", Environment.NewLine, exc)); + } + + // riavvio il timer... + gather.Start(); + } + } + + /// + /// Init oggetti datamonitor + /// + private void initDatamonitor() + { + for (int i = 0; i < 4; i++) + { + dMonDisplVetoVeto.Add(i, DateTime.Now); + dMonValues.Add(i, new List()); + } + } + + /// + /// Carica file ini della configurazione richiesta + /// + /// + private void loadIniFile(string iniConfFile) + { + // out di cosa faccio... + displayTaskAndLog($"[STARTUP] Loading ConfFile: {iniConfFile}"); + var appVers = Assembly.GetExecutingAssembly().GetName().Version; + string path = fileMover.GetExecutingDirectoryName(); // Directory.GetCurrentDirectory(); + string fileName = Path.GetFileName(iniConfFile).Replace(".ini", ".iob"); + string dirPath = Path.Combine(path, "DATA", "CONF_RUN"); + // verifica directory + baseUtils.checkDir(dirPath); + string fullPath = Path.Combine(dirPath, fileName); + // preparazione file conf con nuovo formato e salvataggio... + IOBConfFull = IobConfTree.LoadFromINI(iniConfFile); + if (IOBConfFull.General.FileName.EndsWith("ini")) + { + IOBConfFull.General.FileName = IOBConfFull.General.FileName.Replace("ini", "yaml"); + } + // salvo anche yaml... + IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml")); + + // carico IOB + loadIobType(); + // invio file di conf! + IOBConfFull.SendConfYaml(iobObj.urlSaveConfYaml); + + // avvio macchina con adapter specificato... + if (utils.CRB("autoStartOnLoad")) + { + displayTaskAndLog("Auto Starting...", true); + // avvio! + avviaAdapter(chkForceDequeue.Checked); + displayTaskAndLog("Auto Started!", true); + } + } + + /// + /// Carica file yaml della configurazione richiesta + /// + /// + private void loadYamlFile(string yamlConfFile) + { + // out di cosa faccio... + displayTaskAndLog($"[STARTUP] Loading yamlConfFile: {yamlConfFile}"); + // leggo file + IniFile fIni = new IniFile(yamlConfFile); + + // carivo vettore parametri opzionai + Dictionary optParRead = new Dictionary(); + string[] optParRows = fIni.ReadSection("OPTPAR"); + if (optParRows.Length > 0) + { + try + { + string[] kvp; + foreach (var item in optParRows) + { + kvp = item.Split('='); + optParRead.Add(kvp[0], kvp[1]); + } + lgDebug($"Caricati {optParRead.Count} parametri opzionali da OPTPAR"); + } + catch (Exception exc) + { + lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc)); + } + } + var appVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + + loadIobType(); + // avvio macchina con adapter specificato... + if (utils.CRB("autoStartOnLoad")) + { + displayTaskAndLog("Auto Starting...", true); + // avvio! + avviaAdapter(chkForceDequeue.Checked); + displayTaskAndLog("Auto Started!", true); + } + } + + + /// + /// Verifica se il log di un dato errore sia permesso + /// + /// ID del valore log da loggare/verificare + /// + private bool logValuePermit(string logKey) + { + bool doLog = false; + if (vetoLogError.ContainsKey(logKey)) + { + // verifico se veto scaduto... + if (DateTime.Now > vetoLogError[logKey]) + { + doLog = true; + vetoLogError[logKey] = DateTime.Now.AddMinutes(vetoPeriodMin); + } + } + else { doLog = true; - vetoLogError[logKey] = DateTime.Now.AddMinutes(vetoPeriodMin); + vetoLogError.Add(logKey, DateTime.Now.AddMinutes(vetoPeriodMin)); + } + + return doLog; + } + + /// + /// Fase chiusura Form + /// + /// + /// + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + lgTrace("MainForm_FormClosing"); + closeAdapter(); + } + + /// + /// Completato resize form + /// + /// + /// + private void MainForm_Resize(object sender, EventArgs e) + { + } + + /// + /// Mostrata form + /// + /// + /// + private void MainForm_Shown(object sender, EventArgs e) + { + displayTaskAndLog("Main Form SHOWN (Adapter)", true); + } + + private void mLoadConf_Click(object sender, EventArgs e) + { + // mostro selettore file x leggere adapter.. + OpenFileDialog openFileDial = new OpenFileDialog(); + + // directory iniziale + openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath")); + // Set filter options and filter index. + openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*"; + openFileDial.FilterIndex = 1; + // altre opzioni + openFileDial.Multiselect = false; + + // Call the ShowDialog method to show the dialog box. + DialogResult userClickedOK = openFileDial.ShowDialog(); + + // Process input if the user clicked OK. + if (userClickedOK == DialogResult.OK) + { + string iniConfFile = openFileDial.FileName; + loadIniFile(iniConfFile); + lgInfo("INI LOADED"); } } - else + + private void refreshFormData() { - doLog = true; - vetoLogError.Add(logKey, DateTime.Now.AddMinutes(vetoPeriodMin)); + // aggiorno visualizzazioni varie in form... + alQueueLen = iobObj.QueueAlarm.Count; + evQueueLen = iobObj.QueueIN.Count; + flQueueLen = iobObj.QueueFLog.Count; + msQueueLen = iobObj.QueueMessages.Count; + rtrQueueLen = iobObj.QueueRawTransf.Count; + ulQueueLen = iobObj.QueueULog.Count; + // aggiorno labels counters... + counterIob = $"pz IOB {iobObj.contapezziIOB}"; + counterMac = $"pz PLC {iobObj.contapezziPLC}"; + Dictionary setPar = new Dictionary(); + setPar.Add("IP", iobObj.IOBConfFull.Device.Connect.IpAddr); + setPar.Add("PORT", iobObj.IOBConfFull.Device.Connect.Port); + string note = $"{iobObj.IOBConfFull.General.FilenameIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}"; + // verifico IOB status + IobWinStatus currIobStatus = new IobWinStatus() + { + CodIob = iobObj.IOBConfFull.General.FilenameIOB, + IobType = $"{iobObj.IOBConfFull.General.IobType}",//iobObj.cIobConf.tipoIob.ToString(), + queueAlLen = alQueueLen, + queueEvLen = evQueueLen, + queueFlLen = flQueueLen, + queueMsLen = msQueueLen, + queueRawTransfLen = rtrQueueLen, + queueUlLen = ulQueueLen, + counterIOB = iobObj.contapezziIOB, + counterMAC = iobObj.contapezziPLC, + lastUpdate = lastIobStatus.lastUpdate > iobObj.lastWatchDog ? lastIobStatus.lastUpdate : iobObj.lastWatchDog, + online = utils.IOB_Online, + lastDataIn = iobObj.lastReadPLC, + lastDataOut = iobObj.lastIobOnline, + setupParams = setPar, + freeNotes = note + }; + // se diverso SALVO! + if (!currIobStatus.Equals(lastIobStatus)) + { + // aggiorno data + currIobStatus.lastUpdate = DateTime.Now; + // salvo su redis e in obj corrente + iobObj.redisMan.iobStatus = currIobStatus; + lastIobStatus = currIobStatus; + } + // se diverso SALVO MP IO status + if (lastSrvStatus.online != utils.MPIO_Online) + { + // aggiorno + ServerMpStatus currSrvStatus = iobObj.redisMan.servStatus; + currSrvStatus.online = utils.MPIO_Online; + currSrvStatus.lastUpdate = DateTime.Now; + // salvo su redis e in obj corrente + iobObj.redisMan.servStatus = currSrvStatus; + lastSrvStatus = currSrvStatus; + } } - return doLog; - } - - /// - /// Fase chiusura Form - /// - /// - /// - private void MainForm_FormClosing(object sender, FormClosingEventArgs e) - { - lgTrace("MainForm_FormClosing"); - closeAdapter(); - } - - /// - /// Completato resize form - /// - /// - /// - private void MainForm_Resize(object sender, EventArgs e) - { - } - - /// - /// Mostrata form - /// - /// - /// - private void MainForm_Shown(object sender, EventArgs e) - { - displayTaskAndLog("Main Form SHOWN (Adapter)", true); - } - - private void mLoadConf_Click(object sender, EventArgs e) - { - // mostro selettore file x leggere adapter.. - OpenFileDialog openFileDial = new OpenFileDialog(); - - // directory iniziale - openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath")); - // Set filter options and filter index. - openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*"; - openFileDial.FilterIndex = 1; - // altre opzioni - openFileDial.Multiselect = false; - - // Call the ShowDialog method to show the dialog box. - DialogResult userClickedOK = openFileDial.ShowDialog(); - - // Process input if the user clicked OK. - if (userClickedOK == DialogResult.OK) + /// + /// Button restart + /// + /// + /// + private void restart_Click(object sender, EventArgs e) { - string iniConfFile = openFileDial.FileName; - loadIniFile(iniConfFile); - lgInfo("INI LOADED"); + string message = "Attenzione: con l'operazione di reset veranno persi (e non inviati) i dati eventualmente accumulati (indipendentemente dalla selezione del checkbox 'svuota coda')."; + string caption = "Conferma Reset Dati IOB"; + MessageBoxButtons buttons = MessageBoxButtons.YesNo; + DialogResult result; + + // verifica con messagebox + result = MessageBox.Show(message, caption, buttons); + // solo se ho conferma da utente + if (result == DialogResult.Yes) + { + // faccio stop... SENZA inviare + fermaAdapter(false, false, true); + displayTaskAndLog("RESTARTING: Adapter Stopped", true); + // rileggo INI + loadIniFile(defConfFilePath); + displayTaskAndLog("RESTARTING: Ini File Reloaded", true); + // faccio start... CON RESET delle code + avviaAdapter(true); + displayTaskAndLog("RESTARTING: Adapter Started", true); + // resetto i data monitor... + dataMonitor_0 = ""; + dataMonitor_1 = ""; + dataMonitor_2 = ""; + dataMonitor_3 = ""; + } } - } - private void refreshFormData() - { - // aggiorno visualizzazioni varie in form... - alQueueLen = iobObj.QueueAlarm.Count; - evQueueLen = iobObj.QueueIN.Count; - flQueueLen = iobObj.QueueFLog.Count; - msQueueLen = iobObj.QueueMessages.Count; - rtrQueueLen = iobObj.QueueRawTransf.Count; - ulQueueLen = iobObj.QueueULog.Count; - // aggiorno labels counters... - counterIob = $"pz IOB {iobObj.contapezziIOB}"; - counterMac = $"pz PLC {iobObj.contapezziPLC}"; - Dictionary setPar = new Dictionary(); - setPar.Add("IP", iobObj.IOBConfFull.Device.Connect.IpAddr); - setPar.Add("PORT", iobObj.IOBConfFull.Device.Connect.Port); - string note = $"{iobObj.IOBConfFull.General.FilenameIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}"; - // verifico IOB status - IobWinStatus currIobStatus = new IobWinStatus() + private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) { - CodIob = iobObj.IOBConfFull.General.FilenameIOB, - IobType = $"{iobObj.IOBConfFull.General.IobType}",//iobObj.cIobConf.tipoIob.ToString(), - queueAlLen = alQueueLen, - queueEvLen = evQueueLen, - queueFlLen = flQueueLen, - queueMsLen = msQueueLen, - queueRawTransfLen = rtrQueueLen, - queueUlLen = ulQueueLen, - counterIOB = iobObj.contapezziIOB, - counterMAC = iobObj.contapezziPLC, - lastUpdate = lastIobStatus.lastUpdate > iobObj.lastWatchDog ? lastIobStatus.lastUpdate : iobObj.lastWatchDog, - online = utils.IOB_Online, - lastDataIn = iobObj.lastReadPLC, - lastDataOut = iobObj.lastIobOnline, - setupParams = setPar, - freeNotes = note - }; - // se diverso SALVO! - if (!currIobStatus.Equals(lastIobStatus)) - { - // aggiorno data - currIobStatus.lastUpdate = DateTime.Now; - // salvo su redis e in obj corrente - iobObj.redisMan.iobStatus = currIobStatus; - lastIobStatus = currIobStatus; } - // se diverso SALVO MP IO status - if (lastSrvStatus.online != utils.MPIO_Online) + + /// + /// Avvio dell'adapter + /// + /// + /// + private void start_Click(object sender, EventArgs e) { - // aggiorno - ServerMpStatus currSrvStatus = iobObj.redisMan.servStatus; - currSrvStatus.online = utils.MPIO_Online; - currSrvStatus.lastUpdate = DateTime.Now; - // salvo su redis e in obj corrente - iobObj.redisMan.servStatus = currSrvStatus; - lastSrvStatus = currSrvStatus; + avviaAdapter(chkForceDequeue.Checked); + // salvo che ho avviato adapter + lgInfo("Completato LOAD Adapter"); } - } - /// - /// Button restart - /// - /// - /// - private void restart_Click(object sender, EventArgs e) - { - string message = "Attenzione: con l'operazione di reset veranno persi (e non inviati) i dati eventualmente accumulati (indipendentemente dalla selezione del checkbox 'svuota coda')."; - string caption = "Conferma Reset Dati IOB"; - MessageBoxButtons buttons = MessageBoxButtons.YesNo; - DialogResult result; - - // verifica con messagebox - result = MessageBox.Show(message, caption, buttons); - // solo se ho conferma da utente - if (result == DialogResult.Yes) + /// + /// fermata dell'adapter + /// + /// + /// + private void stop_Click(object sender, EventArgs e) { - // faccio stop... SENZA inviare - fermaAdapter(false, false, true); - displayTaskAndLog("RESTARTING: Adapter Stopped", true); - // rileggo INI - loadIniFile(defConfFilePath); - displayTaskAndLog("RESTARTING: Ini File Reloaded", true); - // faccio start... CON RESET delle code - avviaAdapter(true); - displayTaskAndLog("RESTARTING: Adapter Started", true); - // resetto i data monitor... - dataMonitor_0 = ""; - dataMonitor_1 = ""; - dataMonitor_2 = ""; - dataMonitor_3 = ""; + fermaAdapter(false, chkForceDequeue.Checked, true); + // salvo che ho fermato adapter + lgInfo("UNLOAD Adapter"); } - } - private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) - { - } + private void TabData_Selected(object sender, TabControlEventArgs e) + { + } - /// - /// Avvio dell'adapter - /// - /// - /// - private void start_Click(object sender, EventArgs e) - { - avviaAdapter(chkForceDequeue.Checked); - // salvo che ho avviato adapter - lgInfo("Completato LOAD Adapter"); - } + private void toggleEditMes2Plc() + { + // abilita i campi --> PLC per editing + enableEditMes2Plc = !enableEditMes2Plc; + checkEditMes2Plc(); + } - /// - /// fermata dell'adapter - /// - /// - /// - private void stop_Click(object sender, EventArgs e) - { - fermaAdapter(false, chkForceDequeue.Checked, true); - // salvo che ho fermato adapter - lgInfo("UNLOAD Adapter"); - } + private void txtMReadSize_TextChanged(object sender, EventArgs e) + { + checkAssignSize(); + } - private void TabData_Selected(object sender, TabControlEventArgs e) - { - } + private void txtMReadStart_TextChanged(object sender, EventArgs e) + { + checkAssignStart(); + checkAssignSize(); + } - private void toggleEditMes2Plc() - { - // abilita i campi --> PLC per editing - enableEditMes2Plc = !enableEditMes2Plc; - checkEditMes2Plc(); + #endregion Private Methods } - - private void txtMReadSize_TextChanged(object sender, EventArgs e) - { - checkAssignSize(); - } - - private void txtMReadStart_TextChanged(object sender, EventArgs e) - { - checkAssignStart(); - checkAssignSize(); - } - - #endregion Private Methods -} } \ No newline at end of file diff --git a/IOB-WIN-OPC-UA/AdapterFormNext.cs b/IOB-WIN-OPC-UA/AdapterFormNext.cs index a655ee4e..2a550f93 100644 --- a/IOB-WIN-OPC-UA/AdapterFormNext.cs +++ b/IOB-WIN-OPC-UA/AdapterFormNext.cs @@ -119,6 +119,11 @@ namespace IOB_WIN_OPC_UA btnStart.Enabled = true; break; + case tipoAdapter.OpcUaSiemensSW: + iobObj = new IobOpc.OpcUaSiemensSW(this, IOBConfFull); + btnStart.Enabled = true; + break; + case tipoAdapter.OpcUaUlma: iobObj = new IobOpc.OpcUaUlma(this, IOBConfFull); btnStart.Enabled = true; diff --git a/IOB-WIN-OPC-UA/DATA/CONF/1042.json b/IOB-WIN-OPC-UA/DATA/CONF/1042.json index 7bbdb614..0ffd7f31 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/1042.json +++ b/IOB-WIN-OPC-UA/DATA/CONF/1042.json @@ -2,7 +2,7 @@ "BrowseFullVal": "ns=4;s=NxController.GlobalVars", "BrowseNSIndex": 4, "BrowseValue": 5001, - "keyPartCount": "ext_prod_parziale_robot4", + "keyPartCount": "ext_prod_parziale_mes_robot4", "keyPartReq": "", "keyPartId": "", "keyProgName": "", @@ -168,7 +168,7 @@ "ns=4;s=ext_prod_parziale_robot1", "ns=4;s=ext_prod_parziale_robot2", "ns=4;s=ext_prod_parziale_robot3", - "ns=4;s=ext_prod_parziale_robot4", + "ns=4;s=ext_prod_parziale_mes_robot4", "ns=4;s=ext_prod_totale_robot1", "ns=4;s=ext_prod_totale_robot2", "ns=4;s=ext_prod_totale_robot3", diff --git a/IOB-WIN-OPC-UA/DATA/CONF/2016.ini b/IOB-WIN-OPC-UA/DATA/CONF/2016.ini index d522a9b6..d02475ff 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/2016.ini +++ b/IOB-WIN-OPC-UA/DATA/CONF/2016.ini @@ -1,20 +1,20 @@ ;Configurazione IOB-WIN -[IOB] -;Centro di lavoro OpcUa -CNCTYPE=OpcUaSiemens +[IOB] +;Centro di lavoro OpcUa Siemens SW +CNCTYPE=OpcUaSiemensSW ;CNCTYPE=OpcUa PING_MS_TIMEOUT=500 [MACHINE] -VENDOR=EMCO -MODEL=750 +VENDOR=SW Machines +MODEL=1169 [CNC] -IP=192.168.51.216 -PORT=4840 +IP=192.168.51.219 +PORT=51210 GETPRGNAME=true -[SERVER] +[SERVER] MPIP=http://192.168.51.77 MPURL=/MP/IO CMDBASE=/IOB/input/ @@ -71,12 +71,9 @@ ENABLE_CLI_RESTART=TRUE SEND_PZCNT_MODE=DIRECT ;SEND_PZCNT_MODE=TASK VETO_SIG_IN=false -BASE_SAMPLE_PERIOD=600 - DISABLE_SEND_WDST=TRUE - ; conf parametri memoria READ/WRITE -OPC_PARAM_CONF=2015.json +OPC_PARAM_CONF=2016.json [BRANCH] NAME=master diff --git a/IOB-WIN-OPC-UA/DATA/CONF/2016.json b/IOB-WIN-OPC-UA/DATA/CONF/2016.json index e9eb720e..688d5e32 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/2016.json +++ b/IOB-WIN-OPC-UA/DATA/CONF/2016.json @@ -1,31 +1,60 @@ { - "BrowseFullVal": "ns=2;s=Sinumerik", - "BrowseNSIndex": 4, + "BrowseFullVal": "ns=1;s=/swcp-assets", + "BrowseNSIndex": 1, "BrowseValue": 5001, - "keyPartCount": "QUANTITA_PRODOTTA", + "keyPartCount": "", + "isMulti": true, + "keyPartCountTav": { + "TAV1": "MES A PIECE COUNTER", + "TAV2": "MES U PIECE COUNTER" + }, "keyPartReq": "", "keyPartId": "", - "keyProgName": "progName", - "keyRunMode": "acProg", + "keyProgName": "", + "keyRunMode": "", "pingAsPowerOn": true, - "Identity": { - "UserName": "DONATI_1", - "Passwd": "DONATI_1" - }, + "Identity": {}, "condWork": [ { - "keyName": "acProg", - "targetValue": "2" + "keyName": "WarningLight Green", + "targetValue": "True" } ], + "condWorkOpc": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "WarningLight Green", + "targetValue": "True" + } + ] + }, + "condAreaTav1": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "T1 WorkingArea", + "targetValue": "true" + } + ] + }, + "condAreaTav2": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "T2 WorkingArea", + "targetValue": "true" + } + ] + }, "condPowerOn": { }, "condReady": { "checkMode": "AND", "checkList": [ { - "keyName": "acProg", - "targetValue": "3" + "keyName": "WarningLight Blue", + "targetValue": "True" } ] }, @@ -33,8 +62,8 @@ "checkMode": "AND", "checkList": [ { - "keyName": "acProg", - "targetValue": "4" + "keyName": "WarningLight Yellow", + "targetValue": "True" } ] }, @@ -42,8 +71,8 @@ "checkMode": "AND", "checkList": [ { - "keyName": "aStopesi", - "targetValue": "0" + "keyName": "Emergency Stop", + "targetValue": "False" } ] }, @@ -51,8 +80,8 @@ "checkMode": "AND", "checkList": [ { - "keyName": "acProg", - "targetValue": "1" + "keyName": "WarningLight Red", + "targetValue": "True" } ] }, @@ -86,336 +115,147 @@ "paramsContainsThresh": { }, "filterItemsNodeId": [ - "ns=2;s=/Axis", - "ns=2;s=/Bag", - "ns=2;s=/Channel/State/actProgNetTime", - "ns=2;s=/Channel/AuxiliaryFunctions", - "ns=2;s=/Channel/GenericCoupling", - "ns=2;s=/Channel/Diagnose", - "ns=2;s=/Channel/ChannelDiagnose", - "ns=2;s=/Channel/ProtocolEvent", - "ns=2;s=/Channel/ActualFrame", - "ns=2;s=/Channel/BaseFrame", - "ns=2;s=/Channel/ExternFrame", - "ns=2;s=/Channel/GrindingFrame", - "ns=2;s=/Channel/SystemFrame", - "ns=2;s=/Channel/UserFrame", - "ns=2;s=/Channel/Drive", - "ns=2;s=/Channel/Nibbling", - "ns=2;s=/Channel/Parameter", - "ns=2;s=/Channel/ProtectedArea", - "ns=2;s=/Channel/Settings", - "ns=2;s=/Channel/GeometricAxis", - "ns=2;s=/Channel/MachineAxis", - "ns=2;s=/Channel/ProgramModification", - "ns=2;s=/Channel/SelectedFunctions", - "ns=2;s=/Channel/Search", - "ns=2;s=/Channel/InterruptionSearch", - "ns=2;s=/Channel/ProgramPointer", - "ns=2;s=/Channel/LogicalSpindle", - "ns=2;s=/Channel/Compensation", - "ns=2;s=/Channel/SelectedFunctionData", - "ns=2;s=/Channel/CoordSysWorkAreaLimits", - "ns=2;s=/Channel/Configuration", - "ns=2;s=/Channel/Spindle", - "ns=2;s=/DriveVsa", - "ns=2;s=Sinumerik/FileSystem", - "ns=2;s=/Methods", - "ns=2;s=/NC", - "ns=2;s=/NC/_N_NC_GD1_ACX", - "ns=2;s=/NC/_N_NC_GD4_ACX", - "ns=2;s=/NC/_N_CH_GD1_ACX", - "ns=2;s=/NC/_N_CH_GD4_ACX", - "ns=2;s=/HMI", - "ns=2;s=/Random", - "ns=2;s=/SEA", - "ns=2;s=/TEA", - "ns=2;s=/Tool", - "ns=2;s=/Plc/Clock", - "ns=2;s=/Plc/C", - "ns=2;s=/Plc/T", - "ns=2;s=/Plc/I", - "ns=2;s=/Plc/IB", - "ns=2;s=/Plc/IW", - "ns=2;s=/Plc/ID", - "ns=2;s=/Plc/M", - "ns=2;s=/Plc/MB", - "ns=2;s=/Plc/MW", - "ns=2;s=/Plc/MD", - "ns=2;s=/Plc/Q", - "ns=2;s=/Plc/QB", - "ns=2;s=/Plc/QW", - "ns=2;s=/Plc/QD", - "ns=2;s=/Plc/ID", - "ns=2;s=/Plc/ID", - "ns=2;s=IArea", - "ns=2;s=QArea", - "ns=2;s=MArea", - "ns=2;s=/Plc/DB1", - "ns=2;s=/Plc/DB2", - "ns=2;s=/Plc/DB3", - "ns=2;s=/Plc/DB4", - "ns=2;s=/Plc/DB5", - "ns=2;s=/Plc/DB6", - "ns=2;s=/Plc/DB7", - "ns=2;s=/Plc/DB8", - "ns=2;s=/Plc/DB9", - "ns=2;s=/Plc/DB10", - "ns=2;s=/Plc/DB11", - "ns=2;s=/Plc/DB15", - "ns=2;s=/Plc/DB16", - "ns=2;s=/Plc/DB17", - "ns=2;s=/Plc/DB18", - "ns=2;s=/Plc/DB19", - "ns=2;s=/Plc/DB20", - "ns=2;s=/Plc/DB21", - "ns=2;s=/Plc/DB31", - "ns=2;s=/Plc/DB32", - "ns=2;s=/Plc/DB33", - "ns=2;s=/Plc/DB34", - "ns=2;s=/Plc/DB35", - "ns=2;s=/Plc/DB36", - "ns=2;s=/Plc/DB53", - "ns=2;s=/Plc/DB62", - "ns=2;s=/Plc/DB63", - "ns=2;s=/Plc/DB64", - "ns=2;s=/Plc/DB65", - "ns=2;s=/Plc/DB66", - "ns=2;s=/Plc/DB71", - "ns=2;s=/Plc/DB72", - "ns=2;s=/Plc/DB74", - "ns=2;s=/Plc/DB75", - "ns=2;s=/Plc/DB76", - "ns=2;s=/Plc/DB77", - "ns=2;s=/Plc/DB78", - "ns=2;s=/Plc/DB92", - "ns=2;s=/Plc/DB93", - "ns=2;s=/Plc/DB100", - "ns=2;s=/Plc/DB101", - "ns=2;s=/Plc/DB102", - "ns=2;s=/Plc/DB103", - "ns=2;s=/Plc/DB104", - "ns=2;s=/Plc/DB105", - "ns=2;s=/Plc/DB111", - "ns=2;s=/Plc/DB114", - "ns=2;s=/Plc/DB115", - "ns=2;s=/Plc/DB116", - "ns=2;s=/Plc/DB120", - "ns=2;s=/Plc/DB121", - "ns=2;s=/Plc/DB140", - "ns=2;s=/Plc/DB154", - "ns=2;s=/Plc/DB170", - "ns=2;s=/Plc/DB171", - "ns=2;s=/Plc/DB172", - "ns=2;s=/Plc/DB173", - "ns=2;s=/Plc/DB174", - "ns=2;s=/Plc/DB200", - "ns=2;s=/Plc/DB201", - "ns=2;s=/Plc/DB202", - "ns=2;s=/Plc/DB203", - "ns=2;s=/Plc/DB204", - "ns=2;s=/Plc/DB213", - "ns=2;s=/Plc/DB272", - "ns=2;s=/Plc/DB283", - "ns=2;s=/Plc/DB284", - "ns=2;s=/Plc/DB310", - "ns=2;s=/Plc/DB325", - "ns=2;s=/Plc/DB326", - "ns=2;s=/Plc/DB332", - "ns=2;s=/Plc/DB333", - "ns=2;s=/Plc/DB334", - "ns=2;s=/Plc/DB335", - "ns=2;s=/Plc/DB336", - "ns=2;s=/Plc/DB505", - "ns=2;s=/Plc/DB506", - "ns=2;s=/Plc/DB507", - "ns=2;s=/Plc/DB508", - "ns=2;s=/Plc/DB509", - "ns=2;s=/Plc/DB510", - "ns=2;s=/Plc/DB650", - "ns=2;s=/Plc/DB651", - "ns=2;s=/Plc/DB1000", - "ns=2;s=/Plc/DB1001", - "ns=2;s=/Plc/DB1002", - "ns=2;s=/Plc/DB1071", - "ns=2;s=/Plc/DB1072" + "ns=2;s=/Axis" ], "subscribedItems": [ - "ns=2;s=/Channel/State/actParts", - "ns=2;s=/Channel/State/acProg", - "ns=2;s=/Channel/State/oldProgNetTime", - "ns=2;s=/Channel/State/oldProgNetTimeCounter", - "ns=2;s=/Channel/State/chanAlarm", - "ns=2;s=/Channel/State/actTNumber", - "ns=2;s=/Channel/ProgramInfo/selectedWorkPProg", - "ns=2;s=/Channel/ProgramInfo/progName", - "ns=2;s=/Channel/State/acTotalOvr", - "ns=2;s=/Channel/State/feedRateIpoOvr", - "ns=2;s=/Nck/State/aStopesi", - "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_ARTICOLO", - "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_COMMESSA", - "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_PRODOTTA", - "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_RICHIESTA" + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Actual_CycleTime_T1", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Actual_CycleTime_T2", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/AXIS_X_LOAD", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/AXIS_Y1_LOAD", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/AXIS_Z_LOAD", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Emergency_Stop", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/FEEDRATE_OVERRIDE", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_A_PIECE_COUNTER", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_PIECE_TARGET", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_RESET_COUNTER_TRIGGER", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_STRING1", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_STRING2", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_STRING3", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_OPTIONAL_STRING_NAME1", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_OPTIONAL_STRING_NAME2", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_OPTIONAL_STRING_NAME3", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_ORDER_A", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_ORDER_U", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_PIECE_TARGET", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_RESET_COUNTER_TRIGGER", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_STRING1", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_STRING2", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_STRING3", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_U_PIECE_COUNTER", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/NC_PROGRAM_PATH", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/NUMBER_ALARMS", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/OM_AUTO_Activ", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/OM_JOG_Activ", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/OM_MDA_Activ", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/OPERATION_MODE", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/PART_NUMBER", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Producing_Machine", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Producing_Machine_Auto", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/SPINDLE_1_LOAD", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/SPINDLE_2_LOAD", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/SPINDLE_OVERRIDE", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/SYSTEM_OPERATION_TIME", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/T1_WorkingArea", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/T2_WorkingArea", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/TEMPERATURE_ELECTRIC_CABINET", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/TEMPERATURE_HYDRAULIC_OIL", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/TEMPERATURE_SURROUNDING", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Tot_Parts_Counter_NOK", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/Tot_Parts_Counter_OK", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/WORKING_TIME", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/WarningLight_Blue", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/WarningLight_Green", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/WarningLight_Red", + "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/WarningLight_Yellow" ], "mMapWrite": { - "setComm": { - "name": "setComm", - "description": "Commessa", + "setComm#TAV1": { + "name": "setComm#TAV1", + "description": "Commessa TAV1 (A)", "tipoMem": "String", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_COMMESSA", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_ORDER_A", "index": 0, "size": 20 }, - "setArt": { - "name": "setArt", - "description": "Articolo", + "setArt#TAV1": { + "name": "setArt#TAV1", + "description": "Articolo TAV1 (A)", "tipoMem": "String", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_ARTICOLO", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_STRING1", "index": 0, "size": 20 }, - "setPzComm": { - "name": "setPzComm", - "description": "Qty", + "setPzComm#TAV1": { + "name": "setPzComm#TAV1", + "description": "Qty TAV1 (A)", "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_RICHIESTA", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_STRING2", "index": 0, "size": 4 }, - "forceResetPzCount": { - "name": "forceResetPzCount", - "description": "Set Contapezzi", + "forceResetPzCount#TAV1": { + "name": "forceResetPzCount#TAV1", + "description": "Reset Contapezzi TAV1 (A)", "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_PRODOTTA", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_A_RESET_COUNTER_TRIGGER", "index": 0, "size": 4 }, - "forceSetPzCount": { - "name": "forceSetPzCount", - "description": "Set Contapezzi", + "setComm#TAV2": { + "name": "setComm#TAV2", + "description": "Commessa TAV2 (U)", + "tipoMem": "String", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_ORDER_U", + "index": 0, + "size": 20 + }, + "setArt#TAV2": { + "name": "setArt#TAV2", + "description": "Articolo TAV2 (U)", + "tipoMem": "String", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_STRING1", + "index": 0, + "size": 20 + }, + "setPzComm#TAV2": { + "name": "setPzComm#TAV2", + "description": "Qty TAV2 (U)", "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_PRODOTTA", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_STRING2", + "index": 0, + "size": 4 + }, + "forceResetPzCount#TAV2": { + "name": "forceResetPzCount#TAV2", + "description": "Reset Contapezzi TAV2 (U)", + "tipoMem": "Int", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_OUT_U_RESET_COUNTER_TRIGGER", "index": 0, "size": 4 } }, "mMapRead": { - "OPC_Status": { - "name": "OPC_Status", - "description": "Stato", + "OPC_MES_A_PIECE_COUNTER": { + "name": "OPC_MES_A_PIECE_COUNTER", + "description": "Contatore Tavola 1 (A)", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_A_PIECE_COUNTER", "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/acProg", - "index": 0, - "size": 1 + "func": "POINT", + "period": 60, + "factor": 1, + "unit": "#", + "displOrdinal": 1 }, - "OPC_Alarm": { - "name": "OPC_Alarm", - "description": "Allarme", + "OPC_MES_U_PIECE_COUNTER": { + "name": "OPC_MES_U_PIECE_COUNTER", + "description": "Contatore Tavola 1 (U)", + "memAddr": "ns=1;s=/swcp-assets/137eada7-bd15-474d-8aaf-4e6f2f8ea72a/MES_U_PIECE_COUNTER", "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/chanAlarm", - "index": 0, - "size": 1 - }, - "OPC_ToolNum": { - "name": "OPC_ToolNum", - "description": "Tool Number", - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/actTNumber", - "index": 0, - "size": 1 - }, - "OPC_SelProg": { - "name": "OPC_SelProg", - "description": "Prog Selezionato", - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/ProgramInfo/selectedWorkPProg", - "index": 0, - "size": 50 - }, - "OPC_ProgName": { - "name": "OPC_ProgName", - "description": "Nome Programma", - "tipoMem": "String", - "memAddr": "ns=2;s=/Channel/ProgramInfo/progName", - "index": 0, - "size": 50 - }, - "OPC_ActFeedRateOvr": { - "name": "OPC_ActFeedRateOvr", - "description": "FeedRate Act Override", - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/actFeedRateIpoOvr", - "index": 0, - "size": 1 - }, - "OPC_FeedRateOvr": { - "name": "OPC_FeedRateOvr", - "description": "FeedRate Override", - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/feedRateIpoOvr", - "index": 0, - "size": 1 - }, - "OPC_actParts": { - "name": "OPC_actParts", - "description": "Contapezzi", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/actParts", - "index": 0, - "size": 1 - }, - "OPC_oldProgNetTime": { - "name": "OPC_oldProgNetTime", - "description": "Ultimo TCiclo", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/Channel/State/oldProgNetTime", - "index": 0, - "size": 1 - }, - "OPC_QUANTITA_PRODOTTA": { - "name": "OPC_QUANTITA_PRODOTTA", - "description": "QUANTITA PRODOTTA", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_PRODOTTA", - "index": 0, - "size": 1 - }, - - "OPC_QUANTITA_RICHIESTA": { - "name": "OPC_QUANTITA_RICHIESTA", - "description": "QUANTITA RICHIESTA", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/QUANTITA_RICHIESTA", - "index": 0, - "size": 1 - }, - "OPC_CODICE_ARTICOLO": { - "name": "OPC_CODICE_ARTICOLO", - "description": "CODICE ARTICOLO", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_ARTICOLO", - "index": 0, - "size": 1 - }, - "OPC_CODICE_COMMESSA": { - "name": "OPC_CODICE_COMMESSA", - "description": "CODICE_COMMESSA", - "func": "MEDIAN", - "period": 600, - "tipoMem": "Int", - "memAddr": "ns=2;s=/NC/_N_CH_GD2_ACX/CODICE_COMMESSA", - "index": 0, - "size": 1 + "func": "POINT", + "period": 60, + "factor": 1, + "unit": "#", + "displOrdinal": 1 } } } \ No newline at end of file diff --git a/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini b/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini index 0ce8cc30..3fa00a2d 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini +++ b/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini @@ -29,6 +29,6 @@ CLI_INST=SteamWareSim ;STARTLIST=TFT_RAMA_001 ;STARTLIST=SIM_DP_02 ;STARTLIST=1042 -STARTLIST=2015 +STARTLIST=2016 MAXCNC=10 diff --git a/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj b/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj index e4ea96b7..ec98a386 100644 --- a/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj +++ b/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj @@ -165,6 +165,7 @@ + diff --git a/IOB-WIN-OPC-UA/IobOpc/OpcUa.cs b/IOB-WIN-OPC-UA/IobOpc/OpcUa.cs index a72ebd3e..6a17a3cb 100644 --- a/IOB-WIN-OPC-UA/IobOpc/OpcUa.cs +++ b/IOB-WIN-OPC-UA/IobOpc/OpcUa.cs @@ -58,16 +58,6 @@ namespace IOB_WIN_OPC_UA.IobOpc #endregion Public Constructors - /// - /// Recupero programma in lavorazione - /// - /// - public override string getPrgName() - { - string prgName = getDataItemValue(opcUaParams.keyProgName); - return prgName; - } - #region Public Methods /// @@ -442,6 +432,16 @@ namespace IOB_WIN_OPC_UA.IobOpc return outVal; } + /// + /// Recupero programma in lavorazione + /// + /// + public override string getPrgName() + { + string prgName = getDataItemValue(opcUaParams.keyProgName); + return prgName; + } + /// /// Effettua vero processing contapezzi /// @@ -1199,6 +1199,28 @@ namespace IOB_WIN_OPC_UA.IobOpc /// protected bool doByteRead { get; set; } = false; + /// + /// Verifico se abbia TAV 1 attiva... + /// + protected bool hasActiveTav1 + { + get + { + return checkMultiCondition(opcUaParams.condActTav1); + } + } + + /// + /// Verifico se abbia TAV 2 attiva... + /// + protected bool hasActiveTav2 + { + get + { + return checkMultiCondition(opcUaParams.condActTav2); + } + } + /// /// Verifico se abbia ALMENO un errore... /// diff --git a/IOB-WIN-OPC-UA/IobOpc/OpcUaKpwRama.cs b/IOB-WIN-OPC-UA/IobOpc/OpcUaKpwRama.cs index 7ae38f6e..1e15f03e 100644 --- a/IOB-WIN-OPC-UA/IobOpc/OpcUaKpwRama.cs +++ b/IOB-WIN-OPC-UA/IobOpc/OpcUaKpwRama.cs @@ -51,7 +51,7 @@ namespace IOB_WIN_OPC_UA.IobOpc { bool answ; - lgInfo("iobGetSendDossier: Inizio scrittura dati a KepWare"); + lgInfo("iobGetSendOdlDP: Inizio scrittura dati a KepWare"); /*----------------------------------------- * STEPS processo: * - recupero ARTICOLI (solo quelli dei PODL attivi) diff --git a/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensRama.cs b/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensRama.cs index f5bcbe0e..ceda2039 100644 --- a/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensRama.cs +++ b/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensRama.cs @@ -122,7 +122,7 @@ namespace IOB_WIN_OPC_UA.IobOpc { bool answ; - lgInfo("iobGetSendDossier: Inizio scrittura dati a server OPC-UA"); + lgInfo("iobGetSendOdlDP: Inizio scrittura dati a server OPC-UA"); /*----------------------------------------- * STEPS processo: * - recupero ARTICOLI (solo quelli dei PODL attivi) diff --git a/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensSW.cs b/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensSW.cs new file mode 100644 index 00000000..0d7d3474 --- /dev/null +++ b/IOB-WIN-OPC-UA/IobOpc/OpcUaSiemensSW.cs @@ -0,0 +1,223 @@ +using IOB_UT_NEXT; +using IOB_UT_NEXT.Config; +using MapoSDK; +using Newtonsoft.Json; +using Opc.Ua; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Threading.Tasks; +using static IOB_UT_NEXT.CustomObj; + +namespace IOB_WIN_OPC_UA.IobOpc +{ + public class OpcUaSiemensSW : OpcUaSiemens + { + #region Public Constructors + + /// + /// Estende l'init della classe base, impiegando il pacchetto Nuget OPC-UA foundation con la + /// gestione specifica per macchine SW (Donati Lavorazioni) + /// https://github.com/OPCFoundation/UA-.NETStandard + /// + /// Form chiamante + /// Configurazione (v 4.x) + public OpcUaSiemensSW(AdapterFormNext caller, IobConfTree IobConfFull) : base(caller, IobConfFull) + { + sendKeyRichiesta = true; + lgInfo("Avvio OpcUa Siemens versione SW Machines"); + } + + #endregion Public Constructors + + #region Public Methods + +#if false + /// + /// Effettua reset del contapezzi, NON POSSIBILE in questa versione + /// + /// + public override bool resetContapezziPLC() + { + bool answ = false; + // verifico se richiesta è per tav 1 o 2... + Dictionary task2add = new Dictionary(); + task2add.Add("forceResetPzCount#TAV1", $"{0}"); + executeTasks(task2add); + return answ; + } +#endif + + #endregion Public Methods + + #region Protected Methods + + /// + /// Effettua decodifica aree memoria alla bitmap usata x MAPO + /// + protected override void decodeToBaseBitmap() + { + DateTime adesso = DateTime.Now; + // init a zero... + B_input = 0; + + /* ----------------------------------------------------- + * STATE MACHINE 60 STD / SIMULA + gestione doppia tavola + *------------------------------------------------------ + * bitmap MAPO + * B0: POWER_ON + * B1: RUN + * B2: pzCount + * B3: allarme + * B4: manuale + * B5: SlowTC (NON gestito qui) + * B6: warm-up / cool-down / setup + * B7: emergenza ARMATA (1=ok, 0 = premuta) + * B8: TAV 1 attiva (A) + * B9: TAV 2 attiva (U) + ---------------------------------------------------- */ + + // se valido il check ping lo eseguo... altrimenti lo do x buono + bool checkPing = !opcUaParams.pingAsPowerOn; + string currRun = "N.A."; + if (!checkPing) + { + checkPing = (testPingMachine == IPStatus.Success); + } + // bit 0 (poweron) imposto a 1 SE pingo + PowerOn=="ON"... + bool powerOnOk = checkPing && hasPowerOn; + // procedo SOLO SE mi da ping OK... + if (checkPing) + { + B_input = powerOnOk ? 1 : 0; + + procRunMode(ref currRun); + + // salvo running come = working... + isRunning = isWorking; + + // se ho emergenza premuta --> emergenza! + if (hasEStopArmed) + { + B_input += (1 << 7); + } + // se ho emergenza premuta --> emergenza! + if (isWarmUpCoolDown) + { + B_input += (1 << 6); + } + // se ho almeno 1 allarme E NON SONO IN AUTO --> ALARM! + if (hasError) + { + B_input += (1 << 3); + } + if (isWorking) + { + // RUN = LAVORA! + B_input += (1 << 1); + } + else if (powerOnOk && (!isReady || isManual)) + { + // se NON ready --> manual + B_input += (1 << 4); + } + // verifica speciale dei BIT della tavola corrente + if (opcUaParams.isMulti) + { + if (hasActiveTav1) + { + B_input += (1 << 8); + } + if (hasActiveTav2) + { + B_input += (1 << 9); + } + } + } + // se abilitato watchdog... + if (opcUaParams.WatchDog.IsEnabled) + { + if (adesso.Subtract(lastWatchDogPLC).TotalSeconds > 2) + { + lastWatchDogPLC = adesso; + WatchDog++; + WatchDog = WatchDog > opcUaParams.WatchDog.MaxVal ? 0 : WatchDog; + + lgTrace($"WatchDog val: {WatchDog}"); + try + { + WriteValue commWriteVal = new WriteValue(); + commWriteVal.NodeId = new NodeId(opcUaParams.WatchDog.MemConfWrite); + commWriteVal.AttributeId = Attributes.Value; + commWriteVal.Value = new DataValue(); + commWriteVal.Value.Value = WatchDog; + + List nodes2Write = new List(); + nodes2Write.Add(commWriteVal); + + UA_ref.WriteNodes(nodes2Write); + } + catch (Exception exc) + { + lgError($"Eccezione in gestione WatchDog, valore attuale {WatchDog}{Environment.NewLine}{exc}"); + } + } + } + else + { + lgTrace("WatchDog disabilitato"); + } + + // controllo se sono poweroff e se non ho dati buoni da > 2 minuti --> disconnetto + if (!powerOnOk && adesso.Subtract(lastCurrent).TotalMinutes > 2) + { + tryDisconnect(); + } + + // solo se non ho veto check + int vFactor = 2; + if (vetoCheckStatus < adesso) + { + lgDebug($"Stato variabili checkPing: {testPingMachine}"); + // imposto veto per vetoSeconds... + vetoCheckStatus = adesso.AddSeconds(vetoSeconds * vFactor); + } + + // log opzionale! + if (verboseLog) + { + lgDebug($"Trasformazione checkPing: {checkPing} | hasPowerOn: {hasPowerOn} | B_input: {B_input} | currRun = {currRun}"); + } + } + + /// + /// Effettua sync dati inviando info per la doppia tavola + /// + protected override void processDataSync() + { + lgInfo("--------------------------------------------"); + lgInfo($"executeTasks --> syncDbData --> processDataSync"); + lgInfo("--------------------------------------------"); + // effettua sync scrivendo cablate le info x art/num pezzi + dati ODL + var taskGet = iobGetSendOdlDP(); + } + + #endregion Protected Methods + + #region Private Methods + + /// + /// Recupero dati da server x invio dati ODL delle 2 tavole A/U + /// + /// + private bool iobGetSendOdlDP() + { + bool answ = false; + + return answ; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/IOB-WIN-PING/DATA/CONF/3023-PING.ini b/IOB-WIN-PING/DATA/CONF/3023-PING.ini new file mode 100644 index 00000000..cd6c874f --- /dev/null +++ b/IOB-WIN-PING/DATA/CONF/3023-PING.ini @@ -0,0 +1,62 @@ +;Configurazione IOB-WIN +[IOB] +CNCTYPE=PingWatchdog +PING_MS_TIMEOUT=500 +IOB_NAME=3023 + +[MACHINE] +VENDOR=STEAMWARE +MODEL=WATCHDOG + +[CNC] +IP=192.168.1.151 +;IP=192.168.1.7 +PORT=0000 + +[SERVER] +MPIP=http://192.168.1.7 +MPURL=/MP/IO +CMDBASE=/IOB/input/ +CMDFLOG=/IOB/flog/ +CMDALIVE=/IOB +CMDENABLED=/IOB/enabled/ +CMDADV1=?valore= +CMDREBO=/sendReboot.aspx?idxMacchina= +CMD_ODL_STARTED=/IOB/getCurrOdlStart/ +CMD_FORCLE_SPLIT_ODL=/IOB/forceSplitOdlFull/ +CMD_IDLE_TIME=/IOB/getIdlePeriod/ + +[MEMORY] + +[BLINK] +MAX_COUNTER_BLINK = 15 +BLINK_FILT=0 + +[OPTPAR] +timerIntMs=300 +VETO_QUEUE_IN=15 +AUTO_CHANGE_ODL=false +POWEROFF_TIMEOUT_SEC=60 +DISABLE_PZCOUNT=TRUE +;; gestioni PING +;MAX_TRY_PING=3 +;VETO_QUEUE_IN=4 +;VETO_PING_SEC=4 +;VETO_CHECKDIR_SEC=10 +;MAX_ELAPSED_TIME_SEC=60 +;VETO_SEND_SNAPSHOT=3 +VETO_SIG_IN=false +B_IN_OFF=0 +B_IN_ON=129 +VETO_PING_SEC=6 +VETO_SCADUTO=TRUE + +[BRANCH] +NAME=master + +; Tags manuali +[TAGS] +Customer=JETCO +HostOS=WIN +HostName=IOB-WIN-09 +HostAddr=192.168.1.133 diff --git a/IOB-WIN-PING/IOB-WIN-PING.csproj b/IOB-WIN-PING/IOB-WIN-PING.csproj index 21068841..fee41d89 100644 --- a/IOB-WIN-PING/IOB-WIN-PING.csproj +++ b/IOB-WIN-PING/IOB-WIN-PING.csproj @@ -142,9 +142,8 @@ Resources.resx True - - Always - + +