F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PosixTime.cpp
Go to the documentation of this file.
1 /*
2  * PosixTime.cpp
3  *
4  * Created on: Mar 28, 2014
5  * Author: tcanham
6  */
7 
8 #include <Fw/Time/Time.hpp>
10 #include <ctime>
11 
12 namespace Svc {
13 
14 PosixTime::PosixTime(const char* name) : PosixTimeComponentBase(name), m_timeContext(0) {}
15 
17 
19  this->m_timeContext = timeContext;
20 }
21 
23  Fw::Time& time
24 ) {
25  timespec stime = {};
26  if (clock_gettime(CLOCK_REALTIME, &stime) != 0) {
27  // report zero time rather than uninitialized garbage
28  stime.tv_sec = 0;
29  stime.tv_nsec = 0;
30  }
31  time.set(TimeBase::TB_WORKSTATION_TIME, this->m_timeContext, static_cast<U32>(stime.tv_sec),
32  static_cast<U32>(stime.tv_nsec / 1000));
33 }
34 } // namespace Svc
void setTimeContext(FwTimeContextStoreType timeContext)
Definition: PosixTime.cpp:18
virtual ~PosixTime()
Definition: PosixTime.cpp:16
Auto-generated base for PosixTime component.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
void timeGetPort_handler(FwIndexType portNum, Fw::Time &time)
Handler for input port timeGetPort.
Definition: PosixTime.cpp:22
void set(U32 seconds, U32 useconds)
Definition: Time.cpp:24
Time as reported on workstation where software is running. For testing. (Required) ...
PosixTime(const char *compName)
Definition: PosixTime.cpp:14
PlatformIndexType FwIndexType
RateGroupDivider component implementation.