repo_name
stringclasses
10 values
file_path
stringlengths
29
222
content
stringlengths
24
926k
extention
stringclasses
5 values
fprime
data/projects/fprime/Autocoders/Python/test/tlm_multi_inst/TestTelemRecvImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm1/TestTelemRecvImpl.hpp> #include <cstdio> TestTelemRecvImpl::TestTelemRecvImpl(const char* name) : Tlm::TelemTesterComponentBase(name) { } TestTelemRecvImpl::~TestTelemRecvImpl() { } void TestTelemRecvImpl::tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { U32 tlmVal; val.deserialize(tlmVal); printf("ID: %d TLM value is %d. Time is %d:%d base: %d\n",id,tlmVal,timeTag.getSeconds(),timeTag.getUSeconds(),timeTag.getTimeBase()); } void TestTelemRecvImpl::init() { Tlm::TelemTesterComponentBase::init(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_multi_inst/TestTelemImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm_multi_inst/TestTelemImpl.hpp> #include <cstdio> TestTlmImpl::TestTlmImpl(const char* name) : Tlm::TestTlmComponentBase(name) { } TestTlmImpl::~TestTlmImpl() { } void TestTlmImpl::init() { Tlm::TestTlmComponentBase::init(); } void TestTlmImpl::genTlm(U32 val) { printf("Writing value %d to telemetry.\n",val); this->tlmWrite_somechan(val); } void TestTlmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_multi_inst/TestTelemRecvImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTELEMRECVIMPL_HPP_ #define TESTTELEMRECVIMPL_HPP_ #include <Autocoders/Python/test/telem_tester/TelemTestComponentAc.hpp> class TestTelemRecvImpl: public Tlm::TelemTesterComponentBase { public: TestTelemRecvImpl(const char* compName); virtual ~TestTelemRecvImpl(); void init(); protected: void tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); private: }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_multi_inst/TestTelemImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/tlm_multi_inst/TestComponentAc.hpp> class TestTlmImpl: public Tlm::TestTlmComponentBase { public: TestTlmImpl(const char* compName); void genTlm(U32 val); virtual ~TestTlmImpl(); void init(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_multi_inst/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <tlm_multi_instGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TestTlmTesterBase { public: ATester() : Tlm::TestTlmTesterBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/testgen/MathSenderComponentImpl.hpp
// ====================================================================== // \title MathSenderComponentImpl.hpp // \author jishii // \brief hpp file for MathSender component implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef MathSender_HPP #define MathSender_HPP #include "Autocoders/Python/test/testgen/MathSenderComponentAc.hpp" namespace Ref { class MathSenderComponentImpl : public MathSenderComponentBase { public: // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- //! Construct object MathSender //! MathSenderComponentImpl( const char *const compName /*!< The component name*/ ); //! Initialize object MathSender //! void init( const NATIVE_INT_TYPE queueDepth, /*!< The queue depth*/ const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/ ); //! Destroy object MathSender //! ~MathSenderComponentImpl(); PRIVATE: // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- //! Handler implementation for mathIn //! void mathIn_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ F32 result /*!< the result of the operation*/ ); PRIVATE: // ---------------------------------------------------------------------- // Command handler implementations // ---------------------------------------------------------------------- //! Implementation for MS_DO_MATH command handler //! Do a math operation void MS_DO_MATH_cmdHandler( const FwOpcodeType opCode, /*!< The opcode*/ const U32 cmdSeq, /*!< The command sequence number*/ F32 val1, /*!< The first value*/ F32 val2, /*!< The second value*/ MathOp operation /*!< The operation to perform*/ ); }; } // end namespace Ref #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/testgen/MathSenderComponentImpl.cpp
// ====================================================================== // \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
cpp
fprime
data/projects/fprime/Autocoders/Python/test/testgen/test/ut/testgenTester.cpp
#include "testgenTester.hpp" #define INSTANCE 0 #define MAX_HISTORY_SIZE 10 #define QUEUE_DEPTH 10 namespace Ref { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- testgenTester :: testgenTester() : MathSenderGTestBase("Tester", MAX_HISTORY_SIZE), component("MathSender") { this->initComponents(); this->connectPorts(); } testgenTester :: ~testgenTester() { } // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- void testgenTester :: testAddCommand() { // send MS_DO_MATH command this->sendCmd_MS_DO_MATH(0,10,1.0,2.0,MathSenderComponentBase::ADD); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify that only one output port was called ASSERT_FROM_PORT_HISTORY_SIZE(1); // verify that the math operation port was only called once ASSERT_from_mathOut_SIZE(1); // verify the arguments of the operation port ASSERT_from_mathOut(0,1.0,2.0,MATH_ADD); // verify telemetry - 3 channels were written ASSERT_TLM_SIZE(3); // verify that the desired telemetry values were only sent once ASSERT_TLM_MS_VAL1_SIZE(1); ASSERT_TLM_MS_VAL2_SIZE(1); ASSERT_TLM_MS_OP_SIZE(1); // verify that the correct telemetry values were sent ASSERT_TLM_MS_VAL1(0,1.0); ASSERT_TLM_MS_VAL2(0,2.0); ASSERT_TLM_MS_OP(0,MathSenderComponentBase::ADD_TLM); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_COMMAND_RECV_SIZE(1); // verify the correct event arguments were sent ASSERT_EVENTS_MS_COMMAND_RECV(0,1.0,2.0,MathSenderComponentBase::ADD_EV); // verify command response was sent ASSERT_CMD_RESPONSE_SIZE(1); // verify the command response was correct as expected ASSERT_CMD_RESPONSE(0,MathSenderComponentBase::OPCODE_MS_DO_MATH,10,Fw::CmdResponse::OK); // reset all telemetry and port history this->clearHistory(); // call result port. We don't care about the value being correct since MathSender doesn't this->invoke_to_mathIn(0,10.0); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify only one telemetry value was written ASSERT_TLM_SIZE(1); // verify the desired telemetry channel was sent only once ASSERT_TLM_MS_RES_SIZE(1); // verify the values of the telemetry channel ASSERT_TLM_MS_RES(0,10.0); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_RESULT_SIZE(1); // verify the expected value of the event arguments ASSERT_EVENTS_MS_RESULT(0,10.0); } void testgenTester :: testSubCommand() { // send MS_DO_MATH command this->sendCmd_MS_DO_MATH(0,10,1.0,2.0,MathSenderComponentBase::SUBTRACT); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify that only one output port was called ASSERT_FROM_PORT_HISTORY_SIZE(1); // verify that the math operation port was only called once ASSERT_from_mathOut_SIZE(1); // verify the arguments of the operation port ASSERT_from_mathOut(0,1.0,2.0,MATH_SUB); // verify telemetry - 3 channels were written ASSERT_TLM_SIZE(3); // verify that the desired telemetry values were only sent once ASSERT_TLM_MS_VAL1_SIZE(1); ASSERT_TLM_MS_VAL2_SIZE(1); ASSERT_TLM_MS_OP_SIZE(1); // verify that the correct telemetry values were sent ASSERT_TLM_MS_VAL1(0,1.0); ASSERT_TLM_MS_VAL2(0,2.0); ASSERT_TLM_MS_OP(0,MathSenderComponentBase::SUB_TLM); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_COMMAND_RECV_SIZE(1); // verify the correct event arguments were sent ASSERT_EVENTS_MS_COMMAND_RECV(0,1.0,2.0,MathSenderComponentBase::SUB_EV); // verify command response was sent ASSERT_CMD_RESPONSE_SIZE(1); // verify the command response was correct as expected ASSERT_CMD_RESPONSE(0,MathSenderComponentBase::OPCODE_MS_DO_MATH,10,Fw::CmdResponse::OK); // reset all telemetry and port history this->clearHistory(); // call result port. We don't care about the value being correct since MathSender doesn't this->invoke_to_mathIn(0,10.0); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify only one telemetry value was written ASSERT_TLM_SIZE(1); // verify the desired telemetry channel was sent only once ASSERT_TLM_MS_RES_SIZE(1); // verify the values of the telemetry channel ASSERT_TLM_MS_RES(0,10.0); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_RESULT_SIZE(1); // verify the expect value of the event ASSERT_EVENTS_MS_RESULT(0,10.0); } void testgenTester :: testMultCommand() { // send MS_DO_MATH command this->sendCmd_MS_DO_MATH(0,10,1.0,2.0,MathSenderComponentBase::MULTIPLY); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify that only one output port was called ASSERT_FROM_PORT_HISTORY_SIZE(1); // verify that the math operation port was only called once ASSERT_from_mathOut_SIZE(1); // verify the arguments of the operation port ASSERT_from_mathOut(0,1.0,2.0,MATH_MULTIPLY); // verify telemetry - 3 channels were written ASSERT_TLM_SIZE(3); // verify that the desired telemetry values were only sent once ASSERT_TLM_MS_VAL1_SIZE(1); ASSERT_TLM_MS_VAL2_SIZE(1); ASSERT_TLM_MS_OP_SIZE(1); // verify that the correct telemetry values were sent ASSERT_TLM_MS_VAL1(0,1.0); ASSERT_TLM_MS_VAL2(0,2.0); ASSERT_TLM_MS_OP(0,MathSenderComponentBase::MULT_TLM); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_COMMAND_RECV_SIZE(1); // verify the correct event arguments were sent ASSERT_EVENTS_MS_COMMAND_RECV(0,1.0,2.0,MathSenderComponentBase::MULT_EV); // verify command response was sent ASSERT_CMD_RESPONSE_SIZE(1); // verify the command response was correct as expected ASSERT_CMD_RESPONSE(0,MathSenderComponentBase::OPCODE_MS_DO_MATH,10,Fw::CmdResponse::OK); // reset all telemetry and port history this->clearHistory(); // call result port. We don't care about the value being correct since MathSender doesn't this->invoke_to_mathIn(0,10.0); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify only one telemetry value was written ASSERT_TLM_SIZE(1); // verify the desired telemetry channel was sent only once ASSERT_TLM_MS_RES_SIZE(1); // verify the values of the telemetry channel ASSERT_TLM_MS_RES(0,10.0); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_RESULT_SIZE(1); // verify the expect value of the event ASSERT_EVENTS_MS_RESULT(0,10.0); } void testgenTester :: testDivCommand() { // send MS_DO_MATH command this->sendCmd_MS_DO_MATH(0,10,1.0,2.0,MathSenderComponentBase::DIVIDE); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify that only one output port was called ASSERT_FROM_PORT_HISTORY_SIZE(1); // verify that the math operation port was only called once ASSERT_from_mathOut_SIZE(1); // verify the arguments of the operation port ASSERT_from_mathOut(0,1.0,2.0,MATH_DIVIDE); // verify telemetry - 3 channels were written ASSERT_TLM_SIZE(3); // verify that the desired telemetry values were only sent once ASSERT_TLM_MS_VAL1_SIZE(1); ASSERT_TLM_MS_VAL2_SIZE(1); ASSERT_TLM_MS_OP_SIZE(1); // verify that the correct telemetry values were sent ASSERT_TLM_MS_VAL1(0,1.0); ASSERT_TLM_MS_VAL2(0,2.0); ASSERT_TLM_MS_OP(0,MathSenderComponentBase::DIV_TLM); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_COMMAND_RECV_SIZE(1); // verify the correct event arguments were sent ASSERT_EVENTS_MS_COMMAND_RECV(0,1.0,2.0,MathSenderComponentBase::DIV_EV); // verify command response was sent ASSERT_CMD_RESPONSE_SIZE(1); // verify the command response was correct as expected ASSERT_CMD_RESPONSE(0,MathSenderComponentBase::OPCODE_MS_DO_MATH,10,Fw::CmdResponse::OK); // reset all telemetry and port history this->clearHistory(); // call result port. We don't care about the value being correct since MathSender doesn't this->invoke_to_mathIn(0,10.0); // retrieve the message from the message queue and dispatch the command to the handler this->component.doDispatch(); // verify only one telemetry value was written ASSERT_TLM_SIZE(1); // verify the desired telemetry channel was sent only once ASSERT_TLM_MS_RES_SIZE(1); // verify the values of the telemetry channel ASSERT_TLM_MS_RES(0,10.0); // verify only one event was sent ASSERT_EVENTS_SIZE(1); // verify the expected event was only sent once ASSERT_EVENTS_MS_RESULT_SIZE(1); // verify the expect value of the event ASSERT_EVENTS_MS_RESULT(0,10.0); } void testgenTester :: toDo() { // TODO } // ---------------------------------------------------------------------- // Handlers for typed from ports // ---------------------------------------------------------------------- void testgenTester :: from_mathOut_handler( const NATIVE_INT_TYPE portNum, F32 val1, F32 val2, MathOperation operation ) { this->pushFromPortEntry_mathOut(val1, val2, operation); } // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- void testgenTester :: connectPorts() { // mathIn this->connect_to_mathIn( 0, this->component.get_mathIn_InputPort(0) ); // CmdDisp this->connect_to_CmdDisp( 0, this->component.get_CmdDisp_InputPort(0) ); // mathOut this->component.set_mathOut_OutputPort( 0, this->get_from_mathOut(0) ); // CmdStatus this->component.set_CmdStatus_OutputPort( 0, this->get_from_CmdStatus(0) ); // CmdReg this->component.set_CmdReg_OutputPort( 0, this->get_from_CmdReg(0) ); // Tlm this->component.set_Tlm_OutputPort( 0, this->get_from_Tlm(0) ); // Time this->component.set_Time_OutputPort( 0, this->get_from_Time(0) ); // Log this->component.set_Log_OutputPort( 0, this->get_from_Log(0) ); // LogText this->component.set_LogText_OutputPort( 0, this->get_from_LogText(0) ); } void testgenTester :: initComponents() { this->init(); this->component.init( QUEUE_DEPTH, INSTANCE ); } } // end namespace Ref
cpp
fprime
data/projects/fprime/Autocoders/Python/test/testgen/test/ut/testgenTester.hpp
#ifndef TESTER_HPP #define TESTER_HPP #include "testgenGTestBase.hpp" #include "Autocoders/Python/test/testgen/MathSenderComponentImpl.hpp" namespace Ref { class testgenTester : public MathSenderGTestBase { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- public: //! Construct object testgenTester //! testgenTester(); //! Destroy object testgenTester //! ~testgenTester(); public: // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- //! To do //! //! Test operation command //! void testAddCommand(); void testSubCommand(); void testMultCommand(); void testDivCommand(); void toDo(); private: // ---------------------------------------------------------------------- // Handlers for typed from ports // ---------------------------------------------------------------------- //! Handler for from_mathOut //! void from_mathOut_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ F32 val1, F32 val2, MathOperation operation /*!< operation argument*/ ); private: // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- //! Connect ports //! void connectPorts(); //! Initialize components //! void initComponents(); private: // ---------------------------------------------------------------------- // Variables // ---------------------------------------------------------------------- //! The component under test //! MathSenderComponentImpl component; }; } // end namespace Ref #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/testgen/test/ut/testgenTestMain.cpp
#include "testgenTester.hpp" TEST(Nominal, TestAddCommand) { Ref::testgenTester tester; tester.testAddCommand(); } TEST(Nominal, TestSubCommand) { Ref::testgenTester tester; tester.testSubCommand(); } TEST(Nominal, TestMultCommand) { Ref::testgenTester tester; tester.testMultCommand(); } TEST(Nominal, TestDivCommand) { Ref::testgenTester tester; tester.testDivCommand(); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/array_xml/ExampleArrayImpl.cpp
#include <Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp> #include <FpConfig.hpp> #include <Fw/Types/String.hpp> #include <iostream> #include <cstdio> using namespace std; namespace Example { ExampleArrayImpl::ExampleArrayImpl(const char* compName) : Component1ComponentBase(compName) { } ExampleArrayImpl::~ExampleArrayImpl() { } void ExampleArrayImpl::init(NATIVE_INT_TYPE queueDepth) { Component1ComponentBase::init(queueDepth); } void ExampleArrayImpl::ExArrayIn_handler(NATIVE_INT_TYPE portNum, const Example::SubNameSpace::ArrayType& array1, const Example::ArrSerial& serial1) { Fw::String s; array1.toString(s); printf("%s Invoked ExArrayIn_handler();\n%s", FW_OPTIONAL_NAME(this->getObjName()), s.toChar()); this->ArrayOut_out(0, array1, serial1); } void ExampleArrayImpl::ArrayIn_handler(NATIVE_INT_TYPE portNum, const Example::SubNameSpace::ArrayType& array1, const Example::ArrSerial& serial1) { Fw::String s; array1.toString(s); printf("%s Invoked ArrayIn_handler(%d);\n%s", FW_OPTIONAL_NAME(this->getObjName()), portNum, s.toChar()); } };
cpp
fprime
data/projects/fprime/Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp
#ifndef EXAMPLE_ARRAY_IMPL_HPP #define EXAMPLE_ARRAY_IMPL_HPP #include <Autocoders/Python/test/array_xml/Component1ComponentAc.hpp> namespace Example { class ExampleArrayImpl : public Component1ComponentBase { public: // Only called by derived class ExampleArrayImpl(const char* compName); ~ExampleArrayImpl(); void init(NATIVE_INT_TYPE queueDepth); private: void ExArrayIn_handler(NATIVE_INT_TYPE portNum, const Example::SubNameSpace::ArrayType& array1, const Example::ArrSerial& serial1); void ArrayIn_handler(NATIVE_INT_TYPE portNum, const Example::SubNameSpace::ArrayType& array1, const Example::ArrSerial& serial1); }; }; #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/array_xml/test/ut/main.cpp
#include <Autocoders/Python/test/array_xml/Component1ComponentAc.hpp> #include <Autocoders/Python/test/array_xml/InternalTypeArrayAc.hpp> #include <Autocoders/Python/test/array_xml/StringArrayArrayAc.hpp> #include <Autocoders/Python/test/array_xml/ArrayTypeArrayAc.hpp> #include <Autocoders/Python/test/array_xml/Port1PortAc.hpp> #include <Autocoders/Python/test/array_xml/ArrSerialSerializableAc.hpp> #include <Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> #include <Fw/Types/SerialBuffer.hpp> #include <FpConfig.hpp> #include <Fw/Types/String.hpp> #include <Fw/Types/Assert.hpp> #include <bitset> #include <iostream> #include <cstring> #include <unistd.h> #include <thread> #include <chrono> using namespace std; // Component instance pointers Example::ExampleArrayImpl* inst1 = nullptr; Example::ExampleArrayImpl* inst2 = nullptr; #ifdef TGT_OS_TYPE_LINUX extern "C" { int main(int argc, char* argv[]); }; #endif int main(int argc, char* argv[]) { setbuf(stdout, nullptr); cout << "Initialize Arrays" << endl; Example::InternalType array1 = Example::InternalType(6,7,120,444); Example::SubNameSpace::ArrayType array2 = Example::SubNameSpace::ArrayType(array1); // Create string array for serializable Fw::String mem1 = "Member 1"; Fw::String mem2 = "Member 2"; Fw::String mem3 = "Member 3"; Example::StringArray array3 = Example::StringArray(mem1, mem2, mem3); Example::ArrSerial serial1; // Print toString outputs for each array cout << "Print toString for arrays" << endl; Fw::String tostring1; Fw::String tostring2; Fw::String tostring3; array1.toString(tostring1); array2.toString(tostring2); array3.toString(tostring3); cout << "Integer array: " << tostring1 << endl; cout << "2D integer array: " << tostring2 << endl; cout << "String array: " << tostring3 << endl; // Serialize arrays cout << "Serialize arrays" << endl; U8 buffer1[1024]; U8 buffer2[1024]; Fw::SerialBuffer arraySerial1 = Fw::SerialBuffer(buffer1, sizeof(buffer1)); Fw::SerialBuffer arraySerial2 = Fw::SerialBuffer(buffer2, sizeof(buffer2)); if (arraySerial1.serialize(array1) != Fw::FW_SERIALIZE_OK) { cout << "ERROR: bad serialization array1." << endl; } else { cout << "Serialized array1" << endl; } if (arraySerial2.serialize(array2) != Fw::FW_SERIALIZE_OK) { cout << "ERROR: bad serialization array2." << endl; } else { cout << "Serialized array2" << endl; } cout << "Serialized arrays" << endl; // Save copy of arrays to test against post-serialization Example::InternalType array1Save = array1; Example::SubNameSpace::ArrayType array2Save = array2; cout << "Deserializing arrays" << endl; if (arraySerial1.deserialize(array1Save) != Fw::FW_SERIALIZE_OK) { cout << "ERROR: bad deserialization array1." << endl; } else { cout << "Deserialized array1" << endl; } if(arraySerial2.deserialize(array2Save) != Fw::FW_SERIALIZE_OK) { cout << "ERROR: bad deserialization array2." << endl; } else { cout << "Deserialized array2" << endl; } cout << "Deserialized arrays" << endl; if (array1 != array1Save) { cout << "ERROR: bad array1 check." << endl; } else { cout << "Successful array1 check" << endl; } if (array2 != array2Save) { cout << "ERROR: bad array2 check." << endl; } else { cout << "Successful array2 check" << endl; } // Create serializable int integer1 = 100; int integer2 = 10000; serial1 = Example::ArrSerial(); serial1.setMember1(integer1); serial1.setMember2(integer2); serial1.setMember3(array1); serial1.setMember4(array3); cout << "Invoked ports" << endl; cout << "Quitting..." << endl; cout << "Deleting components..." << endl; delete inst1; delete inst2; cout << "Delete registration objects..." << endl; cout << "Completed..." << endl; return 0; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/main.cpp
#include <Autocoders/Python/test/tlm_string/TestTelemImpl.hpp> #include <Autocoders/Python/test/tlm_string/TestTelemRecvImpl.hpp> #include <Autocoders/Python/test/time_tester/TestTimeImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestTlmImpl testImpl("TestTlmImpl"); testImpl.init(); TestTelemRecvImpl tlmRecv("TestTlmRecv"); tlmRecv.init(); TestTimeImpl timeSource("TimeComp"); timeSource.init(); testImpl.set_Tlm_OutputPort(0,tlmRecv.get_tlmRecvPort_InputPort(0)); testImpl.set_Time_OutputPort(0,timeSource.get_timeGetPort_InputPort(0)); timeSource.setTime(Fw::Time(TB_NONE,2,3)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif Fw::TlmString str(argv[1]); testImpl.genTlm(str); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/TestTelemRecvImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm_string/TestTelemRecvImpl.hpp> #include <cstdio> #include <Fw/Tlm/TlmString.hpp> TestTelemRecvImpl::TestTelemRecvImpl(const char* name) : Tlm::TelemTesterComponentBase(name) { } TestTelemRecvImpl::~TestTelemRecvImpl() { } void TestTelemRecvImpl::tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { Fw::TlmString tlmVal; Fw::SerializeStatus stat = val.deserialize(tlmVal);; if (stat != Fw::FW_SERIALIZE_OK) { printf("Deser failed: %d\n",stat); } printf("ID: %d TLM value is \"%s\". Time is %d:%d base: %d\n",id,tlmVal.toChar(),timeTag.getSeconds(),timeTag.getUSeconds(),timeTag.getTimeBase()); } void TestTelemRecvImpl::init() { Tlm::TelemTesterComponentBase::init(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/TestTelemImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm_string/TestTelemImpl.hpp> #include <cstdio> TestTlmImpl::TestTlmImpl(const char* name) : Tlm::TestTlmComponentBase(name) { } TestTlmImpl::~TestTlmImpl() { } void TestTlmImpl::init() { Tlm::TestTlmComponentBase::init(); } void TestTlmImpl::genTlm(Fw::TlmString& val) { printf("Writing value \"%s\" to telemetry.\n",val.toChar()); this->tlmWrite_stringchan(val); } void TestTlmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/TestTelemRecvImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTELEMRECVIMPL_HPP_ #define TESTTELEMRECVIMPL_HPP_ #include <Autocoders/Python/test/telem_tester/TelemTestComponentAc.hpp> class TestTelemRecvImpl: public Tlm::TelemTesterComponentBase { public: TestTelemRecvImpl(const char* compName); virtual ~TestTelemRecvImpl(); void init(); protected: void tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); private: }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/TestTelemImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/tlm_string/TestComponentAc.hpp> class TestTlmImpl: public Tlm::TestTlmComponentBase { public: TestTlmImpl(const char* compName); void genTlm(Fw::TlmString& val); virtual ~TestTlmImpl(); void init(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_string/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <tlm_stringGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TestTlmGTestBase { public: ATester() : Tlm::TestTlmGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/main.cpp
#include <Autocoders/Python/test/tlm_enum/TestTelemImpl.hpp> #include <Autocoders/Python/test/tlm_enum/TestTelemRecvImpl.hpp> #include <Autocoders/Python/test/time_tester/TestTimeImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestTlmImpl testImpl("TestTlmImpl"); testImpl.init(); TestTelemRecvImpl tlmRecv("TestTlmRecv"); tlmRecv.init(); TestTimeImpl timeSource("TimeComp"); timeSource.init(); testImpl.set_Tlm_OutputPort(0,tlmRecv.get_tlmRecvPort_InputPort(0)); testImpl.set_Time_OutputPort(0,timeSource.get_timeGetPort_InputPort(0)); timeSource.setTime(Fw::Time(TB_NONE,2,3)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif testImpl.genTlm(7); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/TestTelemRecvImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm_enum/TestTelemRecvImpl.hpp> #include <cstdio> TestTelemRecvImpl::TestTelemRecvImpl(const char* name) : Tlm::TelemTesterComponentBase(name) { } TestTelemRecvImpl::~TestTelemRecvImpl() { } void TestTelemRecvImpl::tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { U32 tlmVal; val.deserialize(tlmVal); printf("ID: %d TLM value is %d. Time is %d:%d base: %d\n",id,tlmVal,timeTag.getSeconds(),timeTag.getUSeconds(),timeTag.getTimeBase()); } void TestTelemRecvImpl::init() { Tlm::TelemTesterComponentBase::init(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/TestTelemImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm_enum/TestTelemImpl.hpp> #include <cstdio> TestTlmImpl::TestTlmImpl(const char* name) : Tlm::TestTlmComponentBase(name) { } TestTlmImpl::~TestTlmImpl() { } void TestTlmImpl::init() { Tlm::TestTlmComponentBase::init(); } void TestTlmImpl::genTlm(I32 val) { printf("Writing value %d to telemetry.\n",val); SomeEnum argVal = static_cast<SomeEnum>(val); this->tlmWrite_somechan(argVal); } void TestTlmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/TestTelemRecvImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTELEMRECVIMPL_HPP_ #define TESTTELEMRECVIMPL_HPP_ #include <Autocoders/Python/test/telem_tester/TelemTestComponentAc.hpp> class TestTelemRecvImpl: public Tlm::TelemTesterComponentBase { public: TestTelemRecvImpl(const char* compName); virtual ~TestTelemRecvImpl(); void init(); protected: void tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); private: }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/TestTelemImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/tlm_enum/TestComponentAc.hpp> class TestTlmImpl: public Tlm::TestTlmComponentBase { public: TestTlmImpl(const char* compName); void genTlm(I32 val); virtual ~TestTlmImpl(); void init(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm_enum/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <tlm_enumGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TestTlmGTestBase { public: ATester() : Tlm::TestTlmGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/main.cpp
#include <Autocoders/Python/test/command_multi_inst/TestCommand1Impl.hpp> #include <Autocoders/Python/test/command_multi_inst/TestCommandSourceImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestCommand1Impl testImpl("TestCmdImpl"); testImpl.init(10); TestCommandSourceImpl cmdSrc("TestCmdSource"); cmdSrc.init(); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif testImpl.set_CmdStatus_OutputPort(0,cmdSrc.get_cmdStatusPort_InputPort(0)); testImpl.set_CmdReg_OutputPort(0,cmdSrc.get_cmdRegPort_InputPort(0)); cmdSrc.set_cmdSendPort_OutputPort(0,testImpl.get_CmdDisp_InputPort(0)); testImpl.regCommands(); cmdSrc.test_TEST_CMD_1(10,25.6,5); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/TestCommand1Impl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/command_multi_inst/Test1ComponentAc.hpp> class TestCommand1Impl: public Cmd::Test1ComponentBase { public: TestCommand1Impl(const char* compName); virtual ~TestCommand1Impl(); void init(NATIVE_INT_TYPE queueDepth, //!< The queue depth NATIVE_INT_TYPE instance = 0); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); void TEST_CMD_1_cmdHandler( FwOpcodeType opCode, /*!< The opcode*/ U32 cmdSeq, /*!< The command sequence number*/ I32 arg1, /*!< The I32 command argument*/ F32 arg2, /*!< The F32 command argument*/ U8 arg3, /*!< The U8 command argument*/ SomeEnum arg4 /*!< The ENUM argument*/ ); void TEST_CMD_2_cmdHandler( FwOpcodeType opCode, //!< The opcode U32 cmdSeq, //!< The command sequence number U32 arg1, //!< The U32 command argument F64 arg2, //!< The F64 command argument I8 arg3 //!< The I8 command argument ); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/TestCommand1Impl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/command_multi_inst/TestCommand1Impl.hpp> #include <cstdio> TestCommand1Impl::TestCommand1Impl(const char* name) : Test1ComponentBase(name) { // TODO Auto-generated constructor stub } TestCommand1Impl::~TestCommand1Impl() { // TODO Auto-generated destructor stub } void TestCommand1Impl::init(NATIVE_INT_TYPE queueDepth, //!< The queue depth NATIVE_INT_TYPE instance) { Test1ComponentBase::init(queueDepth,instance); } void TestCommand1Impl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { } void TestCommand1Impl::TEST_CMD_1_cmdHandler( FwOpcodeType opCode, /*!< The opcode*/ U32 cmdSeq, /*!< The command sequence number*/ I32 arg1, /*!< The I32 command argument*/ F32 arg2, /*!< The F32 command argument*/ U8 arg3, /*!< The U8 command argument*/ SomeEnum arg4 /*!< The ENUM argument*/ ) { printf("Got command args: %d %f %d %d\n", arg1, arg2, arg3, arg4 ); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); } void TestCommand1Impl::TEST_CMD_2_cmdHandler( FwOpcodeType opCode, //!< The opcode U32 cmdSeq, //!< The command sequence number U32 arg1, //!< The U32 command argument F64 arg2, //!< The F64 command argument I8 arg3 //!< The I8 command argument ) { }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/TestCommandSourceImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/command1/TestCommandSourceImpl.hpp> #include <cstdio> TestCommandSourceImpl::TestCommandSourceImpl(const char* name) : Cmd::CommandTesterComponentBase(name) { // TODO Auto-generated constructor stub } TestCommandSourceImpl::~TestCommandSourceImpl() { // TODO Auto-generated destructor stub } void TestCommandSourceImpl::cmdStatusPort_handler( NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse& response) { this->printStatus(response); } void TestCommandSourceImpl::cmdRegPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode) { printf("Received registration for opcode %d\n",opCode); } void TestCommandSourceImpl::init() { Cmd::CommandTesterComponentBase::init(); } void TestCommandSourceImpl::printStatus(Fw::CmdResponse response) { switch (response.e) { case Fw::CmdResponse::OK: printf("COMMAND OK\n"); break; case Fw::CmdResponse::INVALID_OPCODE: printf("INVALID OPCODE\n"); break; case Fw::CmdResponse::VALIDATION_ERROR: printf("VALIDATION ERROR\n"); break; case Fw::CmdResponse::FORMAT_ERROR: printf("FORMAT ERROR\n"); break; case Fw::CmdResponse::EXECUTION_ERROR: printf("EXECUTION ERROR\n"); break; default: printf("Unknown status %d\n", response.e); break; } } void TestCommandSourceImpl::test_TEST_CMD_1(I32 arg1, F32 arg2, U8 arg3) { // serialize parameters if (!this->isConnected_cmdSendPort_OutputPort(0)) { printf("Test command port not connected."); return; } Fw::CmdArgBuffer argBuff; // do nominal case argBuff.serialize(arg1); argBuff.serialize(arg2); argBuff.serialize(arg3); this->cmdSendPort_out(0, 0x100, 1, argBuff); // too many arguments argBuff.resetSer(); argBuff.serialize(arg1); argBuff.serialize(arg2); argBuff.serialize(arg3); argBuff.serialize(arg3); this->cmdSendPort_out(0, 0x100, 1, argBuff); // too few arguments argBuff.resetSer(); argBuff.serialize(arg1); argBuff.serialize(arg2); this->cmdSendPort_out(0, 0x100, 1, argBuff); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/TestCommandSourceImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMANDSOURCEIMPL_HPP_ #define TESTCOMMANDSOURCEIMPL_HPP_ #include <Autocoders/Python/test/command_tester/CommandTestComponentAc.hpp> class TestCommandSourceImpl: public Cmd::CommandTesterComponentBase { public: TestCommandSourceImpl(const char* compName); virtual ~TestCommandSourceImpl(); void init(); void test_TEST_CMD_1(I32 arg1, F32 arg2, U8 arg3); protected: void cmdStatusPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse& response); void cmdRegPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode); private: void printStatus(Fw::CmdResponse response); }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command_multi_inst/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <command_multi_instGTestBase.hpp> #endif #include "TesterBase.hpp" #include <FpConfig.hpp> // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Cmd::Test1GTestBase { public: ATester() : Cmd::Test1GTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/UserSerializer.cpp
#include <Autocoders/Python/test/interface1/UserSerializer.hpp> #include <Fw/Types/Assert.hpp> #include <cstdio> namespace ANameSpace { UserSerializer::UserSerializer(): Serializable() { } UserSerializer::UserSerializer(const SomeUserStruct& src) : Serializable() { this->setVal(src); } UserSerializer::UserSerializer(const SomeUserStruct* src) : Serializable() { FW_ASSERT(src); this->setVal(*src); } UserSerializer::UserSerializer(SomeUserStruct val) : Serializable() { this->setVal(val); } SomeUserStruct& UserSerializer::operator=(const SomeUserStruct& src) { this->setVal(src); return this->m_struct; } void UserSerializer::getVal(SomeUserStruct& arg) { arg = this->m_struct; } void UserSerializer::setVal(const SomeUserStruct& val) { this->m_struct = val; } Fw::SerializeStatus UserSerializer::serialize(Fw::SerializeBufferBase& buffer) const { return buffer.serialize(reinterpret_cast<const U8*>(&m_struct),sizeof(m_struct)); } Fw::SerializeStatus UserSerializer::deserialize(Fw::SerializeBufferBase& buffer) { NATIVE_UINT_TYPE serSize = sizeof(m_struct); Fw::SerializeStatus stat = buffer.deserialize(reinterpret_cast<U8*>(&m_struct),serSize); FW_ASSERT(serSize == sizeof(m_struct)); return stat; } #if FW_SERIALIZABLE_TO_STRING void UserSerializer::toString(Fw::StringBase& text) const { // declare strings to hold any serializable toString() arguments char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE]; snprintf(outputString,FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE, "SomeUserStruct: %d %f %d", this->m_struct.mem1,this->m_struct.mem2,this->m_struct.mem3); outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate text = outputString; } #endif }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/TestComponentImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/interface1/TestComponentAc.hpp> class TestComponentImpl: public Cmd::TestComponentBase { public: TestComponentImpl(const char* compName); virtual ~TestComponentImpl(); void init(NATIVE_INT_TYPE queueDepth); protected: void test_internalInterfaceHandler(I32 arg1, F32 arg2, U8 arg3); void test2_internalInterfaceHandler(I32 arg1, SomeEnum arg2, const Fw::InternalInterfaceString& arg3, const ANameSpace::UserSerializer& arg4); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/UserSerializer.hpp
#ifndef EXAMPLE_TYPE_HPP #define EXAMPLE_TYPE_HPP // A hand-coded serializable #include <FpConfig.hpp> #include <Fw/Types/Serializable.hpp> #include <Autocoders/Python/test/interface1/SomeStruct.hpp> #if FW_SERIALIZABLE_TO_STRING #include <Fw/Types/StringType.hpp> #endif namespace ANameSpace { class UserSerializer : public Fw::Serializable { public: enum { SERIALIZED_SIZE = sizeof(SomeUserStruct) + sizeof(I32) }; UserSerializer(); // Default constructor UserSerializer(const SomeUserStruct* src); // copy constructor UserSerializer(const SomeUserStruct& src); // copy constructor UserSerializer(SomeUserStruct arg); // constructor with arguments SomeUserStruct& operator=(const SomeUserStruct& src); // Equal operator void setVal(const SomeUserStruct& arg); // set values void getVal(SomeUserStruct& arg); Fw::SerializeStatus serialize(Fw::SerializeBufferBase& buffer) const; Fw::SerializeStatus deserialize(Fw::SerializeBufferBase& buffer); #if FW_SERIALIZABLE_TO_STRING void toString(Fw::StringBase& text) const; //!< generate text from serializable #endif protected: private: SomeUserStruct m_struct; // stored value }; } #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/TestComponentImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/interface1/TestComponentImpl.hpp> #include <cstdio> TestComponentImpl::TestComponentImpl(const char* name) : TestComponentBase(name) { // TODO Auto-generated constructor stub } TestComponentImpl::~TestComponentImpl() { // TODO Auto-generated destructor stub } void TestComponentImpl::init(NATIVE_INT_TYPE queueDepth) { TestComponentBase::init(queueDepth); } void TestComponentImpl::test_internalInterfaceHandler(I32 arg1, F32 arg2, U8 arg3) { } void TestComponentImpl::test2_internalInterfaceHandler(I32 arg1, SomeEnum arg2, const Fw::InternalInterfaceString& arg3, const ANameSpace::UserSerializer& arg4) { } TestComponentImpl impl("impl");
cpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/SomeStruct.hpp
#ifndef SOME_STRUCT_HPP #define SOME_STRUCT_HPP #include <FpConfig.hpp> extern "C" { typedef struct { U32 mem1; F64 mem2; U8 mem3; } SomeUserStruct; } #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/interface1/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <interface1GTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Cmd::TestGTestBase { public: ATester() : Cmd::TestGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/TestPrmImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/param1/TestPrmImpl.hpp> #include <cstdio> TestPrmImpl::TestPrmImpl(const char* name) : Prm::TestPrmComponentBase(name) { } TestPrmImpl::~TestPrmImpl() { } void TestPrmImpl::init() { Prm::TestPrmComponentBase::init(); } void TestPrmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { } void TestPrmImpl::printParam() { Fw::ParamValid valid = Fw::ParamValid::INVALID; const U32& prmRef = this->paramGet_someparam(valid); printf("Parameter is: %d %s\n",prmRef,valid==Fw::ParamValid::VALID?"VALID":"INVALID"); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/main.cpp
#include <Autocoders/Python/test/param1/TestPrmImpl.hpp> #include <Autocoders/Python/test/param1/TestPrmSourceImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestPrmImpl testImpl("TestPrmImpl"); testImpl.init(); TestParamSourceImpl prmSrc("TestPrmSrc"); prmSrc.init(); testImpl.set_ParamGet_OutputPort(0,prmSrc.get_paramGetPort_InputPort(0)); testImpl.set_ParamSet_OutputPort(0,prmSrc.get_paramSetPort_InputPort(0)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif prmSrc.setPrm(15); testImpl.loadParameters(); testImpl.printParam(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/TestPrmSourceImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTPARAMRECVIMPL_HPP_ #define TESTPARAMRECVIMPL_HPP_ #include <Autocoders/Python/test/param_tester/ParamTestComponentAc.hpp> class TestParamSourceImpl: public Prm::ParamTesterComponentBase { public: TestParamSourceImpl(const char* compName); virtual ~TestParamSourceImpl(); void init(); void setPrm(U32 val); protected: Fw::ParamValid paramGetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val); void paramSetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val); Fw::ParamBuffer m_prm; }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/TestPrmSourceImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/param1/TestPrmSourceImpl.hpp> #include <cstdio> TestParamSourceImpl::TestParamSourceImpl(const char* name) : Prm::ParamTesterComponentBase(name) { } TestParamSourceImpl::~TestParamSourceImpl() { } Fw::ParamValid TestParamSourceImpl::paramGetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val) { val = this->m_prm; return Fw::ParamValid::VALID; } void TestParamSourceImpl::paramSetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val) { } void TestParamSourceImpl::init() { Prm::ParamTesterComponentBase::init(); } void TestParamSourceImpl::setPrm(U32 val) { printf("Setting parameter to %d\n",val); this->m_prm.resetSer(); this->m_prm.serialize(val); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/TestPrmImpl.hpp
/* * TestPrmImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTPARAMIMPL_HPP_ #define TESTPARAMIMPL_HPP_ #include <Autocoders/Python/test/param1/TestComponentAc.hpp> class TestPrmImpl: public Prm::TestPrmComponentBase { public: TestPrmImpl(const char* compName); void genTlm(U32 val); virtual ~TestPrmImpl(); void init(); void printParam(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTPARAMIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/test/ut/param1Tester.cpp
// ---------------------------------------------------------------------- // Autocoders/Python/test/param1/test/ut/Tester.cpp // ---------------------------------------------------------------------- #include "param1Tester.hpp"
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/test/ut/param1Main.cpp
// ---------------------------------------------------------------------- // Main.cpp // ---------------------------------------------------------------------- #include "param1Tester.hpp" int main(int argc, char **argv) { return 0; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param1/test/ut/param1Tester.hpp
// ---------------------------------------------------------------------- // param1Tester.hpp // ---------------------------------------------------------------------- #ifndef TESTER_HPP #define TESTER_HPP #include "../../TestPrmImpl.hpp" namespace Prm { }; #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/main.cpp
#include <Autocoders/Python/test/tlm1/TestTelemImpl.hpp> #include <Autocoders/Python/test/tlm1/TestTelemRecvImpl.hpp> #include <Autocoders/Python/test/time_tester/TestTimeImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestTlmImpl testImpl("TestTlmImpl"); testImpl.init(); TestTelemRecvImpl tlmRecv("TestTlmRecv"); tlmRecv.init(); TestTimeImpl timeSource("TimeComp"); timeSource.init(); testImpl.set_Tlm_OutputPort(0,tlmRecv.get_tlmRecvPort_InputPort(0)); testImpl.set_Time_OutputPort(0,timeSource.get_timeGetPort_InputPort(0)); timeSource.setTime(Fw::Time(TB_NONE,2,3)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif testImpl.genTlm(26); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/TestTelemRecvImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm1/TestTelemRecvImpl.hpp> #include <cstdio> TestTelemRecvImpl::TestTelemRecvImpl(const char* name) : Tlm::TelemTesterComponentBase(name) { } TestTelemRecvImpl::~TestTelemRecvImpl() { } void TestTelemRecvImpl::tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) { U32 tlmVal; val.deserialize(tlmVal); printf("ID: %d TLM value is %d. Time is %d:%d base: %d\n",id,tlmVal,timeTag.getSeconds(),timeTag.getUSeconds(),timeTag.getTimeBase()); } void TestTelemRecvImpl::init() { Tlm::TelemTesterComponentBase::init(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/TestTelemImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/tlm1/TestTelemImpl.hpp> #include <cstdio> TestTlmImpl::TestTlmImpl(const char* name) : Tlm::TestTlmComponentBase(name) { } TestTlmImpl::~TestTlmImpl() { } void TestTlmImpl::init() { Tlm::TestTlmComponentBase::init(); } void TestTlmImpl::genTlm(U32 val) { printf("Writing value %d to telemetry.\n",val); this->tlmWrite_somechan(val); } void TestTlmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/TestTelemRecvImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTELEMRECVIMPL_HPP_ #define TESTTELEMRECVIMPL_HPP_ #include <Autocoders/Python/test/telem_tester/TelemTestComponentAc.hpp> class TestTelemRecvImpl: public Tlm::TelemTesterComponentBase { public: TestTelemRecvImpl(const char* compName); virtual ~TestTelemRecvImpl(); void init(); protected: void tlmRecvPort_handler(NATIVE_INT_TYPE portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val); private: }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/TestTelemImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/tlm1/TestComponentAc.hpp> class TestTlmImpl: public Tlm::TestTlmComponentBase { public: TestTlmImpl(const char* compName); void genTlm(U32 val); virtual ~TestTlmImpl(); void init(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/tlm1/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <tlm1GTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TestTlmGTestBase { public: ATester() : Tlm::TestTlmGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/ext_dict/ExampleComponentImpl.hpp
/* * ExampleComponentImpl.hpp * * Created on: Nov 3, 2014 * Author: tcanham */ #ifndef EXAMPLECOMPONENTIMPL_HPP_ #define EXAMPLECOMPONENTIMPL_HPP_ #include <Autocoders/Python/test/ext_dict/ExampleComponentAc.hpp> namespace ExampleComponents { class ExampleComponentImpl: public ExampleComponentBase { public: ExampleComponentImpl(const char* name); void init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance = 0); virtual ~ExampleComponentImpl(); protected: private: void exampleInput_handler(NATIVE_INT_TYPE portNum, I32 arg1, const ANameSpace::mytype& arg2, U8 arg3, const Example3::ExampleSerializable& arg4, AnotherExample::SomeEnum arg5); void TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, ExampleComponentBase::CmdEnum arg2, const Fw::CmdStringArg& arg3); void TEST_CMD_2_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2); }; } /* namespace ExampleComponents */ #endif /* EXAMPLECOMPONENTIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/ext_dict/ExampleType.hpp
#ifndef EXAMPLE_TYPE_HPP #define EXAMPLE_TYPE_HPP // A hand-coded serializable #include <FpConfig.hpp> #include <Fw/Types/Serializable.hpp> #if FW_SERIALIZABLE_TO_STRING #include <Fw/Types/StringType.hpp> #include <cstdio> // snprintf #endif namespace ANameSpace { class mytype : public Fw::Serializable { public: enum { SERIALIZED_SIZE = sizeof(U32), TYPE_ID = 2000 }; mytype(); // Default constructor mytype(const mytype* src); // copy constructor mytype(const mytype& src); // copy constructor mytype(U32 arg); // constructor with arguments mytype& operator=(const mytype& src); // Equal operator bool operator==(const mytype& src) const; // equality operator void setVal(U32 arg); // set values U32 getVal(); Fw::SerializeStatus serialize(Fw::SerializeBufferBase& buffer) const; Fw::SerializeStatus deserialize(Fw::SerializeBufferBase& buffer); #if FW_SERIALIZABLE_TO_STRING void toString(Fw::StringBase& text) const; //!< generate text from serializable #endif protected: private: U32 m_val; // stored value }; } #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/ext_dict/ExampleComponentImpl.cpp
/* * ExampleComponentImpl.cpp * * Created on: Nov 3, 2014 * Author: tcanham */ #include <Autocoders/Python/test/ext_dict/ExampleComponentImpl.hpp> #include <cstdio> namespace ExampleComponents { ExampleComponentImpl::ExampleComponentImpl(const char* name) : ExampleComponentBase(name) { } ExampleComponentImpl::~ExampleComponentImpl() { } void ExampleComponentImpl::init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance) { ExampleComponentBase::init(queueDepth,instance); } void ExampleComponentImpl::exampleInput_handler(NATIVE_INT_TYPE portNum, I32 arg1, const ANameSpace::mytype& arg2, U8 arg3, const Example3::ExampleSerializable& arg4, AnotherExample::SomeEnum arg5) { //Fw::TlmString arg = "A string arg"; // write some telemetry U32 chan = 0; this->tlmWrite_stringchan(chan); // call the output port if (this->isConnected_exampleOutput_OutputPort(0)) { this->exampleOutput_out(0,arg1,arg2,arg3,arg4,arg5); } else { printf("Output port not connected.\n"); } } void ExampleComponentImpl::TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, ExampleComponentBase::CmdEnum arg2, const Fw::CmdStringArg& arg3) { // issue the test event with the opcode Fw::LogStringArg str = "TEST_CMD_1"; this->log_ACTIVITY_HI_SomeEvent(opCode,static_cast<F32>(arg1), 0, str,ExampleComponentBase::EVENT_MEMB2); // write a value to a telemetry channel U32 chan = 12; this->tlmWrite_somechan(chan); this->cmdResponse_out(opCode,cmdSeq, Fw::CmdResponse::OK); } void ExampleComponentImpl::TEST_CMD_2_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2) { Fw::LogStringArg str = "TEST_CMD_2"; this->log_ACTIVITY_HI_SomeEvent(opCode,arg2, 0, str,ExampleComponentBase::EVENT_MEMB3); U32 chan = 0; this->tlmWrite_anotherchan(chan); // <! Example output port this->cmdResponse_out(opCode,cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); } } /* namespace ExampleComponents */
cpp
fprime
data/projects/fprime/Autocoders/Python/test/ext_dict/ExampleType.cpp
#include <Autocoders/Python/test/ext_dict/ExampleType.hpp> #include <Fw/Types/Assert.hpp> namespace ANameSpace { mytype::mytype(): Serializable() { } mytype::mytype(const mytype& src) : Serializable() { this->setVal(src.m_val); } mytype::mytype(const mytype* src) : Serializable() { FW_ASSERT(src); this->setVal(src->m_val); } mytype::mytype(U32 val) : Serializable() { this->setVal(val); } mytype& mytype::operator=(const mytype& src) { this->setVal(src.m_val); return *this; } bool mytype::operator==(const mytype& src) const { return (this->m_val == src.m_val); } U32 mytype::getVal() { return this->m_val; } void mytype::setVal(U32 val) { this->m_val = val; } Fw::SerializeStatus mytype::serialize(Fw::SerializeBufferBase& buffer) const { Fw::SerializeStatus stat = buffer.serialize(this->m_val); if (Fw::FW_SERIALIZE_OK != stat) { return stat; } return buffer.serialize(static_cast<NATIVE_INT_TYPE>(mytype::TYPE_ID)); } Fw::SerializeStatus mytype::deserialize(Fw::SerializeBufferBase& buffer) { NATIVE_INT_TYPE id; Fw::SerializeStatus stat = buffer.deserialize(id); if (Fw::FW_SERIALIZE_OK != stat) { return stat; } if (id != static_cast<NATIVE_INT_TYPE>(mytype::TYPE_ID)) { return Fw::FW_DESERIALIZE_TYPE_MISMATCH; } return buffer.deserialize(this->m_val); } #if FW_SERIALIZABLE_TO_STRING void mytype::toString(Fw::StringBase& text) const { static const char * formatString = "(val = %u)"; // declare strings to hold any serializable toString() arguments char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE]; snprintf(outputString,FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,formatString,this->m_val); outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate text = outputString; } #endif }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/ext_dict/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <ext_dictGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public ExampleComponents::ExampleGTestBase { public: ATester() : ExampleComponents::ExampleGTestBase("comp",10) { } void from_exampleOutput_handler( const NATIVE_INT_TYPE portNum, //!< The port number I32 arg1, //!< A built-in type argument const ANameSpace::mytype& arg2, //!< A user-defined type argument U8 arg3, //!< The third argument const Example3::ExampleSerializable& arg4, //!< The third argument AnotherExample::SomeEnum arg5 //!< The ENUM argument ); }; void ATester::from_exampleOutput_handler( const NATIVE_INT_TYPE portNum, //!< The port number I32 arg1, //!< A built-in type argument const ANameSpace::mytype& arg2, //!< A user-defined type argument U8 arg3, //!< The third argument const Example3::ExampleSerializable& arg4, //!< The third argument AnotherExample::SomeEnum arg5 //!< The ENUM argument ) { } int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_res/Test1ComponentImpl.hpp
// ====================================================================== // \title Test1Impl.hpp // \author tcanham // \brief hpp file for Test1 component implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef Test1_HPP #define Test1_HPP #include "Autocoders/Python/test/command_res/Test1ComponentAc.hpp" namespace Cmd { class Test1ComponentImpl : public Test1ComponentBase { public: // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- //! Construct object Test1 //! Test1ComponentImpl( const char *const compName /*!< The component name*/ ); //! Initialize object Test1 //! void init( const NATIVE_INT_TYPE queueDepth, /*!< The queue depth*/ const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/ ); //! Destroy object Test1 //! ~Test1ComponentImpl(); PRIVATE: // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- //! Handler implementation for aport //! void aport_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ I32 arg4, /*!< The first argument*/ F32 arg5, /*!< The second argument*/ U8 arg6 /*!< The third argument*/ ); PRIVATE: // ---------------------------------------------------------------------- // Command handler implementations // ---------------------------------------------------------------------- //! Implementation for TEST_CMD_1 command handler //! A test command void TEST_CMD_1_cmdHandler( const FwOpcodeType opCode, /*!< The opcode*/ const U32 cmdSeq, /*!< The command sequence number*/ I32 arg1, /*!< The I32 command argument*/ F32 arg2, /*!< The F32 command argument*/ U8 arg3 /*!< The U8 command argument*/ ); //! Implementation for TEST_CMD_2 command handler //! A test command void TEST_CMD_2_cmdHandler( const FwOpcodeType opCode, /*!< The opcode*/ const U32 cmdSeq, /*!< The command sequence number*/ U32 arg1, /*!< The I32 command argument*/ U16 arg2, /*!< The F32 command argument*/ U8 arg3 /*!< The U8 command argument*/ ); }; } // end namespace Cmd #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command_res/Test1ComponentImpl.cpp
// ====================================================================== // \title Test1Impl.cpp // \author tcanham // \brief cpp file for Test1 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/command_res/Test1ComponentImpl.hpp> #include <FpConfig.hpp> namespace Cmd { // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- Test1ComponentImpl :: Test1ComponentImpl( const char *const compName ) : Test1ComponentBase(compName) { } void Test1ComponentImpl :: init( const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance ) { Test1ComponentBase::init(queueDepth, instance); } Test1ComponentImpl :: ~Test1ComponentImpl() { } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- void Test1ComponentImpl :: aport_handler( const NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6 ) { // TODO } // ---------------------------------------------------------------------- // Command handler implementations // ---------------------------------------------------------------------- void Test1ComponentImpl :: TEST_CMD_1_cmdHandler( const FwOpcodeType opCode, const U32 cmdSeq, I32 arg1, F32 arg2, U8 arg3 ) { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); } void Test1ComponentImpl :: TEST_CMD_2_cmdHandler( const FwOpcodeType opCode, const U32 cmdSeq, U32 arg1, U16 arg2, U8 arg3 ) { this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); } } // end namespace Cmd
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_res/test/ut/main.cpp
// ---------------------------------------------------------------------- // Main.cpp // ---------------------------------------------------------------------- #include "command_resTester.hpp" TEST(Test, CmdResidual) { Cmd::command_resTester tester; tester.residualTest(); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command_res/test/ut/command_resTester.hpp
// ====================================================================== // \title Test1/test/ut/Tester.hpp // \author tcanham // \brief hpp file for Test1 test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef TESTER_HPP #define TESTER_HPP #include "command_resGTestBase.hpp" #include "Autocoders/Python/test/command_res/Test1ComponentImpl.hpp" namespace Cmd { class command_resTester : public Test1GTestBase { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- public: //! Construct object command_resTester //! command_resTester(); //! Destroy object command_resTester //! ~command_resTester(); public: // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- //! Test residual //! void residualTest(); private: // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- //! Connect ports //! void connectPorts(); //! Initialize components //! void initComponents(); private: // ---------------------------------------------------------------------- // Variables // ---------------------------------------------------------------------- //! The component under test //! Test1ComponentImpl component; }; } // end namespace Cmd #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command_res/test/ut/command_resTester.cpp
// ====================================================================== // \title Test1.hpp // \author tcanham // \brief cpp file for Test1 test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #include "command_resTester.hpp" #define INSTANCE 0 #define MAX_HISTORY_SIZE 10 #define QUEUE_DEPTH 10 namespace Cmd { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- command_resTester :: command_resTester() : Test1GTestBase("Tester", MAX_HISTORY_SIZE), component("Test1") { this->initComponents(); this->connectPorts(); } command_resTester :: ~command_resTester() { } // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- void command_resTester :: residualTest() { // This test will do different things based on the configuration macro FW_CMD_CHECK_RESIDUAL // If it is on, a command failure will be checked. If not, command success will be checked. // Manually compose a buffer that is too large. // test command has 9 bytes of argument: // I32, F32, I8 // Serialize more than that. Fw::CmdArgBuffer args; I32 arg1 = 20; F32 arg2 = 20.1; I8 arg3 = 49; U32 arg4 = 1000; ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg1)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg2)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg3)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg4)); this->sendRawCmd(Test1ComponentBase::OPCODE_TEST_CMD_1,10,args); // check reply #if FW_CMD_CHECK_RESIDUAL // should fail ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE(0,Test1ComponentBase::OPCODE_TEST_CMD_1,10,Fw::CmdResponse::FORMAT_ERROR); #else // should pass ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE(0,Test1ComponentBase::OPCODE_TEST_CMD_1,10,Fw::CmdResponse::OK); #endif // second async command args.resetSer(); U32 arg21 = 0; U16 arg22 = 0; U8 arg23 = 0; ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg21)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg22)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg23)); ASSERT_EQ(Fw::FW_SERIALIZE_OK,args.serialize(arg4)); this->sendRawCmd(Test1ComponentBase::OPCODE_TEST_CMD_2,20,args); this->clearHistory(); // dispatch ASSERT_EQ(Fw::QueuedComponentBase::MSG_DISPATCH_OK,this->component.doDispatch()); // check reply #if FW_CMD_CHECK_RESIDUAL // should fail ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE(0,Test1ComponentBase::OPCODE_TEST_CMD_2,20,Fw::CmdResponse::FORMAT_ERROR); #else // should pass ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE(0,Test1ComponentBase::OPCODE_TEST_CMD_2,20,Fw::CmdResponse::OK); #endif } // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- void command_resTester :: connectPorts() { // aport this->connect_to_aport( 0, this->component.get_aport_InputPort(0) ); // CmdDisp this->connect_to_CmdDisp( 0, this->component.get_CmdDisp_InputPort(0) ); // CmdStatus this->component.set_CmdStatus_OutputPort( 0, this->get_from_CmdStatus(0) ); // CmdReg this->component.set_CmdReg_OutputPort( 0, this->get_from_CmdReg(0) ); } void command_resTester :: initComponents() { this->init(); this->component.init(QUEUE_DEPTH, INSTANCE ); } } // end namespace Cmd
cpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/main.cpp
#include <Autocoders/Python/test/event_string/TestLogImpl.hpp> #include <Autocoders/Python/test/event_string/TestLogRecvImpl.hpp> #include <Autocoders/Python/test/time_tester/TestTimeImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestLogImpl testImpl("TestLogImpl"); testImpl.init(); TestLogRecvImpl logRecv("TestLogRecv"); logRecv.init(); TestTimeImpl timeSource("TimeComp"); timeSource.init(); testImpl.set_Log_OutputPort(0,logRecv.get_logRecvPort_InputPort(0)); testImpl.set_Time_OutputPort(0,timeSource.get_timeGetPort_InputPort(0)); testImpl.set_LogText_OutputPort(0,logRecv.get_textLogRecvPort_InputPort(0)); timeSource.setTime(Fw::Time(TB_NONE,2,3)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif Fw::LogStringArg arg("Log Something"); testImpl.sendEvent(20,arg,40); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/TestLogRecvImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/event_string/TestLogRecvImpl.hpp> #include <cstdio> #include <Fw/Log/LogString.hpp> TestLogRecvImpl::TestLogRecvImpl(const char* name) : LogTextImpl(name) { } TestLogRecvImpl::~TestLogRecvImpl() { } void TestLogRecvImpl::logRecvPort_handler(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity& severity, Fw::LogBuffer &args) { printf("Received log %d, Time (%d,%d:%d) severity %d\n",id,timeTag.getTimeBase(),timeTag.getSeconds(),timeTag.getUSeconds(),severity.e); I32 arg1; Fw::LogStringArg arg2; U8 arg3; // deserialize them in reverse order args.deserialize(arg3); args.deserialize(arg2); args.deserialize(arg1); printf("Args: %d \"%s\" %d\n",arg1,arg2.toChar(),arg3); } void TestLogRecvImpl::init() { LogTextImpl::init(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/TestLogRecvImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTELEMRECVIMPL_HPP_ #define TESTTELEMRECVIMPL_HPP_ #include <Autocoders/Python/test/log_tester/TestTextLogImpl.hpp> class TestLogRecvImpl: public LogTextImpl { public: TestLogRecvImpl(const char* compName); virtual ~TestLogRecvImpl(); void init(); protected: void logRecvPort_handler(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity& severity, Fw::LogBuffer &args); private: }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/TestLogImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/event_string/TestComponentAc.hpp> class TestLogImpl: public Somewhere::TestLogComponentBase { public: TestLogImpl(const char* compName); virtual ~TestLogImpl(); void init(); void sendEvent(I32 arg1, Fw::LogStringArg& arg2, U8 arg3); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/TestLogImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/event_string/TestLogImpl.hpp> #include <cstdio> TestLogImpl::TestLogImpl(const char* name) : Somewhere::TestLogComponentBase(name) { } TestLogImpl::~TestLogImpl() { } void TestLogImpl::init() { Somewhere::TestLogComponentBase::init(); } void TestLogImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { } void TestLogImpl::sendEvent(I32 arg1, Fw::LogStringArg& arg2, U8 arg3) { printf("Sending event args %d, %s, %d\n",arg1, arg2.toChar(), arg3); this->log_ACTIVITY_LO_SomeEvent(arg1,arg2,arg3); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/event_string/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <event_stringGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Somewhere::TestLogGTestBase { public: ATester() : Somewhere::TestLogGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/TestPrmImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/param_string/TestPrmImpl.hpp> #include <cstdio> TestPrmImpl::TestPrmImpl(const char* name) : Prm::TestPrmComponentBase(name) { } TestPrmImpl::~TestPrmImpl() { } void TestPrmImpl::init() { Prm::TestPrmComponentBase::init(); } void TestPrmImpl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { } void TestPrmImpl::printParam() { Fw::ParamValid valid = Fw::ParamValid::INVALID; const Fw::ParamString& prmRef = this->paramGet_stringparam(valid); printf("Parameter is: \"%s\" %s\n",prmRef.toChar(),valid==Fw::ParamValid::VALID?"VALID":"INVALID"); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/main.cpp
#include <Autocoders/Python/test/param_string/TestPrmImpl.hpp> #include <Autocoders/Python/test/param_string/TestPrmSourceImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestPrmImpl testImpl("TestPrmImpl"); testImpl.init(); TestParamSourceImpl prmSrc("TestPrmSrc"); prmSrc.init(); testImpl.set_ParamGet_OutputPort(0,prmSrc.get_paramGetPort_InputPort(0)); testImpl.set_ParamSet_OutputPort(0,prmSrc.get_paramSetPort_InputPort(0)); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif Fw::ParamString str("SomeParameter"); prmSrc.setPrm(str); testImpl.loadParameters(); testImpl.printParam(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/TestPrmSourceImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTPARAMRECVIMPL_HPP_ #define TESTPARAMRECVIMPL_HPP_ #include <Autocoders/Python/test/param_tester/ParamTestComponentAc.hpp> #include <Fw/Prm/PrmString.hpp> class TestParamSourceImpl: public Prm::ParamTesterComponentBase { public: TestParamSourceImpl(const char* compName); virtual ~TestParamSourceImpl(); void init(); void setPrm(Fw::ParamString& val); protected: Fw::ParamValid paramGetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val); void paramSetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val); private: Fw::ParamBuffer m_prm; }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/TestPrmSourceImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/param_string/TestPrmSourceImpl.hpp> #include <cstdio> TestParamSourceImpl::TestParamSourceImpl(const char* name) : Prm::ParamTesterComponentBase(name) { } TestParamSourceImpl::~TestParamSourceImpl() { } Fw::ParamValid TestParamSourceImpl::paramGetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val) { val = this->m_prm; return Fw::ParamValid::VALID; } void TestParamSourceImpl::paramSetPort_handler(NATIVE_INT_TYPE portNum, FwPrmIdType id, Fw::ParamBuffer &val) { } void TestParamSourceImpl::init() { Prm::ParamTesterComponentBase::init(); } void TestParamSourceImpl::setPrm(Fw::ParamString& val) { printf("Setting parameter to %s\n",val.toChar()); this->m_prm.resetSer(); Fw::SerializeStatus stat = this->m_prm.serialize(val); if (stat != Fw::FW_SERIALIZE_OK) { printf("Error serializing: %d\n",stat); } }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/TestPrmImpl.hpp
/* * TestPrmImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTPARAMIMPL_HPP_ #define TESTPARAMIMPL_HPP_ #include <Autocoders/Python/test/param_string/TestComponentAc.hpp> #include <Fw/Prm/PrmString.hpp> class TestPrmImpl: public Prm::TestPrmComponentBase { public: TestPrmImpl(const char* compName); void genTlm(U32 val); virtual ~TestPrmImpl(); void init(); void printParam(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); }; #endif /* TESTPARAMIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/param_string/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <param_stringGTestBase.hpp> #endif #include "TesterBase.hpp" #include <FpConfig.hpp> // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Prm::TestPrmGTestBase { public: ATester() : Prm::TestPrmGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/main/main.cpp
int main(int argc, char* argv[]) { return -1; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/main.cpp
#include <Autocoders/Python/test/command1/TestCommand1Impl.hpp> #include <Autocoders/Python/test/command1/TestCommandSourceImpl.hpp> #include <Fw/Obj/SimpleObjRegistry.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif TestCommand1Impl testImpl("TestCmdImpl"); testImpl.init(); TestCommandSourceImpl cmdSrc("TestCmdSource"); cmdSrc.init(); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif testImpl.set_CmdStatus_OutputPort(0,cmdSrc.get_cmdStatusPort_InputPort(0)); testImpl.set_CmdReg_OutputPort(0,cmdSrc.get_cmdRegPort_InputPort(0)); cmdSrc.set_cmdSendPort_OutputPort(0,testImpl.get_CmdDisp_InputPort(0)); testImpl.regCommands(); cmdSrc.test_TEST_CMD_1(10,25.6,5); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/TestCommand1Impl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMAND1IMPL_HPP_ #define TESTCOMMAND1IMPL_HPP_ #include <Autocoders/Python/test/command1/Test1ComponentAc.hpp> class TestCommand1Impl: public Cmd::Test1ComponentBase { public: TestCommand1Impl(const char* compName); virtual ~TestCommand1Impl(); void init(); protected: void aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6); void TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2, U8 arg3); }; #endif /* TESTCOMMAND1IMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/TestCommand1Impl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/command1/TestCommand1Impl.hpp> #include <cstdio> TestCommand1Impl::TestCommand1Impl(const char* name) : Test1ComponentBase(name) { // TODO Auto-generated constructor stub } TestCommand1Impl::~TestCommand1Impl() { // TODO Auto-generated destructor stub } void TestCommand1Impl::init() { Test1ComponentBase::init(); } void TestCommand1Impl::aport_handler(NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6) { } void TestCommand1Impl::TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2, U8 arg3) { printf("Got command args: %d %f %d\n", arg1, arg2, arg3 ); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/TestCommandSourceImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/command1/TestCommandSourceImpl.hpp> #include <cstdio> TestCommandSourceImpl::TestCommandSourceImpl(const char* name) : Cmd::CommandTesterComponentBase(name) { // TODO Auto-generated constructor stub } TestCommandSourceImpl::~TestCommandSourceImpl() { // TODO Auto-generated destructor stub } void TestCommandSourceImpl::cmdStatusPort_handler( NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse& response) { this->printStatus(response); } void TestCommandSourceImpl::cmdRegPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode) { printf("Received registration for opcode %d\n",opCode); } void TestCommandSourceImpl::init() { Cmd::CommandTesterComponentBase::init(); } void TestCommandSourceImpl::printStatus(Fw::CmdResponse response) { switch (response.e) { case Fw::CmdResponse::OK: printf("COMMAND OK\n"); break; case Fw::CmdResponse::INVALID_OPCODE: printf("INVALID OPCODE\n"); break; case Fw::CmdResponse::VALIDATION_ERROR: printf("VALIDATION ERROR\n"); break; case Fw::CmdResponse::FORMAT_ERROR: printf("FORMAT ERROR\n"); break; case Fw::CmdResponse::EXECUTION_ERROR: printf("EXECUTION ERROR\n"); break; default: printf("Unknown status %d\n", response.e); break; } } void TestCommandSourceImpl::test_TEST_CMD_1(I32 arg1, F32 arg2, U8 arg3) { // serialize parameters if (!this->isConnected_cmdSendPort_OutputPort(0)) { printf("Test command port not connected."); return; } Fw::CmdArgBuffer argBuff; // do nominal case argBuff.serialize(arg1); argBuff.serialize(arg2); argBuff.serialize(arg3); this->cmdSendPort_out(0, 0x100, 1, argBuff); // too many arguments argBuff.resetSer(); argBuff.serialize(arg1); argBuff.serialize(arg2); argBuff.serialize(arg3); argBuff.serialize(arg3); this->cmdSendPort_out(0, 0x100, 1, argBuff); // too few arguments argBuff.resetSer(); argBuff.serialize(arg1); argBuff.serialize(arg2); this->cmdSendPort_out(0, 0x100, 1, argBuff); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/TestCommandSourceImpl.hpp
/* * TestCommand1Impl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTCOMMANDSOURCEIMPL_HPP_ #define TESTCOMMANDSOURCEIMPL_HPP_ #include <Autocoders/Python/test/command_tester/CommandTestComponentAc.hpp> class TestCommandSourceImpl: public Cmd::CommandTesterComponentBase { public: TestCommandSourceImpl(const char* compName); virtual ~TestCommandSourceImpl(); void init(); void test_TEST_CMD_1(I32 arg1, F32 arg2, U8 arg3); protected: void cmdStatusPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse& response); void cmdRegPort_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode); private: void printStatus(Fw::CmdResponse response); }; #endif /* TESTCOMMANDSOURCEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/test/ut/command1Tester.hpp
// ====================================================================== // \title Test1/test/ut/Tester.hpp // \author tim // \brief hpp file for Test1 test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef TESTER_HPP #define TESTER_HPP #include "command1GTestBase.hpp" #include "Autocoders/Python/test/command1/Test1ComponentImpl.hpp" namespace Cmd { class command1Tester : public Test1GTestBase { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- public: //! Construct object command1Tester //! command1Tester(); //! Destroy object command1Tester //! ~command1Tester(); public: // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- //! To do //! void toDo(); private: // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- //! Connect ports //! void connectPorts(); //! Initialize components //! void initComponents(); private: // ---------------------------------------------------------------------- // Variables // ---------------------------------------------------------------------- //! The component under test //! Test1ComponentImpl component; }; } // end namespace Cmd #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <command1GTestBase.hpp> #endif #include "TesterBase.hpp" #include <FpConfig.hpp> // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Cmd::Test1GTestBase { public: ATester() : Cmd::Test1GTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command1/test/ut/command1Tester.cpp
// ====================================================================== // \title Test1.hpp // \author tim // \brief cpp file for Test1 test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #include "command1Tester.hpp" #define INSTANCE 0 #define MAX_HISTORY_SIZE 10 namespace Cmd { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- command1Tester :: command1Tester() : Test1GTestBase("Tester", MAX_HISTORY_SIZE), component("Test1") { this->initComponents(); this->connectPorts(); } command1Tester :: ~command1Tester() { } // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- void command1Tester :: toDo() { // TODO } // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- void command1Tester :: connectPorts() { // aport this->connect_to_aport( 0, this->component.get_aport_InputPort(0) ); // CmdDisp this->connect_to_CmdDisp( 0, this->component.get_CmdDisp_InputPort(0) ); // CmdStatus this->component.set_CmdStatus_OutputPort( 0, this->get_from_CmdStatus(0) ); // CmdReg this->component.set_CmdReg_OutputPort( 0, this->get_from_CmdReg(0) ); } void command1Tester :: initComponents() { this->init(); this->component.init( INSTANCE ); } } // end namespace Cmd
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command2/TestCommandComponentImpl.cpp
// ====================================================================== // \title TestCommandImpl.cpp // \author tim // \brief cpp file for TestCommand 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/command2/TestCommandComponentImpl.hpp> #include <FpConfig.hpp> namespace AcTest { // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- TestCommandComponentImpl :: TestCommandComponentImpl( const char *const compName ) : TestCommandComponentBase(compName) { } void TestCommandComponentImpl :: init( const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance ) { TestCommandComponentBase::init(queueDepth, instance); } TestCommandComponentImpl :: ~TestCommandComponentImpl() { } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- void TestCommandComponentImpl :: aport_handler( const NATIVE_INT_TYPE portNum, I32 arg4, F32 arg5, U8 arg6 ) { // TODO } // ---------------------------------------------------------------------- // Command handler implementations // ---------------------------------------------------------------------- void TestCommandComponentImpl :: TEST_CMD_1_cmdHandler( const FwOpcodeType opCode, const U32 cmdSeq, I32 arg1, SomeEnum arg2 ) { // TODO } } // end namespace AcTest
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command2/TestCommandComponentImpl.hpp
// ====================================================================== // \title TestCommandImpl.hpp // \author tim // \brief hpp file for TestCommand component implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef TestCommand_HPP #define TestCommand_HPP #include "Autocoders/Python/test/command2/TestComponentAc.hpp" namespace AcTest { class TestCommandComponentImpl : public TestCommandComponentBase { public: // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- //! Construct object TestCommand //! TestCommandComponentImpl( const char *const compName /*!< The component name*/ ); //! Initialize object TestCommand //! void init( const NATIVE_INT_TYPE queueDepth, /*!< The queue depth*/ const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/ ); //! Destroy object TestCommand //! ~TestCommandComponentImpl(); PRIVATE: // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- //! Handler implementation for aport //! void aport_handler( const NATIVE_INT_TYPE portNum, /*!< The port number*/ I32 arg4, /*!< The first argument*/ F32 arg5, /*!< The second argument*/ U8 arg6 /*!< The third argument*/ ); PRIVATE: // ---------------------------------------------------------------------- // Command handler implementations // ---------------------------------------------------------------------- //! Implementation for TEST_CMD_1 command handler //! A test command void TEST_CMD_1_cmdHandler( const FwOpcodeType opCode, /*!< The opcode*/ const U32 cmdSeq, /*!< The command sequence number*/ I32 arg1, /*!< The I32 command argument*/ SomeEnum arg2 /*!< The ENUM argument*/ ); }; } // end namespace AcTest #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/command2/test/ut/command2Tester.cpp
// ====================================================================== // \title TestCommand.hpp // \author tim // \brief cpp file for TestCommand test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #include "command2Tester.hpp" #define INSTANCE 0 #define MAX_HISTORY_SIZE 10 #define QUEUE_DEPTH 10 namespace AcTest { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- command2Tester :: command2Tester() : TestCommandGTestBase("Tester", MAX_HISTORY_SIZE), component("TestCommand") { this->initComponents(); this->connectPorts(); } command2Tester :: ~command2Tester() { } // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- void command2Tester :: msgTest() { for (NATIVE_UINT_TYPE iter=0; iter <= QUEUE_DEPTH; iter++) { this->sendCmd_TEST_CMD_1( 0, //!< The instance number 10, //!< The command sequence number 20, //!< The I32 command argument TestCommandComponentBase::MEMB1 //!< The ENUM argument ); } ASSERT_EQ(this->component.m_msgsDropped,1); } // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- void command2Tester :: connectPorts() { // aport this->connect_to_aport( 0, this->component.get_aport_InputPort(0) ); // CmdDisp this->connect_to_CmdDisp( 0, this->component.get_CmdDisp_InputPort(0) ); // CmdStatus this->component.set_CmdStatus_OutputPort( 0, this->get_from_CmdStatus(0) ); // CmdReg this->component.set_CmdReg_OutputPort( 0, this->get_from_CmdReg(0) ); } void command2Tester :: initComponents() { this->init(); this->component.init( QUEUE_DEPTH, INSTANCE ); } } // end namespace AcTest
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command2/test/ut/main.cpp
// ---------------------------------------------------------------------- // Main.cpp // ---------------------------------------------------------------------- #include "command2Tester.hpp" TEST(Test, Miscellaneous) { AcTest::command2Tester tester; tester.msgTest(); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/command2/test/ut/command2Tester.hpp
// ====================================================================== // \title TestCommand/test/ut/Tester.hpp // \author tim // \brief hpp file for TestCommand test harness implementation class // // \copyright // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. // // ====================================================================== #ifndef TESTER_HPP #define TESTER_HPP #include "command2GTestBase.hpp" #include "Autocoders/Python/test/command2/TestCommandComponentImpl.hpp" namespace AcTest { class command2Tester : public TestCommandGTestBase { // ---------------------------------------------------------------------- // Construction and destruction // ---------------------------------------------------------------------- public: //! Construct object command2Tester //! command2Tester(); //! Destroy object command2Tester //! ~command2Tester(); public: // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- //! To do //! void msgTest(); private: // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- //! Connect ports //! void connectPorts(); //! Initialize components //! void initComponents(); private: // ---------------------------------------------------------------------- // Variables // ---------------------------------------------------------------------- //! The component under test //! TestCommandComponentImpl component; }; } // end namespace AcTest #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/time_tester/TestTimeImpl.cpp
/* * TestCommand1Impl.cpp * * Created on: Mar 28, 2014 * Author: tcanham */ #include <Autocoders/Python/test/time_tester/TestTimeImpl.hpp> #include <cstdio> TestTimeImpl::TestTimeImpl(const char* name) : Time::TimeTesterComponentBase(name) { } TestTimeImpl::~TestTimeImpl() { } void TestTimeImpl::timeGetPort_handler( NATIVE_INT_TYPE portNum, /*!< The port number*/ Fw::Time &time /*!< The U32 cmd argument*/ ) { time = this->m_time; } void TestTimeImpl::init() { Time::TimeTesterComponentBase::init(); } void TestTimeImpl::setTime(Fw::Time time) { printf("Setting time to (%d,%d,%d)\n",time.getSeconds(),time.getUSeconds(),time.getTimeBase()); this->m_time = time; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/time_tester/TestTimeImpl.hpp
/* * TestTelemRecvImpl.hpp * * Created on: Mar 28, 2014 * Author: tcanham */ #ifndef TESTTIMEIMPL_HPP_ #define TESTTIMEIMPL_HPP_ #include <Autocoders/Python/test/time_tester/TimeTestComponentAc.hpp> class TestTimeImpl: public Time::TimeTesterComponentBase { public: TestTimeImpl(const char* compName); virtual ~TestTimeImpl(); void init(); void setTime(Fw::Time time); protected: void timeGetPort_handler( NATIVE_INT_TYPE portNum, /*!< The port number*/ Fw::Time &time /*!< The U32 cmd argument*/ ); private: Fw::Time m_time; }; #endif /* TESTTIMEIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/time_tester/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <time_testerGTestBase.hpp> #endif #include "TesterBase.hpp" #include <FpConfig.hpp> // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Time::TimeTesterGTestBase { public: ATester() : Time::TimeTesterGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/main.cpp
#include <Fw/Obj/SimpleObjRegistry.hpp> #include <Autocoders/Python/test/port_nogen/ExampleComponentImpl.hpp> int main(int argc, char* argv[]) { #if FW_PORT_TRACING Fw::PortBase::setTrace(true); #endif #if FW_OBJECT_REGISTRATION == 1 Fw::SimpleObjRegistry objReg; #endif ExampleComponents::ExampleComponentImpl impl("impl"); impl.init(10); #if FW_OBJECT_REGISTRATION == 1 objReg.dump(); #endif // This is empty just to get it to link to check for missing symbols }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/ExampleComponentImpl.hpp
/* * ExampleComponentImpl.hpp * * Created on: Nov 3, 2014 * Author: tcanham */ #ifndef EXAMPLECOMPONENTIMPL_HPP_ #define EXAMPLECOMPONENTIMPL_HPP_ #include <Autocoders/Python/test/port_nogen/ExampleComponentAc.hpp> namespace ExampleComponents { class ExampleComponentImpl: public ExampleComponentBase { public: ExampleComponentImpl(const char* name); void init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance = 0); virtual ~ExampleComponentImpl(); protected: private: void exampleInput_handler(NATIVE_INT_TYPE portNum, I32 arg1, const ANameSpace::mytype& arg2, U8 arg3, const Example3::ExampleSerializable& arg4, AnotherExample::SomeEnum arg5); void TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, ExampleComponentBase::CmdEnum arg2, const Fw::CmdStringArg& arg3); void TEST_CMD_2_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2); }; } /* namespace ExampleComponents */ #endif /* EXAMPLECOMPONENTIMPL_HPP_ */
hpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/ExampleType.hpp
#ifndef EXAMPLE_TYPE_HPP #define EXAMPLE_TYPE_HPP // A hand-coded serializable #include <FpConfig.hpp> #include <Fw/Types/Serializable.hpp> #if FW_SERIALIZABLE_TO_STRING #include <Fw/Types/StringType.hpp> #include <cstdio> // snprintf #endif namespace ANameSpace { class mytype : public Fw::Serializable { public: enum { SERIALIZED_SIZE = sizeof(U32), TYPE_ID = 2000 }; mytype(); // Default constructor mytype(const mytype* src); // copy constructor mytype(const mytype& src); // copy constructor mytype(U32 arg); // constructor with arguments mytype& operator=(const mytype& src); // Equal operator bool operator==(const mytype& src) const; // equality operator void setVal(U32 arg); // set values U32 getVal(); Fw::SerializeStatus serialize(Fw::SerializeBufferBase& buffer) const; Fw::SerializeStatus deserialize(Fw::SerializeBufferBase& buffer); #if FW_SERIALIZABLE_TO_STRING void toString(Fw::StringBase& text) const; //!< generate text from serializable #endif protected: private: U32 m_val; // stored value }; } #endif
hpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/ExampleComponentImpl.cpp
/* * ExampleComponentImpl.cpp * * Created on: Nov 3, 2014 * Author: tcanham */ #include <Autocoders/Python/test/port_nogen/ExampleComponentImpl.hpp> #include <cstdio> namespace ExampleComponents { ExampleComponentImpl::ExampleComponentImpl(const char* name) : ExampleComponentBase(name) { } ExampleComponentImpl::~ExampleComponentImpl() { } void ExampleComponentImpl::init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance) { ExampleComponentBase::init(queueDepth,instance); } void ExampleComponentImpl::exampleInput_handler(NATIVE_INT_TYPE portNum, I32 arg1, const ANameSpace::mytype& arg2, U8 arg3, const Example3::ExampleSerializable& arg4, AnotherExample::SomeEnum arg5) { Fw::TlmString arg = "A string arg"; // write some telemetry U32 tlmval = 0; this->tlmWrite_stringchan(tlmval); // call the output port if (this->isConnected_exampleOutput_OutputPort(0)) { this->exampleOutput_out(0,arg1,arg2,arg3,arg4,arg5); } else { printf("Output port not connected.\n"); } } void ExampleComponentImpl::TEST_CMD_1_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, ExampleComponentBase::CmdEnum arg2, const Fw::CmdStringArg& arg3) { // issue the test event with the opcode Fw::LogStringArg str = "TEST_CMD_1"; this->log_FATAL_SomeEvent(opCode, static_cast<F32>(arg1), 0, str,ExampleComponentBase::EVENT_MEMB2); // write a value to a telemetry channel U32 chan = 12; this->tlmWrite_somechan(chan); this->cmdResponse_out(opCode,cmdSeq, Fw::CmdResponse::OK); } void ExampleComponentImpl::TEST_CMD_2_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, I32 arg1, F32 arg2) { Fw::LogStringArg str = "TEST_CMD_2"; this->log_FATAL_SomeEvent(opCode,arg2, 0, str,ExampleComponentBase::EVENT_MEMB3); U32 tlmval = 0; this->tlmWrite_anotherchan(tlmval); // <! Example output port this->cmdResponse_out(opCode,cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); } } /* namespace ExampleComponents */
cpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/ExampleType.cpp
#include <Autocoders/Python/test/port_nogen/ExampleType.hpp> #include <Fw/Types/Assert.hpp> namespace ANameSpace { mytype::mytype(): Serializable() { } mytype::mytype(const mytype& src) : Serializable() { this->setVal(src.m_val); } mytype::mytype(const mytype* src) : Serializable() { FW_ASSERT(src); this->setVal(src->m_val); } mytype::mytype(U32 val) : Serializable() { this->setVal(val); } mytype& mytype::operator=(const mytype& src) { this->setVal(src.m_val); return *this; } bool mytype::operator==(const mytype& src) const { return (this->m_val == src.m_val); } U32 mytype::getVal() { return this->m_val; } void mytype::setVal(U32 val) { this->m_val = val; } Fw::SerializeStatus mytype::serialize(Fw::SerializeBufferBase& buffer) const { Fw::SerializeStatus stat = buffer.serialize(this->m_val); if (Fw::FW_SERIALIZE_OK != stat) { return stat; } return buffer.serialize(static_cast<NATIVE_INT_TYPE>(mytype::TYPE_ID)); } Fw::SerializeStatus mytype::deserialize(Fw::SerializeBufferBase& buffer) { NATIVE_INT_TYPE id; Fw::SerializeStatus stat = buffer.deserialize(id); if (Fw::FW_SERIALIZE_OK != stat) { return stat; } if (id != static_cast<NATIVE_INT_TYPE>(mytype::TYPE_ID)) { return Fw::FW_DESERIALIZE_TYPE_MISMATCH; } return buffer.deserialize(this->m_val); } #if FW_SERIALIZABLE_TO_STRING void mytype::toString(Fw::StringBase& text) const { static const char * formatString = "(val = %u)"; // declare strings to hold any serializable toString() arguments char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE]; snprintf(outputString,FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,formatString,this->m_val); outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate text = outputString; } #endif }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/port_nogen/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <port_nogenGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public ExampleComponents::ExampleGTestBase { public: ATester() : ExampleComponents::ExampleGTestBase("comp",10) { } void from_exampleOutput_handler( const NATIVE_INT_TYPE portNum, //!< The port number I32 arg1, //!< A built-in type argument const ANameSpace::mytype& arg2, //!< A user-defined type argument U8 arg3, //!< The third argument const Example3::ExampleSerializable& arg4, //!< The third argument AnotherExample::SomeEnum arg5 //!< The ENUM argument ); }; void ATester::from_exampleOutput_handler( const NATIVE_INT_TYPE portNum, //!< The port number I32 arg1, //!< A built-in type argument const ANameSpace::mytype& arg2, //!< A user-defined type argument U8 arg3, //!< The third argument const Example3::ExampleSerializable& arg4, //!< The third argument AnotherExample::SomeEnum arg5 //!< The ENUM argument ) { } int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/serialize_stringbuffer/test/ut/main.cpp
#include <Autocoders/Python/test/serialize_stringbuffer/ExampleSerializableAc.hpp> int main(int argc, char** argv) { Example3::ExampleSerializable ex; return 0; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/comp_no_namespace/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <comp_no_namespaceGTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public TestCommandGTestBase { public: ATester() : TestCommandGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/telem_tester/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <telem_testerGTestBase.hpp> #endif #include "TesterBase.hpp" #include <FpConfig.hpp> // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TelemTesterTesterBase { public: ATester() : Tlm::TelemTesterTesterBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp
fprime
data/projects/fprime/Autocoders/Python/test/log1/test/ut/main.cpp
#ifdef FPRIME_CMAKE #include "Autocoder/GTestBase.hpp" #else #include <log1GTestBase.hpp> #endif // Very minimal to test autocoder. Some day they'll be actual unit test code class ATester : public Tlm::TestEventGTestBase { public: ATester() : Tlm::TestEventGTestBase("comp",10) { } }; int main(int argc, char* argv[]) { ATester testBase; }
cpp