コード例 #1
0
        /// <summary>
        /// Sets the indicator status at the TraySlots observable collection.
        /// </summary>
        /// <param name="n"></param>
        /// <param name="state"></param>
        private void SetIndicatorStatus(string response)
        {
            int    n     = (int)Char.GetNumericValue(response[3]);
            string state = response.Substring(5);

            TrayContainers.First(s => s.ID == n).IsIndicatorOn = (state == "ON");
        }
コード例 #2
0
        /// <summary>
        /// Turns the LED indicator on for a given slot.
        /// </summary>
        /// <param name="n"></param>
        public async Task <bool> EnableLEDAsync(int n)
        {
            try
            {
                if (IsTrayOpen == false)
                {
                    try
                    {
                        if ((Enumerable.Range(1, 8).Contains(n)))
                        {
                            await arduino.WriteDataAsync(n.ToString());

                            await Task.Delay(50);

                            TrayContainer slot = TrayContainers.Single(s => s.ID == n);
                            return(slot.IsIndicatorOn);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        private void UpdateAllTrayContainerPresenceData(string response)
        {
            string data = response.Substring(5, 8);
            List <TrayContainer> slots = TrayContainers.OrderBy(s => s.ID).ToList();

            foreach (TrayContainer item in slots)
            {
                int i       = item.ID;
                int hasItem = (int)char.GetNumericValue(data[i - 1]);

                TrayContainers.First(s => s.ID == i).HasItem = (hasItem == 0);
            }
        }
コード例 #4
0
        /// <summary>
        /// Sets the HasItem property of a TraySlot at TraySlots.
        /// </summary>
        /// <param name="response"></param>
        private void SetSwitchStatus(string response)
        {
            int    n     = (int)Char.GetNumericValue(response[7]);
            string state = response.Substring(9);

            //bool isOn = (state == "ON");

            TrayContainers.First(s => s.ID == n).HasItem = (state == "ON");
            if (state == "ON")
            {
                TrayContainers.First(s => s.ID == n).OnStates++;
            }
            else
            {
                TrayContainers.First(s => s.ID == n).OffStates++;
            }
        }