-
Notifications
You must be signed in to change notification settings - Fork 39
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
zimri-leisher
wants to merge
14
commits into
nasa:devel
Choose a base branch
from
zimri-leisher:2919-adv-seq-compiler
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
00e12b7
Add compiler file
bd11f4a
Little more work on seq compiler
b831636
Some more work on example/test code
c833af0
Much more work on adv compiler
f13303f
much more work on parsing cmd args and type ctor args
4f00fa2
Basic syntax and type checking working
7ea9144
Sequence directives for sleep rel and abs
2d2172b
remove debug prints
4d93f91
Get sequence compiler even closer! Now we're adding time info to all …
49c7d05
First attempt at producing bytes output
43db402
Add a basic readme
f34d676
Fix codeql checks
5a5eff9
Fix some more codeql things
d13580a
Remove header generator for now
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,86 @@ | ||
# FPy Advanced Sequencing Language Version 0.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
## 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.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 oldfprime-seqgen
will lose to this in tab-complete and won't process correctly.There was a problem hiding this comment.
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.