예제 #1
0
        /// <summary>
        /// Event handler for the Apply button <c>Click</c> event. Update the 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>
        protected override void m_ButtonApply_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            IWatchFile iWatchFile = CalledFrom as IWatchFile;

            Debug.Assert(iWatchFile != null, "FormPlotDefine.m_ButtonApply_Click() - [iWatchFile != null]");

            Cursor = Cursors.WaitCursor;

            // Yes - Update the WatchFile property with the new workset.
            WatchFile_t watchFile = iWatchFile.WatchFile;

            if (m_RestoreDefault == true)
            {
                watchFile.DataStream.Workset.PlotTabPages = null;
            }
            else
            {
                Workset_t workset = ConvertToWorkset(m_Workset.Name);
                watchFile.DataStream.Workset = workset;
            }
            iWatchFile.WatchFile = watchFile;
            iWatchFile.SaveWatchFile();

            m_ButtonApply.Enabled = false;

            // Let the calling form know that the watchfile has been modified.
            DialogResult = DialogResult.Yes;
            Cursor       = Cursors.Default;
        }
        /// <summary>
        /// Get the fault log/snapshot log data stream corresponding to the specified record.
        /// </summary>
        /// <param name="eventRecord">The event record associated with the data stream that is to be downloaded.</param>
        /// <returns>The data stream corresponding to the specified event record.</returns>
        /// <exception cref="CommunicationException">Thrown if the error code returned from the calls to the PTUDLL32.GetStreamInformation() or PTUDLL32Event.GetStream()
        /// methods is not CommunicationError.Success.</exception>
        public DataStream_t GetStream(EventRecord eventRecord)
        {
            short watchVariableCount, sampleCount, sampleMultiple;

            short[] watchIdentifiers, dataTypes;
            GetStreamInformation(0, out watchVariableCount, out sampleCount, out sampleMultiple, out watchIdentifiers, out dataTypes);

            int[] buffer = new int[sampleCount * watchVariableCount];   // Default values are all zeroes.

            // Not used by the calling class.
            // short timeOrigin = 0;

            Workset_t    workset    = ConvertToWorkset(eventRecord.Description, watchIdentifiers, sampleMultiple);
            DataStream_t dataStream = new DataStream_t(eventRecord, watchVariableCount, sampleCount, sampleMultiple, workset);

            DateTime startTime = eventRecord.DateTime.Subtract(new TimeSpan(0, 0, 0, 0, dataStream.DurationPreTripMs));

            // Convert the retrieved data stream into a list of individual, time-stamped watch variable data frames.
            List <WatchFrame_t> watchFrameList = ConvertToWatchFrameList(startTime, sampleCount, dataStream.FrameIntervalMs, buffer, dataTypes, workset);

            dataStream.WatchFrameList = watchFrameList;

            // Configure the upper and lower display limits.
            dataStream.ConfigureAutoScale();
#if NODELAY
#else
            // Include a delay to provide verisimilitude.
            System.Threading.Thread.Sleep(SleepMsVerisimilitudeGetStream);
#endif
            return(dataStream);
        }
        /// <summary>
        /// Load the specified workset.
        /// </summary>
        /// <param name="workset">The workset that is to be processed.</param>
        protected override 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_TextBoxHeader2.Text = workset.Column[1].HeaderText;
            m_TextBoxHeader3.Text = workset.Column[2].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]);
            WatchItemAddRange(m_ListBox2, workset.Column[1]);
            WatchItemAddRange(m_ListBox3, workset.Column[2]);
            UpdateCount();

            m_TextBoxSecurityLevel.Text = Security.GetSecurityDescription(workset.SecurityLevel);
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="watchFile">The file structure of the log that was saved to disk.</param>
        public HistoricDataManager(WatchFile_t watchFile)
        {
            // Create the list containing all the frames associated with the set.
            Debug.Assert(watchFile.DataStream.WatchFrameList.Count > 1, "HistoricDataManager.Ctor() - [watchFile.WatchFrameList.Count > 1]");
            m_FramesAll = new List <WatchFrame_t>();
            m_FramesAll = watchFile.DataStream.WatchFrameList;

            // Copy All the records in the above list to the list associated with the frames associated with the start and stop times.
            m_FramesToPlot = new List <WatchFrame_t>();
            m_FramesToPlot = m_FramesAll;

            m_StartTime = m_FramesAll[0].CurrentDateTime;
            m_StopTime  = m_FramesAll[m_FramesAll.Count - 1].CurrentDateTime;

            m_LogType = watchFile.DataStream.LogType;

            Debug.Assert(watchFile.DataStream.FrameIntervalMs > 0, "HistoricDataManager.Ctor() - [watchFile.DataStream.FrameIntervalMs > 0]");
            m_FrameIntervalMs = watchFile.DataStream.FrameIntervalMs;
            m_Workset         = watchFile.DataStream.Workset;

            m_WatchFile = watchFile;

            // Convert the DataStream.AutoScaleWatchValues property of the watch file to a list.
            m_AutoScaleWatchValueList = new List <AutoScale_t>();
            AutoScale_t autoScale;

            for (int watchElementIndex = 0; watchElementIndex < m_WatchFile.DataStream.AutoScaleWatchValues.Length; watchElementIndex++)
            {
                autoScale = m_WatchFile.DataStream.AutoScaleWatchValues[watchElementIndex];
                m_AutoScaleWatchValueList.Add(autoScale);
            }
        }
