public IrixiEE0017(ConfigPhysicalMotionController Config) : base(Config) { _controller = new IrixiMotionController(Config.Port); _controller.OnConnectionStatusChanged += _controller_OnConnectionProgressChanged; _controller.OnReportUpdated += _controller_OnReportUpdated; _controller.OnInputIOStatusChanged += ((s, e) => { OnInputStateChanged?.Invoke(this, e); }); }
public override void Dispose() { try { _controller.Close(); } catch (Exception ex) { throw ex; } finally { _controller = null; } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (IsInDesignMode) { //Code runs in Blend-- > create design time data. } else { ThreadPool.SetMinThreads(10, 10); this.DeviceSN = GlobalVariables.HidSN; _controller = new IrixiMotionController(GlobalVariables.HidSN); // For debug, the default SN of the controller is used. // // While scanning the controller, report the state to user window // _controller.OnConnectionStatusChanged += new EventHandler <ConnectionEventArgs>((sender, args) => { switch (args.Event) { case ConnectionEventArgs.EventType.ConnectionSuccess: this.ConnectionStateChangedMessage = "Connected"; for (int i = 0; i < _controller.AxisCollection.Count; i++) { _controller.AxisCollection[i].SoftCWLS = 1000000; _controller.AxisCollection[i].MaxSteps = 1000000; } break; case ConnectionEventArgs.EventType.Connecting: // how many times tried to connect to the device is reported this.ConnectionStateChangedMessage = "Connecting to the controller ..."; break; case ConnectionEventArgs.EventType.ConnectionLost: this.ConnectionStateChangedMessage = "Lost the connection"; break; } }); _controller.OnInputIOStatusChanged += new EventHandler <InputIOEventArgs>((s, e) => { if (e.Channel == 0 && e.State == InputState.Triggered) { _controller.SetGeneralOutput(0, OutputState.Enabled); } }); // // Once the report is received, update the UI components. // _controller.OnReportUpdated += new EventHandler <IrixiStepperControllerHelper.DeviceStateReport>((sender, report) => { // // Nothing to do in this demo // // }); //_controller.OpenDeviceAsync(); Open(); for (int i = 0; i < 5; i++) { Task.Factory.StartNew(DoFooWork); } } }
public override void Dispose() { _controller.CloseDevice(); _controller = null; }