Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Setup a new Java sc project

  1. Create sc folder mkdir ./sc
  2. Create `sc.yaml' with the following content
module: ""language: "java"importPathSeparator: "."enableFileCapitalization: trueforceUnitSetupRegeneration: truectlDir: "src/controller"templates:
- dir: "sc/templates"imports:
- repoOwner: "SoenkeD"repoName: "sc-java-templates"repoPath: "sc/templates/"localPath: "sc/templates/"
  1. Create controller folder mkdir -p ./src/controller/myctl
  2. Create PlantUML file ./src/controller/myctl/myctl.plantuml (must have the same name as the controller) with the following content
@startuml Demo
[*] --> DemoState: [ CheckAlwaysTrue ]
[*] -[bold]-> [*]: / Print(The guard needs to be implemented)
DemoState: do / AddMsg(Hello)
DemoState: do / AddMsg(World)
DemoState: do / AddMsg(!)
DemoState --> BurnState: [ CheckAlwaysTrue ] / Print(Go to BurnState)
DemoState -[bold]-> [*]
BurnState: do / Print(Got messages)
BurnState: do / PrintMsgs
BurnState -[bold]-> [*]
  1. (optional) Create a Makefile with the following content
sc=~/go/bin/sc
.PHONY: sc
sc:
$(sc) gen --root $(PWD) --name myctl
.PHONY: import
import:
$(sc) import --root $(PWD)
.PHONY: export
export:
$(sc) export --root $(PWD)
.PHONY: compile
compile:
javac -d bin src/*.java
.PHONY: run
run:
java -cp ./bin src/Main
.PHONY: exec
exec: compile run
  1. Create src/Main.java with the following content
packagesrc;
importsrc.controller.myctl.Initctl;
importsrc.controller.myctl.controller.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
Ctlctl = Initctl.initCtl();
Reconcilerreconciler = newReconciler(
ctl, newReconcilerInput()
);
try {
reconciler.reconcile();
} catch (CtlErre) {
System.err.println(e);
}
}
}
  1. Import the base templates make import
  2. Generate the state machine by running make sc
  3. Implement at least the Print action in src/controller/myctl/actions/Print.java
  4. Execute your first running state machine with make exec

About

Java templates for the sc state chart tool

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages