-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Deployment generation feature (#123)
* Use argparse mutually exclusive args * Add cookiecutter templates * clean up legacy code * functional push * overwrite option * Move command processing to commands.py * refactor utility_entry to cli.py * lstrip path_to_fprime * Hint --overwrite when directory exist * help text * rephrase short help text * help text * minor comment for readability * template header guards * address code scanning alert * catch exception later up * spelling * formatting * spelling again :( * gotta love spelling
- Loading branch information
Showing
19 changed files
with
1,363 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/cookiecutter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"deployment_name": "MyDeployment", | ||
"path_to_fprime": "./fprime", | ||
"author_name": "", | ||
"__deployment_name_upper": "{{cookiecutter.deployment_name.upper()}}" | ||
} |
32 changes: 32 additions & 0 deletions
32
..._templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
##### | ||
# '{{cookiecutter.deployment_name}}' Deployment: | ||
# | ||
# This sets up the build for the '{{cookiecutter.deployment_name}}' Application, including custom | ||
# components. In addition, it imports FPrime.cmake, which includes the core F Prime components. | ||
# | ||
##### | ||
|
||
### | ||
# Basic Project Setup | ||
### | ||
cmake_minimum_required(VERSION 3.13) | ||
cmake_policy(SET CMP0048 NEW) | ||
project({{cookiecutter.deployment_name}} VERSION 1.0.0 LANGUAGES C CXX) | ||
|
||
### | ||
# F' Core Setup | ||
# This includes all of the F prime core components, and imports the make-system. | ||
### | ||
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime.cmake") | ||
# NOTE: register custom targets between these two lines | ||
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime-Code.cmake") | ||
|
||
### | ||
# Components and Topology | ||
### | ||
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Top/") | ||
|
||
set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Main.cpp") | ||
set(MOD_DEPS ${PROJECT_NAME}/Top) | ||
|
||
register_fprime_deployment() |
91 changes: 91 additions & 0 deletions
91
...cutter_templates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// ====================================================================== | ||
// \title Main.cpp | ||
// \author {{cookiecutter.author_name}} | ||
// \brief main program for the F' application. Intended for CLI-based systems (Linux, macOS) | ||
// | ||
// ====================================================================== | ||
// Used to access topology functions | ||
#include <{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.hpp> | ||
// Used for signal handling shutdown | ||
#include <signal.h> | ||
// Used for command line argument processing | ||
#include <getopt.h> | ||
// Used for printf functions | ||
#include <cstdlib> | ||
|
||
/** | ||
* \brief print command line help message | ||
* | ||
* This will print a command line help message including the available command line arguments. | ||
* | ||
* @param app: name of application | ||
*/ | ||
void print_usage(const char* app) { | ||
(void)printf("Usage: ./%s [options]\n-a\thostname/IP address\n-p\tport_number\n", app); | ||
} | ||
|
||
/** | ||
* \brief shutdown topology cycling on signal | ||
* | ||
* The reference topology allows for a simulated cycling of the rate groups. This simulated cycling needs to be stopped | ||
* in order for the program to shutdown. This is done via handling signals such that it is performed via Ctrl-C | ||
* | ||
* @param signum | ||
*/ | ||
static void signalHandler(int signum) { | ||
{{cookiecutter.deployment_name}}::stopSimulatedCycle(); | ||
} | ||
|
||
/** | ||
* \brief execute the program | ||
* | ||
* This F´ program is designed to run in standard environments (e.g. Linux/macOs running on a laptop). Thus it uses | ||
* command line inputs to specify how to connect. | ||
* | ||
* @param argc: argument count supplied to program | ||
* @param argv: argument values supplied to program | ||
* @return: 0 on success, something else on failure | ||
*/ | ||
int main(int argc, char* argv[]) { | ||
U32 port_number = 0; | ||
I32 option = 0; | ||
char* hostname = nullptr; | ||
|
||
// Loop while reading the getopt supplied options | ||
while ((option = getopt(argc, argv, "hp:a:")) != -1) { | ||
switch (option) { | ||
// Handle the -a argument for address/hostname | ||
case 'a': | ||
hostname = optarg; | ||
break; | ||
// Handle the -p port number argument | ||
case 'p': | ||
port_number = static_cast<U32>(atoi(optarg)); | ||
break; | ||
// Cascade intended: help output | ||
case 'h': | ||
// Cascade intended: help output | ||
case '?': | ||
// Default case: output help and exit | ||
default: | ||
print_usage(argv[0]); | ||
return (option == 'h') ? 0 : 1; | ||
} | ||
} | ||
// Object for communicating state to the reference topology | ||
{{cookiecutter.deployment_name}}::TopologyState inputs; | ||
inputs.hostname = hostname; | ||
inputs.port = port_number; | ||
|
||
// Setup program shutdown via Ctrl-C | ||
signal(SIGINT, signalHandler); | ||
signal(SIGTERM, signalHandler); | ||
(void)printf("Hit Ctrl-C to quit\n"); | ||
|
||
// Setup, cycle, and teardown topology | ||
{{cookiecutter.deployment_name}}::setupTopology(inputs); | ||
{{cookiecutter.deployment_name}}::startSimulatedCycle(1000); // Program loop cycling rate groups at 1Hz | ||
{{cookiecutter.deployment_name}}::teardownTopology(inputs); | ||
(void)printf("Exiting...\n"); | ||
return 0; | ||
} |
39 changes: 39 additions & 0 deletions
39
...lates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# {{cookiecutter.deployment_name}} Application | ||
|
||
This deployment was auto-generated by the F' utility tool. | ||
|
||
## Building and Running the {{cookiecutter.deployment_name}} Application | ||
|
||
In order to build the {{cookiecutter.deployment_name}} application, or any other F´ application, we first need to generate a build directory. This can be done with the following commands: | ||
|
||
``` | ||
cd {{cookiecutter.deployment_name}} | ||
fprime-util generate | ||
``` | ||
|
||
The next step is to build the {{cookiecutter.deployment_name}} application's code. | ||
``` | ||
fprime-util build | ||
``` | ||
|
||
## Running the application and F' GDS | ||
|
||
The following command will spin up the F' GDS as well as run the application binary and the components necessary for the GDS and application to communicate. | ||
|
||
``` | ||
cd {{cookiecutter.deployment_name}} | ||
fprime-gds | ||
``` | ||
|
||
To run the ground system without starting the {{cookiecutter.deployment_name}} app: | ||
``` | ||
cd {{cookiecutter.deployment_name}} | ||
fprime-gds --no-app | ||
``` | ||
|
||
The application binary may then be run independently from the created 'bin' directory. | ||
|
||
``` | ||
cd {{cookiecutter.deployment_name}}/build-artifacts/<platform>/bin/ | ||
./{{cookiecutter.deployment_name}} -a 127.0.0.1 -p 50000 | ||
``` |
22 changes: 22 additions & 0 deletions
22
...plates/cookiecutter-fprime-deployment/{{cookiecutter.deployment_name}}/Top/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#### | ||
# 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}/instances.fpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/{{cookiecutter.deployment_name}}Packets.xml" | ||
"${CMAKE_CURRENT_LIST_DIR}/topology.fpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/{{cookiecutter.deployment_name}}Topology.cpp" | ||
) | ||
set(MOD_DEPS | ||
Fw/Logger | ||
Svc/LinuxTime | ||
# Communication Implementations | ||
Drv/Udp | ||
Drv/TcpClient | ||
) | ||
|
||
register_fprime_module() |
Oops, something went wrong.