Ejemplo n.º 1
0
        private void UpdateCursorResult(double xValue)
        {
            try
            {
                m_chart.BeginUpdate();
                List <BaseWaveChannelToken> channelList = new List <BaseWaveChannelToken>();
                AnnotationXY cursorValueDisplay         = m_chart.ViewXY.Annotations[0];
                float        fTargetYCoord = m_chart.ViewXY.GetMarginsRect().Bottom;
                double       dY;
                m_chart.ViewXY.YAxes[0].CoordToValue(fTargetYCoord, out dY);
                cursorValueDisplay.TargetAxisValues.X = xValue;
                cursorValueDisplay.TargetAxisValues.Y = dY;

                StringBuilder sb            = new StringBuilder();
                int           iSeriesNumber = 1;

                string strChannelStringFormat = "{0}: {1}({2})";
                string strValue      = "";
                bool   bLabelVisible = false;

                foreach (PointLineSeries series in m_chart.ViewXY.PointLineSeries)
                {
                    strValue = "";
                    int index = GetNearestIndex(series, xValue);
                    bLabelVisible = true;
                    if (series.Tag is BaseDivfreChannelToken)
                    {
                        BaseDivfreChannelToken token = series.Tag as BaseDivfreChannelToken;
                        token.CurrentIndex = index;
                        channelList.Add(token);
                        if (index != -1)
                        {
                            var    contract = token.DataContracts[index]; //. series.Points[index].Tag as VInfoTableAMSContract;
                            string unit     = contract.Unit;
                            strValue = string.Format("{0}: {1}({2})|{3}", token.DisplayName, Math.Round(contract.Result ?? 0.0, 3), unit, Math.Round(contract.RPM ?? 0.0, 3));
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.DisplayName, "---", "Unit");
                        }
                    }
                    else if (series.Tag is BaseWaveChannelToken)
                    {
                        BaseWaveChannelToken token = series.Tag as BaseWaveChannelToken;
                        token.CurrentIndex = index;
                        channelList.Add(token);
                        if (index != -1)
                        {
                            var    contract = token.DataContracts[index]; //. series.Points[index].Tag as VInfoTableAMSContract;
                            string unit     = contract.Unit;
                            strValue = string.Format("{0}: {1}({2})", token.DisplayName, Math.Round(contract.Result ?? 0.0, 3), unit);
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.DisplayName, "---", "Unit");
                        }
                    }
                    else if (series.Tag is BaseAlarmChannelToken)
                    {
                        BaseAlarmChannelToken token = series.Tag as BaseAlarmChannelToken;
                        if (index != -1)
                        {
                            var    contract = token.DataContracts[index]; //series.Points[index].Tag as AnInfoTableAMSContract;
                            string unit     = contract.Unit;
                            strValue = string.Format(strChannelStringFormat, token.DisplayName, Math.Round(contract.Result ?? 0.0, 3), unit);
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.DisplayName, "---", "Unit");
                        }
                    }
                    else if (series.Tag is DivFreChannelToken)
                    {
                        DivFreChannelToken token = series.Tag as DivFreChannelToken;
                        if (index != -1)
                        {
                            var    contract = token.DataContracts[index];
                            string unit     = (from p in token.SlotDataContracts where p.RecordLab == contract.RecordLab select p.Unit).FirstOrDefault();

                            strValue = string.Format(strChannelStringFormat, token.DataContracts[index].DescriptionFre, Math.Round(contract.Result ?? 0.0, 3), unit);
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.DataContracts[index].DescriptionFre, "---", "Unit");
                        }
                    }

                    sb.AppendLine(strValue);
                    // series.Title.Text = strValue;
                    iSeriesNumber++;
                }
                sb.AppendLine("Time: " + m_chart.ViewXY.XAxes[0].TimeString(xValue, "yyyy-MM-dd HH:mm:ss"));
                ////Set text
                cursorValueDisplay.Text    = sb.ToString().Trim();
                cursorValueDisplay.Visible = bLabelVisible;
                //Allow chart rendering
                m_chart.EndUpdate();

                if (channelList.Count > 0)
                {
                    viewModel.RaiseTrackChanged(channelList);
                }
            }
            catch (Exception ex)
            {
                EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-趋势趋势-Track", ex));
                m_chart.EndUpdate();
            }
        }
