public static void HandleUI(Control control, PaintEventArgs e)
    {
        // gain access to new properties
        ICtrl ctrl = control as ICtrl;

        if (ctrl != null)
        {
            // perform the checks necessary and add the new UI changes
        }
    }
Exemplo n.º 2
0
        private void btnSetCurrent_Click(object sender, EventArgs e)
        {
            ICtrl ctrl = _Manager.SetController((uint)numericUpDown1.Value);

            if (ctrl != null)
            {
                AddOutputLine(string.Format("The DIO8-MCP22 device {0} is now current.", numericUpDown1.Value));
            }
            else
            {
                AddOutputLine(string.Format("The DIO8-MCP22 device {0} is NOT current.", numericUpDown1.Value));
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            EnableInputDemo(false);
            EnableOutputDemo(false);
            EnableMarchDemo(true);

            ICtrl ctrlr = _Manager.GetCurrentController();

            if (!showThreadStarted[_Manager.GetCurrentControllerID()])
            {
                ThreadPool.QueueUserWorkItem(ThreadPoolThreadProc, ctrlr);
            }

            if (!stopShow.WaitOne(0, false))
            {
                stopShow.Set();
            }
            else
            {
                stopShow.Reset();
            }
        }
Exemplo n.º 4
0
        private void ThreadPoolThreadProc(object state)
        {
            ICtrl     ctrlr    = (ICtrl)state;
            uint      port     = 0;
            CtrlMode  curMode  = CtrlMode.Output;
            CtrlState curState = CtrlState.High;

            for (uint i = 0; i < 8; i++)
            {
                ctrlr.SetPortMode(i, curMode);
            }

            while (true)
            {
                if (!stopShow.WaitOne(0, false))
                {
                    break;
                }

                ctrlr.SetAllPortState((byte)255);

                for (int j = 0; j < 8; j++)
                {
                    if (++port > 7)
                    {
                        port = 0;
                    }

                    ctrlr.SetPortState(port, curState);

                    curState = curState == CtrlState.High ? CtrlState.Low : CtrlState.High;

                    Thread.Sleep(demoDelay);
                }

                for (int k = 0; k < 3; k++)
                {
                    byte tempState = 0;
                    ctrlr.GetAllPortState(ref tempState);
                    tempState = (byte)~tempState;
                    ctrlr.SetAllPortState(tempState);

                    Thread.Sleep(demoDelay * 2);
                }

                for (int l = 0; l < 8; l++)
                {
                    if (--port > 7)
                    {
                        port = 7;             //port is a uint, so it will go high instead of negative
                    }
                    stopShow.WaitOne();

                    ctrlr.SetPortState(port, curState);

                    curState = curState == CtrlState.High ? CtrlState.Low : CtrlState.High;

                    Thread.Sleep(demoDelay);
                }

                for (int m = 0; m < 3; m++)
                {
                    byte tempState = 0;
                    ctrlr.GetAllPortState(ref tempState);
                    tempState = (byte)~tempState;
                    ctrlr.SetAllPortState(tempState);

                    Thread.Sleep(demoDelay * 2);
                }
            }
        }