public ControllerRecord[] GetOneRecord(UInt32 recordNum) { byte[] payload = new byte[34]; WGTools.UInt32ToNet(recordNum, ref payload, 0); byte[] recordResponse = SendCommand(WGParams.CommCmd.COMM_GETONERECORD, payload); if (recordResponse != null) { return(ControllerRecord.ParseRecordFromRecord(recordResponse)); } return(null); }
public void WatchTask(EventHandler <ControllerRecord> watchDelegate) { //Loop Here and Update const int waitMS = 500; //Exit Signal UInt32 getRecordIndex = 0; while (true) { byte[] sendPayload = new byte[26]; WGTools.UInt32ToNet(getRecordIndex, ref sendPayload, 0); byte[] watchResponse = SendCommand(WGParams.CommCmd.COMM_WATCH, null); if (watchResponse == null) { if (watchCancelEvent.WaitOne(waitMS)) { break; } else { continue; } } ControllerRecord rec = ControllerRecord.ParseRecordFromWatch(watchResponse); //Dont record if parse failed if (rec == null) { continue; } getRecordIndex = rec.recordIndex++; lock (WatchRecords) { if (!WatchRecords.Contains(rec)) { WatchRecords.Add(rec); if (watchDelegate != null) { watchDelegate(this, rec); } } } //Delay Until Next Update Period if (watchCancelEvent.WaitOne(waitMS)) { break; } else { continue; } } }