Exemplo n.º 1
0
        private void ReadAllDTCs()
        {
            App.OperationInProgress      = true;
            App.PercentOperationComplete = -1.0f;

            App.DisplayStatusMessage("Reading all ECU DTCs.", StatusMessageType.USER);

            ECUDTCs.Clear();

            var KWP2000CommViewModel = App.CommInterfaceViewModel as KWP2000Interface_ViewModel;

            App.CurrentOperation = new ReadDiagnosticTroubleCodesOperation(App.CommInterface as KWP2000Interface, KWP2000CommViewModel.DesiredBaudRates);
            App.CurrentOperation.CompletedOperationEvent += this.ReadAllDTCsCompleted;

            App.CurrentOperation.Start();
        }
Exemplo n.º 2
0
        private void OnLoadDTCs()
        {
            App.DisplayStatusMessage("Starting loading of DTCs.", StatusMessageType.USER);

            var dialog = new OpenFileDialog();

            dialog.Filter           = DTCsFile.FILTER;
            dialog.CheckFileExists  = true;
            dialog.CheckPathExists  = true;
            dialog.Title            = "Select DTCs File to Load";
            dialog.InitialDirectory = Directory.GetCurrentDirectory();            //TODO: remember last used directory

            if (dialog.ShowDialog() == true)
            {
                ECUDTCs.Clear();

                try
                {
                    using (var fileSteam = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read))
                    {
                        var formatter = new XmlSerializer(typeof(DTCsFile));
                        var dtcFile   = (DTCsFile)formatter.Deserialize(fileSteam);

                        foreach (var dtc in dtcFile.DTCs)
                        {
                            ECUDTCs.Add(dtc);
                        }

                        App.DisplayStatusMessage("Successfully loaded DTCs from file.", StatusMessageType.USER);
                    }
                }
                catch (Exception e)
                {
                    App.DisplayStatusMessage("Failed to load DTCs from file: " + e.Message, StatusMessageType.USER);
                }
            }
            else
            {
                App.DisplayStatusMessage("Cancelling loading of DTCs.", StatusMessageType.USER);
            }
        }