diff --git a/IOB-WIN/DATA/CONF/EM63.json b/IOB-WIN/DATA/CONF/EM63.json index f8f9aceb..fc33289f 100644 --- a/IOB-WIN/DATA/CONF/EM63.json +++ b/IOB-WIN/DATA/CONF/EM63.json @@ -108,7 +108,7 @@ "RetrySec": 30, "SessionName": "SESS0004", "SessionType": "GetStatus", - "ValidityMinutes": 5.0, + "ValidityMinutes": 10.0, "Max2Keep": 120, "StepOrder": 4, "FileList": [ @@ -128,7 +128,7 @@ "RetrySec": 30, "SessionName": "SESS0005", "SessionType": "GetProduction", - "ValidityMinutes": 5.0, + "ValidityMinutes": 10.0, "Max2Keep": 120, "StepOrder": 5, "FileList": [ diff --git a/IOB-WIN/EUR63_JOB/SESS0004.JOB b/IOB-WIN/EUR63_JOB/SESS0004.JOB index 218d9890..a322bddc 100644 --- a/IOB-WIN/EUR63_JOB/SESS0004.JOB +++ b/IOB-WIN/EUR63_JOB/SESS0004.JOB @@ -3,7 +3,7 @@ JOB machstat RESPONSE "SESS0004.LOG"; REPORT status REWRITE "SESS0004.DAT" START IMMEDIATE STOP NEVER -CYCLIC TIME 00:00:01 +CYCLIC TIME 00:00:02 SESSIONS 300 PARAMETERS DATE, TIME, ActStsMach; diff --git a/IOB-WIN/EUR63_JOB/SESS0005.JOB b/IOB-WIN/EUR63_JOB/SESS0005.JOB index f387774a..635534ac 100644 --- a/IOB-WIN/EUR63_JOB/SESS0005.JOB +++ b/IOB-WIN/EUR63_JOB/SESS0005.JOB @@ -3,8 +3,8 @@ JOB machstat RESPONSE "SESS0005.LOG"; REPORT status REWRITE "SESS0005.DAT" START IMMEDIATE STOP NEVER -CYCLIC TIME 00:00:03 -SESSIONS 100 +CYCLIC TIME 00:00:05 +SESSIONS 120 //PARAMETERS //DATE, TIME, ActCntCyc, ActTimCyc, ActTimFill, @OutXhour, SetDescJob; PARAMETERS diff --git a/IOB-WIN/IobFileEurom63.cs b/IOB-WIN/IobFileEurom63.cs index 7db32bb4..676df71d 100644 --- a/IOB-WIN/IobFileEurom63.cs +++ b/IOB-WIN/IobFileEurom63.cs @@ -94,6 +94,8 @@ namespace IOB_WIN var nextLevel = Eurom63.ComLevel.ChannelOk; var connectSession = confE63.ActiveSessions[3]; processSession(nextLevel, ref connectSession); + // qui per sicurezza PULISCE TUTTO + cleanupFolder(); } /// @@ -549,87 +551,81 @@ namespace IOB_WIN // init a zero... B_input = 0; + string currStatus = "00000"; + bool readDone = false; + DateTime adesso = DateTime.Now; + // leggo il file dela produzione HARD CODED... + var sessStatus = confE63.ActiveSessions[4]; // ciclo! try { - // controllo di essere in sampling (o quasi)... - if (actLevel >= Eurom63.ComLevel.ChannelOk) + // controllo se sono in sampling dello stato + if (actLevel >= Eurom63.ComLevel.StatusRequested) { - // controllo se sono in sampling dello stato - if (actLevel >= Eurom63.ComLevel.StatusRequested || true) + /* ----------------------------------------------------- + * bitmap MAPO + * B0: POWER_ON + * B1: RUN + * B2: pzCount + * B3: allarme + * B4: manuale + * B5: allarme TCiclo (SLOW) + ----------------------------------------------------- */ + + /****************************************************************** + * + * EXAMPLE file content + * DATE, TIME, ActStsMach + * 20201007, 21:28:10, 0A000 + * + * Configurazione array status: 5 char status decoding + * + * Pos1: (status) + * 0: poweron + * 1: poweroff + * + * Pos2: (mode) + * A: AUTO + * S: SEMI auto + * M: Manual + * U: Setup + * H: Hord + * C: Maintenance + * 0: Unknown + * I: Idle + * + * Pos3: (assist call) + * 0: No assistance + * 2: Assistance required + * + * Pos4: (Bad part) + * 0: last cycle not bad + * 1: last cycle bad + * + * Pos5: Active Alarm + * 0: No alarm + * 1: Alarm + * + * + * + *******************************************************************/ + + if (sessStatus != null) { - /* ----------------------------------------------------- - * bitmap MAPO - * B0: POWER_ON - * B1: RUN - * B2: pzCount - * B3: allarme - * B4: manuale - * B5: allarme TCiclo (SLOW) - ----------------------------------------------------- */ - - /****************************************************************** - * - * EXAMPLE file content - * DATE, TIME, ActStsMach - * 20201007, 21:28:10, 0A000 - * - * Configurazione array status: 5 char status decoding - * - * Pos1: (status) - * 0: poweron - * 1: poweroff - * - * Pos2: (mode) - * A: AUTO - * S: SEMI auto - * M: Manual - * U: Setup - * H: Hord - * C: Maintenance - * 0: Unknown - * I: Idle - * - * Pos3: (assist call) - * 0: No assistance - * 2: Assistance required - * - * Pos4: (Bad part) - * 0: last cycle not bad - * 1: last cycle bad - * - * Pos5: Active Alarm - * 0: No alarm - * 1: Alarm - * - * - * - *******************************************************************/ - - // leggo il file dela produzione HARD CODED... - var sessStatus = confE63.ActiveSessions[4]; - string currStatus = "00000"; - DateTime adesso = DateTime.Now; - if (sessStatus != null) + if (sessStatus.Active) { - if (sessStatus.Active) + // nome file... + string fileName = $"{BaseDir}\\{sessStatus.SessionName}.DAT"; + if (File.Exists(fileName)) { - // nome file... - string fileName = $"{BaseDir}\\{sessStatus.SessionName}.DAT"; - if (File.Exists(fileName)) + string rawData = ""; + using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var textReader = new StreamReader(fileStream)) + { + rawData = textReader.ReadToEnd(); + } + if (!string.IsNullOrEmpty(rawData)) { -#if false - // leggo il file... - string[] rawLines = File.ReadAllLines(fileName); - int numRow = rawLines.Length; -#endif - - string rawData = ""; - using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - using (var textReader = new StreamReader(fileStream)) - { - rawData = textReader.ReadToEnd(); - } // ora splitto in linee string[] rawLines = Regex.Split(rawData, "\r\n|\r|\n"); int numRow = rawLines.Length; @@ -638,69 +634,81 @@ namespace IOB_WIN if (numRow >= 2) { string[] statusData = rawLines[1].Split(','); - currStatus = statusData[2].Trim(); - if (!string.IsNullOrEmpty(currStatus)) + if (statusData.Length >= 3) { - currDispData.semIn = Semaforo.SV; - } + currStatus = statusData[2].Trim(); + if (!string.IsNullOrEmpty(currStatus)) + { + currDispData.semIn = Semaforo.SV; + } + readDone = true; + // salvo in cache! + Last_CurrStatus.Value = currStatus; + Last_CurrStatus.ValidUntil = DateTime.Now.AddSeconds(15); - // salvo in cache! - Last_CurrStatus.Value = currStatus; - Last_CurrStatus.ValidUntil = DateTime.Now.AddSeconds(15); - - // ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...) - string data = statusData[0].Trim(); - string ora = statusData[1].Trim(); - DateTime lastPub = adesso.AddMinutes(-1); - CultureInfo provider = CultureInfo.InvariantCulture; - try - { - lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider); + // ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...) + string data = statusData[0].Trim(); + string ora = statusData[1].Trim(); + DateTime lastPub = adesso.AddMinutes(-1); + CultureInfo provider = CultureInfo.InvariantCulture; + try + { + lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider); + } + catch + { } + if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec) + { + sessStatus.SessionValidUntil = adesso; + // elimino file RSP... + cleanupResp(sessStatus.SessionName); + } } - catch - { } - if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec) + else { - sessStatus.SessionValidUntil = adesso; - // elimino file RSP... - cleanupResp(sessStatus.SessionName); + lgError($"decodifica StatusData in errore: trovati {statusData.Length} campi in {rawLines}"); } } + else + { + lgError($"Lettura file stato in errore: trovate {numRow} linee"); + } } } - else + } + else + { + actLevel = Eurom63.ComLevel.ChannelOk; + // se valido RILEGGO ultimo curr status + if (Last_CurrStatus.ValidUntil > adesso) { - actLevel = Eurom63.ComLevel.ChannelOk; - // se valido RILEGGO ultimo curr status - if (Last_CurrStatus.ValidUntil > adesso) - { - currStatus = Last_CurrStatus.Value; - } + currStatus = Last_CurrStatus.Value; } } - // processo il currentStatus... parto da poweron - B_input = currStatus[0] == '1' ? 0 : 1; - // ora MODE - switch (currStatus[1]) - { - case 'A': - B_input += (1 << 1); - break; + } - case 'S': - case 'M': - case 'U': - B_input += (1 << 4); - break; + // processo il currentStatus... parto da poweron + B_input = currStatus[0] == '1' ? 0 : 1; + // ora MODE + switch (currStatus[1]) + { + case 'A': + B_input += (1 << 1); + break; - default: - break; - } - // ora cerco allarmi - if (currStatus[4] == '1') - { - B_input += (1 << 3); - } + case 'S': + case 'M': + case 'U': + B_input += (1 << 4); + break; + + default: + break; + } + // ora cerco allarmi + if (currStatus[4] == '1') + { + B_input += (1 << 3); } } @@ -713,6 +721,15 @@ namespace IOB_WIN if (currDispData != null) currDispData.semIn = Semaforo.SR; } + + if (!readDone) + { + // se valido RILEGGO ultimo curr status + if (Last_CurrStatus.ValidUntil > adesso) + { + currStatus = Last_CurrStatus.Value; + } + } } /// @@ -753,6 +770,7 @@ namespace IOB_WIN connectionOk = false; try { + abortPrevJob(); cleanupFolder(); } catch (Exception exc) diff --git a/Jenkinsfile b/Jenkinsfile index 6bd6586a..23624676 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=714']) { + withEnv(['NEXT_BUILD_NUMBER=720']) { // env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN' diff --git a/gitSpread.bat b/gitSpread.bat index 82c207fc..15fb39a3 100644 --- a/gitSpread.bat +++ b/gitSpread.bat @@ -1,4 +1,9 @@ REM Script di replica su altri rami di un branch git +REM l'argomento รจ il replication level: +REM 0 = solo locale +REM 1 = locale + ramo current remoto +REM 2 = locale + current + develop/master remoto +REM 3 = locale + full remoto ECHO off set baseBranch=%1 @@ -11,12 +16,14 @@ git push . %baseBranch%:IOB/MTC git push . %baseBranch%:IobMan git push . %baseBranch%:master +REM Faccio push remoto condizionale +if %pushRemote% GTR 0 ( git push gitlab.steamware %baseBranch%:%baseBranch% ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:develop ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:IOB-NET ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:IOB/Euromap63 ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:IOB/MTC ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:IobMan ) -if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:master ) +if %pushRemote% GTR 1 ( git push gitlab.steamware %baseBranch%:develop ) +if %pushRemote% GTR 2 ( git push gitlab.steamware %baseBranch%:IOB-NET ) +if %pushRemote% GTR 2 ( git push gitlab.steamware %baseBranch%:IOB/Euromap63 ) +if %pushRemote% GTR 2 ( git push gitlab.steamware %baseBranch%:IOB/MTC ) +if %pushRemote% GTR 2 ( git push gitlab.steamware %baseBranch%:IobMan ) +if %pushRemote% GTR 1 ( git push gitlab.steamware %baseBranch%:master ) ECHO on \ No newline at end of file