示例#1
0
文件: Logger.cpp 项目: Turbo87/LK8000
void StartDeclaration(int ntp)
{
  // TODO bug: this is causing problems with some analysis software
  // maybe it's because the date and location fields are bogus
  char start[] = "C0000000N00000000ETAKEOFF\r\n";
  char temp[100];

  if (NumLoggerBuffered==0) {
    FirstPoint.Year = GPS_INFO.Year;
    FirstPoint.Month = GPS_INFO.Month;
    FirstPoint.Day = GPS_INFO.Day;
    FirstPoint.Hour = GPS_INFO.Hour;
    FirstPoint.Minute = GPS_INFO.Minute;
    FirstPoint.Second = GPS_INFO.Second;
  }

  // JMW added task start declaration line

  // LGCSTKF013945TAKEOFF DETECTED

  // IGC GNSS specification 3.6.1
  sprintf(temp,
	  "C%02d%02d%02d%02d%02d%02d0000000000%02d\r\n",
	  // DD  MM  YY  HH  MM  SS  DD  MM  YY IIII TT
	  FirstPoint.Day,
	  FirstPoint.Month,
	  FirstPoint.Year % 100,
	  FirstPoint.Hour,
	  FirstPoint.Minute,
	  FirstPoint.Second,
	  ntp-2);

  IGCWriteRecord(temp);
  // takeoff line
  // IGC GNSS specification 3.6.3

  // Use homewaypoint as default takeoff and landing position. Better than an empty field!
  if (ValidWayPoint(HomeWaypoint)) {
	TCHAR wname[NAME_SIZE+1];
	wsprintf(wname,_T("%s"),WayPointList[HomeWaypoint].Name);
	wname[8]='\0';
	AddDeclaration(WayPointList[HomeWaypoint].Latitude, WayPointList[HomeWaypoint].Longitude, wname);
  } else
  	IGCWriteRecord(start);
                               
}
示例#2
0
void
LoggerImpl::LoggerNote(const TCHAR *text) {
  if (LoggerActive) {
    char fulltext[500];
    sprintf(fulltext, "LPLT%S\r\n", text);
    IGCWriteRecord(fulltext, szLoggerFileName);
  }
}
示例#3
0
void
LoggerImpl::EndDeclaration(void)
{
  // TODO bug: this is causing problems with some analysis software
  // maybe it's because the date and location fields are bogus
  const char start[] = "C0000000N00000000ELANDING\r\n";
  IGCWriteRecord(start, szLoggerFileName);
}
示例#4
0
void
LoggerImpl::StartDeclaration(const NMEA_INFO &gps_info,
                         const int ntp)
{
  // TODO bug: this is causing problems with some analysis software
  // maybe it's because the date and location fields are bogus
  char start[] = "C0000000N00000000ETAKEOFF\r\n";
  char temp[100];

  if (NumLoggerBuffered==0) {
    FirstPoint.Year = gps_info.Year;
    FirstPoint.Month = gps_info.Month;
    FirstPoint.Day = gps_info.Day;
    FirstPoint.Hour = gps_info.Hour;
    FirstPoint.Minute = gps_info.Minute;
    FirstPoint.Second = gps_info.Second;
  }

  // JMW added task start declaration line

  // LGCSTKF013945TAKEOFF DETECTED

  // IGC GNSS specification 3.6.1
  sprintf(temp,
	  "C%02d%02d%02d%02d%02d%02d0000000000%02d\r\n",
	  // DD  MM  YY  HH  MM  SS  DD  MM  YY IIII TT
	  FirstPoint.Day,
	  FirstPoint.Month,
	  FirstPoint.Year % 100,
	  FirstPoint.Hour,
	  FirstPoint.Minute,
	  FirstPoint.Second,
	  ntp-2);

  IGCWriteRecord(temp, szLoggerFileName);
  // takeoff line
  // IGC GNSS specification 3.6.3
  IGCWriteRecord(start, szLoggerFileName);

}
示例#5
0
void LogPointToFile(double Latitude, double Longitude, double Altitude,
                    double BaroAltitude, short Hour, short Minute, short Second)
{
  char szBRecord[500];

  int DegLat, DegLon;
  double MinLat, MinLon;
  char NoS, EoW;

  // pending rounding error from millisecond timefix in RMC sentence?
  if (Second>=60||Second<0) {
	#if TESTBENCH
	StartupStore(_T("... WRONG TIMEFIX FOR LOGGER, seconds=%d, fix skipped\n"),Second);
	#endif
	return;
  }

  if ((Altitude<0) && (BaroAltitude<0)) return;
  Altitude = max(0.0,Altitude);
  BaroAltitude = max(0.0,BaroAltitude);

  DegLat = (int)Latitude;
  MinLat = Latitude - DegLat;
  NoS = 'N';
  if((MinLat<0) || ((MinLat==0) && (DegLat<0)))
    {
      NoS = 'S';
      DegLat *= -1; MinLat *= -1;
    }
  MinLat *= 60;
  MinLat *= 1000;

  DegLon = (int)Longitude ;
  MinLon = Longitude  - DegLon;
  EoW = 'E';
  if((MinLon<0) || ((MinLon==0) && (DegLon<0)))
    {
      EoW = 'W';
      DegLon *= -1; MinLon *= -1;
    }
  MinLon *=60;
  MinLon *= 1000;

  sprintf(szBRecord,"B%02d%02d%02d%02d%05.0f%c%03d%05.0f%cA%05d%05d\r\n",
          Hour, Minute, Second,
          DegLat, MinLat, NoS, DegLon, MinLon, EoW,
          (int)BaroAltitude,(int)Altitude);

  IGCWriteRecord(szBRecord);
}
示例#6
0
文件: Logger.cpp 项目: Turbo87/LK8000
void EndDeclaration(void)
{
  // TODO bug: this is causing problems with some analysis software
  // maybe it's because the date and location fields are bogus
  char start[] = "C0000000N00000000ELANDING\r\n";

  // Use homewaypoint as default takeoff and landing position. Better than an empty field!
  if (ValidWayPoint(HomeWaypoint)) {
	TCHAR wname[NAME_SIZE+1];
	wsprintf(wname,_T("%s"),WayPointList[HomeWaypoint].Name);
	wname[8]='\0';
	AddDeclaration(WayPointList[HomeWaypoint].Latitude, WayPointList[HomeWaypoint].Longitude, wname);
  } else
  	IGCWriteRecord(start);
}
示例#7
0
void
LoggerImpl::AddDeclaration(double Latitude, double Longitude, const TCHAR *ID)
{
  char szCRecord[500];

  char IDString[MAX_PATH];
  int i;

  int DegLat, DegLon;
  double MinLat, MinLon;
  char NoS, EoW;

  TCHAR tmpstring[MAX_PATH];
  _tcscpy(tmpstring, ID);
  _tcsupr(tmpstring);
  for(i=0;i<(int)_tcslen(tmpstring);i++)
    {
      IDString[i] = (char)tmpstring[i];
    }
  IDString[i] = '\0';

  DegLat = (int)Latitude;
  MinLat = Latitude - DegLat;
  NoS = 'N';
  if((MinLat<0) || ((MinLat-DegLat==0) && (DegLat<0)))
    {
      NoS = 'S';
      DegLat *= -1; MinLat *= -1;
    }
  MinLat *= 60;
  MinLat *= 1000;

  DegLon = (int)Longitude ;
  MinLon = Longitude  - DegLon;
  EoW = 'E';
  if((MinLon<0) || ((MinLon-DegLon==0) && (DegLon<0)))
    {
      EoW = 'W';
      DegLon *= -1; MinLon *= -1;
    }
  MinLon *=60;
  MinLon *= 1000;

  sprintf(szCRecord,"C%02d%05.0f%c%03d%05.0f%c%s\r\n",
	  DegLat, MinLat, NoS, DegLon, MinLon, EoW, IDString);

  IGCWriteRecord(szCRecord, szLoggerFileName);
}
示例#8
0
文件: Logger.cpp 项目: Turbo87/LK8000
void LogPointToFile(double Latitude, double Longitude, double Altitude,
                    double BaroAltitude, short Hour, short Minute, short Second)
{
  char szBRecord[500];

  int DegLat, DegLon;
  double MinLat, MinLon;
  char NoS, EoW;

  if ((Altitude<0) && (BaroAltitude<0)) return;
  Altitude = max(0.0,Altitude);
  BaroAltitude = max(0.0,BaroAltitude);

  DegLat = (int)Latitude;
  MinLat = Latitude - DegLat;
  NoS = 'N';
  if((MinLat<0) || ((MinLat-DegLat==0) && (DegLat<0)))
    {
      NoS = 'S';
      DegLat *= -1; MinLat *= -1;
    }
  MinLat *= 60;
  MinLat *= 1000;

  DegLon = (int)Longitude ;
  MinLon = Longitude  - DegLon;
  EoW = 'E';
  if((MinLon<0) || ((MinLon-DegLon==0) && (DegLon<0)))
    {
      EoW = 'W';
      DegLon *= -1; MinLon *= -1;
    }
  MinLon *=60;
  MinLon *= 1000;

  sprintf(szBRecord,"B%02d%02d%02d%02d%05.0f%c%03d%05.0f%cA%05d%05d\r\n",
          Hour, Minute, Second,
          DegLat, MinLat, NoS, DegLon, MinLon, EoW,
          (int)BaroAltitude,(int)Altitude);

  IGCWriteRecord(szBRecord);
}
示例#9
0
void
LoggerImpl::LogPointToFile(const NMEA_INFO& gps_info)
{
  char szBRecord[500];

  int DegLat, DegLon;
  double MinLat, MinLon;
  char NoS, EoW;

  if ((gps_info.Altitude<0) || (gps_info.BaroAltitude<0)) return;

  DegLat = (int)gps_info.Location.Latitude;
  MinLat = gps_info.Location.Latitude - DegLat;
  NoS = 'N';
  if((MinLat<0) || ((MinLat-DegLat==0) && (DegLat<0)))
    {
      NoS = 'S';
      DegLat *= -1; MinLat *= -1;
    }
  MinLat *= 60;
  MinLat *= 1000;

  DegLon = (int)gps_info.Location.Longitude ;
  MinLon = gps_info.Location.Longitude  - DegLon;
  EoW = 'E';
  if((MinLon<0) || ((MinLon-DegLon==0) && (DegLon<0)))
    {
      EoW = 'W';
      DegLon *= -1; MinLon *= -1;
    }
  MinLon *=60;
  MinLon *= 1000;

  sprintf(szBRecord,"B%02d%02d%02d%02d%05.0f%c%03d%05.0f%cA%05d%05d\r\n",
          gps_info.Hour, gps_info.Minute, gps_info.Second,
          DegLat, MinLat, NoS, DegLon, MinLon, EoW,
          (int)gps_info.BaroAltitude,(int)gps_info.Altitude);

  IGCWriteRecord(szBRecord, szLoggerFileName);
}
示例#10
0
void
LoggerImpl::LoggerHeader(const NMEA_INFO &gps_info)
{
  char datum[]= "HFDTM100Datum: WGS-84\r\n";
  char temp[100];
  TCHAR PilotName[100];
  TCHAR AircraftType[100];
  TCHAR AircraftRego[100];

  // Flight recorder ID number MUST go first..
  sprintf(temp,
	  "AXCS%C%C%C\r\n",
	  strAssetNumber[0],
	  strAssetNumber[1],
	  strAssetNumber[2]);
  IGCWriteRecord(temp, szLoggerFileName);

  sprintf(temp,"HFDTE%02d%02d%02d\r\n",
	  gps_info.Day,
	  gps_info.Month,
	  gps_info.Year % 100);
  IGCWriteRecord(temp, szLoggerFileName);

  GetRegistryString(szRegistryPilotName, PilotName, 100);
  sprintf(temp,"HFPLTPILOT:%S\r\n", PilotName);
  IGCWriteRecord(temp, szLoggerFileName);

  GetRegistryString(szRegistryAircraftType, AircraftType, 100);
  sprintf(temp,"HFGTYGLIDERTYPE:%S\r\n", AircraftType);
  IGCWriteRecord(temp, szLoggerFileName);

  GetRegistryString(szRegistryAircraftRego, AircraftRego, 100);
  sprintf(temp,"HFGIDGLIDERID:%S\r\n", AircraftRego);
  IGCWriteRecord(temp, szLoggerFileName);

  sprintf(temp,"HFFTYFR TYPE:XCSOAR,XCSOAR %S\r\n", XCSoar_Version);
  IGCWriteRecord(temp, szLoggerFileName);

  IGCWriteRecord(datum, szLoggerFileName);

}
示例#11
0
文件: Logger.cpp 项目: Turbo87/LK8000
//
// This is called by Calc/Task thread, after calling StartLogger
//
void LoggerHeader(void)
{
  char datum[]= "HFDTM100GPSDATUM:WGS-84\r\n";
  char temp[100];
  
  // Flight recorder ID number MUST go first..

  // Do one more check on %C because if one is 0 the string will not be closed by newline
  // resulting in a wrong header!
  strAssetNumber[0]= IsAlphaNum(strAssetNumber[0]) ? strAssetNumber[0] : _T('A');
  strAssetNumber[1]= IsAlphaNum(strAssetNumber[1]) ? strAssetNumber[1] : _T('A');
  strAssetNumber[2]= IsAlphaNum(strAssetNumber[0]) ? strAssetNumber[2] : _T('A');

  sprintf(temp,
	  "A%s%C%C%C\r\n",
	  LOGGER_MANUFACTURER,
	  strAssetNumber[0],
	  strAssetNumber[1],
	  strAssetNumber[2]);
  IGCWriteRecord(temp);

  sprintf(temp,"HFDTE%02d%02d%02d\r\n",
	  GPS_INFO.Day,
	  GPS_INFO.Month,
	  GPS_INFO.Year % 100);
  IGCWriteRecord(temp);

  // Example: Hanna.Reitsch
  sprintf(temp,"HFPLTPILOT:%S\r\n", PilotName_Config);
  IGCWriteRecord(temp);

  // Example: DG-300
  sprintf(temp,"HFGTYGLIDERTYPE:%S\r\n", AircraftType_Config);
  IGCWriteRecord(temp);

  // Example: D-7176
  sprintf(temp,"HFGIDGLIDERID:%S\r\n", AircraftRego_Config);
  IGCWriteRecord(temp);

  // 110117 TOCHECK: maybe a 8 char limit is needed. 
  sprintf(temp,"HFCCLCOMPETITIONCLASS:%S\r\n", CompetitionClass_Config);
  IGCWriteRecord(temp);

  sprintf(temp,"HFCIDCOMPETITIONID:%S\r\n", CompetitionID_Config);
  IGCWriteRecord(temp);

    #ifndef LKCOMPETITION
  sprintf(temp,"HFFTYFRTYPE:%s\r\n", LKFORK); // default
    #else
  sprintf(temp,"HFFTYFRTYPE:%sC\r\n", LKFORK); // default
    #endif

  // PNAs are also PPC2003, so careful
  #ifdef PNA
  char pnamodel[MAX_PATH+1];
  ConvertTToC(pnamodel,GlobalModelName);
  pnamodel[_tcslen(GlobalModelName)]='\0';
    	#ifndef LKCOMPETITION
    sprintf(temp,"HFFTYFRTYPE:%s PNA %s\r\n", LKFORK,pnamodel);
	#else
    sprintf(temp,"HFFTYFRTYPE:%sC PNA %s\r\n", LKFORK,pnamodel);
	#endif
  #else

  #ifdef PPC2002 
    	#ifndef LKCOMPETITION
    sprintf(temp,"HFFTYFRTYPE:%s PPC2002\r\n", LKFORK);
	#else
    sprintf(temp,"HFFTYFRTYPE:%sC PPC2002\r\n", LKFORK);
	#endif
  #endif
  // PNA is also PPC2003..
  #ifdef PPC2003 
    	#ifndef LKCOMPETITION
    sprintf(temp,"HFFTYFRTYPE:%s PPC2003\r\n", LKFORK);
	#else
    sprintf(temp,"HFFTYFRTYPE:%sC PPC2003\r\n", LKFORK);
	#endif
  #endif

  #endif

  IGCWriteRecord(temp);

  #ifndef LKCOMPETITION
  sprintf(temp,"HFRFWFIRMWAREVERSION:%s.%s\r\n", LKVERSION, LKRELEASE);
  #else
  sprintf(temp,"HFRFWFIRMWAREVERSION:%s.%s.COMPETITION\r\n", LKVERSION, LKRELEASE);
  #endif
  IGCWriteRecord(temp);

  IGCWriteRecord(datum);

}
示例#12
0
文件: Logger.cpp 项目: Turbo87/LK8000
bool LogFRecordToFile(int SatelliteIDs[], short Hour, short Minute, short Second, bool bAlways)
{ // bAlways forces write when completing header for restart
  // only writes record if constallation has changed unless bAlways set
  #if (TESTBENCH && DEBUG_LOGGER)
  #else
  if (SIMMODE) return true;
  #endif
  char szFRecord[MAX_IGC_BUFF];
  static bool bFirst = true;
  int eof=0;
  int iNumberSatellites=0;
  bool bRetVal = false;

  if (bFirst)
  {
    bFirst = false;
    ResetFRecord_Internal();
  }


  sprintf(szFRecord,"F%02d%02d%02d", Hour, Minute, Second);
  eof=7;

  for (int i=0; i < MAXSATELLITES; i++)
  {
    if (SatelliteIDs[i] > 0)
    {
      sprintf(szFRecord+eof, "%02d",SatelliteIDs[i]);
      eof +=2;
      iNumberSatellites++;
    }
  }
  sprintf(szFRecord+ eof,"\r\n");

  // only write F Record if it has changed since last time
  // check every 4.5 minutes to see if it's changed.  Transient changes are not tracked.
  if (!bAlways 
        && strcmp(szFRecord + 7, szLastFRecord + 7) == 0
        && strlen(szFRecord) == strlen(szLastFRecord) )
  { // constellation has not changed 
      if (iNumberSatellites >=3)
        bRetVal=true;  // if the last FRecord had 3+ sats, then return true
                      //  and this causes 5-minute counter to reset
      else
        bRetVal=false;  // non-2d fix, don't reset 5-minute counter so
                        // we keep looking for changed constellations
  }
  else
  { // constellation has changed
    if (IGCWriteRecord(szFRecord))
    {
      strcpy(szLastFRecord, szFRecord);
      if (iNumberSatellites >=3)
        bRetVal=true;  // if we log an FRecord with a 3+ sats, then return true
                      //  and this causes 5-minute counter to reset
      else
        bRetVal=false;  // non-2d fix, log it, and don't reset 5-minute counter so
                        // we keep looking for changed constellations
    }
    else
    {  // IGCwrite failed 
      bRetVal = false;
    }

  }
  return bRetVal;

}
示例#13
0
//
//	259	still active, very bad
//	0	is the only OK that we want!
//	other values, very bad
//
int RunSignature() {

  DWORD retval=99;

  TCHAR homedir[MAX_PATH];
  TCHAR path[MAX_PATH];

  LocalPath(path,_T(LKD_LOGS));
  #if (WINDOWSPC>0)
  _tcscat(path,_T("\\LKRECORD_PC.LK8"));
  #endif

  // CAREFUL!!! PNA is ALSO PPC2003!!
  // 
  // ATTENTION: on PNA we are executing LKRECORD_PNA.LK8.EXE really
  #ifdef PNA
  _tcscat(path,_T("\\LKRECORD_PNA.LK8"));
  #else
    #ifdef PPC2002
    _tcscat(path,_T("\\LKRECORD_2002.LK8"));
    #endif
    #ifdef PPC2003
    _tcscat(path,_T("\\LKRECORD_2003.LK8"));
    #endif
  #endif 

  LocalPath(homedir,TEXT(LKD_LOGS));

  #if TESTBENCH
  StartupStore(_T(".... RunSignature: homedir <%s>%s"),homedir,NEWLINE);
  #endif


  PROCESS_INFORMATION pi;

  #if (WINDOWSPC>0)
  // Sadly, some parameters cannot be passed in the CE version
  STARTUPINFO si;
  ZeroMemory(&si,sizeof(STARTUPINFO));
  si.cb=sizeof(STARTUPINFO);
  si.wShowWindow= SW_SHOWNORMAL;
  si.dwFlags = STARTF_USESHOWWINDOW;

  if (!::CreateProcess(path,homedir, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) {
  #else
  if (!::CreateProcess(path,homedir, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &pi)) {
  #endif
	DWORD lasterr=GetLastError();

	if (lasterr!=2) {
		// External executable failure, bad !
		StartupStore(_T(".... RunSignature exec <%s> FAILED, error code=%d"),path,lasterr,NEWLINE);
		#if TESTBENCH
		StartupStore(_T(".... Trying with DoSignature\n"));
		#endif
	}

	#if TESTBENCH
	else 
		StartupStore(_T(".... no executable <%s> found, proceeding with DoSignature\n"),path);
	#endif

	extern int DoSignature(TCHAR *hpath);
	retval=DoSignature(homedir);

	return retval;
  }
  ::WaitForSingleObject(pi.hProcess, 30000); // 30s
  GetExitCodeProcess(pi.hProcess,&retval);
  // STILL_ACTIVE = 259, this retval should be checked for

  #if TESTBENCH
  StartupStore(_T(".... RunSignature exec <%s> terminated, retval=%d%s"),path,retval,NEWLINE);
  #endif


  return retval;

}


//
// Paolo+Durval: feed external headers to LK for PNAdump software
//
#define EXTHFILE	"COMPE.CNF"
//#define DEBUGHFILE	1

void AdditionalHeaders(void) {

  TCHAR pathfilename[MAX_PATH+1];
  wsprintf(pathfilename, TEXT("%s\\%s\\%S"), LKGetLocalPath(), TEXT(LKD_LOGS), EXTHFILE);

  if (GetFileAttributes(pathfilename) == 0xffffffff) {
	#if DEBUGHFILE
	StartupStore(_T("... No additional headers file <%s>\n"),pathfilename);
	#endif
	return;
  }

  #if DEBUGHFILE
  StartupStore(_T("... HFILE <%s> FOUND\n"),pathfilename);
  #endif

  HANDLE hfile = CreateFile(pathfilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

  if( hfile == INVALID_HANDLE_VALUE) {
	StartupStore(_T("... ERROR, extHFILE <%s> not found!%s"),pathfilename,NEWLINE);
	return;
  }

  #define MAXHLINE 100
  TCHAR tmpString[MAXHLINE+1];
  char tmps[MAXHLINE+1];
  //char line[MAXHLINE+12];
  tmpString[0]=0;


  while (ReadString(hfile, MAXHLINE, tmpString)) {
	size_t len = _tcslen(tmpString);

	if (len < 2) continue;
	if (tmpString[0]!='$' ) {
		#if DEBUGHFILE
		StartupStore(_T("Line skipped: <%s>\n"),tmpString);
		#endif
		continue;
	}

	// Remove trailing cr lf, three times to be sure
	if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) {
		tmpString[len - 1]= 0;
		len--;
	}
	if (len > 0) {
		if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) {
			tmpString[len - 1]= 0;
			len--;
		}
	}
	if (len > 0) {
		if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) {
			tmpString[len - 1]= 0;
		}
	}

	#if DEBUGHFILE
	StartupStore(_T("ADDING HEADER <%s>\n"),tmpString);
	#endif

	/*
	unicode2ascii(&tmpString[1],tmps,MAXHLINE);
	strcpy(line,"HFREMARK:");
	strcat(line,tmps);
	strcat(line,"\r\n");
	*/
	sprintf(tmps,"HFREMARK:%S\r\n",&tmpString[1]);
	
	IGCWriteRecord(tmps);
  }

  CloseHandle(hfile);

}