Example #1
0
        void timerConstructSensorObjects_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            /* Pause the timer till the process is completed. */
            timerConstructSensorObject.Stop();

            /*Processing new notifications and adding them to queue.*/
            target.ConstructSensorObjects();

            /* Start the timer once ConstructSensorObjects process completed. */
            timerConstructSensorObject.Start();

            SetControlPropertyValue(label1, "Text", "Alarm Queued Objects: " + AlarmQueue.AlarmObjectQueue.Count.ToString());
            SetControlPropertyValue(label2, "Text", "Alarm Current Processed Objects: " + AlarmQueue.CurrentProcessObjects.Count.ToString());
            SetControlPropertyValue(label4, "Text", "Latest Time: " + DateTime.Now.ToString());


            Application.DoEvents();
        }
Example #2
0
        /// <summary>
        /// check for the data received from the external source, if
        /// received construct the alarm object and process them
        /// </summary>
        private void HandleThread()
        {
            while (true)
            {
                if (_udpSocket == null)
                {
                    break;
                }
                try
                {
                    byte[] bytes = new byte[1024];
                    _udpSocket.Receive(bytes);

                    string s = System.Text.ASCIIEncoding.ASCII.GetString(bytes);
                    LogBook.Write("Received data from external source, doing update check, data: " + s.Replace("\0", ""));

                    //doing update check.
                    _target.ConstructSensorObjects();
                    _target.ProcessAlarmObjects();
                    Thread.Sleep(1000);
                }
                catch { }
            }
        }