public IrixiMotionController(string DeviceSN = "") { // Generate the instance of the state report object HidReport = new DeviceStateReport(); FirmwareInfo = new FimwareInfo(); PCA9534Info = new PCA9534Info(); TotalAxes = -1; SerialNumber = DeviceSN; AxisCollection = new ObservableCollection <Axis>(); //BindingOperations.EnableCollectionSynchronization(AxisCollection, _lock); hidPort = new HIDUSBDevice(VID, PID, DeviceSN); }
public object Clone() { DeviceStateReport state = new DeviceStateReport(); state.Counter = this.Counter; state.TotalAxes = this.TotalAxes; state.IsBusy = this.IsBusy; state.SystemError = this.SystemError; state.TriggerInput0 = this.TriggerInput0; state.TriggerInput1 = this.TriggerInput1; state.CoreVref = this.CoreVref; state.CoreTemp = this.CoreTemp; state.AxisStateCollection = new ObservableCollection <AxisStateReport>(); for (int i = 0; i < this.AxisStateCollection.Count; i++) { state.AxisStateCollection.Add(this.AxisStateCollection[i].Clone() as AxisStateReport); } return(state); }
/// <summary> /// rasie this event when a data pack containing up-to-date hid report is received /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnReportReceived(object sender, byte[] e) { // the first byte is report id int _report_id = (int)e[0]; // report of device state if (_report_id == REPORT_ID_DEVICESTATE) { // copy the previous report before parsing the new report raw data DeviceStateReport _previous_report = this.Report.Clone() as DeviceStateReport; // parse the report from the up-to-date raw data this.Report.ParseRawData(e); // raise the event OnReportUpdated?.Invoke(this, this.Report); // if the state of input changes, raise the event for (int i = 0; i < this.Report.AxisStateCollection.Count; i++) { if (this.Report.AxisStateCollection[i].IN_A != _previous_report.AxisStateCollection[i].IN_A) { OnInputIOStatusChanged?.Invoke(this, new InputEventArgs(i * 2, this.Report.AxisStateCollection[i].IN_A)); } if (this.Report.AxisStateCollection[i].IN_B != _previous_report.AxisStateCollection[i].IN_B) { OnInputIOStatusChanged?.Invoke(this, new InputEventArgs(i * 2 + 1, this.Report.AxisStateCollection[i].IN_B)); } } } // report of firmware information else if (_report_id == REPORT_ID_FACTINFO) { buf_report_factinfo.AddRange(e); } }