// // Download checkins // private void DownloadCheckinsClick(object sender, RoutedEventArgs e) { Callback storeNumCheckins = (ResponseFrame frame, Exception exc) => { if (CheckForErrorsOrTimeout(frame, exc)) { return; } numCheckinsStoredInReader = BitConverter.ToUInt16(frame.Data, 0); if (numCheckinsStoredInReader == 0) { ShowSuccessStatus("There are no checkins to download from the Tappy"); return; } /* Step 3 - download the checkins currently stored in the Tappy*/ numCheckinsRemainingToDownload = numCheckinsStoredInReader; Command cmdDownloadCheckins = new downloadCheckins(0, (ushort)(numCheckinsToDownloadAtOnce - 1)); Debug.WriteLine($" Checkin numbers 1 through {numCheckinsToDownloadAtOnce} are being downloaded from the Tappy"); tappy.SendCommand(cmdDownloadCheckins, storeDownloadedCheckin); }; Callback storeCurrentStationInfo = (stationNumFrame, stationNumExc) => { if (CheckForErrorsOrTimeout(stationNumFrame, stationNumExc)) { return; } byte[] stationCodeLittleEndian = new byte[2]; Array.Copy(stationNumFrame.Data, stationCodeLittleEndian, 2); Array.Reverse(stationCodeLittleEndian); currentStationCode = BitConverter.ToUInt16(stationCodeLittleEndian, 0); currentStationName = HexarrayToString(BitConverter.ToString(stationNumFrame.Data, 2)); currentStationName.TrimEnd(); /*Step 2: get the number of checkins currently stored in the Tappy*/ Command cmdGetNumCheckins = new getNumCheckins(); tappy.SendCommand(cmdGetNumCheckins, storeNumCheckins); }; ShowPendingStatus("Downloading Checkins..."); /*Step 1 get the station name and code from the Tappy*/ Command cmdGetStationInfo = new GetStationInfo(); tappy.SendCommand(cmdGetStationInfo, storeCurrentStationInfo); }
private void GetNumCheckins_Click(object sender, RoutedEventArgs e) { Callback showNumCheckins = (ResponseFrame frame, Exception exc) => { if (CheckForErrorsOrTimeout(frame, exc)) { return; } UInt32 numCheckins = BitConverter.ToUInt32(frame.Data, 0); ShowSuccessStatus($"Number of Checkins is {numCheckins} "); }; Command cmd = new getNumCheckins(); tappy.SendCommand(cmd, showNumCheckins); }