mirror of
https://github.com/nasa/fpp.git
synced 2025-12-11 03:05:32 -06:00
235 lines
5.0 KiB
C++
Vendored
235 lines
5.0 KiB
C++
Vendored
// ======================================================================
|
|
// \title PrimitivePortAc.cpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief cpp file for Primitive port
|
|
// ======================================================================
|
|
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "Fw/Types/ExternalString.hpp"
|
|
#include "PrimitivePortAc.hpp"
|
|
|
|
#if !FW_DIRECT_PORT_CALLS
|
|
|
|
namespace {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Port buffer class
|
|
// ----------------------------------------------------------------------
|
|
|
|
class PrimitivePortBuffer : public Fw::LinearBufferBase {
|
|
|
|
public:
|
|
|
|
Fw::Serializable::SizeType getCapacity() const {
|
|
return InputPrimitivePort::SERIALIZED_SIZE;
|
|
}
|
|
|
|
U8* getBuffAddr() {
|
|
return m_buff;
|
|
}
|
|
|
|
const U8* getBuffAddr() const {
|
|
return m_buff;
|
|
}
|
|
|
|
private:
|
|
|
|
U8 m_buff[InputPrimitivePort::SERIALIZED_SIZE];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Input Port Member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
InputPrimitivePort ::
|
|
InputPrimitivePort() :
|
|
Fw::InputPortBase(),
|
|
m_func(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
void InputPrimitivePort ::
|
|
init()
|
|
{
|
|
Fw::InputPortBase::init();
|
|
}
|
|
|
|
void InputPrimitivePort ::
|
|
addCallComp(
|
|
Fw::PassiveComponentBase* callComp,
|
|
CompFuncPtr funcPtr
|
|
)
|
|
{
|
|
FW_ASSERT(callComp != nullptr);
|
|
FW_ASSERT(funcPtr != nullptr);
|
|
|
|
this->m_comp = callComp;
|
|
this->m_func = funcPtr;
|
|
this->m_connObj = callComp;
|
|
}
|
|
|
|
void InputPrimitivePort ::
|
|
invoke(
|
|
U32 u32,
|
|
U32& u32Ref,
|
|
F32 f32,
|
|
F32& f32Ref,
|
|
bool b,
|
|
bool& bRef
|
|
)
|
|
{
|
|
#if FW_PORT_TRACING == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
FW_ASSERT(this->m_comp != nullptr);
|
|
FW_ASSERT(this->m_func != nullptr);
|
|
|
|
return this->m_func(this->m_comp, this->m_portNum, u32, u32Ref, f32, f32Ref, b, bRef);
|
|
}
|
|
|
|
#if FW_PORT_SERIALIZATION == 1
|
|
|
|
Fw::SerializeStatus InputPrimitivePort ::
|
|
invokeSerial(Fw::LinearBufferBase& _buffer)
|
|
{
|
|
Fw::SerializeStatus _status;
|
|
|
|
#if FW_PORT_TRACING == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
FW_ASSERT(this->m_comp != nullptr);
|
|
FW_ASSERT(this->m_func != nullptr);
|
|
|
|
U32 u32;
|
|
_status = _buffer.deserializeTo(u32);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
U32 u32Ref;
|
|
_status = _buffer.deserializeTo(u32Ref);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
F32 f32;
|
|
_status = _buffer.deserializeTo(f32);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
F32 f32Ref;
|
|
_status = _buffer.deserializeTo(f32Ref);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
bool b;
|
|
_status = _buffer.deserializeTo(b);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
bool bRef;
|
|
_status = _buffer.deserializeTo(bRef);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
this->m_func(this->m_comp, this->m_portNum, u32, u32Ref, f32, f32Ref, b, bRef);
|
|
|
|
return Fw::FW_SERIALIZE_OK;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Output Port Member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
OutputPrimitivePort ::
|
|
OutputPrimitivePort() :
|
|
Fw::OutputPortBase(),
|
|
m_port(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
void OutputPrimitivePort ::
|
|
init()
|
|
{
|
|
Fw::OutputPortBase::init();
|
|
}
|
|
|
|
void OutputPrimitivePort ::
|
|
addCallPort(InputPrimitivePort* callPort)
|
|
{
|
|
FW_ASSERT(callPort != nullptr);
|
|
|
|
this->m_port = callPort;
|
|
this->m_connObj = callPort;
|
|
|
|
#if FW_PORT_SERIALIZATION == 1
|
|
this->m_serPort = nullptr;
|
|
#endif
|
|
}
|
|
|
|
void OutputPrimitivePort ::
|
|
invoke(
|
|
U32 u32,
|
|
U32& u32Ref,
|
|
F32 f32,
|
|
F32& f32Ref,
|
|
bool b,
|
|
bool& bRef
|
|
) const
|
|
{
|
|
#if FW_PORT_TRACING == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
#if FW_PORT_SERIALIZATION
|
|
FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
|
|
|
|
if (this->m_port != nullptr) {
|
|
this->m_port->invoke(u32, u32Ref, f32, f32Ref, b, bRef);
|
|
}
|
|
else {
|
|
Fw::SerializeStatus _status;
|
|
PrimitivePortBuffer _buffer;
|
|
|
|
_status = _buffer.serializeFrom(u32);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serializeFrom(u32Ref);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serializeFrom(f32);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serializeFrom(f32Ref);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serializeFrom(b);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serializeFrom(bRef);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = this->m_serPort->invokeSerial(_buffer);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
}
|
|
#else
|
|
FW_ASSERT(this->m_port != nullptr);
|
|
this->m_port->invoke(u32, u32Ref, f32, f32Ref, b, bRef);
|
|
#endif
|
|
}
|
|
|
|
#endif
|