From 856c9ec63ec02c689e3829d55e3034a3623d83ab Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 12:31:25 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Accumulo=20valori=20x=20DynData=20SOLO=20SE?= =?UTF-8?q?=20=C3=A8=20connesso=20il=20PLC/CNC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IOB-WIN-NEXT/IobGeneric.cs | 68 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 58c36dc2..ef560e65 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -4239,45 +4239,45 @@ namespace IOB_WIN_NEXT if (connectionOk) { currDynData = getDynData(); + try + { + string sVal = ""; + // se richiesto send diretto... + if (forceSendByIob) + { + // per ogni valore del dizionario mostro ed accodo! + foreach (var item in currDynData) + { + sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value); + // chiamo accodamento... + accodaFLog(sVal, qEncodeFLog(item.Key, item.Value)); + } + } + // altrimenti verifico SE sia cambiato il valore dei DynData... + else if (lastDynDataCtrlVal != currDynData["DYNDATA"]) + { + // salvo! + lastDynDataCtrlVal = currDynData["DYNDATA"]; + // per ogni valore del dizionario mostro ed accodo! + foreach (var item in currDynData) + { + sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value); + // chiamo accodamento... + accodaFLog(sVal, qEncodeFLog(item.Key, item.Value)); + } + } + // salvo array... + lastDynData = currDynData; + } + catch (Exception exc) + { + lgError(exc, "Eccezione in processDynData"); + } } else { lgError("Errore connessione mancante x getDynData"); } - try - { - string sVal = ""; - // se richiesto send diretto... - if (forceSendByIob) - { - // per ogni valore del dizionario mostro ed accodo! - foreach (var item in currDynData) - { - sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value); - // chiamo accodamento... - accodaFLog(sVal, qEncodeFLog(item.Key, item.Value)); - } - } - // altrimenti verifico SE sia cambiato il valore dei DynData... - else if (lastDynDataCtrlVal != currDynData["DYNDATA"]) - { - // salvo! - lastDynDataCtrlVal = currDynData["DYNDATA"]; - // per ogni valore del dizionario mostro ed accodo! - foreach (var item in currDynData) - { - sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value); - // chiamo accodamento... - accodaFLog(sVal, qEncodeFLog(item.Key, item.Value)); - } - } - // salvo array... - lastDynData = currDynData; - } - catch (Exception exc) - { - lgError(exc, "Eccezione in processDynData"); - } } } From bd24fc4032e3017eff66e3f4b6ddf944581da233 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 12:45:18 +0100 Subject: [PATCH 2/8] Modifica simec x invio dati con setParameters x commessa e art --- IOB-WIN-NEXT/IobSiemensSimec.cs | 73 +++++++++++++++++---------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/IOB-WIN-NEXT/IobSiemensSimec.cs b/IOB-WIN-NEXT/IobSiemensSimec.cs index fe8ffca3..78d86f5e 100644 --- a/IOB-WIN-NEXT/IobSiemensSimec.cs +++ b/IOB-WIN-NEXT/IobSiemensSimec.cs @@ -170,55 +170,56 @@ namespace IOB_WIN_NEXT case taskType.setProg: case taskType.sendWatchDogMes2Plc: case taskType.setPzComm: + case taskType.startSetup: + case taskType.stopSetup: taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC"; break; case taskType.setArt: case taskType.setComm: + case taskType.setParameter: saveProdData(item); int byteSize = 0; - // recupero dati da memMap... altrimenti NULLA - if (memMap.mMapWrite.ContainsKey(item.Key)) + // verifico se posso aggiornare valori in memoria... + if (memMap != null && memMap.mMapWrite != null) { - dataConf currMem = memMap.mMapWrite[item.Key]; - byteSize = currMem.size; - memAddrWrite = currMem.memAddr; - MemBlock = new byte[byteSize]; - if (currMem.tipoMem == plcDataType.String) + if (memMap.mMapWrite.ContainsKey(item.Key)) { - saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); + // recupero dati da memMap... altrimenti NULLA + if (memMap.mMapWrite.ContainsKey(item.Key)) + { + dataConf currMem = memMap.mMapWrite[item.Key]; + byteSize = currMem.size; + memAddrWrite = currMem.memAddr; + MemBlock = new byte[byteSize]; + if (currMem.tipoMem == plcDataType.String) + { + saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); + } + else if (currMem.tipoMem == plcDataType.DInt) + { + int valDInt = 0; + int.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt); + } + else if (currMem.tipoMem == plcDataType.Int) + { + short valDInt = 0; + short.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.Int.ToByteArray(valDInt); + } + } + taskVal = item.Value; } - else if (currMem.tipoMem == plcDataType.DInt) + else { - int valDInt = 0; - int.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt); - } - else if (currMem.tipoMem == plcDataType.Int) - { - short valDInt = 0; - short.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.Int.ToByteArray(valDInt); + taskVal = $"NO DATA MEM, SET task: {item.Key} --> {item.Value}"; } } - taskVal = item.Value; - break; - - case taskType.startSetup: - //// processo scrittura BIT su DB150.DBX4.0 - //MemBlock = new byte[1]; - //MemBlock[0] = (byte)1; - //memAddrWrite = "DB150.DBB4"; - break; - - case taskType.stopSetup: - //// processo scrittura BIT su DB150.DBX4.0 - //MemBlock = new byte[1]; - //MemBlock[0] = (byte)0; - //memAddrWrite = "DB150.DBB4"; - break; - - case taskType.setParameter: + else + { + taskVal = $"NO MemMap found, SET task: {item.Key} --> {item.Value}"; + } // richiedo da URL i parametri WRITE da popolare lgInfo("Chiamata processMemWriteRequests"); taskVal = processMemWriteRequests(); From 67d90aa44cdadd0fea9b1716bb971bab515b160b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 12:45:28 +0100 Subject: [PATCH 3/8] update button durante fase upload --- IOB-MAN/IOBManPanel.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/IOB-MAN/IOBManPanel.cs b/IOB-MAN/IOBManPanel.cs index 01eed59f..55028d14 100644 --- a/IOB-MAN/IOBManPanel.cs +++ b/IOB-MAN/IOBManPanel.cs @@ -1282,6 +1282,14 @@ namespace IOB_MAN private async void btnSendLog_Click(object sender, EventArgs e) { + // salvo valori button normali + var stdColor = btnSendLog.BackColor; + var stdText = btnSendLog.Text; + // mostro che sto inviando dati... + btnSendLog.Enabled = false; + btnSendLog.BackColor = Color.OrangeRed; + btnSendLog.Text = "fix directory"; + btnSendLog.Refresh(); // svuoto area temp... string fileName = "LogFiles.zip"; string tempDir = Path.Combine(Application.StartupPath, "temp", "logs"); @@ -1300,6 +1308,8 @@ namespace IOB_MAN string logDir = TargetLogDir; if (dgvManagedItems.SelectedRows.Count > 0) { + btnSendLog.Text = "zip start"; + btnSendLog.Refresh(); // ciclo su row selezionate foreach (DataGridViewRow riga in dgvManagedItems.SelectedRows) { @@ -1326,6 +1336,8 @@ namespace IOB_MAN File.Delete(zipPath); } ZipFile.CreateFromDirectory(tempDir, zipPath); + btnSendLog.Text = "zip end"; + btnSendLog.Refresh(); // ciclo di creazione ticket e upload file try @@ -1365,6 +1377,10 @@ namespace IOB_MAN idxSubLic = 0 }; } + + btnSendLog.Text = "LogSend start"; + btnSendLog.BackColor = Color.DarkOrange; + btnSendLog.Refresh(); var ticketReq = new RestRequest("/api/ticket/sendReq", DataFormat.Json).AddJsonBody(newSuppReq); var ticketResp = await client.PostAsync(ticketReq); @@ -1376,6 +1392,9 @@ namespace IOB_MAN // ... infine INVIA file zip che li contiene... //var fileUploadResp = client.Post(fileUploadReq); var fileUploadResp = await client.PostAsync(fileUploadReq); + btnSendLog.Text = "LogSend end"; + btnSendLog.BackColor = Color.DarkOliveGreen; + btnSendLog.Refresh(); // elimino folder temporanea if (Directory.Exists(tempDir)) @@ -1393,6 +1412,10 @@ namespace IOB_MAN Logging.LogError($"Eccezione in fase gestione REST services{Environment.NewLine}{exc}"); } } + + btnSendLog.BackColor = stdColor; + btnSendLog.Text = stdText; + btnSendLog.Enabled = true; } } } \ No newline at end of file From d680cbd2abdcfd5191f44327d52785761c05e872 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 15:47:29 +0100 Subject: [PATCH 4/8] Inizio modifica setup x gestione UserLog simulato --- IOB-UT-NEXT/Enums.cs | 7 ++- IOB-WIN-NEXT/AdapterForm.Designer.cs | 27 ++++++++- IOB-WIN-NEXT/AdapterForm.cs | 31 +++++++++- IOB-WIN-NEXT/DATA/CONF/MAIN.ini | 2 +- IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini | 7 +++ IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json | 4 +- IOB-WIN-NEXT/IobGeneric.cs | 81 ++++++++++++++++++++++++++- IOB-WIN-NEXT/IobSimula.cs | 40 ++++++++++++- 8 files changed, 191 insertions(+), 8 deletions(-) diff --git a/IOB-UT-NEXT/Enums.cs b/IOB-UT-NEXT/Enums.cs index b5ebaa90..b42c1c45 100644 --- a/IOB-UT-NEXT/Enums.cs +++ b/IOB-UT-NEXT/Enums.cs @@ -483,6 +483,11 @@ namespace IOB_UT_NEXT /// /// INPUT segnali in ingresso (standard base MAPO) /// - SignIN + SignIN, + + /// + /// Salvataggio UserLog (valori log attività utente) + /// + ULog } } \ No newline at end of file diff --git a/IOB-WIN-NEXT/AdapterForm.Designer.cs b/IOB-WIN-NEXT/AdapterForm.Designer.cs index 93084e4c..d5a4057c 100644 --- a/IOB-WIN-NEXT/AdapterForm.Designer.cs +++ b/IOB-WIN-NEXT/AdapterForm.Designer.cs @@ -107,6 +107,8 @@ this.lblOutMessage3 = new System.Windows.Forms.Label(); this.lblOutMessage2 = new System.Windows.Forms.Label(); this.tabData = new System.Windows.Forms.TabControl(); + this.label24 = new System.Windows.Forms.Label(); + this.lblQueueULog = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tabMes.SuspendLayout(); @@ -362,6 +364,8 @@ // panel1 // this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.label24); + this.panel1.Controls.Add(this.lblQueueULog); this.panel1.Controls.Add(this.label19); this.panel1.Controls.Add(this.lblQueueAlarmLen); this.panel1.Controls.Add(this.label13); @@ -380,7 +384,7 @@ this.panel1.Location = new System.Drawing.Point(4, 6); this.panel1.Margin = new System.Windows.Forms.Padding(2); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(343, 231); + this.panel1.Size = new System.Drawing.Size(343, 248); this.panel1.TabIndex = 88; // // label19 @@ -1020,6 +1024,25 @@ this.tabData.TabIndex = 71; this.tabData.Selected += new System.Windows.Forms.TabControlEventHandler(this.TabData_Selected); // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(15, 214); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(85, 13); + this.label24.TabIndex = 94; + this.label24.Text = "ULog Queue len"; + // + // lblQueueULog + // + this.lblQueueULog.AutoSize = true; + this.lblQueueULog.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblQueueULog.Location = new System.Drawing.Point(105, 214); + this.lblQueueULog.Name = "lblQueueULog"; + this.lblQueueULog.Size = new System.Drawing.Size(31, 13); + this.lblQueueULog.TabIndex = 95; + this.lblQueueULog.Text = "###"; + // // AdapterForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1143,5 +1166,7 @@ private System.Windows.Forms.Label lblOutMessage3; private System.Windows.Forms.Label lblOutMessage2; private System.Windows.Forms.TabControl tabData; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.Label lblQueueULog; } } \ No newline at end of file diff --git a/IOB-WIN-NEXT/AdapterForm.cs b/IOB-WIN-NEXT/AdapterForm.cs index d4bf4a68..752724ed 100644 --- a/IOB-WIN-NEXT/AdapterForm.cs +++ b/IOB-WIN-NEXT/AdapterForm.cs @@ -275,6 +275,8 @@ namespace IOB_WIN_NEXT protected int maxMsQueue { get; set; } + protected int maxUlQueue { get; set; } + protected int qAlLen { get; set; } protected int qEvLen { get; set; } @@ -282,12 +284,14 @@ namespace IOB_WIN_NEXT protected int qFlLen { get; set; } protected int qMsLen { get; set; } + + protected int qUlLen { get; set; } protected int totQueue { get { - return qEvLen + qFlLen + qAlLen + qMsLen; + return qEvLen + qFlLen + qAlLen + qMsLen+ qUlLen; } } @@ -639,6 +643,30 @@ namespace IOB_WIN_NEXT } } + public int ulQueueLen + { + set + { + qUlLen = value; + lblQueueULog.Text = qUlLen.ToString(); + showQueueData(); + // se supero max precedente, ed è > 10... loggo! + if (qUlLen > maxUlQueue && qUlLen > 10) + { + maxUlQueue = qUlLen; + lgInfo($"[WARN] Coda UL di {value} record"); + } + else + { + maxUlQueue--; + maxUlQueue = maxUlQueue < qUlLen ? qUlLen : maxUlQueue; + } + } + get + { + return qUlLen; + } + } /// /// Numero max linee da mostrare (da controllo)... /// @@ -1401,6 +1429,7 @@ namespace IOB_WIN_NEXT flQueueLen = iobObj.QueueFLog.Count; alQueueLen = iobObj.QueueAlarm.Count; msQueueLen = iobObj.QueueMessages.Count; + ulQueueLen = iobObj.QueueMessages.Count; // aggiorno labels counters... counterIob = $"pz IOB {iobObj.contapezziIOB}"; counterMac = $"pz PLC {iobObj.contapezziPLC}"; diff --git a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini index af1b9fe2..ce4998e0 100644 --- a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini +++ b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini @@ -74,6 +74,6 @@ CLI_INST=SteamWareSim ;STARTLIST=PING ;STARTLIST=PIZ09 ;STARTLIST=VL25 -STARTLIST=SIMUL_02 +STARTLIST=SIMUL_03 MAXCNC=10 \ No newline at end of file diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini index 6ae178df..1eebacfd 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini @@ -52,6 +52,13 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=true T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=100|1 +; indica simulazione registro scarti +SIM_RS=200|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=300|1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json b/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json index c929fe76..8bfdc204 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json +++ b/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json @@ -44,7 +44,7 @@ }, "PressBH": { "name": "SIM_PressBH", - "description": "Pressione ALTA Bolbole", + "description": "Pressione ALTA Bombole", "tipoMem": "Real", "minVal": 2000, "maxVal": 2300, @@ -52,7 +52,7 @@ }, "PressBL": { "name": "SIM_PressBL", - "description": "Pressione Media Bolbole", + "description": "Pressione Media Bombole", "tipoMem": "Real", "minVal": 2100, "maxVal": 2500, diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index ef560e65..679c8046 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -355,6 +355,11 @@ namespace IOB_WIN_NEXT /// public ConcurrentQueue QueueMessages = new ConcurrentQueue(); + /// + /// Coda valori LOG UTENTE (da non sottocampionare come samples)... + /// + public ConcurrentQueue QueueULog = new ConcurrentQueue(); + /// /// alias booleano false = R /// @@ -2029,6 +2034,7 @@ namespace IOB_WIN_NEXT QueueFLog = new ConcurrentQueue(); QueueAlarm = new ConcurrentQueue(); QueueMessages = new ConcurrentQueue(); + QueueULog = new ConcurrentQueue(); } // imposto contatori blink a zero... i_counters = new int[32]; @@ -2153,6 +2159,75 @@ namespace IOB_WIN_NEXT } } + // + /// Processo la coda UserLog... + /// + private void svuotaCodaULog() + { + // verifico SE la coda abbia dei valori... + if (QueueULog.Count > 0) + { + // invio pacchetto di dati (max da conf) + for (int i = 0; i < nMaxSend; i++) + { + // SE ho qualcosa in coda... + if (QueueULog.Count > 0) + { + string currVal = ""; + if (MPOnline) + { + if (IobOnline) + { + // se ho + di 2 elementi in coda --> uso invio JSON in blocco... + if (QueueULog.Count > 1) + { + List listaValori = new List(); + // se ho + di maxJsonData elementi --> invio un set di dati alla volta + if (QueueULog.Count > maxJsonData) + { + // prendoi primi maxJsonDataValori + for (int j = 0; j < maxJsonData; j++) + { + QueueULog.TryDequeue(out currVal); + listaValori.Add(currVal); + } + sendDataBlock(urlType.ULog, listaValori); + } + else + { + // invio in blocco + listaValori = QueueULog.ToList(); + // invio + sendDataBlock(urlType.ULog, listaValori); + // svuoto! + QueueULog = new ConcurrentQueue(); + } + } + else + { + // INVIO SINGOLO...!!! + QueueULog.TryDequeue(out currVal); + sendToMoonPro(urlType.ULog, currVal); + } + } + else + { + break; + } + } + else + { + break; + } + } + else + { + break; + } + } + } + } + /// /// Cerca di inviare su un altro thread i vari dati accumulati... /// @@ -2183,7 +2258,8 @@ namespace IOB_WIN_NEXT { // invio con thread separato... Task taskSigIN = Task.Run(() => svuotaCodaSignIN()); - Task taskFlog = Task.Run(() => svuotaCodaFLog()); + Task taskFLog = Task.Run(() => svuotaCodaFLog()); + Task taskULog = Task.Run(() => svuotaCodaULog()); } else { @@ -2197,6 +2273,9 @@ namespace IOB_WIN_NEXT raiseRefresh(currDispData); // gestione queue FluxLog (invio, display) svuotaCodaFLog(); + // coda UserLog + svuotaCodaULog(); + // refresh raiseRefresh(currDispData); } // se arrivo è tutto ok... diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 0ff71b08..5323dc17 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -45,6 +45,23 @@ namespace IOB_WIN_NEXT /// protected int cP = 1; + /// + /// Simulazione effettuazione controlli utente + /// + protected simPar simRC; + + /// + /// Simulazione registro scarti utente + /// + protected simPar simRS; + + /// + /// Simulazione registrazione dichiarazioni utente + /// + protected simPar simDich; + + + protected bool disableSimStatus = false; /// @@ -146,6 +163,10 @@ namespace IOB_WIN_NEXT { bool.TryParse(strDisableSim, out disableSimStatus); } + // simulazioni azioni utente + simRC = setupSimPar("SIM_RC"); + simRS = setupSimPar("SIM_RS"); + simDich = setupSimPar("SIM_DICH"); } setParamPlc(); // ricarico da server i dati dei pezzi fatti... @@ -473,6 +494,23 @@ namespace IOB_WIN_NEXT } } + // gestione simulazione utente + if (simRC.wait <= 0) + { + // preparo record controlli... guasto se mi esce un secondo divisibile x 25 + DateTime adesso = DateTime.Now; + bool esitoOk = adesso.Second % 25 == 0 ? false : true; + + // decremento duration + simRC.duration--; + // controllo se sia scaduta la duration... in quel caso reset... + if (simRC.duration <= 0) + { + simRC = setupSimPar("SIM_RC"); + } + } + + // init obj display newDisplayData currDispData = new newDisplayData(); currDispData.counter = contapezziIOB; @@ -482,7 +520,7 @@ namespace IOB_WIN_NEXT } /// - /// Setup aprametri di simulazione per BIT indicato + /// Setup parametri di simulazione per BIT indicato /// /// private simPar setupSimPar(string keyName) From 0199e8364c97d8a2ef66004cb72133a3e857c9ee Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 16:39:59 +0100 Subject: [PATCH 5/8] Continuo integrazione nuova coda ULog --- IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini | 2 + IOB-WIN-NEXT/IobGeneric.cs | 70 +++++++++++++++++++++++++++++ IOB-WIN-NEXT/IobSimula.cs | 44 +++++++++++++++++- 3 files changed, 114 insertions(+), 2 deletions(-) diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini index 1eebacfd..985d0380 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini @@ -58,6 +58,8 @@ SIM_RC=100|1 SIM_RS=200|1 ; indica simulazione dichiarazioni (note) utente SIM_DICH=300|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 ; gestione DynData simulati ENABLE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 679c8046..74b3a0d9 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -1069,6 +1069,11 @@ namespace IOB_WIN_NEXT /// public int counterFLog { get; set; } + /// + /// Contatore x invio dati UserLog + /// + public int counterULog { get; set; } + /// /// Contatore x invio dati SignalIN /// @@ -3284,6 +3289,28 @@ namespace IOB_WIN_NEXT } } + + + /// + /// Accumula in coda i valori USER LOG e logga... + /// + /// VALORE RAW (x display) + /// VALORE già processato con qEncodeULog(...) + public void accodaUserLog(string val, string encodedVal) + { + // mostro dati variati letti... + displayOtherData(val); + // accodo IN PRIMIS al FluxLog --> accodo (valore già formattato)! + QueueULog.Enqueue(encodedVal); + + // loggo! + lgInfo(string.Format("[QUEUE-USER-LOG] {0}", encodedVal)); + counterULog++; + if (counterULog > 9999) + { + counterFLog = 0; + } + } /// /// Accumula in coda i valori Flux Log e logga... /// @@ -4602,6 +4629,22 @@ namespace IOB_WIN_NEXT { } return answ; } + /// + /// Fornisce il valore di UserLog e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont + /// Flusso dati (RC/RS/DI) + /// Valore da inviare + /// + public string qEncodeULog(string flusso, string valore) + { + string answ = ""; + try + { + answ = $"{DateTime.Now:yyyyMMddHHmmssfff}#{flusso}#{valore}#{counterULog}"; + } + catch + { } + return answ; + } /// /// Fornisce il valore di flusso e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont @@ -5095,6 +5138,33 @@ namespace IOB_WIN_NEXT sendToMoonPro(urlType.FLog, currVal); } } + + // svuoto coda ULog + while (QueueULog.Count > 0) + { + List listaValori = new List(); + // se ho + di maxJsonData elementi --> invio un set di dati alla volta + if (QueueULog.Count > maxJsonData) + { + string currVal = ""; + // prendoi primi maxJsonDataValori + for (int i = 0; i < maxJsonData; i++) + { + QueueULog.TryDequeue(out currVal); + listaValori.Add(currVal); + } + sendDataBlock(urlType.ULog, listaValori); + } + else + { + // invio in blocco + listaValori = QueueULog.ToList(); + // invio + sendDataBlock(urlType.ULog, listaValori); + // svuoto! + QueueULog = new ConcurrentQueue(); + } + } } parentForm.displayTaskAndLog("[STOP] Stopping adapter..."); adpTryRestart = false; diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 5323dc17..f00aa48e 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -60,7 +60,10 @@ namespace IOB_WIN_NEXT /// protected simPar simDich; - + /// + /// Matricola OPR simulato + /// + protected int matrOpr = 1; protected bool disableSimStatus = false; @@ -167,6 +170,7 @@ namespace IOB_WIN_NEXT simRC = setupSimPar("SIM_RC"); simRS = setupSimPar("SIM_RS"); simDich = setupSimPar("SIM_DICH"); + int.TryParse(getOptPar("SIM_MATR_OPR"), out matrOpr); } setParamPlc(); // ricarico da server i dati dei pezzi fatti... @@ -500,7 +504,10 @@ namespace IOB_WIN_NEXT // preparo record controlli... guasto se mi esce un secondo divisibile x 25 DateTime adesso = DateTime.Now; bool esitoOk = adesso.Second % 25 == 0 ? false : true; - + string note = esitoOk ? "" : $"SIM Controllo fallito alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + string sVal = $"MatrOpr: {matrOpr} | Esito: {esitoOk} | note: {note}"; + // accodo x invio + accodaUserLog(sVal, qEncodeULog("RC", $"{esitoOk}|{note}")); // decremento duration simRC.duration--; // controllo se sia scaduta la duration... in quel caso reset... @@ -509,6 +516,39 @@ namespace IOB_WIN_NEXT simRC = setupSimPar("SIM_RC"); } } + if (simRS.wait <= 0) + { + // preparo record controlli... guasto se mi esce un secondo divisibile x 25 + DateTime adesso = DateTime.Now; + int causale = adesso.Second % 5; + string note = $"SIM Scarto alle {DateTime.Now:yyyy-MM-dd HH:mm:ss} | causale: {causale}"; + string sVal = $"MatrOpr: {matrOpr} | Causale: {causale} | note: {note}"; + // accodo x invio + accodaUserLog(sVal, qEncodeULog("RS", $"{causale:00}|{note}")); + // decremento duration + simRS.duration--; + // controllo se sia scaduta la duration... in quel caso reset... + if (simRS.duration <= 0) + { + simRS = setupSimPar("SIM_RS"); + } + } + if (simDich.wait <= 0) + { + // preparo record controlli... guasto se mi esce un secondo divisibile x 25 + DateTime adesso = DateTime.Now; + string note = $"SIM Nota automatica alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + string sVal = $"MatrOpr: {matrOpr} | nota: {note}"; + // accodo x invio + accodaUserLog(sVal, qEncodeULog("DI", $"{note}")); + // decremento duration + simDich.duration--; + // controllo se sia scaduta la duration... in quel caso reset... + if (simDich.duration <= 0) + { + simDich = setupSimPar("SIM_DICH"); + } + } // init obj display From 2a643d1df371e7d4d7134da024016b46ca21cebc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 28 Feb 2022 20:07:15 +0100 Subject: [PATCH 6/8] Test modifiche da rivedere, con update SDK --- CVCncLib/CVCncLib.dll | Bin 967680 -> 967680 bytes IOB-UT-NEXT/IOB-UT-NEXT.csproj | 4 +- IOB-UT-NEXT/packages.config | 2 +- IOB-WIN-NEXT/AdapterForm.cs | 2 +- IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini | 1 + IOB-WIN-NEXT/IOB-WIN-NEXT.csproj | 4 +- IOB-WIN-NEXT/IobConfiguration.cs | 22 ++- IOB-WIN-NEXT/IobGeneric.cs | 203 ++++++++++++++++++---------- IOB-WIN-NEXT/IobSimula.cs | 7 +- IOB-WIN-NEXT/packages.config | 2 +- 10 files changed, 165 insertions(+), 82 deletions(-) diff --git a/CVCncLib/CVCncLib.dll b/CVCncLib/CVCncLib.dll index 8774ddab2f784f4ca60153094b900c387d1638ae..0cf7b395aee4469757039e91aeae81751be1ad52 100644 GIT binary patch delta 135 zcmZqZux{wEp3uP}C@q`R*wfm>*xJL?+QZ!1!_wNr+St-cQ#4L-J5q_Yx|!Kd@RBM!lN%4 delta 135 zcmZqZux{wEp3uQEzhQS`V^3=jV`~pnYY%g44@+wgYikc%YY%&C4@YYcXKN2vYY+F< z9v+K@0_#8h3Xq+`?BB=4VOp@n<3{_Hg*-sayZy>SzCV0AAhQ^NfC-3Y7#SE|oa1A7 jv4M{vDA*-+P)c_GkoL-u`C;AB!*mKv* ..\packages\SharpZipLib.1.3.1\lib\net45\ICSharpCode.SharpZipLib.dll - - ..\packages\MapoSDK.6.14.2109.2809\lib\net40\MapoSDK.dll + + ..\packages\MapoSDK.6.14.2202.2819\lib\net40\MapoSDK.dll ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/IOB-UT-NEXT/packages.config b/IOB-UT-NEXT/packages.config index ae2cdab6..857d3932 100644 --- a/IOB-UT-NEXT/packages.config +++ b/IOB-UT-NEXT/packages.config @@ -1,6 +1,6 @@  - + diff --git a/IOB-WIN-NEXT/AdapterForm.cs b/IOB-WIN-NEXT/AdapterForm.cs index 752724ed..246583a3 100644 --- a/IOB-WIN-NEXT/AdapterForm.cs +++ b/IOB-WIN-NEXT/AdapterForm.cs @@ -1139,7 +1139,7 @@ namespace IOB_WIN_NEXT cpuType = fIni.ReadString("CNC", "CPUTYPE", ""), rack = (short)fIni.ReadInteger("CNC", "RACK", 0), slot = (short)fIni.ReadInteger("CNC", "SLOT", 0), - serverData = new serverMapo(fIni.ReadString("SERVER", "MPIP", "::1"), fIni.ReadString("SERVER", "MPURL", "/"), fIni.ReadString("SERVER", "CMDBASE", "/"), fIni.ReadString("SERVER", "CMDFLOG", "/"), fIni.ReadString("SERVER", "CMDALIVE", "/"), fIni.ReadString("SERVER", "CMDENABLED", "/"), fIni.ReadString("SERVER", "CMDREBO", "/"), fIni.ReadString("SERVER", "CMD_ODL_STARTED", "/IOB/getCurrOdlStart/"), fIni.ReadString("SERVER", "CLI_INST", "SW_CLI"), fIni.ReadString("SERVER", "CMD_FORCLE_SPLIT_ODL", "/IOB/forceSplitOdlFull/")), + serverData = new serverMapo(fIni.ReadString("SERVER", "MPIP", "::1"), fIni.ReadString("SERVER", "MPURL", "/MP/IO"), fIni.ReadString("SERVER", "CMDBASE", "/IOB/input/"), fIni.ReadString("SERVER", "CMDFLOG", "/IOB/flog/"), fIni.ReadString("SERVER", "CMDULOG", "/IOB/ulog/"), fIni.ReadString("SERVER", "CMDALIVE", "/"), fIni.ReadString("SERVER", "CMDENABLED", "/"), fIni.ReadString("SERVER", "CMDREBO", "/"), fIni.ReadString("SERVER", "CMD_ODL_STARTED", "/IOB/getCurrOdlStart/"), fIni.ReadString("SERVER", "CLI_INST", "SW_CLI"), fIni.ReadString("SERVER", "CMD_FORCLE_SPLIT_ODL", "/IOB/forceSplitOdlFull/")), MAX_COUNTER_BLINK = Convert.ToInt32(fIni.ReadString("BLINK", "MAX_COUNTER_BLINK", "1")), BLINK_FILT = Convert.ToInt32(fIni.ReadString("BLINK", "BLINK_FILT", "0")), TCMaxDelayFactor = Convert.ToDouble(fIni.ReadString("OPTPAR", "TC_MAX_TC_FACTOR", "1.2").Replace(".", ",")), diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini index 985d0380..a6acdcf0 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini @@ -16,6 +16,7 @@ MPIP=http://10.74.82.218 MPURL=/MP/IO CMDBASE=/IOB/input/ CMDFLOG=/IOB/flog/ +CMDULOG=/IOB/ulog/ CMDALIVE=/IOB CMDENABLED=/IOB/enabled/ CMDADV1=?valore= diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj index 9903147e..4067947f 100644 --- a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj +++ b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj @@ -90,8 +90,8 @@ False ExtLib\krcc.dll - - ..\packages\MapoSDK.6.14.2111.313\lib\net40\MapoSDK.dll + + ..\packages\MapoSDK.6.14.2202.2819\lib\net40\MapoSDK.dll ..\packages\MathNet.Numerics.4.15.0\lib\net461\MathNet.Numerics.dll diff --git a/IOB-WIN-NEXT/IobConfiguration.cs b/IOB-WIN-NEXT/IobConfiguration.cs index a79c864b..98af38be 100644 --- a/IOB-WIN-NEXT/IobConfiguration.cs +++ b/IOB-WIN-NEXT/IobConfiguration.cs @@ -141,12 +141,13 @@ namespace IOB_WIN_NEXT /// URL Base server applicativo /// Comando x invio INPUT /// Comando x invio LOG per FLUSSO generico + /// Comando x invio USER LOG /// Comando x check alive /// Comando x check abilitato /// Comando x reboot /// Comando x check data avvio ODL /// Comando x forzare split ODL - public serverMapo(string MPIP_, string MPURL_ = "/MP/IO", string CMDBASE_ = "/IOB/input/", string CMDFLOG_ = "/IOB/flog/", string CMDALIVE_ = "IOB", string CMDENABLED_ = "/IOB/enabled/", string CMDREBO_ = "/sendReboot.aspx?idxMacchina=", string CMD_ODL_STARTED_ = "/IOB/getCurrOdlStart/", string CLI_INST_ = "SteamWare", string CMD_FORCLE_SPLIT_ODL_ = "/IOB/forceSplitOdlFull/", string CMD_IDLE_TIME_ = "/IOB/getIdlePeriod/") + public serverMapo(string MPIP_, string MPURL_ = "/MP/IO", string CMDBASE_ = "/IOB/input/", string CMDFLOG_ = "/IOB/flog/", string CMDULOG_ = "/IOB/ulog/", string CMDALIVE_ = "IOB", string CMDENABLED_ = "/IOB/enabled/", string CMDREBO_ = "/sendReboot.aspx?idxMacchina=", string CMD_ODL_STARTED_ = "/IOB/getCurrOdlStart/", string CLI_INST_ = "SteamWare", string CMD_FORCLE_SPLIT_ODL_ = "/IOB/forceSplitOdlFull/", string CMD_IDLE_TIME_ = "/IOB/getIdlePeriod/") { if (!string.IsNullOrEmpty(MPIP_)) { @@ -159,6 +160,7 @@ namespace IOB_WIN_NEXT MPURL = MPURL_; CMDBASE = CMDBASE_; CMDFLOG = CMDFLOG_; + CMDULOG = CMDULOG_; if (!string.IsNullOrEmpty(CMDBASE_)) { CMDBASE_JSON = CMDBASE_.Replace("input", "evListJson"); @@ -167,6 +169,10 @@ namespace IOB_WIN_NEXT { CMDFLOG_JSON = CMDFLOG_.Replace("flog", "flogJson"); } + if (!string.IsNullOrEmpty(CMDULOG_)) + { + CMDULOG_JSON = CMDULOG_.Replace("ulog", "ulogJson"); + } CMDALIVE = CMDALIVE_; CMDENABLED = CMDENABLED_; CMDREBO = CMDREBO_; @@ -221,15 +227,25 @@ namespace IOB_WIN_NEXT public string CMDENABLED { get; set; } = ""; /// - /// comando base x LOG di FLUSSSO generico - salvataggio parametri extra sistema MAPO + /// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO /// public string CMDFLOG { get; set; } = ""; /// - /// comando base x LOG di FLUSSSO generico - salvataggio parametri extra sistema MAPO in modalità JSON payload come lista + /// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO in modalità JSON payload come lista /// public string CMDFLOG_JSON { get; set; } = ""; + /// + /// comando base x USER LOG - salvataggio parametri extra sistema MAPO + /// + public string CMDULOG { get; set; } = ""; + + /// + /// comando base x USER LOG - salvataggio parametri extra sistema MAPO in modalità JSON payload come lista + /// + public string CMDULOG_JSON { get; set; } = ""; + /// /// comando base x comando reboot /// diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 74b3a0d9..89702448 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -2230,7 +2230,7 @@ namespace IOB_WIN_NEXT break; } } - } + } } /// @@ -3974,76 +3974,105 @@ namespace IOB_WIN_NEXT string answ = ""; if (elencoValori != null) { - if (tipoUrl == urlType.FLog) + string[] valori; + int counter = 0; + DateTime dtEve = DateTime.Now; + switch (tipoUrl) { - flogData currData = new flogData(); - flogJsonPayload fullObj = new flogJsonPayload(); - fullObj.fluxData = new List(); - string[] valori; - int counter = 0; - DateTime dtEve = DateTime.Now; - // inizio processando ogni valore - foreach (var item in elencoValori) - { - valori = qDecodeIN(item); - //DateTime.TryParse(valori[0], out dtEve); - CultureInfo provider = CultureInfo.InvariantCulture; - DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); - int.TryParse(valori[3], out counter); - currData = new flogData() + case urlType.FLog: + flogData currFlData = new flogData(); + flogJsonPayload fullFlObj = new flogJsonPayload(); + fullFlObj.fluxData = new List(); + // inizio processando ogni valore + foreach (var item in elencoValori) { - flux = valori[1], - valore = valori[2], - dtEve = dtEve, - dtCurr = DateTime.Now, - cnt = counter - }; - fullObj.fluxData.Add(currData); - } - // conversione finale - try - { - answ = JsonConvert.SerializeObject(fullObj); - } - catch (Exception exc) - { - lgError($"Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); - } - } - else - { - evData currData = new evData(); - evJsonPayload fullObj = new evJsonPayload(); - fullObj.eventList = new List(); - string[] valori; - int counter = 0; - DateTime dtEve = DateTime.Now; - // inizio processando ogni valore - foreach (var item in elencoValori) - { - valori = qDecodeIN(item); - //DateTime.TryParse(valori[0], out dtEve); - CultureInfo provider = CultureInfo.InvariantCulture; - DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); - int.TryParse(valori[2], out counter); - currData = new evData() + valori = qDecodeIN(item); + CultureInfo provider = CultureInfo.InvariantCulture; + DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); + int.TryParse(valori[3], out counter); + currFlData = new flogData() + { + flux = valori[1], + valore = valori[2], + dtEve = dtEve, + dtCurr = DateTime.Now, + cnt = counter + }; + fullFlObj.fluxData.Add(currFlData); + } + // conversione finale + try { - valore = valori[1], - dtEve = dtEve, - dtCurr = DateTime.Now, - cnt = counter - }; - fullObj.eventList.Add(currData); - } - // conversione finale - try - { - answ = JsonConvert.SerializeObject(fullObj); - } - catch (Exception exc) - { - lgError($"Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); - } + answ = JsonConvert.SerializeObject(fullFlObj); + } + catch (Exception exc) + { + lgError($"FLog Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); + } + break; + case urlType.SignIN: + evData currSigData = new evData(); + evJsonPayload fullEvObj = new evJsonPayload(); + fullEvObj.eventList = new List(); + // inizio processando ogni valore + foreach (var item in elencoValori) + { + valori = qDecodeIN(item); + CultureInfo provider = CultureInfo.InvariantCulture; + DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); + int.TryParse(valori[2], out counter); + currSigData = new evData() + { + valore = valori[1], + dtEve = dtEve, + dtCurr = DateTime.Now, + cnt = counter + }; + fullEvObj.eventList.Add(currSigData); + } + // conversione finale + try + { + answ = JsonConvert.SerializeObject(fullEvObj); + } + catch (Exception exc) + { + lgError($"SignIN Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); + } + break; + case urlType.ULog: + ulogData currUlData = new ulogData(); + ulogJsonPayload fullUlObj = new ulogJsonPayload(); + fullUlObj.fluxData = new List(); + // inizio processando ogni valore + foreach (var item in elencoValori) + { + valori = qDecodeIN(item); + CultureInfo provider = CultureInfo.InvariantCulture; + DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); + int.TryParse(valori[3], out counter); + currUlData = new ulogData() + { + flux = valori[1], + valore = valori[2], + dtEve = dtEve, + dtCurr = DateTime.Now, + cnt = counter + }; + fullUlObj.fluxData.Add(currUlData); + } + // conversione finale + try + { + answ = JsonConvert.SerializeObject(fullUlObj); + } + catch (Exception exc) + { + lgError($"ULog Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); + } + break; + default: + break; } } return answ; @@ -4964,6 +4993,10 @@ namespace IOB_WIN_NEXT lastUrl = urlInput(queueVal); break; + case urlType.ULog: + lastUrl = urlULog(queueVal); + break; + default: lastUrl = ""; break; @@ -5365,7 +5398,21 @@ namespace IOB_WIN_NEXT public string urlDataBlock(urlType tipoUrl) { // verifico la parte di link "tipoComando" - string tipoComando = tipoUrl == urlType.FLog ? cIobConf.serverData.CMDFLOG_JSON : cIobConf.serverData.CMDBASE_JSON; + string tipoComando = ""; + switch (tipoUrl) + { + case urlType.FLog: + tipoComando = cIobConf.serverData.CMDFLOG_JSON; + break; + case urlType.SignIN: + tipoComando = cIobConf.serverData.CMDBASE_JSON; + break; + case urlType.ULog: + tipoComando = cIobConf.serverData.CMDULOG_JSON; + break; + default: + break; + } // URL base x input string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{tipoComando}{cIobConf.codIOB}"; return answ; @@ -5389,6 +5436,24 @@ namespace IOB_WIN_NEXT return answ; } + /// + /// Fornisce URL di tipo UserLog + /// + /// valore salvato in coda nel formato dtEve#flux#valore#counter + /// + public string urlULog(string queueVal) + { + // URL base x input + string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDULOG}"; + // decodifica valore! + string[] valori = qDecodeIN(queueVal); + // aggiungo macchina e valore... + answ += string.Format(@"{0}?flux={1}&&valore={2}", cIobConf.codIOB, valori[1], valori[2]); + // aggiondo dataOra evento e corrente + contatore... + answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); + return answ; + } + /// /// Fornisce URL INPUT per i parametri richiesti /// diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index f00aa48e..22d98a7e 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -537,10 +537,11 @@ namespace IOB_WIN_NEXT { // preparo record controlli... guasto se mi esce un secondo divisibile x 25 DateTime adesso = DateTime.Now; - string note = $"SIM Nota automatica alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; - string sVal = $"MatrOpr: {matrOpr} | nota: {note}"; + bool esitoOk = adesso.Second % 25 == 0 ? false : true; + string note = esitoOk ? "" : $"SIM Nota automatica alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + string sVal = $"MatrOpr: {matrOpr} | Esito: {esitoOk} | note: {note}"; // accodo x invio - accodaUserLog(sVal, qEncodeULog("DI", $"{note}")); + accodaUserLog(sVal, qEncodeULog("DI", $"{esitoOk}|{note}")); // decremento duration simDich.duration--; // controllo se sia scaduta la duration... in quel caso reset... diff --git a/IOB-WIN-NEXT/packages.config b/IOB-WIN-NEXT/packages.config index 0d438dba..e52e0c09 100644 --- a/IOB-WIN-NEXT/packages.config +++ b/IOB-WIN-NEXT/packages.config @@ -2,7 +2,7 @@ - + From 859a91976f95d38a1c11da9f4fbbae459692122a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 1 Mar 2022 08:56:14 +0100 Subject: [PATCH 7/8] update conf x SIM azioni USER --- IOB-WIN-NEXT/DATA/CONF/SIMUL_01.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_02.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini | 8 ++++---- IOB-WIN-NEXT/DATA/CONF/SIMUL_04.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_05.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_06.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_07.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIMUL_08.ini | 9 +++++++++ IOB-WIN-NEXT/DATA/CONF/SIM_DP_01.ini | 8 ++++++++ IOB-WIN-NEXT/DATA/CONF/SIM_DP_02.ini | 8 ++++++++ 10 files changed, 83 insertions(+), 4 deletions(-) diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_01.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_01.ini index c81f0cca..67eae433 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_01.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_01.ini @@ -58,6 +58,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=true T_ON=7 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=81|1 +; indica simulazione registro scarti +SIM_RS=161|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=261|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_02.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_02.ini index f5b8e830..bca734ed 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_02.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_02.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=82|1 +; indica simulazione registro scarti +SIM_RS=162|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=262|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini index a6acdcf0..08296d7e 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_03.ini @@ -49,16 +49,16 @@ SIM_SLOW=4000|20 SIM_WUCD=8000|20 ; indica gestione e simulazione bit 7 --> emergenza SIM_EMRG=4000|10 -; indica simulazione delle funzionalit� power ON/ OFF +; indica simulazione delle funzionalita power ON/ OFF SIM_POW_ON_OFF=true T_ON=6 T_OFF=22 ; indica simulazione controlli utente -SIM_RC=100|1 +SIM_RC=83|1 ; indica simulazione registro scarti -SIM_RS=200|1 +SIM_RS=163|1 ; indica simulazione dichiarazioni (note) utente -SIM_DICH=300|1 +SIM_DICH=263|1 ; indica matricola opr simulata SIM_MATR_OPR=1 diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_04.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_04.ini index 1da5e19a..403966e7 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_04.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_04.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=84|1 +; indica simulazione registro scarti +SIM_RS=164|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=264|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_05.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_05.ini index 301b6238..050dbbc5 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_05.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_05.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=85|1 +; indica simulazione registro scarti +SIM_RS=165|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=265|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_06.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_06.ini index 859e1f1b..4e62781a 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_06.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_06.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=86|1 +; indica simulazione registro scarti +SIM_RS=166|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=266|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_07.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_07.ini index ef7152de..344cbac7 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_07.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_07.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=87|1 +; indica simulazione registro scarti +SIM_RS=167|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=267|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIMUL_08.ini b/IOB-WIN-NEXT/DATA/CONF/SIMUL_08.ini index d7b32c85..6acfc014 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIMUL_08.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIMUL_08.ini @@ -52,6 +52,15 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=88|1 +; indica simulazione registro scarti +SIM_RS=168|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=268|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 + ; gestione DynData simulati ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE diff --git a/IOB-WIN-NEXT/DATA/CONF/SIM_DP_01.ini b/IOB-WIN-NEXT/DATA/CONF/SIM_DP_01.ini index 41d5792c..e94ec473 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIM_DP_01.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIM_DP_01.ini @@ -61,6 +61,14 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=true T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=81|1 +; indica simulazione registro scarti +SIM_RS=161|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=261|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 [BRANCH] diff --git a/IOB-WIN-NEXT/DATA/CONF/SIM_DP_02.ini b/IOB-WIN-NEXT/DATA/CONF/SIM_DP_02.ini index c6f7b315..ed26ab45 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIM_DP_02.ini +++ b/IOB-WIN-NEXT/DATA/CONF/SIM_DP_02.ini @@ -61,6 +61,14 @@ SIM_EMRG=4000|10 SIM_POW_ON_OFF=false T_ON=6 T_OFF=22 +; indica simulazione controlli utente +SIM_RC=82|1 +; indica simulazione registro scarti +SIM_RS=162|1 +; indica simulazione dichiarazioni (note) utente +SIM_DICH=262|1 +; indica matricola opr simulata +SIM_MATR_OPR=1 [BRANCH] From da6e3a77f414def0376bb3f795c4bc8d9a91c7d4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 1 Mar 2022 08:56:34 +0100 Subject: [PATCH 8/8] modifica x invio dati ULog x iobGen + iobSim --- IOB-WIN-NEXT/IobGeneric.cs | 252 +++++++++++++++++++------------------ IOB-WIN-NEXT/IobSimula.cs | 71 ++++++----- 2 files changed, 167 insertions(+), 156 deletions(-) diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 89702448..75198d69 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -1069,16 +1069,16 @@ namespace IOB_WIN_NEXT /// public int counterFLog { get; set; } - /// - /// Contatore x invio dati UserLog - /// - public int counterULog { get; set; } - /// /// Contatore x invio dati SignalIN /// public int counterSigIN { get; set; } + /// + /// Contatore x invio dati UserLog + /// + public int counterULog { get; set; } + /// /// Verifica se sia in modalità DEMO --> da tipo IOB SIMULA... /// @@ -2183,36 +2183,26 @@ namespace IOB_WIN_NEXT { if (IobOnline) { - // se ho + di 2 elementi in coda --> uso invio JSON in blocco... - if (QueueULog.Count > 1) + List listaValori = new List(); + // se ho + di maxJsonData elementi --> invio un set di dati alla volta + if (QueueULog.Count > maxJsonData) { - List listaValori = new List(); - // se ho + di maxJsonData elementi --> invio un set di dati alla volta - if (QueueULog.Count > maxJsonData) + // prendoi primi maxJsonDataValori + for (int j = 0; j < maxJsonData; j++) { - // prendoi primi maxJsonDataValori - for (int j = 0; j < maxJsonData; j++) - { - QueueULog.TryDequeue(out currVal); - listaValori.Add(currVal); - } - sendDataBlock(urlType.ULog, listaValori); - } - else - { - // invio in blocco - listaValori = QueueULog.ToList(); - // invio - sendDataBlock(urlType.ULog, listaValori); - // svuoto! - QueueULog = new ConcurrentQueue(); + QueueULog.TryDequeue(out currVal); + listaValori.Add(currVal); } + sendDataBlock(urlType.ULog, listaValori); } else { - // INVIO SINGOLO...!!! - QueueULog.TryDequeue(out currVal); - sendToMoonPro(urlType.ULog, currVal); + // invio in blocco + listaValori = QueueULog.ToList(); + // invio + sendDataBlock(urlType.ULog, listaValori); + // svuoto! + QueueULog = new ConcurrentQueue(); } } else @@ -2540,6 +2530,38 @@ namespace IOB_WIN_NEXT return answ; } + /// + /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + protected void lgDebug(string message, bool sendToForm = true) + { + //if (isVerboseLog) + //{ + lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; + lg.Debug(message); + if (sendToForm) + { + sendToLogWatch("DEBUG", message); + } + //} + } + + /// + /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + /// + protected void lgDebug(string message, params object[] args) + { + //if (isVerboseLog) + //{ + lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; + lg.Debug(message, args); + sendToLogWatch("DEBUG", message, args); + //} + } + /// /// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere... /// @@ -2669,36 +2691,6 @@ namespace IOB_WIN_NEXT lg.Trace(message, args); sendToLogWatch("INFO", message, args); } - /// - /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - protected void lgDebug(string message, bool sendToForm = true) - { - //if (isVerboseLog) - //{ - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; - lg.Debug(message); - if (sendToForm) - { - sendToLogWatch("DEBUG", message); - } - //} - } - /// - /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - /// - protected void lgDebug(string message, params object[] args) - { - //if (isVerboseLog) - //{ - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; - lg.Debug(message, args); - sendToLogWatch("DEBUG", message, args); - //} - } /// /// Legge il file di conf di una MAP di informazioni da gestire con lettura set memoria @@ -3289,28 +3281,6 @@ namespace IOB_WIN_NEXT } } - - - /// - /// Accumula in coda i valori USER LOG e logga... - /// - /// VALORE RAW (x display) - /// VALORE già processato con qEncodeULog(...) - public void accodaUserLog(string val, string encodedVal) - { - // mostro dati variati letti... - displayOtherData(val); - // accodo IN PRIMIS al FluxLog --> accodo (valore già formattato)! - QueueULog.Enqueue(encodedVal); - - // loggo! - lgInfo(string.Format("[QUEUE-USER-LOG] {0}", encodedVal)); - counterULog++; - if (counterULog > 9999) - { - counterFLog = 0; - } - } /// /// Accumula in coda i valori Flux Log e logga... /// @@ -3384,6 +3354,27 @@ namespace IOB_WIN_NEXT } } + /// + /// Accumula in coda i valori USER LOG e logga... + /// + /// VALORE RAW (x display) + /// VALORE già processato con qEncodeULog(...) + public void accodaUserLog(string val, string encodedVal) + { + // mostro dati variati letti... + displayOtherData(val); + // accodo IN PRIMIS al FluxLog --> accodo (valore già formattato)! + QueueULog.Enqueue(encodedVal); + + // loggo! + lgInfo(string.Format("[QUEUE-USER-LOG] {0}", encodedVal)); + counterULog++; + if (counterULog > 9999) + { + counterFLog = 0; + } + } + /// /// Update visualizzaizone BIT in ingresso /// Parametri da aggiornare x display in form @@ -4010,6 +4001,7 @@ namespace IOB_WIN_NEXT lgError($"FLog Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); } break; + case urlType.SignIN: evData currSigData = new evData(); evJsonPayload fullEvObj = new evJsonPayload(); @@ -4040,7 +4032,10 @@ namespace IOB_WIN_NEXT lgError($"SignIN Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); } break; + case urlType.ULog: + int numVal = 0; + int matrOp = 0; ulogData currUlData = new ulogData(); ulogJsonPayload fullUlObj = new ulogJsonPayload(); fullUlObj.fluxData = new List(); @@ -4050,14 +4045,19 @@ namespace IOB_WIN_NEXT valori = qDecodeIN(item); CultureInfo provider = CultureInfo.InvariantCulture; DateTime.TryParseExact(valori[0], "yyyyMMddHHmmssfff", provider, DateTimeStyles.AssumeLocal, out dtEve); - int.TryParse(valori[3], out counter); + int.TryParse(valori[3], out matrOp); + int.TryParse(valori[5], out numVal); + int.TryParse(valori[6], out counter); currUlData = new ulogData() { flux = valori[1], valore = valori[2], dtEve = dtEve, dtCurr = DateTime.Now, - cnt = counter + cnt = counter, + matrOpr = matrOp, + label = valori[4], + valNum = numVal }; fullUlObj.fluxData.Add(currUlData); } @@ -4071,6 +4071,7 @@ namespace IOB_WIN_NEXT lgError($"ULog Errore in costruzione jsonPayload:{Environment.NewLine}{exc}"); } break; + default: break; } @@ -4643,27 +4644,12 @@ namespace IOB_WIN_NEXT } /// - /// Fornisce il valore di flusso e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont + /// Fornisce il valore di flusso e valore in formato valido x messa in coda nel formato + /// dtEve#flusso#valore#cont /// Flusso dati /// Valore da salvare /// public string qEncodeFLog(string flusso, string valore) - { - string answ = ""; - try - { - answ = string.Format("{0:yyyyMMddHHmmssfff}#{1}#{2}#{3}", DateTime.Now, flusso, valore, counterFLog); - } - catch - { } - return answ; - } - /// - /// Fornisce il valore di UserLog e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont - /// Flusso dati (RC/RS/DI) - /// Valore da inviare - /// - public string qEncodeULog(string flusso, string valore) { string answ = ""; try @@ -4686,7 +4672,28 @@ namespace IOB_WIN_NEXT string answ = ""; try { - answ = string.Format("{0:yyyyMMddHHmmssfff}#{1}#{2}#{3}", eventDT, flusso, valore, counterFLog); + answ = $"{eventDT:yyyyMMddHHmmssfff}#{flusso}#{valore}#{counterFLog}"; + } + catch + { } + return answ; + } + + /// + /// Fornisce il valore di UserLog e valore in formato valido x messa in coda nel formato: + /// dtEve#flusso#value#cont#matrOpr#label#valNum + /// Flusso dati (RC/RS/DI) + /// Valore da inviare (valString + /// Matricola operatore + /// Valore etichetta: causale scarto / tagCode + /// Valore numerico: esitoOk (0/1) / nuo scarti + /// + public string qEncodeULog(string flusso, string valore, int matrOpr, string label, int valNum) + { + string answ = ""; + try + { + answ = $"{DateTime.Now:yyyyMMddHHmmssfff}#{flusso}#{valore}#{matrOpr}#{label}#{valNum}#{counterULog}"; } catch { } @@ -4993,10 +5000,6 @@ namespace IOB_WIN_NEXT lastUrl = urlInput(queueVal); break; - case urlType.ULog: - lastUrl = urlULog(queueVal); - break; - default: lastUrl = ""; break; @@ -5404,12 +5407,15 @@ namespace IOB_WIN_NEXT case urlType.FLog: tipoComando = cIobConf.serverData.CMDFLOG_JSON; break; + case urlType.SignIN: tipoComando = cIobConf.serverData.CMDBASE_JSON; break; + case urlType.ULog: tipoComando = cIobConf.serverData.CMDULOG_JSON; break; + default: break; } @@ -5436,24 +5442,6 @@ namespace IOB_WIN_NEXT return answ; } - /// - /// Fornisce URL di tipo UserLog - /// - /// valore salvato in coda nel formato dtEve#flux#valore#counter - /// - public string urlULog(string queueVal) - { - // URL base x input - string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDULOG}"; - // decodifica valore! - string[] valori = qDecodeIN(queueVal); - // aggiungo macchina e valore... - answ += string.Format(@"{0}?flux={1}&&valore={2}", cIobConf.codIOB, valori[1], valori[2]); - // aggiondo dataOra evento e corrente + contatore... - answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); - return answ; - } - /// /// Fornisce URL INPUT per i parametri richiesti /// @@ -5472,6 +5460,24 @@ namespace IOB_WIN_NEXT return answ; } + /// + /// Fornisce URL di tipo UserLog + /// + /// valore salvato in coda nel formato dtEve#flux#valore#counter + /// + public string urlULog(string queueVal) + { + // URL base x input + string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDULOG}"; + // decodifica valore! + string[] valori = qDecodeIN(queueVal); + // aggiungo macchina e valore... + answ += string.Format(@"{0}?flux={1}&&valore={2}", cIobConf.codIOB, valori[1], valori[2]); + // aggiondo dataOra evento e corrente + contatore... + answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); + return answ; + } + #endregion Public Methods } diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 22d98a7e..2c4046a6 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -45,26 +45,6 @@ namespace IOB_WIN_NEXT /// protected int cP = 1; - /// - /// Simulazione effettuazione controlli utente - /// - protected simPar simRC; - - /// - /// Simulazione registro scarti utente - /// - protected simPar simRS; - - /// - /// Simulazione registrazione dichiarazioni utente - /// - protected simPar simDich; - - /// - /// Matricola OPR simulato - /// - protected int matrOpr = 1; - protected bool disableSimStatus = false; /// @@ -77,6 +57,11 @@ namespace IOB_WIN_NEXT /// protected DateTime lastSimData; + /// + /// Matricola OPR simulato + /// + protected int matrOpr = 1; + /// /// Durata minima ODL x reset quando pezzi iob > pezzi macchina... /// @@ -97,11 +82,26 @@ namespace IOB_WIN_NEXT /// protected bool sigPzCount = false; + /// + /// Simulazione registrazione dichiarazioni utente + /// + protected simPar simDich; + /// /// BOOL: indica se simulare powerOn/Off (bit 0 e 1) compresi WarmUp e CoolDown /// protected bool simPowerOnOff; + /// + /// Simulazione effettuazione controlli utente + /// + protected simPar simRC; + + /// + /// Simulazione registro scarti utente + /// + protected simPar simRS; + /// /// Tempo di MINIMO attesa x simulazione parametri /// @@ -503,11 +503,11 @@ namespace IOB_WIN_NEXT { // preparo record controlli... guasto se mi esce un secondo divisibile x 25 DateTime adesso = DateTime.Now; - bool esitoOk = adesso.Second % 25 == 0 ? false : true; - string note = esitoOk ? "" : $"SIM Controllo fallito alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; - string sVal = $"MatrOpr: {matrOpr} | Esito: {esitoOk} | note: {note}"; + int esitoNum = adesso.Second % 25 == 0 ? 0 : 1; + string note = esitoNum == 1 ? "" : $"SIM Controllo fallito alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + string sVal = $"MatrOpr: {matrOpr} | Esito: {esitoNum} | note: {note}"; // accodo x invio - accodaUserLog(sVal, qEncodeULog("RC", $"{esitoOk}|{note}")); + accodaUserLog(sVal, qEncodeULog("RC", note, matrOpr, "", esitoNum)); // decremento duration simRC.duration--; // controllo se sia scaduta la duration... in quel caso reset... @@ -520,11 +520,13 @@ namespace IOB_WIN_NEXT { // preparo record controlli... guasto se mi esce un secondo divisibile x 25 DateTime adesso = DateTime.Now; - int causale = adesso.Second % 5; - string note = $"SIM Scarto alle {DateTime.Now:yyyy-MM-dd HH:mm:ss} | causale: {causale}"; + int causaleInt = adesso.Second % 7 + 1; + int numSca = adesso.Second % 5 + 1; + string causale = $"{causaleInt:00}"; + string note = $"SIM Scarto [{causale} x {numSca}] {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; string sVal = $"MatrOpr: {matrOpr} | Causale: {causale} | note: {note}"; // accodo x invio - accodaUserLog(sVal, qEncodeULog("RS", $"{causale:00}|{note}")); + accodaUserLog(sVal, qEncodeULog("RS", note, matrOpr, causale, numSca)); // decremento duration simRS.duration--; // controllo se sia scaduta la duration... in quel caso reset... @@ -535,13 +537,14 @@ namespace IOB_WIN_NEXT } if (simDich.wait <= 0) { - // preparo record controlli... guasto se mi esce un secondo divisibile x 25 + // preparo record dichiarazione... DateTime adesso = DateTime.Now; - bool esitoOk = adesso.Second % 25 == 0 ? false : true; - string note = esitoOk ? "" : $"SIM Nota automatica alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; - string sVal = $"MatrOpr: {matrOpr} | Esito: {esitoOk} | note: {note}"; + bool recLogin = adesso.Second % 5 == 0 ? false : true; + string note = recLogin ? "SIM Login Utente STEAMWARE USER" : $"SIM Nota automatica alle {DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + string codTag = recLogin ? "UserLogin" : "Note"; + string sVal = $"MatrOpr: {matrOpr} | codTag: {codTag} | note: {note}"; // accodo x invio - accodaUserLog(sVal, qEncodeULog("DI", $"{esitoOk}|{note}")); + accodaUserLog(sVal, qEncodeULog("DI", note, matrOpr, codTag, 0)); // decremento duration simDich.duration--; // controllo se sia scaduta la duration... in quel caso reset... @@ -551,7 +554,6 @@ namespace IOB_WIN_NEXT } } - // init obj display newDisplayData currDispData = new newDisplayData(); currDispData.counter = contapezziIOB; @@ -883,6 +885,9 @@ namespace IOB_WIN_NEXT bit3.wait--; bit4.wait--; bit5.wait--; + simDich.wait--; + simRC.wait--; + simRS.wait--; lastEvCheck = DateTime.Now; } }