diff --git a/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini b/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini index fec811a..2c0e8d9 100644 --- a/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini +++ b/IOB-WIN/IOB-WIN/DATA/CONF/IOB.ini @@ -4,7 +4,7 @@ CNCTYPE=FANUC IDXMACC=999 [CNC] -IP=127.0.0.1 +IP=192.168.139.1 PORT=8193 [SERVER] diff --git a/IOB-WIN/IOB-WIN/IobGeneric.cs b/IOB-WIN/IOB-WIN/IobGeneric.cs index 0c5e3f0..bcdd5c4 100644 --- a/IOB-WIN/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IOB-WIN/IobGeneric.cs @@ -42,6 +42,61 @@ namespace IOB_WIN /// Ultimo valore watchdog rilevato /// public bool lastWatchDog = false; + + + // 16 byte di strobe (4 word da 32 bit di flags...) + public byte[] Strobes = new byte[16]; + /// + /// Prima word di strobe da array flag completo + /// + public StFlag32 STRB_DW0 + { + get + { + return (StFlag32)BitConverter.ToUInt32(Strobes, 0); + } + } + /// + /// Seconda word di strobe da array flag completo + /// + public StFlag32 STRB_DW1 + { + get + { + return (StFlag32)BitConverter.ToUInt32(Strobes, 4); + } + } + /// + /// Terza word di strobe da array flag completo + /// + public StFlag32 STRB_DW2 + { + get + { + return (StFlag32)BitConverter.ToUInt32(Strobes, 8); + } + } + /// + /// Quarta word di strobe da array flag completo + /// + public StFlag32 STRB_DW3 + { + get + { + return (StFlag32)BitConverter.ToUInt32(Strobes, 12); + } + } + /// + /// Quarta word di strobe da array flag completo + /// + public StFlag32 STRB_DW4 + { + get + { + return (StFlag32)BitConverter.ToUInt32(Strobes, 16); + } + } + /// /// Determina se utilizzare blocchi di memoria IOT contigui (e quindi processing "monoblocco" semplificato"= /// diff --git a/IOB-WIN/IOB-WIN/MainForm.Designer.cs b/IOB-WIN/IOB-WIN/MainForm.Designer.cs index 24dcc5c..3b56c23 100644 --- a/IOB-WIN/IOB-WIN/MainForm.Designer.cs +++ b/IOB-WIN/IOB-WIN/MainForm.Designer.cs @@ -64,6 +64,10 @@ this.gbMonitor.SuspendLayout(); this.SuspendLayout(); // + // gather + // + this.gather.Tick += new System.EventHandler(this.gather_Tick); + // // statusStrip1 // this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); diff --git a/IOB-WIN/IOB-WIN/MainForm.cs b/IOB-WIN/IOB-WIN/MainForm.cs index 4f9d15f..5b7bfb7 100644 --- a/IOB-WIN/IOB-WIN/MainForm.cs +++ b/IOB-WIN/IOB-WIN/MainForm.cs @@ -342,6 +342,107 @@ namespace IOB_WIN #region gestione metodi specifici FORM + /// + /// Avanza la barra di stato... + /// + public void advProgBar() + { + try + { + MainProgrBar.PerformStep(); + MainProgrBar.Invalidate(); + } + catch + { } + } + private void checkNormTask() + { + + // decremento... + normCount--; + // se il counter è a zero eseguo... + if (normCount <= 0) + { + normCount = utils.CRI("normCount"); + + // avvio fase raccolta dati e invio con adapter + iobObj.gaterAndSend(gatherCycle.MF); + } + } + private void checkFastTask() + { + // decremento... + fastCount--; + // se il counter è a zero eseguo... + if (fastCount <= 0) + { + fastCount = utils.CRI("fastCount"); + + // avvio fase raccolta dati e invio con adapter + iobObj.gaterAndSend(gatherCycle.HF); + + refreshVisualStrobes(); + } + } + private void refreshVisualStrobes() + { + // aggiorno visualizzazione strobe! + STATUS_STRB_DW0.Text = utils.binaryForm((int)iobObj.STRB_DW0); + } + private void gather_Tick(object sender, EventArgs e) + { + // eseguo cicli attivi SOLO se adapter è in EFFETTIVO running... + if (iobObj.adpRunning) + { + // inizio a riportare che sto eseguendo.. + advProgBar(); + if (iobObj.connectionOk) + { + // check esecuzione FastTask + checkFastTask(); + // check esecuzione NormTask + checkNormTask(); +#if false + // check esecuzione SlowTask + checkSlowTask(); + // check esecuzione AlarmSync + checkAlarmSync(); + // check esecuzione SendTask (VHF) + checkSendTask(); +#endif + if (utils.CRI("waitEndCycle") > 0) + { + Thread.Sleep(utils.CRI("waitEndCycle")); + } + } + else + { + double currWait = DateTime.Now.Subtract(lastStartTry).TotalMilliseconds; + if (iobObj.adpTryRestart && currWait > utils.CRI("waitRecMSec")) + { + lastStartTry = DateTime.Now; + iobObj.tryConnect(); + iobObj.loadPersData(); + } + } + // se è arrivato a MAX resetto... + if (MainProgrBar.Value >= MainProgrBar.Maximum) + { + MainProgrBar.Value = 0; + } + } + else + { + // verifico SE debba tentare il riavvio, ovvero NON running ma tryReconn e non ho riprovato x oltre waitRecMSec + double currWait = DateTime.Now.Subtract(lastStartTry).TotalMilliseconds; + if (iobObj.adpTryRestart && currWait > utils.CRI("waitRecMSec")) + { + lastStartTry = DateTime.Now; + avviaAdapter(); + iobObj.loadPersData(); + } + } + } /// /// Chiusura adapter ///