UPDATE PARZIALE NON COMPLETO del filtering...

This commit is contained in:
2017-10-20 18:22:19 +02:00
parent 92fd46b403
commit 69fab9a76a
5 changed files with 117 additions and 14 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="20"/>
<add key="fastCount" value="10"/>
<!--Modalità DEMO: DemoOUT indica che NON invia davvero al server e DemoIN che simula e NON legge da PLC-->
<add key="DemoIn" value="true"/>
+13
View File
@@ -20,3 +20,16 @@ CMDREBO=/sendReboot.aspx?idxMacchina=
BITRED=Y8.4
BITYELLOW=Y8.5
BITGREEN=Y8.6
[BLINK]
;MAX_COUNTER_BLINK = 30
MAX_COUNTER_BLINK = 3
;bit0 = 0
;bit1 = 0
;bit2 = 1
;bit3 = 1
;bit4 = 1
;bit5 = 0
;bit6 = 0
;bit7 = 0
BLINK_FILT=28
+10
View File
@@ -45,6 +45,14 @@ namespace IOB_WIN
/// Porta del CNC Controllato
/// </summary>
public tipoAdapter tipoIob { get; set; }
/// <summary>
/// Valore MAX per countdown segnali blinking
/// </summary>
public int MAX_COUNTER_BLINK;
/// <summary>
/// Valore intero corrispondente ai BIT da filtrare x blinking
/// </summary>
public int BLINK_FILT;
/// <summary>
/// Avvio configurazione DUMMY
@@ -57,6 +65,8 @@ namespace IOB_WIN
cncPort = "0";
tipoIob = tipoAdapter.DEMO;
serverData = new serverMapo("127.0.0.1", "/", "/IOB/input/", "/IOB", "/IOB/enabled/", "/sendReboot.aspx?idxMacchina=");
MAX_COUNTER_BLINK = 1;
BLINK_FILT = 0;
}
}
+80 -2
View File
@@ -1,6 +1,7 @@
using IOB_UT;
using NLog;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -136,6 +137,23 @@ namespace IOB_WIN
return (StFlag32)BitConverter.ToUInt32(StrobesPrev, 0);
}
}
/// <summary>
/// Array dei contatori x segnali blinking
/// </summary>
protected int[] i_counters;
/// <summary>
/// Vettore 16 BIT valori precedenti
/// </summary>
protected int B_previous;
/// <summary>
/// Vettore 16 BIT valori in ingresso al filtro
/// </summary>
protected int B_input;
/// <summary>
/// Vettore 16 BIT valori in uscita dal filtro
/// </summary>
protected int B_output;
/// <summary>
/// Determina se utilizzare blocchi di memoria IOT contigui (e quindi processing "monoblocco" semplificato"=
/// </summary>
@@ -215,6 +233,15 @@ namespace IOB_WIN
numSim = utils.CRI("numSim");
nReadIN = 0;
nSendOut = 0;
// svuoto code...
QueueIN.Clear();
QueueSIM.Clear();
// imposto contatori blink a zero...
i_counters = new int[32];
//for (int i = 0; i < 32; i++)
//{
// i_counters[i] = 0;
//}
}
@@ -1053,7 +1080,7 @@ namespace IOB_WIN
if (IobOnline != answ)
{
// se ORA sono online riporto...
if(answ)
if (answ)
{
lg.Info("IOB ONLINE");
}
@@ -1136,7 +1163,58 @@ namespace IOB_WIN
/// </summary>
private void filterData()
{
// !!!FARE!!!
// per ora, PER TEST, copio i valori da stroibe a bits...
B_input = (int)STRB_DW0;
B_previous = (int)STRB_00_PREV;
// effettuo filtraggio dei valori letti... inizializzo OUT!
B_output = 0;
// in primis verifico SE ci siano bit blinkng... se non ci sono OUT=IN...
if (currIobConf.BLINK_FILT == 0)
{
B_output = B_input;
}
else
{
// incomincio con i valori NON blinking: questi "passano invariati", inizio a sommare nel valore OUT...
B_output = B_input & ~currIobConf.BLINK_FILT;
// calcolo il valore dei BIT che "passano la maschera"
int iBlink = B_input & currIobConf.BLINK_FILT;
// ...aggiungo i "bit che passano"
B_output += iBlink;
// calcolo QUALI valori (tra quelli blink) siano ad 1 x cui richiedono di inizializzare i counters al max val...
BitArray bBlink = new BitArray(new byte[] { Convert.ToByte(iBlink) });
int[] bitsUp = bBlink.Cast<bool>().Select(bit => bit ? 1 : 0).ToArray();
foreach (int item in bitsUp)
{
// e impostiamo contatori al MAX
i_counters[item] = currIobConf.MAX_COUNTER_BLINK;
}
// quelli che sono zero... LI RECUPERO E LI PROCESSO...
int iZero = ~B_input & currIobConf.BLINK_FILT;
BitArray bBlinkEnd = new BitArray(new byte[] { Convert.ToByte(iZero) });
int[] bitsDown = bBlinkEnd.Cast<bool>().Select(bit => bit ? 1 : 0).ToArray();
foreach (int item in bitsDown)
{
// !!!FARE NON VA BENE... legge tutto ma NON VA BENE (deve vedere INDICI...)
// va usata una funzione di trasformazione x la parte BLINK dei segnali x salvare i vettori IN/OUT e PREV... x testare se sia 0 e abbia finito counter... deve usare INDICE DEL VETTORE int[] x andare a controllare counters...
// decremento contatore
i_counters[item] = i_counters[item] - 1;
// controllo, se è 0 CONFERMO e NON faccio nulla (NON aggiungo)m sennò resta 1 ed aggiungo...
if (i_counters[item] > 0)
{
B_output += 1 << item;
}
else
{
// rimetto a zero counter...
i_counters[item] = 0;
}
}
}
}
/// <summary>
/// Fornisce il valore letto da BITMAP in formato valido x messa in coda nel formato dtEve#value#cont
+13 -11
View File
@@ -77,7 +77,7 @@ namespace IOB_WIN
#endregion
#region utils ed helpers
private class Item
{
public string Name;
@@ -180,7 +180,7 @@ namespace IOB_WIN
lg.Info("INI LOADED");
loadPersistLayer(utils.defPersLayerFile);
lg.Info("PersLayerFile READ");
iobObj.loadPersData();
iobObj.loadPersData();
lg.Info("PersLayerFile LOADED");
}
else
@@ -476,7 +476,7 @@ namespace IOB_WIN
stop.Enabled = false;
dump.Enabled = false;
start.Enabled = true;
start.Enabled = true;
if (stopTimer)
{
@@ -504,7 +504,9 @@ namespace IOB_WIN
codIOB = fIni.ReadString("IOB", "IDXMACC", "0"),
cncIpAddr = fIni.ReadString("CNC", "IP", "::1"),
cncPort = fIni.ReadString("CNC", "PORT", "0"),
serverData = new serverMapo(fIni.ReadString("SERVER", "MPIP", "::1"), fIni.ReadString("SERVER", "MPURL", "/"), fIni.ReadString("SERVER", "CMDBASE", "/"), fIni.ReadString("SERVER", "CMDALIVE", "/"), fIni.ReadString("SERVER", "CMDENABLED", "/"), fIni.ReadString("SERVER", "CMDREBO", "/"))
serverData = new serverMapo(fIni.ReadString("SERVER", "MPIP", "::1"), fIni.ReadString("SERVER", "MPURL", "/"), fIni.ReadString("SERVER", "CMDBASE", "/"), fIni.ReadString("SERVER", "CMDALIVE", "/"), fIni.ReadString("SERVER", "CMDENABLED", "/"), fIni.ReadString("SERVER", "CMDREBO", "/")),
MAX_COUNTER_BLINK = Convert.ToInt32(fIni.ReadString("BLINK", "MAX_COUNTER_BLINK", "1")),
BLINK_FILT = Convert.ToInt32(fIni.ReadString("BLINK", "BLINK_FILT", "0"))
};
loadIobType();
@@ -547,7 +549,7 @@ namespace IOB_WIN
}
// abbasso semaforo salvataggio
iobObj.adpSaving = false;
}
}
}
/// <summary>
/// Carica da file l'oggetto di persistenza dati
@@ -579,7 +581,7 @@ namespace IOB_WIN
numDD++;
}
// se sono uscito PROVO a passare il file storico letto buono (oppure vuoto...)
iobObj.persistenceLayer = lastRead;
iobObj.persistenceLayer = lastRead;
}
}
@@ -610,7 +612,7 @@ namespace IOB_WIN
loadPersistLayer(utils.defPersLayerFile);
lg.Info("PersLayerFile READ");
iobObj.loadPersData();
lg.Info("PersLayerFile LOADED");
lg.Info("PersLayerFile LOADED");
}
}
@@ -648,7 +650,7 @@ namespace IOB_WIN
displayTaskAndWait(string.Format("Caricata conf per adapter {0}", tipoScelto));
}
/// <summary>
/// impostazione valori defaults
/// </summary>
@@ -690,7 +692,7 @@ namespace IOB_WIN
private void start_Click(object sender, EventArgs e)
{
avviaAdapter();
iobObj.loadPersData();
iobObj.loadPersData();
// salvo che ho avviato adapter
lg.Info("Completato LOAD Adapter");
}
@@ -729,7 +731,7 @@ namespace IOB_WIN
else
{
displayTaskAndWait("Adapter STILL Running...");
}
}
}
/// <summary>
@@ -833,7 +835,7 @@ namespace IOB_WIN
{
set
{
bIN.BackColor= decSemaforo(value);
bIN.BackColor = decSemaforo(value);
bIN.Refresh();
}
}