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

Advanced Sequence Compiler 0.1 #181

Open
wants to merge 14 commits into
base: devel
Choose a base branch
from
14 changes: 14 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ autoapi
AUTOBRIEF
autocoded
autocomplete
autocompletion
Autodetected
autodoc
autogen
Expand Down Expand Up @@ -77,6 +78,7 @@ CFDP
CFPD
cgi
Chainable
chans
chartjs
checkbox
CHNG
Expand All @@ -103,13 +105,15 @@ config
configparser
configs
Consolas
consts
cpp
CPython
creatingdocsetswithdoxygen
css
csum
csv
ctime
ctor
CTORS
curateable
curated
Expand All @@ -118,6 +122,8 @@ customise
cwd
cxx
daringfireball
dataclass
dataclasses
dataobjects
datastore
datastructures
Expand Down Expand Up @@ -218,6 +224,8 @@ evt
exe
executables
expanduser
Expr
expr
extlinks
extns
exts
Expand Down Expand Up @@ -249,6 +257,9 @@ FONTSIZE
fpp
fprime
fptable
fpy
Fpy
fqn
frac
framerate
fromtimestamp
Expand Down Expand Up @@ -312,6 +323,7 @@ hyperlink
hyperlinks
idct
idl
idx
ieeetr
ifconfig
ified
Expand Down Expand Up @@ -369,6 +381,7 @@ keepalive
keyframes
keyify
kinda
kwarg
kwargs
len
lestarch
Expand Down Expand Up @@ -623,6 +636,7 @@ staticmethod
stderr
Stdio
stdout
stmt
strftime
stringified
stringify
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fprime-cli = "fprime_gds.executables.fprime_cli:main"
fprime-seqgen = "fprime_gds.common.tools.seqgen:main"
fprime-dp-write = "fprime_gds.executables.data_product_writer:main"
fprime-gds = "fprime_gds.executables.run_deployment:main"
fprime-seq = "fprime_gds.common.sequence.compiler:main"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add fpy to this name to distinguish it? The old fprime-seqgen will lose to this in tab-complete and won't process correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. Sure, if you think that's the best idea, we can make a generic "fpy" cmdline tool whose default behavior can be compiling.


# For Pytest fixtures
[project.entry-points."pytest11"]
Expand Down
86 changes: 86 additions & 0 deletions src/fprime_gds/common/sequence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# FPy Advanced Sequencing Language Version 0.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should put this with F´. We typically try to avoid directory-READMEs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to move it. Where/when should we move it?

The FPy advanced sequencing language is a combination of a high-level scripting language and a low-level bytecode language for running complex command sequences on spacecraft flight software.

Check failure on line 2 in src/fprime_gds/common/sequence/README.md

View workflow job for this annotation

GitHub Actions / Spell checking

`bytecode` is not a recognized word. (unrecognized-spelling)
## FPy Syntax
### Modules, components, channels, commands and types
You can imagine the FPy syntax as Python with the following mappings:
1. FPrime modules become Python namespaces
2. FPrime components become Python classes
3. FPrime types (structs, arrays and enums) become Python classes
4. FPrime component instances become Python object instances
5. FPrime commands become member functions of Python object instances
6. FPrime telemetry channels become member properties of Python object instances

FPrime declaration:
```
module Ref {
passive component ExampleComponent {
telemetry testChannel: U8
sync command TEST_COMMAND(arg: string size 40)
}

instance exampleInstance: ExampleComponent base id 0x01
}
```
FPy usage:
```py
# reference a telemetry channel
Ref.exampleInstance.testChannel
# call a command
Ref.exampleInstance.TEST_COMMAND("arg value")
```


FPrime declaration:
```
struct ExampleStruct {
member: F32
}

enum TestEnum {
ONE
TWO
THREE
}

array TestArray = [3] U8
```

FPy usage:
```py
# construct a struct
ExampleStruct(0.0)
# reference an enum const
TestEnum.THREE
# construct an array
TestArray(1, 2, 3)
```

### Sequence directives
FPy also has sequence directives, which are like commands that control the running sequence itself.

The most common sequence directives are absolute and relative sleep:
```py
sleep_abs(Time(time_base, time_context, seconds, useconds))
sleep_rel(Time(time_base, time_context, seconds, useconds))
```

Due to the nature of the FPrime `CmdSequencer`, you can only have zero or one `sleep` directives before each command.

## FPy Usage
```
fprime-seq <sequence.fpy> -d <TopologyDictionary.json> [-o <output.bin>]

A compiler for the FPrime advanced sequencing language

positional arguments:
input The path of the input sequence to compile

options:
-h, --help show this help message and exit
-d DICTIONARY, --dictionary DICTIONARY
The JSON topology dictionary to compile against
-o OUTPUT, --output OUTPUT
The output .bin file path. Defaults to the input file path
```

The result is a sequence binary file that works with the FPrime `CmdSequencer`.
Empty file.
Loading
Loading