Ejemplo n.º 1
0
 /// <summary>
 /// Set the RailDriver LEDs to the specified values
 /// </summary>
 /// <param name="led1"></param>
 /// <param name="led2"></param>
 /// <param name="led3"></param>
 public void SetLeds(byte led1, byte led2, byte led3)
 {
     if (device != null)
     {
         writeBuffer.Initialize();
         writeBuffer[1] = 134;
         writeBuffer[2] = led3;
         writeBuffer[3] = led2;
         writeBuffer[4] = led1;
         device.WriteData(writeBuffer);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Set the RailDriver LEDs to the specified values
 /// led1 is the right most
 /// </summary>
 /// <param name="led1"></param>
 /// <param name="led2"></param>
 /// <param name="led3"></param>
 void SetLEDs(byte led1, byte led2, byte led3)
 {
     if (Device == null)
     {
         return;
     }
     for (int i = 0; i < WriteBuffer.Length; i++)
     {
         WriteBuffer[i] = 0;
     }
     WriteBuffer[1] = 134;
     WriteBuffer[2] = led1;
     WriteBuffer[3] = led2;
     WriteBuffer[4] = led3;
     Device.WriteData(WriteBuffer);
 }
Ejemplo n.º 3
0
        public int WriteData(params byte[] data)
        {
            if (data.Length > BackingObject.WriteLength)
            {
                throw new ArgumentException("data too long");
            }

            if (data.Length < BackingObject.WriteLength)
            {
                Array.Resize(ref data, BackingObject.WriteLength);
            }

            var result = BackingObject.WriteData(data);

            return(result);
        }
Ejemplo n.º 4
0
        private static void GreenIndicatorLight(PIEDevice device)
        {
            if (device.WriteLength < 4)
            {
                return;
            }
            var wData = new byte[device.WriteLength];

            wData[1] = 179; //0xb3
            wData[2] = 6;   //6 for green, 7 for red
            wData[3] = 1;   //0=off, 1=on, 2=flash
            var result = 404;

            while (result == 404)
            {
                result = device.WriteData(wData);
            }
        }
Ejemplo n.º 5
0
        internal override void SetDisplay(int speed)
        {
            int d1 = (int)((double)speed / 100 % 10);         //1 digit
            int d2 = (int)((double)speed / 10 % 10);          //10 digit
            int d3 = (int)((double)speed % 10);               //100 digit

            for (int i = 2; i < 5; i++)
            {
                switch (i)
                {
                //100 digit display
                case 2:
                    wData[i] = GetDigit(d3);
                    break;

                //10 digit display
                case 3:
                    wData[i] = GetDigit(d2);
                    break;

                //1 digit display
                case 4:
                    wData[i] = GetDigit(d1);
                    break;
                }
            }

            int result = 404;

            while (result == 404)
            {
                result = myDevice.WriteData(wData);
            }

            if (result != 0)
            {
                throw new Exception();
            }
        }
Ejemplo n.º 6
0
 public int WriteData(byte[] writeBuffer)
 {
     return(device?.WriteData(writeBuffer) ?? -1);
 }