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

Add QPC-C target #12

Merged
merged 144 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
97409cb
Added QM target platforrm (not finalized)
thomas-bc Jun 9, 2021
ebb73fd
Init state prrinting
thomas-bc Jun 9, 2021
25556ca
Added TODO initial pseudoState
thomas-bc Jun 9, 2021
cabac00
Added Transition parsing
thomas-bc Jun 9, 2021
b989e82
Fixed missing double quotes
thomas-bc Jun 9, 2021
925b009
Fixed missing newline
thomas-bc Jun 9, 2021
e3b84dc
Other quickfixes
thomas-bc Jun 9, 2021
0615650
Added TODO and placeholders
thomas-bc Jun 10, 2021
798f2e3
renamed printSMStart to printDocumentStart
thomas-bc Jun 10, 2021
5ae829a
Added package and class generation
thomas-bc Jun 10, 2021
94b7943
Added state handling. Blinky example opens in QM!
thomas-bc Jun 10, 2021
f74ebee
Generating TimeEvents
thomas-bc Jun 11, 2021
11c0264
Remoed done TODO
thomas-bc Jun 11, 2021
db8193a
Trigger event replaceAll and toUpperCase
thomas-bc Jun 11, 2021
c16dc45
TimeEvent declaration moved before StateChart element
thomas-bc Jun 11, 2021
cf5a642
Added QBehavior Class
thomas-bc Jun 12, 2021
3a8a29b
Use QBehavior for entry/exit behaviors
thomas-bc Jun 12, 2021
4c56782
Initial transition <action> only if code is there
thomas-bc Jun 12, 2021
87e9faf
Added some documentation
thomas-bc Jun 12, 2021
7e3ab9b
Removed bad import
thomas-bc Jun 14, 2021
4ad7ac7
Removed static keyword from timeEventsNameset
thomas-bc Jun 14, 2021
a9eed86
Added QmTree class
thomas-bc Jun 14, 2021
c202dec
Variable renaming and rescoping QmTree to String only
thomas-bc Jun 14, 2021
e635d78
Added getNodeByName and getRelativePath to QmTree
thomas-bc Jun 14, 2021
6f93938
timeEventNaming function
thomas-bc Jun 15, 2021
5699296
Added target path resolution
thomas-bc Jun 15, 2021
ef6ab84
Moved QmTree transition handling to exploreTransitions
thomas-bc Jun 15, 2021
26128a0
Removed done TODO
thomas-bc Jun 15, 2021
dc1836c
Corrected exit action printing
thomas-bc Jun 15, 2021
ffef871
Moved QM generation to base of target dir
thomas-bc Jun 16, 2021
51622c8
Added composite state handling
thomas-bc Jun 16, 2021
825855e
Removed debugging sysout
thomas-bc Jun 16, 2021
4d594c3
Actions and transitions moved up
thomas-bc Jun 16, 2021
255a39b
Transition action gets Effect name
thomas-bc Jun 16, 2021
ce6a07b
Done TODO: Transition action
thomas-bc Jun 16, 2021
740f9ba
Removed debugging print
thomas-bc Jun 16, 2021
42ec0b8
Simplified printStateGlyph
thomas-bc Jun 16, 2021
ccbe2c4
Removed printFinalState return
thomas-bc Jun 16, 2021
54cff79
Added guards
thomas-bc Jun 17, 2021
f47ab79
Added Choice nodes handling
thomas-bc Jun 17, 2021
13c823a
Transition <action> field comes first
thomas-bc Jun 17, 2021
1c662b3
Reshaped printTransition for clarity
thomas-bc Jun 17, 2021
6c49bbd
Renamed printTransitionAction and removed Do activities
thomas-bc Jun 17, 2021
fd6fa38
Added generation of .c and .h template files
thomas-bc Jun 23, 2021
826688c
Removed unused imports and vars
thomas-bc Jun 23, 2021
59acb40
Added first draft of implementation files generation
thomas-bc Jun 23, 2021
ec8016b
Reformatting and rescoping
thomas-bc Jun 23, 2021
a3053d9
Added pseudostates (choice nodes) to getAllGuardNames
thomas-bc Jun 24, 2021
80f1cb9
Seperating timeEvents and signalEvents
thomas-bc Jun 24, 2021
cad73dc
Code clarity and comments
thomas-bc Jun 24, 2021
2f73706
Refactoring for better SCA compatibility
thomas-bc Jun 24, 2021
07277c6
Added signals and state headers
thomas-bc Jun 25, 2021
55f27a3
Injecting constructor and methods in source files
thomas-bc Jun 25, 2021
012e6b3
Removed struct definition from template
thomas-bc Jun 25, 2021
43d85d0
Removed includes from signals and states files
thomas-bc Jun 25, 2021
5102dcf
Renamed target and files from QF-QM to QPC-QM
thomas-bc Jun 28, 2021
61879e0
Fixed for correct generation of multiple Statemachines
thomas-bc Jun 28, 2021
27b034b
Init action subscription to signals (QPC code)
thomas-bc Jun 28, 2021
04f449e
Using state machine qualified names for file generation
thomas-bc Jun 28, 2021
a4b3512
Refactored for future QPC-C introduction
thomas-bc Jul 9, 2021
77d1400
Refactored for future QPC-C target
thomas-bc Jul 9, 2021
7e9ee7f
Merge branch qf
thomas-bc Jul 9, 2021
2eac170
Added readme description of QPC-QM target
thomas-bc Jul 9, 2021
4653a65
Merge pull request #1 from thomas-bc/qf
thomas-bc Jul 9, 2021
9f2fcf2
Added QPC-C Target
thomas-bc Jul 10, 2021
ce188b0
Merge branch 'Open-MBEE:main' into main
thomas-bc Jul 12, 2021
2f7203f
Merge branch 'main' into qpc-c
thomas-bc Jul 12, 2021
5f4936f
Added State Machine header file generation
thomas-bc Jul 12, 2021
bd78f73
Changed isChoiceTransition logic
thomas-bc Jul 13, 2021
38a4dd3
Added FunctionBehavior to getFirstActionName
thomas-bc Jul 14, 2021
c233330
First draft of generation of state machine
thomas-bc Jul 14, 2021
8b2501d
Removed unused function
thomas-bc Jul 14, 2021
e7b47c5
Added comments for readability
thomas-bc Jul 14, 2021
2152bbe
formatSignalName function for robustness
thomas-bc Jul 14, 2021
d2b1f34
Warning and formatting
thomas-bc Jul 14, 2021
e0a96a9
Handling of initial state into choice node
thomas-bc Jul 14, 2021
d85726c
Return statements handling
thomas-bc Jul 14, 2021
5c99350
Format function name for impl files use
thomas-bc Jul 14, 2021
6592431
Handling of internal transitions
thomas-bc Jul 14, 2021
8f7b00d
Corrected formatting for guard (vs actions)
thomas-bc Jul 15, 2021
06e3a6e
Added include of own's header
thomas-bc Jul 15, 2021
d95f836
Using registered events instead of querying model
thomas-bc Jul 15, 2021
78049fa
Trimming whitespaces
thomas-bc Jul 15, 2021
550461d
Return statement only printing if non-empty
thomas-bc Jul 15, 2021
52cb61b
Typo hotfix
thomas-bc Jul 15, 2021
b5c4e5f
Init node into choice return statement fix
thomas-bc Jul 15, 2021
f1d8d7f
getAllSignalNames also look in every transitions
thomas-bc Jul 15, 2021
5c7cf0d
Fixed hasSignalEvent for handling malformed transitions
thomas-bc Jul 15, 2021
c24a187
Refactored for statelessness of QpcHeaders
thomas-bc Jul 15, 2021
4221ba8
Robustness: refactored naming schemes to QUtils
thomas-bc Jul 15, 2021
da3f3bf
Added time events (not used)
thomas-bc Jul 15, 2021
4a0d16c
Renamed QUtils to Utils
thomas-bc Jul 15, 2021
96c27d2
Renamed enum to xxx_state (singular)
thomas-bc Jul 15, 2021
1853591
Added QPC-C description to README
thomas-bc Jul 15, 2021
9f968df
Added QPC-C to options help
thomas-bc Jul 15, 2021
32677ca
Multiple function handling in action name + (me->impl) arg
thomas-bc Jul 20, 2021
f797f43
Added support for sending signals within action strings
thomas-bc Jul 20, 2021
1c3aacf
State machine header full generation
thomas-bc Jul 20, 2021
ab06e3d
Refactored QpcHeaders to use StringTemplate
thomas-bc Jul 20, 2021
b1da87a
Refined getAllActionNames to include choice node actions
thomas-bc Jul 21, 2021
7cbb0e4
Refined QpcImplFiles to use StringTemplate
thomas-bc Jul 21, 2021
5122053
Removed legacy debugging print
thomas-bc Jul 21, 2021
bebc11f
Added default return to parent state
thomas-bc Jul 21, 2021
af140c3
Added initial statemachine transition
thomas-bc Jul 21, 2021
722010b
Corrected event publish formatting
thomas-bc Jul 21, 2021
5196051
Typo quickfix
thomas-bc Jul 22, 2021
3e5d880
State names quickfix
thomas-bc Jul 22, 2021
c0acd8b
Replaced QPC QEvent by QEvt
thomas-bc Jul 22, 2021
433a855
Removing overhead for compileable code
thomas-bc Jul 22, 2021
b252e70
only QF_PUBLISH_ is available
thomas-bc Jul 22, 2021
1cc25e9
All file description headers from template
thomas-bc Jul 22, 2021
0eef482
Added AnalysisContext for Sequence diagrams
thomas-bc Jul 23, 2021
8304bcb
Refactored FileDescriptionHeader to traceability
thomas-bc Jul 23, 2021
1157b02
Fix member injection
thomas-bc Jul 23, 2021
71db2e0
Reformatted requirement traceability
thomas-bc Jul 28, 2021
8bd88c7
Added support for arguments in QpcImplFiles
thomas-bc Jul 29, 2021
861db1b
formatActionNames to use FunctionCall object
thomas-bc Jul 29, 2021
66d3681
Minor formatting changes
thomas-bc Jul 29, 2021
aaefcc7
Removing unnecessary newlines
thomas-bc Jul 29, 2021
02e10a0
Quickfix: counter incrementation
thomas-bc Jul 29, 2021
602a39e
Added CurrentGeneration class usage
thomas-bc Jul 30, 2021
378d108
Added sending multiple signals within one action
thomas-bc Aug 3, 2021
5c3a054
Added final state handling
thomas-bc Aug 3, 2021
c87da52
Added function docstring
thomas-bc Aug 3, 2021
8c9eff2
Add check on composites' initial cases
thomas-bc Aug 4, 2021
daf72cc
History pseudostates implementation
thomas-bc Aug 5, 2021
726e590
Deleted unused QBehavior.java
thomas-bc Aug 5, 2021
9205a85
Added comments for readability
thomas-bc Aug 5, 2021
d8d9875
Added support for entry/exit pseudostates
thomas-bc Aug 5, 2021
0e84d0f
Remove trailing semicolon from guard
thomas-bc Aug 5, 2021
91224ce
corrected semicolon removal
thomas-bc Aug 5, 2021
acfe3dc
Reformatting for more readability
thomas-bc Aug 5, 2021
1926d5c
Added History pseudostates and TimeEvents
thomas-bc Aug 9, 2021
c06facf
Optimized getImplementationArgsString
thomas-bc Aug 10, 2021
cc9d80d
Using states' qualified name
thomas-bc Aug 10, 2021
071384c
Refactoring in preparation for orthogonal states
thomas-bc Aug 10, 2021
067c9cb
Implemented orthogonal states
thomas-bc Aug 13, 2021
951a7af
Added documentation
thomas-bc Aug 16, 2021
9d643be
RobotFramework test for QPC-C target
thomas-bc Aug 17, 2021
862a7f4
Traceability service hostname change
thomas-bc Aug 17, 2021
559e2cd
Merge branch 'Open-MBEE:main' into qpc-c
thomas-bc Feb 1, 2023
5824cf5
Merge branch 'Open-MBEE:main' into qpc-c
thomas-bc Mar 2, 2023
d35b324
Delete launch.json
thomas-bc Mar 2, 2023
da29a7d
Review modifications
thomas-bc Mar 3, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The following target platforms are supported:
- *SCXML* Transforms the input model into SCXML document(s). The generated SCXML document can be executed by an SCXML interpreted.
- *ELT-MAL* Transforms the input model into XML/MAL ICD. The generated XML file can be transformed into code using CII tools.
- *ELT-RAD* Transforms the input model into C++ code, SCXML, XML/MAL ICD, for the Rapid Application Development toolkit (RAD). The generated code can be compiled and executed on a machine installed with the ELT Development Environment and RAD.
- *QPC-C* Transofrms the input model into C code representing the state machine logic and structure, using the [Quantum Framework (QP/C)](https://www.state-machine.com/qpc/).
- *QPC-QM* Transofrms the input model into a QM file for the [Quantum Modeler](https://www.state-machine.com/qm/). This also generates implementation files that are used for the C code QM will generate.

Generation Modes
Expand Down
1 change: 1 addition & 0 deletions comodo2/src/comodo2/engine/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Config {
public final static String TARGET_PLATFORM_ELT_RAD = "ELT-RAD"; // RAD application (SCXML, MAL, rad.ev)
public final static String TARGET_PLATFORM_ELT_MAL = "ELT-MAL"; // MAL ICD only
public final static String TARGET_PLATFORM_QPC_QM = "QPC-QM"; // Quantum Framework: Quantum Modeler file format
public final static String TARGET_PLATFORM_QPC_C = "QPC-C"; // Quantum Framework: direct C generation

/**
* Platforms specific configuration options
Expand Down
2 changes: 1 addition & 1 deletion comodo2/src/comodo2/engine/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Options getOptions() {
opt.addOption("d", "debug", false, "Enable printing of debug information.");
opt.addOption("i", "input-model", true, "Filepath of the model to transform. Model should be in EMF XMI (.uml) format.");
opt.addOption("o", "output-path", true, "Output directory path.");
opt.addOption("t", "target-platform", true, "Target platform [SCXML|ELT-RAD|ELT-MAL].");
opt.addOption("t", "target-platform", true, "Target platform [SCXML|ELT-RAD|ELT-MAL|QPC-QM|QPC-C].");
opt.addOption("c", "target-platform-config", true, "Configuration parameters specific to the target platform [NOACTIONSSTD].");
opt.addOption("g", "generation-mode", true, "Generation mode [DEFAULT|UPDATE|ALL].");
opt.addOption("n", "no-backup", false, "Disable automatic backup of overwritten files.");
Expand Down
28 changes: 0 additions & 28 deletions comodo2/src/comodo2/queries/QBehavior.java

This file was deleted.

4 changes: 4 additions & 0 deletions comodo2/src/comodo2/queries/QEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public String getTimeEventName(final Event e) {
}
}

public String getTimeEventDurationString(final TimeEvent e) {
return e.getWhen().getExpr().stringValue();
}

public boolean isTimeEvent(final Event e) {
return (e instanceof TimeEvent);
}
Expand Down
12 changes: 10 additions & 2 deletions comodo2/src/comodo2/queries/QRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,25 @@ public String getRegionName(final Region r) {
}
*/
public String getInitialStateName(final Region r) {
State s = this.getInitialState(r);
if (s != null) {
return mQState.getStateName(s);
}
return "";
}

public State getInitialState(final Region r) {
thomas-bc marked this conversation as resolved.
Show resolved Hide resolved
for (final Pseudostate ps : Iterables.<Pseudostate>filter(r.allOwnedElements(), Pseudostate.class)) {
if ((ps.getKind() == PseudostateKind.INITIAL_LITERAL) &&
Objects.equal(ps.getContainer().getOwner(), this.getParentState(r)) &&
(ps.getOutgoings().size() == 1)) {
Vertex v = ps.getOutgoings().get(0).getTarget();
if (v != null) {
return mQState.getStateName((State)v);
return (State)v;
}
}
}
return "";
return null;
}

public boolean isTopState(final Region r) {
Expand Down
153 changes: 149 additions & 4 deletions comodo2/src/comodo2/queries/QState.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,55 @@ public Iterable<State> getAllFinalSubstates(final State s) {
return res;
}

public Boolean hasInitialSubstate(final State s) {
thomas-bc marked this conversation as resolved.
Show resolved Hide resolved
State sub = this.getInitialSubstate(s);
if (sub != null) {
return true;
}
return false;
}

public String getInitialSubstateName(final State s) {
State sub = this.getInitialSubstate(s);
if (sub != null) {
return getStateName(sub);
}
return "";
}

/**
* @return The substate of a composite state that is pointed at by the initial node.
*/
public State getInitialSubstate(final State s) {
thomas-bc marked this conversation as resolved.
Show resolved Hide resolved
Iterable<Pseudostate> _filter = Iterables.<Pseudostate>filter(s.allOwnedElements(), Pseudostate.class);
for (final Pseudostate ps : _filter) {
if (((((ps.getKind() == PseudostateKind.INITIAL_LITERAL) &&
Objects.equal(ps.getContainer().getOwner(), s)) &&
(ps.getOutgoings().size() == 1)) &&
(Iterables.<Transition>getFirst(ps.getOutgoings(), null).getTarget() != null))) {
return getStateName( ((State) Iterables.<Transition>getFirst(ps.getOutgoings(), null).getTarget()) );
return ( ((State) Iterables.<Transition>getFirst(ps.getOutgoings(), null).getTarget()) );
}
}

return "";
return null;
}

/**
* Returns the initial transition of a composite state.
* This is used when the initial transition of a composite state points to a pseudostate (like a choice node)
* which makes getInitialSubstateName(s) throws a ClassCastException.
*/
public Transition getInitialSubstateTransition(final State s) {
Iterable<Pseudostate> _filter = Iterables.<Pseudostate>filter(s.allOwnedElements(), Pseudostate.class);
for (final Pseudostate ps : _filter) {
if (((((ps.getKind() == PseudostateKind.INITIAL_LITERAL) &&
Objects.equal(ps.getContainer().getOwner(), s)) &&
(ps.getOutgoings().size() == 1)) &&
(Iterables.<Transition>getFirst(ps.getOutgoings(), null).getTarget() != null))) {
return ps.getOutgoings().get(0);
}
}
return null;
}

/**
Expand Down Expand Up @@ -234,12 +271,24 @@ public boolean hasTimerTransition(final State s) {
}
/*
final Function1<Transition, Boolean> _function = (Transition e) -> {
return Boolean.valueOf((mQTransition.isTimerTransition(e) && e.getSource().getName().matches(s.getName())));
return Boolean.valueOf((mQTransition.isTimerTransitionWithEvent(e) && e.getSource().getName().matches(s.getName())));
};
return !IterableExtensions.isEmpty(IterableExtensions.<Transition>filter(Iterables.<Transition>filter(this.getParentState(s).allOwnedElements(), Transition.class), _function));
*/
for (Transition e : Iterables.<Transition>filter(getParentState(s).allOwnedElements(), Transition.class)) {
if (mQTransition.isTimerTransition(e) && e.getSource().getName().matches(s.getName())) {
if (mQTransition.isTimerTransitionWithEvent(e) && e.getSource().getName().matches(s.getName())) {
return true;
}
}
return false;
}

/**
* @return True if State s has at least one outgoing transition that carries a TimeEvent. False otherwise.
*/
public boolean hasOutgoingTimerTransition(final State s) {
for (Transition t : s.getOutgoings()){
if (mQTransition.isTimerTransition(t)) {
return true;
}
}
Expand All @@ -263,4 +312,100 @@ public boolean hasHistory(final State s) {
}
return false;
}

/**
* Returns all the pseudostates that are directly owned by State s.
*/
public Iterable<Pseudostate> getAllDirectlyOwnedPseudostates(final State s) {

BasicEList<Pseudostate> res = new BasicEList<Pseudostate>();
for (Pseudostate ps : Iterables.<Pseudostate>filter(s.allOwnedElements(), Pseudostate.class)) {
if (ps.getKind() == PseudostateKind.ENTRY_POINT_LITERAL ||
ps.getKind() == PseudostateKind.EXIT_POINT_LITERAL){
// Entry and exit points are directly owned by the composite state
if (((State)ps.getOwner()).equals(s)) {
res.add(ps);
}
// other pseudostates are owned by the state's region
} else if (ps.getContainer().getState().equals(s)){
res.add(ps);
}
}
return res;
}

/**
* Returns all the substates that are directly owned by State s.
*/
public Iterable<State> getAllDirectSubstates(final State s) {
BasicEList<State> res = new BasicEList<State>();
for (State e : Iterables.<State>filter(s.allOwnedElements(), State.class)) {
if (Objects.equal(getParentState(e), s)) {
res.add(e);
}
}
return res;
}

/**
* Returns all the History nodes that this state is tracked by.
* That is, shallowHistory at depth +1 and all deepHistory that are owned by
* a composite state that also owns this state.
*/
public BasicEList<Pseudostate> getAllParentHistoryNodes(final State s) {
BasicEList<Pseudostate> res = new BasicEList<Pseudostate>();
State p = getParentState(s);
Integer depth = 1;

while (p!=null){
for (Pseudostate ps : getAllDirectlyOwnedPseudostates(p)) {
// We care about shallow history only at depth 0
if ((isHistoryState(ps) && depth <= 1) || ps.getKind() == PseudostateKind.DEEP_HISTORY_LITERAL) {
res.add(ps);
}
}
p = getParentState(p);
depth++;
}
return res;
}

/**
* Returns the duration string of the first TimeEvent that the transitions of the state carry.
* A state should only have one TimeEvent transition.
*/
public String getFirstTimeEventDurationString(final State s) {
for (Transition t : s.getOutgoings()){
if (mQTransition.hasTimeEvent(t)){
return mQTransition.getFirstTimeEventDurationString(t);
}
}
return null;
}

/**
* Returns the orthogonal region (belonging to an orthogonal state) that State s
* is in, if any. If s in not within any orthogonal region, returns null.
*/
public Region getParentOrthogonalRegion(final State s) {

Region parent_region = getParentRegion(s);
State parent_state = null;

if (parent_region == null) {
return null;
}

while (parent_region!=null){
parent_state = mQRegion.getParentState(parent_region);
if (parent_state==null){
return null;
}
if (parent_state.isOrthogonal()){
return parent_region;
}
parent_region = getParentRegion(parent_state);
}
return null;
}
}
Loading