diff --git a/CVCncLib/testSam.dll b/CVCncLib/testSam.dll index 67856c44..e90f9b12 100644 Binary files a/CVCncLib/testSam.dll and b/CVCncLib/testSam.dll differ diff --git a/IOB-WIN/DATA/CONF/MAIN.ini b/IOB-WIN/DATA/CONF/MAIN.ini index 313f2f61..7906162c 100644 --- a/IOB-WIN/DATA/CONF/MAIN.ini +++ b/IOB-WIN/DATA/CONF/MAIN.ini @@ -3,17 +3,18 @@ NAME=master [SERVER] -;MPIP=192.168.1.7 -MPIP=10.74.82.218 +MPIP=192.168.1.7 +;MPIP=10.74.82.218 MPURL=/MP/IO CMDREBO=/IOB/sendRebootGateway?GWIP= CMDIOB2CALL=/IOB/getIob2call?GWIP= [IOB] ;--- TEST SIMULAZIONE -;STARTLIST=3011 +STARTLIST=3010 +;STARTLIST=SIMUL_01 + ;STARTLIST=3015 -STARTLIST=SIMUL_01 ;STARTLIST=SIMUL_05,SIMUL_06,SIMUL_07,SIMUL_08,SIM_DP_01,SIM_DP_02 ;STARTLIST=SIMUL_01,SIMUL_02,SIMUL_03,SIMUL_04,SIMUL_05,SIMUL_06,SIMUL_07,SIMUL_08,SIM_DP_01 ,SIM_DP_02 diff --git a/IOB-WIN/IOB-WIN.csproj b/IOB-WIN/IOB-WIN.csproj index ba36e020..37683a09 100644 --- a/IOB-WIN/IOB-WIN.csproj +++ b/IOB-WIN/IOB-WIN.csproj @@ -78,6 +78,9 @@ False ExtLib\krcc.dll + + ..\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll + ..\packages\NLog.4.5.11\lib\net40-client\NLog.dll diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs index d282aa78..c9725f1a 100644 --- a/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IobGeneric.cs @@ -481,7 +481,7 @@ namespace IOB_WIN /// - /// Invia al server IO i valori dei parametri opzionali (es counters) + /// Chiede elenco dei task da eseguire /// protected string getTask2exe() { @@ -494,6 +494,20 @@ namespace IOB_WIN } return answ; } + /// + /// Cancella dal server i task eseguiti + /// + protected string remTask2exe(string taskName) + { + string answ = ""; + if (checkServerAlive) + { + string url2call = $"{urlRemTask2Exe}{taskName}"; + lgInfo("chiamata URL " + url2call); + answ = utils.callUrl(url2call); + } + return answ; + } /// /// Invia al server IO i valori dei parametri opzionali (es counters) @@ -701,10 +715,10 @@ namespace IOB_WIN { processAllMemory(); processMode(); - processServerRequests(); } else if (ciclo == gatherCycle.MF) { + processServerRequests(); processOverride(); processContapezzi(); processCncAlarms(); @@ -793,19 +807,29 @@ namespace IOB_WIN public void processServerRequests() { Dictionary task2exe = new Dictionary(); + Dictionary taskDone = new Dictionary(); // recupero elenco delle cose da fare string resp = getTask2exe(); task2exe = JsonConvert.DeserializeObject>(resp); - // chiamo procedura esecutiva (diversa x ogni IOB) - executeTasks(task2exe); + // se ho da fare chiamo esecuzione.. + if (task2exe.Count > 0) + { + // chiamo procedura esecutiva (diversa x ogni IOB) + taskDone = executeTasks(task2exe); + } + // ora chiamo la cancellazione dei task eseguiti... + foreach (var item in taskDone) + { + remTask2exe(item.Key); + } } /// - /// Esecuzione dei task richiesti e pulizia coda richieste 1:1 + /// Esecuzione dei task richiesti e pulizia coda richieste eseguite /// /// - public virtual void executeTasks(Dictionary task2exe) + public virtual Dictionary executeTasks(Dictionary task2exe) { - + return null; } /// @@ -1360,11 +1384,30 @@ namespace IOB_WIN string answ = ""; try { - answ = string.Format(@"http://{0}{1}{2}/getTask2Exe/{3}?", cIobConf.serverData.MPIP, cIobConf.serverData.MPURL, cIobConf.serverData.CMDALIVE, cIobConf.codIOB); + answ = string.Format(@"http://{0}{1}{2}/getTask2Exe/{3}", cIobConf.serverData.MPIP, cIobConf.serverData.MPURL, cIobConf.serverData.CMDALIVE, cIobConf.codIOB); } catch (Exception exc) { - lgError(exc, "Errore in composizione urlSetOptVal"); + lgError(exc, "Errore in composizione urlGetTask2Exe"); + } + return answ; + } + } + /// + /// URL per richiamo task da eseguire... + /// + public string urlRemTask2Exe + { + get + { + string answ = ""; + try + { + answ = string.Format(@"http://{0}{1}{2}/remTask2Exe/{3}?taskName=", cIobConf.serverData.MPIP, cIobConf.serverData.MPURL, cIobConf.serverData.CMDALIVE, cIobConf.codIOB); + } + catch (Exception exc) + { + lgError(exc, "Errore in composizione urlRemTask2Exe"); } return answ; } diff --git a/IOB-WIN/IobSiemens.cs b/IOB-WIN/IobSiemens.cs index 707ebd41..612d61b0 100644 --- a/IOB-WIN/IobSiemens.cs +++ b/IOB-WIN/IobSiemens.cs @@ -120,29 +120,28 @@ namespace IOB_WIN public bool S7WriteBB(ref byte[] Value) { bool answ = false; - -#if false sw.Restart(); if (testCncConn()) { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - string byteVal = ""; - for (int i = 0; i < memByteRead.Length; i++) - { - byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); - } - showOut(titolo, contenuto); + // decodifico memoria... + memAreaSiemens memoria = new memAreaSiemens(parametri.memAddrWrite); + int numByte = Value.Length; + var errorCode = currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, Value); + + answ = true; + //titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte); + //contenuto = ""; + //string byteVal = ""; + //for (int i = 0; i < memByteRead.Length; i++) + //{ + // byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); + // contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); + //} + //showOut(titolo, contenuto); } sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); -#endif + //tslRTime.Text = string.Format("{0}", sw.Elapsed); + #if false diff --git a/IOB-WIN/IobSiemensTorri.cs b/IOB-WIN/IobSiemensTorri.cs index 72ecfb34..a4285ac7 100644 --- a/IOB-WIN/IobSiemensTorri.cs +++ b/IOB-WIN/IobSiemensTorri.cs @@ -15,7 +15,7 @@ namespace IOB_WIN * mod: 2019.01.19: aggiunta gestione segnale test/accensione/spegnimento (DB700.B1.4) --> mod StateMachine! * mod: 2019.04.06: aggiunta indicazione (IOB--> PLC) di stato setup su DB701.B0.4 * -------------------------------------------------------------------------------- */ - + /// /// estende l'init della classe base con i metodi x Siemens specifici x Torri @@ -27,9 +27,46 @@ namespace IOB_WIN // dovebbe fare init della classe base, VERIFICARE... lgInfo("NEW IOB SIEMENS versione TORRI"); } + /// + /// Processo i task richeisti e li elimino dalla coda 1:1 + /// + /// + public override Dictionary executeTasks(Dictionary task2exe) + { + // Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti... + Dictionary answ = new Dictionary(); + // inizio con 1 byte VUOTO + byte[] MemBlock = new byte[1]; + + // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 + foreach (var item in task2exe) + { + switch (item.Value) + { + case "startSetup": + MemBlock[0] += (1 << 4); + answ.Add(item.Key, item.Value); + break; + case "stopSetup": + answ.Add(item.Key, item.Value); + break; + default: + break; + } + //if (item.Value == "startSetup") + //{ + // MemBlock[0] += (1 << 4); + // answ.(item); + //} + } + // scrivo comunque! + bool fatto = S7WriteBB(ref MemBlock); + + return answ; + } #region da verificare - + /// /// Recupero dati override in formato dictionary ///