示例#1
0
        /// <summary>
        /// Inializes a new instance of the class. Used to create an item with the specified default workset column text.
        /// </summary>
        /// <param name="workset">The workset associated with the item.</param>
        /// <param name="defaultText">The text to be displayed in the default workset column.</param>
        public WorksetItem(Workset_t workset, string defaultText)
        {
            m_Workset = workset;
            base.Text = m_Workset.Name;

            // Default column text string defined by defaultText.
            base.SubItems.Add(defaultText);
        }
示例#2
0
        /// <summary>
        /// Inializes a new instance of the class. Used to create an item that has an empty string for the default workset column text.
        /// </summary>
        /// <param name="workset">The workset associated with the item.</param>
        public WorksetItem(Workset_t workset)
        {
            m_Workset = workset;
            base.Text = m_Workset.Name;

            // Default column text string is empty.
            base.SubItems.Add(string.Empty);
        }
示例#3
0
        /// <summary>
        /// Predicate function called by the <c>List.Find()</c> method to return a workset that matches the specified workset, ignoring the Name, SecurityLevel, 
        /// HeaderText and TabPagePlots fields of each workset. 
        /// </summary>
        /// <param name="workset">The list item that is to be processed.</param>
        /// <returns>True, if the specified item meets the logic requirements given in the function; otherwise false.</returns>
        protected virtual bool CompareWorkset(Workset_t workset)
        {
            Workset_t worksetToCompare = m_WorksetToCompare;

            // ----------------------------------------------------------------------
            // Ignore the name and security level as these are not stored on the VCU.
            // ----------------------------------------------------------------------
            if ((workset.SampleMultiple != worksetToCompare.SampleMultiple) ||
                (workset.CountMax != worksetToCompare.CountMax))
            {
                return false;
            }

            #region - [Column] -
            if (workset.Column.Length != worksetToCompare.Column.Length)
            {
                return false;
            }

            #region - [OldIdentifierList] -
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                // --------------------------------------------------------
                // Ignore the header text as this is not stored on the VCU.
                // --------------------------------------------------------

				// Check to be sure both lists have the same number of Old Identifiers.
				// At one point, this could lead to an exception if the user tried to create a Chart Recorder with no items.
				if (workset.Column[columnIndex].OldIdentifierList.Count != worksetToCompare.Column[columnIndex].OldIdentifierList.Count)
				{
					return false;
				}

                for (int index = 0; index < workset.Column[columnIndex].OldIdentifierList.Count; index++)
                {
                    if (workset.Column[columnIndex].OldIdentifierList[index] != worksetToCompare.Column[columnIndex].OldIdentifierList[index])
                    {
                        return false;
                    }
                }
            }
            #endregion - [OldIdentifierList] -
            #endregion - [Column] -

            #region - [WatchItems] -
            if (workset.WatchItems.Length != worksetToCompare.WatchItems.Length)
            {
                return false;
            }

            for (int index = 0; index < workset.WatchItems.Length; index++)
            {
                if (workset.WatchItems[index].Added != worksetToCompare.WatchItems[index].Added)
                {
                    return false;
                }
            }
            #endregion - [WatchItems] -

            #region - [WatchElementList] -
            if (workset.WatchElementList.Count != worksetToCompare.WatchElementList.Count)
            {
                return false;
            }

            for (int index = 0; index < workset.WatchElementList.Count; index++)
            {
                if (workset.WatchElementList[index] != worksetToCompare.WatchElementList[index])
                {
                    return false;
                }
            }
            #endregion - [WatchElementList] -

            #region - [Count] -
            if (workset.Count != worksetToCompare.Count)
            {
                return false;
            }
            #endregion - [Count] -

            return true;
        }
示例#4
0
        /// <summary>
        /// Download the specified workset to the VCU. The logic is performed in the child class.
        /// </summary>
        /// <param name="workset">The workset that is to be downloaded to the VCU.</param>
        /// <returns>A flag that indicates whether the workset was successfully downloaded to the VCU. True, if the VCU update was successful; otherwise, false.</returns>
        protected virtual bool DownloadWorkset(Workset_t workset)
        {
            // A flag that indicates whether the VCU update was successful.
            bool updateSuccess = false;

            return updateSuccess;
        }
示例#5
0
        /// <summary>
        /// Event handler for <c>ComboBox</c> control <c>SelectedIndexChanged</c> event.
        /// </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>
        protected void m_ComboBoxWorkset_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            m_ComboBoxWorkset.DropDownStyle = ComboBoxStyle.DropDownList;

            // Load the selected workset.
            Workset_t workset = (Workset_t)m_ComboBoxWorkset.SelectedItem;
            m_SelectedWorkset = workset;

            m_CreateMode = false;
            m_UseTextBoxAsNameSource = false;
            m_TextBoxName.Enabled = false;

            SetModifyState(ModifyState.Configure);

            if (ConfigurationModified() == true)
            {
                m_TSBDownload.Enabled = true;
            }
            else
            {
                m_TSBDownload.Enabled = false;
            }

            Cursor = Cursors.Default;
        }
