From 7781fd4f38aa085bdd9159570d2a32b678c5b5f1 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 4 Dec 2019 16:34:45 +0100 Subject: [PATCH] Revisione gestione variazioni MTC --- IOB-WIN/IobMTC.cs | 67 ++++++++++++++++++++++++++++++++++++++--------- Jenkinsfile | 2 +- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/IOB-WIN/IobMTC.cs b/IOB-WIN/IobMTC.cs index 99b69dc9..3752a611 100644 --- a/IOB-WIN/IobMTC.cs +++ b/IOB-WIN/IobMTC.cs @@ -235,7 +235,7 @@ namespace IOB_WIN MTC_ref = new MTConnectClient($"http://{cIobConf.cncIpAddr}:{port}"); // Subscribe to the Event handlers to receive the MTConnect documents MTC_ref.ProbeReceived += DevicesSuccessful; - MTC_ref.CurrentReceived += StreamsSuccessful; + MTC_ref.CurrentReceived += CurrentSuccessful; MTC_ref.SampleReceived += StreamsSuccessful; // attendo 1 sec... @@ -624,8 +624,41 @@ namespace IOB_WIN } return answ; } - + /// + /// Effettuata discovery iniziale + /// + /// + /// + protected void CurrentSuccessful(MTConnectStreams.Document document) + { + if (document != null) + { + lgInfo($"DiscoverySuccessful: discovery per {document.Url}"); + if (document.DeviceStreams != null) + { + lgInfo($"DiscoverySuccessful: trovati {document.DeviceStreams.Count} streams"); + } + checkAndSend(document, true); + } + else + { + lgError("StreamsSuccessful ERROR: document è null"); + } + } + /// + /// Ricevuta modifica come stream + /// + /// protected void StreamsSuccessful(MTConnectStreams.Document document) + { + checkAndSend(document, false); + } + /// + /// Verifica ed invia variazioni + /// + /// + /// + private void checkAndSend(MTConnectStreams.Document document, bool forceSend) { if (document != null) { @@ -648,7 +681,7 @@ namespace IOB_WIN var time2 = tStamp.ToLocalTime(); // verifico se salvare bool changed = checkSaveItem(dataItem); - if (changed) + if (changed || forceSend) { // accodare ed invia nella coda ALARMS (che POI salva in document MongoDB anche ultimi x minuti di FluxLog...) accodaAlarmLog(sVal, qEncodeFLog(time2, descr, dataItem.CDATA)); @@ -656,8 +689,10 @@ namespace IOB_WIN } } } - catch - { } + catch (Exception exc) + { + lgError($"Eccezione in decodifica Conditions x StreamSuccesfull{Environment.NewLine}{exc}"); + } // check su events try { @@ -672,15 +707,17 @@ namespace IOB_WIN var time2 = tStamp.ToLocalTime(); // verifico se salvare bool changed = checkSaveItem(dataItem); - if (changed) + if (changed || forceSend) { accodaFLog(sVal, qEncodeFLog(time2, descr, dataItem.CDATA)); //accodaFLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA)); } } } - catch - { } + catch (Exception exc) + { + lgError($"Eccezione in decodifica Events x StreamSuccesfull{Environment.NewLine}{exc}"); + } // check su samples try @@ -696,7 +733,7 @@ namespace IOB_WIN var time2 = tStamp.ToLocalTime(); // verifico se salvare bool changed = checkSaveSample(dataItem); - if (changed) + if (changed || forceSend) { accodaFLog(sVal, qEncodeFLog(time2, descr, dataItem.CDATA)); //accodaFLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA)); @@ -705,16 +742,22 @@ namespace IOB_WIN { if (utils.CRB("verbose")) { - lgInfo($"NON ACCODATO sample poiché verifica variazioen ha dato esito negativo"); + lgInfo($"NON ACCODATO sample poiché verifica variazione SAMPLE ha dato esito negativo"); } } } } - catch - { } + catch (Exception exc) + { + lgError($"Eccezione in decodifica Samples x StreamSuccesfull{Environment.NewLine}{exc}"); + } } } + else + { + lgError("StreamsSuccessful ERROR: document è null"); + } } /// diff --git a/Jenkinsfile b/Jenkinsfile index 1603ca05..89d4d617 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=570']) { + withEnv(['NEXT_BUILD_NUMBER=571']) { // env.versionNumber = VersionNumber(versionNumberString : '2.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'