/// <summary> /// Add the watch variables defined in the specified workset column to the <c>ListBox</c> controls that display the description and the chart recorder scaling /// information for each chart recorder channel. /// </summary> /// <param name="worksetColumn">The column of the workset that is to be added to the <c>ListBox</c> control.</param> protected void WatchItemAddRange(Column_t worksetColumn) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; m_ListBox1.Items.Clear(); m_ListBoxChartScaleMin.Items.Clear(); m_ListBoxChartScaleMax.Items.Clear(); m_ListBoxUnits.Items.Clear(); m_ListBox1.SuspendLayout(); m_ListBoxChartScaleMin.SuspendLayout(); m_ListBoxChartScaleMax.SuspendLayout(); m_ListBoxUnits.SuspendLayout(); WatchItem_t watchItem; short oldIdentifier; WatchVariable watchVariable; ChartScale_t chartScale; for (int index = 0; index < worksetColumn.OldIdentifierList.Count; index++) { watchItem = new WatchItem_t(); oldIdentifier = worksetColumn.OldIdentifierList[index]; watchItem.OldIdentifier = oldIdentifier; watchItem.Added = true; m_ListBox1.Items.Add(watchItem); // Check whether the watch variable exists. try { watchVariable = watchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[oldIdentifier]; if (watchVariable == null) { throw new Exception(); } // Check whether the chart scaling for the current watch variable has been defined. try { chartScale = worksetColumn.ChartScaleList[index]; } catch (Exception) { // No - Set up the default chart scaling for the watch variable based upon the data dictionary. chartScale = new ChartScale_t(); chartScale.ChartScaleMax = watchVariable.MaxChartScale; chartScale.ChartScaleMin = watchVariable.MinChartScale; chartScale.Units = watchVariable.Units; } } catch (Exception) { // Watch variable does not exist. chartScale.ChartScaleMax = double.NaN; chartScale.ChartScaleMin = double.NaN; chartScale.Units = CommonConstants.VariableNotDefinedUnitsString; } m_ListBoxChartScaleMin.Items.Add(chartScale.ChartScaleMin); m_ListBoxChartScaleMax.Items.Add(chartScale.ChartScaleMax); m_ListBoxUnits.Items.Add(chartScale.Units); } m_ListBox1.PerformLayout(); m_ListBoxChartScaleMin.PerformLayout(); m_ListBoxChartScaleMax.PerformLayout(); m_ListBoxUnits.PerformLayout(); Cursor = Cursors.Default; }
/// <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> /// Add the watch variables defined in the specified workset column to the <c>ListBox</c> controls that display the description and the chart recorder scaling /// information for each chart recorder channel. /// </summary> /// <param name="listBox">The <c>ListBox</c> to which the items are to be added.</param> /// <param name="worksetColumn">The column of the workset that is to be added to the <c>ListBox</c> control.</param> protected override void WatchItemAddRange(ListBox listBox, Column_t worksetColumn) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; listBox.Items.Clear(); m_ListBoxChartScaleUpperLimit.Items.Clear(); m_ListBoxChartScaleLowerLimit.Items.Clear(); m_ListBoxUnits.Items.Clear(); listBox.SuspendLayout(); m_ListBoxChartScaleUpperLimit.SuspendLayout(); m_ListBoxChartScaleLowerLimit.SuspendLayout(); m_ListBoxUnits.SuspendLayout(); bool hexFormat = false; WatchItem_t watchItem; short oldIdentifier; WatchVariable watchVariable; ChartScale_t chartScale; for (int index = 0; index < worksetColumn.OldIdentifierList.Count; index++) { watchItem = new WatchItem_t(); oldIdentifier = worksetColumn.OldIdentifierList[index]; watchItem.OldIdentifier = oldIdentifier; watchItem.Added = true; m_ListBox1.Items.Add(watchItem); // Check whether the watch variable exists. try { watchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[oldIdentifier]; if (watchVariable == null) { throw new Exception(); } // Determine the format of the watch variable. hexFormat = (watchVariable.FormatString.ToLower().Equals(CommonConstants.DDFormatStringHex)) ? true : false; // Check whether the chart scaling for the current watch variable has been defined. try { chartScale = worksetColumn.ChartScaleList[index]; } catch (Exception) { // No - Set up the default chart scaling for the watch variable based upon the data dictionary. chartScale = new ChartScale_t(); chartScale.ChartScaleLowerLimit = watchVariable.MinChartScale; chartScale.ChartScaleUpperLimit = watchVariable.MaxChartScale; chartScale.Units = watchVariable.Units; } } catch (Exception) { // Watch variable does not exist. chartScale.ChartScaleLowerLimit = double.NaN; chartScale.ChartScaleUpperLimit = double.NaN; chartScale.Units = CommonConstants.ChartScaleUnitsNotDefinedString; } // Rather tha displaying 'NaN' if the chart scale values are undefined, display the default string used to represent a chart scale value that is not defined. if (chartScale.ChartScaleLowerLimit.Equals(double.NaN)) { m_ListBoxChartScaleLowerLimit.Items.Add(CommonConstants.ChartScaleValueNotDefinedString); } else { if (hexFormat == true) { m_ListBoxChartScaleLowerLimit.Items.Add(CommonConstants.HexValueIdentifier + ((uint)chartScale.ChartScaleLowerLimit).ToString(CommonConstants.FormatStringHex)); } else { m_ListBoxChartScaleLowerLimit.Items.Add(chartScale.ChartScaleLowerLimit.ToString(CommonConstants.FormatStringNumeric)); } } if (chartScale.ChartScaleUpperLimit.Equals(double.NaN)) { m_ListBoxChartScaleUpperLimit.Items.Add(CommonConstants.ChartScaleValueNotDefinedString); } else { if (hexFormat == true) { m_ListBoxChartScaleUpperLimit.Items.Add(CommonConstants.HexValueIdentifier + ((uint)chartScale.ChartScaleUpperLimit).ToString(CommonConstants.FormatStringHex)); } else { m_ListBoxChartScaleUpperLimit.Items.Add(chartScale.ChartScaleUpperLimit.ToString(CommonConstants.FormatStringNumeric)); } } m_ListBoxUnits.Items.Add(chartScale.Units); } listBox.PerformLayout(); m_ListBoxChartScaleLowerLimit.PerformLayout(); m_ListBoxChartScaleUpperLimit.PerformLayout(); m_ListBoxUnits.PerformLayout(); Cursor = Cursors.Default; }
/// <summary> /// Initialize a new instance of the structure. Creates a new workset based upon the specified name and list of watch identifiers. /// </summary> /// <param name="name">The name of the workset.</param> /// <param name="watchIdentifierList">The list of watch identifiers that are to be used to initialize the workset.</param> /// <param name="entryCountMax">The maximum number of entries that the workset can support.</param> /// <param name="columnCountMax">The maximum number of display columns that the workset can support.</param> /// <param name="securityLevel">The security level associated with the workset.</param> /// <remarks> /// All watch identifiers contained within the specified list will appear in the first column of the workset in the order that they appear in the list. The /// watch element list is sorted by watch identifier value in ascending order. /// </remarks> public Workset_t(string name, List<short> watchIdentifierList, short entryCountMax, short columnCountMax, SecurityLevel securityLevel) { Debug.Assert(name != string.Empty, "Workset_t.Ctor() - [name != string.Empty]"); Debug.Assert(watchIdentifierList != null, "Workset_t.Ctor() - [watchElementList != null]"); Debug.Assert((watchIdentifierList.Count > 0), "Workset_t.Ctor() - [watchElementList.Count > 0"); Name = name; SampleMultiple = DefaultSampleMultiple; CountMax = entryCountMax; SecurityLevel = securityLevel; // Create the WatchElementList property. WatchElementList = new List<short>(); short watchIdentifier; for (int watchIdentifierIndex = 0; watchIdentifierIndex < watchIdentifierList.Count; watchIdentifierIndex++) { watchIdentifier = watchIdentifierList[watchIdentifierIndex]; WatchElementList.Add(watchIdentifier); } WatchElementList.Sort(); Count = WatchElementList.Count; #region - [Column] - Column = new Column_t[columnCountMax]; for (int columnIndex = 0; columnIndex < columnCountMax; columnIndex++) { Column[columnIndex] = new Column_t(); Column[columnIndex].HeaderText = (columnIndex == 0) ? Resources.LegendColumn + CommonConstants.Space + (columnIndex + 1).ToString() : string.Empty; Column[columnIndex].OldIdentifierList = new List<short>(); Column[columnIndex].ChartScaleList = new List<ChartScale_t>(); } // Add the old identifier values of the watch variables defined in the watch element list to the first column of the workset. WatchVariable watchVariable; ChartScale_t chartScale; for (short watchIdentifierIndex = 0; watchIdentifierIndex < WatchElementList.Count; watchIdentifierIndex++) { chartScale = new ChartScale_t(); try { watchVariable = Lookup.WatchVariableTable.Items[watchIdentifierList[watchIdentifierIndex]]; if (watchVariable == null) { throw new Exception(); } else { Column[0].OldIdentifierList.Add(watchVariable.OldIdentifier); // Set up the default chart scaling from the values in the data dictionary. chartScale.ChartScaleUpperLimit = watchVariable.MaxChartScale; chartScale.ChartScaleLowerLimit = watchVariable.MinChartScale; chartScale.Units = watchVariable.Units; Column[0].ChartScaleList.Add(chartScale); } } catch (Exception) { Column[0].OldIdentifierList.Add(CommonConstants.OldIdentifierNotDefined); // Set the chart scaling values to represent an invalid entry. chartScale.ChartScaleLowerLimit = double.NaN; chartScale.ChartScaleUpperLimit = double.NaN; chartScale.Units = CommonConstants.ChartScaleUnitsNotDefinedString; Column[0].ChartScaleList.Add(chartScale); } } #endregion - [Column] - // This attribute is used to define the plot screen layout and is defined by the user when displaying the saved data file. PlotTabPages = null; WatchItems = new WatchItem_t[Lookup.WatchVariableTableByOldIdentifier.Items.Length]; // Create the WatchItems property from the list of watch elements. WatchItems = CreateWatchItems(WatchElementList, Lookup.WatchVariableTableByOldIdentifier.Items.Length); }
/// <summary> /// Add the watch variables defined in the specified list of old identifiers to the specified <c>ListBox</c> control. /// </summary> /// <param name="listBox">The <c>ListBox</c> to which the items are to be added.</param> /// <param name="worksetColumn">The column of the workset that is to be added to the <c>ListBox</c> control.</param> protected virtual void WatchItemAddRange(ListBox listBox, Column_t worksetColumn) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; List<short> oldIdentifierList = worksetColumn.OldIdentifierList; listBox.Items.Clear(); listBox.SuspendLayout(); WatchItem_t watchItem; short oldIdentifier; for (int index = 0; index < oldIdentifierList.Count; index++) { watchItem = new WatchItem_t(); oldIdentifier = oldIdentifierList[index]; watchItem.OldIdentifier = oldIdentifier; watchItem.Added = true; // The DisplayMask field is only applicable to bitmask watch variables and is used to define which bits of the bitmask watch variable // are to be plotted. watchItem.DisplayMask = uint.MaxValue; listBox.Items.Add(watchItem); } listBox.PerformLayout(); Cursor = Cursors.Default; }