示例#6
0
 /// <summary>
 /// Compare the two worksets, ignoring the Name, SecurityLevel, HeaderText and TabPagePlots fields of each workset.
 /// </summary>
 /// <param name="worksetA">The first workset that is to be compared.</param>
 /// <param name="worksetB">The second workset that is to be compared.</param>
 /// <returns>True, if the worksets are identical; otherwise, false.</returns>
 protected bool CompareWorkset(Workset_t worksetA, Workset_t worksetB)
 {
     m_WorksetToCompare = worksetB;
     return CompareWorkset(worksetA);
 }
        /// <summary>
        /// Convert the data stream values retrieved from the VCU to a format that can be plotted by the <c>FormViewDataStream</c> class.
        /// </summary>
        /// <remarks>
        /// The value array retrieved by from the VCU is initially mapped to the WatchIdentifierList property of Column[0] of the workset, however, the WatchElement
        /// array associated with each frame must be mapped to the WatchElementList property of the workset.
        /// </remarks>
        /// <param name="startTime">The start time of the fault log.</param>
        /// <param name="sampleCount">The number of samples in the data stream.</param>
        /// <param name="frameIntervalMs">The interval, in ms, between consecutive data frames.</param>
        /// <param name="values">The point values corresponding to each variable.</param>
        /// <param name="dataTypes">The data types associated with each value.</param>
        /// <param name="workset">The workset that is to be used to define the output format.</param>
        /// <returns>The watch variable values in the format that can be plotted by the <c>FormViewDataStream</c> class.</returns>
        /// <exception cref="ArgumentException">Thrown if one or more of the the watch identifiers defined in the WatchElementList property of the workset does nor exist.</exception>
        private List<WatchFrame_t> ConvertToWatchFrameList(DateTime startTime, short sampleCount, short frameIntervalMs, int[] values, short[] dataTypes, Workset_t workset)
        {
            Debug.Assert(sampleCount > 1, "CommunicationEvent.ConvertToWatchFrameList() - [pointCount > 1]");
            Debug.Assert(frameIntervalMs > 0, "CommunicationEvent.ConvertToWatchFrameList() - [frameIntervalMs > 0");
            Debug.Assert(values != null, "CommunicationEvent.ConvertToWatchFrameList() - [values != null]");
            Debug.Assert(dataTypes != null, "CommunicationEvent.ConvertToWatchFrameList() - [dataTypes != null]");

            short watchCount = (short)workset.WatchElementList.Count;

            // Create a look-up array to translate the watch variable data retrieved from the VCU to the order defined by the WatchElementList property of the workset.
            short[] translate = new short[watchCount];
            short watchIdentifier, rowIndex, columnIndex;
            WatchVariable watchVariable;
            for (short watchElementIndex = 0; watchElementIndex < watchCount; watchElementIndex++)
            {
                watchIdentifier = workset.WatchElementList[watchElementIndex];
                try
                {
                    watchVariable = Lookup.WatchVariableTable.Items[watchIdentifier];
                    if (watchVariable == null)
                    {
                        throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
                    }
                }
                catch (Exception)
                {
                    throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
                }

                workset.GetWatchVariableLocation(watchVariable.OldIdentifier, out columnIndex, out rowIndex);
                Debug.Assert(((columnIndex != CommonConstants.NotFound) && (rowIndex != CommonConstants.NotFound)), "CommunicationEvent.ConvertToWatchFrameList() - [((columnIndex != 0) || (rowIndex != CommonConstants.NotFound))]");

                translate[watchElementIndex] = rowIndex;
            }

            // Translate the values of the watch variables retrieved from the VCU to a list of watch frames.
            List<WatchFrame_t> watchFrameList = new List<WatchFrame_t>();
            WatchFrame_t watchFrame;
            WatchElement_t watchElement;
            for (int frameIndex = 0; frameIndex < sampleCount; frameIndex++)
            {
                watchFrame = new WatchFrame_t();
                watchFrame.CurrentDateTime = startTime.AddMilliseconds(frameIndex * frameIntervalMs);
                watchFrame.WatchElements = new WatchElement_t[watchCount];
                for (short watchElementIndex = 0; watchElementIndex < watchCount; watchElementIndex++)
                {
                    watchElement = new WatchElement_t();
                    watchElement.ElementIndex = watchElementIndex;
                    watchElement.WatchIdentifier = workset.WatchElementList[watchElementIndex];
                    watchElement.DataType = dataTypes[translate[watchElementIndex]];
                    watchElement.Value = (double)values[(frameIndex * watchCount) + translate[watchElementIndex]];
                    watchFrame.WatchElements[watchElementIndex] = watchElement;
                }
                watchFrameList.Add(watchFrame);
            }
            return watchFrameList;
        }
        /// <summary>
        /// Convert the current user setting to a workset.
        /// </summary>
        /// <param name="worksetName">The name of the workset.</param>
        /// <returns>The user settings converted to a workset.</returns>
        protected Workset_t ConvertToWorkset(string worksetName)
        {
            // --------------------------------------------------------------------------
            // Copy the definitions to a new workset and update the WorksetManager class.
            // --------------------------------------------------------------------------
            Workset_t workset = new Workset_t();

            workset.Name = worksetName;
            workset.SampleMultiple = Workset_t.DefaultSampleMultiple;
            workset.CountMax = m_WorksetCollection.EntryCountMax;
            workset.SecurityLevel = Security.SecurityLevelCurrent;

            // Copy the old identifiers defined in Column[0].
            workset.Column = new Column_t[1];
            workset.Column[0].HeaderText = m_TextBoxHeader1.Text;
            workset.Column[0].OldIdentifierList = new List<short>();
            workset.Column[0].ChartScaleList = new List<ChartScale_t>();
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                workset.Column[0].OldIdentifierList.Add(((WatchItem_t)m_ListBox1.Items[index]).OldIdentifier);
            }

            // Copy the chart scale values.
            ChartScale_t chartScale;
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                chartScale.ChartScaleMin = (double)m_ListBoxChartScaleMin.Items[index];
                chartScale.ChartScaleMax = (double)m_ListBoxChartScaleMax.Items[index];
                chartScale.Units = (string)m_ListBoxUnits.Items[index];
                workset.Column[0].ChartScaleList.Add(chartScale);
            }


            // Copy the watchItems list.
            workset.WatchItems = new WatchItem_t[m_WatchItems.Length];
            Array.Copy(m_WatchItems, workset.WatchItems, m_WatchItems.Length);

            // Create the WatchElementList property from the column entries.
            workset.WatchElementList = new List<short>();
            short oldIdentifier;
            WatchVariable watchVariable;

            for (int rowIndex = 0; rowIndex < workset.Column[0].OldIdentifierList.Count; rowIndex++)
            {
                oldIdentifier = workset.Column[0].OldIdentifierList[rowIndex];
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];
                    if (watchVariable == null)
                    {
                        workset.WatchElementList.Add(CommonConstants.VariableNotDefinedWatchIdentifier);
                    }
                    else
                    {
                        workset.WatchElementList.Add(watchVariable.Identifier);
                    }
                }
                catch (Exception)
                {
                    workset.WatchElementList.Add(CommonConstants.VariableNotDefinedWatchIdentifier);
                }
            }
            workset.WatchElementList.Sort();
            workset.Count = workset.WatchElementList.Count;

            if (workset.Count != m_WatchElementCount)
            {
                throw new ArgumentException(Resources.EMWorksetIntegrityCheckFailed, "FormWorksetDefineFaultLog.ConvertToWorkset() - [workset.WatchElements.Count]");
            }

            return workset;
        }
