From 0359ac17352f45d375e5b28f197c64f8dbaa8f98 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Sat, 7 Mar 2020 11:10:35 +0100 Subject: [PATCH] update comportamento x mantenere ordinato elenco IOB --- CVCncLib/CVCncLib.dll | Bin 967680 -> 967680 bytes IOB-MAN/IOBManPanel.cs | 45 ++++++++++++++++++++++++----------------- Jenkinsfile | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CVCncLib/CVCncLib.dll b/CVCncLib/CVCncLib.dll index 2b661b518603055e69449845629fbbc48d8ab63f..2f28006799b1f3c48c774cbadc077336f8ec2512 100644 GIT binary patch delta 134 zcmZqZux{wEp3uSku{)`;yS1CKwVSE6o4K`{rL~*2wVSQAo4vK0qqUo}wVSK8n|o_F zkL5xE4voF}PqsBWtTvT6C(&@vt^LYE9w6r3eq|xwA3mKA-AQo_K)?jVGK>riFV68X lyx73U5ESeZ{CU^h&gYx*oi?9aBmDlo-|y{zHt?|s0{}@-P+CA+RfD3&D`3}(%Q}1+RfJ5&EDG0(b~<~+RfG4&Aqjo z$8w>-JV&KR*JV>Yw(sP-X69um+kRys4-oTizp{|;51&qBS9}};5HJC;3?l=>i*tMo kFE;Qo1O>YUA6s~@_)nv<+rphD9&VC9lD7ZZz{esC0J_UFsQ>@~ diff --git a/IOB-MAN/IOBManPanel.cs b/IOB-MAN/IOBManPanel.cs index 34f9281d..62d31704 100644 --- a/IOB-MAN/IOBManPanel.cs +++ b/IOB-MAN/IOBManPanel.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using SteamWare.Logger; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Diagnostics; using System.Drawing; @@ -200,7 +201,6 @@ namespace IOB_MAN private void ElencoIOB_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { - //updateStatus(); } private void ElencoIOB_AddingNew(object sender, System.ComponentModel.AddingNewEventArgs e) @@ -274,7 +274,8 @@ namespace IOB_MAN /// Avvio di un child process da parametro ARG /// /// - private void startChildProc(string procArg) + /// + private void startChildProc(string procArg, int indice = -1) { ProcessStartInfo psi = null; // da testare x aprire chiudere risorsa... @@ -296,9 +297,15 @@ namespace IOB_MAN newIob.startTime = adesso; newIob.pID = p.Id; newIob.isRunning = true; - // aggiungo a datasource - ElencoIOB.Add(newIob); - + // aggiungo a datasource, se indice -1 aggiungendo e basta, altrimenti alla posizione richiesta... + if (indice == -1) + { + ElencoIOB.Add(newIob); + } + else + { + ElencoIOB.Insert(indice, newIob); + } utils.lgInfo($"Avviato child process per {procArg} | pid: {p.Id}"); } @@ -449,21 +456,23 @@ namespace IOB_MAN private void processAutoRestart() { // verifico se ci siano processi (da ARGS LIST) NON running --> li riavvio! - List proc2restart = new List(); - List proc2close = new List(); + Dictionary proc2restart = new Dictionary(); + Dictionary proc2close = new Dictionary(); + int indice = 0; foreach (iobAdapt item in ElencoIOB.List) { // se NON comunica da troppo (ultima comunicazione è > 5 minuti fa...) if (!item.plcOk) { - proc2close.Add(item); + proc2close.Add(indice, item); } // se NON E' running if (!item.isRunning) { // segno da eliminare e riavviare - proc2restart.Add(item); + proc2restart.Add(indice, item); } + indice++; } // SE abilitato autorestart... @@ -473,26 +482,26 @@ namespace IOB_MAN foreach (var item in proc2close) { ElencoIOB.Remove(item); - utils.lgInfo($"Chiusura processo non in PLC-Online | IOB: {item.CodIOB} | pid: {item.pID}"); + utils.lgInfo($"Chiusura processo non in PLC-Online | IOB: {item.Value.CodIOB} | pid: {item.Value.pID}"); // chiudo! - closeSingleChild(item); + closeSingleChild(item.Value); } foreach (var item in proc2close) { // riavvio! - startChildProc(item.CodIOB); + startChildProc(item.Value.CodIOB, item.Key); } // se ho da riavviare... elimino! - foreach (var item in proc2restart) + foreach (var dictVal in proc2restart) { - ElencoIOB.Remove(item); - utils.lgInfo($"Chiusura processo non in running | IOB: {item.CodIOB} | pid: {item.pID}"); + ElencoIOB.Remove(dictVal.Value); + utils.lgInfo($"Chiusura processo non in running | IOB: {dictVal.Value.CodIOB} | pid: {dictVal.Value.pID}"); } // li faccio ripartire! foreach (var item in proc2restart) { - startChildProc(item.CodIOB); + startChildProc(item.Value.CodIOB, item.Key); } // update! @@ -743,8 +752,6 @@ namespace IOB_MAN int pid = -1; if (e.RowIndex >= 0) { - //dgvManagedItems.CurrentCell = dgvManagedItems.Rows[e.RowIndex].Cells[0]; - dgvManagedItems.Rows[e.RowIndex].Selected = true; using (var riga = dgvManagedItems.Rows[e.RowIndex]) { @@ -1078,7 +1085,7 @@ namespace IOB_MAN // verifico che sia già chiuso... if (((iobAdapt)ElencoIOB[riga.Index]).isRunning == false) { - startChildProc(((iobAdapt)ElencoIOB[riga.Index]).CodIOB); + startChildProc(((iobAdapt)ElencoIOB[riga.Index]).CodIOB, riga.Index); // rimuovo vecchia riga... ElencoIOB.RemoveAt(riga.Index); } diff --git a/Jenkinsfile b/Jenkinsfile index adb1fe3f..f7f35e40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=687']) { + withEnv(['NEXT_BUILD_NUMBER=688']) { // env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'