Ejemplo n.º 2
0
        private void UpdateCursorResult(double xValue)
        {
            try
            {
                m_chart.BeginUpdate();
                List <VibrationChannelToken> channelList = new List <VibrationChannelToken>();
                AnnotationXY cursorValueDisplay          = m_chart.ViewXY.Annotations[0];
                float        fTargetYCoord = m_chart.ViewXY.GetMarginsRect().Bottom;
                double       dY;
                m_chart.ViewXY.YAxes[0].CoordToValue(fTargetYCoord, out dY);
                cursorValueDisplay.TargetAxisValues.X = xValue;
                cursorValueDisplay.TargetAxisValues.Y = dY;

                StringBuilder sb            = new StringBuilder();
                int           iSeriesNumber = 1;

                string strChannelStringFormat = "{0}: {1}({2})";
                string strValue      = "";
                bool   bLabelVisible = false;

                foreach (PointLineSeries series in m_chart.ViewXY.PointLineSeries)
                {
                    strValue = "";
                    int index = GetNearestIndex(series, xValue);
                    bLabelVisible = true;
                    if (series.Tag is VibrationChannelToken)
                    {
                        VibrationChannelToken token = series.Tag as VibrationChannelToken;
                        token.CurrentIndex = index;
                        channelList.Add(token);
                        if (index != -1)
                        {
                            VInfoTableAMSContract contract = token.DataContracts[index];  //. series.Points[index].Tag as VInfoTableAMSContract;
                            string unit = string.Empty;
                            switch (contract.Unit)
                            {
                            case 0:
                                unit = "m/s2";
                                break;

                            case 1:
                                unit = "mm/s";
                                break;

                            case 2:
                                unit = "mm";
                                break;
                            }
                            strValue = string.Format("{0}: {1}({2})|{3}", token.Channel.Name + token.Channel.MSSN, Math.Round(contract.Value, 3), unit, Math.Round(contract.RPM ?? 0.0, 3));
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.Channel.Name + token.Channel.MSSN, "---", "Unit");
                        }
                    }
                    else if (series.Tag is AnalogChannelToken)
                    {
                        AnalogChannelToken token = series.Tag as AnalogChannelToken;
                        if (index != -1)
                        {
                            AnInfoTableAMSContract contract = token.DataContracts[index]; //series.Points[index].Tag as AnInfoTableAMSContract;
                            string unit = string.Empty;
                            switch (contract.Unit)
                            {
                            case 3:
                                unit = "℃";
                                break;

                            case 4:
                                unit = "Pa";
                                break;

                            case 5:
                                unit = "RPM";
                                break;
                            }
                            strValue = string.Format(strChannelStringFormat, token.Channel.Name + token.Channel.MSSN, Math.Round(contract.Value, 3), unit);
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.Channel.Name + token.Channel.MSSN, "---", "Unit");
                        }
                    }
                    else if (series.Tag is DivFreChannelToken)
                    {
                        DivFreChannelToken token = series.Tag as DivFreChannelToken;
                        if (index != -1)
                        {
                            DivFreTableFreContract contract = token.DataContracts[index];
                            string unit = string.Empty;
                            switch (contract.Unit)
                            {
                            case 0:
                                unit = "分频-m/s2";
                                break;

                            case 1:
                                unit = "分频-mm/s";
                                break;

                            case 2:
                                unit = "分频-mm";
                                break;
                            }
                            strValue = string.Format(strChannelStringFormat, token.Channel.FreDescription, Math.Round(contract.FreMV, 3), unit);
                        }
                        else
                        {
                            strValue = string.Format(strChannelStringFormat, token.Channel.FreDescription, "---", "Unit");
                        }
                    }

                    sb.AppendLine(strValue);
                    // series.Title.Text = strValue;
                    iSeriesNumber++;
                }
                sb.AppendLine("Time: " + m_chart.ViewXY.XAxes[0].TimeString(xValue, "yyyy/MM/dd HH:mm:ss"));
                //Set text
                cursorValueDisplay.Text    = sb.ToString().Trim();
                cursorValueDisplay.Visible = bLabelVisible;
                //Allow chart rendering
                m_chart.EndUpdate();

                if (channelList.Count > 0)
                {
                    viewModel.RaiseTrackChanged(channelList);
                }
            }
            catch (Exception ex)
            {
                EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-通频趋势-Track", ex));
                m_chart.EndUpdate();
            }
        }