예제 #5
0
        /// <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 FormWorksetDefineFaultLog(WorksetCollection worksetCollection, Workset_t workset, bool applyVisible)
            : base(worksetCollection, workset, applyVisible)
        {
            InitializeComponent();

            // Check whether the 'Row Header' ListBox can be used to display the channel numbers. This is only possible if
            // the project doesn't support multiple data stream types and the number of parameters supported by the data
            // stream can be displayed on the TabPage without the need for scroll bars i.e. <= WatchSizeFaultLogMax.
            if ((Parameter.SupportsMultipleDataStreamTypes == false) && (Parameter.WatchSizeFaultLog <= WatchSizeFaultLogMax))
            {
                AddRowHeader();
            }
            else
            {
                NoRowHeader();
            }

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

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

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

            UpdateSampleMultiple(workset.SampleMultiple);
        }
예제 #6
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 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 = m_SampleMultiple;
            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>();
            for (int index = 0; index < m_ListBox1.Items.Count; index++)
            {
                workset.Column[0].OldIdentifierList.Add(((WatchItem_t)m_ListBox1.Items[index]).OldIdentifier);
            }

            // 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.WatchIdentifierNotDefined);
                    }
                    else
                    {
                        workset.WatchElementList.Add(watchVariable.Identifier);
                    }
                }
                catch (Exception)
                {
                    workset.WatchElementList.Add(CommonConstants.WatchIdentifierNotDefined);
                }
            }
            workset.WatchElementList.Sort();
            workset.Count = workset.WatchElementList.Count;

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

            return(workset);
        }
예제 #7
0
        /// <summary>
        /// Configure the watch user controls required to display the specified <paramref name="workset"/> and then add these to the specified
        /// <paramref name="displayPanel"/>.
        /// </summary>
        /// <param name="workset">The workset that is to be used to configure the watch user controls.</param>
        /// <param name="displayPanel">The <c>Panel</c> to which the configured watch user controls are to be added.</param>
        /// <param name="watchControlSize">The size to make each watch user control.</param>
        /// <remarks>This method uses the <c>UserControl</c> class to: (a) layout and initialize all of the controls required to display the watch variables
        /// associated with the specified worset and (b) add these to the tabpage/panel associated with the display.
        /// </remarks>
        protected void ConfigureDisplayPanel(Workset_t workset, Panel displayPanel, VariableControlSize_t watchControlSize)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Clear the panel to which the controls are to be added.
            displayPanel.Hide();
            displayPanel.Controls.Clear();

            // Instantiate the watch control jagged array.
            m_WatchControls = new WatchControl[workset.Column.Length][];
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                m_WatchControls[columnIndex] = new WatchControl[workset.Column[columnIndex].OldIdentifierList.Count];
            }

            // Create a separate panel for each display column.
            Panel[] panelColumn = new Panel[workset.Column.Length];
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                panelColumn[columnIndex]          = new Panel();
                panelColumn[columnIndex].AutoSize = true;
                panelColumn[columnIndex].Location = new Point(columnIndex * (watchControlSize.Size.Width + watchControlSize.Margin.Horizontal), 0);
                m_WatchControlLayout.WriteColumnHeaders(workset.Column[columnIndex].HeaderText, panelColumn[columnIndex], watchControlSize);
                m_WatchControlLayout.ConfigureWatchControls(m_WatchControls[columnIndex], panelColumn[columnIndex], watchControlSize,
                                                            workset.Column[columnIndex].OldIdentifierList);
                displayPanel.Controls.Add(panelColumn[columnIndex]);
            }
            displayPanel.Show();
        }
