diff --git a/IOB-WIN/DATA/CONF/IMI_50.ini b/IOB-WIN/DATA/CONF/IMI_50.ini
index 56521241..bb65e120 100644
--- a/IOB-WIN/DATA/CONF/IMI_50.ini
+++ b/IOB-WIN/DATA/CONF/IMI_50.ini
@@ -58,6 +58,7 @@ PZCOUNT_MODE=STD.DM20.2
DISABLE_PZCOUNT=TRUE
ENABLE_DYN_DATA=FALSE
FORCE_DYN_DATA=TRUE
+ENABLE_DATA_FILTER=FALSE
; conf parametri memoria READ/WRITE
PARAM_CONF=IMI_50.json
diff --git a/IOB-WIN/IobMTC.cs b/IOB-WIN/IobMTC.cs
index ed878c38..a2b5e894 100644
--- a/IOB-WIN/IobMTC.cs
+++ b/IOB-WIN/IobMTC.cs
@@ -26,6 +26,10 @@ namespace IOB_WIN
///
protected MTConnectClient MTC_ref;
///
+ /// Gestione filtraggio dati
+ ///
+ protected bool enableDataFilter = false;
+ ///
/// URL x salvataggio elenco dataItems MTC
///
protected string urlSaveDataItems
@@ -56,6 +60,11 @@ namespace IOB_WIN
{
// gestione invio ritardato contapezzi
pzCountDelay = utils.CRI("pzCountDelay");
+ // gestione data filtering...
+ if (!string.IsNullOrEmpty(getOptPar("ENABLE_DATA_FILTER")))
+ {
+ bool.TryParse(getOptPar("ENABLE_DATA_FILTER"), out enableDataFilter);
+ }
lastPzCountSend = DateTime.Now;
lastWarnODL = DateTime.Now;
}
@@ -199,6 +208,7 @@ namespace IOB_WIN
}
protected void DevicesSuccessful(MTConnectDevices.Document document)
{
+ lgInfo("STEP DevicesSuccessful reached!");
MtcDataItemExt currDataItem = null;
machDataItem currMapoDataItem = null;
List elencoDataItems = new List();
@@ -218,55 +228,7 @@ namespace IOB_WIN
lgInfo(sVal);
try
{
- // uuid e parametri secondo categoria...
- switch (dataItem.Category)
- {
- case MTConnect.DataItemCategory.CONDITION:
- uuid = $"C_{dataItem.Id}";
- threshDBand = 0;
- dSamplePeriod = 0;
- break;
- case MTConnect.DataItemCategory.EVENT:
- uuid = $"E_{dataItem.Id}";
- threshDBand = 0;
- dSamplePeriod = 0;
- break;
- case MTConnect.DataItemCategory.SAMPLE:
- uuid = $"S_{dataItem.Id}";
- threshDBand = 1;
- if (dataItem.Id.EndsWith("PosAct") || dataItem.Id.EndsWith("PosTgt"))
- {
- threshDBand = 5;
- }
- dSamplePeriod = 60;
- break;
- default:
- break;
- }
- // salvo oggetto x "uso interno"
- currDataItem = new MtcDataItemExt()
- {
- Id = dataItem.Id,
- Category = dataItem.Category,
- Constraints = dataItem.Constraints,
- CoordinateSystem = dataItem.CoordinateSystem,
- Name = dataItem.Name,
- NativeScale = dataItem.NativeScale,
- NativeUnits = dataItem.NativeUnits,
- SampleRate = dataItem.SampleRate,
- Representation = dataItem.Representation,
- SignificantDigits = dataItem.SignificantDigits,
- Source = dataItem.Source,
- Statistic = dataItem.Statistic,
- SubType = dataItem.SubType,
- Type = dataItem.Type,
- TypePath = dataItem.TypePath,
- Units = dataItem.Units,
- XPath = dataItem.XPath,
- uid = uuid,
- thresholdDeadBand = threshDBand,
- samplePeriod = dSamplePeriod
- };
+ currDataItem = formatDataItem(ref dSamplePeriod, ref threshDBand, ref uuid, dataItem);
// aggiungo
dataItemMem.Add(dataItem.Id, currDataItem);
// salvo oggetto x registrazione su server MP-IO
@@ -282,8 +244,10 @@ namespace IOB_WIN
// aggiungo
elencoDataItems.Add(currMapoDataItem);
}
- catch
- { }
+ catch (Exception exc)
+ {
+ lgError($"Eccezione in DevicesSuccessful / DataItem:{Environment.NewLine}{exc}");
+ }
}
// invio IN BLOCCO il dataItem serializzati...
sendDataItemsList(elencoDataItems);
@@ -291,6 +255,76 @@ namespace IOB_WIN
}
}
}
+
+ private MtcDataItemExt formatDataItem(ref int dSamplePeriod, ref int threshDBand, ref string uuid, MTConnectDevices.DataItem dataItem)
+ {
+ MtcDataItemExt currDataItem;
+ // uuid e parametri secondo categoria...
+ switch (dataItem.Category)
+ {
+ case MTConnect.DataItemCategory.CONDITION:
+ uuid = $"C_{dataItem.Id}";
+ threshDBand = 0;
+ dSamplePeriod = 0;
+ break;
+ case MTConnect.DataItemCategory.EVENT:
+ uuid = $"E_{dataItem.Id}";
+ threshDBand = 0;
+ dSamplePeriod = 0;
+ break;
+ case MTConnect.DataItemCategory.SAMPLE:
+ uuid = $"S_{dataItem.Id}";
+ // SOLOS E è abilitato il datafiltering...
+ if (enableDataFilter)
+ {
+ threshDBand = 1;
+ if (dataItem.Id.EndsWith("PosAct") || dataItem.Id.EndsWith("PosTgt"))
+ {
+ threshDBand = 5;
+ }
+ }
+ else
+ {
+ threshDBand = 0;
+ }
+ dSamplePeriod = 60;
+ break;
+ default:
+ break;
+ }
+ // salvo oggetto x "uso interno"
+ currDataItem = new MtcDataItemExt()
+ {
+ Id = dataItem.Id,
+ Category = dataItem.Category,
+ Constraints = dataItem.Constraints,
+ CoordinateSystem = dataItem.CoordinateSystem,
+ Name = dataItem.Name,
+ NativeScale = dataItem.NativeScale,
+ NativeUnits = dataItem.NativeUnits,
+ SampleRate = dataItem.SampleRate,
+ Representation = dataItem.Representation,
+ SignificantDigits = dataItem.SignificantDigits,
+ Source = dataItem.Source,
+ Statistic = dataItem.Statistic,
+ SubType = dataItem.SubType,
+ Type = dataItem.Type,
+ TypePath = dataItem.TypePath,
+ Units = dataItem.Units,
+ XPath = dataItem.XPath,
+ uid = uuid,
+ thresholdDeadBand = threshDBand,
+ samplePeriod = dSamplePeriod
+ };
+ // lo g x capire COME ho chiamato alcune cosette...
+ if (dataItem.Id.Contains("EXE_MODE") || dataItem.Id.Contains("RUN_MODE") || dataItem.Id.Contains("POWER") || dataItem.Id.EndsWith("_Status"))
+ {
+ lgInfo($"DEBUG DATA | dataItem.Id : {dataItem.Id}");
+ }
+
+ return currDataItem;
+ }
+
///
/// Effettua invio a MP/IO dell'elenco serializzato dei dataItems
///
@@ -321,9 +355,14 @@ namespace IOB_WIN
///
protected bool checkSaveItem(MTConnectStreams.DataItem newValue)
{
- bool answ = false;
+ bool answ = !enableDataFilter;
+
if (newValue != null)
{
+ if (utils.CRB("verbose"))
+ {
+ lgInfo($"Richiesta checkSaveItem per {newValue} | id: {newValue.DataItemId} | CDATA: {newValue.CDATA}");
+ }
// verifico in memoria se ho l'oggetto condition ed il suo valore..
if (dataItemMem.ContainsKey(newValue.DataItemId))
{
@@ -332,6 +371,38 @@ namespace IOB_WIN
dataItemMem[newValue.DataItemId].valueTimestamp = newValue.Timestamp;
answ = true;
}
+ else
+ {
+ // registro non trovato da aggiungere...
+ lgInfo($"DataItem non trovato in checkSaveItem: {newValue.DataItemId}");
+#if false
+ List elencoDataItems = new List();
+ int dSamplePeriod = 0;
+ int threshDBand = 0;
+ string uuid = "";
+ var currDataItem = formatDataItem(ref dSamplePeriod, ref threshDBand, ref uuid, (MTConnectDevices.DataItem)newValue);
+ // aggiungo
+ dataItemMem.Add(newValue.DataItemId, currDataItem);
+ // salvo oggetto x registrazione su server MP-IO
+ var currMapoDataItem = new machDataItem()
+ {
+ uuid = newValue.DataItemId,
+ Category = (DataItemCategory)newValue.Category,
+ Name = newValue.Name,
+ Type = newValue.Type,
+ SubType = newValue.SubType,
+ //Units = newValue.Units
+ };
+ // aggiungo
+ elencoDataItems.Add(currMapoDataItem);
+ // invio IN BLOCCO il dataItem serializzati...
+ sendDataItemsList(elencoDataItems);
+#endif
+ }
+ }
+ else
+ {
+ lgError("Attenzione: checkSaveItem con newValue null!");
}
return answ;
}
@@ -342,11 +413,15 @@ namespace IOB_WIN
///
protected bool checkSaveSample(MTConnectStreams.Sample newValue)
{
- bool answ = false;
+ bool answ = !enableDataFilter;
double oldVal = 0;
double newVal = 0;
if (newValue != null)
{
+ if (utils.CRB("verbose"))
+ {
+ lgInfo($"Richiesta checkSaveSample per {newValue} | id: {newValue.DataItemId} | CDATA: {newValue.CDATA}");
+ }
// verifico in memoria se ho l'oggetto condition ed il suo valore..
if (dataItemMem.ContainsKey(newValue.DataItemId))
{
@@ -365,6 +440,10 @@ namespace IOB_WIN
// controllo SE ho DeadBand...
if (dataItemMem[newValue.DataItemId].thresholdDeadBand > 0)
{
+ if (utils.CRB("verbose"))
+ {
+ lgInfo($"Test deadband: oldVal: {oldVal} | newVal: {newVal}");
+ }
// recupero i valori e testo DeadBand...
double.TryParse(dataItemMem[newValue.DataItemId].value.Replace(".", ","), out oldVal);
double.TryParse(newValue.CDATA.Replace(".", ","), out newVal);
@@ -384,6 +463,15 @@ namespace IOB_WIN
dataItemMem[newValue.DataItemId].valueTimestamp = newValue.Timestamp;
}
}
+ else
+ {
+ // registro non trovato da aggiungere...
+ lgInfo($"DataItem non trovato in checkSaveSample: {newValue.DataItemId}");
+ }
+ }
+ else
+ {
+ lgError("Attenzione: checkSaveItem con newValue null!");
}
return answ;
}
@@ -405,14 +493,17 @@ namespace IOB_WIN
{
descr = itemTranslation("C", dataItem.DataItemId);
locTStamp = dataItem.Timestamp.ToLocalTime();
- sVal = $"CONDITION: {locTStamp.ToString()} | descr: {descr} | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
+ sVal = $"CONDITION: {locTStamp.ToString()} | descr: {descr} | Id: {dataItem.DataItemId} | | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
lgInfo(sVal);
+ DateTime tStamp = dataItem.Timestamp;
+ var time2 = tStamp.ToLocalTime();
// verifico se salvare
bool changed = checkSaveItem(dataItem);
if (changed)
{
// accodare ed invia nella coda ALARMS (che POI salva in document MongoDB anche ultimi x minuti di FluxLog...)
- accodaAlarmLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA));
+ accodaAlarmLog(sVal, qEncodeFLog(time2, descr, dataItem.CDATA));
+ //accodaAlarmLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA));
}
}
}
@@ -426,7 +517,7 @@ namespace IOB_WIN
{
descr = itemTranslation("E", dataItem.DataItemId);
locTStamp = dataItem.Timestamp.ToLocalTime();
- sVal = $"EVENT: {locTStamp.ToString()} | descr: {descr} | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
+ sVal = $"EVENT: {locTStamp.ToString()} | descr: {descr} | Id: {dataItem.DataItemId} | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
lgInfo(sVal);
DateTime tStamp = dataItem.Timestamp;
var time2 = tStamp.ToLocalTime();
@@ -434,7 +525,8 @@ namespace IOB_WIN
bool changed = checkSaveItem(dataItem);
if (changed)
{
- accodaFLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA));
+ accodaFLog(sVal, qEncodeFLog(time2, descr, dataItem.CDATA));
+ //accodaFLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA));
}
}
}
@@ -449,7 +541,7 @@ namespace IOB_WIN
{
descr = itemTranslation("S", dataItem.DataItemId);
locTStamp = dataItem.Timestamp.ToLocalTime();
- sVal = $"SAMPLE: {locTStamp.ToString()} | descr: {descr} | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
+ sVal = $"SAMPLE: {locTStamp.ToString()} | descr: {descr} | Id: {dataItem.DataItemId} | | Name: {dataItem.Name} | Val: {dataItem.CDATA}";
lgInfo(sVal);
// verifico se salvare
bool changed = checkSaveSample(dataItem);
@@ -457,6 +549,13 @@ namespace IOB_WIN
{
accodaFLog(sVal, qEncodeFLog(locTStamp, descr, dataItem.CDATA));
}
+ else
+ {
+ if (utils.CRB("verbose"))
+ {
+ lgInfo($"NON ACCODATO sample poiché verifica variazioen ha dato esito negativo");
+ }
+ }
}
}
catch
@@ -735,16 +834,20 @@ namespace IOB_WIN
// Controllo booleano PING e POWERON...
bool checkPing = (testPingMachine == IPStatus.Success);
string currPowerOn = "";
+ MtcDataItemExt currMTC_DI = null;
try
{
- var exeMode = dataItemMem["POWER"];
- currPowerOn = exeMode.value;
+ currMTC_DI = dataItemMem["POWER"];
+ currPowerOn = currMTC_DI.value;
}
- catch
- { }
+ catch (Exception exc)
+ {
+ //lgError($"Eccezione in decodifica currPowerOn: {Environment.NewLine}{exc}");
+ }
+
bool checkPowerOn = (currPowerOn == "ON");
- // bit 0 (poweron) imposto a 1 SE pingo o ho PowerOn...
+ // bit 0 (poweron) imposto a 1 SE pingo o PowerOn=="ON"...
B_input = (checkPing || checkPowerOn) ? 1 : 0;
@@ -754,25 +857,31 @@ namespace IOB_WIN
string currUnOpStatus = "";
try
{
- var exeMode = dataItemMem["Path_01_EXE_MODE"];
- currExe = exeMode.value;
+ currMTC_DI = dataItemMem["Path_01_EXE_MODE"];
+ currExe = currMTC_DI.value;
+ }
+ catch (Exception exc)
+ {
+ //lgError($"Eccezione in decodifica exeMode: {Environment.NewLine}{exc}");
}
- catch
- { }
try
{
- var runMode = dataItemMem["Path_01_RUN_MODE"];
- currRun = runMode.value;
+ currMTC_DI = dataItemMem["Path_01_RUN_MODE"];
+ currRun = currMTC_DI.value;
+ }
+ catch (Exception exc)
+ {
+ //lgError($"Eccezione in decodifica runMode: {Environment.NewLine}{exc}");
}
- catch
- { }
try
{
- var UnOp_Status = dataItemMem["ST_UnOp_01_Status"];
- currUnOpStatus = UnOp_Status.value;
+ currMTC_DI = dataItemMem["ST_UnOp_01_Status"];
+ currUnOpStatus = currMTC_DI.value;
+ }
+ catch (Exception exc)
+ {
+ //lgError($"Eccezione in decodifica UnOp_Status: {Environment.NewLine}{exc}");
}
- catch
- { }
// controllo lavora...
if (currRun == "AUTOMATIC" || currRun == "SEMI_AUTO")
@@ -795,6 +904,11 @@ namespace IOB_WIN
{
// se ho run mode != auto --> manual
B_input += (1 << 4);
+ // loggo cosa sia curr run!
+ if (utils.CRB("verbose"))
+ {
+ lgInfo($"Indicato manuale | currRun = {currRun}");
+ }
}
@@ -837,9 +951,31 @@ namespace IOB_WIN
// log opzionale!
if (verboseLog)
{
- lgInfo(string.Format("Trasformazione B_input: {0}", B_input));
+ lgInfo($"Trasformazione B_input: {B_input} | currRun = {currRun} | currExe = {currExe} | currUnOpStatus {currUnOpStatus}");
}
}
+ ///
+ /// Verifica un DataItem e se il valore corrisponde a quello indicato come "true value" restituisce true
+ ///
+ ///
+ ///
+ ///
+ protected bool checkDataItem(string itemName, string trueVal)
+ {
+ bool answ = false;
+ MtcDataItemExt currValue = null;
+ try
+ {
+ currValue = dataItemMem[itemName];
+ answ = (currValue.value.Equals(trueVal));
+ }
+ catch
+ {
+ lgError($"Errore in decodifica valore per {itemName} rispetto a {trueVal} | recuperato {currValue} / {currValue.value}");
+ }
+ return answ;
+ }
+
///
/// Recupero dati dinamici...
///
diff --git a/Jenkinsfile b/Jenkinsfile
index 82973a6b..f288335f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -16,7 +16,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
- withEnv(['NEXT_BUILD_NUMBER=550']) {
+ withEnv(['NEXT_BUILD_NUMBER=557']) {
// 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'