/// <summary>
        /// Get the parameters associated with the default stream.
        /// </summary>
        /// <param name="watchVariableCount">The number of watch variables included in 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 recording interval (60ms) at which the data is sampled.</param>
        /// <param name="watchIdentifiers">The watch identifiers of the watch variables contained within the data stream.</param>
        /// <param name="dataTypes">The data types corresponding to each of the watch variables contained within the data stream.</param>
        /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.GetDefaultStreamInformation() method is not CommunicationError.Success.</exception>
        public void GetDefaultStreamInformation(out short watchVariableCount, out short sampleCount, out short sampleMultiple, out short[] watchIdentifiers, out short[] dataTypes)
        {
            sampleCount = (short)m_SampleCountFaultLog;
            sampleMultiple = SampleMultiple;

            // If it has been configured, get the first valid workset other than the baseline workset; otherwise, use the baseline workset.
            watchVariableCount = (short)m_Workset.Column[0].OldIdentifierList.Count;

            // Adjust the length of the output array to the correct size.
            watchIdentifiers = new short[watchVariableCount];
            dataTypes = new short[watchVariableCount];

            // Populate the watchIdentifiers array with the watch identifiers associated with the baseline workset.
            WatchVariable watchVariable = new WatchVariable();
            for (int watchElementIndex = 0; watchElementIndex < m_Workset.Column[0].OldIdentifierList.Count; watchElementIndex++)
            {
                try
                {
                    watchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_Workset.Column[0].OldIdentifierList[watchElementIndex]];
                    if (watchVariable == null)
                    {
                        // Set to the 'not defined' values.
                        watchVariable.Identifier = CommonConstants.WatchIdentifierNotDefined;
                        watchVariable.DataType = DataType_e.u32;
                    }
                    watchIdentifiers[watchElementIndex] = watchVariable.Identifier;
                    dataTypes[watchElementIndex] = (short)watchVariable.DataType;
                }
                catch (Exception)
                {
                    // Set to the 'not defined' values.
                    watchVariable.Identifier = CommonConstants.WatchIdentifierNotDefined;
                    watchVariable.DataType = DataType_e.u32;
                }

                watchIdentifiers[watchElementIndex] = watchVariable.Identifier;
                dataTypes[watchElementIndex] = (short)watchVariable.DataType;
            }
