Skip to content

Commit

Permalink
update FppTest for new autocoder changes
Browse files Browse the repository at this point in the history
  • Loading branch information
watney committed Aug 26, 2024
1 parent 112b60b commit ff7b023
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 15 deletions.
1 change: 1 addition & 0 deletions FppTest/state_machine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/SmTest.fpp"
"${CMAKE_CURRENT_LIST_DIR}/DeviceSm.cpp"
)
set(MOD_DEPS Fw/SMSignal)

register_fprime_module()

Expand Down
6 changes: 3 additions & 3 deletions FppTest/state_machine/DeviceSm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void FppTest::DeviceSm::init()
}


void FppTest::DeviceSm::update(const Fw::SMSignals *e)
void FppTest::DeviceSm::update(const DeviceSmEvents signal, const Fw::SMSignalBuffer &data)
{
switch (this->state) {

Expand All @@ -28,7 +28,7 @@ void FppTest::DeviceSm::update(const Fw::SMSignals *e)
*/
case OFF:

switch (e->geteventSignal()) {
switch (signal) {

case RTI_SIG:
this->state = ON;
Expand All @@ -45,7 +45,7 @@ void FppTest::DeviceSm::update(const Fw::SMSignals *e)
*/
case ON:

switch (e->geteventSignal()) {
switch (signal) {

case RTI_SIG:
this->state = OFF;
Expand Down
6 changes: 4 additions & 2 deletions FppTest/state_machine/DeviceSm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

#ifndef DEVICESM_H_
#define DEVICESM_H_


#include <Fw/SMSignal/SMSignalBuffer.hpp>

namespace Fw {
class SMSignals;
}
Expand Down Expand Up @@ -43,7 +45,7 @@ class DeviceSm {
void * extension;

void init();
void update(const Fw::SMSignals *e);
void update(const DeviceSmEvents signal, const Fw::SMSignalBuffer &data);

};

Expand Down
2 changes: 2 additions & 0 deletions FppTest/state_machine/DeviceSm.trans
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
InitialState = OFF, Event = RTI, guard = None, action = None, TargetState = ON
InitialState = ON, Event = RTI, guard = None, action = None, TargetState = OFF
14 changes: 4 additions & 10 deletions FppTest/state_machine/SmTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ SmTest ::~SmTest() {}
// ----------------------------------------------------------------------

void SmTest::schedIn_handler(const NATIVE_INT_TYPE portNum, U32 context) {
Fw::SMSignals event;
event.seteventSignal(DeviceSm::RTI_SIG);
Fw::SMSignalBuffer data;

event.setsmId(STATE_MACHINE_DEVICE1);
stateMachineInvoke(event);

event.setsmId(STATE_MACHINE_DEVICE2);
stateMachineInvoke(event);

event.setsmId(STATE_MACHINE_DEVICE3);
stateMachineInvoke(event);
device1StateMachineInvoke(DeviceSm::RTI_SIG, data);
device2StateMachineInvoke(DeviceSm::RTI_SIG, data);
device3StateMachineInvoke(DeviceSm::RTI_SIG, data);

}

Expand Down
1 change: 1 addition & 0 deletions FppTest/state_machine/autosm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/watney/STARS/autocoder/Stars.py -namespace FppTest -backend fprime -noImpl -model DeviceSm.plantuml
21 changes: 21 additions & 0 deletions FppTest/state_machine/cpstuff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Define the source and destination directories
SOURCE_DIR="/home/watney/fprime/FppTest/state_machine/dev"
DEST_DIR="/home/watney/fprime/FppTest/build-fprime-automatic-native-ut/FppTest/state_machine"

# List of files to copy
FILES=("SmTestComponentAc.cpp" "SmTestComponentAc.hpp")

# Loop through each file and copy it to the destination directory
for FILE in "${FILES[@]}"; do
if [ -f "$SOURCE_DIR/$FILE" ]; then
cp "$SOURCE_DIR/$FILE" "$DEST_DIR/"
echo "Copied $FILE to $DEST_DIR/"
else
echo "File not found: $SOURCE_DIR/$FILE"
fi
done

echo "File copy operation completed."

1 change: 1 addition & 0 deletions Fw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Tlm/")
# Framework subdirectories
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Cfg/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Comp/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SMSignal/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FilePacket/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Obj/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Port/")
Expand Down
11 changes: 11 additions & 0 deletions Fw/SMSignal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
#
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/SMSignalBuffer.cpp"
)
register_fprime_module()
3 changes: 3 additions & 0 deletions Fw/SMSignal/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ComPortAi.xml - Port description for communication buffers
ComBuffer.hpp(.cpp) - A buffer holding a serialized communication buffer
ComPacket.hpp(.cpp) - A packet type that holds a communication buffer
45 changes: 45 additions & 0 deletions Fw/SMSignal/SMSignalBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <Fw/SMSignal/SMSignalBuffer.hpp>
#include <Fw/Types/Assert.hpp>

namespace Fw {

SMSignalBuffer::SMSignalBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

SMSignalBuffer::SMSignalBuffer() {
}

SMSignalBuffer::~SMSignalBuffer() {
}

SMSignalBuffer::SMSignalBuffer(const SMSignalBuffer& other) : Fw::SerializeBufferBase() {
SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
}

SMSignalBuffer& SMSignalBuffer::operator=(const SMSignalBuffer& other) {
if(this == &other) {
return *this;
}

SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength());
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<NATIVE_INT_TYPE>(stat));
return *this;
}

NATIVE_UINT_TYPE SMSignalBuffer::getBuffCapacity() const {
return sizeof(this->m_bufferData);
}

const U8* SMSignalBuffer::getBuffAddr() const {
return this->m_bufferData;
}

U8* SMSignalBuffer::getBuffAddr() {
return this->m_bufferData;
}

}

42 changes: 42 additions & 0 deletions Fw/SMSignal/SMSignalBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* SMSignalBuffer.hpp
*
*/

/*
* Description:
* This object contains the SMSignalBuffer type, used for attaching data to state machine signals
*/
#ifndef FW_SM_SIGNAL_BUFFER_HPP
#define FW_SM_SIGNAL_BUFFER_HPP

#include <FpConfig.hpp>
#include <Fw/Types/Serializable.hpp>

namespace Fw {

class SMSignalBuffer : public SerializeBufferBase {
public:

enum {
SERIALIZED_TYPE_ID = 1010,
SERIALIZED_SIZE = FW_COM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) // size of buffer + storage of size word
};

SMSignalBuffer(const U8 *args, NATIVE_UINT_TYPE size);
SMSignalBuffer();
SMSignalBuffer(const SMSignalBuffer& other);
virtual ~SMSignalBuffer();
SMSignalBuffer& operator=(const SMSignalBuffer& other);

NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
U8* getBuffAddr();
const U8* getBuffAddr() const;

private:
U8 m_bufferData[FW_SM_SIGNALS_BUFFER_MAX_SIZE]; // packet data buffer
};

}

#endif
1 change: 1 addition & 0 deletions Fw/SMSignal/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
Binary file added Fw/SMSignal/docs/img/FwComBDD.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions Fw/SMSignal/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
\page FwComPort Fw::Com Port
# Fw::Com Port

## 1. Introduction

The `Fw::Com` port is used to pass binary data to a service for transporting data out of the system.
Incoming and outgoing packets are serialized into these buffers.

## 2. Design

### 2.1 Context

#### 2.1.1 Port Diagram

The `Fw::Com` port has the following port diagram:

![Fw::Com Diagram](img/FwComBDD.jpg "Fw::Com Port")

#### 2.1.2 Serializables

##### 2.1.2.1 Fw::ComPacket

The `Fw::ComPacket` class is a base class for other packet classes. It provides type identification for packet subtypes.

##### 2.1.2.2 Fw::ComBuffer

The `Fw::ComBuffer` class represents a buffer to store data for transmission. It is used as a destination buffer for serialization of `Fw::ComPacket` subtypes.

## 3. Change Log

Date | Description
---- | -----------
6/22/2015 | Initial Version



5 changes: 5 additions & 0 deletions config/FpConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ typedef FwIndexType FwQueueSizeType;
#define FW_COM_BUFFER_MAX_SIZE 512
#endif

// Specifies the size of the buffer attached to state machine signals.
#ifndef FW_SM_SIGNALS_BUFFER_MAX_SIZE
#define FW_SM_SIGNALS_BUFFER_MAX_SIZE 128
#endif

// Specifies the size of the buffer that contains the serialized command arguments.

#ifndef FW_CMD_ARG_BUFFER_MAX_SIZE
Expand Down

0 comments on commit ff7b023

Please sign in to comment.