diff --git a/IOB-UT-NEXT/Config/IobConfTree.cs b/IOB-UT-NEXT/Config/IobConfTree.cs index 9272ee07..5ab307ec 100644 --- a/IOB-UT-NEXT/Config/IobConfTree.cs +++ b/IOB-UT-NEXT/Config/IobConfTree.cs @@ -789,6 +789,40 @@ namespace IOB_UT_NEXT.Config } } + // cerco in OPTPAR la conf json del dizionario StepActionList + if (optParRead.ContainsKey("STEP_ACTION_CONF")) + { + string opcParamConf = optParRead["STEP_ACTION_CONF"]; + if (!string.IsNullOrEmpty(opcParamConf)) + { + string jsonStepActFileName = Path.Combine(dirPath, opcParamConf); + if (File.Exists(jsonStepActFileName)) + { + newConfObj.lgInfo($"Apertura file {jsonStepActFileName}"); + using (StreamReader reader = new StreamReader(jsonStepActFileName)) + { + string jsonData = reader.ReadToEnd().Replace("\n", "").Replace("\r", ""); + if (!string.IsNullOrEmpty(jsonData)) + { + newConfObj.lgDebug($"File json composto da {jsonData.Length} caratteri"); + if (newConfObj.Actions == null) + { + newConfObj.Actions = new ActionDto(); + //newConfObj.Actions.StepActionList = new Dictionary(); + try + { + newConfObj.Actions = JsonConvert.DeserializeObject(jsonData); + } + catch (Exception exc) + { + newConfObj.lgError($"Eccezione in decodifica conf json STEP_ACTION_CONF{Environment.NewLine}{exc}"); + } + } + } + } + } + } + } // salvo eventuale memTrace... if (!string.IsNullOrEmpty(fIni.ReadString("OPTPAR", "MEM_2_TRACE", ""))) diff --git a/IOB-UT-NEXT/Config/Special/ActionDto.cs b/IOB-UT-NEXT/Config/Special/ActionDto.cs index d417c6b4..bd08cfee 100644 --- a/IOB-UT-NEXT/Config/Special/ActionDto.cs +++ b/IOB-UT-NEXT/Config/Special/ActionDto.cs @@ -15,5 +15,12 @@ namespace IOB_UT_NEXT.Config.Special /// Configurazione speciale azioni in fase di setup /// public MachineSetupConf SetupConf { get; set; } + + /// + /// Configurazione di un dizionario + /// chiave = action ricevuta + /// valore = elenco di step da eseguire in sequenza + /// + public Dictionary> StepActionList { get; set; } } } diff --git a/IOB-UT-NEXT/Config/Special/StepActionDto.cs b/IOB-UT-NEXT/Config/Special/StepActionDto.cs new file mode 100644 index 00000000..49e8b969 --- /dev/null +++ b/IOB-UT-NEXT/Config/Special/StepActionDto.cs @@ -0,0 +1,57 @@ +using MapoSDK; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IOB_UT_NEXT.Config.Special +{ + /// + /// Definizione di una step action (per effettuare una scrittura sul PLC con eventuale ritardo) + /// + public class StepActionDto + { + + /// + /// Idx Azione (per ordinamento) + /// + public int IdxAct { get; set; } = 0; + + /// + /// Nome azione + /// + public string Name { get; set; } = ""; + + /// + /// Valore composto (a partire da altri valori in mMap),da usare se != null + /// Sostituzione token espressi nel formato [[token]] + /// + public string CompoValMMap { get; set; } = null; + +#if false + /// + /// Valore composto (a partire da altri valori in ProdData),da usare se != null + /// Sostituzione token espressi nel formato [[token]] + /// + public string CompoValProdData { get; set; } = null; +#endif + + /// + /// Valore fix da inviare alla memoria se != null + /// + public string FixVal { get; set; } = null; + + /// + /// Nome valore memoria da usare (OUT/Write) + /// + public string MMapWrite { get; set; } = ""; + + /// + /// Tempo di attesa prima dell'azione (se >0) in ms + /// + public int WaitTimeMs { get; set; } = 0; + } +} diff --git a/IOB-WIN-OPC-UA/DATA/CONF/1042.ini b/IOB-WIN-OPC-UA/DATA/CONF/1042.ini index 955be4db..62dfa719 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/1042.ini +++ b/IOB-WIN-OPC-UA/DATA/CONF/1042.ini @@ -76,6 +76,7 @@ DISABLE_SEND_WDST=TRUE ; conf parametri memoria READ/WRITE OPC_PARAM_CONF=1042.json +;STEP_ACTION_CONF=1042.json [BRANCH] NAME=master diff --git a/IOB-WIN-OPC-UA/DATA/CONF/1042.json b/IOB-WIN-OPC-UA/DATA/CONF/1042.json index 11823f5c..7bbdb614 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/1042.json +++ b/IOB-WIN-OPC-UA/DATA/CONF/1042.json @@ -278,7 +278,7 @@ "name": "OPC_SelProg", "description": "Prog Selezionato", "tipoMem": "Int", - "memAddr": "ns=4;s=ext_codice_lotto", + "memAddr": "ns=4;s=hmi_rcp_dmActive", "index": 0, "size": 50 } diff --git a/IOB-WIN-OPC-UA/DATA/CONF/1042.test.json b/IOB-WIN-OPC-UA/DATA/CONF/1042.test.json new file mode 100644 index 00000000..8361a544 --- /dev/null +++ b/IOB-WIN-OPC-UA/DATA/CONF/1042.test.json @@ -0,0 +1,309 @@ +{ + "BrowseFullVal": "ns=4;s=NxController.GlobalVars", + "BrowseNSIndex": 4, + "BrowseValue": 5001, + "keyPartCount": "ext_prod_parziale_robot4", + "keyPartReq": "", + "keyPartId": "", + "keyProgName": "", + "keyRunMode": "", + "pingAsPowerOn": true, + "Identity": {}, + "condWork": [ + { + "keyName": "rele_ciclo_automatico", + "targetValue": "True" + } + ], + "condPowerOn": { + }, + "condReady": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "rele_automatico", + "targetValue": "True" + } + ] + }, + "condManual": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "rele_manuale", + "targetValue": "True" + } + ] + }, + "condEStop": { + "checkMode": "AND", + "negateValue": false, + "checkList": [ + ] + }, + "condError": { + "checkMode": "AND", + "checkList": [ + { + "keyName": "rele_emergenza", + "targetValue": "True" + } + ] + }, + "condCountEnabled": { + "checkMode": "AND", + "checkList": [] + }, + "condWarmUpCoolDown": { + "checkMode": "OR", + "negateValue": true, + "checkList": [ + ] + }, + "fluxLogVeto": [ + "L2p1CommonVariable" + ], + "itemTranslation": { + "avail": "Machine Available", + "rstat": "Execution Mode", + "mode": "Controller Mode", + "ncprog": "Program Name", + "IO_150": "Qta Prodotta (metri)", + "lpremain": "Qta Richiesta", + "fdovrd": "PATH FEED OVERRIDE", + "rovrd": "PATH RAPID OVERRIDE" + }, + "paramsEndThresh": { + "actFeedRateIpoOvr": 10, + "feedRateIpoOvr": 10 + }, + "paramsContainsThresh": { + }, + "filterItemsNodeId": [ + "ns=4;s=abilitazione_aspiratore", + "ns=4;s=abilitazione_man_aspiratore", + "ns=4;s=ailitazione_apre_cassetti", + "ns=4;s=all_barriere_Triplano", + "ns=4;s=all_batteria_PLC_scarica", + "ns=4;s=all_batteria_ROBOT2_scarica", + "ns=4;s=all_batteria_ROBOT3_scarica", + "ns=4;s=all_batteria_ROBOT4_scarica", + "ns=4;s=all_batteria_ROBOT_scarica", + "ns=4;s=all_blocco_inverter_mgazzion_ruote", + "ns=4;s=all_blocco_inverter_ruote", + "ns=4;s=all_blocco_inverter_ruote_10_11", + "ns=4;s=all_blocco_inverter_ruote_12_13", + "ns=4;s=all_blocco_inverter_ruote_14_15", + "ns=4;s=all_blocco_inverter_ruote_16_17", + "ns=4;s=all_blocco_inverter_ruote_18_1", + "ns=4;s=all_blocco_inverter_ruote_19_20", + "ns=4;s=all_blocco_inverter_ruote_2_3", + "ns=4;s=all_blocco_inverter_ruote_4_5", + "ns=4;s=all_blocco_inverter_ruote_6_7", + "ns=4;s=all_blocco_inverter_ruote_robot2", + "ns=4;s=all_codifica_ruote_errate", + "ns=4;s=all_com_robot", + "ns=4;s=all_com_robot2", + "ns=4;s=all_com_robot3", + "ns=4;s=all_com_robot4", + "ns=4;s=all_condizione_reset", + "ns=4;s=all_Ethernet", + "ns=4;s=all_extracorsa_av_manipolatore", + "ns=4;s=all_extracorsa_ind_manipolatore", + "ns=4;s=all_feedback_contac_su_tavola", + "ns=4;s=all_fine_ciclo_da_robot", + "ns=4;s=all_fine_ciclo_da_robot2", + "ns=4;s=all_fine_ciclo_da_robot3", + "ns=4;s=all_ftc_presenza_pezzo_sporca", + "ns=4;s=all_ftc_presenza_pezzo_sporca_robot2", + "ns=4;s=all_ftc_presenza_pezzo_sporca_robot3", + "ns=4;s=all_ftc_presenza_pezzo_sporca_robot4", + "ns=4;s=all_magazzino_pezzi_fuori_posizione", + "ns=4;s=all_magazzino_ruote_fuori_posizione", + "ns=4;s=all_man_fuor_pos_da_robot", + "ns=4;s=all_man_fuor_pos_da_robot2", + "ns=4;s=all_mancanza_pressione_aria", + "ns=4;s=all_modulo_24Vdc", + "ns=4;s=all_plc", + "ns=4;s=all_porta_cabina_aperta", + "ns=4;s=all_porta_quadro_aperta", + "ns=4;s=all_potenza_ausiliari", + "ns=4;s=all_pulsantiera_mobile_ON", + "ns=4;s=all_rete_ethercat", + "ns=4;s=all_robot2_in_emergenza", + "ns=4;s=all_robot4_in_emergenza", + "ns=4;s=all_robot_in_emergenza", + "ns=4;s=all_scatto_termico_aspiratore", + "ns=4;s=all_scatto_termico_magazzino_pezzi", + "ns=4;s=all_vuoto_da_robot", + "ns=4;s=all_vuoto_da_robot2", + "ns=4;s=all_vuoto_da_robot3", + "ns=4;s=all_vuoto_da_robot4", + "ns=4;s=BarCodeIn", + "ns=4;s=BarCodeOut", + "ns=4;s=Hmi_ListaStringheR17", + "ns=4;s=PM_ActiveEnergy", + "ns=4;s=PM_ActivePower", + "ns=4;s=PM_CorrenteI1", + "ns=4;s=PM_CorrenteI2", + "ns=4;s=PM_CorrenteI3", + "ns=4;s=PM_Frequency", + "ns=4;s=PM_PowerFactor", + "ns=4;s=PM_ReactivePower", + "ns=4;s=PM_TensioneV1", + "ns=4;s=PM_TensioneV1_V2", + "ns=4;s=PM_TensioneV1_V3", + "ns=4;s=PM_TensioneV2", + "ns=4;s=PM_TensioneV2_V3", + "ns=4;s=PM_TensioneV3", + "ns=4;s=produzione" + ], + "subscribedItems": [ + "ns=4;s=ext_codice_lotto", + "ns=4;s=ext_NumPezziora_robot1", + "ns=4;s=ext_NumPezziora_robot2", + "ns=4;s=ext_NumPezziora_robot3", + "ns=4;s=ext_NumPezziora_robot4", + "ns=4;s=ext_popup", + "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_totale_robot1", + "ns=4;s=ext_prod_totale_robot2", + "ns=4;s=ext_prod_totale_robot3", + "ns=4;s=ext_prod_totale_robot4", + "ns=4;s=ext_R17_articolo_da_robot", + "ns=4;s=ext_reset_parziale", + "ns=4;s=ext_stringa1_popup", + "ns=4;s=ext_stringa2_popup", + "ns=4;s=ext_stringa3_popup", + "ns=4;s=Hmi_Rcp_DmActName", + "ns=4;s=InvRuote_10_11_IOut", + "ns=4;s=InvRuote_12_13_IOut", + "ns=4;s=InvRuote_14_15_IOut", + "ns=4;s=InvRuote_16_17_IOut", + "ns=4;s=invRuote_18_1_IOut", + "ns=4;s=InvRuote_19_20_IOut", + "ns=4;s=InvRuote_2_3_IOut", + "ns=4;s=InvRuote_4_5_IOut", + "ns=4;s=InvRuote_6_7_IOut", + "ns=4;s=InvRuote_8_9_IOut", + "ns=4;s=invTavola_IOut", + "ns=4;s=num_pressione_robot2_sv", + "ns=4;s=num_pressione_robot3_sv", + "ns=4;s=num_pressione_robot4_sv", + "ns=4;s=num_pressione_sv", + "ns=4;s=rele_automatico", + "ns=4;s=rele_ciclo_automatico", + "ns=4;s=rele_emergenza", + "ns=4;s=rele_inserzione_pm", + "ns=4;s=rele_manuale", + "ns=4;s=rele_reset_allarmi", + "ns=4;s=ruota_attiva_robot2_sv", + "ns=4;s=ruota_attiva_robot3_sv", + "ns=4;s=ruota_attiva_robot4_sv", + "ns=4;s=ruota_attiva_sv", + "ns=4;s=valore_pressione_robot2_sv", + "ns=4;s=valore_pressione_robot3_sv", + "ns=4;s=valore_pressione_robot4_sv", + "ns=4;s=valore_pressione_sv", + "ns=4;s=velocita_rot2_SV", + "ns=4;s=velocita_rot3_SV", + "ns=4;s=velocita_rot4_SV", + "ns=4;s=velocita_rot_SV" + + ], + "mMapWrite": { + "setComm": { + "name": "setComm", + "description": "Commessa", + "tipoMem": "String", + "memAddr": "ns=4;s=ext_stringa1_popup", + "index": 0, + "size": 20 + }, + "setArt": { + "name": "setArt", + "description": "Articolo", + "tipoMem": "String", + "memAddr": "ns=4;s=ext_stringa2_popup", + "index": 0, + "size": 20 + }, + "setPzComm": { + "name": "setPzComm", + "description": "Qty", + "tipoMem": "Int", + "memAddr": "ns=4;s=ext_stringa3_popup", + "index": 0, + "size": 4 + }, + "showPopup": { + "name": "showPopup", + "description": "Mostra POPUP", + "tipoMem": "Boolean", + "memAddr": "ns=4;s=ext_popup", + "index": 0, + "size": 1 + }, + "processOtherInfo": { + "name": "processOtherInfo", + "description": "Scrittura Commessa + Quantita + Articolo", + "tipoMem": "String", + "memAddr": "ns=4;s=ext_codice_lotto", + "ComposedVal": "[[setComm]] | [[setPzComm]] pz | [[setArt]]", + "index": 0, + "size": 50 + }, + "forceResetPzCount": { + "name": "forceResetPzCount", + "description": "Reset Contapezzi MES", + "tipoMem": "Boolean", + "memAddr": "ns=4;s=ext_reset_parziale", + "index": 0, + "size": 1 + } + }, + "mMapRead": { + "OPC_GTOT": { + "name": "OPC_GTOT", + "description": "Contapezzi globale", + "tipoMem": "Int", + "memAddr": "ns=4;s=ext_prod_totale_robot4", + "index": 0, + "size": 4 + }, + "OPC_SelProg": { + "name": "OPC_SelProg", + "description": "Prog Selezionato", + "tipoMem": "Int", + "memAddr": "ns=4;s=ext_codice_lotto", + "index": 0, + "size": 50 + } + }, + "mMapWriteLink": { + "setArt": "processOtherInfo", + "setComm": "processOtherInfo", + "setPzComm": "processOtherInfo" + }, + "StepActionList": { + "processOtherInfo": [ + { + "IdxAct": 1, + "Name": "Abilita Popup", + "FixVal": "True", + "MMapWrite": "showPopup", + "WaitTimeMs": 0 + }, + { + "IdxAct": 2, + "Name": "Disabilita Popup", + "FixVal": "False", + "MMapWrite": "showPopup", + "WaitTimeMs": 50 + } + ] + } +} \ No newline at end of file diff --git a/IOB-WIN-OPC-UA/IobOpc/OpcUaOmronGhidini.cs b/IOB-WIN-OPC-UA/IobOpc/OpcUaOmronGhidini.cs index e9e7652f..475415c6 100644 --- a/IOB-WIN-OPC-UA/IobOpc/OpcUaOmronGhidini.cs +++ b/IOB-WIN-OPC-UA/IobOpc/OpcUaOmronGhidini.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.NetworkInformation; +using System.Threading; using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace IOB_WIN_OPC_UA.IobOpc @@ -89,11 +90,30 @@ namespace IOB_WIN_OPC_UA.IobOpc reqValue = compoValue, name = pKey }; - // aggiungo! + list2Write.Add(currData); + // aggiungo bit popup + currData = new objItem() + { + uid = "showPopup", + reqValue = "True", + name = "showPopup" + }; + list2Write.Add(currData); + // scrivo! + plcWriteParams(ref list2Write); + + // sctivo nuovo parametro x spegnere popup... + Thread.Sleep(500); + list2Write.Clear(); + currData = new objItem() + { + uid = "showPopup", + reqValue = "False", + name = "showPopup" + }; list2Write.Add(currData); // scrivo! plcWriteParams(ref list2Write); - // valutare se scrivere il bit di show display?!? } } return answ;