Beispiel #1
0
        /// <summary>
        /// Run method of the background pulling thread to check the input port of the
        /// robot. The robot does not support interrupts (-.-), so a stupid polling is needed.
        /// </summary>
        private void Run()
        {
            int oldData = -1;
            int newData;

            run = true;
            while (run)
            {
                newData = this.Data;
                if (oldData != newData)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        bool oldBit = RobotHelper.GetBitFromInteger(oldData, i);
                        bool newBit = RobotHelper.GetBitFromInteger(newData, i);
                        if (oldBit != newBit)
                        {
                            this.OnDigitalInChanged(new SwitchEventArgs((Switches)i, newBit));
                        }
                    }
                }

                oldData = newData;
                Thread.Sleep(50);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Access a single bit of the input.
 /// </summary>
 /// <param name="bit">index of the bit to access [0..3]</param>
 /// <returns>TRUE if the bit is 1, FALSE if the bit is 0</returns>
 public virtual bool this[int bit]
 {
     get
     {
         return(RobotHelper.GetBitFromInteger(this.Data, bit));
     }
 }
Beispiel #3
0
 /// <summary>
 /// Access a single bit of the output.
 /// </summary>
 ///
 /// <param name="bit">index of the bit to access [0..3]</param>
 /// <returns>TRUE if the bit is 1, FALSE if the bit is 0</returns>
 public virtual bool this[int bit]
 {
     get
     {
         return(RobotHelper.GetBitFromInteger(data, bit));
     }
     set
     {
         this.Data = RobotHelper.SetBitOfInteger(data, bit, value);
     }
 }