예제 #1
0
        private void updateLabels(byte[] EvtBytes)
        {
            byte[] IObytes = sb.GetSlideBarStatus();
            for (int i = 0; i < IObytes.Length; i++)
            {
                labelIOBytes[i].Text = IObytes[i].ToString("X2");
            }


            for (int i = 0; i < labelInputBytes.Length; i++)
            {
                labelInputBytes[i].Text = rawInputBytes[i].ToString("X2");
            }

            if (EvtBytes == null)
            {
                return;
            }
            SlideBar.Event sbEvt = (SlideBar.Event)EvtBytes[1];
            for (int i = 0; i < EvtBytes.Length; i++)
            {
                labelEvtBytes[i].Text = EvtBytes[i].ToString("X2");
            }
        }
예제 #2
0
        private void SB_Controller_Load(object sender, EventArgs e)
        {
            sb = new SlideBar(true);
            sb.sbArriveEvent += new SlideBarEventHandler(sb_sbArriveEvent);
            byte[] IObytes = sb.GetSlideBarStatus();
            foreach (SlideBar.Event sbEvt in Enum.GetValues(typeof(SlideBar.Event)))
            {
                CheckBox cb = new CheckBox();
                cb.Text = sbEvt.ToString();
                /// add the checkstatus to current checkbox
                switch (sbEvt)
                {
                case SlideBar.Event.SlideBarLightSwitch:
                case SlideBar.Event.ServiceKey:
                    cb.Checked = (IObytes[64 + (int)sbEvt] != 0);
                    break;

                case SlideBar.Event.AP00:
                case SlideBar.Event.AP01:
                case SlideBar.Event.AP02:
                case SlideBar.Event.AP03:
                case SlideBar.Event.AP04:
                case SlideBar.Event.AP05:
                case SlideBar.Event.AP06:
                case SlideBar.Event.AP07:
                    cb.Checked = (((int)IObytes[66]) >> ((int)sbEvt - 8)) % 2 != 0;
                    break;
                }
                cb.CheckedChanged += new EventHandler(cb_CheckedChanged);
                flowLayoutPanelControls.Controls.Add(cb);
            }

            for (int i = 0; i < IObytes.Length; i++)
            {
                labelIOBytes[i]       = new Label();
                labelIOBytes[i].Text  = IObytes[i].ToString("X2");
                labelIOBytes[i].Width = 21;
                //labelIOBytes[i].Click += new EventHandler(SB_Controller_Click);
                labelIOBytes[i].TextChanged += new EventHandler(SB_Controller_TextChanged);
                flowLayoutPanelIOBytes.Controls.Add(labelIOBytes[i]);

                labelInputBytes[i]              = new Label();
                labelInputBytes[i].Width        = 21;
                labelInputBytes[i].Text         = "00";
                labelInputBytes[i].Click       += new EventHandler(SB_Controller_Click);
                labelInputBytes[i].TextChanged += new EventHandler(SB_Controller_TextChanged);
                flowLayoutPanelInputBytes.Controls.Add(labelInputBytes[i]);
            }
            for (int i = 0; i < labelEvtBytes.Length; i++)
            {
                labelEvtBytes[i]              = new Label();
                labelEvtBytes[i].Width        = 21;
                labelEvtBytes[i].TextChanged += new EventHandler(SB_Controller_TextChanged);
                flowLayoutPanelEventBytes.Controls.Add(labelEvtBytes[i]);
            }

            //labelInputBytes[8].Text = "09";
            //labelInputBytes[85].Text = "01";
            //labelInputBytes[86].Text = "01";
            //labelInputBytes[66].Text = "01";
            //labelInputBytes[16].Text = "01";
            //labelInputBytes[10].Text = "01";
            //labelInputBytes[9].Text = "03";
            //labelInputBytes[0].Text = "01";
            //labelInputBytes[1].Text = "10";



            //labelInputBytes[0].ForeColor = Color.Blue;
            //labelInputBytes[1].ForeColor = Color.Blue;
            //labelInputBytes[8].ForeColor = Color.Blue;
            //labelInputBytes[9].ForeColor = Color.Blue;
            //labelInputBytes[10].ForeColor = Color.Blue;
            //labelInputBytes[16].ForeColor = Color.Blue;
            //labelInputBytes[66].ForeColor = Color.Blue;
            //labelInputBytes[85].ForeColor = Color.Blue;
            //labelInputBytes[86].ForeColor = Color.Blue;
        }