From 1b9f5c6896060b39b00634a15352436a95128e98 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 26 Jul 2017 10:37:46 +0200 Subject: [PATCH] completata revisione counters --- MTC_Adapter/MTC_Adapter/AdapterGeneric.cs | 212 ++++++++++++---------- 1 file changed, 113 insertions(+), 99 deletions(-) diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index 1b0609d..4a3e7f5 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -4117,6 +4117,49 @@ namespace MTC_Adapter #region metodi che prevedono salvataggio valori su file XML/BIN + /// + /// Processing delle variabili generiche Counters + /// + /// + /// + public bool procCounters(bool needSave) + { + uint delta = 0; + uint valore = 0; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mCounters.Length; i++) + { + // procedo solo SE HO FINESTRA VALIDA... + if (istCounters[i].vcValid) + { + valore = Convert.ToUInt32(istCounters[i].vcMedian); + if (valore >= currCounters[i]) + { + delta = valore - currCounters[i]; + // controllo delta < 50% max... + if (delta < uint.MaxValue / 2) + { + //processo comunque sempre... + uint contTot = updateValUIntByIncr(i, delta, "Counter_{0:000}"); + // passo valore totale all'adapter + mCounters[i].Value = contTot; + // controllo valore riferimento... + if (delta > 0) + { + // segnalo necessità salvataggio! + needSave = true; + } + } + } + // ...aggiorno valore riferimento... + currCounters[i] = valore; + } + sb.AppendLine(mCounters[i].ToString().Replace("|", " | ")); + } + // salvo su maschera... + parentForm.dataMonitor_2 += sb.ToString(); + return needSave; + } /// /// Processing delle ore macchina ACCESA /// @@ -4124,32 +4167,37 @@ namespace MTC_Adapter /// public bool procOreMaccOn(bool needSave) { + double delta = 0; + double valore = 0; + StringBuilder sb = new StringBuilder(); if (istOreMaccOn.vcValid) { - double delta = istOreMaccOn.vcMedian - contOreMaccOn; - // controllo delta < 50% max... - if (delta < double.MaxValue / 2) + valore = istOreMaccOn.vcMedian; + if (valore >= contOreMaccOn) { - // processo comunque sempre... - double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME"); - currAdpConf.ContOreMaccOn += delta; - // salvo valore su persistent layer - mAccTime.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture); - // controllo incremento... - if (delta > 0) + delta = valore - contOreMaccOn; + // controllo delta < 50% max... + if (delta < double.MaxValue / 2) { - // segnalo necessità salvataggio! - needSave = true; + // processo comunque sempre... + double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME"); + currAdpConf.ContOreMaccOn += delta; + // salvo valore su persistent layer + mAccTime.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture); + // controllo incremento... + if (delta > 0) + { + // segnalo necessità salvataggio! + needSave = true; + } } - // salvo su maschera... - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format("ACC_TIME: {0}", mAccTime.Value)); - parentForm.dataMonitor_1 += sb.ToString(); - - // ...aggiorno valore riferimento... - contOreMaccOn = istOreMaccOn.vcMedian; } + // ...aggiorno valore riferimento... + contOreMaccOn = valore; } + // salvo su maschera... + sb.AppendLine(string.Format("ACC_TIME: {0}", mAccTime.Value)); + parentForm.dataMonitor_1 += sb.ToString(); return needSave; } /// @@ -4159,31 +4207,36 @@ namespace MTC_Adapter /// public bool procOreMaccLav(bool needSave) { + double delta = 0; + double valore = 0; + StringBuilder sb = new StringBuilder(); if (istOreMaccLav.vcValid) { - double delta = istOreMaccLav.vcMedian - contOreMaccLav; - // controllo delta < 50% max... - if (delta < double.MaxValue / 2) + valore = istOreMaccLav.vcMedian; + if (valore >= contOreMaccLav) { - double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK"); - currAdpConf.ContOreMaccLav += delta; - // salvo valore su persistent layer - mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture); - // controllo valore riferimento... - if (delta > 0) + delta = valore - contOreMaccLav; + // controllo delta < 50% max... + if (delta < double.MaxValue / 2) { - // segnalo necessità salvataggio! - needSave = true; + double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK"); + currAdpConf.ContOreMaccLav += delta; + // salvo valore su persistent layer + mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture); + // controllo valore riferimento... + if (delta > 0) + { + // segnalo necessità salvataggio! + needSave = true; + } } - // salvo su maschera... - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format("ACC_TIME_WORK: {0}", mAccTimeWork.Value)); - parentForm.dataMonitor_1 += sb.ToString(); - - // ...aggiorno valore riferimento... - contOreMaccLav = istOreMaccLav.vcMedian; } + // ...aggiorno valore riferimento... + contOreMaccLav = valore; } + // salvo su maschera... + sb.AppendLine(string.Format("ACC_TIME_WORK: {0}", mAccTimeWork.Value)); + parentForm.dataMonitor_1 += sb.ToString(); return needSave; } /// @@ -4193,31 +4246,36 @@ namespace MTC_Adapter /// public bool procSlittaTast(bool needSave) { + double delta = 0; + double valore = 0; + StringBuilder sb = new StringBuilder(); if (istSlittaTast.vcValid) { - double delta = istSlittaTast.vcMedian - contSlittaTast; - // controllo delta < 50% max... - if (delta < double.MaxValue / 2) + valore = istSlittaTast.vcMedian; + if (valore >= contSlittaTast) { - double contatore = updateValDoubleByIncr(0, delta, "SlittaTastatore_Count"); - currAdpConf.ContSlittaTast += delta; - // salvo valore su persistent layer - mSlittaTast.Value = contatore.ToString("0", CultureInfo.InvariantCulture); - // controllo valore riferimento... - if (delta > 0) + delta = valore - contSlittaTast; + // controllo delta < 50% max... + if (delta < double.MaxValue / 2) { - // segnalo necessità salvataggio! - needSave = true; + double contatore = updateValDoubleByIncr(0, delta, "SlittaTastatore_Count"); + currAdpConf.ContSlittaTast += delta; + // salvo valore su persistent layer + mSlittaTast.Value = contatore.ToString("0", CultureInfo.InvariantCulture); + // controllo valore riferimento... + if (delta > 0) + { + // segnalo necessità salvataggio! + needSave = true; + } } - // salvo su maschera... - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format("SlittaTastatore_Count: {0}", mSlittaTast.Value)); - parentForm.dataMonitor_1 += sb.ToString(); - - // ...aggiorno valore riferimento... - contSlittaTast = istSlittaTast.vcMedian; } + // ...aggiorno valore riferimento... + contSlittaTast = valore; } + // salvo su maschera... + sb.AppendLine(string.Format("SlittaTastatore_Count: {0}", mSlittaTast.Value)); + parentForm.dataMonitor_1 += sb.ToString(); return needSave; } /// @@ -4292,7 +4350,6 @@ namespace MTC_Adapter if (istPathPartCount[i].vcMedian > currPathPartCount[i]) { uint delta = Convert.ToUInt32(istPathPartCount[i].vcMedian) - currPathPartCount[i]; - //uint contatore = updatePathRefListByIncr(i, delta, "Path_{0:00}_PZ_TOT"); uint contatore = updateValUIntByIncr(i, delta, "Path_{0:00}_PZ_TOT"); // passo valore num pz all'adapter vettPath[i].mPathPartCount.Value = contatore; @@ -4656,49 +4713,6 @@ namespace MTC_Adapter return needSave; } /// - /// Processing delle variabili generiche Counters - /// - /// - /// - public bool procCounters(bool needSave) - { - uint delta = 0; - uint valore = 0; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < mCounters.Length; i++) - { - // procedo solo SE HO FINESTRA VALIDA... - if (istCounters[i].vcValid) - { - valore = Convert.ToUInt32(istCounters[i].vcMedian); - if (valore >= currCounters[i]) - { - delta = valore - currCounters[i]; - // controllo delta < 50% max... - if (delta < uint.MaxValue / 2) - { - //processo comunque sempre... - uint contTot = updateValUIntByIncr(i, delta, "Counter_{0:000}"); - // passo valore totale all'adapter - mCounters[i].Value = contTot; - // controllo valore riferimento... - if (delta > 0) - { - // segnalo necessità salvataggio! - needSave = true; - } - } - } - // ...aggiorno valore riferimento... - currCounters[i] = valore; - } - sb.AppendLine(mCounters[i].ToString().Replace("|", " | ")); - } - // salvo su maschera... - parentForm.dataMonitor_2 += sb.ToString(); - return needSave; - } - /// /// Processing delle variabili sui componenti SlittaMag /// ///