/// <summary>
        /// Configure the <c>AutoScaleWatchValues</c> property from the information contained within the <c>WatchFrameList</c> and <c>Workset</c> properties.
        /// </summary>
        /// <reamarks>
        /// This method is used when the <c>AutoScalesWatchValues</c> property is empty/null. The <c>WatchFrameList</c> and <c>Workset</c> properties must
        /// be defined before using this method.
        /// </reamarks>
        public void ConfigureAutoScale()
        {
            Debug.Assert(WatchFrameList != null, "DataStream_t.ConfigureAutoScale - [WatchFrameList != null]");
            Debug.Assert(Workset.WatchElementList != null, "DataStream_t.ConfigureAutoScale - [(Workset.WatchElementList != null]");

            AutoScaleWatchValues = new AutoScale_t[Workset.WatchElementList.Count];

            for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
            {
                AutoScaleWatchValues[watchElementIndex] = new AutoScale_t();
            }

            double valueCurrent;

            for (int frameIndex = 0; frameIndex < WatchFrameList.Count; frameIndex++)
            {
                if (frameIndex == 0)
                {
                    // Initialize both the maximum and minimum values to the current value.
                    for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
                    {
                        valueCurrent = WatchFrameList[frameIndex].WatchElements[watchElementIndex].Value;
                        AutoScaleWatchValues[watchElementIndex].MaximumRaw = valueCurrent;
                        AutoScaleWatchValues[watchElementIndex].MinimumRaw = valueCurrent;
                    }
                    continue;
                }

                for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
                {
                    valueCurrent = WatchFrameList[frameIndex].WatchElements[watchElementIndex].Value;
                    if (valueCurrent > AutoScaleWatchValues[watchElementIndex].MaximumRaw)
                    {
                        AutoScaleWatchValues[watchElementIndex].MaximumRaw = valueCurrent;
                    }
                    else if (valueCurrent < AutoScaleWatchValues[watchElementIndex].MinimumRaw)
                    {
                        AutoScaleWatchValues[watchElementIndex].MinimumRaw = valueCurrent;
                    }
                }
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            // Add the configured control to the TableLayoutPanel.
                            if (plotterBitmask != null)
                            {
                                tableLayoutPanel.Controls.Add(plotterBitmask);
                            }
                        }
                        break;
                    default:
                        throw new InvalidEnumArgumentException("LookupTable.Watch.Items[watchIdentifier].VariableType",
                                                               (int)watchVariable.VariableType, typeof(VariableType));
                }
            }
        }
示例#3
0
        /// <summary>
        /// Configure the <c>AutoScaleWatchValues</c> property from the information contained within the <c>WatchFrameList</c> and <c>Workset</c> properties.
        /// </summary>
        /// <reamarks>
        /// This method is used when the <c>AutoScalesWatchValues</c> property is empty/null. The <c>WatchFrameList</c> and <c>Workset</c> properties must 
        /// be defined before using this method.
        /// </reamarks>
        public void ConfigureAutoScale()
        {
            Debug.Assert(WatchFrameList != null, "DataStream_t.ConfigureAutoScale - [WatchFrameList != null]");
            Debug.Assert(Workset.WatchElementList != null, "DataStream_t.ConfigureAutoScale - [(Workset.WatchElementList != null]");

            AutoScaleWatchValues = new AutoScale_t[Workset.WatchElementList.Count];

            for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
            {
                AutoScaleWatchValues[watchElementIndex] = new AutoScale_t();
            }

            double valueCurrent;
            for (int frameIndex = 0; frameIndex < WatchFrameList.Count; frameIndex++)
            {
                if (frameIndex == 0)
                {
                    // Initialize both the maximum and minimum values to the current value.
                    for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
                    {
                        valueCurrent = WatchFrameList[frameIndex].WatchElements[watchElementIndex].Value;
                        AutoScaleWatchValues[watchElementIndex].MaximumRaw = valueCurrent;
                        AutoScaleWatchValues[watchElementIndex].MinimumRaw = valueCurrent;
                    }
                    continue;
                }

                for (int watchElementIndex = 0; watchElementIndex < Workset.WatchElementList.Count; watchElementIndex++)
                {
                    valueCurrent = WatchFrameList[frameIndex].WatchElements[watchElementIndex].Value;
                    if (valueCurrent > AutoScaleWatchValues[watchElementIndex].MaximumRaw)
                    {
                        AutoScaleWatchValues[watchElementIndex].MaximumRaw = valueCurrent;
                    }
                    else if (valueCurrent < AutoScaleWatchValues[watchElementIndex].MinimumRaw)
                    {
                        AutoScaleWatchValues[watchElementIndex].MinimumRaw = valueCurrent;
                    }
                }
            }

            EvaluateAutoScaleLimits();
        }