예제 #8
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();
            }
        }
예제 #9
0
        /// <summary>
        /// Inializes a new instance of the class. Used to create an item that shows a tick icon next to the workset name, depending upon
        /// the state of the showTick parameter. True, to display a tick icon; otherwise, false. The tick is used to show that the workset
        /// is the default workset.
        /// </summary>
        public WorksetItem(Workset_t workset, bool showTick)
        {
            m_Workset = workset;
            base.Text = m_Workset.Name;

            base.ImageIndex = showTick ? 1 : 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 and
        /// HeaderText 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 override bool CompareWorkset(Workset_t workset)
        {
            Workset_t worksetToCompare = m_WorksetToCompare;

            if (base.CompareWorkset(workset) == false)
            {
                return(false);
            }
            else
            {
                #region - [ChartScaleList] -
                for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
                {
                    for (int index = 0; index < workset.Column[columnIndex].ChartScaleList.Count; index++)
                    {
                        if ((workset.Column[columnIndex].ChartScaleList[index].ChartScaleLowerLimit != worksetToCompare.Column[columnIndex].ChartScaleList[index].ChartScaleLowerLimit) ||
                            (workset.Column[columnIndex].ChartScaleList[index].ChartScaleUpperLimit != worksetToCompare.Column[columnIndex].ChartScaleList[index].ChartScaleUpperLimit) ||
                            (workset.Column[columnIndex].ChartScaleList[index].Units != worksetToCompare.Column[columnIndex].ChartScaleList[index].Units))
                        {
                            return(false);
                        }
                    }
                }
                #endregion - [ChartScaleList] -
            }

            return(true);
        }
예제 #11
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();
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
0
        /// <summary>
        /// Event handler for the 'Copy' context menu option <c>Click</c> event. Copies an existing 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_ContextMenuItemCopy_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.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Create a temporary workset.
            Workset_t copyOfWorkset = new Workset_t();

            copyOfWorkset.Replicate(selectedItem.Workset);

            // Override the security level to be the security level of the current user.
            copyOfWorkset.SecurityLevel = Security.SecurityLevelCurrent;

            // Override the name of the workset.
            copyOfWorkset.Name = selectedItem.Workset.Name + CommonConstants.BindingMessage + Resources.TextCopy;
            m_WorksetCollection.Add(copyOfWorkset);
            Cursor = Cursors.Default;

            // Save the modified object to disk.
            Save();
            UpdateListView();
        }
예제 #15
0
        /// <summary>
        /// Inializes a new instance of the class. Used to create an item that shows a tick icon next to the workset name, depending upon
        /// the state of the showTick parameter. True, to display a tick icon; otherwise, false. The tick is used to show that the workset
        /// is the default workset. Also displays the description corresponding to the specified workset security level.
        /// </summary>
        public WorksetItem(Workset_t workset, SecurityLevel securityLevel)
        {
            m_Workset = workset;
            base.Text = m_Workset.Name;

            string securityLevelDescription = new Security().GetSecurityDescription(securityLevel);

            base.SubItems.Add(securityLevelDescription);
        }
예제 #16
0
        /// <summary>
        /// Inializes a new instance of the class. Used to create an item that shows a tick icon next to the workset name, depending upon
        /// the state of the showTick parameter. True, to display a tick icon; otherwise, false. The tick is used to show that the workset
        /// is the default workset. Also displays the description corresponding to the specified workset security level.
        /// </summary>
        public WorksetItem(Workset_t workset, bool showTick, SecurityLevel securityLevel)
        {
            m_Workset = workset;
            base.Text = m_Workset.Name;

            base.ImageIndex = showTick ? 1 : 0;

            string securityLevelDescription = new Security().GetSecurityDescription(securityLevel);

            base.SubItems.Add(securityLevelDescription);
        }
