Skip to content

SoenkeD/sc-java-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

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: true
forceUnitSetupRegeneration: true
ctlDir: "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
package src;

import src.controller.myctl.Initctl;
import src.controller.myctl.controller.*;

public class Main {
    public static void main(String[] args) {

            Ctl ctl = Initctl.initCtl();
            Reconciler reconciler = new Reconciler(
                ctl, 
                new ReconcilerInput()
                );


            try {
                reconciler.reconcile();
            } catch (CtlErr e) {
                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

Watchers

Forks

Releases

No releases published

Packages

No packages published