Beispiel #1
0
 /// <summary>
 /// constructor
 /// </summary>
 public GpioClient(string id, IotHttpClient client, IotNode parent)
     : base(id, client, parent)
 {
     GpioData = new GpioData {
         Parent = this, Pins = new List <GpioPinData>()
     };
     for (int jj = 1; jj <= 40; jj++)
     {
         GpioPinClient pinClient = new GpioPinClient(jj.ToString(), Client, this);
         GpioPinClients.Add(pinClient);
         Children.Add(pinClient);
     }
 }
Beispiel #2
0
        /// <summary>
        /// process the response from server and update the properties
        /// </summary>
        protected override bool ProcessResponse(HttpResponse response)
        {
            string json = response.Result;

            // deserialize
            GpioData = new GpioData
            {
                Parent = this,
                Pins   = JsonConvert.DeserializeObject <List <GpioPinData> >(json)
            };
            // populate GpioPinClients' PinData
            foreach (GpioPinData pinData in GpioData.Pins)
            {
                GpioPinClients[pinData.Pin - 1].PinData = pinData;
            }
            return(true);
        }