mirror of
https://github.com/nasa/fpp.git
synced 2025-12-11 19:23:13 -06:00
Add tests for port calls
This commit is contained in:
parent
52cca509c8
commit
17895b4ca2
4
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/.gitignore
vendored
Normal file
4
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.xml
|
||||
*.o
|
||||
*Ac.*
|
||||
*Ai.*
|
||||
@ -0,0 +1,88 @@
|
||||
#ifndef TypedPortsActive_Receiver_HPP
|
||||
#define TypedPortsActive_Receiver_HPP
|
||||
|
||||
#include "ReceiverComponentAc.hpp"
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
class Receiver final :
|
||||
public ReceiverComponentBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Receiver() {
|
||||
|
||||
}
|
||||
|
||||
Receiver(const char* name) {
|
||||
|
||||
}
|
||||
|
||||
void p1_handler(
|
||||
FwIndexType portNum,
|
||||
U32 x1,
|
||||
F32 x2,
|
||||
bool x3,
|
||||
const Fw::StringBase& x4,
|
||||
const TypedPortsActive::A& x5,
|
||||
const TypedPortsActive::E& x6,
|
||||
const TypedPortsActive::S& x7
|
||||
) override {
|
||||
|
||||
}
|
||||
|
||||
U32 p2_handler(
|
||||
FwIndexType portNum,
|
||||
U32 x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
F32 p3_handler(
|
||||
FwIndexType portNum,
|
||||
F32 x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
bool p4_handler(
|
||||
FwIndexType portNum,
|
||||
bool x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
Fw::String p5_handler(
|
||||
FwIndexType portNum,
|
||||
const Fw::StringBase& x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
TypedPortsActive::A p6_handler(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::A& x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
TypedPortsActive::E p7_handler(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::E& x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
TypedPortsActive::S p8_handler(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::S& x
|
||||
) override {
|
||||
return x;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,26 @@
|
||||
#ifndef TypedPortsActive_Sender_HPP
|
||||
#define TypedPortsActive_Sender_HPP
|
||||
|
||||
#include "SenderComponentAc.hpp"
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
class Sender :
|
||||
public SenderComponentBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Sender() {
|
||||
|
||||
}
|
||||
|
||||
Sender(const char* name) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,5 @@
|
||||
namespace TypedPortsActive {
|
||||
|
||||
using TopologyState = int;
|
||||
|
||||
}
|
||||
27
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/check
Executable file
27
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/check
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
fpp_to_cpp=../../../../../../bin/fpp-to-cpp
|
||||
fprime_gcc=../../../../../../scripts/fprime-gcc
|
||||
|
||||
echo ' removing old files'
|
||||
./clean
|
||||
|
||||
base_dir=`cd ../..; echo $PWD`
|
||||
src_dir=$base_dir/typed_ports_active
|
||||
|
||||
echo ' generating C++'
|
||||
$fpp_to_cpp -p $base_dir,$src_dir $src_dir/components.fpp \
|
||||
$src_dir/topology.fpp
|
||||
|
||||
for suffix in hpp cpp
|
||||
do
|
||||
cp $src_dir/TypedPortsActiveTopologyAc.ref.$suffix TypedPortsActiveTopologyAc.$suffix
|
||||
done
|
||||
|
||||
flags="-I.. -I../../../fprime -I../../../fprime/config -Wno-unused-parameter -c"
|
||||
echo ' compiling C++'
|
||||
for variable_flags in '' '-DFW_DIRECT_PORT_CALLS'
|
||||
do
|
||||
echo " variable_flags=$variable_flags"
|
||||
$fprime_gcc $variable_flags $flags TypedPortsActiveTopologyAc.cpp
|
||||
done
|
||||
6
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/clean
Executable file
6
compiler/tools/fpp-to-cpp/test/top/check-cpp-dir/TypedPortsActive/clean
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
for file in `find . -name '*~' -or -name '*Ac.*' -or -name '*.o'`
|
||||
do
|
||||
rm $file
|
||||
done
|
||||
@ -3,4 +3,5 @@ Commands
|
||||
Health
|
||||
Params
|
||||
TlmPackets
|
||||
TypedPortsActive
|
||||
TypedPortsPassive
|
||||
|
||||
@ -56,3 +56,11 @@ typed_ports_passive()
|
||||
$src_dir/topology && \
|
||||
diff_cpp $src_dir/TypedPortsPassiveTopology
|
||||
}
|
||||
|
||||
typed_ports_active()
|
||||
{
|
||||
src_dir=$PWD/typed_ports_active
|
||||
run_test "-d $src_dir -p $PWD,$src_dir -i $src_dir/components.fpp" \
|
||||
$src_dir/topology && \
|
||||
diff_cpp $src_dir/TypedPortsActiveTopology
|
||||
}
|
||||
|
||||
@ -6,5 +6,6 @@ nested_namespaces
|
||||
no_namespace
|
||||
params
|
||||
tlm_packets
|
||||
typed_ports_active
|
||||
typed_ports_passive
|
||||
"
|
||||
|
||||
729
compiler/tools/fpp-to-cpp/test/top/typed_ports_active/TypedPortsActiveTopologyAc.ref.cpp
vendored
Normal file
729
compiler/tools/fpp-to-cpp/test/top/typed_ports_active/TypedPortsActiveTopologyAc.ref.cpp
vendored
Normal file
@ -0,0 +1,729 @@
|
||||
// ======================================================================
|
||||
// \title TypedPortsActiveTopologyAc.cpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief cpp file for TypedPortsActive topology
|
||||
// ======================================================================
|
||||
|
||||
#include "TypedPortsActiveTopologyAc.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Component instances
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
TypedPortsActive::Receiver receiver(FW_OPTIONAL_NAME("receiver"));
|
||||
|
||||
}
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
TypedPortsActive::Sender sender(FW_OPTIONAL_NAME("sender"));
|
||||
|
||||
}
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void initComponents(const TopologyState& state) {
|
||||
TypedPortsActive::receiver.init(QueueSizes::TypedPortsActive_receiver, InstanceIds::TypedPortsActive_receiver);
|
||||
TypedPortsActive::sender.init(InstanceIds::TypedPortsActive_sender);
|
||||
}
|
||||
|
||||
void configComponents(const TopologyState& state) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void setBaseIds() {
|
||||
TypedPortsActive::sender.setIdBase(BaseIds::TypedPortsActive_sender);
|
||||
TypedPortsActive::receiver.setIdBase(BaseIds::TypedPortsActive_receiver);
|
||||
}
|
||||
|
||||
void connectComponents() {
|
||||
|
||||
#ifndef FW_DIRECT_PORT_CALLS
|
||||
|
||||
// C
|
||||
TypedPortsActive::sender.set_p1_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p1_InputPort(1)
|
||||
);
|
||||
TypedPortsActive::sender.set_p1_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p1_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p2_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p2_InputPort(1)
|
||||
);
|
||||
TypedPortsActive::sender.set_p2_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p2_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p3_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p3_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p3_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p3_InputPort(1)
|
||||
);
|
||||
TypedPortsActive::sender.set_p4_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p4_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p4_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p4_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p5_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p5_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p5_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p5_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p6_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p6_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p6_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p6_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p7_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p7_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p7_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p7_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p8_OutputPort(
|
||||
0,
|
||||
TypedPortsActive::receiver.get_p8_InputPort(0)
|
||||
);
|
||||
TypedPortsActive::sender.set_p8_OutputPort(
|
||||
1,
|
||||
TypedPortsActive::receiver.get_p8_InputPort(0)
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void regCommands() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void readParameters() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void loadParameters() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void startTasks(const TopologyState& state) {
|
||||
TypedPortsActive::receiver.start(
|
||||
Os::Task::TASK_PRIORITY_DEFAULT, // Default priority
|
||||
static_cast<Os::Task::ParamType>(StackSizes::TypedPortsActive_receiver),
|
||||
Os::Task::TASK_DEFAULT, // Default CPU
|
||||
static_cast<Os::Task::ParamType>(TaskIds::TypedPortsActive_receiver)
|
||||
);
|
||||
}
|
||||
|
||||
void stopTasks(const TopologyState& state) {
|
||||
TypedPortsActive::receiver.exit();
|
||||
}
|
||||
|
||||
void freeThreads(const TopologyState& state) {
|
||||
(void) TypedPortsActive::receiver.ActiveComponentBase::join();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if FW_DIRECT_PORT_CALLS
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Topology-dependent component implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
bool SenderComponentBase::isConnected_p1_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P1_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P1_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p2_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P2_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P2_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p3_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P3_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P3_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p4_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P4_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P4_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p5_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P5_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P5_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p6_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P6_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P6_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p7_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P7_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P7_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::isConnected_p8_OutputPort(FwIndexType portNum) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P8_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P8_OUTPUT_PORTS)
|
||||
);
|
||||
bool result = false;
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
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;
|
||||
}
|
||||
|
||||
void SenderComponentBase::p1_out(
|
||||
FwIndexType portNum,
|
||||
U32 x1,
|
||||
F32 x2,
|
||||
bool x3,
|
||||
const Fw::StringBase& x4,
|
||||
const TypedPortsActive::A& x5,
|
||||
const TypedPortsActive::E& x6,
|
||||
const TypedPortsActive::S& x7
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P1_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P1_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
TypedPortsActive::receiver.p1_handlerBase(
|
||||
1,
|
||||
x1,
|
||||
x2,
|
||||
x3,
|
||||
x4,
|
||||
x5,
|
||||
x6,
|
||||
x7
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
TypedPortsActive::receiver.p1_handlerBase(
|
||||
0,
|
||||
x1,
|
||||
x2,
|
||||
x3,
|
||||
x4,
|
||||
x5,
|
||||
x6,
|
||||
x7
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U32 SenderComponentBase::p2_out(
|
||||
FwIndexType portNum,
|
||||
U32 x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P2_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P2_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
U32 _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p2_handlerBase(
|
||||
1,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p2_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
F32 SenderComponentBase::p3_out(
|
||||
FwIndexType portNum,
|
||||
F32 x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P3_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P3_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
F32 _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p3_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p3_handlerBase(
|
||||
1,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
bool SenderComponentBase::p4_out(
|
||||
FwIndexType portNum,
|
||||
bool x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P4_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P4_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
bool _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p4_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p4_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
Fw::String SenderComponentBase::p5_out(
|
||||
FwIndexType portNum,
|
||||
const Fw::StringBase& x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P5_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P5_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
Fw::String _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p5_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p5_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
TypedPortsActive::A SenderComponentBase::p6_out(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::A& x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P6_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P6_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
TypedPortsActive::A _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p6_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p6_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
TypedPortsActive::E SenderComponentBase::p7_out(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::E& x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P7_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P7_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
TypedPortsActive::E _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p7_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p7_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
TypedPortsActive::S SenderComponentBase::p8_out(
|
||||
FwIndexType portNum,
|
||||
const TypedPortsActive::S& x
|
||||
) const {
|
||||
FW_ASSERT(
|
||||
(0 <= portNum) && (portNum < NUM_P8_OUTPUT_PORTS),
|
||||
static_cast<FwAssertArgType>(portNum),
|
||||
static_cast<FwAssertArgType>(NUM_P8_OUTPUT_PORTS)
|
||||
);
|
||||
const auto instance = this->getInstance();
|
||||
TypedPortsActive::S _result = {};
|
||||
switch (instance) {
|
||||
case ::TypedPortsActive::InstanceIds::TypedPortsActive_sender:
|
||||
switch (portNum) {
|
||||
case 0:
|
||||
_result = TypedPortsActive::receiver.p8_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_result = TypedPortsActive::receiver.p8_handlerBase(
|
||||
0,
|
||||
x
|
||||
);
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(portNum));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
|
||||
break;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
135
compiler/tools/fpp-to-cpp/test/top/typed_ports_active/TypedPortsActiveTopologyAc.ref.hpp
vendored
Normal file
135
compiler/tools/fpp-to-cpp/test/top/typed_ports_active/TypedPortsActiveTopologyAc.ref.hpp
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
// ======================================================================
|
||||
// \title TypedPortsActiveTopologyAc.hpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief hpp file for TypedPortsActive topology
|
||||
// ======================================================================
|
||||
|
||||
#ifndef TypedPortsActive_TypedPortsActiveTopologyAc_HPP
|
||||
#define TypedPortsActive_TypedPortsActiveTopologyAc_HPP
|
||||
|
||||
#include "Receiver.hpp"
|
||||
#include "Sender.hpp"
|
||||
#include "TypedPortsActiveTopologyDefs.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Component instances
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
//! receiver
|
||||
extern TypedPortsActive::Receiver receiver;
|
||||
|
||||
}
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
//! sender
|
||||
extern TypedPortsActive::Sender sender;
|
||||
|
||||
}
|
||||
|
||||
namespace TypedPortsActive {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace BaseIds {
|
||||
enum {
|
||||
TypedPortsActive_sender = 0x100,
|
||||
TypedPortsActive_receiver = 0x200,
|
||||
};
|
||||
}
|
||||
|
||||
namespace InstanceIds {
|
||||
enum {
|
||||
TypedPortsActive_receiver,
|
||||
TypedPortsActive_sender,
|
||||
};
|
||||
}
|
||||
|
||||
namespace QueueSizes {
|
||||
enum {
|
||||
TypedPortsActive_receiver = 10,
|
||||
};
|
||||
}
|
||||
|
||||
namespace StackSizes {
|
||||
enum {
|
||||
TypedPortsActive_receiver = 1024,
|
||||
};
|
||||
}
|
||||
|
||||
namespace TaskIds {
|
||||
enum {
|
||||
TypedPortsActive_receiver,
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Initialize components
|
||||
void initComponents(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Configure components
|
||||
void configComponents(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Set component base Ids
|
||||
void setBaseIds();
|
||||
|
||||
//! Connect components
|
||||
void connectComponents();
|
||||
|
||||
//! Register commands
|
||||
void regCommands();
|
||||
|
||||
//! Read parameters
|
||||
void readParameters();
|
||||
|
||||
//! Load parameters
|
||||
void loadParameters();
|
||||
|
||||
//! Start tasks
|
||||
void startTasks(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Stop tasks
|
||||
void stopTasks(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Free threads
|
||||
void freeThreads(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Tear down components
|
||||
void tearDownComponents(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Setup and teardown functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Set up the topology
|
||||
void setup(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
//! Tear down the topology
|
||||
void teardown(
|
||||
const TopologyState& state //!< The topology state
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,50 @@
|
||||
module TypedPortsActive {
|
||||
|
||||
array A = [3] U32
|
||||
enum E { A, B }
|
||||
struct S { x: U32 }
|
||||
|
||||
port P1(
|
||||
x1: U32,
|
||||
x2: F32,
|
||||
x3: bool,
|
||||
x4: string,
|
||||
x5: A,
|
||||
x6: E,
|
||||
x7: S
|
||||
)
|
||||
port P2(x: U32) -> U32
|
||||
port P3(x: F32) -> F32
|
||||
port P4(x: bool) -> bool
|
||||
port P5(x: string) -> string
|
||||
port P6(x: A) -> A
|
||||
port P7(x: E) -> E
|
||||
port P8(x: S) -> S
|
||||
|
||||
passive component Sender {
|
||||
|
||||
output port p1: [2] P1
|
||||
output port p2: [2] P2
|
||||
output port p3: [2] P3
|
||||
output port p4: [2] P4
|
||||
output port p5: [2] P5
|
||||
output port p6: [2] P6
|
||||
output port p7: [2] P7
|
||||
output port p8: [2] P8
|
||||
|
||||
}
|
||||
|
||||
active component Receiver {
|
||||
|
||||
async input port p1: [2] P1
|
||||
sync input port p2: [2] P2
|
||||
sync input port p3: [2] P3
|
||||
sync input port p4: [2] P4
|
||||
guarded input port p5: [2] P5
|
||||
guarded input port p6: [2] P6
|
||||
guarded input port p7: [2] P7
|
||||
guarded input port p8: [2] P8
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
module TypedPortsActive {
|
||||
|
||||
instance sender: Sender base id 0x100
|
||||
instance receiver: Receiver base id 0x200 \
|
||||
queue size 10 \
|
||||
stack size 1024
|
||||
|
||||
topology TypedPortsActive {
|
||||
|
||||
instance sender
|
||||
instance receiver
|
||||
|
||||
connections C {
|
||||
|
||||
sender.p1[0] -> receiver.p1[1]
|
||||
sender.p1[1] -> receiver.p1[0]
|
||||
|
||||
sender.p2[0] -> receiver.p2[1]
|
||||
sender.p2[1] -> receiver.p2[0]
|
||||
|
||||
sender.p3[0] -> receiver.p3[0]
|
||||
sender.p3[1] -> receiver.p3[1]
|
||||
|
||||
sender.p4 -> receiver.p4
|
||||
sender.p4 -> receiver.p4
|
||||
|
||||
sender.p5 -> receiver.p5
|
||||
sender.p5 -> receiver.p5
|
||||
|
||||
sender.p6 -> receiver.p6
|
||||
sender.p6 -> receiver.p6
|
||||
|
||||
sender.p7 -> receiver.p7
|
||||
sender.p7 -> receiver.p7
|
||||
|
||||
sender.p8 -> receiver.p8
|
||||
sender.p8 -> receiver.p8
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,3 +56,11 @@ typed_ports_passive()
|
||||
$src_dir/topology
|
||||
move_cpp $src_dir/TypedPortsPassiveTopology
|
||||
}
|
||||
|
||||
typed_ports_active()
|
||||
{
|
||||
src_dir=$PWD/typed_ports_active
|
||||
update "-d $src_dir -p $PWD,$src_dir -i $src_dir/components.fpp" \
|
||||
$src_dir/topology
|
||||
move_cpp $src_dir/TypedPortsActiveTopology
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user