//Playback void CPlaybackByTime::OnButtonPlay() { // TODO: Add your control notification handler code here BOOL bValid = UpdateData(TRUE); if(bValid) { //Channel number int nChannelId = 0; int nIndex = m_ctlChannel.GetCurSel(); nChannelId = (int)m_ctlChannel.GetItemData(nIndex); //Time NET_TIME netTimeFrom = ConvertToDateTime(m_dateFrom,m_timeFrom); NET_TIME netTimeTo = ConvertToDateTime(m_dateTo,m_timeTo); //Playback //To get play mode nIndex = m_ctlPlayMode.GetCurSel(); if(CB_ERR != nIndex) { DH_PlayBackMode ePlayMode = (DH_PlayBackMode)m_ctlPlayMode.GetItemData(nIndex); if(ePlayMode == EM_SERVERMODE) { ((CClientDemo3Dlg *)AfxGetMainWnd())->PlayBackByTimeServerMode(nChannelId,&netTimeFrom,&netTimeTo); } else { ((CClientDemo3Dlg *)AfxGetMainWnd())->PlayBackByTime(nChannelId,&netTimeFrom,&netTimeTo); } } } }
void ATimeManager::InitializeCalendar(FTimeDate time) { time = ValidateTimeDate(time); InternalTime = ConvertToDateTime(time); OffsetUTC = FMath::Clamp(OffsetUTC, -12, 12); DayOfYear = InternalTime.GetDayOfYear(); int32 leapDays = IsLeapYear(time.Year); if (DayOfYear >= (79 + leapDays) && DayOfYear < (265 + leapDays)) { bDaylightSavingsActive = true; } OffsetDST = bAllowDaylightSavings && bDaylightSavingsActive ? 1 : 0; // Local Standard Time Meridian (degrees) = 15 * Hour Offset from UTC LSTM = 15 * OffsetUTC; SpanUTC = FTimespan((FMath::Abs(OffsetUTC) + OffsetDST), 0, 0); Latitude = FMath::Clamp(Latitude, -90.0f, 90.0f); Longitude = FMath::Clamp(Longitude, -180.0f, 180.0f); CurrentLocalTime = time; bIsCalendarInitialized = true; }
//Download void CPlaybackByTime::OnButtonDownload() { // TODO: Add your control notification handler code here CString strText; GetDlgItemText(IDC_BUTTON_DOWNLOAD,strText); if(strText == "Download" || strText == ConvertString("Download") ) { BOOL bValid = UpdateData(TRUE); if(bValid) { //Channel number int nIndex = m_ctlLoadChannel.GetCurSel(); int nChannelId = (int)m_ctlLoadChannel.GetItemData(nIndex); //Time NET_TIME netTimeFrom = ConvertToDateTime(m_dateLoadFrom,m_timeLoadFrom); NET_TIME netTimeTo = ConvertToDateTime(m_dateLoadTo,m_timeLoadTo); BOOL bSuccess = ((CClientDemo3Dlg *)AfxGetMainWnd())->DownLoadByTime(nChannelId,&netTimeFrom,&netTimeTo,TRUE); if(bSuccess) { SetDlgItemText(IDC_BUTTON_DOWNLOAD, ConvertString("Stop")); } } } else { NET_TIME netTimeFrom = {0}; NET_TIME netTimeTo = {0}; BOOL bSuccess = ((CClientDemo3Dlg *)AfxGetMainWnd())->DownLoadByTime(0,&netTimeFrom,&netTimeTo,FALSE); if(bSuccess) { SetDlgItemText(IDC_BUTTON_DOWNLOAD, ConvertString("Download")); m_dwTotalSize = 0; m_dwCurValue = 0; long hDownLoad = ((CClientDemo3Dlg *)AfxGetMainWnd())->m_pDownLoadByTime; if(0 != hDownLoad) { CLIENT_StopDownload(hDownLoad); ((CClientDemo3Dlg *)AfxGetMainWnd())->m_pDownLoadByTime = 0; } m_ctlLoadPro.SetRange32(0,0); m_ctlLoadPro.SetPos(0); Invalidate(); } } }
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; }
void CDevByFileDlg::OnButtonQuery() { // TODO: Add your control notification handler code here BOOL bValid = UpdateData(TRUE); if(bValid && (0 != m_lLoginHandle)) { int nIndex = m_ctlChannel.GetCurSel(); int nChannelId = (int)m_ctlChannel.GetItemData(nIndex); NET_TIME netTimeFrom = ConvertToDateTime(m_dateFrom,m_timeFrom); NET_TIME netTimeTo = ConvertToDateTime(m_dateTo,m_timeTo); nIndex = m_ctlType.GetCurSel(); int nRecordFileType = m_ctlType.GetItemData(nIndex); int nMaxLen = 2000 * sizeof(NET_RECORDFILE_INFO); int nFileCount = 0; BOOL bSuccess = CLIENT_QueryRecordFile(m_lLoginHandle, nChannelId, nRecordFileType, &netTimeFrom, &netTimeTo, NULL, m_netFileInfo, nMaxLen, &nFileCount, 5000, FALSE); if(bSuccess) { if(0 == nFileCount) { MessageBox(ConvertString("No record!"), ConvertString("Prompt")); } else { AddRecordInfoToListView(m_netFileInfo,nFileCount); } } else { MessageBox(ConvertString("Failed to query!"), ConvertString("Prompt")); } } }
int32 ATimeManager::GetDayOfYear(FTimeDate time) { return ConvertToDateTime(time).GetDayOfYear(); }
void IMI::WriteFix(const Fix &fix, bool fromB2, int no_enl, FILE *file) { bool append_line_break = false; unsigned offset = __builtin_offsetof(Fix, checksum); if (fix.checksum != FixChecksum(&fix, offset)) { fixBLastFull.id = 0; return; } if (fix.id == IMIFIX_ID_B_RECORD) { const FixB *fix_b = (const FixB *)&fix; AngleConverter angle; fputc('B', file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); angle.value = (IMIDWORD)fix_b->lat; fprintf(file, "%02d%05d", angle.degrees, angle.milliminutes); fputc((angle.sign) ? 'S' : 'N', file); angle.value = (IMIDWORD)fix_b->lon; fprintf(file, "%03d%05d", angle.degrees, angle.milliminutes); fputc((angle.sign) ? 'W' : 'E', file); fputc("VA??"[fix_b->fv], file); int alt = (int)fix_b->alt - 1000; fprintf(file, alt < 0 ? "%04d" : "%05d", alt); int gpsalt = (int)fix_b->gpsalt - 1000; fprintf(file, alt < 0 ? "%04d" : "%05d", gpsalt); fprintf(file, "%03d", fix_b->fxa); fprintf(file, "%02d", siu); if (!no_enl) fprintf(file, "%03d", fix_b->enl); append_line_break = true; if (!fromB2) memcpy(&fixBLastFull, &fix, sizeof(fixBLastFull)); } else if (fix.id == IMIFIX_ID_B2_RECORD) { const FixB2 *fix_b2 = (const FixB2 *)&fix; if (SplitB2Fix(fix_b2, &fixBLastFull, &fixB1, &fixB2)) { WriteFix(*(Fix*)&fixB1, true, no_enl, file); WriteFix(*(Fix*)&fixB2, true, no_enl, file); } } else if (fix.id == IMIFIX_ID_K_RECORD) { const FixK *fix_k = (const FixK *)&fix; fputc('K', file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); fprintf(file, "%03d", fix_k->hdt); fprintf(file, "%03d", fix_k->gsp); append_line_break = true; } else if (fix.id == IMIFIX_ID_E_RECORD) { const FixE *fix_e = (const FixE *)&fix; if (fix_e->type == IMIFIX_E_TYPE_SATELLITES) { siu = 0; fputc('F', file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); for (unsigned i = 0; i < sizeof(fix_e->text); i++) { if (fix_e->text[i] > 0) { fprintf(file, "%02d", fix_e->text[i]); siu++; } } append_line_break = true; } else if (fix_e->type == IMIFIX_E_TYPE_COMMENT) { fputs("LIMI", file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); WriteString((const char *)fix_e->text, sizeof(fix_e->text), file); append_line_break = true; } else if (fix_e->type == IMIFIX_E_TYPE_PEV) { fputc('E', file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); WriteString((const char *)fix_e->text, sizeof(fix_e->text), file); append_line_break = true; } else if (fix_e->type == IMIFIX_E_TYPE_TASK) { fputc('E', file); BrokenTime time = ConvertToDateTime(fix.time); fprintf(file, "%02d%02d%02d", time.hour, time.minute, time.second); if (fix_e->text[0] == 1) { fputs("STA", file); WriteString((const char *)fix_e->text + 2, sizeof(fix_e->text) - 2, file); } else { if (fix_e->text[0] == 2) fputs("ONT", file); else if (fix_e->text[0] == 3) fputs("FIN", file); else fputs("TPC", file); fprintf(file, "%02d", fix_e->text[1]); WriteString((const char *)fix_e->text + 2, sizeof(fix_e->text) - 2, file); } append_line_break = true; } } if (append_line_break) fputs("\r\n", file); }
void IMI::WriteHeader(const TDeclaration &decl, IMIBYTE tampered, FILE *file) { fputs("AIMI", file); WriteSerialNumber(decl.header.sn, file); fputs("\r\n", file); BrokenDate start_date = ConvertToDateTime(decl.header.recStartDateTime); fprintf(file, "HFDTE%02d%02d%02d\r\n", start_date.day, start_date.month, start_date.year % 100); fputs("HFFXA010\r\n", file); fputs("HFPLTPILOT:", file); WriteString(decl.header.plt, sizeof(decl.header.plt), file); fputs("\r\n", file); if (decl.header.db1Day != 0) fprintf(file, "HFDB1PILOTBIRTHDATE:%02d%02d%02d\r\n", decl.header.db1Day + 1, decl.header.db1Month + 1, decl.header.db1Year % 100); fputs("HFGTYGLIDERTYPE:", file); WriteString(decl.header.gty, sizeof(decl.header.gty), file); fputs("\r\n", file); fputs("HFGIDGLIDERID:", file); WriteString(decl.header.gid, sizeof(decl.header.gid), file); fputs("\r\n", file); fputs("HFDTM100DATUM:WGS-1984\r\n", file); fprintf(file, "HFRFWFIRMWAREVERSION:%d.%d\r\n", (unsigned)(decl.header.swVersion >> 4), (unsigned)(decl.header.swVersion & 0x0F)); fprintf(file, "HFRHWHARDWAREVERSION:%d.%d\r\n", (unsigned)(decl.header.hwVersion >> 4), (unsigned)(decl.header.hwVersion & 0x0F)); fprintf(file, "HFFTYFRTYPE:IMI Gliding, %s\r\n", GetDeviceName(decl.header.device)); fprintf(file, "HFGPSGPS:%s\r\n", GetGPSName(decl.header.gps)); fprintf(file, "HFPRSPRESSALTSENSOR:%s\r\n", GetSensorName(decl.header.sensor)); if (tampered) fputs("HFFRSSECURITYSUSPECTUSEVALIPROGRAM:Tamper detected, FR needs to be reset", file); if (decl.header.cid[0] != 0) { fputs("HFCIDCOMPETITIONID:", file); WriteString(decl.header.cid, sizeof(decl.header.cid), file); fputs("\r\n", file); } // This seems to be a bug in the original implementation // When the competition class line is missing the integrity check will fail! if (decl.header.cid[0] != 0) { fputs("HFCCLCOMPETITIONCLASS:", file); if (decl.header.ccl[0] != 0) WriteString(decl.header.ccl, sizeof(decl.header.ccl), file); fputs("\r\n", file); } if (decl.header.cm2[0] != '\0') { fputs("HFCM2SECONDCREW:", file); WriteString(decl.header.cm2, sizeof(decl.header.cm2), file); fputs("\r\n", file); if (decl.header.db2Day != 0) fprintf(file, "HFDB1SECONDCREWBIRTHDATE:%02d%02d%02d\r\n", decl.header.db2Day + 1, decl.header.db2Month + 1, decl.header.db2Year % 100); } if (decl.header.clb[0] != '\0') { fputs("HFCLBCLUB:", file); WriteString(decl.header.clb, sizeof(decl.header.clb), file); fputs("\r\n", file); } if (decl.header.sit[0] != '\0') { fputs("HFCLBSITE:", file); WriteString(decl.header.sit, sizeof(decl.header.sit), file); fputs("\r\n", file); } if ((decl.header.sensor & IMINO_ENL_MASK) != 0) fputs("I033638FXA3940SIU\r\n", file); else fputs("I033638FXA3940SIU4143ENL\r\n", file); fputs("J020810HDT1113GSP\r\n", file); unsigned count = CountWaypoints(decl.wp); if (count >= 2) { BrokenDateTime decl_date = ConvertToDateTime(decl.header.date); fprintf(file, "C%02d%02d%02d", decl_date.day, decl_date.month, decl_date.year % 100); fprintf(file, "%02d%02d%02d", decl_date.hour, decl_date.minute, decl_date.second); if (decl.header.tskYear != 0) fprintf(file, "%02d%02d%02d", decl.header.tskDay + 1, decl.header.tskMonth + 1, decl.header.tskYear % 100); else fputs("000000", file); fprintf(file, "%04d%02d", decl.header.tskNumber, count - 2); WriteString(decl.header.tskName, sizeof(decl.header.tskName), file); fputs("\r\n", file); const IMI::TWaypoint *wp = decl.wp; for (unsigned i = 0; i < count + 2; i++, wp++) { AngleConverter l; l.value = wp->lat; fprintf(file, "C%02d%05d%c", l.degrees, l.milliminutes, (l.sign ? 'S' : 'N')); l.value = wp->lon; fprintf(file, "%03d%05d%c", l.degrees, l.milliminutes, (l.sign ? 'W' : 'E')); WriteString(wp->name, sizeof(wp->name), file); fputs("\r\n", file); } } fputs("LIMIFLIGHTOFDAY:", file); fprintf(file, "%03d", decl.header.flightOfDay); fputs("\r\n", file); //first fix must be full fixBLastFull.id = 0; }