Пример #1
0
 private static GpioPin[] ArrayListToGpioPinArray(ArrayList list)
 {
     List<GpioPin> gps = new List<GpioPin>();
     foreach (ArrayList innerlist in list)
     {
         int[] pinval = (int[])innerlist.ToArray(typeof(int));
         int id = pinval[0];
         bool high = (0 != pinval[1]);
         GpioPin gp = new GpioPin(id, high);
         gps.Add(gp);
     }
     return gps.ToArray();
 }
Пример #2
0
        /// <summary>
        /// Get the state of all of the reader's GPI pins. 
        /// </summary>
        /// <returns>array of GpioPin objects representing the state of all input pins</returns>
        public override GpioPin[] GpiGet()
        {
            MSG_GET_READER_CONFIG msg = new MSG_GET_READER_CONFIG();
            msg.RequestedData = ENUM_GetReaderConfigRequestedData.GPIPortCurrentState;
            MSG_GET_READER_CONFIG_RESPONSE response = (MSG_GET_READER_CONFIG_RESPONSE)SendLlrpMessage(msg);

            List<GpioPin> list = new List<GpioPin>();
            if (response.GPIPortCurrentState != null)
            {
                foreach (PARAM_GPIPortCurrentState state in response.GPIPortCurrentState)
                {
                    int id = LlrpToTmGpi(state.GPIPortNum);
                    bool high = (ENUM_GPIPortState.High == state.State);
                    bool output = false;
                    GpioPin pin = new GpioPin(id, high, output);
                    list.Add(pin);
                }
            }
            return list.ToArray();
        }