Skip to content

Commit

Permalink
Merge pull request #199 from Yakindu/java-naming-adaptation
Browse files Browse the repository at this point in the history
Adapt to changes in naming (Java code generator)
  • Loading branch information
andreasmuelder authored Jul 27, 2020
2 parents 4f4f5dd + ce53674 commit 8d51b99
Show file tree
Hide file tree
Showing 41 changed files with 2,112 additions and 2,241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ GeneratorModel for yakindu::java {
targetProject = "com.yakindu.sct.examples.musicplayer.java"
targetFolder = "src-gen"
}

feature Naming {
basePackage = "com.yakindu.sct.examples.musicplayer.java"
typeName = "Player"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.yakindu.sct.examples.musicplayer.java;

import com.yakindu.sct.examples.musicplayer.java.player.IPlayerStatemachine;
import com.yakindu.sct.examples.musicplayer.java.player.IPlayerStatemachine.SCInterfaceListener;
import com.yakindu.sct.examples.musicplayer.java.player.PlayerStatemachine;

import javafx.application.Application;
import javafx.geometry.Insets;
Expand Down Expand Up @@ -60,56 +57,41 @@ public void start(Stage stage) throws Exception {
}

private void setupBehaviour() {
IPlayerStatemachine statemachine = new PlayerStatemachine();
IPlayer statemachine = new Player();

statemachine.init();

// hook up in-events
playBtn.setOnAction((e) -> {
statemachine.getSCInterface().raisePlayPressed();
statemachine.getInterface().raisePlayPressed();
});

pauseBtn.setOnAction((e) -> {
statemachine.getSCInterface().raisePausePressed();
statemachine.getInterface().raisePausePressed();
});

stopBtn.setOnAction((e) -> {
statemachine.getSCInterface().raiseStopPressed();
statemachine.getInterface().raiseStopPressed();
});

prevBtn.setOnAction((e) -> {
statemachine.getSCInterface().raisePrevPressed();
infoLbl.setText(statemachine.getSCInterface().getCurrentSong().getName());
statemachine.getInterface().raisePrevPressed();
infoLbl.setText(statemachine.getInterface().getCurrentSong().getName());
});

nextBtn.setOnAction((e) -> {
statemachine.getSCInterface().raiseNextPressed();
infoLbl.setText(statemachine.getSCInterface().getCurrentSong().getName());
statemachine.getInterface().raiseNextPressed();
infoLbl.setText(statemachine.getInterface().getCurrentSong().getName());
});

// hook up out-events
statemachine.getSCInterface().getListeners().add(new SCInterfaceListener() {

@Override
public void onPlayBtnEnabledRaised(boolean value) {
playBtn.setDisable(!value);
}

@Override
public void onPauseBtnEnabledRaised(boolean value) {
pauseBtn.setDisable(!value);
}

@Override
public void onStopBtnEnabledRaised(boolean value) {
stopBtn.setDisable(!value);
}

});
statemachine.getInterface().getPlayBtnEnabled().subscribe(value -> playBtn.setDisable(!value));
statemachine.getInterface().getPauseBtnEnabled().subscribe(value -> pauseBtn.setDisable(!value));
statemachine.getInterface().getStopBtnEnabled().subscribe(value -> stopBtn.setDisable(!value));

statemachine.enter();

infoLbl.setText(statemachine.getSCInterface().getCurrentSong().getName());
infoLbl.setText(statemachine.getInterface().getCurrentSong().getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ GeneratorModel for yakindu::java {
targetFolder = "src-gen"
libraryTargetFolder = "src"
}

feature Naming {
basePackage = "org.yakindu.sct.examples.basic.tutorial"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ GeneratorModel for yakindu::java {
targetFolder = "src-gen"
libraryTargetFolder = "src"
}

feature Naming {
basePackage = "org.yakindu.sct.examples.basic.tutorial"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ GeneratorModel for yakindu::java {
feature GeneralFeatures {
TimerService = true
}

feature Naming {
basePackage = "org.yakindu.sct.examples.basic.tutorial"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ GeneratorModel for yakindu::java {
targetFolder = "src-gen"
libraryTargetFolder = "src"
}

feature Naming {
basePackage = "org.yakindu.sct.examples.basic.tutorial"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package org.yakindu.sct.examples.lightswitch;

import org.yakindu.sct.examples.basic.tutorial._02_lightswitch._02_LightSwitchStatemachine;
import org.yakindu.sct.examples.basic.tutorial._02_LightSwitch;

public class LightSwitch_02 {

public static void main(String[] args) throws InterruptedException {
_02_LightSwitchStatemachine sm = new _02_LightSwitchStatemachine();
_02_LightSwitch sm = new _02_LightSwitch();

sm.init();

sm.enter();

for (int i = 0; i < 10; i++) {
sm.getSCIUser().raiseOperate();
sm.getInterfaceUser().raiseOperate();
sm.runCycle();

if (sm.isStateActive(_02_LightSwitchStatemachine.State.main_region_On)) {
if (sm.isStateActive(_02_LightSwitch.State.MAIN_REGION_ON)) {
System.out.println("Light is On");
} else if (sm.isStateActive(_02_LightSwitchStatemachine.State.main_region_Off)) {
} else if (sm.isStateActive(_02_LightSwitch.State.MAIN_REGION_OFF)) {
System.out.println("Light is Off");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import java.io.IOException;
import java.io.InputStreamReader;

import org.yakindu.sct.examples.basic.tutorial._03_lightswitch._03_LightSwitchStatemachine;
import org.yakindu.sct.examples.basic.tutorial._03_LightSwitch;

public class LightSwitch_03 {

public static void main(String[] args) throws InterruptedException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

_03_LightSwitchStatemachine sm = new _03_LightSwitchStatemachine();
_03_LightSwitch sm = new _03_LightSwitch();

sm.init();
sm.enter();
Expand All @@ -21,16 +21,16 @@ public static void main(String[] args) throws InterruptedException, IOException
String input = br.readLine();

if (input.equals("On")) {
sm.getSCIUser().raiseOn_button();
sm.getInterfaceUser().raiseOn_button();
} else if (input.equals("Off")) {
sm.getSCIUser().raiseOff_button();
sm.getInterfaceUser().raiseOff_button();
} else if (input.equals("Exit")) {
break;
} else {
System.out.println("Incorrect input: " + input);
}
sm.runCycle();
System.out.printf("Brightness: %d\n", sm.getSCIUser().getBrightness());
System.out.printf("Brightness: %d\n", sm.getInterfaceUser().getBrightness());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import java.io.IOException;
import java.io.InputStreamReader;

import org.yakindu.sct.examples.basic.tutorial.TimerService;
import org.yakindu.sct.examples.basic.tutorial._04_lightswitch._04_LightSwitchStatemachine;
import org.yakindu.sct.TimerService;
import org.yakindu.sct.examples.basic.tutorial._04_LightSwitch;

public class LightSwitch_04 {

public static void main(String[] args) throws IOException {
// Instantiate statemachine
_04_LightSwitchStatemachine sm = new _04_LightSwitchStatemachine();
_04_LightSwitch sm = new _04_LightSwitch();

// Instantiate BufferedReader for command line reading inside of IDE
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Expand All @@ -33,19 +33,19 @@ public static void main(String[] args) throws IOException {
}

if (input.equals("On")) {
sm.getSCIUser().raiseOn_button();
sm.getInterfaceUser().raiseOn_button();
} else if (input.equals("Off")) {
sm.getSCIUser().raiseOff_button();
sm.getInterfaceUser().raiseOff_button();
} else if (input.equals("Exit")) {
break;
} else if (!input.equals("")) {
sm.getSCISensor().raiseMotion();
sm.getInterfaceSensor().raiseMotion();
System.out.println("Motion detected");
}

sm.runCycle();
if (sm.getSCIUser().getBrightness() != brightness) {
brightness = sm.getSCIUser().getBrightness();
if (sm.getInterfaceUser().getBrightness() != brightness) {
brightness = sm.getInterfaceUser().getBrightness();
System.out.printf("Brightness %d\n", brightness);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import java.io.IOException;
import java.io.InputStreamReader;

import org.yakindu.sct.examples.basic.tutorial.TimerService;
import org.yakindu.sct.examples.basic.tutorial._06_lightswitch_simulation._06_LightSwitch_simulationStatemachine;
import org.yakindu.sct.TimerService;
import org.yakindu.sct.examples.basic.tutorial._06_LightSwitch_simulation;
import org.yakindu.sct.examples.basic.tutorial._06_LightSwitch_simulation.State;

public class LightSwitch_06 {

public static void main(String[] args) throws IOException {
// Instantiate statemachine
_06_LightSwitch_simulationStatemachine sm = new _06_LightSwitch_simulationStatemachine();
_06_LightSwitch_simulation sm = new _06_LightSwitch_simulation();

// Instantiate BufferedReader for command line reading inside of IDE
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Expand All @@ -37,23 +38,23 @@ public static void main(String[] args) throws IOException {
}

if (input.equals("On")) {
sm.getSCIUser().raiseOn_button();
sm.getInterfaceUser().raiseOn_button();
} else if (input.equals("Off")) {
sm.getSCIUser().raiseOff_button();
sm.getInterfaceUser().raiseOff_button();
} else if (input.equals("Exit")) {
break;
}

sm.runCycle();

// Output section
if (sm.getSCIUser().getBrightness() != brightness) {
brightness = sm.getSCIUser().getBrightness();
if (sm.getInterfaceUser().getBrightness() != brightness) {
brightness = sm.getInterfaceUser().getBrightness();
System.out.printf("Brightness %d\n", brightness);
}

if (sm.isStateActive(_06_LightSwitch_simulationStatemachine.State.main_region_Manual) != isManual) {
isManual = sm.isStateActive(_06_LightSwitch_simulationStatemachine.State.main_region_Manual);
if (sm.isStateActive(State.MAIN_REGION_MANUAL) != isManual) {
isManual = sm.isStateActive(State.MAIN_REGION_MANUAL);
if (isManual) {
System.out.println("Manual mode activated");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import java.time.LocalDateTime;
import java.util.Random;

import org.yakindu.sct.examples.basic.tutorial._06_lightswitch_simulation.I_06_LightSwitch_simulationStatemachine.InternalOperationCallback;
import org.yakindu.sct.examples.basic.tutorial.I_06_LightSwitch_simulation.InternalOperationCallback;


public class LightSwitch_06_Callback implements InternalOperationCallback {

Expand Down
4 changes: 4 additions & 0 deletions org.yakindu.sct.examples.codegen.java/models/java.sgen
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ GeneratorModel for yakindu::java {
targetFolder = "src-gen"
}

feature Naming {
basePackage = "org.yakindu.sct.examples.codegen.java"
}

}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Generated by YAKINDU Statechart Tools code generator. */
package traffic.light;
package org.yakindu.sct;

/**
* Basic interface for state machines.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** Generated by YAKINDU Statechart Tools code generator. */
package org.yakindu.sct.examples.codegen.java;

import org.yakindu.sct.IStatemachine;

public interface ILightSwitch extends IStatemachine {

public interface InterfaceUser {

public void raiseOn_button();

public void raiseOff_button();

public long getBrightness();

public void setBrightness(long value);

}

public InterfaceUser getInterfaceUser();

}
Loading

0 comments on commit 8d51b99

Please sign in to comment.