From fb5d5d5bb1cd2ee42ab34ab1b88bb3a403e4c664 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 8 Nov 2019 17:28:04 +0100 Subject: [PATCH] Update x LASCO --- IOB-WIN/DATA/CONF/VL20.json | 22 +++++ IOB-WIN/DATA/CONF/VL22.ini | 4 + IOB-WIN/DATA/CONF/VL22.json | 84 +++++++++++++++++ IOB-WIN/DATA/CONF/VL24.json | 38 ++++++++ IOB-WIN/IOB-WIN.csproj | 5 + IOB-WIN/IobGeneric.cs | 17 ++-- IOB-WIN/IobSiemensLasco.cs | 182 +++++++++++++++++++++++++----------- Jenkinsfile | 2 +- 8 files changed, 292 insertions(+), 62 deletions(-) create mode 100644 IOB-WIN/DATA/CONF/VL22.json diff --git a/IOB-WIN/DATA/CONF/VL20.json b/IOB-WIN/DATA/CONF/VL20.json index d40c0736..3b4e7ebd 100644 --- a/IOB-WIN/DATA/CONF/VL20.json +++ b/IOB-WIN/DATA/CONF/VL20.json @@ -2,18 +2,24 @@ "mMapWrite": { "setArt": { "name": "setArt", + "description": "Articolo", + "memAddr": "DB1275.DBB96", "tipoMem": "String", "index": 4, "size": 32 }, "setComm": { "name": "setComm", + "description": "Commessa", + "memAddr": "DB1275.DBB130", "tipoMem": "String", "index": 38, "size": 12 }, "setPzComm": { "name": "setPzComm", + "description": "Qty", + "memAddr": "DB1275.DBB144", "tipoMem": "Int", "index": 52, "size": 4 @@ -22,6 +28,8 @@ "mMapRead": { "Power_01": { "name": "Power_01", + "description": "Potenza_ST_1", + "memAddr": "DB1275.DBB24", "tipoMem": "Real", "index": 24, "size": 4, @@ -31,6 +39,8 @@ }, "Power_02": { "name": "Power_02", + "description": "Potenza_ST_2", + "memAddr": "DB1275.DBB28", "tipoMem": "Real", "index": 28, "size": 4, @@ -40,6 +50,8 @@ }, "TempPirom_01": { "name": "TempPirom_01", + "description": "Temperatura_Pirometro_1", + "memAddr": "DB1275.DBB40", "tipoMem": "Real", "index": 40, "size": 4, @@ -49,6 +61,8 @@ }, "TempCool_01": { "name": "TempCool_01", + "description": "Temperatura_Raffr_1", + "memAddr": "DB1275.DBB56", "tipoMem": "Real", "index": 56, "size": 4, @@ -58,6 +72,8 @@ }, "PartStatus_01": { "name": "PartStatus_01", + "description": "Pezzo_Staz_1", + "memAddr": "DB1275.DBB72", "tipoMem": "Int", "index": 72, "size": 2, @@ -66,6 +82,8 @@ }, "PartStatus_02": { "name": "PartStatus_02", + "description": "Pezzo_Staz_2", + "memAddr": "DB1275.DBB74", "tipoMem": "Int", "index": 74, "size": 2, @@ -74,6 +92,8 @@ }, "PartStatus_03": { "name": "PartStatus_03", + "description": "Pezzo_Staz_3", + "memAddr": "DB1275.DBB76", "tipoMem": "Int", "index": 76, "size": 2, @@ -82,6 +102,8 @@ }, "PartStatus_04": { "name": "PartStatus_04", + "description": "Pezzo_Staz_4", + "memAddr": "DB1275.DBB78", "tipoMem": "Int", "index": 78, "size": 2, diff --git a/IOB-WIN/DATA/CONF/VL22.ini b/IOB-WIN/DATA/CONF/VL22.ini index 8b5cdc97..c193a8a6 100644 --- a/IOB-WIN/DATA/CONF/VL22.ini +++ b/IOB-WIN/DATA/CONF/VL22.ini @@ -64,6 +64,10 @@ PZCOUNT_MODE=STD.DB1001.DBDW2 DISABLE_PZCOUNT=TRUE ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE +USE_NEW_EXE_TASK=TRUE +; conf parametri memoria READ/WRITE +PARAM_CONF=VL22.json + TSVC_RamPosition=MAX:10 TSVC_LowerEjectorPosition=MAX:10 TSVC_UpperTool=MAX:10 diff --git a/IOB-WIN/DATA/CONF/VL22.json b/IOB-WIN/DATA/CONF/VL22.json new file mode 100644 index 00000000..b20eb79f --- /dev/null +++ b/IOB-WIN/DATA/CONF/VL22.json @@ -0,0 +1,84 @@ +{ + "mMapWrite": { + "setArt": { + "name": "setArt", + "description": "Articolo", + "memAddr": "DB1002.DBB2", + "tipoMem": "String", + "index": 2, + "size": 22 + }, + "setComm": { + "name": "setComm", + "description": "Commessa", + "memAddr": "DB1002.DBB24", + "tipoMem": "String", + "index": 24, + "size": 22 + }, + "setProg": { + "name": "setProg", + "description": "Programma", + "memAddr": "DB1002.DBB46", + "tipoMem": "String", + "index": 46, + "size": 22 + } + }, + "mMapRead": { + //"RamPosition": { + // "name": "RamPosition", + // "tipoMem": "Int", + // "index": 18, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 10 + //}, + //"LowerEjectorPosition": { + // "name": "LowerEjectorPosition", + // "tipoMem": "Int", + // "index": 20, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 10 + //}, + //"UpperTool": { + // "name": "UpperTool", + // "tipoMem": "Int", + // "index": 22, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 10 + //}, + //"TempMainMotorU": { + // "name": "TempMainMotorU", + // "tipoMem": "Int", + // "index": 24, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 1 + //}, + //"TempMainMotorV": { + // "name": "TempMainMotorV", + // "tipoMem": "Int", + // "index": 26, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 1 + //}, + //"TempMainMotorW": { + // "name": "TempMainMotorW", + // "tipoMem": "Int", + // "index": 28, + // "size": 2, + // "func": "MAX", + // "period": 60, + // "factor": 1 + //} + } +} \ No newline at end of file diff --git a/IOB-WIN/DATA/CONF/VL24.json b/IOB-WIN/DATA/CONF/VL24.json index d862941c..d66edb6d 100644 --- a/IOB-WIN/DATA/CONF/VL24.json +++ b/IOB-WIN/DATA/CONF/VL24.json @@ -2,18 +2,24 @@ "mMapWrite": { "setArt": { "name": "setArt", + "description": "Articolo", + "memAddr": "DB1275.DBB96", "tipoMem": "String", "index": 4, "size": 32 }, "setComm": { "name": "setComm", + "description": "Commessa", + "memAddr": "DB1275.DBB130", "tipoMem": "String", "index": 38, "size": 12 }, "setPzComm": { "name": "setPzComm", + "description": "Qty", + "memAddr": "DB1275.DBB144", "tipoMem": "Int", "index": 52, "size": 4 @@ -22,6 +28,8 @@ "mMapRead": { "Power_01": { "name": "Power_01", + "description": "Potenza_ST_1", + "memAddr": "DB1275.DBB24", "tipoMem": "Real", "index": 24, "size": 4, @@ -31,6 +39,8 @@ }, "Power_02": { "name": "Power_02", + "description": "Potenza_ST_2", + "memAddr": "DB1275.DBB28", "tipoMem": "Real", "index": 28, "size": 4, @@ -40,6 +50,8 @@ }, "Power_03": { "name": "Power_03", + "description": "Potenza_ST_3", + "memAddr": "DB1275.DBB32", "tipoMem": "Real", "index": 32, "size": 4, @@ -49,6 +61,8 @@ }, "Power_04": { "name": "Power_04", + "description": "Potenza_ST_4", + "memAddr": "DB1275.DBB36", "tipoMem": "Real", "index": 36, "size": 4, @@ -58,6 +72,8 @@ }, "TempPirom_01": { "name": "TempPirom_01", + "description": "Temperatura_Pirometro_1", + "memAddr": "DB1275.DBB40", "tipoMem": "Real", "index": 40, "size": 4, @@ -67,6 +83,8 @@ }, "TempPirom_02": { "name": "TempPirom_02", + "description": "Temperatura_Pirometro_3", + "memAddr": "DB1275.DBB44", "tipoMem": "Real", "index": 44, "size": 4, @@ -76,6 +94,8 @@ }, "TempPirom_03": { "name": "TempPirom_03", + "description": "Temperatura_Pirometro_3", + "memAddr": "DB1275.DBB46", "tipoMem": "Real", "index": 48, "size": 4, @@ -85,6 +105,8 @@ }, "TempPirom_04": { "name": "TempPirom_04", + "description": "Temperatura_Pirometro_4", + "memAddr": "DB1275.DBB48", "tipoMem": "Real", "index": 52, "size": 4, @@ -94,6 +116,8 @@ }, "TempCool_01": { "name": "TempCool_01", + "description": "Temperatura_Raffr_1", + "memAddr": "DB1275.DBB56", "tipoMem": "Real", "index": 56, "size": 4, @@ -103,6 +127,8 @@ }, "TempCool_02": { "name": "TempCool_02", + "description": "Temperatura_Raffr_2", + "memAddr": "DB1275.DBB60", "tipoMem": "Real", "index": 60, "size": 4, @@ -112,6 +138,8 @@ }, "TempCool_03": { "name": "TempCool_03", + "description": "Temperatura_Raffr_3", + "memAddr": "DB1275.DBB64", "tipoMem": "Real", "index": 64, "size": 4, @@ -121,6 +149,8 @@ }, "TempCool_04": { "name": "TempCool_04", + "description": "Temperatura_Raffr_4", + "memAddr": "DB1275.DBB68", "tipoMem": "Real", "index": 68, "size": 4, @@ -130,6 +160,8 @@ }, "PartStatus_01": { "name": "PartStatus_01", + "description": "Pezzo_Staz_1", + "memAddr": "DB1275.DBB72", "tipoMem": "Int", "index": 72, "size": 2, @@ -138,6 +170,8 @@ }, "PartStatus_02": { "name": "PartStatus_02", + "description": "Pezzo_Staz_2", + "memAddr": "DB1275.DBB74", "tipoMem": "Int", "index": 74, "size": 2, @@ -146,6 +180,8 @@ }, "PartStatus_03": { "name": "PartStatus_03", + "description": "Pezzo_Staz_3", + "memAddr": "DB1275.DBB76", "tipoMem": "Int", "index": 76, "size": 2, @@ -154,6 +190,8 @@ }, "PartStatus_04": { "name": "PartStatus_04", + "description": "Pezzo_Staz_4", + "memAddr": "DB1275.DBB78", "tipoMem": "Int", "index": 78, "size": 2, diff --git a/IOB-WIN/IOB-WIN.csproj b/IOB-WIN/IOB-WIN.csproj index d727a223..e7942f7d 100644 --- a/IOB-WIN/IOB-WIN.csproj +++ b/IOB-WIN/IOB-WIN.csproj @@ -244,6 +244,11 @@ Always + + + + + diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs index 9ff448d1..e359495d 100644 --- a/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IobGeneric.cs @@ -316,18 +316,17 @@ namespace IOB_WIN try { newDisplayData currDispData = new newDisplayData(); - StringBuilder sb = new StringBuilder($"----------- Read Data Memory -----------{Environment.NewLine}"); -#if false + StringBuilder sb = new StringBuilder(); + sb.Append($"B_input --> {(short)B_input}{Environment.NewLine}"); + sb.Append($"{baseUtils.binaryForm(B_input)}{Environment.NewLine}"); + sb.Append($"{Environment.NewLine}"); + sb.Append($"----------- RAW Data Memory -----------{Environment.NewLine}"); int i = 0; foreach (var item in RawInput) { - sb.Append($"B{i:00} --> {baseUtils.binaryForm(item)} = {(short)item}"); + sb.Append($"B{i:00} --> {baseUtils.binaryForm(item)} = {(short)item}{Environment.NewLine}"); i++; } -#endif - - sb.Append($"B_input --> {(short)B_input}{Environment.NewLine}"); - sb.Append($"{baseUtils.binaryForm(B_input)}{Environment.NewLine}"); sb.Append("-------------------------------"); currDispData.currBitmap = sb.ToString(); parentForm.updateFormDisplay(currDispData); @@ -1793,7 +1792,7 @@ namespace IOB_WIN string answ = ""; if (cIobConf.optPar.Count > 0) { - // controllo SE salvare contapezzo + // controllo SE HO il parametro if (cIobConf.optPar.ContainsKey(key)) { answ = cIobConf.optPar[key]; @@ -1810,7 +1809,7 @@ namespace IOB_WIN { Dictionary answ = new Dictionary(); // controllo SE keySearch !="" - if (keyStartSearch != "") + if (!string.IsNullOrWhiteSpace(keyStartSearch)) { if (cIobConf.optPar.Count > 0) { diff --git a/IOB-WIN/IobSiemensLasco.cs b/IOB-WIN/IobSiemensLasco.cs index ecf69e02..686df5b4 100644 --- a/IOB-WIN/IobSiemensLasco.cs +++ b/IOB-WIN/IobSiemensLasco.cs @@ -65,6 +65,8 @@ namespace IOB_WIN protected int counterPlc2Mes = 0; protected int counterPlc2MesWrote = 0; + protected bool useNewSend = false; + /// /// Classe base con i metodi x Siemens /// @@ -74,6 +76,7 @@ namespace IOB_WIN { lgInfo("NEW IOB SIEMENS versione LASCO"); lastPLCWatchDog = DateTime.Now.AddMinutes(-1); + useNewSend = string.IsNullOrWhiteSpace(getOptPar("USE_NEW_EXE_TASK")) ? false : true; // imposto i parametri speciali x calcolo... var chiaviTSVC = findOptPar("TSVC"); if (chiaviTSVC.Count > 0) @@ -148,65 +151,140 @@ namespace IOB_WIN Dictionary taskDone = new Dictionary(); bool taskOk = false; string taskVal = ""; - // inizio VUOTO - byte[] MemBlock = new byte[parametri.memSizeWrite]; - - // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 - foreach (var item in task2exe) + string memAddrWrite = ""; + if (task2exe != null) { - taskOk = false; - taskVal = ""; - // converto richiesta in enum... - taskType tName = taskType.nihil; - Enum.TryParse(item.Key, out tName); - // controllo sulla KEY - //!!!FIXME!!! totalmente da rivedere - switch (tName) + // inizio VUOTO + byte[] MemBlock = new byte[parametri.memSizeWrite]; + + // controllo su OPT_PAR se usare nuovo metodo exe task... + if (useNewSend) { - case taskType.nihil: - case taskType.fixStopSetup: - case taskType.forceResetPzCount: - case taskType.forceSetPzCount: - 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.setProg: - // imposto i valori... - if (currProdData.ContainsKey(item.Key)) + // cerco task specifici + foreach (var item in task2exe) + { + taskOk = false; + taskVal = ""; + // converto richiesta in enum... + taskType tName = taskType.nihil; + Enum.TryParse(item.Key, out tName); + // controllo sulla KEY + switch (tName) { - currProdData[item.Key] = item.Value; + case taskType.nihil: + case taskType.fixStopSetup: + case taskType.forceResetPzCount: + case taskType.forceSetPzCount: + case taskType.setProg: + 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.setPzComm: + saveProdData(item); + int byteSize = 0; + // 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, true); + } + 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; + break; + case taskType.sendWatchDogMes2Plc: + // processo scrittura BIT su DB150.DBX4.0 + MemBlock = new byte[1]; + memAddrWrite = "DB1002.DBB0"; + // compogo in byte... primo bit è setup/run, ultimo è watchdog + int valore = inSetup ? 1 : 0; + valore += (byte)(counterMes2Plc << 7); + MemBlock[0] = (byte)valore; + taskVal = $"VALUE DB1002.92 --> {counterMes2Plc}"; + break; + default: + taskVal = "SKIPPED | NO EXEC"; + break; } - else + // aggiungo task! + taskDone.Add(item.Key, taskVal); + // scrivo comunque! + taskOk = S7WriteBB(ref MemBlock, memAddrWrite); + if (!taskOk) { - currProdData.Add(item.Key, item.Value); + lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}"); } - taskVal = item.Value; - break; - case taskType.sendWatchDogMes2Plc: - // compogo in byte... primo bit è setup/run, ultimo è watchdog - int valore = inSetup ? 1 : 0; - valore += (byte)(counterMes2Plc << 7); - MemBlock[0] = (byte)valore; - taskVal = $"VALUE DB1275.92 --> {counterMes2Plc}"; - break; - default: - taskVal = "SKIPPED | NO EXEC"; - break; + } + } + else + { + // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 + foreach (var item in task2exe) + { + taskOk = false; + taskVal = ""; + // converto richiesta in enum... + taskType tName = taskType.nihil; + Enum.TryParse(item.Key, out tName); + // controllo sulla KEY + switch (tName) + { + case taskType.nihil: + case taskType.fixStopSetup: + case taskType.forceResetPzCount: + case taskType.forceSetPzCount: + 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.setProg: + saveProdData(item); + taskVal = item.Value; + break; + case taskType.sendWatchDogMes2Plc: + // compogo in byte... primo bit è setup/run, ultimo è watchdog + int valore = inSetup ? 1 : 0; + valore += (byte)(counterMes2Plc << 7); + MemBlock[0] = (byte)valore; + taskVal = $"VALUE DB1002.92 --> {counterMes2Plc}"; + break; + default: + taskVal = "SKIPPED | NO EXEC"; + break; + } + // aggiungo task! + taskDone.Add(item.Key, taskVal); + } + // controllo SE HO da scrivere articolo/commessa/programma + saveStringOnMemBlock(ref MemBlock, "setArt", 2, 22, true); + saveStringOnMemBlock(ref MemBlock, "setComm", 24, 22, true); + saveStringOnMemBlock(ref MemBlock, "setProg", 46, 22, true); + + // scrivo comunque! + taskOk = S7WriteBB(ref MemBlock); } - // aggiungo task! - taskDone.Add(item.Key, taskVal); } - // controllo SE HO da scrivere articolo/commessa/programma - saveStringOnMemBlock(ref MemBlock, "setArt", 2, 20, true); - saveStringOnMemBlock(ref MemBlock, "setComm", 24, 20, true); - saveStringOnMemBlock(ref MemBlock, "setProg", 46, 20, true); - - // scrivo comunque! - taskOk = S7WriteBB(ref MemBlock); - return taskDone; } @@ -362,7 +440,7 @@ namespace IOB_WIN * - DBX0.5: SAFETY DOORS ----------------------------------------------------- */ - byte mainData = RawInput[2]; + byte mainData = RawInput[0]; int byteSignals = 0; // bit 0 (poweron) imposto a 1 SE connected... diff --git a/Jenkinsfile b/Jenkinsfile index b46594eb..c9d3d59a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=504']) { + withEnv(['NEXT_BUILD_NUMBER=505']) { // env.versionNumber = VersionNumber(versionNumberString : '2.4.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.4.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'