Skip to content
Merged
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
112 changes: 112 additions & 0 deletions StarsProj/Arg_Actions_Component/Arg_Actions_Component.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// ======================================================================
// \title Arg_Actions_Component.cpp
// \author watney
// \brief cpp file for Arg_Actions_Component component implementation class
// ======================================================================

#include "Arg_Actions_Component/Arg_Actions_Component.hpp"

namespace Components {

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

Arg_Actions_Component ::Arg_Actions_Component(const char* const compName)
: Arg_Actions_ComponentComponentBase(compName), m_g1Value(false), m_g2Value(false), m_evCount(0) {}

Arg_Actions_Component ::~Arg_Actions_Component() {}

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

void Arg_Actions_Component ::schedIn_handler(FwIndexType portNum, U32 context) {
// Send EV1 signal with incrementing U16 parameter
// Alternate g1 value to test guard behavior
m_g1Value = !m_g1Value;
argActionsState_sendSignal_EV1(static_cast<U16>(m_evCount++));
}

void Arg_Actions_Component ::schedIn2_handler(FwIndexType portNum, U32 context) {
// Send EV2 signal to test g2 guard
// Alternate g2 value to test guard behavior
m_g2Value = !m_g2Value;
argActionsState_sendSignal_EV2();
}

// ----------------------------------------------------------------------
// Implementations for internal state machine actions
// ----------------------------------------------------------------------

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_a1(SmId smId,
Components_Arg_Actions_FP::Signal signal,
U16 value) {
this->log_ACTIVITY_HI_a1Event(value);
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_a2(SmId smId, Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_a2Event();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_foo(SmId smId, Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_fooEvent();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Entry(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s1EntryEvent();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Entry2(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s1Entry2Event();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Exit(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s1ExitEvent();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Exit2(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s1Exit2Event();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Entry(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s2EntryEvent();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Entry2(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s2Entry2Event();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Exit(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s2ExitEvent();
}

void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Exit2(SmId smId,
Components_Arg_Actions_FP::Signal signal) {
this->log_ACTIVITY_HI_s2Exit2Event();
}

// ----------------------------------------------------------------------
// Implementations for internal state machine guards
// ----------------------------------------------------------------------

bool Arg_Actions_Component ::Components_Arg_Actions_FP_guard_g1(SmId smId,
Components_Arg_Actions_FP::Signal signal,
U16 value) const {
printf("---- g1 value = %d\n", value);
return m_g1Value;
}

bool Arg_Actions_Component ::Components_Arg_Actions_FP_guard_g2(SmId smId,
Components_Arg_Actions_FP::Signal signal) const {
return m_g2Value;
}

} // namespace Components
37 changes: 37 additions & 0 deletions StarsProj/Arg_Actions_Component/Arg_Actions_Component.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Components {
include "Arg_Actions_FP_State_Machine.fppi"

@ Component wrapper for Arg_Actions_FP state machine
active component Arg_Actions_Component {

state machine instance argActionsState: Arg_Actions_FP

async input port schedIn: Svc.Sched
async input port schedIn2: Svc.Sched

event s1EntryEvent() severity activity high id 0 format "s1Entry Event"
event s1Entry2Event() severity activity high id 1 format "s1Entry2 Event"
event s1ExitEvent() severity activity high id 2 format "s1Exit Event"
event s1Exit2Event() severity activity high id 3 format "s1Exit2 Event"
event s2EntryEvent() severity activity high id 4 format "s2Entry Event"
event s2Entry2Event() severity activity high id 5 format "s2Entry2 Event"
event s2ExitEvent() severity activity high id 6 format "s2Exit Event"
event s2Exit2Event() severity activity high id 7 format "s2Exit2 Event"
event a1Event(value: U16) severity activity high id 8 format "a1 action with value {}"
event a2Event() severity activity high id 9 format "a2 Event"
event fooEvent() severity activity high id 10 format "foo Event"

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

@ Enables command handling
import Fw.Command

@ Enables event handling
import Fw.Event

}
}
130 changes: 130 additions & 0 deletions StarsProj/Arg_Actions_Component/Arg_Actions_Component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// ======================================================================
// \title Arg_Actions_Component.hpp
// \author watney
// \brief hpp file for Arg_Actions_Component component implementation class
// ======================================================================

#ifndef Components_Arg_Actions_Component_HPP
#define Components_Arg_Actions_Component_HPP

#include "Arg_Actions_Component/Arg_Actions_ComponentComponentAc.hpp"

namespace Components {

class Arg_Actions_Component final : public Arg_Actions_ComponentComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

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

//! Destroy Arg_Actions_Component object
~Arg_Actions_Component();

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

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

//! Handler implementation for schedIn2
void schedIn2_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;

private:
// ----------------------------------------------------------------------
// Implementations for internal state machine actions
// ----------------------------------------------------------------------

//! Implementation for action a1 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_a1(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal, //!< The signal
U16 value //!< The value
) override;

//! Implementation for action a2 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_a2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action foo of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_foo(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s1Entry of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s1Entry(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s1Entry2 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s1Entry2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s1Exit of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s1Exit(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s1Exit2 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s1Exit2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s2Entry of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s2Entry(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s2Entry2 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s2Entry2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s2Exit of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s2Exit(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

//! Implementation for action s2Exit2 of state machine Components_Arg_Actions_FP
void Components_Arg_Actions_FP_action_s2Exit2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) override;

private:
// ----------------------------------------------------------------------
// Implementations for internal state machine guards
// ----------------------------------------------------------------------

//! Implementation for guard g1 of state machine Components_Arg_Actions_FP
bool Components_Arg_Actions_FP_guard_g1(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal, //!< The signal
U16 value //!< The value
) const override;

//! Implementation for guard g2 of state machine Components_Arg_Actions_FP
bool Components_Arg_Actions_FP_guard_g2(SmId smId, //!< The state machine id
Components_Arg_Actions_FP::Signal signal //!< The signal
) const override;
private:
// ----------------------------------------------------------------------
// Member variables for guard state
// ----------------------------------------------------------------------
bool m_g1Value;
bool m_g2Value;
U32 m_evCount;

};

} // namespace Components

#endif
20 changes: 20 additions & 0 deletions StarsProj/Arg_Actions_Component/Arg_Actions_FP.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

@startuml

[*] --> S1

state S1 {
S1:Entry: s1Entry(); s1Entry2(); foo()
S1:Exit: s1Exit(); s1Exit2(); foo()
}

state S2 {
S2:Entry: s2Entry(); s2Entry2(); foo()
S2:Exit: s2Exit(); s2Exit2()
}

S1 --> S2: EV1[g1(U16)]
S1 --> S2: EV2[g2()]
S2 --> S1: EV1/a1(U16); a2(); foo()

@enduml
35 changes: 35 additions & 0 deletions StarsProj/Arg_Actions_Component/Arg_Actions_FP_State_Machine.fppi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
state machine Arg_Actions_FP {

action a1: U16
action a2
action foo
action s1Entry
action s1Entry2
action s1Exit
action s1Exit2
action s2Entry
action s2Entry2
action s2Exit
action s2Exit2

guard g1: U16
guard g2

signal EV1: U16
signal EV2

initial enter S1
state S1 {
entry do { s1Entry, s1Entry2, foo }
exit do { s1Exit, s1Exit2, foo }
on EV1 if g1 enter S2
on EV2 if g2 enter S2
}

state S2 {
entry do { s2Entry, s2Entry2, foo }
exit do { s2Exit, s2Exit2 }
on EV1 do { a1, a2, foo } enter S1
}

}
34 changes: 34 additions & 0 deletions StarsProj/Arg_Actions_Component/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
####
# 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
# `MyProj/Some/Path/CMakeLists.txt` will be named `MyProj_Some_Path`.

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

### Unit Tests ###
register_fprime_ut(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/Arg_Actions_Component.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Arg_Actions_ComponentTestMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Arg_Actions_ComponentTester.cpp"
UT_AUTO_HELPERS
)
2 changes: 2 additions & 0 deletions StarsProj/Arg_Actions_Component/autocode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
../../autocoder/Stars.py -backend fprime -noImpl -model Arg_Actions_FP.plantuml
21 changes: 21 additions & 0 deletions StarsProj/Arg_Actions_Component/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Components::Arg_Actions_Component

Component wrapper for Arg_Actions_FP state machine

## Introduction

<!-- High level introduction, FPP interfaces?, high-level features? -->

## Requirements

| Name | Description | Rationale | Validation |
|---|---|---|---|
| | | | |

## Design

<!-- Explain high level design and important internal details -->

## Configuration

<!-- If the component requires configuration at initialization, document here -->
Loading
Loading