Skip to content
Closed
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
71 changes: 71 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ======================================================================
// \title Burnwire.cpp
// \author aldjia
// \brief cpp file for Burnwire component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Burnwire/Burnwire.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

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

Burnwire ::~Burnwire() {}

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

// void Burnwire ::stop_handler(FwIndexType portNum) {
// //TODO
// }

void Burnwire ::schedIn_handler(FwIndexType portNum, U32 context) {
if (this->m_state == Fw::On::ON) {
this->m_safetyCounter++;
if (this->m_safetyCounter == 1) {
this->gpioSet_out(0, Fw::Logic::HIGH);
this->gpioSet_out(1, Fw::Logic::HIGH);
this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::ON);
}

if (this->m_safetyCounter >= m_safetyMaxCount) {
// 30 seconds reached → turn OFF
this->gpioSet_out(0, Fw::Logic::LOW);
this->gpioSet_out(1, Fw::Logic::LOW);

this->m_state = Fw::On::OFF;
this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF);
this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::OFF);
}
}
}

// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------

void Burnwire ::START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
// reset count to 0
this->m_safetyCounter = 0;
// update private member variable
this->m_state = Fw::On::ON;
// send event
this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::ON);
// confirm response
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

void Burnwire ::STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
this->m_state = Fw::On::OFF;
this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
this->gpioSet_out(0, Fw::Logic::LOW);
this->gpioSet_out(1, Fw::Logic::LOW);
}

} // namespace Components
78 changes: 78 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module Components {
@ Turns Burnwire on and off
passive component Burnwire {

##############################################################################
#### Uncomment the following examples to start customizing your component ####
##############################################################################

# @ Examplesync command
sync command START_BURNWIRE(
)

sync command STOP_BURNWIRE(
)

# @ Example telemetry counter
# telemetry ExampleCounter: U64

# @ Example event
# event ExampleStateEvent(example_state: Fw.On) severity activity high id 0 format "State set to {}"
event SetBurnwireState(burnwire_state: Fw.On) \
severity activity high \
format "Burnwire State: {}"

event SafetyTimerStatus(burnwire_state: Fw.On) \
severity activity high\
format "Safety Timer State: {} "

# @ Example port: receiving calls from the rate group
# sync input port run: Svc.Sched

@ Port getting start signal
sync input port burnStart: Fw.Signal

@ Port getting stop signal
sync input port burnStop: Fw.Signal

@ Input Port to get the rate group
sync input port schedIn: Svc.Sched

@ Port sending calls to the GPIO driver to stop and start the burnwire
output port gpioSet: [2] Drv.GpioWrite

# @ Example parameter
# param PARAMETER_NAME: U32

###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
###############################################################################
@ Port for requesting the current time
time get port timeCaller

@ Port for sending command registrations
command reg port cmdRegOut

@ Port for receiving commands
command recv port cmdIn

@ Port for sending command responses
command resp port cmdResponseOut

@ Port for sending textual representation of events
text event port logTextOut

@ Port for sending events to downlink
event port logOut

@ Port for sending telemetry channels to downlink
telemetry port tlmOut

@ Port to return the value of a parameter
param get port prmGetOut

@Port to set the value of a parameter
param set port prmSetOut

}
}
60 changes: 60 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ======================================================================
// \title Burnwire.hpp
// \author aldjia
// \brief hpp file for Burnwire component implementation class
// ======================================================================

#ifndef Components_Burnwire_HPP
#define Components_Burnwire_HPP

#include <atomic>
#include "FprimeZephyrReference/Components/Burnwire/BurnwireComponentAc.hpp"

namespace Components {

class Burnwire final : public BurnwireComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

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

//! Destroy Burnwire object
~Burnwire();

private:
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for stop
//!
//! Port to start and stop the burnwire

void schedIn_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;

private:
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------

//! Handler implementation for command START_BURNWIRE
void START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;

//! Handler implementation for command STOP_BURNWIRE
void STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;

Fw::On m_state = Fw::On::OFF; // keeps track if burnwire is on or off
std::atomic<U32> m_safetyCounter; // makes this an atomic variable (so its set only in one command),
// you read and write half the value bc a corrupted read could be dangerouts
U32 m_safetyMaxCount = 5; // make this a aparamater
};

} // namespace Components

#endif
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Burnwire.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
58 changes: 58 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Components::Burnwire

Driving the Burnwire on and off. The deployment will be handled by the Antenna Deployment component TODO ADD details

## Sequence Diagrams
Add sequence diagrams here

## Requirements
Add requirements in the chart below
| Name | Description | Validation |
| ---- | ----------- | ------ |
|BW-001|The burnwire shall turn on in response to a port call |Hardware Test|
|BW-002|The burnwire shall turn off in response to a port call |Hardware Test|
|BW-003|The burnwire component shall provide an Event when it is turned on and off |Integration Test|
|BW-004|The burnwire component shall activate by turning the GPIO pins on one at a time |Integration Test|
|BW-005|The burnwire component shall be controlled by a safety timeout attached to a 1Hz rate group that can be changed within the code |Integration Test|
|BW-006|The burnwire safety time shall emit an event when it starts and stops |Integration Test|

## Port Descriptions
Name | Type | Description |
|----|---|---|
|burnStop|`Fw::Signal`|Receive stop signal to stop the burnwire|
|burnStart|`Fw::Signal`|Receive start signal to start burnwire|
|gpioSet|`Drv::GpioWrite`|Control GPIO state to driver|
|schedIn|[`Svc::Sched`]| run | Input | Synchronous | Receive periodic calls from rate group


## Commands
| Name | Description |
| ---- | ----------- |
|START_BURNWIRE|Starts the Burn|
|STOP_BURNWIRE|Stops the Burn|

## Events
| Name | Description |
|---|---|
|Burnwire_Start|Emitted once the burnwire has started|
|Burnwire_Stop|Emitted once the burnwire has ended|


## Component States
Add component states in the chart below
| Name | Description |
|----|---|
|m_state|Keeps track if the burnwire is on or off|


## Unit Tests
Add unit test descriptions in the chart below
| Name | Description | Output | Coverage |
|TestSafety|Tests Burnwire turns off after X seconds|---|---|
|TestOn|Tests right GPIO pins turn on |---|---|
|TestOn|Tests right GPIO pins turn off, same as |---|---|


## Parameter
| Name | Description |
| m_safetyMaxCount | The maximum amount that the burnwire will burn before stopping itself for safety |
2 changes: 2 additions & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DistanceSensor/")
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/DistanceSensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/DistanceSensor.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/DistanceSensor.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/DistanceSensor.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/DistanceSensorTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/DistanceSensorTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
19 changes: 19 additions & 0 deletions FprimeZephyrReference/Components/DistanceSensor/DistanceSensor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ======================================================================
// \title DistanceSensor.cpp
// \author aldjia
// \brief cpp file for DistanceSensor component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/DistanceSensor/DistanceSensor.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

DistanceSensor ::DistanceSensor(const char* const compName) : DistanceSensorComponentBase(compName) {}

DistanceSensor ::~DistanceSensor() {}

} // namespace Components
Loading
Loading