Ejemplo n.º 1
0
 private void InputBinaryEventHandler_EventIsReached(object sender, InputBinaryEventArgs e)
 {
     try
     {
         var i = 0;
         foreach (var item in e.Store)
         {
             this.Input[i].Color = item.Value ? this.green : this.gray;
             ++i;
         }
     }
     catch (Exception ex)
     {
         this.Logger.LogError(ex);
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Raises the <see cref="E:NodeReached" /> event.
        /// </summary>
        /// <param name="e">The <see cref="InputBinaryEventArgs" /> instance containing the event data.</param>
        public virtual void OnReached(InputBinaryEventArgs e)
        {
            try
            {
                this.Logger.LogBegin(this.GetType());
                if (this.EventIsReached == null)
                {
                    throw new Exception("Event for binary input is null");
                }

                this.EventIsReached.Invoke(this, e);
            }
            catch (Exception exception)
            {
                this.Logger.LogError(exception);
                throw;
            }
            finally
            {
                this.Logger.LogEnd(this.GetType());
            }
        }
Ejemplo n.º 3
0
        private void HandleBinaryInputState(uint id, byte[] data)
        {
            try
            {
                if ((this.GetActualNodeId.Get() + CanCommandConsts.InputState) == id)
                {
                    var inputBinbaryArgs = new InputBinaryEventArgs();

                    for (byte i = 0; i < 16; i++)
                    {
                        var res = ((data[i / 8] >> (i % 8)) & 0x01) == 1;
                        inputBinbaryArgs.Add(i, res);
                    }

                    this.InputBinaryEventHandler.OnReached(inputBinbaryArgs);
                }
            }
            catch (Exception ex)
            {
                this.Logger.LogError(ex);
                throw;
            }
        }