/** * @brief Sends DSX T1 sentence * * DSX T1 is the first of the declaration sequence: must be the first, and must * be sent only one time. It let to send the base data of the task. * * Syntax: * @verbatim Sentence ID: T1 (in ASCII) Task ID: 4 char ASCII alphanumeric Intended date of flight: 6 char YYMMDD Turnpoints number: 1 char ASCII – Turnpoint total number range: hex 0x30..0x3A (max 10 ) Task description: 30 char max ASCII, if shorter it will be ended by the CR(0x0d) End of the sentence: ASCII CR (0x0d) @endverbatim * * @param d Device handle * @param decl Task declaration data * @param errBufferLen The length of the buffer for error string * @param errBuffer The buffer for error string * * @return Declaration status */ bool DSXT1Send(PDeviceDescriptor_t d, const Declaration_t &decl, unsigned errBufferLen, TCHAR errBuffer[]) { // Task ID can be hardcoded const TCHAR *TASK_ID_STR = _T("LK8K"); // prepare date string TCHAR dateStr[7]; _stprintf(dateStr, _T("%02u%02u%02u"), GPS_INFO.Year % 100, GPS_INFO.Month, GPS_INFO.Day); // prepare description const unsigned DESC_LEN = 30; TCHAR descBuffer[DESC_LEN + 1]; TaskFileName(DESC_LEN + 1, descBuffer); // send final sequence TCHAR buffer[64]; _stprintf(buffer, _T("T1%s%s%X%s\r"), TASK_ID_STR, dateStr, decl.num_waypoints - 2, descBuffer); d->Com->WriteString(buffer); if(!DSXPromptWait(d, PROMPT_WAIT_CHARS)) { // LKTOKEN _@M1420_ = "Error while declaring!" // LKTOKEN _@M1421_ = "Task description" _sntprintf(errBuffer, errBufferLen, _T("%s '%s'!"), MsgToken(1420), MsgToken(1421)); return false; } return true; }
/** * @brief Sends task declaration * * @param d Device handle * @param decl Task declaration data * @param errBufSize The size of the buffer for error string * @param errBuf The buffer for error string * * @return Operation status */ bool CDevIMI::DeclarationWrite(PDeviceDescriptor_t d, const Declaration_t &decl, unsigned errBufSize, TCHAR errBuf[]) { if(!_connected) { // LKTOKEN _@M1411_ = "Device not connected!" _sntprintf(errBuf, errBufSize, _T("%s"), gettext(_T("_@M1411_"))); return false; } TDeclaration imiDecl; memset(&imiDecl, 0, sizeof(imiDecl)); // idecl.date ignored - will be set by FR unicode2usascii(decl.PilotName, imiDecl.header.plt, sizeof(imiDecl.header.plt)); // decl.header.db1Year = year; decl.header.db1Month = month; decl.header.db1Day = day; unicode2usascii(decl.AircraftType, imiDecl.header.gty, sizeof(imiDecl.header.gty)); unicode2usascii(decl.AircraftRego, imiDecl.header.gid, sizeof(imiDecl.header.gid)); unicode2usascii(decl.CompetitionID, imiDecl.header.cid, sizeof(imiDecl.header.cid)); unicode2usascii(decl.CompetitionClass, imiDecl.header.ccl, sizeof(imiDecl.header.ccl)); // strncpy(decl.header.clb, idecl.clb, sizeof(decl.header.clb)); // strncpy(decl.header.sit, idecl.sit, sizeof(decl.header.sit)); // strncpy(decl.header.cm2, idecl.cm2, sizeof(decl.header.cm2)); // decl.header.db2Year = year; decl.header.db2Month = month; decl.header.db2Day = day; TCHAR tskName[IMIDECL_TASK_NAME_LENGTH]; TaskFileName(IMIDECL_TASK_NAME_LENGTH, tskName); unicode2usascii(tskName, imiDecl.header.tskName, sizeof(imiDecl.header.tskName)); // decl.header.tskYear = year; decl.header.tskMonth = month; decl.header.tskDay = day; // decl.header.tskNumber = MIN(9999, idecl.tskNumber); IMIWaypoint(decl, 0, imiDecl.wp[0]); for(int i=0; i<decl.num_waypoints; i++) IMIWaypoint(decl, i + 1, imiDecl.wp[i + 1]); IMIWaypoint(decl, decl.num_waypoints + 1, imiDecl.wp[decl.num_waypoints + 1]); // send declaration for current task const TMsg *msg = SendRet(d, errBufSize, errBuf, MSG_DECLARATION, &imiDecl, sizeof(imiDecl), MSG_ACK_SUCCESS, 0, static_cast<IMIBYTE>(-1)); if(!msg && errBuf[0] == '\0') { // LKTOKEN _@M1415_ = "Declaration not accepted!" _sntprintf(errBuf, errBufSize, _T("%s"), gettext(_T("_@M1415_"))); } return msg; }
static void UpdateCaption (void) { TCHAR title[MAX_PATH]; TCHAR name[MAX_PATH] = TEXT("\0"); TaskFileName(MAX_PATH, name); if (_tcslen(name)>0) { _stprintf(title, TEXT("%s: %s"), // LKTOKEN _@M688_ = "Task Overview" MsgToken(688), name); } else { _stprintf(title, TEXT("%s"), // LKTOKEN _@M688_ = "Task Overview" MsgToken(688)); } if (TaskModified) { _tcscat(title, TEXT(" *")); } wf->SetCaption(title); }