Skip to content

Commit

Permalink
Convert Svc.Time into An Interface (nasa#2317)
Browse files Browse the repository at this point in the history
* Renaming of linux time files to posix

* Fixes nasa#2256. Renames LinuxTime into PosixTime implementing new Time interface

* sp

* Static analysis errors

* Cleaning up other LinuxTime references
  • Loading branch information
LeStarch authored Oct 25, 2023
1 parent 5e0b388 commit b5777e9
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 225 deletions.
4 changes: 2 additions & 2 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ignore$
^Fw/Types/Linux/StandardTypes\.hpp$
^requirements\.txt$
^RPI/settings\.ini$
^Svc/LinuxTime/LinuxTime\.hpp$
^Svc/PosixTime/PosixTime\.hpp$
^Svc/PrmDb/PrmDb\.hpp$
^Svc/TlmChan/TlmChan\.hpp$
^\.github/actions/spelling/
Expand All @@ -113,6 +113,6 @@ ignore$
^\Qrequirements.txt\E$
^\QSTest/README.md\E$
^\QSvc/FileDownlink/check.xml\E$
^\QSvc/LinuxTime/LinuxTime.hpp\E$
^\QSvc/PosixTime/PosixTime.hpp\E$
^\QSvc/PrmDb/PrmDb.hpp\E$
^\QSvc/TlmChan/TlmChan.hpp\E$
2 changes: 1 addition & 1 deletion RPI/Top/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(SOURCE_FILES
# Note: supply non-explicit dependencies here
set(MOD_DEPS
Fw/Logger
Svc/LinuxTime
Svc/PosixTime
# Communication Implementations
Drv/Udp
Drv/TcpClient
Expand Down
4 changes: 2 additions & 2 deletions RPI/Top/Components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <Svc/CmdSequencer/CmdSequencerImpl.hpp>
#include <Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp>
#include <Svc/ActiveLogger/ActiveLoggerImpl.hpp>
#include <Svc/LinuxTime/LinuxTimeImpl.hpp>
#include <Svc/PosixTime/PosixTime.hpp>
#include <Svc/LinuxTimer/LinuxTimerComponentImpl.hpp>
#include <Svc/TlmChan/TlmChanImpl.hpp>
#include <Svc/PrmDb/PrmDbImpl.hpp>
Expand Down Expand Up @@ -45,7 +45,7 @@ extern Svc::ActiveRateGroupImpl rateGroup1HzComp;
extern Svc::CmdSequencerComponentImpl cmdSeq;
extern Svc::ConsoleTextLoggerImpl textLogger;
extern Svc::ActiveLoggerImpl eventLogger;
extern Svc::LinuxTimeImpl linuxTime;
extern Svc::PosixTime posixTime;
extern Svc::LinuxTimerComponentImpl linuxTimer;
extern Svc::TlmChanImpl chanTlm;
extern Svc::CommandDispatcherImpl cmdDisp;
Expand Down
4 changes: 2 additions & 2 deletions RPI/Top/Topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Svc::ConsoleTextLoggerImpl textLogger("TLOG");

Svc::ActiveLoggerImpl eventLogger("ELOG");

Svc::LinuxTimeImpl linuxTime("LTIME");
Svc::PosixTime posixTime("LTIME");

Svc::LinuxTimerComponentImpl linuxTimer("LTIMER");

Expand Down Expand Up @@ -102,7 +102,7 @@ void constructApp(U32 port_number, char* hostname) {

eventLogger.init(10,0);

linuxTime.init(0);
posixTime.init(0);

linuxTimer.init(0);

Expand Down
4 changes: 1 addition & 3 deletions RPI/Top/instances.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ module RPI {

}

instance linuxTime: Svc.Time base id 1500 \
type "Svc::LinuxTime" \
at "../../Svc/LinuxTime/LinuxTime.hpp"
instance posixTime: Svc.PosixTime base id 1500

instance linuxTimer: Svc.LinuxTimer base id 1600 \
{
Expand Down
4 changes: 2 additions & 2 deletions RPI/Top/topology.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module RPI {
instance gpio24Drv
instance gpio25Drv
instance ledDrv
instance linuxTime
instance posixTime
instance linuxTimer
instance prmDb
instance rateGroup10HzComp
Expand Down Expand Up @@ -53,7 +53,7 @@ module RPI {

text event connections instance textLogger

time connections instance linuxTime
time connections instance posixTime

# ----------------------------------------------------------------------
# Direct graph specifiers
Expand Down
2 changes: 1 addition & 1 deletion Ref/Top/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(SOURCE_FILES
)
set(MOD_DEPS
Fw/Logger
Svc/LinuxTime
Svc/PosixTime
# Communication Implementations
Drv/Udp
Drv/TcpClient
Expand Down
4 changes: 1 addition & 3 deletions Ref/Top/instances.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ module Ref {

instance fileUplinkBufferManager: Svc.BufferManager base id 0x4400

instance linuxTime: Svc.Time base id 0x4500 \
type "Svc::LinuxTime" \
at "../../Svc/LinuxTime/LinuxTime.hpp"
instance posixTime: Svc.PosixTime base id 0x4500

instance rateGroupDriverComp: Svc.RateGroupDriver base id 0x4600

Expand Down
4 changes: 2 additions & 2 deletions Ref/Top/topology.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module Ref {
instance fileManager
instance fileUplink
instance fileUplinkBufferManager
instance linuxTime
instance posixTime
instance pingRcvr
instance prmDb
instance rateGroup1Comp
Expand Down Expand Up @@ -69,7 +69,7 @@ module Ref {

text event connections instance textLogger

time connections instance linuxTime
time connections instance posixTime

health connections instance $health

Expand Down
2 changes: 1 addition & 1 deletion Ref/docs/Ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
|Svc/PassiveConsoleTextLogger|[Link](../../Svc/PassiveConsoleTextLogger/docs/sdd.md)|
|Svc/Time|[Link](../../Svc/Time/docs/sdd.md)|
|Svc/Cycle|[Link](../../Svc/Cycle/docs/sdd.md)|
|Svc/LinuxTime|[Link](../../Svc/LinuxTime/docs/sdd.md)|
|Svc/PosixTime|[Link](../../Svc/PosixTime/docs/sdd.md)|
|Svc/ActiveLogger|[Link](../../Svc/ActiveLogger/docs/sdd.md)|
|Svc/Fatal|[Link](../../Svc/Fatal/docs/sdd.md)|
|Svc/PolyIf|[Link](../../Svc/PolyIf/docs/sdd.md)|
Expand Down
2 changes: 1 addition & 1 deletion Ref/docs/sdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ There is a set of useful utility components that can be used on supported operat

|Component|Description|Link
|---|---|---|
|LinuxTime|Provides time stamps for telemetry on a Linux system|[HTML](../../Svc/LinuxTime/docs/sdd.html) [MD](../../Svc/LinuxTime/docs/sdd.md)|
|PosixTime|Provides time stamps for telemetry on a posix systems|[HTML](../../Svc/PosixTime/docs/sdd.html) [MD](../../Svc/PosixTime/docs/sdd.md)|
|PassiveConsoleTextLogger|Prints the text form of events to standard output|[HTML](../../Svc/PassiveConsoleTextLogger/docs/sdd.html) [MD](../../Svc/PassiveConsoleTextLogger/docs/sdd.md)|
|SocketGndIf|Provides a socket for communicating with the ground system|[HTML](../../Svc/SocketGndIf/docs/sdd.html) [MD](../../Svc/SocketGndIf/docs/sdd.md)|

Expand Down
3 changes: 1 addition & 2 deletions Svc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PolyDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PrmDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RateGroupDriver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StaticMemory/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Time/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmChan/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmPacketizer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SystemResources/")
Expand All @@ -53,6 +52,6 @@ if (FPRIME_ENABLE_TEXT_LOGGERS)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTime/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/")
endif()
2 changes: 2 additions & 0 deletions Svc/Interfaces/Time.fppi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ Port to retrieve time
sync input port timeGetPort: Fw.Time
33 changes: 0 additions & 33 deletions Svc/LinuxTime/DarwinTimeImpl.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions Svc/LinuxTime/LinuxTime.hpp

This file was deleted.

5 changes: 0 additions & 5 deletions Svc/LinuxTime/README

This file was deleted.

32 changes: 0 additions & 32 deletions Svc/LinuxTime/VxWorksTimeImpl.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions Svc/LinuxTime/docs/sdd.md

This file was deleted.

13 changes: 5 additions & 8 deletions Svc/LinuxTime/CMakeLists.txt → Svc/PosixTime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
# Note: using PROJECT_NAME as EXECUTABLE_NAME
####
set(SOURCE_FILES
"${FPRIME_FRAMEWORK_PATH}/Svc/Time/Time.fpp"
"${CMAKE_CURRENT_LIST_DIR}/LinuxTimeImpl.cpp"
)
set(MOD_DEPS
Svc/Time
"${CMAKE_CURRENT_LIST_DIR}/PosixTime.fpp"
"${CMAKE_CURRENT_LIST_DIR}/PosixTime.cpp"
)

register_fprime_module()
### UTs ###
set(UT_SOURCE_FILES
"${FPRIME_FRAMEWORK_PATH}/Svc/Time/Time.fpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/LinuxTimeTester.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/LinuxTimeMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PosixTime.fpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/PosixTimeTester.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/PosixTimeMain.cpp"
)
register_fprime_ut()
13 changes: 4 additions & 9 deletions Svc/LinuxTime/LinuxTimeImpl.cpp → Svc/PosixTime/PosixTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,25 @@
* Author: tcanham
*/

#include <Svc/LinuxTime/LinuxTimeImpl.hpp>
#include <Svc/PosixTime/PosixTime.hpp>
#include <Fw/Time/Time.hpp>
#include <ctime>

namespace Svc {

LinuxTimeImpl::LinuxTimeImpl(const char* name) : TimeComponentBase(name)
PosixTime::PosixTime(const char* name) : PosixTimeComponentBase(name)
{
}

LinuxTimeImpl::~LinuxTimeImpl() {
PosixTime::~PosixTime() {
}

void LinuxTimeImpl::timeGetPort_handler(
void PosixTime::timeGetPort_handler(
NATIVE_INT_TYPE portNum, /*!< The port number*/
Fw::Time &time /*!< The U32 cmd argument*/
) {
timespec stime;
(void)clock_gettime(CLOCK_REALTIME,&stime);
time.set(TB_WORKSTATION_TIME,0, stime.tv_sec, stime.tv_nsec/1000);
}

void LinuxTimeImpl::init(NATIVE_INT_TYPE instance) {
TimeComponentBase::init(instance);
}

}
6 changes: 6 additions & 0 deletions Svc/PosixTime/PosixTime.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Svc {
@ A component for getting time
passive component PosixTime {
include "../Interfaces/Time.fppi"
}
}
15 changes: 7 additions & 8 deletions Svc/LinuxTime/LinuxTimeImpl.hpp → Svc/PosixTime/PosixTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
* Author: tcanham
*/

#ifndef LINUXTIMEIMPL_HPP_
#define LINUXTIMEIMPL_HPP_
#ifndef POSIX_TIME_HPP_
#define POSIX_TIME_HPP_

#include <Svc/Time/TimeComponentAc.hpp>
#include <Svc/PosixTime/PosixTimeComponentAc.hpp>

namespace Svc {

class LinuxTimeImpl: public TimeComponentBase {
class PosixTime: public PosixTimeComponentBase {
public:
LinuxTimeImpl(const char* compName);
virtual ~LinuxTimeImpl();
void init(NATIVE_INT_TYPE instance);
explicit PosixTime(const char* compName);
virtual ~PosixTime();
protected:
void timeGetPort_handler(
NATIVE_INT_TYPE portNum, /*!< The port number*/
Expand All @@ -27,4 +26,4 @@ class LinuxTimeImpl: public TimeComponentBase {

}

#endif /* LINUXTIMEIMPL_HPP_ */
#endif /* POSIX_TIME_HPP_ */
Loading

0 comments on commit b5777e9

Please sign in to comment.