private void ReceiveReport(HidReport 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); } }
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] == 0) { state.Diagnostics = "Received Time and Data Reset " + cron_entries_received + ": "; state.Read_MoreToParse = true; cron_entries_received++; } 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 (report.Data[0] == 0 && report.Data[1] == 6) { state.Diagnostics = "Written Chron Entry " + cron_entries_written + ": "; state.Read_MoreToParse = true; cron_entries_written++; this.WriteCronDataContinuation(); } if (report.Data[0] == 0 && report.Data[1] == 5) { state.Diagnostics = "Chron Write Comms Ended: "; cron_entries_written = 0; } // Override Control Reply if (report.Data[0] == 0 && report.Data[1] == 13) { state.Diagnostics = "Override Control Response: "; } if (debugPrintRawMessages) { for (int i = 0; i < report.Data.Length; i++) { state.Diagnostics += report.Data[i] + ", "; } byte[] data = new byte[9]; //for (int i = 4; i < 11; i++) //{ // data[i] = report.Data[i]; //} state.SetData(data); System.Diagnostics.Debug.WriteLine(state.Diagnostics); } this.OnEntryReceived(state); } device.ReadReport(OnReport); }
public ChronEventArgs(ChronState state) { this.State = state; }