fprime/Autocoders/Python/test/testgen/MathSenderComponentImpl.cpp
M Starch b76d8c9a0c
Update/types refactor as constants (#1623)
* lestarch: adding logical types implementation into Linux/StandardTypes.hpp

* lestarch: removing VxWorks StandardTypes from repository

* updated fprime types for correct compilation with vxworks and baremetal

* lestarch: refactoring types and configuration header w.r.t type design

* lestarch: replacing usages of AssertArg with FwAssertArgType

* lestarch: missspelled configuration

* lestarch: minor compilation fixes

* lestarch: renaming StandardTypes.hpp -> PlatformTypes.hpp

* lestarch: updating PRI tokens

* lestarch: replacing BasicTypes.hpp includes with FpConfig.hpp

* lestarch: UT and compilation fixes for types refactor

* lestarch: sp

* lestarch: fixing RPI issues in PassiveConsoleTextLogger

* lestarch: converting RPI build to debug

* lestarch: removing duplicate config imports

* lestarch: fixing documentation

* lestarch: fixing up multiple definitions and RPI compilation problems

* lestarch: reverting debug build

* lestarch: reverting platform types to class-based constants

* lestarch: reworking basic types

* lestarch: configured types refactor into classes

* lestarch: fixing bugs with static constants in classes

* lestarch: fixing platform types spelling and documentation

* lestarch: adding include guards to types headers

Co-authored-by: Kevin F Ortega <kevin.f.ortega@jpl.nasa.gov>
2022-08-18 13:25:56 -07:00

112 lines
2.9 KiB
C++

// ======================================================================
// \title MathSenderComponentImpl.cpp
// \author jishii
// \brief cpp file for MathSender component implementation class
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#include <Autocoders/Python/test/testgen/MathSenderComponentImpl.hpp>
#include <FpConfig.hpp>
namespace Ref {
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
MathSenderComponentImpl ::
MathSenderComponentImpl(
const char *const compName
) : MathSenderComponentBase(compName)
{
}
void MathSenderComponentImpl ::
init(
const NATIVE_INT_TYPE queueDepth,
const NATIVE_INT_TYPE instance
)
{
MathSenderComponentBase::init(queueDepth, instance);
}
MathSenderComponentImpl ::
~MathSenderComponentImpl()
{
}
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
void MathSenderComponentImpl ::
mathIn_handler(
const NATIVE_INT_TYPE portNum,
F32 result
)
{
this->tlmWrite_MS_RES(result);
this->log_ACTIVITY_HI_MS_RESULT(result);
}
// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------
void MathSenderComponentImpl ::
MS_DO_MATH_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq,
F32 val1,
F32 val2,
MathOp operation
)
{
MathOpTlm opTlm = ADD_TLM;
MathOperation opPort = MATH_ADD;
MathOpEv opEv = ADD_EV;
switch (operation) {
case ADD:
opTlm = ADD_TLM;
opPort = MATH_ADD;
opEv = ADD_EV;
break;
case SUBTRACT:
opTlm = SUB_TLM;
opPort = MATH_SUB;
opEv = SUB_EV;
break;
case MULTIPLY:
opTlm = MULT_TLM;
opPort = MATH_MULTIPLY;
opEv = MULT_EV;
break;
case DIVIDE:
opTlm = DIV_TLM;
opPort = MATH_DIVIDE;
opEv = DIV_EV;
break;
default:
FW_ASSERT(0,operation);
}
this->tlmWrite_MS_OP(opTlm);
this->tlmWrite_MS_VAL1(val1);
this->tlmWrite_MS_VAL2(val2);
this->log_ACTIVITY_LO_MS_COMMAND_RECV(val1,val2,opEv);
this->mathOut_out(0,val1,val2,opPort);
// reply with completion status
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
} // end namespace Ref