Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the class. Initializes the communication interface and read/write locks.
        /// </summary>
        /// <param name="communicationInterface">Reference to the communication interface used to communicate with the target hardware.</param>
        /// <param name="formViewEventLog">Reference to the form that called this form.</param>
        public ThreadPollEvent(ICommunicationEvent communicationInterface, FormViewEventLog formViewEventLog)
        {
            CommunicationInterface = communicationInterface;
            Debug.Assert(m_CommunicationInterface != null, "ThreadPollEvent.Ctor() - [m_CommunicationInterface != null]");

            m_FormViewEventLog = formViewEventLog;
            Debug.Assert(m_FormViewEventLog != null, "ThreadPollEvent.Ctor() - [m_FormViewEventLog != null]");

            m_MutexPause              = new Mutex();
            m_MutexPauseFeedback      = new Mutex();
            m_MutexCommunicationFault = new Mutex();

            m_PacketCount          = 0;
            m_PollScheduler        = new PollScheduler();
            m_ReadTimeoutCountdown = ReadTimeoutCountdown;
        }
        /// <summary>
        /// Show the child form which displays the current event logs.
        /// </summary>
        public void ViewEventLog()
        {
            MainWindow.CloseChildForms();
            MainWindow.Cursor = Cursors.WaitCursor;

            // ---------------------------------------------------------------
            // Inform the user of the name of the log that is being retrieved.
            // ---------------------------------------------------------------
            // Retrieve the first valid log from the LogTable as this is the log that will be displayed by the FormViewEventLog class.
            Log log = null;

            for (int recordIndex = 0; recordIndex < Lookup.LogTable.RecordList.Count; recordIndex++)
            {
                // Check that a valid entry exists.
                if (Lookup.LogTable.Items[recordIndex] != null)
                {
                    log = Lookup.LogTable.Items[recordIndex];
                    break;
                }
            }

            MainWindow.WriteStatusMessage(string.Format(Resources.SMEventLogRetrieve, log.Description));

            // --------------
            // Show the form.
            // --------------
            try
            {
                FormViewEventLog formEventLog = new FormViewEventLog(MainWindow.CommunicationInterface, MainWindow);
                MainWindow.ShowMdiChild(formEventLog);
            }
            catch (Exception exception)
            {
                MessageBox.Show(Resources.MBTViewEventLogFailed + CommonConstants.NewLine + CommonConstants.NewLine + exception.Message, Resources.MBCaptionError,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                MainWindow.WriteStatusMessage(string.Empty);
                MainWindow.Cursor = Cursors.Default;
            }
        }