Пример #1
0
void
LoggerImpl::guiStartLogger(const NMEA_INFO& gps_info,
                       const SETTINGS_COMPUTER& settings,
                       bool noAsk) {
  int i;
  if (!LoggerActive) {
    if (gps_info.Replay) {
      if (LoggerActive)
        guiStopLogger(gps_info, true);
      return;
    }
    TCHAR TaskMessage[1024];
    _tcscpy(TaskMessage,TEXT("Start Logger With Declaration\r\n"));
    if (task.Valid()) {
      for (i = 0; task.ValidTaskPoint(i); i++) {
        _tcscat(TaskMessage, task.getWaypoint(i).Name);
	_tcscat(TaskMessage,TEXT("\r\n"));
      }
    } else {
      _tcscat(TaskMessage,TEXT("None"));
    }

    if(noAsk ||
       (MessageBoxX(TaskMessage,gettext(TEXT("Start Logger")),
		    MB_YESNO|MB_ICONQUESTION) == IDYES))
      {

	if (LoggerClearFreeSpace(gps_info)) {

	  StartLogger(gps_info, settings, strAssetNumber);
	  LoggerHeader(gps_info);
	  LoggerActive = true; // start logger after Header is completed.  Concurrency

          if (task.Valid()) {
            int ntp = task.getFinalWaypoint();
            StartDeclaration(gps_info,ntp);
            for (i = 0; task.ValidTaskPoint(i); i++) {
              const WAYPOINT &way_point = task.getWaypoint(i);
              AddDeclaration(way_point.Location.Latitude,
                             way_point.Location.Longitude,
                             way_point.Name);
            }
            EndDeclaration();
          }
	  ResetFRecord(); // reset timer & lastRecord string so if
			  // logger is restarted, FRec appears at top
			  // of file
	} else {

	  MessageBoxX(
		      gettext(TEXT("Logger inactive, insufficient storage!")),
		      gettext(TEXT("Logger Error")), MB_OK| MB_ICONERROR);
	  StartupStore(TEXT("Logger not started: Insufficient Storage\r\n"));
	}
      }
  }
}
Пример #2
0
void
Logger::GUIStartLogger(const NMEAInfo& gps_info,
                    const ComputerSettings& settings,
                       const ProtectedTaskManager *protected_task_manager,
                    bool noAsk)
{
  if (IsLoggerActive() || gps_info.gps.replay)
    return;

  OrderedTask* task = protected_task_manager != nullptr
    ? protected_task_manager->TaskClone()
    : nullptr;
  const Declaration decl(settings.logger, settings.plane, task);

  if (task) {
    delete task;

    if (!noAsk) {
      TCHAR TaskMessage[1024];
      _tcscpy(TaskMessage, _T("Start Logger With Declaration\r\n"));
      
      if (decl.Size()) {
        for (unsigned i = 0; i< decl.Size(); ++i) {
          _tcscat(TaskMessage, decl.GetName(i));
          _tcscat(TaskMessage, _T("\r\n"));
        }
      } else {
        _tcscat(TaskMessage, _T("None"));
      }
      
      if (ShowMessageBox(TaskMessage, _("Start Logger"),
                      MB_YESNO | MB_ICONQUESTION) != IDYES)
        return;
    }
  }

  if (!LoggerClearFreeSpace(gps_info.date_time_utc.year)) {
    ShowMessageBox(_("Logger inactive, insufficient storage!"),
                _("Logger Error"), MB_OK| MB_ICONERROR);
    LogFormat("Logger not started: Insufficient Storage");
    return;
  }

  const ScopeExclusiveLock protect(lock);
  logger.StartLogger(gps_info, settings.logger, asset_number, decl);
}
Пример #3
0
void
Logger::guiStartLogger(const NMEA_INFO& gps_info,
                    const SETTINGS_COMPUTER& settings,
                       const ProtectedTaskManager &protected_task_manager,
                    bool noAsk)
{
  if (isLoggerActive() || gps_info.gps.Replay)
    return;

  OrderedTask* task = protected_task_manager.task_clone();
  Declaration decl(task);
  Profile::GetDeclarationConfig(decl, settings.plane);

  if (task) {
    delete task;

    if (!noAsk) {
      TCHAR TaskMessage[1024];
      _tcscpy(TaskMessage, _T("Start Logger With Declaration\r\n"));
      
      if (decl.size()) {
        for (unsigned i = 0; i< decl.size(); ++i) {
          _tcscat(TaskMessage, decl.get_name(i));
          _tcscat(TaskMessage, _T("\r\n"));
        }
      } else {
        _tcscat(TaskMessage, _T("None"));
      }
      
      if (MessageBoxX(TaskMessage, _("Start Logger"),
                      MB_YESNO | MB_ICONQUESTION) != IDYES)
        return;
    }
  }

  if (!LoggerClearFreeSpace(gps_info)) {
    MessageBoxX(_("Logger inactive, insufficient storage!"),
                _("Logger Error"), MB_OK| MB_ICONERROR);
    LogStartUp(_T("Logger not started: Insufficient Storage"));
    return;
  }

  Poco::ScopedRWLock protect(lock, true);
  _logger.StartLogger(gps_info, settings, strAssetNumber, decl);
}
Пример #4
0
void StopLogger(void) {
  TCHAR szMessage[(MAX_PATH*2)+1] = TEXT("\0");
  int iLoggerError=0;  // see switch statement for error handler
  TCHAR sztmplogfile[MAX_PATH+1] = TEXT("\0");
  int retval=0;

  _tcscpy(sztmplogfile,szLoggerFileName); // use LOGGER_TMP, unsigned

  if (LoggerActive) {
    LoggerActive = false;
    if (LoggerClearFreeSpace()) {

    #if (TESTBENCH && DEBUG_LOGGER)
    if (LoggerGActive())
    #else
    if (!SIMMODE && LoggerGActive())
    #endif
	{

	extern int RunSignature();
	retval = RunSignature();
	if (retval!=0) {
		StartupStore(_T(".... LOGGER SIGNATURE ERROR, CODE=%d%s"),retval,NEWLINE);
		switch(retval) {
			case -1:
				StartupStore(_T(".... (EXEQ DEBUG FAILURE)%s"),NEWLINE);
				break;
			case 1:
				StartupStore(_T(".... (SOURCE FILE DISAPPEARED)%s"),NEWLINE);
				break;
			case 3:
				StartupStore(_T(".... (EXEQ WITH WRONG ARGUMENTS)%s"),NEWLINE);
				break;
			case 4:
				StartupStore(_T(".... (BAD ENVIRONMENT)%s"),NEWLINE);
				break;
			case 11:
				StartupStore(_T(".... (LOGGER_TMP DISAPPEARED)%s"),NEWLINE);
				break;
			case 12:
				StartupStore(_T(".... (LOGGER_SIG ALREADY EXISTING)%s"),NEWLINE);
				break;
			case 21:
				StartupStore(_T(".... (MUTEX FAILURE=)%s"),NEWLINE);
				break;
			case 259:
				StartupStore(_T(".... (PROCESS DID NOT TERMINATE!)%s"),NEWLINE);
				break;
			default:
				break;
		}
		// we shall be moving LOGGER_TMP, and leave LOGGER_SIG untouched. In fact we do not know
		// if LOGGER_SIG is or will be available.
	} else {
		// RunSig ok, change logfile to new logger_sig
		StartupStore(_T(". Logger OK, IGC signed with G-Record%s"),NEWLINE);
		DeleteFile(szLoggerFileName);	// remove old LOGGER_TMP
		_tcscpy(sztmplogfile,szSLoggerFileName); // use LOGGER_SIG, signed
	}

	} // logger active

      int imCount=0;
      const int imMax=3;
      for (imCount=0; imCount < imMax; imCount++) {
        // MoveFile() nonzero==Success
        if (0 != MoveFile( sztmplogfile, szFLoggerFileName)) {
          iLoggerError=0;
          break; // success
        }
        Sleep(750); // wait for file system cache to fix itself?
      }
      if (imCount == imMax) { // MoveFile() failed all attempts

        if (0 == MoveFile( sztmplogfile, szFLoggerFileNameRoot)) { // try rename it and leave in root
          iLoggerError=1; //Fail.  NoMoveNoRename
        }
        else {
          iLoggerError=2; //NoMoveYesRename
        }
      }

    } // logger clearfreespace
    else { // Insufficient disk space.  // MoveFile() nonzero==Success
      if (0 == MoveFile( sztmplogfile, szFLoggerFileNameRoot)) { // try rename it and leave in root
        iLoggerError=3; //Fail.  Insufficient Disk Space, NoRename
      }
      else {
        iLoggerError=4; //Success.  Insufficient Disk Space, YesRename
      }
    }

    switch (iLoggerError) { //0=Success 1=NoMoveNoRename 2=NoMoveYesRename 3=NoSpaceNoRename 4=NoSpaceYesRename
    case 0:
      StartupStore(TEXT(". Logger: File saved %s%s"),WhatTimeIsIt(),NEWLINE);
      break;

    case 1: // NoMoveNoRename
      LK_tcsncpy(szMessage,TEXT("--- Logger file not copied.  It is in the root folder of your device and called "),MAX_PATH);
      _tcsncat(szMessage,sztmplogfile,MAX_PATH);

      MessageBoxX(hWndMapWindow,
		gettext(szMessage),
	// LKTOKEN  _@M404_ = "Logger Error" 
		gettext(TEXT("_@M404_")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT(SNEWLINE),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 2: // NoMoveYesRename
      LK_tcsncpy(szMessage,TEXT("--- Logger file not copied.  It is in the root folder of your device"),MAX_PATH);

      MessageBoxX(hWndMapWindow,
		gettext(szMessage),
	// LKTOKEN  _@M404_ = "Logger Error" 
		gettext(TEXT("_@M404_")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT(SNEWLINE),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 3: // Insufficient Storage.  NoRename
      LK_tcsncpy(szMessage,TEXT("++++++ Insuff. storage. Logger file in device's root folder, called "),MAX_PATH);
      _tcsncat(szMessage,sztmplogfile,MAX_PATH);

      MessageBoxX(hWndMapWindow,
		gettext(szMessage),
	// LKTOKEN  _@M404_ = "Logger Error" 
		gettext(TEXT("_@M404_")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT(SNEWLINE),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 4: // Insufficient Storage.  YesRename
      LK_tcsncpy(szMessage,TEXT("++++++ Insufficient storage.  Logger file is in the root folder of your device"),MAX_PATH);

      MessageBoxX(hWndMapWindow,
		gettext(szMessage),
	// LKTOKEN  _@M404_ = "Logger Error" 
		gettext(TEXT("_@M404_")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT(SNEWLINE),MAX_PATH);
      StartupStore(szMessage);
      break;
} // error handler

    NumLoggerBuffered = 0;
  }
}
Пример #5
0
void
LoggerImpl::StopLogger(const NMEA_INFO &gps_info) {
  TCHAR szMessage[MAX_PATH] = TEXT("\0");
  int iLoggerError=0;  // see switch statement for error handler
  if (LoggerActive) {
    LoggerActive = false;
    if (LoggerClearFreeSpace(gps_info)) {

      if (!is_simulator() && LoggerGActive())
        LoggerGStop(szLoggerFileName);

      int imCount=0;
      const int imMax=3;
      for (imCount=0; imCount < imMax; imCount++) {
        // MoveFile() nonzero==Success
        if (0 != MoveFile( szLoggerFileName, szFLoggerFileName)) {
          iLoggerError=0;
          break; // success
        }
        Sleep(750); // wait for file system cache to fix itself?
      }
      if (imCount == imMax) { // MoveFile() failed all attempts

        if (0 == MoveFile( szLoggerFileName, szFLoggerFileNameRoot)) { // try rename it and leave in root
          iLoggerError=1; //Fail.  NoMoveNoRename
        }
        else {
          iLoggerError=2; //NoMoveYesRename
        }
      }
    } else { // Insufficient disk space.  // MoveFile() nonzero==Success
      if (0 == MoveFile( szLoggerFileName, szFLoggerFileNameRoot)) { // try rename it and leave in root
        iLoggerError=3; //Fail.  Insufficient Disk Space, NoRename
      }
      else {
        iLoggerError=4; //Success.  Insufficient Disk Space, YesRename
      }
    }

    switch (iLoggerError) { //0=Success 1=NoMoveNoRename 2=NoMoveYesRename 3=NoSpaceNoRename 4=NoSpaceYesRename
    case 0:
      StartupStore(TEXT("Logger file successfully moved\r\n"));
      break;

    case 1: // NoMoveNoRename
      _tcsncpy(szMessage,TEXT("Logger file not copied.  It is in the root folder of your device and called "),MAX_PATH);
      _tcsncat(szMessage,szLoggerFileName,MAX_PATH);

      MessageBoxX(gettext(szMessage),
		gettext(TEXT("Logger Error")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT("\r\n"),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 2: // NoMoveYesRename
      _tcsncpy(szMessage,TEXT("Logger file not copied.  It is in the root folder of your device"),MAX_PATH);

      MessageBoxX(gettext(szMessage),
		gettext(TEXT("Logger Error")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT("\r\n"),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 3: // Insufficient Storage.  NoRename
      _tcsncpy(szMessage,TEXT("Insuff. storage. Logger file in device's root folder, called "),MAX_PATH);
      _tcsncat(szMessage,szLoggerFileName,MAX_PATH);

      MessageBoxX(gettext(szMessage),
		gettext(TEXT("Logger Error")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT("\r\n"),MAX_PATH);
      StartupStore(szMessage);
      break;

    case 4: // Insufficient Storage.  YesRename
      _tcsncpy(szMessage,TEXT("Insufficient storage.  Logger file is in the root folder of your device"),MAX_PATH);

      MessageBoxX(gettext(szMessage),
		gettext(TEXT("Logger Error")), MB_OK| MB_ICONERROR);
      _tcsncat(szMessage,TEXT("\r\n"),MAX_PATH);
      StartupStore(szMessage);
      break;
} // error handler

    NumLoggerBuffered = 0;
  }
}