#if NODELAY
#else
            // Include a delay to provide verisimilitude.
            System.Threading.Thread.Sleep(SleepMsVerisimilitudeStreamInformation);
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clean up the resources used by the form.
        /// </summary>
        /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data members to null.
                m_WatchVariable = null;
                m_IChartScale = null;
                m_CalledFromAsFormConfigureChartRecorder = null;

                #region --- Windows Form Designer Variables ---
                // Detach the event handler delegates.

                // Set the Windows Form Designer Variables to null.

                #endregion --- Windows Form Designer Variables ---
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception isn't thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the form. (1) Positions the form; (2) displays the watch variable and current value; (3) displays the flag state 
        /// corresponding to the current value of the watch variable.
        /// </summary>
        /// <param name="bitmaskControl">Reference to the bit mask control that called this form.</param>
        public FormShowFlags(VariableControl bitmaskControl)
        {
            InitializeComponent();

            m_VariableControl = bitmaskControl;

            // Add this form to the list of opened dialog forms associated with the client form.
            m_ClientAsFormPTU = m_VariableControl.ClientForm as FormPTU;
            if (m_ClientAsFormPTU != null)
            {
                m_ClientAsFormPTU.OpenedDialogBoxList.Add(this);
            }

            // Register the event handler for the data update event.
            m_ClientAsIDataUpdate = m_VariableControl.ClientForm as IDataUpdate;
            if (m_ClientAsIDataUpdate != null)
            {
                m_ClientAsIDataUpdate.DataUpdate += new EventHandler(DataUpdate);
            }

            m_OldIdentifier = (short)m_VariableControl.Identifier;
            try
            {
                m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_OldIdentifier];
                if (m_WatchVariable == null)
                {
                    throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
                }
            }
            catch (Exception)
            {
                throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
            }

            m_WatchVariableName = m_VariableControl.VariableNameFieldText;
            
            // Get a list of the current state of each flag and keep a record to determine if there is a change in state.
            List<FlagState_t> flagStateList = Lookup.WatchVariableTableByOldIdentifier.GetFlagStateList(m_OldIdentifier, m_PreviousValue = GetValue());

            m_TableLayoutPanel = ConstructLayoutPanel();
            m_PanelFlagList.Controls.Add(m_TableLayoutPanel);
            ConfigureTableLayoutPanel(m_TableLayoutPanel, flagStateList);

            UpdateTitle(m_WatchVariableName, GetValue());
            UpdateFlagStates(m_TableLayoutPanel.Controls, flagStateList);
            CheckHeight();
            PositionTheForm(m_VariableControl);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Clean up the resources used by the form.
        /// </summary>
        /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }

                    if (m_IDataUpdate != null)
                    {
                        // De-register the event handler for the data update event.
                        m_IDataUpdate.DataUpdate -= new EventHandler(DataUpdate);
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data members to null.
                m_WatchVariable = null;
                m_ICheckBoxUInt32 = null;

                #region --- Windows Form Designer Variables ---
                // Detach the event handler delegates.

                // Set the Windows Form Designer Variables to null.

                #endregion --- Windows Form Designer Variables ---
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception isn't thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>.
        /// <param name="listBox">The ListBox control containing the chart recorder channel scaling information.</param>
        public FormChangeChartScale(ListBox listBox)
        {
            InitializeComponent();
            Debug.Assert(listBox != null, "FormChangeChartScale.Ctor() - ");

            int oldIdentifier = ((WatchItem_t)listBox.SelectedItem).OldIdentifier;
            m_SelectedIndex = listBox.SelectedIndex;

            try
            {
                m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[oldIdentifier];
                if (m_WatchVariable == null)
                {
                    throw new ArgumentException();
                }

                Text = m_WatchVariable.Name;
            }
            catch (Exception)
            {
                throw new ArgumentException(Resources.MBTWatchVariableNotFound);
            }

            // Display the engineering units of the watch variable associated with the current channel.
            m_LabelUnitsMin.Text = m_WatchVariable.Units;
            m_LabelUnitsMax.Text = m_WatchVariable.Units;

            // Set the display format.
            if (m_WatchVariable.FormatString.ToLower().Equals(CommonConstants.DDFormatStringHex))
            {
                m_HexFormat = true;
            }

            // Display the default upper and lower chart scale limits of the watch variable associated with the current channel.
            if (m_HexFormat == true)
            {
                m_LabelDefaultChartScaleMin.Text = CommonConstants.HexValueIdentifier + ((uint)m_WatchVariable.MinChartScale).ToString(CommonConstants.FormatStringHex);
                m_LabelDefaultChartScaleMax.Text = CommonConstants.HexValueIdentifier + ((uint)m_WatchVariable.MaxChartScale).ToString(CommonConstants.FormatStringHex);
            }
            else
            {
                m_LabelDefaultChartScaleMin.Text = m_WatchVariable.MinChartScale.ToString(CommonConstants.FormatStringNumeric);
                m_LabelDefaultChartScaleMax.Text = m_WatchVariable.MaxChartScale.ToString(CommonConstants.FormatStringNumeric);
            }

            m_LabelDefaultUnits.Text = m_WatchVariable.Units;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize a new instance of the class.
        /// </summary>
        /// <param name="bitmaskControl">The <c>WatchControl</c> derived user control that called this form.</param>
        public FormChangeBitmask(WatchBitmaskControl bitmaskControl)
        {
            InitializeComponent();

            m_WatchControl = bitmaskControl;

            // Use the communication interface associated with the client form.
            m_ICommunicationInterface = m_WatchControl.ClientForm as ICommunicationInterface<ICommunicationWatch>;
            Debug.Assert(m_ICommunicationInterface != null);

            // Register the event handler for the data update event.
            m_IDataUpdate = m_WatchControl.ClientForm as IDataUpdate;
            if (m_IDataUpdate != null)
            {
                m_IDataUpdate.DataUpdate += new EventHandler(DataUpdate);
            }

            m_IPollTarget = m_WatchControl.ClientForm as IPollTarget;
            Debug.Assert(m_IPollTarget != null);

            m_OldIdentifier = (short)m_WatchControl.Identifier;
            try
            {
                m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_OldIdentifier];
                if (m_WatchVariable == null)
                {
                    throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
                }
            }
            catch(Exception)
            {
                throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
            }

            Debug.Assert(m_WatchVariable.VariableType == VariableType.Bitmask, "FormChangeBitmask.Ctor() - [m_WatchVariable.VariableType == VariableType.Bitmask]");

            Text = m_WatchVariable.Name;

            #region - [Units] -
            string units = m_WatchVariable.Units;
            m_LabelCurrentValueUnits.Text = units;
            m_LabelNewValueUnits.Text = units;
            #endregion - [Units] -

            #region - [NumericUpDown] -
            m_NumericUpDownNewValue.Hexadecimal = m_RadioButtonHex.Checked;
            m_NumericUpDownNewValue.DecimalPlaces = 0;
            m_NumericUpDownNewValue.Increment = 1;

            m_NumericUpDownNewValue.Maximum = (decimal)m_WatchVariable.MaxModifyValue;
            m_NumericUpDownNewValue.Minimum = (decimal)m_WatchVariable.MinModifyValue;
            
            // Initialize the NumericUpDown control Value property.
            try
            {
                m_NumericUpDownNewValue.Value = (decimal)m_WatchControl.Value;
            }
            catch (Exception)
            {
                // The specified initial value is outside of the limits, set to the minimum value.
                m_NumericUpDownNewValue.Value = m_NumericUpDownNewValue.Minimum;
            }
            #endregion - [NumericUpDown] -

            #region - [ICheckBoxUInt32] -
            m_ICheckBoxUInt32 = new CheckBoxUInt32();
            CheckBox[] checkBoxes;
            ConfigureCheckBoxes(out checkBoxes);
            m_ICheckBoxUInt32.CheckBoxes = checkBoxes;
            m_ICheckBoxUInt32.SetText(m_OldIdentifier);
            m_ICheckBoxUInt32.SetChecked((uint)m_WatchControl.Value);
            #endregion - [ICheckBoxUInt32] -

            // Update the display by calling the DataUpdate event handler.
            DataUpdate(this, new EventArgs());

            // Now that the display has been initialized, disable the apply button. This will only be re-enabled when the user has specified a new watch value.
            m_ButtonApply.Enabled = false;
        }
        /// <summary>
        /// Build an array of the watch variable records contained within the <c>WATCHVARIABLES</c> table of the data dictionary. This array is used to access the
        /// parameters associated with the watch variables defined in the table. The array element is mapped to the old identifier field of the table.
        /// </summary>
        /// <param name="variableDataTable">Reference to the <c>WATCHVARIABLES</c> table of the data dictionary.</param>
        /// <returns>>An array of the records contained within the <c>WATCHVARIABLES</c> table of the data dictionary, if the specified table is valid; otherwise, null.</returns>
        protected override WatchVariable[] BuildDataTable(DataDictionary.WATCHVARIABLESDataTable variableDataTable)
        {
            // Local copy of the table.
            WatchVariable[] variables;

            if (variableDataTable == null)
            {
                return(null);
            }

            try
            {
                // Determine the maximum value of the identifier field in the WatchVariables table, it cannot be assumed that the table is sorted by WatchID value.
                int iDMax     = 0;
                int iDCurrent = 0;
                for (int record = 0; record < variableDataTable.Count; record++)
                {
                    iDCurrent = variableDataTable[record].OLDID;
                    if (iDCurrent > iDMax)
                    {
                        iDMax = iDCurrent;
                    }
                }

                m_IdentifierMax = iDMax;

                // Instantiate the lookup array.
                variables = new WatchVariable[iDMax + 1];

                // Populate the lookup table;
                int identifier;
                DataDictionary.WATCHVARIABLESRow row;
                for (int record = 0; record < variableDataTable.Count; record++)
                {
                    row        = variableDataTable[record];
                    identifier = row.OLDID;

                    // Instantiate a new structure to contain the variable data and copy the data across.
                    WatchVariable watchVariable = new WatchVariable() as WatchVariable;
                    watchVariable.Identifier        = row.WATCHID;
                    watchVariable.OldIdentifier     = row.OLDID;
                    watchVariable.Name              = row.VARIABLENAME;
                    watchVariable.FormatString      = row.FORMATSTRING;
                    watchVariable.EmbeddedName      = row.EMBEDDEDVARNAME;
                    watchVariable.DataType          = (DataType_e)row.TYPEID;
                    watchVariable.ScaleFactor       = row.SCALEFACTOR;
                    watchVariable.EnumBitIdentifier = row.ENUMBITID;
                    watchVariable.IsBitMask         = (row.BITMASK == 0) ? true : false;
                    watchVariable.Units             = row.UNITS;
                    watchVariable.MinChartScale     = row.MINCHARTSCALE;
                    watchVariable.MaxChartScale     = row.MAXCHARTSCALE;
                    watchVariable.AttributeFlags    = row.FLAGS;
                    watchVariable.HelpIndex         = row.HELPINDEX;
                    watchVariable.MinModifyValue    = row.MINMODIFYVALUE;
                    watchVariable.MaxModifyValue    = row.MAXMODIFYVALUE;

                    // Determine the variable type.
                    if (watchVariable.IsBitMask)
                    {
                        watchVariable.VariableType = VariableType.Bitmask;
                    }
                    else
                    {
                        if (watchVariable.EnumBitIdentifier == 0)
                        {
                            watchVariable.VariableType = VariableType.Scalar;
                        }
                        else
                        {
                            watchVariable.VariableType = VariableType.Enumerator;
                        }
                    }

                    // Add the structure to the correct element of the array.
                    variables[identifier] = watchVariable;
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(variables);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initialize a new instance of the class.
        /// </summary>
        /// <param name="watchControl">The watch control derived user control that called this form.</param>
        /// <exception cref="Exception">Thrown if the old Identifier associated with the control that called this form is not defined in the current data dictionary.</exception>
        public FormChangeWatch(WatchControl watchControl)
        {
            InitializeComponent();

            m_WatchControl = watchControl;

            // Use the communication interface associated with the client form.
            m_ICommunicationInterface = m_WatchControl.ClientForm as ICommunicationInterface<ICommunicationWatch>;
            Debug.Assert(m_ICommunicationInterface != null);

            // Register the event handler for the data update event.
            m_IDataUpdate = m_WatchControl.ClientForm as IDataUpdate;
            if (m_IDataUpdate != null)
            {
                m_IDataUpdate.DataUpdate += new EventHandler(DataUpdate);
            }

            m_IPollTarget = m_WatchControl.ClientForm as IPollTarget;
            Debug.Assert(m_IPollTarget != null);

            m_OldIdentifier = (short)m_WatchControl.Identifier;
            try
            {
                m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_OldIdentifier];
                if (m_WatchVariable == null)
                {
                    throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
                }
            }
            catch (Exception)
            {
                throw new ArgumentException(Resources.MBTWatchVariableNotDefined);
            }

            m_WatchVariableName = m_WatchControl.VariableNameFieldText;
            Text = m_WatchVariableName;

            #region - [Units] -
            string units = m_WatchVariable.Units;
            m_LabelCurrentValueUnits.Text = units;
            m_LabelAllowableRangeUnits.Text = units;
            m_LabelNewValueUnits.Text = units;
            #endregion - [Units] -

            // Update the display by calling the DataUpdate event handler.
            DataUpdate(this, new EventArgs());
        }
        /// <summary>
        /// Clean up the resources used by the user control.
        /// </summary>
        /// <param name="disposing">True, to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data members to null.
                m_WatchVariable = null;
                m_ClientAsFormPTU = null;

                #region - [Detach the event handler methods.] -
                #endregion - [Detach the event handler methods.] -

                #region - [Component Designer Variables] -
                #endregion - [Component Designer Variables] -
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception isn't thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
        /// <summary>
        /// Build an array of the watch variable records contained within the <c>WATCHVARIABLES</c> table of the data dictionary. This array is used to access the 
        /// parameters associated with the watch variables defined in the table. The array element is mapped to the old identifier field of the table.
        /// </summary>
        /// <param name="variableDataTable">Reference to the <c>WATCHVARIABLES</c> table of the data dictionary.</param>
        /// <returns>>An array of the records contained within the <c>WATCHVARIABLES</c> table of the data dictionary, if the specified table is valid; otherwise, null.</returns>
        protected override WatchVariable[] BuildDataTable(DataDictionary.WATCHVARIABLESDataTable variableDataTable)
        {
            // Local copy of the table.
            WatchVariable[] variables;

            if (variableDataTable == null)
            {
                return null;
            }

            try
            {
                // Determine the maximum value of the identifier field in the WatchVariables table, it cannot be assumed that the table is sorted by WatchID value.
                int iDMax = 0;
                int iDCurrent = 0;
                for (int record = 0; record < variableDataTable.Count; record++)
                {
                    iDCurrent = variableDataTable[record].OLDID;
                    if (iDCurrent > iDMax)
                    {
                        iDMax = iDCurrent;
                    }
                }

                m_IdentifierMax = iDMax;

                // Instantiate the lookup array.
                variables = new WatchVariable[iDMax + 1];

                // Populate the lookup table;
                int identifier;
                DataDictionary.WATCHVARIABLESRow row;
                for (int record = 0; record < variableDataTable.Count; record++)
                {
                    row = variableDataTable[record];
                    identifier = row.OLDID;

                    // Instantiate a new structure to contain the variable data and copy the data across.
                    WatchVariable watchVariable = new WatchVariable() as WatchVariable;
                    watchVariable.Identifier = row.WATCHID;
                    watchVariable.OldIdentifier = row.OLDID;
                    watchVariable.Name = row.VARIABLENAME;
                    watchVariable.FormatString = row.FORMATSTRING;
                    watchVariable.EmbeddedName = row.EMBEDDEDVARNAME;
                    watchVariable.DataType = (DataType_e)row.TYPEID;
                    watchVariable.ScaleFactor = row.SCALEFACTOR;
                    watchVariable.EnumBitIdentifier = row.ENUMBITID;
                    watchVariable.IsBitMask = (row.BITMASK == 0) ? true : false;
                    watchVariable.Units = row.UNITS;
                    watchVariable.MinChartScale = row.MINCHARTSCALE;
                    watchVariable.MaxChartScale = row.MAXCHARTSCALE;
                    watchVariable.AttributeFlags = row.FLAGS;
                    watchVariable.HelpIndex = row.HELPINDEX;
                    watchVariable.MinModifyValue = row.MINMODIFYVALUE;
                    watchVariable.MaxModifyValue = row.MAXMODIFYVALUE;

                    // Determine the variable type.
                    if (watchVariable.IsBitMask)
                    {
                        watchVariable.VariableType = VariableType.Bitmask;
                    }
                    else
                    {
                        if (watchVariable.EnumBitIdentifier == 0)
                        {
                            watchVariable.VariableType = VariableType.Scalar;
                        }
                        else
                        {
                            watchVariable.VariableType = VariableType.Enumerator;
                        }
                    }

                    // Add the structure to the correct element of the array.
                    variables[identifier] = watchVariable;
                }
            }
            catch (Exception)
            {
                return null;
            }

            return variables;
        }