diff --git a/IOB-WIN/IOB-WIN/App.config b/IOB-WIN/IOB-WIN/App.config index 366bd6b..6ba23a6 100644 --- a/IOB-WIN/IOB-WIN/App.config +++ b/IOB-WIN/IOB-WIN/App.config @@ -10,7 +10,7 @@ - + diff --git a/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini b/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini index 3ad6113..627984d 100644 --- a/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini +++ b/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini @@ -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 diff --git a/IOB-WIN/IOB-WIN/IobConfiguration.cs b/IOB-WIN/IOB-WIN/IobConfiguration.cs index cf3ab0d..c015745 100644 --- a/IOB-WIN/IOB-WIN/IobConfiguration.cs +++ b/IOB-WIN/IOB-WIN/IobConfiguration.cs @@ -45,6 +45,14 @@ namespace IOB_WIN /// Porta del CNC Controllato /// public tipoAdapter tipoIob { get; set; } + /// + /// Valore MAX per countdown segnali blinking + /// + public int MAX_COUNTER_BLINK; + /// + /// Valore intero corrispondente ai BIT da filtrare x blinking + /// + public int BLINK_FILT; /// /// 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; } } diff --git a/IOB-WIN/IOB-WIN/IobGeneric.cs b/IOB-WIN/IOB-WIN/IobGeneric.cs index 6089a25..1003617 100644 --- a/IOB-WIN/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IOB-WIN/IobGeneric.cs @@ -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); } } + /// + /// Array dei contatori x segnali blinking + /// + protected int[] i_counters; + /// + /// Vettore 16 BIT valori precedenti + /// + protected int B_previous; + /// + /// Vettore 16 BIT valori in ingresso al filtro + /// + protected int B_input; + /// + /// Vettore 16 BIT valori in uscita dal filtro + /// + protected int B_output; + /// /// Determina se utilizzare blocchi di memoria IOT contigui (e quindi processing "monoblocco" semplificato"= /// @@ -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 /// 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().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().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; + } + } + } } /// /// Fornisce il valore letto da BITMAP in formato valido x messa in coda nel formato dtEve#value#cont diff --git a/IOB-WIN/IOB-WIN/MainForm.cs b/IOB-WIN/IOB-WIN/MainForm.cs index 92a10a6..d9f1618 100644 --- a/IOB-WIN/IOB-WIN/MainForm.cs +++ b/IOB-WIN/IOB-WIN/MainForm.cs @@ -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; - } + } } /// /// 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)); } - + /// /// impostazione valori defaults /// @@ -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..."); - } + } } /// @@ -833,7 +835,7 @@ namespace IOB_WIN { set { - bIN.BackColor= decSemaforo(value); + bIN.BackColor = decSemaforo(value); bIN.Refresh(); } }