va testato meglio in debug, ma SEMBRA OK il prefiltraggio dati...

This commit is contained in:
Samuele E. Locatelli
2017-10-21 10:17:49 +02:00
parent da99d598f8
commit b12c890e66
3 changed files with 676 additions and 31 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
<!-- ciclo corto x invio a server: 5ms-->
<add key="timerIntMs" value="5"/>
<!--lettura a monte ogni X cicli: 5msx20=100ms-->
<add key="fastCount" value="10"/>
<add key="fastCount" value="5"/>
<!--Modalità DEMO: DemoOUT indica che NON invia davvero al server e DemoIN che simula e NON legge da PLC-->
<add key="DemoIn" value="true"/>
+659 -21
View File
@@ -23,33 +23,131 @@
1
; allarme (BLINK)
9
1
9
9
9
9
1
9
1
1
1
1
1
9
9
9
9
9
1
1
1
1
1
19
9
9
9
9
1
1
1
1
1
1
; allarme manuale (2 blink, periodo diverso)
25
17
9
1
25
17
9
1
25
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
; indico manuale
17
17
17
17
17
17
17
17
17
17
1
1
1
1
1
1
1
1
17
17
17
17
17
17
17
17
17
17
1
1
1
1
1
1
1
1
17
17
17
17
17
17
17
17
17
17
1
1
1
1
1
1
1
1
; RUN!
@@ -97,9 +195,47 @@
3
; contapezzo
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
; RUN
@@ -147,11 +283,49 @@
3
; contapezzo
7
3
3
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
; RUN
3
3
@@ -195,38 +369,300 @@
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
; contapezzo
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
; RUN
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
; allarme (BLINK)
9
1
9
9
9
9
1
9
1
1
1
1
1
9
9
9
9
9
1
1
1
1
1
19
9
9
9
9
1
1
1
1
1
1
; allarme manuale (2 blink, periodo diverso)
25
17
9
1
25
17
9
1
25
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
25
25
17
17
9
9
1
1
; indico manuale
17
17
1
1
17
17
17
17
17
17
17
17
1
1
; RUN
1
1
1
1
1
1
17
17
17
17
17
17
17
17
17
17
1
1
1
1
1
1
1
1
17
17
17
17
17
17
17
17
17
17
1
1
1
1
1
1
1
1
; RUN!
3
3
3
@@ -271,9 +707,47 @@
3
; contapezzo
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
; RUN
@@ -318,4 +792,168 @@
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
; contapezzo
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
7
7
7
7
7
3
3
3
3
3
3
; RUN
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
+16 -9
View File
@@ -1165,7 +1165,7 @@ namespace IOB_WIN
/// Esegue filtraggio dati x bit blinking!!!
/// </summary>
private void filterData()
{
{
// effettuo filtraggio dei valori letti... inizializzo OUT!
B_output = 0;
// in primis verifico SE ci siano bit blinkng... se non ci sono OUT=IN...
@@ -1181,11 +1181,9 @@ namespace IOB_WIN
int iBlink = B_input & currIobConf.BLINK_FILT;
// ...aggiungo i "bit che passano"
B_output += iBlink;
// calcolo fronte di salita (0 --> 1 dei bit BLINK)
int iFronte = (B_input & ~B_previous) & currIobConf.BLINK_FILT;
// calcolo QUALI valori (tra quelli blink) siano PASSATI da 0 a 1 --> init counters...
BitArray bBlinkStart = new BitArray(new byte[] { Convert.ToByte(iFronte) });
BitArray bBlinkStart = new BitArray(new byte[] { Convert.ToByte(iBlink) });
int[] bitsUp = bBlinkStart.Cast<bool>().Select(bit => bit ? 1 : 0).ToArray();
for (int i = 0; i < bitsUp.Length; i++)
{
@@ -1193,7 +1191,10 @@ namespace IOB_WIN
if (bitsUp[i] == 1)
{
// se era zero indico START blink...
if(i_counters[i]==0) lg.Info("START BLINK: B{0}", i);
if (i_counters[i] == 0)
{
lg.Info("START BLINK: B{0}", i);
}
// imposto comunque contatore al cambio fronte...
i_counters[i] = currIobConf.MAX_COUNTER_BLINK;
}
@@ -1213,6 +1214,8 @@ namespace IOB_WIN
{
// decremento!
i_counters[i] -= 1;
if (countSim == 0)
{ }
// se è zero NON faccio nulla, altrimenti SOMMO...
if (i_counters[i] > 0)
{
@@ -1361,7 +1364,12 @@ namespace IOB_WIN
}
// processo la coda di simulazione (stacco ed accodo 1 valore...)
B_input = QueueSIM.Dequeue();
//Strobes = BitConverter.GetBytes(QueueSIM.Dequeue());
countSim++;
// ogni 5 loggo...
if (countSim % 5 == 0)
{
lg.Info("Read {0} sim data", countSim);
}
}
else
{
@@ -1375,8 +1383,7 @@ namespace IOB_WIN
{
countSim++;
if (countSim > 255) countSim = 0;
B_input =countSim;
//Strobes = BitConverter.GetBytes(countSim);
B_input = countSim;
}
lastSim = DateTime.Now;
}