Example #1
0
        public async Task ChangeOrthoData(IEnumerable <VibrationChannelToken> tokens)
        {
            double[] xArray = new double[0];
            double[] yArray = new double[0];
            try
            {
                if (SelecetedXChannel == null)
                {
                    SelecetedXChannel = xChannelCollection.FirstOrDefault();
                }

                if (SelecetedXChannel != null && SelecetedYChannel != null)
                {
                    if (SelecetedXChannel.VData != null && SelecetedXChannel.VData.Waveform != null)
                    {
                        xArray = SelecetedXChannel.VData.Waveform;
                        int             globalIndex = SelecetedYChannel.ChannelGlobalIndex;
                        Guid            saveLab     = SelecetedXChannel.VData.SaveLab;
                        LinqWhereHelper helper      = new LinqWhereHelper();
                        helper.AddCondition("SaveLab", "=", saveLab);
                        string ipAddress = ServerAddress.CTLAddress.Split('/')[2].Split(':')[0];
                        var    database  = await DatabaseComponent.Instance;
                        var    contracts = await Task.Run(() => database.QueryVInfoTable(ipAddress, globalIndex, helper, SelecetedXChannel.VData.STIME, SelecetedXChannel.VData.STIME));

                        if (contracts.Length == 1)
                        {
                            var yVInfo = contracts.Single();
                            int length = yVInfo.VData.Length / 4;
                            if (xArray.Length != length)
                            {
                                throw new Exception(string.Format("X向与Y向数组长度不等,X:{0},Y:{1}", xArray.Length, length));
                            }
                            else
                            {
                                yArray = new double[length];
                                for (int i = 0; i < length; i++)
                                {
                                    yArray[i] = BitConverter.ToSingle(yVInfo.VData, i * 4);
                                }
                            }
                        }
                        else if (contracts.Length > 0)
                        {
                            throw new Exception(string.Format("存在多个Y轴数据,count:{0}", contracts.Length));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-轴心轨迹", ex));
            }
            finally
            {
                RaiseOrthoDataChanged(xArray, yArray);
            }
        }
        private async Task OnShowGraph()
        {
            try
            {
                //htzk123,获取数据
                string          ipAddress = ServerAddress.CTLAddress.Split('/')[2].Split(':')[0];
                LinqWhereHelper helper    = new LinqWhereHelper();
                //var dateTime = SelecetedSeriesToken.DataContracts[SelecetedSeriesToken.CurrentIndex].Date;
                //helper.AddCondition("ChannelGlobalIndex", "=", SelecetedSeriesToken.Channel.ChannelGlobalIndex);
                //helper.AddCondition("STIME", "=", dateTime);
                //var response = await Task.Run(() => SocketCaller.ExecuteMethod(ipAddress, 39997, "Snapshot_Query", 1, true, null, helper.ToString(), dateTime, helper.Values));
                //if (!response[0].StartsWith("#"))
                //{
                //    var contracts = JsonConvert.DeserializeObject<List<SnapshotContract2>>(response[0]);
                //    if (contracts != null)
                //    {
                //        CurrentSnapshotContract = contracts[0];
                //    }
                //    else
                //    {
                //        throw new Exception("SnapshotContract2 反序列化失败 NULL");
                //    }
                //}
                //else
                //{
                //    throw new Exception(response[0]);
                //}

                if (CurrentSnapshotContract != null)
                {
                    RaiseShowTimeOrFrequency();
                }
            }
            catch (Exception ex)
            {
                EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-报警点趋势", ex));
            }
        }
Example #3
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);
                }
            }
        }