Exemplo n.º 1
0
        /// <summary>
        /// The background worker task. Download the event history associated with the current event log and update the EventStatusList property of the
        /// FormShowEventHistory class.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // ---------------------------------------------------------------
            // Get the history information associated with the current log.
            // ---------------------------------------------------------------
            int eventCount    = (short)m_EventRecordList.Count;
            int maxEventCount = m_Log.MaxEventsPerTask * m_Log.MaxTasks;

            // Initialize the validFlags array to define which of the events are used in the current log.
            short[] validFlags = new short[maxEventCount];
            int     eventIndex;

            for (int index = 0; index < m_EventRecordList.Count; index++)
            {
                eventIndex             = m_EventRecordList[index].TaskIdentifier * m_Log.MaxEventsPerTask + m_EventRecordList[index].EventIdentifier;
                validFlags[eventIndex] = CommonConstants.True;
            }

            short[] cumulativeHistoryCounts = new short[eventCount];
            short[] recentHistoryCounts     = new short[eventCount];

            CommunicationInterface.GetFltHistInfo(validFlags, ref cumulativeHistoryCounts, ref recentHistoryCounts, m_Log.MaxTasks, m_Log.MaxEventsPerTask);

            // ---------------------------------
            // Initialise the event status list.
            // ---------------------------------
            List <EventStatus_t> eventStatusList = new List <EventStatus_t>(eventCount);
            EventStatus_t        eventStatus;

            for (int eventStatusIndex = 0; eventStatusIndex < eventCount; eventStatusIndex++)
            {
                eventStatus                        = new EventStatus_t();
                eventStatus.Index                  = eventStatusIndex;
                eventStatus.Identifier             = m_EventRecordList[eventStatusIndex].Identifier;
                eventStatus.CumulativeHistoryCount = cumulativeHistoryCounts[eventStatusIndex];
                eventStatus.RecentHistoryCount     = recentHistoryCounts[eventStatusIndex];

                eventStatusList.Add(eventStatus);
            }

            // Get the reference to the calling form.
            FormShowEventHistory calledFromAsFormShowEventHistory = CalledFrom as FormShowEventHistory;

            Debug.Assert(calledFromAsFormShowEventHistory != null, "FormGetFltHistInfo.m_BackgroundWorker_DoWork() - [calledFromAsFormShowEventHistory != null]");

            // Update the EventStatusList property of the form.
            calledFromAsFormShowEventHistory.EventStatusList = eventStatusList;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the element of the <c>EventStatusList</c> property corresponding to the selected row of the <c>DataGridView</c> control.
        /// </summary>
        /// <param name="eventStatus">The event status element corresponding to the selected row of the <c>DataGridView</c> control.</param>
        /// <param name="dataGridViewRow">The selected row of the <c>DataGridView</c> control.</param>
        /// <returns>A flag to indicate whether an event status element matching the selected row of the DataGridView control was found. True, if a matching element
        /// was found; otherwise, false.</returns>
        private bool GetEventStatusElement(out EventStatus_t eventStatus, out DataGridViewRow dataGridViewRow)
        {
            eventStatus     = new EventStatus_t();
            dataGridViewRow = new DataGridViewRow();

            // Flag to indicate whether an event flag matching the selected row of the DataGridView control was found.
            bool matchFound = false;

            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return(matchFound);
            }

            // Ensure that a row has been selected.
            if (m_DataGridViewEventStatus.SelectedRows.Count <= 0)
            {
                return(matchFound);
            }

            // Get the selected row of the DataGridView control.
            dataGridViewRow = m_DataGridViewEventStatus.SelectedRows[0];
            if (dataGridViewRow != null)
            {
                // Get the event index of the event flag associated with the selected record.
                short eventIndex = short.Parse((string)dataGridViewRow.Cells[ColumnIndexEventIndex].Value);

                // Ensure that the event index is a positive value.
                if (eventIndex < 0)
                {
                    return(matchFound);
                }

                // Find the event flag associated with the selected event index.
                eventStatus = m_EventStatusList.Find(delegate(EventStatus_t currentEventFlag)
                {
                    return(currentEventFlag.Identifier == eventIndex);
                });

                if (eventStatus.Identifier == eventIndex)
                {
                    matchFound = true;
                }
            }

            return(matchFound);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Convert the specified event status structure to a <c>DataGridViewRow</c> so that it may be added to the <c>DataGridView</c> control used to display the
        /// event status information.
        /// </summary>
        /// <param name="eventStatus">The event status structure that is to be converted.</param>
        /// <returns>The specified event status structure converted to a <c>DataGridViewRow</c>.</returns>
        private DataGridViewRow Convert(EventStatus_t eventStatus)
        {
            DataGridViewRow dataGridViewRow = new DataGridViewRow();

            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return(dataGridViewRow);
            }

            string description;

            // Get the description of the event type associated with the event flag.
            try
            {
                EventRecord eventRecord = Lookup.EventTable.RecordList[eventStatus.Identifier];
                if (eventRecord == null)
                {
                    description = string.Empty;
                }

                description = eventRecord.Description;
            }
            catch (Exception)
            {
                description = string.Empty;
            }

            string enableEventText;

            if (eventStatus.Enabled == true)
            {
                enableEventText = m_TextTrue;
            }
            else
            {
                enableEventText = m_TextFalse;
            }

            string streamTriggeredText;

            if (eventStatus.StreamTriggered == true)
            {
                streamTriggeredText = m_TextTrue;
            }
            else
            {
                streamTriggeredText = m_TextFalse;
            }

            int totalCount;

            totalCount = eventStatus.CumulativeHistoryCount + eventStatus.RecentHistoryCount;

            dataGridViewRow = new DataGridViewRow();
            dataGridViewRow.CreateCells(m_DataGridViewEventStatus, new object[]   {
                (object)eventStatus.Identifier.ToString(FormatStringInteger),
                (object)description,
                (object)enableEventText,
                (object)streamTriggeredText,
                (object)eventStatus.CumulativeHistoryCount.ToString(),
                (object)totalCount.ToString()
            });
            return(dataGridViewRow);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="communicationInterface">The communication interface that is to be used to communicate with the VCU.</param>
        /// <param name="log">The current event log.</param>
        public FormConfigureEventFlags(ICommunicationParent communicationInterface, Log log)
        {
            InitializeComponent();

            // Initialize the communication interface.
            if (communicationInterface is CommunicationParent)
            {
                CommunicationInterface = new CommunicationEvent(communicationInterface);
            }
            else
            {
                CommunicationInterface = new CommunicationEventOffline(communicationInterface);
            }
            Debug.Assert(CommunicationInterface != null);

            #region - [Size] -
            // Get the combined width of all visible DataGridView columns.
            int dataGridViewWidth = 0;
            DataGridViewColumn dataGridViewColumn;
            for (int columnIndex = 0; columnIndex < m_DataGridViewEventStatus.Columns.Count; columnIndex++)
            {
                dataGridViewColumn = m_DataGridViewEventStatus.Columns[columnIndex];
                if (dataGridViewColumn.Visible == true)
                {
                    dataGridViewWidth += dataGridViewColumn.Width;
                }
            }

            m_PanelDataGridViewEventStatus.Width = dataGridViewWidth + MarginRightDataGridViewControl;

            Width = m_PanelDataGridViewEventStatus.Width + MarginRightPanelControl;
            #endregion - [Size] -

            // ------------------------------------------------------------------
            // Get the list of events associated with the current event log.
            // ------------------------------------------------------------------
            List <EventRecord> foundEventRecordList;
            foundEventRecordList = Lookup.EventTable.RecordList.FindAll(delegate(EventRecord eventRecord)
            {
                // Include a try/catch block in case an event record has not been defined.
                try
                {
                    // The LOGID field of the EVENTS table actually uses the log index value which is equal to the log identifier - 1.
                    return(eventRecord.LogIdentifier == log.Identifier - 1);
                }
                catch (Exception)
                {
                    return(false);
                }
            });

            foundEventRecordList.Sort(CompareByTaskIDByEventIDAscending);

            // ---------------------------------------------------------------
            // Get the event flag information associated with the current log.
            // ---------------------------------------------------------------
            int eventCount    = (short)foundEventRecordList.Count;
            int maxEventCount = log.MaxEventsPerTask * log.MaxTasks;

            // Initialize the validFlags array to define which of the events are used in the current log.
            short[] validFlags = new short[maxEventCount];
            int     eventIndex;
            for (int index = 0; index < foundEventRecordList.Count; index++)
            {
                eventIndex             = foundEventRecordList[index].TaskIdentifier * log.MaxEventsPerTask + foundEventRecordList[index].EventIdentifier;
                validFlags[eventIndex] = CommonConstants.True;
            }

            short[] enabledFlags         = new short[eventCount];
            short[] streamTriggeredFlags = new short[eventCount];
            try
            {
                CommunicationInterface.GetFltFlagInfo(validFlags, ref enabledFlags, ref streamTriggeredFlags, (short)maxEventCount);
            }
            catch (Exception)
            {
                throw new CommunicationException(Resources.EMGetFltFlagInfoFailed);
            }

            // ---------------------------------
            // Initialise the event status list.
            // ---------------------------------
            m_EventStatusList = new List <EventStatus_t>(eventCount);
            EventStatus_t eventStatus;
            for (int eventStatusIndex = 0; eventStatusIndex < eventCount; eventStatusIndex++)
            {
                eventStatus            = new EventStatus_t();
                eventStatus.Index      = eventStatusIndex;
                eventStatus.Identifier = foundEventRecordList[eventStatusIndex].Identifier;

                if (enabledFlags[eventStatusIndex] == CommonConstants.True)
                {
                    eventStatus.Enabled = true;
                }

                if (streamTriggeredFlags[eventStatusIndex] == CommonConstants.True)
                {
                    eventStatus.StreamTriggered = true;
                }

                m_EventStatusList.Add(eventStatus);
            }

            AddList(m_EventStatusList);
        }