예제 #17
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 override Workset_t ConvertToWorkset(string worksetName)
        {
            Workset_t workset = base.ConvertToWorkset(worksetName);

            #region - [SampleMultiple] -
            workset.SampleMultiple = m_SampleMultiple;
            workset.CountMax       = Parameter.WatchSizeFaultLog;
            #endregion - [SampleMultiple] -

            return(workset);
        }
        /// <summary>
        /// Initializes an new instance of the form. Retrieve the chart recorder configuration from the VCU.
        /// </summary>
        /// <remarks>The reference to the main application window is also derived from the CalledFrom parameter, however, this is not obtained until after the form
        /// has been shown. As a number of multiple document interface child forms (mdi child) may be polling the VCU when this form is instantiated, the
        /// call to the PauseCommunication() method must be made before the chart configuration data can be retrieved from the VCU from within the constructor code.
        /// A requirement of the PauseCommunication() method is that the reference to the main application window must be defined.
        /// </remarks>
        /// <param name="communicationInterface">Reference to the communication interface that is to be used to communicate with the VCU.</param>
        /// <param name="mainWindow">Reference to the main application window, this is required for the call to the PauseCommunication() method in the constructor
        /// code.</param>
        /// <param name="worksetCollection">The workset collection associated with the chart recorder.</param>
        public FormConfigureChartRecorder(ICommunicationParent communicationInterface, IMainWindow mainWindow, WorksetCollection worksetCollection)
            : base(worksetCollection)
        {
            InitializeComponent();

            // Move the position of the Cancel buttons.
            m_ButtonCancel.Location = m_ButtonApply.Location;

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

            m_MainWindow = mainWindow;
            PauseCommunication <ICommunicationWatch>(CommunicationInterface, true);

            // Show the context menu that allows the user to configure the chart scaling, however, disable it until the form is in edit mode.
            m_MenuItemChangeChartScaleFactor.Visible = true;
            m_MenuItemChangeChartScaleFactor.Enabled = false;

            // Don't allow the user to edit the workset until the security level of the workset has been established.
            ModifyEnabled = false;

            m_CreateMode = false;

            // Set the structure containing the workset that was downloaded from the VCU to be an empty workset.
            m_WorksetFromVCU = new Workset_t();

            // Get the default chart recorder workset.
            Workset_t workset = worksetCollection.Worksets[worksetCollection.DefaultIndex];

            // Keep a record of the selected workset. This must be set up before the call to SetEnabledEditNewCopyRename().
            m_SelectedWorkset = workset;

            SetEnabledEditNewCopyRename(true);

            // Display the name of the default workset on the ComboBox control.
            // Ensure that the SelectionChanged event is not triggered as a result of specifying the Text property of the ComboBox control.
            m_ComboBoxWorkset.SelectedIndexChanged -= new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged);
            m_ComboBoxWorkset.Text = workset.Name;
            m_ComboBoxWorkset.SelectedIndexChanged += new EventHandler(m_ComboBoxWorkset_SelectedIndexChanged);

            LoadWorkset(workset);

            // Allow the user to download the workset.
            m_TSBDownload.Enabled = true;
        }
예제 #19
0
        /// <summary>
        /// Load the specified workset.
        /// </summary>
        /// <param name="workset">The workset that is to be processed.</param>
        protected override void LoadWorkset(Workset_t workset)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            base.LoadWorkset(workset);

            UpdateSampleMultiple(workset.SampleMultiple);
        }
