Esempio n. 1
0
        private static void UpdateRelays(string sn)
        {
            if (sn == "")
            {
                return;
            }

            byte values = _relays.GetRelays(sn);
            //Console.WriteLine("SN: " + sn + "  Values: " + values.ToString());

            int relayNum = 0;

            foreach (Relay relay in _relayControls)
            {
                byte mask = (byte)(1 << relayNum);
                relayNum++;

                //Console.WriteLine("relayNum: " + relayNum.ToString() +
                //    String.Format("  values {0:x}", values) +
                //    String.Format("  mask {0:x}", mask) );

                if ((mask & values) > 0)
                {
                    relay.Latched = true;
                }
                else
                {
                    relay.Latched = false;
                }
            }
        }
        private void UpdateRelays()
        {
            String sn = cbDevices.Text;

            if (sn == "")
            {
                return;
            }

            byte values = _relays.GetRelays(sn);

            //Console.WriteLine("SN: " + sn + "  Values: " + values.ToString());

            foreach (CheckBox cb in _relayControls)
            {
                int  relayNum = (int)cb.TabIndex;
                byte mask     = (byte)(1 << relayNum);

                //Console.WriteLine("relayNum: " + relayNum.ToString() +
                //    String.Format("  values {0:x}", values) +
                //    String.Format("  mask {0:x}", mask) );

                if ((mask & values) > 0)
                {
                    cb.Checked = true;
                }
                else
                {
                    cb.Checked = false;
                }
            }
        }