Esempio n. 1
0
        /// <summary>
        /// Creates an EOS Bus Device for an address and the supplied info packet from the device.
        /// </summary>
        /// <param name="bus">Bus that this device is attached to.</param>
        /// <param name="address">Address which this device is assigned.</param>
        /// <param name="data">Data from this devices INFO_RESPONSE packet.</param>
        internal EosDevice(EosBus bus, byte address, List <byte> data)
        {
            _bus           = bus;
            _address       = address;
            _pollingErrors = 0;

            byte[] stringBuffer = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            int length = 8;

            for (int i = 0; i < 8; i++)
            {
                if (data[i] == 0)
                {
                    length = i;
                    break;
                }
                stringBuffer[i] = data[i];
            }
            _name = System.Text.ASCIIEncoding.ASCII.GetString(stringBuffer, 0, length);

            length = 4;
            for (int i = 0; i < 4; i++)
            {
                if (data[i] == 0)
                {
                    length = i;
                    break;
                }
                stringBuffer[i] = data[i + 8];
            }
            stringBuffer[4] = 0;
            _firmware       = System.Text.ASCIIEncoding.ASCII.GetString(stringBuffer, 0, 4);

            _digialInputs         = data[12];
            _analogInputs         = data[13];
            _rotaryEncoders       = data[14];
            _ledOutputs           = data[15];
            _steppers             = data[16];
            _servos               = data[17];
            _alphaNumericDisplays = data[18];
            _groupAddress         = data[19];
            if (data.Count >= 21)
            {
                _coilOutputs = data[20];
            }


            _powerPacket = new EosPacket(Address, EosBusCommands.BACKLIGHT_POWER);
            _powerPacket.Add((byte)0);
            _powerPacket.IsSent = true;

            _levelPacket = new EosPacket(Address, EosBusCommands.BACKLIGHT_LEVEL);
            _levelPacket.Add((byte)0);
            _levelPacket.IsSent = true;
        }
Esempio n. 2
0
 public EosCommandProcessor(EosBus bus)
 {
     _bus = bus;
 }