예제 #20
0
        /// <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;
        }
        /// <summary>
        /// Initializes an new instance of the form. Retrieve the chart recorder configuration from the VCU.
        /// </summary>
        /// <remarks>The reference to the main application window is also derived from the CalledFrom parameter, however, this is not obtained until after the form
        /// has been shown. As a number of multiple document interface child forms (mdi child) may be polling the VCU when this form is instantiated, the
        /// call to the PauseCommunication() method must be made before the chart configuration data can be retrieved from the VCU from within the constructor code.
        /// A requirement of the PauseCommunication() method is that the reference to the main application window must be defined.
        /// </remarks>
        /// <param name="communicationInterface">Reference to the communication interface that is to be used to communicate with the VCU.</param>
        /// <param name="mainWindow">Reference to the main application window, this is required for the call to the PauseCommunication() method in the constructor
        /// code.</param>
        /// <param name="worksetCollection">The workset collection associated with the chart recorder.</param>
        public FormConfigureWatchWindow(ICommunicationParent communicationInterface, IMainWindow mainWindow, WorksetCollection worksetCollection)
            : base(worksetCollection)
        {
            InitializeComponent();

            Debug.Assert(mainWindow != null, "FormConfigureWatchWindow.Ctor() - [mainWindow != null]");
            m_MainWindow = mainWindow;

            // Move the position of the Cancel buttons.
            m_ButtonCancel.Location = m_ButtonApply.Location;

            NoRowHeader();

            // Check the mode of the PTU.
            if (communicationInterface == null)
            {
                CommunicationInterface = null;
            }
            else if (communicationInterface is CommunicationParent)
            {
                // The PTU is in online mode.
                CommunicationInterface = new CommunicationWatch(communicationInterface);
                PauseCommunication <ICommunicationWatch>(CommunicationInterface, true);
            }
            else
            {
                // The PTU is in simulation mode (originally referred to as offline mode).
                CommunicationInterface = new CommunicationWatchOffline(communicationInterface);
                PauseCommunication <ICommunicationWatch>(CommunicationInterface, true);
            }

            #region - [ToolTipText] -
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonUpload].ToolTipText           = Resources.FunctionKeyToolTipChartRecorderUpload;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonSave].ToolTipText             = Resources.FunctionKeyToolTipChartRecorderSave;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonEdit].ToolTipText             = Resources.FunctionKeyToolTipChartRecorderConfigure;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonNew].ToolTipText              = Resources.FunctionKeyToolTipChartRecorderCreate;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonCopy].ToolTipText             = Resources.FunctionKeyToolTipChartRecorderCopy;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonRename].ToolTipText           = Resources.FunctionKeyToolTipChartRecorderRename;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonDelete].ToolTipText           = Resources.FunctionKeyToolTipChartRecorderDelete;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonSetAsDefault].ToolTipText     = Resources.FunctionKeyToolTipChartRecorderSetAsDefault;
            m_ToolStrip.Items[CommonConstants.KeyToolStripButtonOverrideSecurity].ToolTipText = Resources.FunctionKeyToolTipChartRecorderOverrideSecurity;
            #endregion - [ToolTipText] -

            // Don't allow the user to edit the workset until the security level of the workset has been established.
            ModifyEnabled = false;

            m_CreateMode = false;

            // Set the structure containing the workset that was downloaded from the VCU to be an empty workset.
            m_WorksetFromVCU = new Workset_t();
        }
        /// <summary>
        /// Download the specified workset to the VCU.
        /// </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 override bool DownloadWorkset(Workset_t workset)
        {
            // A flag that indicates whether the chart recorder update was successful.
            bool updateSuccess;

            try
            {
                CommunicationInterface.DownloadChartRecorderWorkset(workset);
                updateSuccess = true;
            }
            catch (Exception)
            {
                updateSuccess = false;
            }

            return(updateSuccess);
        }
예제 #23
0
        /// <summary>
        /// Download the specified fault log workset to the VCU.
        /// </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 override bool DownloadWorkset(Workset_t workset)
        {
            // A flag that indicates whether the chart recorder update was successful.
            bool updateSuccess;

            try
            {
                CommunicationInterface.SetDefaultStreamInformation(workset.SampleMultiple, workset.Column[0].OldIdentifierList);
                updateSuccess = true;
            }
            catch (Exception)
            {
                updateSuccess = false;
            }

            return(updateSuccess);
        }
