mirror of
https://github.com/nasa/fpp.git
synced 2025-12-12 15:59:33 -06:00
226 lines
5.0 KiB
C++
Vendored
226 lines
5.0 KiB
C++
Vendored
// ======================================================================
|
|
// \title HealthTopologyAc.cpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief cpp file for Health topology
|
|
// ======================================================================
|
|
|
|
#include "HealthTopologyAc.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Component instances
|
|
// ----------------------------------------------------------------------
|
|
|
|
namespace M {
|
|
|
|
M::C c1(FW_OPTIONAL_NAME("c1"));
|
|
|
|
}
|
|
|
|
namespace M {
|
|
|
|
M::C c2(FW_OPTIONAL_NAME("c2"));
|
|
|
|
}
|
|
|
|
namespace M {
|
|
|
|
Svc::Health health(FW_OPTIONAL_NAME("health"));
|
|
|
|
}
|
|
|
|
namespace M {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Component configuration objects
|
|
// ----------------------------------------------------------------------
|
|
|
|
namespace ConfigObjects {
|
|
|
|
namespace M_health {
|
|
Svc::Health::PingEntry pingEntries[NUM_PING_ENTRIES] = {
|
|
{
|
|
PingEntries::M_c1::WARN,
|
|
PingEntries::M_c1::FATAL,
|
|
"M_c1"
|
|
},
|
|
{
|
|
PingEntries::M_c2::WARN,
|
|
PingEntries::M_c2::FATAL,
|
|
"M_c2"
|
|
},
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Helper functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
void initComponents(const TopologyState& state) {
|
|
M::c1.init(InstanceIds::M_c1);
|
|
M::c2.init(InstanceIds::M_c2);
|
|
M::health.init(InstanceIds::M_health);
|
|
}
|
|
|
|
void configComponents(const TopologyState& state) {
|
|
// Nothing to do
|
|
}
|
|
|
|
void setBaseIds() {
|
|
M::health.setIdBase(BaseIds::M_health);
|
|
M::c1.setIdBase(BaseIds::M_c1);
|
|
M::c2.setIdBase(BaseIds::M_c2);
|
|
}
|
|
|
|
void connectComponents() {
|
|
|
|
#ifndef FW_DIRECT_PORT_CALLS
|
|
|
|
// Health
|
|
M::c1.set_pingOut_OutputPort(
|
|
0,
|
|
M::health.get_pingIn_InputPort(0)
|
|
);
|
|
M::c2.set_pingOut_OutputPort(
|
|
0,
|
|
M::health.get_pingIn_InputPort(1)
|
|
);
|
|
M::health.set_pingOut_OutputPort(
|
|
0,
|
|
M::c1.get_pingIn_InputPort(0)
|
|
);
|
|
M::health.set_pingOut_OutputPort(
|
|
1,
|
|
M::c2.get_pingIn_InputPort(0)
|
|
);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
void regCommands() {
|
|
// Nothing to do
|
|
}
|
|
|
|
void readParameters() {
|
|
// Nothing to do
|
|
}
|
|
|
|
void loadParameters() {
|
|
// Nothing to do
|
|
}
|
|
|
|
void startTasks(const TopologyState& state) {
|
|
// Nothing to do
|
|
}
|
|
|
|
void stopTasks(const TopologyState& state) {
|
|
// Nothing to do
|
|
}
|
|
|
|
void freeThreads(const TopologyState& state) {
|
|
// Nothing to do
|
|
}
|
|
|
|
void tearDownComponents(const TopologyState& state) {
|
|
// Nothing to do
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Setup and teardown functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
void setup(const TopologyState& state) {
|
|
initComponents(state);
|
|
configComponents(state);
|
|
setBaseIds();
|
|
connectComponents();
|
|
regCommands();
|
|
readParameters();
|
|
loadParameters();
|
|
startTasks(state);
|
|
}
|
|
|
|
void teardown(const TopologyState& state) {
|
|
stopTasks(state);
|
|
freeThreads(state);
|
|
tearDownComponents(state);
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef FW_DIRECT_PORT_CALLS
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Topology-dependent component implementation
|
|
// ----------------------------------------------------------------------
|
|
|
|
namespace M {
|
|
|
|
bool CComponentBase::isConnected_pingOut_OutputPort(FwIndexType portNum) const {
|
|
FW_ASSERT((0 <= portNum) && (portNum < NUM_PINGOUT_OUTPUT_PORTS), static_cast<FwAssertArgType>(portNum));
|
|
bool result = false;
|
|
const auto instance = this->getInstance();
|
|
switch (instance) {
|
|
case ::M::InstanceIds::M_c1:
|
|
switch (portNum) {
|
|
case 0:
|
|
result = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ::M::InstanceIds::M_c2:
|
|
switch (portNum) {
|
|
case 0:
|
|
result = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// TODO: Implementation for CComponentBase::pingOut_out
|
|
|
|
}
|
|
|
|
namespace Svc {
|
|
|
|
bool HealthComponentBase::isConnected_pingOut_OutputPort(FwIndexType portNum) const {
|
|
FW_ASSERT((0 <= portNum) && (portNum < NUM_PINGOUT_OUTPUT_PORTS), static_cast<FwAssertArgType>(portNum));
|
|
bool result = false;
|
|
const auto instance = this->getInstance();
|
|
switch (instance) {
|
|
case ::M::InstanceIds::M_health:
|
|
switch (portNum) {
|
|
case 0:
|
|
result = true;
|
|
break;
|
|
case 1:
|
|
result = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// TODO: Implementation for HealthComponentBase::pingOut_out
|
|
|
|
}
|
|
|
|
#endif
|