예제 #1
0
        private void Start_Button_Click(object sender, RoutedEventArgs e)
        {
            if (Settings.SelectedDevice.DeviceType != BaseDevice.DeviceTypeOptions.TwiKfdtool)
            {
                ErrorEmulation(string.Format("The device type {0} does not support MR emulation", Settings.SelectedDevice.DeviceType.ToString()));
                return;
            }

            if (Settings.SelectedDevice.TwiKfdtoolDevice.ComPort == string.Empty)
            {
                ErrorEmulation("No device selected");
                return;
            }

            StartEmulation();

            Task.Run(() =>
            {
                ap = null;

                try
                {
                    ap = new AdapterProtocol(Settings.SelectedDevice.TwiKfdtoolDevice.ComPort);

                    ap.Open();

                    ap.Clear();

                    twp = new ThreeWireProtocol(ap);

                    twp.StatusChanged += OnProgressUpdated;

                    twp.MrRunProducer();
                }
                catch (Exception ex)
                {
                    ErrorEmulation(ex.Message);
                }
                finally
                {
                    try
                    {
                        if (ap != null)
                        {
                            ap.Close();
                        }
                    }
                    catch (System.IO.IOException ex)
                    {
                        Log.Warn("could not close serial port: {0}", ex.Message);
                    }
                }
            });
        }
        private void Start_Button_Click(object sender, RoutedEventArgs e)
        {
            Settings.InProgressScreen = "NavigateP25MrEmulator";

            StartEmulation();

            Task.Run(() =>
            {
                if (Settings.Port == string.Empty)
                {
                    throw new ArgumentException("port empty");
                }

                ap = null;

                try
                {
                    ap = new AdapterProtocol(Settings.Port);

                    ap.Open();

                    ap.Clear();

                    twp = new ThreeWireProtocol(ap);

                    twp.StatusChanged += OnProgressUpdated;

                    twp.MrRunProducer();
                }
                catch (Exception ex)
                {
                    ErrorEmulation(ex.Message);
                }
                finally
                {
                    try
                    {
                        if (ap != null)
                        {
                            ap.Close();
                        }
                    }
                    catch (System.IO.IOException ex)
                    {
                        //Logger.Warn("could not close serial port: {0}", ex.Message);
                    }
                }
            });
        }
예제 #3
0
        public static void CheckTargetMrConnection(string port)
        {
            if (port == string.Empty)
            {
                throw new ArgumentException("port empty");
            }

            AdapterProtocol ap = null;

            try
            {
                ap = new AdapterProtocol(port);

                ap.Open();

                ap.Clear();

                ThreeWireProtocol twp = new ThreeWireProtocol(ap);

                twp.CheckTargetMrConnection();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                try
                {
                    if (ap != null)
                    {
                        ap.Close();
                    }
                }
                catch (System.IO.IOException ex)
                {
                    Logger.Warn("could not close serial port: {0}", ex.Message);
                }
            }
        }
예제 #4
0
 public ManualRekeyApplication(AdapterProtocol adapterProtocol)
 {
     ThreeWireProtocol = new ThreeWireProtocol(adapterProtocol);
 }