示例#9
0
        /// <summary>
        /// Create the baseline workset. The baseline workset is a workset that displays the first <c>WatchSize</c> watch variables in the data dictionary. It's primary 
        /// purpose is to ensure that there is always at least one workset available. Under normal circumstances, once the user has defined a set of worksets the 
        /// baseline workset has no purpose.
        /// </summary>
        /// <returns>The baseline workset.</returns>
        public Workset_t CreateBaselineWorkset()
        {
            // Create a list of the first WatchSize watch variables that appear in the data dictionary.
            List<short> watchElementList = new List<short>();
            string name;
            for (short watchIdentifier = 0; watchElementList.Count < EntryCountMax; watchIdentifier++)
            {
                // Check that the watch identifier exists in the current data dictionary.
                try
                {
                    name = Lookup.WatchVariableTable.Items[watchIdentifier].Name;
                    watchElementList.Add(watchIdentifier);
                }
                catch (NullReferenceException)
                {
                    continue;
                }
            }

            // Instantiate a new workset structure.
            Workset_t workset = new Workset_t(Resources.NameBaselineWorkset, watchElementList, EntryCountMax, ColumnCountMax, SecurityLevel.Level2);
            return workset;
        }
        /// <summary>
        /// Convert the current user setting to a workset.
        /// </summary>
        /// <param name="worksetName">The name of the workset.</param>
        /// <returns>The user settings converted to a workset.</returns>
        protected Workset_t ConvertToWorkset(string worksetName)
        {
            // --------------------------------------------------------------------------
            // Copy the definitions to a new workset and update the WorksetManager class.
            // --------------------------------------------------------------------------
            Workset_t workset = new Workset_t();

            workset.Name = worksetName;
            workset.SampleMultiple = Workset_t.DefaultSampleMultiple;
            workset.CountMax = m_WorksetCollection.EntryCountMax;
            workset.SecurityLevel = Security.SecurityLevelCurrent;

            #region - [Column] -
            workset.Column = new Column_t[1];
            workset.Column[0].HeaderText = m_TextBoxHeader1.Text;
            workset.Column[0].OldIdentifierList = new List<short>();
            workset.Column[0].ChartScaleList = new List<ChartScale_t>();

            #region - [OldIdentifierList] -
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                workset.Column[0].OldIdentifierList.Add(((WatchItem_t)m_ListBox1.Items[index]).OldIdentifier);
            }
            #endregion - [OldIdentifierList] -

            #region - [ChartScaleList] -
            // The old identifer associated with the current watch variable.
            short oldIdentifier;

            // The current watch variable.
            WatchVariable watchVariable;

            // A flag to indicate whether the current watch variable is to be displayed in hexadecimal format. True, if the variable is to be displayed in hex format.
            bool hexFormat = false;

            // The upper and lower chart scale values as a text string.
            string chartScaleLowerLimitText, chartScaleUpperLimitText;
            ChartScale_t chartScale = new ChartScale_t();

            // The current culture information. Used to parse hexadecimal values.
            CultureInfo provider = new CultureInfo(CommonConstants.CultureInfoString);

            // A flag to indicate whether the parse operationwas successful. True, if the parse was successful.
            bool successfulParse;
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                // Get the watch variable associated with the current item.
                oldIdentifier = ((WatchItem_t)m_ListBox1.Items[index]).OldIdentifier;
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];
                    if (watchVariable == null)
                    {
                        throw new Exception();
                    }

                    // Determine the format of the watch variable.
                    hexFormat = (watchVariable.FormatString.ToLower().Equals(CommonConstants.DDFormatStringHex)) ? true : false;

                    chartScaleLowerLimitText = (string)m_ListBoxChartScaleLowerLimit.Items[index];
                    chartScaleUpperLimitText = (string)m_ListBoxChartScaleUpperLimit.Items[index];

                    if (m_ListBoxChartScaleLowerLimit.Items[index].Equals(CommonConstants.ChartScaleValueNotDefinedString))
                    {
                        chartScale.ChartScaleLowerLimit = double.NaN;
                    }
                    else
                    {
                        if (hexFormat == true)
                        {
                            uint lowerLimitAsUInt32;
                            string strippedChartScaleLowerLimitText;

                            // Strip out the leading HexValueIdentifier.
                            Debug.Assert(chartScaleLowerLimitText.Contains(CommonConstants.HexValueIdentifier), "FormConfigureChartRecorder.ConvertToWorkset() - [chartScaleLowerLimitText.Contains(HexValueIdentifier)]");
                            strippedChartScaleLowerLimitText = chartScaleLowerLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);

                            // Check that the value entered is a valid 32 bit hexadecimal value.
                            successfulParse = UInt32.TryParse(strippedChartScaleLowerLimitText, NumberStyles.HexNumber, provider, out lowerLimitAsUInt32);
                            if (successfulParse == false)
                            {
                                chartScale.ChartScaleLowerLimit = double.NaN;
                            }
                            else
                            {
                                chartScale.ChartScaleLowerLimit = lowerLimitAsUInt32;
                            }
                        }
                        else
                        {
                            double lowerLimitAsDouble;

                            // Check that the value entered is a valid 32 bit decimal value.
                            successfulParse = double.TryParse(chartScaleLowerLimitText, out lowerLimitAsDouble);
                            if (successfulParse == false)
                            {
                                chartScale.ChartScaleLowerLimit = double.NaN;
                            }
                            else
                            {
                                chartScale.ChartScaleLowerLimit = lowerLimitAsDouble;
                            }
                        }
                    }

                    if (m_ListBoxChartScaleUpperLimit.Items[index].Equals(CommonConstants.ChartScaleValueNotDefinedString))
                    {
                        chartScale.ChartScaleUpperLimit = double.NaN;
                    }
                    else
                    {
                        if (hexFormat == true)
                        {
                            uint upperLimitAsUInt32;
                            string strippedChartScaleUpperLimitText;

                            // Strip out the leading HexValueIdentifier.
                            Debug.Assert(chartScaleUpperLimitText.Contains(CommonConstants.HexValueIdentifier), "FormConfigureChartRecorder.ConvertToWorkset() - [chartScaleUpperLimitText.Contains(HexValueIdentifier)]");
                            strippedChartScaleUpperLimitText = chartScaleUpperLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);

                            // Check that the value entered is a valid 32 bit hexadecimal value.
                            successfulParse = UInt32.TryParse(strippedChartScaleUpperLimitText, NumberStyles.HexNumber, provider, out upperLimitAsUInt32);
                            if (successfulParse == false)
                            {
                                chartScale.ChartScaleUpperLimit = double.NaN;
                            }
                            else
                            {
                                chartScale.ChartScaleUpperLimit = upperLimitAsUInt32;
                            }
                        }
                        else
                        {
                            double upperLimitAsDouble;

                            // Check that the value entered is a valid 32 bit decimal value.
                            successfulParse = double.TryParse(chartScaleUpperLimitText, out upperLimitAsDouble);
                            if (successfulParse == false)
                            {
                                chartScale.ChartScaleUpperLimit = double.NaN;
                            }
                            else
                            {
                                chartScale.ChartScaleUpperLimit = upperLimitAsDouble;
                            }
                        }
                    }

                    chartScale.Units = (string)m_ListBoxUnits.Items[index];
                    workset.Column[0].ChartScaleList.Add(chartScale);
                }
                catch (Exception)
                {
                    // The watch variable does not exist, add an empty chart scale value.
                    chartScale.ChartScaleLowerLimit = double.NaN;
                    chartScale.ChartScaleUpperLimit = double.NaN;
                    chartScale.Units = CommonConstants.ChartScaleUnitsNotDefinedString;
                    workset.Column[0].ChartScaleList.Add(chartScale);
                }
            }
            #endregion - [ChartScaleList] -
            #endregion - [Column] -

            #region - [WatchItems] -
            workset.WatchItems = new WatchItem_t[m_WatchItems.Length];
            Array.Copy(m_WatchItems, workset.WatchItems, m_WatchItems.Length);
            #endregion - [WatchItems] -

            #region - [WatchElementList] -
            workset.WatchElementList = new List<short>();
   
            for (int rowIndex = 0; rowIndex < workset.Column[0].OldIdentifierList.Count; rowIndex++)
            {
                oldIdentifier = workset.Column[0].OldIdentifierList[rowIndex];
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];
                    if (watchVariable == null)
                    {
                        workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                    }
                    else
                    {
                        workset.WatchElementList.Add(watchVariable.Identifier);
                    }
                }
                catch (Exception)
                {
                    workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                }
            }
            workset.WatchElementList.Sort();
            #endregion - [WatchElementList] -

            #region - [Count] -
            workset.Count = workset.WatchElementList.Count;

            if (workset.Count != m_ListItemCount)
            {
                throw new ArgumentException(Resources.EMWorksetIntegrityCheckFailed, "FormWorksetDefineChartRecorder.ConvertToWorkset() - [workset.WatchElements.Count]");
            }
            #endregion - [Count] -

            return workset;
        }