예제 #24
0
        /// <summary>
        /// Configure the watch user controls required to display the specified <paramref name="workset"/> and then add these to the specified
        /// <paramref name="displayPanel"/>.
        /// </summary>
        /// <param name="workset">The workset that is to be used to configure the watch user controls.</param>
        /// <param name="displayPanel">The <c>Panel</c> to which the configured watch user controls are to be added.</param>
        /// <param name="watchControlSize">The size to make each watch user control.</param>
        /// <remarks>This method uses the <c>UserControl</c> class to: (a) layout and initialize all of the controls required to display the watch variables
        /// associated with the specified worset and (b) add these to the tabpage/panel associated with the display.
        /// </remarks>
        protected void ConfigureDisplayPanel(Workset_t workset, Panel displayPanel, VariableControlSize_t watchControlSize)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Clear the panel to which the controls are to be added.
            displayPanel.Hide();
            displayPanel.Controls.Clear();

            // Instantiate the watch control jagged array.
            m_WatchControls = new WatchControl[workset.Column.Length][];
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                m_WatchControls[columnIndex] = new WatchControl[workset.Column[columnIndex].OldIdentifierList.Count];
            }

            // Create a separate panel for each display column.
            Panel[] panelColumn = new Panel[workset.Column.Length];
            for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
            {
                panelColumn[columnIndex]          = new Panel();
                panelColumn[columnIndex].AutoSize = true;
                panelColumn[columnIndex].Location = new Point(columnIndex * (watchControlSize.Size.Width + watchControlSize.Margin.Horizontal), 0);
                m_WatchControlLayout.WriteColumnHeaders(workset.Column[columnIndex].HeaderText, panelColumn[columnIndex], watchControlSize);
                m_WatchControlLayout.ConfigureWatchControls(m_WatchControls[columnIndex], panelColumn[columnIndex], watchControlSize,
                                                            workset.Column[columnIndex].OldIdentifierList);

                // Do not add the panel to the controls associated with the 'displayPanel' parameter if the last column of the workset does not contain any watch
                // variables AND no header text is defined. This ensures that the horizontal scroll bar is not displayed.
                if ((columnIndex == workset.Column.Length - 1) &&
                    (workset.Column[columnIndex].OldIdentifierList.Count == 0) &&
                    (workset.Column[columnIndex].HeaderText.Equals(string.Empty)))
                {
                    break;
                }
                else
                {
                    displayPanel.Controls.Add(panelColumn[columnIndex]);
                }
            }
            displayPanel.Show();
        }
예제 #25
0
        /// <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);
        }
예제 #26
0
        /// <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 FormWorksetDefineWatch(WorksetCollection worksetCollection, Workset_t workset, bool applyVisible)
            : base(worksetCollection, workset, applyVisible)
        {
            InitializeComponent();

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

            // ------------------------------------
            // Update the 'Column' ListBox controls.
            // -------------------------------------
            WatchItemAddRange(m_ListBox1, workset.Column[0]);
            WatchItemAddRange(m_ListBox2, workset.Column[1]);
            WatchItemAddRange(m_ListBox3, workset.Column[2]);

            UpdateCount();
        }
예제 #27
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;
        }
예제 #28
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;
        }
예제 #29
0
        /// <summary>
        /// Event handler for the <c>AfterLabelEdit</c> event. Updates the <c>workset</c> class with the new name of the workset and then saves the changes to disk.
        /// </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_ListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip, if a valid selection hasn't been made or the baseline workset has been selected.
            if ((e.Label != null) && (e.Item != 0) && (e.Label != string.Empty))
            {
                // get the selected workset.
                Workset_t workset = ((WorksetItem)m_ListView.Items[e.Item]).Workset;

                // Update the name field of the workset.
                workset.Name = e.Label.Trim();

                for (int index = 0; index < m_ListView.Items.Count; index++)
                {
                    if (((WorksetItem)m_ListView.Items[index]).Workset.Name == workset.Name)
                    {
                        MessageBox.Show(Resources.MBTWorksetNameExists, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.CancelEdit = true;
                        return;
                    }
                }

                // Update the workset class.
                m_WorksetCollection.Worksets[e.Item] = workset;

                // Save the modified object to disk.
                Save();

                // Update the ListView.
                UpdateListView();
            }
            else
            {
                e.CancelEdit = true;
            }
        }
예제 #30
0
        /// <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 FormWorksetDefineChartRecorder(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_TabControlColumn.TabPages.Remove(m_TabPageColumn2);
            m_TabControlColumn.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(m_ListBox1, 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;
        }