static bool ConvertDirectoryToRecordedFlightList(const std::vector<DIRENTRY> &dir, RecordedFlightList &flight_list) { RecordedFlightInfo flight_info; for (unsigned i=0; (i < dir.size()) && !flight_list.full(); i++) { const DIRENTRY &flight = dir[i]; /* * Only show logs with a takeoff detected */ if (flight.takeoff == 1) { if (!flight.firsttime.IsPlausible() || !flight.lasttime.IsPlausible()) return false; flight_info.date = {flight.firsttime.year, flight.firsttime.month, flight.firsttime.day}; flight_info.start_time = {flight.firsttime.hour, flight.firsttime.minute, flight.firsttime.second}; flight_info.end_time = {flight.lasttime.hour, flight.lasttime.minute, flight.lasttime.second}; flight_info.internal.volkslogger = i; flight_list.append(flight_info); } } return true; }
static bool ReadFlightListInner(Port &port, RecordedFlightList &flight_list, OperationEnvironment &env) { if (!LX::CommandMode(port, env)) return false; port.Flush(); if (!LX::SendCommand(port, LX::READ_FLIGHT_LIST)) return false; bool success = false; while (!flight_list.full()) { LX::FlightInfo flight; if (!LX::ReadCRC(port, &flight, sizeof(flight), env, 20000)) break; success = true; if (!flight.IsValid()) break; RecordedFlightInfo dest; if (Copy(dest, flight)) flight_list.append(dest); } return success; }
bool FlarmDevice::ReadFlightList(RecordedFlightList &flight_list, OperationEnvironment &env) { if (!BinaryMode(env)) return false; // Try to receive flight information until the list is full for (uint8_t i = 0; !flight_list.full(); ++i) { FLARM::MessageType ack_result = SelectFlight(i, env); // Last record reached -> bail out and return list if (ack_result == FLARM::MT_NACK) break; // If neither ACK nor NACK was received if (ack_result != FLARM::MT_ACK || env.IsCancelled()) { mode = Mode::UNKNOWN; return false; } RecordedFlightInfo flight_info; flight_info.internal.flarm = i; if (ReadFlightInfo(flight_info, env)) flight_list.append(flight_info); } return true; }
static void PrintFlightList(const RecordedFlightList &flight_list) { for (auto i = flight_list.begin(); i != flight_list.end(); ++i) { const RecordedFlightInfo &flight = *i; printf("%04u/%02u/%02u %02u:%02u-%02u:%02u\n", flight.date.year, flight.date.month, flight.date.day, flight.start_time.hour, flight.start_time.minute, flight.end_time.hour, flight.end_time.minute); } }
/** * * @param list list of flights from the logger * @param flight the flight * @return 1-99 Flight number of the day per section 2.5 of the * FAI IGC tech gnss spec Appendix 1 * (spec says 35 flights - this handles up to 99 flights per day) */ static unsigned GetFlightNumber(const RecordedFlightList &flight_list, const RecordedFlightInfo &flight) { unsigned flight_number = 1; for (auto it = flight_list.begin(), end = flight_list.end(); it != end; ++it) { const RecordedFlightInfo &_flight = *it; if (flight.date == _flight.date && (flight.start_time.GetSecondOfDay() > _flight.start_time.GetSecondOfDay())) flight_number++; } return flight_number; }
static bool ReadLogbookContents(PortNMEAReader &reader, RecordedFlightList &flight_list, unsigned n, TimeoutClock &timeout) { while (n-- > 0) { if (!ReadLogbookContent(reader, flight_list.append(), timeout)) return false; } return true; }
bool IMI::ReadFlightList(Port &port, RecordedFlightList &flight_list, OperationEnvironment &env) { flight_list.clear(); if (!_connected) return false; IMIWORD address = 0, addressStop = 0xFFFF; IMIBYTE count = 1, totalCount = 0; for (;; count++) { const TMsg *pMsg = SendRet(port, env, MSG_FLIGHT_INFO, nullptr, 0, MSG_FLIGHT_INFO, -1, totalCount, address, addressStop, 200, 6); if (pMsg == nullptr) break; totalCount = pMsg->parameter1; address = pMsg->parameter2; addressStop = pMsg->parameter3; for (unsigned i = 0; i < pMsg->payloadSize / sizeof(IMI::FlightInfo); i++) { const IMI::FlightInfo *fi = ((const IMI::FlightInfo*)pMsg->payload) + i; RecordedFlightInfo &ifi = flight_list.append(); BrokenDateTime start = ConvertToDateTime(fi->start); ifi.date = start; ifi.start_time = start; ifi.end_time = ConvertToDateTime(fi->finish); ifi.internal.imi = fi->address; } if (pMsg->payloadSize == 0 || address == 0xFFFF) return true; } return false; }
static bool ReadFlightListInner(Port &port, RecordedFlightList &flight_list, OperationEnvironment &env) { env.SetProgressRange(8); for (unsigned i = 0; i < 8 && !flight_list.full(); ++i) { CAI302::FileList file_list; if (!CAI302::UploadFileList(port, i, file_list, env)) break; for (unsigned j = 0; j < 8 && !flight_list.full(); ++j) { const CAI302::FileList::FileInfo &file = file_list.files[j]; if (file.start_utc.month > 0) Copy(flight_list.append(), i * 8 + j, file); } env.SetProgressPosition(i); } return !flight_list.empty() && !env.IsCancelled(); }
bool Nano::ReadFlightList(Port &port, RecordedFlightList &flight_list, OperationEnvironment &env) { port.StopRxThread(); PortNMEAReader reader(port, env); TimeoutClock timeout(2000); int nflights = GetNumberOfFlights(port, reader, env, timeout); if (nflights <= 0) return nflights == 0; env.SetProgressRange(nflights); unsigned requested_tail = 1; while (true) { const unsigned room = flight_list.max_size() - flight_list.size(); const unsigned remaining = nflights - requested_tail + 1; const unsigned nmax = std::min(room, remaining); if (nmax == 0) break; /* read 8 records at a time */ const unsigned nrequest = std::min(nmax, 8u); timeout = TimeoutClock(2000); if (!GetLogbookContents(port, reader, flight_list, requested_tail, nrequest, env, timeout)) return false; requested_tail += nrequest; env.SetProgressPosition(requested_tail - 1); } return true; }
bool FlytecDevice::ReadFlightList(RecordedFlightList &flight_list, OperationEnvironment &env) { port.StopRxThread(); char buffer[256]; strcpy(buffer, "$PBRTL,"); AppendNMEAChecksum(buffer); strcat(buffer, "\r\n"); port.Write(buffer); if (!ExpectXOff(port, env, 1000)) return false; unsigned tracks = 0; while (true) { // Check if the user cancelled the operation if (env.IsCancelled()) return false; // Receive the next line if (!ReceiveLine(port, buffer, ARRAY_SIZE(buffer), 1000)) return false; // XON was received, last record was read already if (StringIsEmpty(buffer)) break; // $PBRTL Identifier // AA total number of stored tracks // BB actual number of track (0 indicates the most actual track) // DD.MM.YY date of recorded track (UTC)(e.g. 24.03.04) // hh:mm:ss starttime (UTC)(e.g. 08:23:15) // HH:MM:SS duration (e.g. 03:23:15) // *ZZ Checksum as defined by NMEA RecordedFlightInfo flight; NMEAInputLine line(buffer); // Skip $PBRTL line.Skip(); if (tracks == 0) { // If number of tracks not read yet // .. read and save it if (!line.ReadChecked(tracks)) continue; env.SetProgressRange(tracks); } else line.Skip(); if (!line.ReadChecked(flight.internal.flytec)) continue; if (tracks != 0 && flight.internal.flytec < tracks) env.SetProgressPosition(flight.internal.flytec); char field_buffer[16]; line.Read(field_buffer, ARRAY_SIZE(field_buffer)); if (!ParseDate(field_buffer, flight.date)) continue; line.Read(field_buffer, ARRAY_SIZE(field_buffer)); if (!ParseTime(field_buffer, flight.start_time)) continue; BrokenTime duration; line.Read(field_buffer, ARRAY_SIZE(field_buffer)); if (!ParseTime(field_buffer, duration)) continue; flight.end_time = flight.start_time + duration; flight_list.append(flight); } return true; }