Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devin/feature/create deployables interface fprime component #20

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ Gemfile.lock
persistent/.bash_history

# For fprime lib
cubics-obc-test/fprime/**
cubics-obc-test/fprime**

# For Fprime project builds and auto generated code
cubics-obc-test/build**
cubics-obc-test/venv/**

# For individual component builds and auto generated code
# For auto generated code
cubics-obc-test/BurnwireTester/build**
cubics-obc-test/BurnwireTester/logs/**

cubics-obc-test/SimulationDeployment/build**
cubics-obc-test/SimulationDeployment/logs/**


8 changes: 7 additions & 1 deletion cubics-obc-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ include("${CMAKE_CURRENT_LIST_DIR}/fprime/cmake/FPrime.cmake")
# NOTE: register custom targets between these two lines
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime-Code.cmake")


# This includes project-wide objects
include("${CMAKE_CURRENT_LIST_DIR}/project.cmake")


### Manually added CMAKE stuff:

# Enables debug symbols in compilation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

140 changes: 61 additions & 79 deletions cubics-obc-test/Components/Burnwire/Burnwire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,89 @@
// \brief cpp file for Burnwire component implementation class
// ======================================================================


#include <Components/Burnwire/Burnwire.hpp>
#include <FpConfig.hpp>
#include <Fw/Types/LogicEnumAc.hpp>

namespace Components {

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

Burnwire ::
Burnwire(
const char *const compName
) : BurnwireComponentBase(compName)
{
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

}
Burnwire ::Burnwire(const char *const compName)
: BurnwireComponentBase(compName) {}

Burnwire ::
~Burnwire()
{
Burnwire ::~Burnwire() {}

}

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

/*
* When ACTIVATE_BURNWIRE_cmdHandler() toggles the burnwire state to Fw::On::ON, and
* sets the counter value is to zero, this function toggles the burnwire GPIO high.
* This function will report via telemetry and log the burnwire state, and increment
* a counter once per second. Once the counter value exceeds BURNWIRE_TIME_SECONDS,
* the state is set of OFF. The counter value is not reset here in case the state is
* somehow set to ON erronesouly, then the function will simply set the state to back
* to OFF.
*
* A 1Hz rate group timer output must be attached to the input port of this component.
* This is done within the topology.fpp file of the deployment using it.
* When ACTIVATE_BURNWIRE_cmdHandler() toggles the burnwire state to
* Fw::On::ON, and sets the counter value is to zero, this function toggles the
* burnwire GPIO high. This function will report via telemetry and log the
* burnwire state, and increment a counter once per second. Once the counter
* value exceeds BURNWIRE_TIME_SECONDS, the state is set of OFF. The counter
* value is not reset here in case the state is somehow set to ON erronesouly,
* then the function will simply set the state to back to OFF.
*
* A 1Hz rate group timer output must be attached to the input port of this
* component. This is done within the topology.fpp file of the deployment using
* it.
*/
void Burnwire ::
run_handler(
const NATIVE_INT_TYPE portNum,
NATIVE_UINT_TYPE context
)
{
if(state == Fw::On::ON){
if(count >= BURNWIRE_TIME_SECONDS){
//Turn off gpio
//reset state to off
// Port may not be connected, so check before sending output
// if (this->isConnected_gpioSet_OutputPort(0))
// {
// this->gpioSet_out(0, Fw::Logic::LOW);
state = Fw::On::OFF;
this->tlmWrite_BurnwireState(state);
this->log_ACTIVITY_HI_SetBurnwireState(state);
// }
}
else if(count == 0){
//turn on gpio
// if (this->isConnected_gpioSet_OutputPort(0))
// {
// this->gpioSet_out(0, Fw::Logic::HIGH);
this->tlmWrite_BurnwireState(state);
this->log_ACTIVITY_HI_SetBurnwireState(state);
count = count + 1;
// }
}
else{
count = count+1;
this->tlmWrite_BurnwireCounter(count);
}
void Burnwire ::run_handler(const NATIVE_INT_TYPE portNum,
NATIVE_UINT_TYPE context) {
if (state == Fw::On::ON) {
if (count >= BURNWIRE_TIME_SECONDS) {
// Turn off gpio
// reset state to off
// Port may not be connected, so check before sending output
// if (this->isConnected_gpioSet_OutputPort(0))
// {
// this->gpioSet_out(0, Fw::Logic::LOW);
state = Fw::On::OFF;
this->tlmWrite_BurnwireState(state);
this->log_ACTIVITY_HI_SetBurnwireState(state);
// }
} else if (count == 0) {
// turn on gpio
// if (this->isConnected_gpioSet_OutputPort(0))
// {
// this->gpioSet_out(0, Fw::Logic::HIGH);
this->tlmWrite_BurnwireState(state);
this->log_ACTIVITY_HI_SetBurnwireState(state);
count = count + 1;
// }
} else {
count = count + 1;
this->tlmWrite_BurnwireCounter(count);
}
}
}
}

// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------

/*
* Sets the burnwire state to ON and resets the counter to zero. This will allow the
* run_handler to begin.
* Sets the burnwire state to ON and resets the counter to zero. This will
* allow the run_handler to begin.
*/
void Burnwire ::
ACTIVATE_BURNWIRE_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq
)
{
void Burnwire ::ACTIVATE_BURNWIRE_cmdHandler(const FwOpcodeType opCode,
const U32 cmdSeq) {
// Create a variable to represent the command response
auto cmdResp = Fw::CmdResponse::OK;

state = Fw::On::ON;
count = 0;
count = 0;
this->tlmWrite_BurnwireCounter(count);

//run_handler function uses a scheduled input port to receive calls from rate group. If the burnwire state is 'off', ignore them.

this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
// run_handler function uses a scheduled input port to receive calls from
// rate group. If the burnwire state is 'off', ignore them.

this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

} // end namespace Components
86 changes: 40 additions & 46 deletions cubics-obc-test/Components/Burnwire/Burnwire.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,46 @@

namespace Components {

class Burnwire :
public BurnwireComponentBase
{

public:

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object Burnwire
//!
Burnwire(
const char *const compName /*!< The component name*/
);

//! Destroy object Burnwire
//!
~Burnwire();

PRIVATE:

// Component state tracking variables
Fw::On state; //Tracks state of whether or not burnwire is on or off.
U32 count; //Incremented over a 1Hz rate group, until a certain time has passed

// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------

//! Handler implementation for run
//!
void run_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
NATIVE_UINT_TYPE context /*!< The call order*/
);

//! Implementation for ACTIVATE_BURNWIRE command handler
//! Comand to activate the burnwire
void ACTIVATE_BURNWIRE_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq /*!< The command sequence number*/
);


};
class Burnwire : public BurnwireComponentBase {

public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object Burnwire
//!
Burnwire(const char *const compName /*!< The component name*/
);

//! Destroy object Burnwire
//!
~Burnwire();

PRIVATE :

// Component state tracking variables
Fw::On state; // Tracks state of whether or not burnwire is on or off.
U32 count; // Incremented over a 1Hz rate group, until a certain time has
// passed

// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------

//! Handler implementation for run
//!
void run_handler(const NATIVE_INT_TYPE portNum, /*!< The port number*/
NATIVE_UINT_TYPE context /*!< The call order*/
);

//! Implementation for ACTIVATE_BURNWIRE command handler
//! Comand to activate the burnwire
void ACTIVATE_BURNWIRE_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq /*!< The command sequence number*/
);
};

} // end namespace Components

Expand Down
21 changes: 21 additions & 0 deletions cubics-obc-test/Components/DeployablesInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
# UT_SOURCE_FILES: list of source files for unit tests
#
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/DeployablesInterface.fpp"
"${CMAKE_CURRENT_LIST_DIR}/DeployablesInterface.cpp"
)

# Uncomment and add any modules that this component depends on, else
# they might not be available when cmake tries to build this component.

# set(MOD_DEPS
# Add your dependencies here
# )

register_fprime_module()
Loading