private void OnEntryReceived(ChronState state) { var handle = this.EntryReceived; if (handle != null) { handle(this, new ChronEventArgs(state)); } }
private void OnReport(HidReport report) { ChronState state = new ChronState(); if (attached == false) { return; } if (report.Data.Length > 2) { if (report.Data[0] == 0 && report.Data[1] == 2) { state.Diagnostics = "Received Chron Entry " + cron_entries_received + ": "; state.Read_MoreToParse = true; cron_entries_received++; //this.GetCronDataContinuation(); } if (report.Data[0] == 0 && report.Data[1] == 3) { state.Diagnostics = "Chron Entry Comms Ended: "; cron_entries_received = 0; } if (debugPrintRawMessages) { for (int i = 0; i < report.Data.Length; i++) { state.Diagnostics += report.Data[i] + ", "; } System.Diagnostics.Debug.WriteLine(state.Diagnostics); } this.OnEntryReceived(state); } device.ReadReport(OnReport); }
public void GetCronData() { if (connectedToDriver) { byte[] data = new byte[2]; data[0] = 0x00; data[1] = 0x01; HidReport report = new HidReport(2, new HidDeviceData(data, HidDeviceData.ReadStatus.Success)); device.WriteReport(report); ChronState state = new ChronState(); if (report.Data.Length > 2) { if (report.Data[0] == 0 && report.Data[1] == 2) { state.Diagnostics = "Received Chron Entry " + cron_entries_received + ": "; state.Read_MoreToParse = true; cron_entries_received++; //this.GetCronDataContinuation(); } if (report.Data[0] == 0 && report.Data[1] == 3) { state.Diagnostics = "Chron Entry Comms Ended: "; cron_entries_received = 0; } if (debugPrintRawMessages) { for (int i = 0; i < report.Data.Length; i++) { state.Diagnostics += report.Data[i] + ", "; } System.Diagnostics.Debug.WriteLine(state.Diagnostics); } this.OnEntryReceived(state); } } }
public ChronEventArgs(ChronState state) { this.State = state; }