Beispiel #1
0
        public async Task ChangeSnapshotData(IEnumerable <VibrationChannelToken> tokens)
        {
            if (SelecetedSeriesToken == null)
            {
                SelecetedSeriesToken = contractsCollection.FirstOrDefault();
            }
            if (SelecetedSeriesToken != null)
            {
                if (SelecetedSeriesToken.CurrentIndex != -1)
                {
                    string ipAddress = ServerAddress.CTLAddress.Split('/')[2].Split(':')[0];
                    VInfoTableAMSContract vInfoAMS = SelecetedSeriesToken.DataContracts[SelecetedSeriesToken.CurrentIndex];
                    LinqWhereHelper       helper   = new LinqWhereHelper();
                    helper.AddCondition("ChannelGlobalIndex", "=", SelecetedSeriesToken.Channel.ChannelGlobalIndex);
                    helper.AddCondition("STIME", "=", vInfoAMS.Date);
                    var database  = await DatabaseComponent.Instance;
                    var contracts = await Task.Run(() => database.QuerySnapshot(ipAddress, helper, vInfoAMS.Date));

                    var contact = contracts.SingleOrDefault();
                    RaiseSnapshotDataChanged(contact);
                }
            }
        }
        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();
            }
        }