void SBLog::initWithLogDir(const String& logDir) { // Nothing to do if log directory is empty if (logDir.empty()) return; // Create the log directory if (mkpath(logDir)) { SBLog::error() << "Failed to create \"" << logDir << "\" log directory. All log output will go to stderr." << std::endl; return; } // Create a unique filename std::stringstream ss; ss.precision(0); ss << std::fixed << logDir << "/ParseLog-" << getEpochTime() << ".log"; std::string logPath = ss.str(); // Try opening the log file std::ofstream* newFile = new std::ofstream(logPath.c_str()); if (!newFile->good()) { delete newFile; SBLog::error() << "Failed to open \"" << logPath << "\" log file for writing. All log output will go to stderr." << std::endl; return; } // Update the logger delete s_logger.m_logFile; s_logger.m_logFile = newFile; s_logger.m_logPath = logPath; s_logger.m_logStream.clear(); s_logger.m_logStream.addStream(*newFile); s_logger.m_errStream.addStream(*newFile); }
void DespatchTracker:: calcSecondsFromDeparture (double* secondsFromDeparture) const { double epochMjd; getEpochTime (&epochMjd); double epochUnixtime; tf:: convertMjdToUnixtime (&epochUnixtime, epochMjd); double departureUnixtime; tf:: convertMjdToUnixtime (&departureUnixtime, departureMjd_); double secondsFromEpoch; getSecondsFromEpoch (&secondsFromEpoch); *secondsFromDeparture = (epochUnixtime - departureUnixtime) + secondsFromEpoch; }
void SpacecraftTracker:: calcIntegrationPeriod (double* period) const { double epochMjd; getEpochTime (&epochMjd); double epochUnixtime; tf:: convertMjdToUnixtime (&epochUnixtime, epochMjd); double secondsFromEpoch; getSecondsFromEpoch (&secondsFromEpoch); double tFinal = unixtime_ - epochUnixtime; if (tFinal < 0.0) { cout << "[WARNING] Specified unixtime is smaller than the unixtime of the epoch" << endl; cout << "[WARNING] Specified unixtime: " << unixtime_ << ", Unixtime of the epoch: " << epochUnixtime << endl; } *period = tFinal - secondsFromEpoch; // period of the numerical integration }
void net_task (void const *arg) { uint8_t count; bool ntpSuccess; netTaskErr resultGetTime; netTaskId = osThreadGetId(); while (1) { osSignalWait(FLAG_NTP_REQ_START, osWaitForever); ntpSuccess = false; ledSetState(TASK_LED, LedOn); for (count = 0; count < DHCP_WAIT_TRIES; count++) { if ((localm[NETIF_ETH].IpAddr[0] != 0) || (localm[NETIF_ETH].IpAddr[1] != 0) || (localm[NETIF_ETH].IpAddr[2] != 0) || (localm[NETIF_ETH].IpAddr[3] != 0)) { resultGetTime = getEpochTime(); if (resultGetTime == errOK) { updateRtcTime(); ntpSuccess = true; break; } } else osDelay(DHCP_WAIT_DELAY_MS); } if (ntpSuccess == true) ledSetState(TASK_LED, LedOff); else { ledSetState(TASK_LED, LedBlink); //rerequest NTP time after delay scheldueNTPRequest(); } } }
/// used for template functions CommonTime getTimestamp() const throw() { return getEpochTime(); }
/// used for template functions DayTime getTimestamp() const throw(gpstk::InvalidRequest) { return getEpochTime(); }