Rename ActiveLogger to EventManager (#3920)

* Rename ActiveLogger to EventManager

* Spelling and link fixes

* Formatting and CMake API

* Remove UT_AUTO_HELPERS
This commit is contained in:
Thomas Boyer-Chammard 2025-07-23 10:41:24 -07:00 committed by GitHub
parent 0bb6d59230
commit 7ec2bb9a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 1092 additions and 1318 deletions

View File

@ -1,9 +1,5 @@
Aadil
AClass
ACTIVELOGGER
ACTIVELOGGERIMPL
ACTIVELOGGERIMPLCFG
ACTIVELOGGERIMPLTESTER
ACTIVERATEGROUP
ACTIVERATEGROUPCFG
ACTIVERATEGROUPTESTER

View File

@ -34,6 +34,7 @@ jobs:
Fw/Cmd
Fw/Com
Svc/Ccsds
Svc/EventManager
run: |
fprime-util format --check --dirs $CHECKED_DIRS
shell: bash

View File

@ -27,7 +27,7 @@ The following test case IDs are assigned:
Svc:
100 - ActiveLogger
100 - EventManager
101 - ActiveRateGroup
102 - CmdDispatcher
103 - CmdSequencer

View File

@ -23,7 +23,7 @@ It interconnects those application components with reusable service components:
|Component|Description|Link
|---|---|---|
|ActiveLogger|Logs events for downlink| [SDD](../../Svc/ActiveLogger/docs/sdd.md)|
|EventManager|Logs events for downlink| [SDD](../../Svc/EventManager/docs/sdd.md)|
|ActiveRateGroup|Executes a rate group by calling components| [SDD](../../Svc/ActiveRateGroup/docs/sdd.md)|
|BufferManager|Manages a pool of buffers| [SDD](../../Svc/BufferManager/docs/sdd.md)|
|CmdSequencer|Loads a set of commands from a binary file and executes them| [SDD](../../Svc/CmdSequencer/docs/sdd.md)|
@ -84,7 +84,7 @@ The connections for the reference deployment telemetry are as follows:
### 2.3 Logging
The logging view consists of connections for components to send events for logging to the `ActiveLogger` component.
The logging view consists of connections for components to send events for logging to the `EventManager` component.
#### 2.3.1 C&DH Logging

View File

@ -13,7 +13,7 @@ from fprime_gds.common.utils.event_severity import EventSeverity
"""
This enum is includes the values of EventSeverity that can be filtered by the ActiveLogger Component
This enum is includes the values of EventSeverity that can be filtered by the EventManager Component
"""
FilterSeverity = Enum(
"FilterSeverity",
@ -39,7 +39,7 @@ def test_is_streaming(fprime_test_api):
def set_event_filter(fprime_test_api, severity, enabled):
"""Send command to set event filter
This helper will send a command that updates the given severity filter on the ActiveLogger
This helper will send a command that updates the given severity filter on the EventManager
Component in the Ref App.
Args:

View File

@ -1,17 +0,0 @@
// ======================================================================
// ActiveLogger.hpp
// Standardization header for ActiveLogger
// ======================================================================
#ifndef Svc_ActiveLogger_HPP
#define Svc_ActiveLogger_HPP
#include "Svc/ActiveLogger/ActiveLoggerImpl.hpp"
namespace Svc {
typedef ActiveLoggerImpl ActiveLogger;
}
#endif

View File

@ -1,205 +0,0 @@
/*
* TestCommand1Impl.cpp
*
* Created on: Mar 28, 2014
* Author: tcanham
*/
#include <cstdio>
#include <Svc/ActiveLogger/ActiveLoggerImpl.hpp>
#include <Fw/Types/Assert.hpp>
#include <Os/File.hpp>
namespace Svc {
static_assert(std::numeric_limits<FwSizeType>::max() >= TELEM_ID_FILTER_SIZE, "TELEM_ID_FILTER_SIZE must fit within range of FwSizeType");
typedef ActiveLogger_Enabled Enabled;
typedef ActiveLogger_FilterSeverity FilterSeverity;
ActiveLoggerImpl::ActiveLoggerImpl(const char* name) :
ActiveLoggerComponentBase(name)
{
// set filter defaults
this->m_filterState[FilterSeverity::WARNING_HI].enabled =
FILTER_WARNING_HI_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
this->m_filterState[FilterSeverity::WARNING_LO].enabled =
FILTER_WARNING_LO_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
this->m_filterState[FilterSeverity::COMMAND].enabled =
FILTER_COMMAND_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
this->m_filterState[FilterSeverity::ACTIVITY_HI].enabled =
FILTER_ACTIVITY_HI_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
this->m_filterState[FilterSeverity::ACTIVITY_LO].enabled =
FILTER_ACTIVITY_LO_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
this->m_filterState[FilterSeverity::DIAGNOSTIC].enabled =
FILTER_DIAGNOSTIC_DEFAULT?Enabled::ENABLED:Enabled::DISABLED;
memset(m_filteredIDs,0,sizeof(m_filteredIDs));
}
ActiveLoggerImpl::~ActiveLoggerImpl() {
}
void ActiveLoggerImpl::LogRecv_handler(FwIndexType portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity& severity, Fw::LogBuffer &args) {
// make sure ID is not zero. Zero is reserved for ID filter.
FW_ASSERT(id != 0);
switch (severity.e) {
case Fw::LogSeverity::FATAL: // always pass FATAL
break;
case Fw::LogSeverity::WARNING_HI:
if (this->m_filterState[FilterSeverity::WARNING_HI].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::WARNING_LO:
if (this->m_filterState[FilterSeverity::WARNING_LO].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::COMMAND:
if (this->m_filterState[FilterSeverity::COMMAND].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::ACTIVITY_HI:
if (this->m_filterState[FilterSeverity::ACTIVITY_HI].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::ACTIVITY_LO:
if (this->m_filterState[FilterSeverity::ACTIVITY_LO].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::DIAGNOSTIC:
if (this->m_filterState[FilterSeverity::DIAGNOSTIC].enabled == Enabled::DISABLED) {
return;
}
break;
default:
FW_ASSERT(0,static_cast<FwAssertArgType>(severity.e));
return;
}
// check ID filters
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (
(m_filteredIDs[entry] == id) &&
(severity != Fw::LogSeverity::FATAL)
) {
return;
}
}
// send event to the logger thread
this->loqQueue_internalInterfaceInvoke(id,timeTag,severity,args);
// if connected, announce the FATAL
if (Fw::LogSeverity::FATAL == severity.e) {
if (this->isConnected_FatalAnnounce_OutputPort(0)) {
this->FatalAnnounce_out(0,id);
}
}
}
void ActiveLoggerImpl::loqQueue_internalInterfaceHandler(FwEventIdType id, const Fw::Time &timeTag, const Fw::LogSeverity& severity, const Fw::LogBuffer &args) {
// Serialize event
this->m_logPacket.setId(id);
this->m_logPacket.setTimeTag(timeTag);
this->m_logPacket.setLogBuffer(args);
this->m_comBuffer.resetSer();
Fw::SerializeStatus stat = this->m_logPacket.serialize(this->m_comBuffer);
FW_ASSERT(Fw::FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
if (this->isConnected_PktSend_OutputPort(0)) {
this->PktSend_out(0, this->m_comBuffer,0);
}
}
void ActiveLoggerImpl::SET_EVENT_FILTER_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, FilterSeverity filterLevel, Enabled filterEnable) {
this->m_filterState[filterLevel.e].enabled = filterEnable;
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
void ActiveLoggerImpl::SET_ID_FILTER_cmdHandler(
FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
FwEventIdType ID,
Enabled idEnabled //!< ID filter state
) {
if (Enabled::ENABLED == idEnabled.e) { // add ID
// search list for existing entry
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == ID) {
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(ID);
return;
}
}
// if not already a match, search for an open slot
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == 0) {
this->m_filteredIDs[entry] = ID;
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(ID);
return;
}
}
// if an empty slot was not found, send an error event
this->log_WARNING_LO_ID_FILTER_LIST_FULL(ID);
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR);
} else { // remove ID
// search list for existing entry
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == ID) {
this->m_filteredIDs[entry] = 0; // zero entry
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_REMOVED(ID);
return;
}
}
// if it gets here, wasn't found
this->log_WARNING_LO_ID_FILTER_NOT_FOUND(ID);
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR);
}
}
void ActiveLoggerImpl::DUMP_FILTER_STATE_cmdHandler(
FwOpcodeType opCode, //!< The opcode
U32 cmdSeq //!< The command sequence number
) {
// first, iterate through severity filters
for (FwEnumStoreType filter = 0; filter < FilterSeverity::NUM_CONSTANTS; filter++) {
FilterSeverity filterState(static_cast<FilterSeverity::t>(filter));
this->log_ACTIVITY_LO_SEVERITY_FILTER_STATE(
filterState,
Enabled::ENABLED == this->m_filterState[filter].enabled.e
);
}
// iterate through ID filter
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] != 0) {
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(this->m_filteredIDs[entry]);
}
}
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
void ActiveLoggerImpl::pingIn_handler(
const FwIndexType portNum,
U32 key
)
{
// return key
this->pingOut_out(0,key);
}
} // namespace Svc

View File

@ -1,67 +0,0 @@
/*
* ActiveLoggerImpl.hpp
*
* Created on: Mar 28, 2014
* Author: tcanham
*/
#ifndef ACTIVELOGGERIMPL_HPP_
#define ACTIVELOGGERIMPL_HPP_
#include <Svc/ActiveLogger/ActiveLoggerComponentAc.hpp>
#include <Fw/Log/LogPacket.hpp>
#include <config/ActiveLoggerImplCfg.hpp>
namespace Svc {
class ActiveLoggerImpl final : public ActiveLoggerComponentBase {
public:
ActiveLoggerImpl(const char* compName); //!< constructor
virtual ~ActiveLoggerImpl(); //!< destructor
protected:
private:
void LogRecv_handler(FwIndexType portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity& severity, Fw::LogBuffer &args);
void loqQueue_internalInterfaceHandler(FwEventIdType id, const Fw::Time &timeTag, const Fw::LogSeverity& severity, const Fw::LogBuffer &args);
void SET_EVENT_FILTER_cmdHandler(
FwOpcodeType opCode,
U32 cmdSeq,
ActiveLogger_FilterSeverity filterLevel,
ActiveLogger_Enabled filterEnabled);
void SET_ID_FILTER_cmdHandler(
FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
FwEventIdType ID,
ActiveLogger_Enabled idFilterEnabled //!< ID filter state
);
void DUMP_FILTER_STATE_cmdHandler(
FwOpcodeType opCode, //!< The opcode
U32 cmdSeq //!< The command sequence number
);
//! Handler implementation for pingIn
//!
void pingIn_handler(
const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
);
// Filter state
struct t_filterState {
ActiveLogger_Enabled enabled; //<! filter is enabled
} m_filterState[ActiveLogger_FilterSeverity::NUM_CONSTANTS];
// Working members
Fw::LogPacket m_logPacket; //!< packet buffer for assembling log packets
Fw::ComBuffer m_comBuffer; //!< com buffer for sending event buffers
// array of filtered event IDs.
// value of 0 means no entry
FwEventIdType m_filteredIDs[TELEM_ID_FILTER_SIZE];
};
}
#endif /* ACTIVELOGGERIMPL_HPP_ */

View File

@ -1,26 +0,0 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
#
# Note: using PROJECT_NAME as EXECUTABLE_NAME
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/ActiveLogger.fpp"
"${CMAKE_CURRENT_LIST_DIR}/ActiveLoggerImpl.cpp"
)
register_fprime_module()
### UTs ###
set(UT_SOURCE_FILES
"${FPRIME_FRAMEWORK_PATH}/Svc/ActiveLogger/ActiveLogger.fpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ActiveLoggerTestMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ActiveLoggerTester.cpp"
)
register_fprime_ut()
set (UT_TARGET_NAME "${FPRIME_CURRENT_MODULE}_ut_exe")
if (TARGET "${UT_TARGET_NAME}")
target_compile_options("${UT_TARGET_NAME}" PRIVATE -Wno-conversion)
endif()

View File

@ -1,86 +0,0 @@
Old Symbol
New Symbol
Svc::ActiveLoggerComponentBase::EventLevel
Svc::ActiveLogger_FilterSeverity
Svc::ActiveLoggerComponentBase::FILTER_WARNING_HI
Svc::ActiveLogger_FilterSeverity::WARNING_HI
Svc::ActiveLoggerComponentBase::FILTER_WARNING_LO
Svc::ActiveLogger_FilterSeverity::WARNING_LO
Svc::ActiveLoggerComponentBase::FILTER_COMMAND
Svc::ActiveLogger_FilterSeverity::COMMAND
Svc::ActiveLoggerComponentBase::FILTER_ACTIVITY_HI
Svc::ActiveLogger_FilterSeverity::ACTIVITY_HI
Svc::ActiveLoggerComponentBase::FILTER_ACTIVITY_LO
Svc::ActiveLogger_FilterSeverity::ACTIVITY_LO
Svc::ActiveLoggerComponentBase::FILTER_DIAGNOSTIC
Svc::ActiveLogger_FilterSeverity::DIAGNOSTIC
Svc::ActiveLoggerComponentBase::FilterEnabled
Svc::ActiveLogger_Enabled
Svc::ActiveLoggerComponentBase::FILTER_ENABLED
Svc::ActiveLogger_Enabled::ENABLED
Svc::ActiveLoggerComponentBase::FILTER_DISABLED
Svc::ActiveLogger_Enabled::DISABLED
Svc::ActiveLoggerComponentBase::IdFilterEnabled
Svc::ActiveLogger_Enabled
Svc::ActiveLoggerComponentBase::ID_ENABLED
Svc::ActiveLogger_Enabled::ENABLED
Svc::ActiveLoggerComponentBase::ID_DISABLED
Svc::ActiveLogger_Enabled::DISABLED
Svc::ActiveLoggerComponentBase::EventFilterState
Svc::ActiveLogger_FilterSeverity
Svc::ActiveLoggerComponentBase::FILT_WARNING_HI
Svc::ActiveLogger_FilterSeverity::WARNING_HI
Svc::ActiveLoggerComponentBase::FILT_WARNING_LO
Svc::ActiveLogger_FilterSeverity::WARNING_LO
Svc::ActiveLoggerComponentBase::FILT_COMMAND
Svc::ActiveLogger_FilterSeverity::COMMAND
Svc::ActiveLoggerComponentBase::FILT_ACTIVITY_HI
Svc::ActiveLogger_FilterSeverity::ACTIVITY_HI
Svc::ActiveLoggerComponentBase::FILT_ACTIVITY_LO
Svc::ActiveLogger_FilterSeverity::ACTIVITY_LO
Svc::ActiveLoggerComponentBase::FILT_DIAGNOSTIC
Svc::ActiveLogger_FilterSeverity::DIAGNOSTIC
Svc::ActiveLoggerComponentBase::QueueLogSeverity
Fw::LogSeverity
Svc::ActiveLoggerComponentBase::QUEUE_LOG_FATAL
Fw::LogSeverity::FATAL
Svc::ActiveLoggerComponentBase::QUEUE_LOG_WARNING_HI
Fw::LogSeverity::WARNING_HI
Svc::ActiveLoggerComponentBase::QUEUE_LOG_WARNING_LO
Fw::LogSeverity::WARNING_LO
Svc::ActiveLoggerComponentBase::QUEUE_LOG_COMMAND
Fw::LogSeverity::COMMAND
Svc::ActiveLoggerComponentBase::QUEUE_LOG_ACTIVITY_HI
Fw::LogSeverity::ACTIVITY_HI
Svc::ActiveLoggerComponentBase::QUEUE_LOG_ACTIVITY_LO
Fw::LogSeverity::ACTIVITY_LO
Svc::ActiveLoggerComponentBase::QUEUE_LOG_DIAGNOSTIC
Fw::LogSeverity::DIAGNOSTIC

View File

@ -1 +0,0 @@
*.html

View File

@ -1,156 +0,0 @@
/*
* ActiveLoggerTesterMain.cpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#include <Svc/ActiveLogger/test/ut/ActiveLoggerTester.hpp>
#include <Svc/ActiveLogger/ActiveLoggerImpl.hpp>
#include <Fw/Obj/SimpleObjRegistry.hpp>
#include <Fw/Test/UnitTest.hpp>
#include <gtest/gtest.h>
#if FW_OBJECT_REGISTRATION == 1
static Fw::SimpleObjRegistry simpleReg;
#endif
void connectPorts(Svc::ActiveLoggerImpl& impl, Svc::ActiveLoggerTester& tester) {
tester.connect_to_CmdDisp(0,impl.get_CmdDisp_InputPort(0));
impl.set_CmdStatus_OutputPort(0,tester.get_from_CmdStatus(0));
impl.set_FatalAnnounce_OutputPort(0,tester.get_from_FatalAnnounce(0));
tester.connect_to_LogRecv(0,impl.get_LogRecv_InputPort(0));
impl.set_Log_OutputPort(0,tester.get_from_Log(0));
impl.set_LogText_OutputPort(0,tester.get_from_LogText(0));
impl.set_PktSend_OutputPort(0,tester.get_from_PktSend(0));
#if FW_PORT_TRACING
// Fw::PortBase::setTrace(true);
#endif
// simpleReg.dump();
}
TEST(ActiveLoggerTest,NominalEventSend) {
TEST_CASE(100.1.1,"Nominal Event Logging");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runEventNominal();
}
TEST(ActiveLoggerTest,FilteredEventSend) {
TEST_CASE(100.1.2,"Nominal Event Filtering");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runFilterEventNominal();
}
TEST(ActiveLoggerTest,FilterIdTest) {
TEST_CASE(100.1.3,"Filter events by ID");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runFilterIdNominal();
}
TEST(ActiveLoggerTest,FilterDumpTest) {
TEST_CASE(100.1.3,"Dump filter values");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runFilterDump();
}
TEST(ActiveLoggerTest,InvalidCommands) {
TEST_CASE(100.2.1,"Off-Nominal Invalid Commands");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runFilterInvalidCommands();
}
TEST(ActiveLoggerTest,FatalTesting) {
TEST_CASE(100.2.2,"Off-Nominal FATAL processing");
Svc::ActiveLoggerImpl impl("ActiveLoggerImpl");
impl.init(10,0);
Svc::ActiveLoggerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl,tester);
tester.runEventFatal();
}
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,625 +0,0 @@
/*
* ActiveLoggerTester.cpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#include <Svc/ActiveLogger/test/ut/ActiveLoggerTester.hpp>
#include <Fw/Com/ComBuffer.hpp>
#include <Fw/Com/ComPacket.hpp>
#include <Os/IntervalTimer.hpp>
#include <gtest/gtest.h>
#include <Fw/Test/UnitTest.hpp>
#include <cstdio>
namespace Svc {
typedef ActiveLogger_Enabled Enabled;
typedef ActiveLogger_FilterSeverity FilterSeverity;
ActiveLoggerTester::ActiveLoggerTester(Svc::ActiveLoggerImpl& inst) :
Svc::ActiveLoggerGTestBase("testerbase",100),
m_impl(inst),
m_receivedPacket(false),
m_receivedFatalEvent(false) {
}
ActiveLoggerTester::~ActiveLoggerTester() {
}
void ActiveLoggerTester::from_PktSend_handler(
const FwIndexType portNum, //!< The port number
Fw::ComBuffer &data, //!< Buffer containing packet data
U32 context //!< context; not used
) {
this->m_sentPacket = data;
this->m_receivedPacket = true;
}
void ActiveLoggerTester::from_FatalAnnounce_handler(
const FwIndexType portNum, //!< The port number
FwEventIdType Id //!< The ID of the FATAL event
) {
this->m_receivedFatalEvent = true;
this->m_fatalID = Id;
}
void ActiveLoggerTester::runEventNominal() {
REQUIREMENT("AL-001");
this->writeEvent(29,Fw::LogSeverity::WARNING_HI,10);
}
void ActiveLoggerTester::runWithFilters(Fw::LogSeverity filter) {
REQUIREMENT("AL-002");
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 29;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
Fw::Time timeTag(TimeBase::TB_NONE,0,0);
U32 cmdSeq = 21;
// enable report filter
this->clearHistory();
FilterSeverity reportFilterLevel = FilterSeverity::WARNING_HI;
switch (filter.e) {
case Fw::LogSeverity::WARNING_HI:
reportFilterLevel = FilterSeverity::WARNING_HI;
break;
case Fw::LogSeverity::WARNING_LO:
reportFilterLevel = FilterSeverity::WARNING_LO;
break;
case Fw::LogSeverity::COMMAND:
reportFilterLevel = FilterSeverity::COMMAND;
break;
case Fw::LogSeverity::ACTIVITY_HI:
reportFilterLevel = FilterSeverity::ACTIVITY_HI;
break;
case Fw::LogSeverity::ACTIVITY_LO:
reportFilterLevel = FilterSeverity::ACTIVITY_LO;
break;
case Fw::LogSeverity::DIAGNOSTIC:
reportFilterLevel = FilterSeverity::DIAGNOSTIC;
break;
default:
ASSERT_TRUE(false);
break;
}
this->clearHistory();
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,reportFilterLevel,Enabled::ENABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,filter,buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(desc,static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(sentId,id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE,0,0);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(),0u);
// Disable severity filter
this->clearHistory();
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,reportFilterLevel,Enabled::DISABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,filter,buff);
// should not have received packet - all we can check since no message is dispatched.
ASSERT_FALSE(this->m_receivedPacket);
}
void ActiveLoggerTester::runFilterInvalidCommands() {
U32 cmdSeq = 21;
this->clearHistory();
FilterSeverity reportFilterLevel = FilterSeverity::WARNING_HI;
Enabled filterEnabled(static_cast<Enabled::t>(10));
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,reportFilterLevel,filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::FORMAT_ERROR
);
this->clearHistory();
reportFilterLevel = FilterSeverity::WARNING_HI;
filterEnabled.e = static_cast<Enabled::t>(-2);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,reportFilterLevel,filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::FORMAT_ERROR
);
FilterSeverity eventLevel;
this->clearHistory();
Enabled reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(-1);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,eventLevel,reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::FORMAT_ERROR
);
this->clearHistory();
reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(100);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,eventLevel,reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::FORMAT_ERROR
);
}
void ActiveLoggerTester::runFilterEventNominal() {
for (Fw::LogSeverity::t sev = Fw::LogSeverity::WARNING_HI; sev <= Fw::LogSeverity::DIAGNOSTIC; sev = static_cast<Fw::LogSeverity::t>(sev + 1)) {
this->runWithFilters(sev);
}
}
void ActiveLoggerTester::runFilterIdNominal() {
U32 cmdSeq = 21;
// for a set of IDs, fill filter
REQUIREMENT("AL-003");
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,filterID,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED(0,filterID);
// send it again, to verify it will accept a second add
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,filterID,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED(0,filterID);
}
// Try to send the IDs that are filtered
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = filterID;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
Fw::Time timeTag(TimeBase::TB_NONE,0,0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,Fw::LogSeverity::ACTIVITY_HI,buff);
// should not get a packet
ASSERT_FALSE(this->m_receivedPacket);
}
// send one of the IDs as a FATAL, it should not be filtered event thought the ID is in the filter
this->clearHistory();
this->clearEvents();
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 1;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
Fw::Time timeTag(TimeBase::TB_NONE,0,0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,Fw::LogSeverity::FATAL,buff);
this->m_impl.doDispatch();
// should get a packet anyway
ASSERT_TRUE(this->m_receivedPacket);
// Try to add to the full filter. It should be rejected
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,TELEM_ID_FILTER_SIZE+1,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::EXECUTION_ERROR
);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_LIST_FULL_SIZE(1);
ASSERT_EVENTS_ID_FILTER_LIST_FULL(0,TELEM_ID_FILTER_SIZE+1);
// Now clear them
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,filterID,Enabled::DISABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_REMOVED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_REMOVED(0,filterID);
}
// Try to clear one that doesn't exist
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,10,Enabled::DISABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::EXECUTION_ERROR
);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_NOT_FOUND_SIZE(1);
ASSERT_EVENTS_ID_FILTER_NOT_FOUND(0,10);
// Send an invalid argument
this->clearHistory();
this->clearEvents();
Enabled idEnabled(static_cast<Enabled::t>(10));
this->sendCmd_SET_ID_FILTER(0,cmdSeq,10,idEnabled);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_ID_FILTER,
cmdSeq,
Fw::CmdResponse::FORMAT_ERROR
);
ASSERT_EVENTS_SIZE(0);
}
void ActiveLoggerTester::runFilterDump() {
U32 cmdSeq = 21;
// set random set of filters
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::WARNING_HI,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::WARNING_LO,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::COMMAND,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::ACTIVITY_HI,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::ACTIVITY_LO,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,0,FilterSeverity::DIAGNOSTIC,Enabled::ENABLED);
this->sendCmd_SET_ID_FILTER(0,cmdSeq,4,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,13,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
this->sendCmd_SET_ID_FILTER(0,cmdSeq,4000,Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
// send command to dump the filters
this->clearHistory();
this->clearEvents();
this->sendCmd_DUMP_FILTER_STATE(0,cmdSeq);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_DUMP_FILTER_STATE,
cmdSeq,
Fw::CmdResponse::OK
);
ASSERT_EVENTS_SIZE(6+3);
ASSERT_EVENTS_SEVERITY_FILTER_STATE_SIZE(6);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(0,FilterSeverity::WARNING_HI,true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(1,FilterSeverity::WARNING_LO,false);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(2,FilterSeverity::COMMAND,true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(3,FilterSeverity::ACTIVITY_HI,false);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(4,FilterSeverity::ACTIVITY_LO,true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(5,FilterSeverity::DIAGNOSTIC,true);
}
void ActiveLoggerTester::runEventFatal() {
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 29;
U32 cmdSeq = 21;
REQUIREMENT("AL-004");
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
Fw::Time timeTag(TimeBase::TB_NONE,0,0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,Fw::LogSeverity::FATAL,buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// should have seen event port
ASSERT_TRUE(this->m_receivedFatalEvent);
ASSERT_EQ(this->m_fatalID,id);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(desc,static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(sentId,id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE,0,0);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(),0u);
// Turn on all filters and make sure FATAL still gets through
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::WARNING_HI,Enabled::DISABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(
0,
ActiveLoggerImpl::OPCODE_SET_EVENT_FILTER,
cmdSeq,
Fw::CmdResponse::OK
);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::WARNING_LO,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::COMMAND,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::ACTIVITY_HI,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::ACTIVITY_LO,Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::DIAGNOSTIC,Enabled::DISABLED);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,Fw::LogSeverity::FATAL,buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(desc,static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(sentId,id);
// next piece is time tag
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(),0u);
// turn off filters
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::WARNING_HI,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::WARNING_LO,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::COMMAND,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::ACTIVITY_HI,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::ACTIVITY_LO,Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0,cmdSeq,FilterSeverity::DIAGNOSTIC,Enabled::ENABLED);
}
void ActiveLoggerTester::writeEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value) {
Fw::LogBuffer buff;
Fw::SerializeStatus stat = buff.serialize(value);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
Fw::Time timeTag(TimeBase::TB_NONE,1,2);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0,id,timeTag,severity,buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(desc,static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(sentId,id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE,1,2);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK,stat);
ASSERT_EQ(readVal, value);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(),0u);
}
void ActiveLoggerTester::readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file) {
static const BYTE delimiter = 0xA5;
// first read should be delimiter
BYTE de;
FwSizeType readSize = static_cast<FwSizeType>(sizeof(de));
ASSERT_EQ(file.read(&de,readSize,Os::File::WaitType::WAIT),Os::File::OP_OK);
ASSERT_EQ(delimiter,de);
// next is LogPacket
Fw::ComBuffer comBuff;
// size is specific to this test
readSize = sizeof(FwPacketDescriptorType) + sizeof(FwEventIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32);
ASSERT_EQ(file.read(comBuff.getBuffAddr(),readSize,Os::File::WaitType::WAIT),Os::File::OP_OK);
comBuff.setBuffLen(readSize);
// deserialize LogPacket
Fw::LogPacket packet;
Fw::Time time(TimeBase::TB_NONE,1,2);
Fw::LogBuffer logBuff;
ASSERT_EQ(comBuff.deserialize(packet),Fw::FW_SERIALIZE_OK);
// read back values
ASSERT_EQ(id,packet.getId());
ASSERT_EQ(time,packet.getTimeTag());
logBuff = packet.getLogBuffer();
U32 readValue;
ASSERT_EQ(logBuff.deserialize(readValue),Fw::FW_SERIALIZE_OK);
ASSERT_EQ(value,readValue);
}
void ActiveLoggerTester::textLogIn(const FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
) {
TextLogEntry e = { id, timeTag, severity, text };
printTextLogHistoryEntry(e, stdout);
}
void ActiveLoggerTester ::
from_pingOut_handler(
const FwIndexType portNum,
U32 key
)
{
this->pushFromPortEntry_pingOut(key);
}
} /* namespace SvcTest */

View File

@ -1,80 +0,0 @@
/*
* ActiveLoggerTester.hpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#ifndef ACTIVELOGGER_TEST_UT_ACTIVELOGGER_TESTER_HPP_
#define ACTIVELOGGER_TEST_UT_ACTIVELOGGER_TESTER_HPP_
#include <ActiveLoggerGTestBase.hpp>
#include <Svc/ActiveLogger/ActiveLoggerImpl.hpp>
#include <Os/File.hpp>
namespace Svc {
class ActiveLoggerTester: public Svc::ActiveLoggerGTestBase {
public:
explicit ActiveLoggerTester(Svc::ActiveLoggerImpl& inst);
virtual ~ActiveLoggerTester();
void runEventNominal();
void runFilterEventNominal();
void runFilterIdNominal();
void runFilterDump();
void runFilterInvalidCommands();
void runEventFatal();
void runFileDump();
void runFileDumpErrors();
private:
void from_PktSend_handler(
const FwIndexType portNum, //!< The port number
Fw::ComBuffer &data, //!< Buffer containing packet data
U32 context //!< context (not used)
) override;
void from_FatalAnnounce_handler(
const FwIndexType portNum, //!< The port number
FwEventIdType Id //!< The ID of the FATAL event
) override;
Svc::ActiveLoggerImpl& m_impl;
bool m_receivedPacket;
Fw::ComBuffer m_sentPacket;
bool m_receivedFatalEvent;
FwEventIdType m_fatalID;
void runWithFilters(Fw::LogSeverity filter);
void writeEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value);
void readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file);
// enumeration to tell what kind of error to inject
typedef enum {
FILE_WRITE_WRITE_ERROR, // return a bad read status
FILE_WRITE_SIZE_ERROR, // return a bad size
} FileWriteTestType;
FileWriteTestType m_writeTestType;
FwSizeType m_writeSize;
void textLogIn(const FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
) override;
//! Handler for from_pingOut
//!
void from_pingOut_handler(
const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
) override;
};
} /* namespace Svc */
#endif /* ACTIVELOGGER_TEST_UT_ACTIVELOGGER_TESTER_HPP_ */

View File

@ -12,7 +12,6 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/WatchDog/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ports/")
# Components
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ActiveLogger/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ActiveRateGroup/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AssertFatalAdapter/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BufferAccumulator/")
@ -31,6 +30,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpCatalog/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpPorts/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpWriter/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/EventManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FileDownlinkPorts/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FileDownlink/")

View File

@ -0,0 +1,29 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
#
# Note: using PROJECT_NAME as EXECUTABLE_NAME
####
register_fprime_library(
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/EventManager.cpp"
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/EventManager.fpp"
)
### UTs ###
register_fprime_ut(
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/EventManagerTestMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/EventManagerTester.cpp"
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/EventManager.fpp"
)
set (UT_TARGET_NAME "${FPRIME_CURRENT_MODULE}_ut_exe")
if (TARGET "${UT_TARGET_NAME}")
target_compile_options("${UT_TARGET_NAME}" PRIVATE -Wno-conversion)
endif()

View File

@ -0,0 +1,196 @@
/*
* TestCommand1Impl.cpp
*
* Created on: Mar 28, 2014
* Author: tcanham
*/
#include <cstdio>
#include <Fw/Types/Assert.hpp>
#include <Os/File.hpp>
#include <Svc/EventManager/EventManager.hpp>
namespace Svc {
static_assert(std::numeric_limits<FwSizeType>::max() >= TELEM_ID_FILTER_SIZE,
"TELEM_ID_FILTER_SIZE must fit within range of FwSizeType");
typedef EventManager_Enabled Enabled;
typedef EventManager_FilterSeverity FilterSeverity;
EventManager::EventManager(const char* name) : EventManagerComponentBase(name) {
// set filter defaults
this->m_filterState[FilterSeverity::WARNING_HI].enabled =
FILTER_WARNING_HI_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
this->m_filterState[FilterSeverity::WARNING_LO].enabled =
FILTER_WARNING_LO_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
this->m_filterState[FilterSeverity::COMMAND].enabled =
FILTER_COMMAND_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
this->m_filterState[FilterSeverity::ACTIVITY_HI].enabled =
FILTER_ACTIVITY_HI_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
this->m_filterState[FilterSeverity::ACTIVITY_LO].enabled =
FILTER_ACTIVITY_LO_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
this->m_filterState[FilterSeverity::DIAGNOSTIC].enabled =
FILTER_DIAGNOSTIC_DEFAULT ? Enabled::ENABLED : Enabled::DISABLED;
memset(m_filteredIDs, 0, sizeof(m_filteredIDs));
}
EventManager::~EventManager() {}
void EventManager::LogRecv_handler(FwIndexType portNum,
FwEventIdType id,
Fw::Time& timeTag,
const Fw::LogSeverity& severity,
Fw::LogBuffer& args) {
// make sure ID is not zero. Zero is reserved for ID filter.
FW_ASSERT(id != 0);
switch (severity.e) {
case Fw::LogSeverity::FATAL: // always pass FATAL
break;
case Fw::LogSeverity::WARNING_HI:
if (this->m_filterState[FilterSeverity::WARNING_HI].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::WARNING_LO:
if (this->m_filterState[FilterSeverity::WARNING_LO].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::COMMAND:
if (this->m_filterState[FilterSeverity::COMMAND].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::ACTIVITY_HI:
if (this->m_filterState[FilterSeverity::ACTIVITY_HI].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::ACTIVITY_LO:
if (this->m_filterState[FilterSeverity::ACTIVITY_LO].enabled == Enabled::DISABLED) {
return;
}
break;
case Fw::LogSeverity::DIAGNOSTIC:
if (this->m_filterState[FilterSeverity::DIAGNOSTIC].enabled == Enabled::DISABLED) {
return;
}
break;
default:
FW_ASSERT(0, static_cast<FwAssertArgType>(severity.e));
return;
}
// check ID filters
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if ((m_filteredIDs[entry] == id) && (severity != Fw::LogSeverity::FATAL)) {
return;
}
}
// send event to the logger thread
this->loqQueue_internalInterfaceInvoke(id, timeTag, severity, args);
// if connected, announce the FATAL
if (Fw::LogSeverity::FATAL == severity.e) {
if (this->isConnected_FatalAnnounce_OutputPort(0)) {
this->FatalAnnounce_out(0, id);
}
}
}
void EventManager::loqQueue_internalInterfaceHandler(FwEventIdType id,
const Fw::Time& timeTag,
const Fw::LogSeverity& severity,
const Fw::LogBuffer& args) {
// Serialize event
this->m_logPacket.setId(id);
this->m_logPacket.setTimeTag(timeTag);
this->m_logPacket.setLogBuffer(args);
this->m_comBuffer.resetSer();
Fw::SerializeStatus stat = this->m_logPacket.serialize(this->m_comBuffer);
FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
if (this->isConnected_PktSend_OutputPort(0)) {
this->PktSend_out(0, this->m_comBuffer, 0);
}
}
void EventManager::SET_EVENT_FILTER_cmdHandler(FwOpcodeType opCode,
U32 cmdSeq,
FilterSeverity filterLevel,
Enabled filterEnable) {
this->m_filterState[filterLevel.e].enabled = filterEnable;
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void EventManager::SET_ID_FILTER_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
FwEventIdType ID,
Enabled idEnabled //!< ID filter state
) {
if (Enabled::ENABLED == idEnabled.e) { // add ID
// search list for existing entry
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == ID) {
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(ID);
return;
}
}
// if not already a match, search for an open slot
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == 0) {
this->m_filteredIDs[entry] = ID;
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(ID);
return;
}
}
// if an empty slot was not found, send an error event
this->log_WARNING_LO_ID_FILTER_LIST_FULL(ID);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
} else { // remove ID
// search list for existing entry
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] == ID) {
this->m_filteredIDs[entry] = 0; // zero entry
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
this->log_ACTIVITY_HI_ID_FILTER_REMOVED(ID);
return;
}
}
// if it gets here, wasn't found
this->log_WARNING_LO_ID_FILTER_NOT_FOUND(ID);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
}
}
void EventManager::DUMP_FILTER_STATE_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq //!< The command sequence number
) {
// first, iterate through severity filters
for (FwEnumStoreType filter = 0; filter < FilterSeverity::NUM_CONSTANTS; filter++) {
FilterSeverity filterState(static_cast<FilterSeverity::t>(filter));
this->log_ACTIVITY_LO_SEVERITY_FILTER_STATE(filterState,
Enabled::ENABLED == this->m_filterState[filter].enabled.e);
}
// iterate through ID filter
for (FwSizeType entry = 0; entry < TELEM_ID_FILTER_SIZE; entry++) {
if (this->m_filteredIDs[entry] != 0) {
this->log_ACTIVITY_HI_ID_FILTER_ENABLED(this->m_filteredIDs[entry]);
}
}
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void EventManager::pingIn_handler(const FwIndexType portNum, U32 key) {
// return key
this->pingOut_out(0, key);
}
} // namespace Svc

View File

@ -1,7 +1,7 @@
module Svc {
@ A component for logging events
active component ActiveLogger {
active component EventManager {
# ----------------------------------------------------------------------
# Types

View File

@ -0,0 +1,70 @@
/*
* EventManager.hpp
*
* Created on: Mar 28, 2014
* Author: tcanham
*/
#ifndef Svc_EventManager_HPP_
#define Svc_EventManager_HPP_
#include <Fw/Log/LogPacket.hpp>
#include <Svc/EventManager/EventManagerComponentAc.hpp>
#include <config/EventManagerCfg.hpp>
namespace Svc {
class EventManager final : public EventManagerComponentBase {
public:
EventManager(const char* compName); //!< constructor
virtual ~EventManager(); //!< destructor
private:
void LogRecv_handler(FwIndexType portNum,
FwEventIdType id,
Fw::Time& timeTag,
const Fw::LogSeverity& severity,
Fw::LogBuffer& args);
void loqQueue_internalInterfaceHandler(FwEventIdType id,
const Fw::Time& timeTag,
const Fw::LogSeverity& severity,
const Fw::LogBuffer& args);
void SET_EVENT_FILTER_cmdHandler(FwOpcodeType opCode,
U32 cmdSeq,
EventManager_FilterSeverity filterLevel,
EventManager_Enabled filterEnabled);
void SET_ID_FILTER_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
FwEventIdType ID,
EventManager_Enabled idFilterEnabled //!< ID filter state
);
void DUMP_FILTER_STATE_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq //!< The command sequence number
);
//! Handler implementation for pingIn
//!
void pingIn_handler(const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
);
// Filter state
struct t_filterState {
EventManager_Enabled enabled; //<! filter is enabled
} m_filterState[EventManager_FilterSeverity::NUM_CONSTANTS];
// Working members
Fw::LogPacket m_logPacket; //!< packet buffer for assembling log packets
Fw::ComBuffer m_comBuffer; //!< com buffer for sending event buffers
// array of filtered event IDs.
// value of 0 means no entry
FwEventIdType m_filteredIDs[TELEM_ID_FILTER_SIZE];
};
} // namespace Svc
#endif /* Svc_EventManager_HPP_ */

View File

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -1,21 +1,21 @@
# Svc::ActiveLogger Component
# Svc::EventManager Component
## 1. Introduction
The `Svc::ActiveLogger` component processes events from other components. The events are put in packets and sent to an
The `Svc::EventManager` component processes events from other components. The events are put in packets and sent to an
external component like the ground interface. The component provides event filtering capability such that events may
be turned off via ID or severity.
## 2. Requirements
The requirements for `Svc::ActiveLogger` are as follows:
The requirements for `Svc::EventManager` are as follows:
Requirement | Description | Verification Method
----------- | ----------- | -------------------
AL-001 | The `Svc::ActiveLogger` component shall receive events and compose them into downlink packets. | Inspection; Unit Test
AL-002 | The `Svc::ActiveLogger` component shall have commands to filter events based on event severity. | Unit Test
AL-003 | The `Svc::ActiveLogger` component shall have commands to filter events based on the event ID. | Unit Test
AL-004 | The `Svc::ActiveLogger` component shall call fatalOut port when FATAL is received | Inspection; Unit Test
AL-001 | The `Svc::EventManager` component shall receive events and compose them into downlink packets. | Inspection; Unit Test
AL-002 | The `Svc::EventManager` component shall have commands to filter events based on event severity. | Unit Test
AL-003 | The `Svc::EventManager` component shall have commands to filter events based on the event ID. | Unit Test
AL-004 | The `Svc::EventManager` component shall call fatalOut port when FATAL is received | Inspection; Unit Test
## 3. Design
@ -23,13 +23,13 @@ AL-004 | The `Svc::ActiveLogger` component shall call fatalOut port when FATAL i
#### 3.1.1 Component Diagram
The `Svc::ActiveLogger` component has the following component diagram:
The `Svc::EventManager` component has the following component diagram:
![`Svc::ActiveLogger` Diagram](img/ActiveLoggerBDD.jpg "Svc::ActiveLogger")
![`Svc::EventManager` Diagram](img/EventManagerBDD.jpg "Svc::EventManager")
#### 3.1.2 Ports
The `Svc::ActiveLogger` component uses the following port types:
The `Svc::EventManager` component uses the following port types:
Port Data Type | Name | Direction | Kind | Usage
-------------- | ---- | --------- | ---- | -----
@ -39,10 +39,10 @@ Port Data Type | Name | Direction | Kind | Usage
### 3.2 Functional Description
The `Svc::ActiveLogger` component provides an event logging function for the software. The framework autocoder allows
The `Svc::EventManager` component provides an event logging function for the software. The framework autocoder allows
developers to specify a set of events in the component FPP.
(see [Events](../../../docs/user-manual/overview/04-cmd-evt-chn-prm.md). For these components, the
autocoder will add an `Fw::Log` output port to send events in serialized form. The ActiveLogger receives these port
autocoder will add an `Fw::Log` output port to send events in serialized form. The EventManager receives these port
calls and provides commands to filter these events. The filtered events are sent to other components such as the ground
interface.
@ -53,9 +53,9 @@ event is seen.
#### 3.2.1 Filtering
The `Svc::ActiveLogger` `LogRecv` input port handler filters events to lessen the load on the downstream components. The
The `Svc::EventManager` `LogRecv` input port handler filters events to lessen the load on the downstream components. The
filters can be set by severity and ID. By default, the DIAGNOSTIC events are filtered out since the number of DIAGNOSTIC
events can be quite high. All defaults can be globally configured in `config/ActiveLoggerImplCfg.hpp`. Filters are
events can be quite high. All defaults can be globally configured in `config/EventManagerCfg.hpp`. Filters are
modified at runtime by the `SET_EVENT_FILTER` command.
The component also allows filtering events by event ID. There is a configuration parameter that sets the number of IDs
@ -69,7 +69,7 @@ the F´ ground format and sent out using the `PktSend` port.
#### 3.2.2 Fatal Announce
When the `ActiveLogger` component receives a FATAL event, it calls the FatalAnnounce port. Another component that
When the `EventManager` component receives a FATAL event, it calls the FatalAnnounce port. Another component that
handles the system response to FATALs (such as resetting the system) can connect to this port to be informed when a
FATAL has occurred.
@ -77,33 +77,25 @@ FATAL has occurred.
#### 3.3.1 Receive Events
The `Svc::ActiveLogger` component accepts events from other components.
The `Svc::EventManager` component accepts events from other components.
### 3.4 State
`Svc::ActiveLogger` has no state machines, but stores the state of the event severity and event ID filters.
`Svc::EventManager` has no state machines, but stores the state of the event severity and event ID filters.
### 3.5 Algorithms
`Svc::ActiveLogger` has no significant algorithms.
`Svc::EventManager` has no significant algorithms.
## 4. Dictionaries
TBD
## 5. Module Checklists
Checklist |
-------- |
[Design](Checklist_Design.xlsx) |
[Code](Checklist_Code.xlsx) |
[Unit Test](Checklist_Unit_Test.xls) |
## 6. Unit Testing
## 5. Unit Testing
To see unit test coverage run fprime-util check --coverage
## 7. Change Log
## 6. Change Log
Date | Description
---- | -----------

View File

@ -0,0 +1,143 @@
/*
* EventManagerTesterMain.cpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#include <Fw/Obj/SimpleObjRegistry.hpp>
#include <Fw/Test/UnitTest.hpp>
#include <Svc/EventManager/EventManager.hpp>
#include <Svc/EventManager/test/ut/EventManagerTester.hpp>
#include <gtest/gtest.h>
#if FW_OBJECT_REGISTRATION == 1
static Fw::SimpleObjRegistry simpleReg;
#endif
void connectPorts(Svc::EventManager& impl, Svc::EventManagerTester& tester) {
tester.connect_to_CmdDisp(0, impl.get_CmdDisp_InputPort(0));
impl.set_CmdStatus_OutputPort(0, tester.get_from_CmdStatus(0));
impl.set_FatalAnnounce_OutputPort(0, tester.get_from_FatalAnnounce(0));
tester.connect_to_LogRecv(0, impl.get_LogRecv_InputPort(0));
impl.set_Log_OutputPort(0, tester.get_from_Log(0));
impl.set_LogText_OutputPort(0, tester.get_from_LogText(0));
impl.set_PktSend_OutputPort(0, tester.get_from_PktSend(0));
#if FW_PORT_TRACING
// Fw::PortBase::setTrace(true);
#endif
// simpleReg.dump();
}
TEST(EventManagerTest, NominalEventSend) {
TEST_CASE(100.1.1, "Nominal Event Logging");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runEventNominal();
}
TEST(EventManagerTest, FilteredEventSend) {
TEST_CASE(100.1.2, "Nominal Event Filtering");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runFilterEventNominal();
}
TEST(EventManagerTest, FilterIdTest) {
TEST_CASE(100.1.3, "Filter events by ID");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runFilterIdNominal();
}
TEST(EventManagerTest, FilterDumpTest) {
TEST_CASE(100.1.3, "Dump filter values");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runFilterDump();
}
TEST(EventManagerTest, InvalidCommands) {
TEST_CASE(100.2.1, "Off-Nominal Invalid Commands");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runFilterInvalidCommands();
}
TEST(EventManagerTest, FatalTesting) {
TEST_CASE(100.2.2, "Off-Nominal FATAL processing");
Svc::EventManager impl("EventManager");
impl.init(10, 0);
Svc::EventManagerTester tester(impl);
tester.init();
// connect ports
connectPorts(impl, tester);
tester.runEventFatal();
}
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,534 @@
/*
* EventManagerTester.cpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#include <gtest/gtest.h>
#include <Fw/Com/ComBuffer.hpp>
#include <Fw/Com/ComPacket.hpp>
#include <Fw/Test/UnitTest.hpp>
#include <Os/IntervalTimer.hpp>
#include <Svc/EventManager/test/ut/EventManagerTester.hpp>
#include <cstdio>
namespace Svc {
typedef EventManager_Enabled Enabled;
typedef EventManager_FilterSeverity FilterSeverity;
EventManagerTester::EventManagerTester(Svc::EventManager& inst)
: Svc::EventManagerGTestBase("testerbase", 100),
m_impl(inst),
m_receivedPacket(false),
m_receivedFatalEvent(false) {}
EventManagerTester::~EventManagerTester() {}
void EventManagerTester::from_PktSend_handler(const FwIndexType portNum, //!< The port number
Fw::ComBuffer& data, //!< Buffer containing packet data
U32 context //!< context; not used
) {
this->m_sentPacket = data;
this->m_receivedPacket = true;
}
void EventManagerTester::from_FatalAnnounce_handler(const FwIndexType portNum, //!< The port number
FwEventIdType Id //!< The ID of the FATAL event
) {
this->m_receivedFatalEvent = true;
this->m_fatalID = Id;
}
void EventManagerTester::runEventNominal() {
REQUIREMENT("AL-001");
this->writeEvent(29, Fw::LogSeverity::WARNING_HI, 10);
}
void EventManagerTester::runWithFilters(Fw::LogSeverity filter) {
REQUIREMENT("AL-002");
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 29;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
Fw::Time timeTag(TimeBase::TB_NONE, 0, 0);
U32 cmdSeq = 21;
// enable report filter
this->clearHistory();
FilterSeverity reportFilterLevel = FilterSeverity::WARNING_HI;
switch (filter.e) {
case Fw::LogSeverity::WARNING_HI:
reportFilterLevel = FilterSeverity::WARNING_HI;
break;
case Fw::LogSeverity::WARNING_LO:
reportFilterLevel = FilterSeverity::WARNING_LO;
break;
case Fw::LogSeverity::COMMAND:
reportFilterLevel = FilterSeverity::COMMAND;
break;
case Fw::LogSeverity::ACTIVITY_HI:
reportFilterLevel = FilterSeverity::ACTIVITY_HI;
break;
case Fw::LogSeverity::ACTIVITY_LO:
reportFilterLevel = FilterSeverity::ACTIVITY_LO;
break;
case Fw::LogSeverity::DIAGNOSTIC:
reportFilterLevel = FilterSeverity::DIAGNOSTIC;
break;
default:
ASSERT_TRUE(false);
break;
}
this->clearHistory();
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, Enabled::ENABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::OK);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, filter, buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(desc, static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(sentId, id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE, 0, 0);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u);
// Disable severity filter
this->clearHistory();
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, Enabled::DISABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::OK);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, filter, buff);
// should not have received packet - all we can check since no message is dispatched.
ASSERT_FALSE(this->m_receivedPacket);
}
void EventManagerTester::runFilterInvalidCommands() {
U32 cmdSeq = 21;
this->clearHistory();
FilterSeverity reportFilterLevel = FilterSeverity::WARNING_HI;
Enabled filterEnabled(static_cast<Enabled::t>(10));
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
this->clearHistory();
reportFilterLevel = FilterSeverity::WARNING_HI;
filterEnabled.e = static_cast<Enabled::t>(-2);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, reportFilterLevel, filterEnabled);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
FilterSeverity eventLevel;
this->clearHistory();
Enabled reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(-1);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, eventLevel, reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
this->clearHistory();
reportEnable = Enabled::ENABLED;
eventLevel.e = static_cast<FilterSeverity::t>(100);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, eventLevel, reportEnable);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
}
void EventManagerTester::runFilterEventNominal() {
for (Fw::LogSeverity::t sev = Fw::LogSeverity::WARNING_HI; sev <= Fw::LogSeverity::DIAGNOSTIC;
sev = static_cast<Fw::LogSeverity::t>(sev + 1)) {
this->runWithFilters(sev);
}
}
void EventManagerTester::runFilterIdNominal() {
U32 cmdSeq = 21;
// for a set of IDs, fill filter
REQUIREMENT("AL-003");
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, filterID, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::OK);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED(0, filterID);
// send it again, to verify it will accept a second add
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, filterID, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::OK);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_ENABLED(0, filterID);
}
// Try to send the IDs that are filtered
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = filterID;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
Fw::Time timeTag(TimeBase::TB_NONE, 0, 0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, Fw::LogSeverity::ACTIVITY_HI, buff);
// should not get a packet
ASSERT_FALSE(this->m_receivedPacket);
}
// send one of the IDs as a FATAL, it should not be filtered event thought the ID is in the filter
this->clearHistory();
this->clearEvents();
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 1;
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
Fw::Time timeTag(TimeBase::TB_NONE, 0, 0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, Fw::LogSeverity::FATAL, buff);
this->m_impl.doDispatch();
// should get a packet anyway
ASSERT_TRUE(this->m_receivedPacket);
// Try to add to the full filter. It should be rejected
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, TELEM_ID_FILTER_SIZE + 1, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_LIST_FULL_SIZE(1);
ASSERT_EVENTS_ID_FILTER_LIST_FULL(0, TELEM_ID_FILTER_SIZE + 1);
// Now clear them
for (FwSizeType filterID = 1; filterID <= TELEM_ID_FILTER_SIZE; filterID++) {
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, filterID, Enabled::DISABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::OK);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_REMOVED_SIZE(1);
ASSERT_EVENTS_ID_FILTER_REMOVED(0, filterID);
}
// Try to clear one that doesn't exist
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, 10, Enabled::DISABLED);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_ID_FILTER_NOT_FOUND_SIZE(1);
ASSERT_EVENTS_ID_FILTER_NOT_FOUND(0, 10);
// Send an invalid argument
this->clearHistory();
this->clearEvents();
Enabled idEnabled(static_cast<Enabled::t>(10));
this->sendCmd_SET_ID_FILTER(0, cmdSeq, 10, idEnabled);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_ID_FILTER, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
ASSERT_EVENTS_SIZE(0);
}
void EventManagerTester::runFilterDump() {
U32 cmdSeq = 21;
// set random set of filters
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::WARNING_HI, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::WARNING_LO, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::COMMAND, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::ACTIVITY_HI, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::ACTIVITY_LO, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, 0, FilterSeverity::DIAGNOSTIC, Enabled::ENABLED);
this->sendCmd_SET_ID_FILTER(0, cmdSeq, 4, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, 13, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
this->sendCmd_SET_ID_FILTER(0, cmdSeq, 4000, Enabled::ENABLED);
// dispatch message
this->m_impl.doDispatch();
// send command to dump the filters
this->clearHistory();
this->clearEvents();
this->sendCmd_DUMP_FILTER_STATE(0, cmdSeq);
// dispatch message
this->m_impl.doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_DUMP_FILTER_STATE, cmdSeq, Fw::CmdResponse::OK);
ASSERT_EVENTS_SIZE(6 + 3);
ASSERT_EVENTS_SEVERITY_FILTER_STATE_SIZE(6);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(0, FilterSeverity::WARNING_HI, true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(1, FilterSeverity::WARNING_LO, false);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(2, FilterSeverity::COMMAND, true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(3, FilterSeverity::ACTIVITY_HI, false);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(4, FilterSeverity::ACTIVITY_LO, true);
ASSERT_EVENTS_SEVERITY_FILTER_STATE(5, FilterSeverity::DIAGNOSTIC, true);
}
void EventManagerTester::runEventFatal() {
Fw::LogBuffer buff;
U32 val = 10;
FwEventIdType id = 29;
U32 cmdSeq = 21;
REQUIREMENT("AL-004");
Fw::SerializeStatus stat = buff.serialize(val);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
Fw::Time timeTag(TimeBase::TB_NONE, 0, 0);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, Fw::LogSeverity::FATAL, buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// should have seen event port
ASSERT_TRUE(this->m_receivedFatalEvent);
ASSERT_EQ(this->m_fatalID, id);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(desc, static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(sentId, id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE, 0, 0);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u);
// Turn on all filters and make sure FATAL still gets through
this->clearHistory();
this->clearEvents();
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::WARNING_HI, Enabled::DISABLED);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, EventManager::OPCODE_SET_EVENT_FILTER, cmdSeq, Fw::CmdResponse::OK);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::WARNING_LO, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::COMMAND, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::ACTIVITY_HI, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::ACTIVITY_LO, Enabled::DISABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::DIAGNOSTIC, Enabled::DISABLED);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, Fw::LogSeverity::FATAL, buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(desc, static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(sentId, id);
// next piece is time tag
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(readVal, val);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u);
// turn off filters
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::WARNING_HI, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::WARNING_LO, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::COMMAND, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::ACTIVITY_HI, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::ACTIVITY_LO, Enabled::ENABLED);
this->sendCmd_SET_EVENT_FILTER(0, cmdSeq, FilterSeverity::DIAGNOSTIC, Enabled::ENABLED);
}
void EventManagerTester::writeEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value) {
Fw::LogBuffer buff;
Fw::SerializeStatus stat = buff.serialize(value);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
Fw::Time timeTag(TimeBase::TB_NONE, 1, 2);
this->m_receivedPacket = false;
this->invoke_to_LogRecv(0, id, timeTag, severity, buff);
// should not have received packet
ASSERT_FALSE(this->m_receivedPacket);
// dispatch message
this->m_impl.doDispatch();
// should have received packet
ASSERT_TRUE(this->m_receivedPacket);
// verify contents
// first piece should be log packet descriptor
FwPacketDescriptorType desc;
stat = this->m_sentPacket.deserialize(desc);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(desc, static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_LOG));
// next piece should be event ID
FwEventIdType sentId;
stat = this->m_sentPacket.deserialize(sentId);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(sentId, id);
// next piece is time tag
Fw::Time recTimeTag(TimeBase::TB_NONE, 1, 2);
stat = this->m_sentPacket.deserialize(recTimeTag);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_TRUE(timeTag == recTimeTag);
// next piece is event argument
U32 readVal;
stat = this->m_sentPacket.deserialize(readVal);
ASSERT_EQ(Fw::FW_SERIALIZE_OK, stat);
ASSERT_EQ(readVal, value);
// packet should be empty
ASSERT_EQ(this->m_sentPacket.getBuffLeft(), 0u);
}
void EventManagerTester::readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file) {
static const BYTE delimiter = 0xA5;
// first read should be delimiter
BYTE de;
FwSizeType readSize = static_cast<FwSizeType>(sizeof(de));
ASSERT_EQ(file.read(&de, readSize, Os::File::WaitType::WAIT), Os::File::OP_OK);
ASSERT_EQ(delimiter, de);
// next is LogPacket
Fw::ComBuffer comBuff;
// size is specific to this test
readSize = sizeof(FwPacketDescriptorType) + sizeof(FwEventIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32);
ASSERT_EQ(file.read(comBuff.getBuffAddr(), readSize, Os::File::WaitType::WAIT), Os::File::OP_OK);
comBuff.setBuffLen(readSize);
// deserialize LogPacket
Fw::LogPacket packet;
Fw::Time time(TimeBase::TB_NONE, 1, 2);
Fw::LogBuffer logBuff;
ASSERT_EQ(comBuff.deserialize(packet), Fw::FW_SERIALIZE_OK);
// read back values
ASSERT_EQ(id, packet.getId());
ASSERT_EQ(time, packet.getTimeTag());
logBuff = packet.getLogBuffer();
U32 readValue;
ASSERT_EQ(logBuff.deserialize(readValue), Fw::FW_SERIALIZE_OK);
ASSERT_EQ(value, readValue);
}
void EventManagerTester::textLogIn(const FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
) {
TextLogEntry e = {id, timeTag, severity, text};
printTextLogHistoryEntry(e, stdout);
}
void EventManagerTester ::from_pingOut_handler(const FwIndexType portNum, U32 key) {
this->pushFromPortEntry_pingOut(key);
}
} // namespace Svc

View File

@ -0,0 +1,76 @@
/*
* EventManagerTester.hpp
*
* Created on: Mar 18, 2015
* Author: tcanham
*/
#ifndef EventManager_TEST_UT_EventManager_TESTER_HPP_
#define EventManager_TEST_UT_EventManager_TESTER_HPP_
#include <EventManagerGTestBase.hpp>
#include <Os/File.hpp>
#include <Svc/EventManager/EventManager.hpp>
namespace Svc {
class EventManagerTester : public Svc::EventManagerGTestBase {
public:
explicit EventManagerTester(Svc::EventManager& inst);
virtual ~EventManagerTester();
void runEventNominal();
void runFilterEventNominal();
void runFilterIdNominal();
void runFilterDump();
void runFilterInvalidCommands();
void runEventFatal();
void runFileDump();
void runFileDumpErrors();
private:
void from_PktSend_handler(const FwIndexType portNum, //!< The port number
Fw::ComBuffer& data, //!< Buffer containing packet data
U32 context //!< context (not used)
) override;
void from_FatalAnnounce_handler(const FwIndexType portNum, //!< The port number
FwEventIdType Id //!< The ID of the FATAL event
) override;
Svc::EventManager& m_impl;
bool m_receivedPacket;
Fw::ComBuffer m_sentPacket;
bool m_receivedFatalEvent;
FwEventIdType m_fatalID;
void runWithFilters(Fw::LogSeverity filter);
void writeEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value);
void readEvent(FwEventIdType id, Fw::LogSeverity severity, U32 value, Os::File& file);
// enumeration to tell what kind of error to inject
typedef enum {
FILE_WRITE_WRITE_ERROR, // return a bad read status
FILE_WRITE_SIZE_ERROR, // return a bad size
} FileWriteTestType;
FileWriteTestType m_writeTestType;
FwSizeType m_writeSize;
void textLogIn(const FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
) override;
//! Handler for from_pingOut
//!
void from_pingOut_handler(const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
) override;
};
} /* namespace Svc */
#endif /* EventManager_TEST_UT_EventManager_TESTER_HPP_ */

View File

@ -1,6 +1,6 @@
This test can be run by executing the following:
From Svc/ActiveLogger:
From Svc/EventManager:
"make ut run_ut"

View File

@ -34,4 +34,4 @@ namespace Svc {
} /* namespace Svc */
#endif /* RATEGROUPDRIVER_TEST_UT_ACTIVELOGGERIMPLTESTER_HPP_ */
#endif

View File

@ -7,7 +7,7 @@ module CdhCore {
stack size CdhCoreConfig.StackSizes.cmdDisp \
priority CdhCoreConfig.Priorities.cmdDisp
instance events: Svc.ActiveLogger base id CdhCoreConfig.BASE_ID + 0x0200 \
instance events: Svc.EventManager base id CdhCoreConfig.BASE_ID + 0x0200 \
queue size CdhCoreConfig.QueueSizes.events \
stack size CdhCoreConfig.StackSizes.events \
priority CdhCoreConfig.Priorities.events

View File

@ -38,13 +38,13 @@ STANDARD_MODULES = [
]
REF_MODULES = [
"Svc_ActiveLogger",
"Svc_ActiveRateGroup",
"Svc_AssertFatalAdapter",
"Svc_BufferManager",
"Svc_CmdDispatcher",
"Svc_CmdSequencer",
"Svc_Cycle",
"Svc_EventManager",
"Svc_Fatal",
"Svc_FatalHandler",
"Svc_FileDownlink",

View File

@ -33,7 +33,7 @@ UNIT_TESTS = [
"Fw_Types_ut_exe",
"Os_ut_exe",
"Ref_SignalGen_ut_exe",
"Svc_ActiveLogger_ut_exe",
"Svc_EventManager_ut_exe",
"Svc_ActiveRateGroup_ut_exe",
"Svc_ActiveTextLogger_ut_exe",
"Svc_AssertFatalAdapter_ut_exe",

View File

@ -481,8 +481,8 @@ endfunction()
# 1. If passed a path, the module name is the '_'ed variant of the relative path from BUILD_ROOT
# 2. If passes something which does not exist on the file system, it is just '_'ed
#
# i.e. ${BUILD_ROOT}/Svc/ActiveLogger becomes Svc_ActiveLogger
# Svc/ActiveLogger also becomes Svc_ActiveLogger
# i.e. ${BUILD_ROOT}/Svc/EventManager becomes Svc_EventManager
# Svc/EventManager also becomes Svc_EventManager
#
# - **DIRECTORY_PATH:** (optional) path to infer MODULE_NAME from. Default: CMAKE_CURRENT_LIST_DIR
# - **Return: MODULE_NAME** (set in parent scope)

View File

@ -13,7 +13,7 @@ register_fprime_config(
"${CMAKE_CURRENT_LIST_DIR}/PolyDbCfg.fpp"
"${CMAKE_CURRENT_LIST_DIR}/VersionCfg.fpp"
HEADERS
"${CMAKE_CURRENT_LIST_DIR}/ActiveLoggerImplCfg.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EventManagerCfg.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ActiveRateGroupCfg.hpp"
"${CMAKE_CURRENT_LIST_DIR}/BufferManagerComponentImplCfg.hpp"
"${CMAKE_CURRENT_LIST_DIR}/CommandDispatcherImplCfg.hpp"

View File

@ -1,12 +1,12 @@
/*
* ActiveLoggerImplCfg.hpp
* EventManagerCfg.hpp
*
* Created on: Apr 16, 2015
* Author: tcanham
*/
#ifndef ACTIVELOGGER_ACTIVELOGGERIMPLCFG_HPP_
#define ACTIVELOGGER_ACTIVELOGGERIMPLCFG_HPP_
#ifndef Config_EventManagerCfg_HPP_
#define Config_EventManagerCfg_HPP_
// set default filters
@ -24,4 +24,4 @@ enum {
TELEM_ID_FILTER_SIZE = 25, //!< Size of telemetry ID filter
};
#endif /* ACTIVELOGGER_ACTIVELOGGERIMPLCFG_HPP_ */
#endif /* Config_EventManagerCfg_HPP_ */

View File

@ -75,7 +75,7 @@ while a successful response moves to the next command in the sequence.
Events represent a log of activities taken by the embedded system. Events can be thought of in the same way as a program
execution log in that they enable the ability to trace the execution of the system. Events are sent out of the system via
the `Svc::ActiveLogger` component and components defining events should hook up the log port to it. If console logging is
the `Svc::EventManager` component and components defining events should hook up the log port to it. If console logging is
desired, the text log port can be hooked up to the `Svc::PassiveConsoleTextLogger` component. Events are defined per
component and are typically used to capture what the component is doing. Events can occur sporadically; however, they
should all be captured for downlink. Events are defined by the following properties:
@ -108,7 +108,7 @@ events:
### Event Logging
Events first acquire a time tag to represent when they occurred and then are typically sent to the `Svc::ActiveLogger`
Events first acquire a time tag to represent when they occurred and then are typically sent to the `Svc::EventManager`
component on their way to be sent down to the ground. This logger component both processes the event and also recognizes
and begins responses for FATAL severity events.

View File

@ -157,7 +157,7 @@ methods. For these directories, each file will not be described, but a
higher-level description of what each directory contains will be given
instead. The descriptions are as follows.
### ActiveLogger
### EventManager
This directory contains a component FPP description and implementation
for an active component that accepts serialized log events. The input
@ -214,7 +214,7 @@ components. The port passes a time stamp indicating when the cycle started.
### Fatal
The directory specifies a port used to pass a notification that a FATAL
event has occurred. It is currently produced by the ActiveLogger
event has occurred. It is currently produced by the EventManager
component when it receives a FATAL event from a component.
### GndIf