示例#1
0
        public override async Task <List <string> > GetEcuInfo()
        {
            DiagnosticData dv = this.GetDiagnosticSets().Find((diag) => diag.DataID == (int)ObjectsIndex_e.didEcuInfo);

            if (dv == null)
            {
                return(new List <string>());
            }

            _diagSrv.AddRequestedDID((uint)dv.DataID);

            if (await _diagSrv.RequestService(EcuAddress))
            {
                var lst = _diagSrv.GetResponseValue(dv.DataID);
                foreach (int val in lst)
                {
                    dv.AddValue(val);
                }

                return(dv.GetValue());
            }
            else
            {
                return(new List <string>());
            }
        }
示例#2
0
        private void ECUMeasure_Loaded(object sender, RoutedEventArgs e)
        {
            ecu     = Global.EcuList.CurrentEcu;
            dvsList = ecu.GetDiagnosticSets();


            DiagSrv = new Diag.A_Service_ReadDataByIdentifier();
            FormatGrid_Vars();
            FillValueList();

            cancelTaskShow = new CancellationTokenSource();
            CancellationToken token = cancelTaskShow.Token;

            Task.Factory.StartNew(async() =>
            {
                while (!token.IsCancellationRequested)
                {
                    if (DiagSrv.RequestedDIDs.Count > 0)
                    {
                        foreach (int i in DiagSrv.RequestedDIDs)
                        {
                            rxCnt++;
                            Thread.Sleep(10);
                            // Отправить запрос
                            if (await DiagSrv.RequestService(ecu.Address))
                            {
                                // Визуализация значений
                                await Dispatcher.BeginInvoke(new Action(() =>
                                {
                                    UpdateCommunicationStatus();
                                    ShowResponse(DiagSrv);
                                }));
                            }
                        }
                    }
                    else
                    {
                        Dispatcher.Invoke(ClearGrid_Vars);
                    }

                    Thread.Sleep(250);
                }
            }, token);
        }