示例#1
0
        static void Main()
        {
            evth = new eventHandler();
            evth.LogMessage(evth, new LogEventArgs(LogLevel.DEBUG, "Program start."));
            MainForm mainForm   = new MainForm();
            Thread   mainThread = new Thread(new ThreadStart(mainForm.Main));

            mainThread.Start();
            while (!mainThread.IsAlive)
            {
                ;
            }
            evth.LogMessage(evth, new LogEventArgs(LogLevel.DEBUG, "Main thread running."));
            Thread.Sleep(100);

            LJU3Control lju3Control = new LJU3Control(evth);
            Thread      lju3Thread  = new Thread(new ThreadStart(lju3Control.Main));

            lju3Thread.Start();


            while (mainThread.IsAlive)
            {
                Thread.Sleep(10);
            }
            mainThread.Join();
            evth.LogMessage(evth, new LogEventArgs(LogLevel.DEBUG, "Main thread terminated."));
            lju3Thread.Abort();
            while (lju3Thread.IsAlive)
            {
                ;
            }
            lju3Thread.Join();
            evth.LogMessage(evth, new LogEventArgs(LogLevel.DEBUG, "Program exit normally."));
        }
示例#2
0
        public frmMain(eventHandler eh)
        {
            evth = eh;
            InitializeComponent();

            evth.onMessage += evth_onMessage;

            //Populate combobox DebugLevel with LogLevel enumeration.
            uint[]   logLevelValues = (uint[])Enum.GetValues(typeof(LogLevel));
            string[] logLevelNames  = Enum.GetNames(typeof(LogLevel));
            for (uint i = 0; i < logLevelValues.Length; i++)
            {
                ListBoxItem lbi = new ListBoxItem(logLevelValues[i], logLevelNames[i]);
                cbDebugLevel.Items.Insert(0, lbi);
            }
            //set combobox DebugLevel to initial value (set in code).
            for (int i = 0; i < cbDebugLevel.Items.Count; i++)
            {
                if (((ListBoxItem)cbDebugLevel.Items[i]).Value == (uint)evth.loglevel)
                {
                    cbDebugLevel.SelectedIndex = i;
                    break;
                }
            }
            //add eventhandler for when the user changes the log level.
            cbDebugLevel.SelectedIndexChanged += CbDebugLevel_SelectedIndexChanged;

            //eventhandler for digital io
            for (byte i = 0; i < gbDigitalIO.Controls.Count; i++)
            {
                gbDigitalIO.Controls[i].Text = i.ToString();
                DigitalControl digitalControl = new DigitalControl(evth, gbDigitalIO.Controls[i], i, false);
                digitalControl.onChange += DigitalControl_onChange;
            }
        }
示例#3
0
 public LJU3Control(eventHandler eh)
 {
     evth = eh;
     evth.onLJU3Request += Evth_onLJU3Request;
     for (byte i = 0; i < DigitalIO.Length; i++)
     {
         DigitalIO[i] = true;
     }
 }
示例#4
0
 public DigitalControl(eventHandler eh, Control ctl, byte channel, bool value)
 {
     evth = eh; Ctl = ctl; Channel = channel; Value = value;
     evth.onDigitalIOChange += Evth_onDigitalIOChange;
 }