示例#11
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when initializing a data stream to store recorded watch values.
        /// </summary>
        /// <param name="frameIntervalMs">The interval, in ms, between successive data frames.</param>
        public DataStream_t(short frameIntervalMs)
        {
            DataStreamTypeParameters = new DataStreamTypeParameters_t();
            DataStreamTypeParameters.SetToDefaulDataStreamType();

            StreamNumber = CommonConstants.NotDefined;
            LogType = LogType.Watch;
            EventDescription = string.Empty;
            FrameIntervalMs = frameIntervalMs;

            DurationMs = CommonConstants.NotDefined;
            SampleCount = CommonConstants.NotDefined;
            DurationPostTripMs = CommonConstants.NotDefined;
            DurationPreTripMs = CommonConstants.NotDefined;
            
            Workset = new Workset_t();
            WatchFrameList = new List<WatchFrame_t>();
            AutoScaleWatchValues = new AutoScale_t[Parameter.WatchSize];
            TimeOrigin = CommonConstants.NotDefined;
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when instantiating a data stream structure to store the simulated fault log.
        /// </summary>
        /// <param name="logType">The type of log.</param>
        /// <param name="durationMs">The duration of the log, in ms.</param>
        /// <param name="durationPostTripMs">The duration of the log, in ms, following the trip.</param>
        /// <param name="frameIntervalMs">The interval, in ms, between successive data frames.</param>
        public DataStream_t(LogType logType, double durationMs, double durationPostTripMs, short frameIntervalMs)
        {
            DataStreamTypeParameters = new DataStreamTypeParameters_t();
            StreamNumber = CommonConstants.NotDefined;
            LogType = LogType.SimulatedDataStream;
            EventDescription = string.Empty;
            FrameIntervalMs = frameIntervalMs;

            DurationMs = (int)durationMs;
            SampleCount = (short)(DurationMs / frameIntervalMs);
            DurationPostTripMs = (int)durationPostTripMs;
            DurationPreTripMs = (int)(durationMs - durationPostTripMs);

            DataStreamTypeParameters.TripIndex = (short)(((durationMs - durationPostTripMs) / durationMs) * SampleCount);

            Workset = new Workset_t();
            WatchFrameList = new List<WatchFrame_t>(SampleCount);
            AutoScaleWatchValues = new AutoScale_t[Parameter.WatchSize];
            TimeOrigin = CommonConstants.NotDefined;
        }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the structure. Used when initializing a datastream to store fault log data retrieved from the VCU. 
        /// </summary>
        /// <param name="eventRecord">The event record associated with the data stream.</param>
        /// <param name="watchCount">The number of watch variables contained within the data stream.</param>
        /// <param name="sampleCount">The number of data samples associated with the data stream.</param>
        /// <param name="sampleMultiple">The multiple of the base sample interval at which the data is recorded.</param>
        /// <param name="workset">The workset associated with the data stream.</param>
        public DataStream_t(EventRecord eventRecord, short watchCount, short sampleCount, short sampleMultiple, Workset_t workset)
        {
            // Get the log information associated with the event record.
            Log log = Lookup.LogTable.Items[eventRecord.LogIdentifier];

            DataStreamTypeParameters = log.DataStreamTypeParameters;
            StreamNumber = eventRecord.StreamNumber;
            LogType = LogType.DataStream;
            EventDescription = eventRecord.Description;
            FrameIntervalMs = (short)(sampleMultiple * log.SampleIntervalMs);

            SampleCount = sampleCount;
            DurationMs = (SampleCount - 1) * FrameIntervalMs;

            DurationPreTripMs = DataStreamTypeParameters.TripIndex * FrameIntervalMs;
            DurationPostTripMs = DurationMs - DurationPreTripMs;

            Workset = new Workset_t();
            Workset = workset;

            WatchFrameList = new List<WatchFrame_t>(SampleCount);
            AutoScaleWatchValues = new AutoScale_t[workset.Count];
            TimeOrigin = CommonConstants.NotDefined;
        }
示例#14
0
        /// <summary>
        /// Event handler for the 'Override Security' context menu option <c>Click</c> event. Sets the security level of the selected workset 
        /// to the specified value.
        /// </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_ContextMenuItemOverrideSecurity_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Local reference to the selected item.
            WorksetItem selectedItem = new WorksetItem();

            // The index value of the selected workset.
            int selectedIndex;

            try
            {
                selectedItem = (WorksetItem)m_ListView.SelectedItems[0];
                selectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem = null;
                selectedIndex = 0;
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            // Check that an item has been selected.
            if (selectedItem == null)
            {
                MessageBox.Show(Resources.MBTInstructionSelectWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            FormSetSecurityLevel FormSetSecurityLevel = new FormSetSecurityLevel(selectedItem.Workset.Name, selectedItem.Workset.SecurityLevel);
            FormSetSecurityLevel.CalledFrom = this;
            DialogResult dialogResult = FormSetSecurityLevel.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                // Copy the selected workset
                Workset_t workset = new Workset_t();
                workset = selectedItem.Workset;

                // Modify the security level of the workset to the selected security level.
                workset.SecurityLevel = FormSetSecurityLevel.SecurityLevel;

                // Replace the existing workset with the workset with the modified security level.
                m_WorksetCollection.Edit(selectedItem.Workset.Name, workset);

                // Save the modified object to disk.
                Save();
                UpdateListView();
            }
        }
示例#15
0
        /// <summary>
        /// Event handler for the 'Set As Default' context menu option <c>Click</c> event. Sets the selected workset as the default workset.
        /// </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_ContextMenuItemSetAsDefault_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Local reference to the selected item.
            WorksetItem selectedItem = new WorksetItem();

            // The index value of the selected workset.
            int selectedIndex;

            try
            {
                selectedItem = (WorksetItem)m_ListView.SelectedItems[0];
                selectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem = null;
                selectedIndex = 0;
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            // Check that an item has been selected.
            if (selectedItem == null)
            {
                MessageBox.Show(Resources.MBTInstructionSelectWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Update the object reference with the new default setting.
            m_WorksetCollection.SetDefaultWorkset(selectedItem.Workset.Name);

            // Ensure that the security level of the default workset is set to the appropriate level.
            if (selectedItem.Workset.SecurityLevel < Security.SecurityLevelHighest)
            {
                // Copy the selected workset
                Workset_t workset = new Workset_t();
                workset = selectedItem.Workset;

                // Modify the security level of the workset to be the highest security level.
                workset.SecurityLevel = Security.SecurityLevelHighest;

                // Replace the existing workset with the workset with the modified security level.
                m_WorksetCollection.Edit(selectedItem.Workset.Name, workset);
            }

            // Save the modified object to disk.
            Save();
            UpdateListView();
        }
示例#16
0
        /// <summary>
        /// Download the specified chart recorder workset.
        /// </summary>
        /// <param name="workset">The workset that is to be downloaded to the VCU.</param>
        public void DownloadChartRecorderWorkset(Workset_t workset)
        {
            WatchVariable watchVariable;
            short watchIdentifier;
            double chartScaleUpperLimit, chartScaleLowerLimit;
            for (short channelIndex = 0; channelIndex < Parameter.WatchSizeChartRecorder; channelIndex++)
            {
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[workset.Column[0].OldIdentifierList[channelIndex]];
                    if (watchVariable == null)
                    {
                        throw new Exception("CommunicationParent.DownloadChartRecorderWorkset() - [watchVariable == null]");
                    }

                    watchIdentifier = watchVariable.Identifier;
                    chartScaleUpperLimit = workset.Column[0].ChartScaleList[channelIndex].ChartScaleUpperLimit;
                    chartScaleLowerLimit = workset.Column[0].ChartScaleList[channelIndex].ChartScaleLowerLimit;
                }
                catch (Exception)
                {
                    watchIdentifier = CommonConstants.WatchIdentifierNotDefined;
                    chartScaleUpperLimit = 0;
                    chartScaleLowerLimit = 0;
                }

                SetChartIndex(channelIndex, watchIdentifier);
                SetChartScale(watchIdentifier, chartScaleUpperLimit, chartScaleLowerLimit);
            }
        }
        /// <summary>
        /// <para>
        /// Initializes an new instance of the form for use when EDITing a workset. Populates the 'Configuration' ListBoxes with the data associated with the 
        /// specified configuration and populates the 'Available' ListBoxes with the remaining data i.e. the difference between the configuration and the default data.
        /// </para>
        /// <para>
        /// If the <paramref name="applyVisible"/> parameter is set to true the form will include an apply button so that the user can update the workset without closing
        /// the form between updates. This is especially useful when modifying the active workset while the workset is on display.
        /// </para>
        /// </summary>
        /// <param name="worksetCollection">The workset collection that is to be managed.</param>
        /// <param name="workset">The workset that is to be edited.</param>
        /// <param name="applyVisible">Flag to specify whether the Apply button is to be visible; True, displays the Apply button, false, hides the Apply button.</param>
        public FormWorksetDefineChartRecorderBackup(WorksetCollection worksetCollection, Workset_t workset, bool applyVisible)
            : base(worksetCollection, workset, applyVisible)
        {
            InitializeComponent();

            // Only one column is required fot this workset so delete the tab pages associated with columns 2 and 3.
            m_TabControlWorkset.TabPages.Remove(m_TabPageColumn2);
            m_TabControlWorkset.TabPages.Remove(m_TabPageColumn3);

            // Initialize the column header text boxes, use the default values.
            m_TextBoxHeader1.Text = workset.Column[0].HeaderText;

            // ------------------------------------
            // Update the ListBox controls.
            // -------------------------------------
            WatchItemAddRange(workset.Column[0]);
            UpdateCount();

            // --------------------------
            // OK, Cancel and Apply buttons.
            // ----------------------------
            if (applyVisible == false)
            {
                // Hide the Apply button and move the position of the OK and Cancel buttons.
                m_ButtonApply.Visible = false;
                m_ButtonOK.Location = m_ButtonCancel.Location;
                m_ButtonCancel.Location = m_ButtonApply.Location;
            }
            else
            {
                // Display the Apply button.
                m_ButtonApply.Visible = true;

                // Disable the Apply button until the user modifies the workset.
                m_ButtonApply.Enabled = false;
            }

            // Enable the context menu that allows the user to configure the chart scaling.
            m_MenuItemChangeChartScaleFactor.Visible = true;
        }
示例#18
0
        /// <summary>
        /// For the specified workset file update: (a) the baseline workset; (b) the WatchItems, WatchElementList and CountMax properties of all other worksets and (c) 
        /// the EntryCountMax field to be compatible with the new data dictionary. Also report any worksets that: (a) contain more watch values than are permitted 
        /// or (b) include one or more invalid old identifier references.
        /// </summary>
        /// <param name="worksetCollectionFile">The structure containing the de-serialized workset file.</param>
        private void Update(ref WorksetCollectionFile_t worksetCollectionFile)
        {
            // Get the number of watch variables and the number of oldIdentifiers associated with the current data dictionary and the data dictionary associated with 
            // the workset.
            int dataDictionaryOldIdentifierCount = Lookup.WatchVariableTableByOldIdentifier.RecordList.Count;
            int dataDictionaryWatchIdentifierCount = Lookup.WatchVariableTable.RecordList.Count;
            int worksetOldIdentifierCount = worksetCollectionFile.WorksetList[0].WatchItems.Length;
            int worksetWatchIdentifierCount = 0;
            for (int elementIndex = 0; elementIndex < worksetOldIdentifierCount; elementIndex++)
            {
                if (worksetCollectionFile.WorksetList[0].WatchItems[elementIndex].Exists == true)
                {
                    worksetWatchIdentifierCount++;
                }
            }

            int watchVariablesAddedTo = 0;
            int watchVariablesDeletedFrom = 0;
            if (dataDictionaryOldIdentifierCount > worksetOldIdentifierCount)
            {
                watchVariablesAddedTo = dataDictionaryOldIdentifierCount - worksetOldIdentifierCount;
                watchVariablesDeletedFrom = watchVariablesAddedTo - (dataDictionaryWatchIdentifierCount - worksetWatchIdentifierCount);
            }
            else if (worksetOldIdentifierCount > dataDictionaryOldIdentifierCount)
            {
                watchVariablesDeletedFrom = worksetOldIdentifierCount - dataDictionaryOldIdentifierCount;
                watchVariablesAddedTo = watchVariablesDeletedFrom - (worksetWatchIdentifierCount - dataDictionaryWatchIdentifierCount);
            }

            // Check whether the WatchItems property of the worksets in the specified workset collection need be updated i.e. check whether any watch variables have been 
            // added to or deleted from the the data dictionary since the workset was created.
            List<short> invalidOldIdentifierList;
            List<Workset_t> invalidOldIdentifierWorksetList, invalidWatchSizeWorksetList;
            if ((dataDictionaryOldIdentifierCount != worksetOldIdentifierCount) ||
                (dataDictionaryWatchIdentifierCount != worksetWatchIdentifierCount))
            {
                #region - [Error Reporting] -
                // Check whether any watch variables have been deleted from the current data dictionary since the worksets were defined.
                if (watchVariablesDeletedFrom > 0)
                {
                    // Yes - Get a list of any old identifiers in the workset file that are incompatible with the current data dictionary.
                    invalidOldIdentifierList = GetIncompatibleOldIdentifierList(worksetCollectionFile);
                    if (invalidOldIdentifierList.Count > 0)
                    {
                        // Get the list of worksets that are effected.
                        invalidOldIdentifierWorksetList = GetIncompatibleWorksetList(worksetCollectionFile, invalidOldIdentifierList);

                        if (invalidOldIdentifierWorksetList.Count > 0)
                        {
                            ReportIncompatibleWorksets(invalidOldIdentifierWorksetList, invalidOldIdentifierList, worksetCollectionFile.WorksetCollectionType); 
                        }
                    }
                }
                #endregion - [Error Reporting] -

                #region - [WatchItems/WatchElementList Update] -
                // ------------------------------------------------------------------------------------
                // Update the WatchItems and WatchElementList fields of all of the workset in the file.
                // ------------------------------------------------------------------------------------
                for (short worksetIndex = 0; worksetIndex < worksetCollectionFile.WorksetList.Count; worksetIndex++)
                {
                    // Replicate the workset.
                    Workset_t workset = new Workset_t();
                    workset.Replicate(worksetCollectionFile.WorksetList[worksetIndex]);

                    //Create a new WatchItems propery for the current workset based upon the current data dictionary with the Added property of all elements set to false.
                    workset.WatchItems = new WatchItem_t[dataDictionaryOldIdentifierCount];
                    WatchItem_t watchItem;
                    for (short watchItemIndex = 0; watchItemIndex < dataDictionaryOldIdentifierCount; watchItemIndex++)
                    {
                        watchItem = new WatchItem_t();
                        watchItem.OldIdentifier = watchItemIndex;
                        watchItem.Added = false;

                        try
                        {
                            // Check whether the watch variable exists and set the Exists property of the watch item appropriately.
                            WatchVariable watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[watchItemIndex];
                            watchItem.Exists = (watchVariable == null) ? false : true;
                        }
                        catch (Exception)
                        {
                            watchItem.Exists = false;
                        }

                        workset.WatchItems[watchItemIndex] = watchItem;
                    }

                    // Update the WatchElementList and the WatchItems properties of the workset using the old identifier values stored in each column of the workset.
                    workset.WatchElementList = new List<short>();
                    short oldIdentifier;
                    for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
                    {
                        for (int rowIndex = 0; rowIndex < workset.Column[columnIndex].OldIdentifierList.Count; rowIndex++)
                        {
                            // Get the old identifier value.
                            oldIdentifier = workset.Column[columnIndex].OldIdentifierList[rowIndex];

                            // Check whether the watch variable associated with the old identifier value exists in the current workset.
                            try
                            {
                                WatchVariable watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];
                                if (watchVariable == null)
                                {
                                    // No, add the watch identifier value used to represent the watch variable not being defined in the current data dictionary.
                                    workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                                }
                                else
                                {
                                    // Add the watch identifier of the watch variable corresponding to the specified old identifier to the list of watch identifiers.
                                    workset.WatchElementList.Add(watchVariable.Identifier);

                                    // Update the Exists and Added properties of the WatchItem element corresponding to the specified old identifier.
                                    workset.WatchItems[oldIdentifier].Added = true;
                                    workset.WatchItems[oldIdentifier].Exists = true;
                                }
                            }
                            catch (Exception)
                            {
                                // No, add the watch identifier value used to represent the watch variable not being defined in the current data dictionary.
                                workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                            }
                        }
                    }

                    workset.WatchElementList.Sort();

                    // Replace the workset.
                    worksetCollectionFile.WorksetList[worksetIndex] = workset;
                    #endregion - [WatchItems/WatchElementList Update] -
                }
            }

            // Only carry out watch size processing if the workset collection corresponds to a watch window workset.
            if (worksetCollectionFile.WorksetCollectionType == Configuration.WorksetCollectionType.RecordedWatch)
            {
                #region - [Error Reporting] -
                invalidWatchSizeWorksetList = GetIncompatibleWorksetList(worksetCollectionFile, Parameter.WatchSize);
                if (invalidWatchSizeWorksetList.Count > 0)
                {
                    ReportIncompatibleWorksets(invalidWatchSizeWorksetList);
                }
                #endregion - [Error Reporting] -

                #region - [WatchSize Update] -
                // Update the EntryCountMax field of the workset file, if required.
                if (worksetCollectionFile.EntryCountMax != Parameter.WatchSize)
                {
                    worksetCollectionFile.EntryCountMax = Parameter.WatchSize;
                }

                // Update the baseline workset and the EntryCount max field of individual worksets, if required.
                for (int worksetIndex = 0; worksetIndex < worksetCollectionFile.WorksetList.Count; worksetIndex++)
                {
                    Workset_t workset;
                    if (worksetCollectionFile.WorksetList[worksetIndex].CountMax != Parameter.WatchSize)
                    {
                        // If the workset is the baseline workset, update it.
                        if (worksetIndex == 0)
                        {
                            workset = CreateBaselineWorkset();

                        }
                        else
                        {
                            workset = worksetCollectionFile.WorksetList[worksetIndex];
                            workset.CountMax = Parameter.WatchSize;
                        }

                        worksetCollectionFile.WorksetList[worksetIndex] = workset;
                    }
                }
                #endregion - [WatchSize Update] -
            }
        }
        /// <summary>
        /// Initialize a new instance of the class and set the properties and member variables to those values associated with the specified communication interface.
        /// </summary>
        /// <param name="communicationInterface">Reference to the communication interface containing the properties and member variables that are to be used to
        /// initialize the class.</param>
        public CommunicationEventOffline(ICommunicationParent communicationInterface)
            : base(communicationInterface)
        {
            // --------------------------------------------------------------------------------------------
            // Get the workset that is to be used to simulate the fault log parameters and the data stream.
            // --------------------------------------------------------------------------------------------

            // If it has been configured, get the first valid workset other than the baseline workset; otherwise, use the baseline workset.
            int worksetIndex = (Workset.FaultLog.Worksets.Count > 0) ? 1 : 0;
            Workset_t workset = Workset.FaultLog.Worksets[worksetIndex];
            m_Workset = workset;
        }
示例#20
0
        /// <summary>
        /// Replicate the specified workset i.e. produce a copy of the workset that is completely independent of the original.
        /// </summary>
        /// <param name="workset">The workset that is to be copied.</param>
        public void Replicate(Workset_t workset)
        {
            Name = workset.Name;
            SampleMultiple = workset.SampleMultiple;
            CountMax = workset.CountMax;
            SecurityLevel = workset.SecurityLevel;

            // Copy WatchElementList.
            WatchElementList = new List<short>();
            short watchIdentifier;
            for (int watchElementIndex = 0; watchElementIndex < workset.WatchElementList.Count; watchElementIndex++)
            {
                watchIdentifier = workset.WatchElementList[watchElementIndex];
                WatchElementList.Add(watchIdentifier);
            }
            Count = WatchElementList.Count;

            #region - [Column] -
            Column = new Column_t[workset.Column.Length];
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                Column[columnIndex] = new Column_t();
                Column[columnIndex].HeaderText = workset.Column[columnIndex].HeaderText;
                Column[columnIndex].OldIdentifierList = new List<short>();

                short oldIdentifier;
                for (int rowIndex = 0; rowIndex < workset.Column[columnIndex].OldIdentifierList.Count; rowIndex++)
                {
                    oldIdentifier = workset.Column[columnIndex].OldIdentifierList[rowIndex];
                    Column[columnIndex].OldIdentifierList.Add(oldIdentifier);
                }

                // Only replicate the chart recorder scaling information if it has been defined.
                if (workset.Column[columnIndex].ChartScaleList == null)
                {
                    Column[columnIndex].ChartScaleList = null;
                }
                else
                {
                    Column[columnIndex].ChartScaleList = new List<ChartScale_t>();
                    ChartScale_t chartScale;
                    for (int rowIndex = 0; rowIndex < workset.Column[columnIndex].ChartScaleList.Count; rowIndex++)
                    {
                        chartScale = workset.Column[columnIndex].ChartScaleList[rowIndex];
                        Column[columnIndex].ChartScaleList.Add(chartScale);
                    }
                }
            }
            #endregion - [Column] -

            #region - [PlotTabPages] -
            // Only replicate the tab page plot information if it has been defined.
            if (workset.PlotTabPages == null)
            {
                PlotTabPages = null;
            }
            else
            {
                PlotTabPages = new PlotTabPage_t[workset.PlotTabPages.Length];

                // Copy the TabPagePlot information to the new array.
                Array.Copy(workset.PlotTabPages, PlotTabPages, workset.PlotTabPages.Length);
            }
            #endregion - [PlotTabPages] -

            WatchItems = new WatchItem_t[workset.WatchItems.Length];

            // Copy the WatchItems property to the new array.
            Array.Copy(workset.WatchItems, WatchItems, WatchItems.Length);
        }
        /// <summary>
        /// Convert the specified data stream watch variable identifiers/parameters into a valid workset.
        /// </summary>
        /// <remarks>
        /// All of the watch identifiers returned from the VCU s are added to Column[0] of the workset in the order in which they appear in <paramref name="variableIdentifiers"/> and
        /// the security level of the workset is set to the lowest security level.
        /// </remarks>
        /// <param name="name">The name of the workset.</param>
        /// <param name="variableIdentifiers">The array of watch identifiers.</param>
        /// <param name="sampleMultiple">The multiple of the recording interval at which the data is recorded.</param>
        /// <returns>The watch identifiers contained within <paramref name="variableIdentifiers"/> as a valid workset.</returns>
        public Workset_t ConvertToWorkset(string name, short[] variableIdentifiers, short sampleMultiple)
        {
            Debug.Assert(variableIdentifiers != null, "CommunicationEvent.ConvertToWorkset() - [variableIdentifiers != null]");
            Debug.Assert(name != string.Empty, "CommunicationEvent.ConvertToWorkset() - [name != string.Empty]");

            // Create a workset based upon those watch identifiers contained within the array.
            List<short> watchIdentifierList = new List<short>(variableIdentifiers.Length);
            for (short index = 0; index < variableIdentifiers.Length; index++)
            {
                watchIdentifierList.Add(variableIdentifiers[index]);
            }

            Workset_t workset = new Workset_t(name, watchIdentifierList, Parameter.WatchSizeFaultLog, VCUDataStreamColumnCountMax, new Security().SecurityLevelBase);

            workset.SampleMultiple = sampleMultiple;
            return workset;
        }
示例#22
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// <list type="number">
        /// <item><description>Clear the existing list of worksets.</description></item>
        /// <item><description>Create a baseline workset and add this to the list of worksets.</description></item>
        /// <item><description>Set the newly created baseline workset to be the default workset.</description></item>
        /// <item><description>Copy the project information specified in the data dictionary to the project information field.</description></item>
        /// </list>
        /// </summary>
        /// <param name="worksetCollectionType">The type of workset collection.</param>
        /// <param name="entryCountMax">The maximum number of entries that each workset can support.</param>
        /// <param name="columnCountMax">The maximum number of display columns that each workset can support.</param>
        public void Initialize(WorksetCollectionType worksetCollectionType, short entryCountMax, short columnCountMax)
        {
            m_WorksetCollectionFile_t = new WorksetCollectionFile_t();
            m_WorksetCollectionFile_t.ProjectInformation = Parameter.ProjectInformation;
            m_WorksetCollectionFile_t.WorksetCollectionType = worksetCollectionType;
            m_WorksetCollectionFile_t.EntryCountMax = entryCountMax;
            m_WorksetCollectionFile_t.ColumnCountMax = columnCountMax;

            // Instantiate the list of workset structures.
            m_WorksetCollectionFile_t.WorksetList = new List<Workset_t>();

            // Create a new baseline workset i.e. one containing ALL watch variable references, ordered by watch identifier.
            Workset_t workset = new Workset_t();
            workset = CreateBaselineWorkset();

            // Add this baseline workset to the list.
            m_WorksetCollectionFile_t.WorksetList.Add(workset);

            // Set the active index to point at the baseline workset.
            m_WorksetCollectionFile_t.ActiveIndex = 0;

            // Set the default index to point at the baseline workset.
            m_WorksetCollectionFile_t.DefaultIndex = 0;
        }
示例#23
0
        /// <summary>
        /// Predicate function called by the <c>List.Find()</c> method to return a workset that matches the Name variable of the m_WorksetToCompare workset.
        /// </summary>
        /// <param name="workset">The workset list item that is to be processed.</param>
        /// <returns>True if the specified item meets the logic requirements given in the function; otherwise false.</returns>
        private bool CompareName(Workset_t workset)
        {
            bool match = false;
            Workset_t worksetToCompare = m_WorksetToCompare;

            if (worksetToCompare.Name == workset.Name)
            {
                match = true;
            }

            return match;
        }
示例#24
0
        /// <summary>
        /// Replace the specified workset with the new workset. If the workset specified by <paramref name="worksetName"/> cannot be found, no action is taken.
        /// </summary>
        /// <param name="worksetName">The name of the workset that is to be edited.</param>
        /// <param name="newWorkset">The new workset <seealso cref="Workset_t"/>.</param>
        public void Edit(string worksetName, Workset_t newWorkset)
        {
            // Local copy of active workset index, just in case things are disturbed.
            int activeIndex;

            // Preserve the index of the active workset in case this is disturbed by the operation.
            activeIndex = m_WorksetCollectionFile_t.ActiveIndex;

            // Get the names of the worksets included in the collection.
            object[] worksetNames = GetWorksetNames();

            // Check each entry in the collection for the specified name.
            for (int index = 0; index < m_WorksetCollectionFile_t.WorksetList.Count; index++)
            {
                if ((string)worksetNames[index] == worksetName)
                {
                    // Remove the existing workset.
                    m_WorksetCollectionFile_t.WorksetList.RemoveAt(index);

                    // Insert the new workset at the same index.
                    m_WorksetCollectionFile_t.WorksetList.Insert(index, newWorkset);

                    // Re-establish the status-quo.
                    m_WorksetCollectionFile_t.ActiveIndex = activeIndex;

                    break;
                }
            }
        }
示例#25
0
        /// <summary>
        /// Event handler for the 'Save' <c>ToolStripButton</c> <c>Click</c> event. 
        /// </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>
        protected virtual void m_TSBSave_Click(object sender, EventArgs e)
        {
            string userMessage = string.Empty;

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

            Cursor = Cursors.WaitCursor;
            m_TSBSave.Checked = true;

            // Convert the downloaded chart configuration to a workset format.
            Workset_t workset;
            if (m_UseTextBoxAsNameSource == true)
            {
                workset = ConvertToWorkset(m_TextBoxName.Text);
            }
            else
            {
                workset = ConvertToWorkset(m_ComboBoxWorkset.Text);
            }

            m_WorksetToCompare = workset;
            Workset_t matchedWorkset;

            switch (m_ModifyState)
            {
                case ModifyState.Rename:
                    // Check whether the name already exists. 
                    matchedWorkset = m_WorksetCollection.Worksets.Find(CompareName);
                    if (matchedWorkset.WatchItems != null)
                    {
                        // Yes, inform the user.
                        MessageBox.Show(Resources.MBTWorksetNameExists, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        m_TSBSave.Checked = false;
                        Cursor = Cursors.Default;
                        return;
                    }
                    break;
                default:
                    // Check whether the workset identifiers currently exists.
                    matchedWorkset = m_WorksetCollection.Worksets.Find(CompareWorkset);

                    // Check whether the current parameters, excluding name and security level, match those of an existing workset.
                    if (matchedWorkset.WatchItems != null)
                    {
                        // Yes - check whether the names are identical.
                        if (workset.Name == matchedWorkset.Name)
                        {
                            MessageBox.Show(string.Format(Resources.MBTWorksetExists, workset.Name), Resources.MBCaptionInformation, MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show(string.Format(Resources.MBTWorksetIdentical, matchedWorkset.Name), Resources.MBCaptionInformation, MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }

                        m_TSBSave.Checked = false;
                        Cursor = Cursors.Default;
                        return;
                    }
                    break;
            }
            
            // Check whether the workset is an existing workset that is to be modified or a new workset. 
            if (m_CreateMode == true)
            {
                // The workset is a new workset, check whether the name already exists.
                matchedWorkset = m_WorksetCollection.Worksets.Find(CompareName);
                if (matchedWorkset.WatchItems != null)
                {
                    // Yes, inform the user.
                    MessageBox.Show(Resources.MBTWorksetNameExists, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    m_TSBSave.Checked = false;
                    Cursor = Cursors.Default;
                    return;
                }
                else
                {
                    // No,save the new workset.
                    m_WorksetCollection.Add(workset);
                    ComboBoxAddWorksets(m_ComboBoxWorkset, m_WorksetCollection);
                    m_ComboBoxWorkset.Text = workset.Name;
                    userMessage = string.Format(Resources.MBTWorksetCreationSuccess, workset.Name);
                    SetModifyState(ModifyState.Configure);
                }
            }
            else
            {
                if (Security.SecurityLevelCurrent < ((Workset_t)m_ComboBoxWorkset.SelectedItem).SecurityLevel)
                {
                    MessageBox.Show(Resources.MBTInsufficientPrivilegesModify, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    m_TSBSave.Checked = false;
                    Cursor = Cursors.Default;
                    return;
                }
                else
                {
                    // Ask the user for confirmation.
                    string worksetName = string.Empty;
                    DialogResult dialogResult;
                    switch (m_ModifyState)
                    {
                        case ModifyState.Rename:
                            worksetName = m_ComboBoxWorkset.Text;
                            dialogResult = MessageBox.Show(string.Format(Resources.MBTQueryWorksetRename, worksetName), Resources.MBCaptionQuestion,
                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            userMessage = string.Format(Resources.MBTWorksetRenameSuccess, worksetName, workset.Name);
                            break;
                        case ModifyState.Edit:
                            worksetName = workset.Name;
                            dialogResult = MessageBox.Show(string.Format(Resources.MBTConfirmWorksetModify, worksetName), Resources.MBCaptionQuestion,
                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            userMessage = string.Format(Resources.MBTWorksetUpdateSuccess, workset.Name);
                            break;
                        default:
                            m_TSBSave.Checked = false;
                            Cursor = Cursors.Default;
                            return;
                    }

                    if (dialogResult == DialogResult.No)
                    {
                        m_TSBSave.Checked = false;
                        Cursor = Cursors.Default;
                        return;
                    }

                    Update();
                    m_WorksetCollection.Edit(worksetName, workset);
                    ComboBoxAddWorksets(m_ComboBoxWorkset, m_WorksetCollection);
                    m_ComboBoxWorkset.Text = workset.Name;
                    m_SelectedWorkset = workset;
                    SetModifyState(ModifyState.Configure);
                }
            }

            Save();

            // Allow the user to select any of the available worksets. 
            m_TextBoxName.Visible = false;
            m_TextBoxName.Enabled = false;
            m_ComboBoxWorkset.Text = m_TextBoxName.Text;
            m_ComboBoxWorkset.Visible = true;

            m_TSBSave.Checked = false;

            // Inform the user of a successful update.
            MessageBox.Show(userMessage, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
            Cursor = Cursors.Default;
        }
示例#26
0
 /// <summary>
 /// Add the specified workset.
 /// </summary>
 /// <param name="workset">The workset that is to be added to the workset collection.</param>
 /// <returns>True, if the specified workset was successfully added to the collection; otherise, false.</returns>
 public bool Add(Workset_t workset)
 {
     // Check whether the workset collection contains a workset with the same name as the specified workset. 
     if (m_WorksetCollectionFile_t.WorksetList.Contains(workset) == false)
     {
         // No - add the workset.
         m_WorksetCollectionFile_t.WorksetList.Add(workset);
         return true;
     }
     else
     {
         // Yes - Ignore the request and inform the user.
         return false;
     }
 }
示例#27
0
        /// <summary>
        /// Convert the current user settings to a workset.
        /// </summary>
        /// <param name="worksetName">The name of the workset.</param>
        /// <returns>The user settings converted to a workset.</returns>
        protected virtual Workset_t ConvertToWorkset(string worksetName)
        {
            Workset_t workset = new Workset_t();

            workset.Name = worksetName;
            workset.SampleMultiple = Workset_t.DefaultSampleMultiple;
            workset.CountMax = m_WorksetCollection.EntryCountMax;
            workset.SecurityLevel = Security.SecurityLevelCurrent;

            #region - [Column] -
            workset.Column = new Column_t[1];
            workset.Column[0].HeaderText = m_TextBoxHeader1.Text;
            workset.Column[0].OldIdentifierList = new List<short>();

            #region - [OldIdentifierList] -
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                workset.Column[0].OldIdentifierList.Add(((WatchItem_t)m_ListBox1.Items[index]).OldIdentifier);
            }
            #endregion - [OldIdentifierList] -
            #endregion - [Column] -

            #region - [WatchItems] -
            workset.WatchItems = new WatchItem_t[m_WatchItems.Length];
            Array.Copy(m_WatchItems, workset.WatchItems, m_WatchItems.Length);
            #endregion - [WatchItems] -

            #region - [WatchElementList] -
            workset.WatchElementList = new List<short>();
            short oldIdentifier;
            WatchVariable watchVariable;

            for (int rowIndex = 0; rowIndex < workset.Column[0].OldIdentifierList.Count; rowIndex++)
            {
                oldIdentifier = workset.Column[0].OldIdentifierList[rowIndex];
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];
                    if (watchVariable == null)
                    {
                        workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                    }
                    else
                    {
                        workset.WatchElementList.Add(watchVariable.Identifier);
                    }
                }
                catch (Exception)
                {
                    workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                }
            }
            workset.WatchElementList.Sort();
            #endregion - [WatchElementList] -

            #region - [Count] -
            workset.Count = workset.WatchElementList.Count;

            if (workset.Count != m_ListItemCount)
            {
                throw new ArgumentException(Resources.EMWorksetIntegrityCheckFailed, "FormWorksetDefineFaultLog.ConvertToWorkset() - [workset.WatchElements.Count]");
            }
            #endregion - [Count] -

            return workset;
        }
示例#28
0
        /// <summary>
        /// Add the plotter controls used to plot the watch variables associated with the specified column of the workset to the specified
        /// <c>TableLayoutPanel</c>.
        /// </summary>
        /// <param name="tableLayoutPanel">The <c>TableLayoutPanel</c> that is to be configured.</param>
        /// <param name="workset">The workset containing the watch variables.</param>
        /// <param name="autoScaleWatchValues">The auto-scale values associated with the watch variables contained within the workset.</param>
        /// <param name="tabPageIndex">The index of the tab page definition that is to be processed.</param>
        private void ConfigureTableLayoutPanel(TableLayoutPanel tableLayoutPanel, Workset_t workset, AutoScale_t[] autoScaleWatchValues,
                                               int tabPageIndex)
        {
            tableLayoutPanel.Controls.Clear();
            tableLayoutPanel.RowCount = 0;

            // Add the row style and plotter controls to the layout panel.
            short oldIdentifier, watchElementIndex;
            WatchVariable watchVariable;
            PlotterScalar plotterScalar;
            PlotterBitmask plotterBitmask;
            PlotterEnumerator plotterEnumerator;
            uint displayMask;
            for (int oldIdentifierListIndex = 0; oldIdentifierListIndex < workset.PlotTabPages[tabPageIndex].OldIdentifierList.Count;
                 oldIdentifierListIndex++)
            {
                tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize, PreferredHeight));

                oldIdentifier = workset.PlotTabPages[tabPageIndex].OldIdentifierList[oldIdentifierListIndex];
                // TODO FormDataStreamPlot.ConfigureTableLayoutPanel(). Discuss with John Paul about a check for oldIdentifier = 1 representing not
                // valid.

                displayMask = workset.PlotTabPages[tabPageIndex].DisplayMaskList[oldIdentifierListIndex]; 

                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[oldIdentifier];

                    // Check whether the watch variable exists.
                    if (watchVariable == null)
                    {
                        // No, skip this entry.
                        continue;
                    }
                }
                catch (Exception)
                {
                    continue;
                }

                // Get the watch element index associated with the old identifier identifier.
                watchElementIndex = m_HistoricDataManager.GetWatchElementIndex(oldIdentifier);

                // Check whether the old watch file contains watch values associated with this old identifier.
                if (watchElementIndex == CommonConstants.NotDefined)
                {
                    continue;
                }

                switch (watchVariable.VariableType)
                {
                    case VariableType.Scalar:
                        // Create a new row for the scalar watch variable plot.
                        tableLayoutPanel.RowCount++;

                        // Instantiate and configure a plotter control to plot the watch variable.
                        plotterScalar = 
                            m_PlotterControlLayout.ConstructPlotterScalar(oldIdentifier,
                                                                                      autoScaleWatchValues[watchElementIndex].UpperDisplayLimitEng,
                                                                                      autoScaleWatchValues[watchElementIndex].LowerDisplayLimitEng);

                        // Add the configured control to the TableLayoutPanel.
                        if (plotterScalar != null)
                        {
                            tableLayoutPanel.Controls.Add(plotterScalar);
                        }
                        break;
                    case VariableType.Enumerator:
                        // Create a new row for the enumerator watch variable plot.
                        tableLayoutPanel.RowCount++;

                        // Instantiate and configure a plotter control to plot the watch variable.
                        plotterEnumerator = 
                            m_PlotterControlLayout.ConstructPlotterEnumerator(oldIdentifier,
                                                                              autoScaleWatchValues[watchElementIndex].UpperDisplayLimitEng,
                                                                              autoScaleWatchValues[watchElementIndex].LowerDisplayLimitEng);

                        // Add the configured control to the TableLayoutPanel.
                        if (plotterEnumerator != null)
                        {
                            tableLayoutPanel.Controls.Add(plotterEnumerator);
                        }
                        break;
                    case VariableType.Bitmask:
                        byte bitCount = (byte)Lookup.WatchVariableTableByOldIdentifier.GetBitCount(oldIdentifier);

                        ulong bitMask;
                        for (byte bitIndex = 0; bitIndex < bitCount; bitIndex++)
                        {
                            // Skip, if the flag description associated with the current bit is empty.
                            if (Lookup.WatchVariableTableByOldIdentifier.GetFlagDescription(oldIdentifier, bitIndex) == string.Empty)
                            {
                                continue;
                            }

                            // Skip if the bit is not set in the display mask.
                            bitMask = (ulong)0x01 << bitIndex;
                            if ((displayMask & bitMask) != bitMask)
                            {
                                continue;
                            }

                            // Create a new row for the bitmask watch variable plot.
                            tableLayoutPanel.RowCount++;

                            // Instantiate and configure a logic analyzer control to plot the watch variable.
                            plotterBitmask = m_PlotterControlLayout.ConstructLogicAnalyzerControl(oldIdentifier, bitIndex);

                            // Add the configured control to the TableLayoutPanel.
                            if (plotterBitmask != null)
                            {
                                tableLayoutPanel.Controls.Add(plotterBitmask);
                            }
                        }
                        break;
                    default:
                        throw new InvalidEnumArgumentException("LookupTable.Watch.Items[watchIdentifier].VariableType",
                                                               (int)watchVariable.VariableType, typeof(VariableType));
                }
            }
        }
示例#29
0
        /// <summary>
        /// Load the specified workset.
        /// </summary>
        /// <param name="workset">The workset that is to be processed.</param>
        protected virtual void LoadWorkset(Workset_t workset)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control.
            m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged);
            m_TextBoxName.Text = workset.Name;
            m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged);

            m_TextBoxHeader1.Text = workset.Column[0].HeaderText;

            m_ListItemCount = workset.Count;

            m_WatchItems = new WatchItem_t[workset.WatchItems.Length];
            Array.Copy(workset.WatchItems, m_WatchItems, workset.WatchItems.Length);

            UpdateListBoxAvailable(m_WatchItems);

            // ------------------------------------
            // Update the 'Column' ListBox control.
            // -------------------------------------
            WatchItemAddRange(m_ListBox1, workset.Column[0]);
            UpdateCount();

            m_TextBoxSecurityLevel.Text = Security.GetSecurityDescription(workset.SecurityLevel);
        }
 /// <summary>
 /// Download the specified chart recorder workset to the VCU.
 /// </summary>
 /// <param name="workset">The workset that is to be downloaded to the VCU.</param>
 public void DownloadChartRecorderWorkset(Workset_t workset)
 {
     Thread.Sleep(SleepIntervalMsDownloadChartRecorderWorkset);
 }