Exemplo n.º 1
0
        void OnInitMasterEmulatorWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            this.Invoke((MethodInvoker) delegate()
            {
                log.Add(new StringValue(AppText.StartingUp));
            });

            masterEmulator = new MasterEmulator();
            RegisterEventHandlers();

            IEnumerable <string> usbDevices = masterEmulator.EnumerateUsb();

            this.Invoke((MethodInvoker) delegate()
            {
                PopulateUsbDevComboBox(usbDevices);
                //string usbSerial;
                if (masterEmulatorBoardsCount == 0)
                {
                    MessageBox.Show(AppText.NoDeviceSelected);
                    return;
                }
                btnOpenClose.Enabled = true;
                cboUsbSerial.Enabled = true;
            });

            initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorWorkerDoWork;
        }
Exemplo n.º 2
0
 public PipeSetup(MasterEmulator master)
 {
     masterEmulator = master;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create MasterEmulator instance.
 /// </summary>
 void InitializeMasterEmulator()
 {
     AddToLog("Loading...");
     masterEmulator = new MasterEmulator();
 }
Exemplo n.º 4
0
 //PPP , PipeSetup pipe)
 public void UpDnEngine_Setup(Nordicsemi.MasterEmulator master)
 {
     masterEmulator = master;
     //PPP pipeSetup = pipe;
     pipeSetup = new PipeSetup_UpDn(master);
 }
Exemplo n.º 5
0
        void OnInitMasterEmulatorDoWork(object sender, DoWorkEventArgs e)
        {
            this.Dispatcher.BeginInvoke((Action)delegate ()
            {
                AddLineToLog(AppText.StartingUp);
            });

            masterEmulator = new MasterEmulator();
            RegisterEventHandlers();

            IEnumerable<string> usbDevices = masterEmulator.EnumerateUsb();

            this.Dispatcher.BeginInvoke((Action)delegate ()
            {
                PopulateUsbDevComboBox(usbDevices);
            });

            initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorDoWork;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Create MasterEmulator instance.
 /// </summary>
 void InitializeMasterEmulator()
 {
     AddToLog("Loading...");
     //AddToOutput("Ready to connect");
     masterEmulator = new MasterEmulator();
 }
 /// <summary>
 /// Create MasterEmulator instance.
 /// </summary>
 void InitializeMasterEmulator()
 {
     AddToLog("Loading...");
     masterEmulator = new MasterEmulator();
 }
Exemplo n.º 8
0
 public PipeSetup(MasterEmulator master)
 {
     masterEmulator = master;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Collection of method calls to start and setup MasterEmulator.
        /// The calls are placed in a background task for not blocking the gui thread.
        /// </summary>
        public void Initialize_Controller()
        {
            IsBusy = true;
            IsBusy_Initializing = true;

            hasBLEMasterDevice = false;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    IsInitialized = false;
                    if (masterEmulator == null)
                    {
                        masterEmulator = new MasterEmulator();
                        RegisterEventHandlers();
                    }
                    else
                    {
                        if (masterEmulator.IsOpen)
                        {
                            masterEmulator.Close();
                        }
                        masterEmulator = new MasterEmulator();
                        RegisterEventHandlers();
                    }


                    String device = FindUsbDevice();
                    if (device.Equals(String.Empty))
                    {
                        hasBLEMasterDevice = false;
                        IsInitialized = true;
                        Initialized_OK = false;
                        IsBusy = false;
                        IsBusy_Initializing = false;
                        appEv_InitializedResult(this, new Initialized_OK_EventArgs(false));
                        return;
                    }
                    hasBLEMasterDevice = true;

                    if (masterEmulator.IsOpen == false)
                    {
                        masterEmulator.Open(device);
                        masterEmulator.Reset();
                    }


                    //----- PipeSetup -----
                    udEngine = new UpDnEngine();
                    udEngine.UpDnEngine_Setup(masterEmulator);
                    udEngine.PerformPipeSetup();

                    set_default_local_udPacketHandler();


                    ctrlEngine = new CtrlEngine();
                    ctrlEngine.CtrlEngine_Setup(masterEmulator);
                    ctrlEngine.PerformPipeSetup();

                    //----- Start the MasterEmulator -----
                    if (masterEmulator.IsRunning == false)
                    {
                        masterEmulator.Run();
                    }

                    //----- Send Out Initialized Event -----
                    IsInitialized = true;
                    Initialized_OK = true;
                    IsBusy = false;
                    IsBusy_Initializing = false;
                    appEv_InitializedResult(this, new Initialized_OK_EventArgs(true));

                }
                catch (Exception ex)
                {
                    LogErrorMessage(string.Format("Exception in StartMasterEmulator: {0}", ex.Message), ex.StackTrace);
                    IsInitialized = true;
                    Initialized_OK = false;
                    IsBusy = false;
                    IsBusy_Initializing = false;
                    appEv_InitializedResult(this, new Initialized_OK_EventArgs(false));
                }
            });
        }