...
 
Commits (14)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.codeling</groupId>
<artifactId>heater</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.codeling</groupId>
<artifactId>heater.mm</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package heater.impl;
import org.codeling.lang.heater.mm.Component;
import org.codeling.lang.heater.mm.component_feature.Statemachine;
@Component
public class Heater {
@Statemachine
HeaterStateMachine heaterStateMachine;
}
package heater.impl;
import org.codeling.lang.heater.mm.State;
import org.codeling.lang.heater.mm.StateMachine;
import org.codeling.lang.heater.mm.statemachine_feature.Initial;
import org.codeling.lang.heater.mm.statemachine_feature.Variable;
import heater.impl.states.TemperatureOK;
import heater.impl.states.TemperatureTooHigh;
import heater.impl.states.TemperatureTooLow;
@StateMachine
public class HeaterStateMachine {
@Variable(Variables.class)
Variables variables;
@Initial(TemperatureOK.class)
State initial;
@org.codeling.lang.heater.mm.statemachine_feature.State({
TemperatureOK.class,
TemperatureTooHigh.class,
TemperatureTooLow.class })
State[] states;
public void tick() {
}
}
package heater.impl;
import java.text.MessageFormat;
import java.util.Random;
import java.util.logging.Logger;
import org.codeling.lang.heater.mm.Variable;
public class Variables implements Variable {
private static final Logger log = Logger.getLogger(Variables.class.getSimpleName());
private float deltaCool;
private float deltaHeat;
private float lastMeasured;
private float measured;
private int sleepTime;
private float tolerance;
private float target;
private boolean heating = false;
private Random random = new Random();
public float getDeltaCool() {
return deltaCool;
}
public void setDeltaCool(float deltaCool) {
this.deltaCool = deltaCool;
}
public float getDeltaHeat() {
return deltaHeat;
}
public void setDeltaHeat(float deltaHeat) {
this.deltaHeat = deltaHeat;
}
public float getLastMeasured() {
return lastMeasured;
}
public void setLastMeasured(float lastMeasured) {
this.lastMeasured = lastMeasured;
}
public float getMeasured() {
return measured;
}
public void setMeasured(float measured) {
this.measured = measured;
}
public int getSleepTime() {
return sleepTime;
}
public void setSleepTime(int sleepTime) {
this.sleepTime = sleepTime;
}
public float getTolerance() {
return tolerance;
}
public void setTolerance(float tolerance) {
this.tolerance = tolerance;
}
public float getTarget() {
return target;
}
public void setTarget(float target) {
this.target = target;
}
public void sleep() {
try {
if(getSleepTime() < 0) {
log.info("There was an error in calculating the sleep time (is now "+getSleepTime()+"). Resetting it to 1 second.");
setSleepTime(1);
}
log.info("Sleeping for " + getSleepTime() + " seconds");
Thread.sleep(getSleepTime() * 1000);
} catch (InterruptedException e) {
}
}
public void measure() {
setLastMeasured(getMeasured());
float variance = random.nextFloat() + 2;
if (heating) {
setMeasured(lastMeasured + variance);
} else {
setMeasured(lastMeasured - variance);
}
log.info("Measured: " + getMeasured());
}
public void startHeating() {
heating = true;
}
public void stopHeating() {
heating = false;
}
}
package heater.impl.states;
import org.codeling.lang.heater.mm.State;
import org.codeling.lang.heater.mm.state_feature.Transitions;
import heater.impl.Variables;
import heater.impl.states.temperatureok.Guard_Ok;
import heater.impl.states.temperatureok.Guard_TooHigh;
import heater.impl.states.temperatureok.Guard_TooLow;
import heater.impl.states.temperatureok.Update_Ok;
import heater.impl.states.temperatureok.Update_TooHigh;
import heater.impl.states.temperatureok.Update_TooLow;
public class TemperatureOK implements State {
@Transitions( target = TemperatureOK.class,
guard = Guard_Ok.class,
update = Update_Ok.class)
public void ok(Variables variables) {
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooLow.class,
guard = Guard_TooLow.class,
update = Update_TooLow.class)
public void decrease(Variables variables) {
variables.startHeating();
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooHigh.class,
guard = Guard_TooHigh.class,
update = Update_TooHigh.class)
public void increase(Variables variables) {
variables.sleep();
variables.measure();
}
}
package heater.impl.states;
import org.codeling.lang.heater.mm.State;
import org.codeling.lang.heater.mm.state_feature.Transitions;
import heater.impl.Variables;
import heater.impl.states.temperaturetoohigh.Guard_Ok;
import heater.impl.states.temperaturetoohigh.Guard_TooHigh;
import heater.impl.states.temperaturetoohigh.Guard_TooLow;
import heater.impl.states.temperaturetoohigh.Update_Ok;
import heater.impl.states.temperaturetoohigh.Update_TooHigh;
import heater.impl.states.temperaturetoohigh.Update_TooLow;
public class TemperatureTooHigh implements State {
@Transitions( target = TemperatureTooHigh.class,
guard = Guard_Ok.class,
update = Update_Ok.class)
public void ok(Variables variables) {
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooLow.class,
guard = Guard_TooLow.class,
update = Update_TooLow.class)
public void decrease(Variables variables) {
variables.startHeating();
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooHigh.class,
guard = Guard_TooHigh.class,
update = Update_TooHigh.class)
public void increase(Variables variables) {
variables.sleep();
variables.measure();
}
}
package heater.impl.states;
import org.codeling.lang.heater.mm.State;
import org.codeling.lang.heater.mm.state_feature.Transitions;
import heater.impl.Variables;
import heater.impl.states.temperaturetoolow.Guard_Ok;
import heater.impl.states.temperaturetoolow.Guard_TooHigh;
import heater.impl.states.temperaturetoolow.Guard_TooLow;
import heater.impl.states.temperaturetoolow.Update_Ok;
import heater.impl.states.temperaturetoolow.Update_TooHigh;
import heater.impl.states.temperaturetoolow.Update_TooLow;
public class TemperatureTooLow implements State {
@Transitions( target = TemperatureTooHigh.class,
guard = Guard_Ok.class,
update = Update_Ok.class)
public void ok(Variables variables) {
variables.stopHeating();
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooLow.class,
guard = Guard_TooLow.class,
update = Update_TooLow.class)
public void decrease(Variables variables) {
variables.sleep();
variables.measure();
}
@Transitions( target = TemperatureTooHigh.class,
guard = Guard_TooHigh.class,
update = Update_TooHigh.class)
public void increase(Variables variables) {
variables.stopHeating();
variables.sleep();
variables.measure();
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_Ok implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() > variables.getTarget() - variables.getTolerance() &&
variables.getMeasured() < variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooHigh implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() >= variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooLow implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() <= variables.getTarget() - variables.getTolerance();
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_Ok implements Update {
public void evaluate(Variables variables) {
variables.setLastMeasured(variables.getMeasured());
variables.setDeltaCool((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getTolerance() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooHigh implements Update {
public void evaluate(Variables variables) {
variables.setDeltaCool((variables.getMeasured()-variables.getLastMeasured())/variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
package heater.impl.states.temperatureok;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooLow implements Update {
public void evaluate(Variables variables) {
variables.setDeltaHeat((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured()) / variables.getDeltaHeat()));
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_Ok implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() > variables.getTarget() - variables.getTolerance() &&
variables.getMeasured() < variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooHigh implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() > variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooLow implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() < variables.getTarget() - variables.getTolerance();
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_Ok implements Update {
public void evaluate(Variables variables) {
variables.setDeltaCool((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getTolerance() - variables.getMeasured())
/ variables.getDeltaCool()));
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooHigh implements Update {
public void evaluate(Variables variables) {
variables.setDeltaCool((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured())
/ variables.getDeltaCool()));
}
}
package heater.impl.states.temperaturetoohigh;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooLow implements Update {
public void evaluate(Variables variables) {
variables.setDeltaCool((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_Ok implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() > variables.getTarget() - variables.getTolerance() &&
variables.getMeasured() < variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooHigh implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() > variables.getTarget() + variables.getTolerance();
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Guard;
import heater.impl.Variables;
public class Guard_TooLow implements Guard {
public boolean evaluate(Variables variables) {
return variables.getMeasured() < variables.getTarget() - variables.getTolerance();
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_Ok implements Update {
public void evaluate(Variables variables) {
variables.setDeltaHeat((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getTolerance() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooHigh implements Update {
public void evaluate(Variables variables) {
variables.setDeltaHeat((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
package heater.impl.states.temperaturetoolow;
import org.codeling.lang.heater.mm.Update;
import heater.impl.Variables;
public class Update_TooLow implements Update {
public void evaluate(Variables variables) {
variables.setDeltaHeat((variables.getMeasured() - variables.getLastMeasured()) / variables.getSleepTime());
variables.setSleepTime((int) ((variables.getTarget() - variables.getMeasured()) / variables.getDeltaCool()));
}
}
<map>
<entry>
<string>HasExpression</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>Action</string>
<string>Marker Interface</string>
</entry>
<entry>
<string>Variable</string>
<string>Marker Interface</string>
</entry>
<entry>
<string>Transition.update</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>StateMachine</string>
<string>Type Annotation</string>
</entry>
<entry>
<string>Update</string>
<string>Marker Interface</string>
</entry>
<entry>
<string>Transition.target</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>HasStatement</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>StateMachine.state</string>
<string>Annotated Member Reference</string>
</entry>
<entry>
<string>Component.interface</string>
<string>Static Interface Implementation</string>
</entry>
<entry>
<string>Variable.initialValue</string>
<string>Constant Member Attribute</string>
</entry>
<entry>
<string>Transition.action</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>Guard</string>
<string>Marker Interface</string>
</entry>
<entry>
<string>State.transitions</string>
<string>Containment Operation</string>
</entry>
<entry>
<string>Component</string>
<string>Type Annotation</string>
</entry>
<entry>
<string>StateMachine.variable</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>Transition.guard</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>Named</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>Named.name</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>HasExpression.expression</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>StateMachine.initial</string>
<string>Annotated Member Reference</string>
</entry>
<entry>
<string>Variable.type</string>
<string>Constant Member Attribute</string>
</entry>
<entry>
<string>Component.statemachine</string>
<string>Annotated Member Reference</string>
</entry>
<entry>
<string>HasStatement.statement</string>
<string>Do Not Translate</string>
</entry>
<entry>
<string>State</string>
<string>Marker Interface</string>
</entry>
<entry>
<string>Component.required</string>
<string>Annotated Member Reference</string>
</entry>
<entry>
<string>Transition</string>
<string>Custom Translation</string>
</entry>
<entry>
<string>Interface</string>
<string>Static Interface</string>
</entry>
</map>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.codeling</groupId>
<artifactId>heater.launcher</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>de.codeling</groupId>
<artifactId>heater</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codeling</groupId>
<artifactId>heater.mm</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codeling</groupId>
<artifactId>heater.runtime</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package heater.launcher;
import org.codeling.lang.heater.runtime.ComponentRuntime;
import org.codeling.lang.heater.runtime.StateMachineRuntime;
import org.codeling.mechanism.runtime.common.IntegratedModelException;
import heater.impl.Heater;
import heater.impl.HeaterStateMachine;
import heater.impl.Variables;
public class Main {
public static void main(String[] args) throws IntegratedModelException {
long nanoTime = System.nanoTime();
ComponentRuntime componentRT = new ComponentRuntime(Heater.class);
componentRT.initialize();
componentRT.initializeContainments();
componentRT.initializeCrossReferences();
Heater heaterComponent = (Heater) componentRT.getInstance();
StateMachineRuntime<HeaterStateMachine> stateMachineRuntime = (StateMachineRuntime<HeaterStateMachine>) componentRT
.getStatemachineRuntime().getTargetRuntimes()[0];
Variables variables = (Variables) stateMachineRuntime.getVariableRuntime().getTargets()[0];
variables.setTarget(37f);
variables.setTolerance(1f);
variables.setMeasured(20);
variables.setDeltaCool(1f);
variables.setDeltaHeat(1f);
stateMachineRuntime.execute();
// System.out.println("Possible Transitions: "+ stateMachineRuntime.getPossibleTransitions());
// System.out.println("Is Executeble? "+stateMachineRuntime.isExecutable("ok"));
// stateMachineRuntime.executeTransition("ok");
//
// System.out.println(stateMachineRuntime.getPossibleTransitions());
// System.out.println(stateMachineRuntime.getCurrentStateRuntime().getInstance().toString());
// System.out.println(heaterComponent);
// long nanoTime2 = System.nanoTime();
// System.out.println((nanoTime2 - nanoTime));
}
}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
source.. = src/main/java/
output.. = target/classes/
bin.includes = META-INF/,\
.
jars.compile.order = .
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codeling</groupId>
<artifactId>heater.mm</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>heater.mm</name>
<url>http://codeling.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package org.codeling.lang.heater.mm;
public interface Action {
}
\ No newline at end of file
package org.codeling.lang.heater.mm;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface Attribute {
}
package org.codeling.lang.heater.mm;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
public @interface Component {
}
package org.codeling.lang.heater.mm;
public interface Guard {
}
\ No newline at end of file
package org.codeling.lang.heater.mm;
public @interface Interface {
}
\ No newline at end of file
package org.codeling.lang.heater.mm;
public interface State {
}
\ No newline at end of file
package org.codeling.lang.heater.mm;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
public @interface StateMachine {
}
package org.codeling.lang.heater.mm;
public interface Update {
}
\ No newline at end of file
package org.codeling.lang.heater.mm;
public interface Variable {
}
\ No newline at end of file
package org.codeling.lang.heater.mm.component_feature;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface Required {
}
package org.codeling.lang.heater.mm.component_feature;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface Statemachine {
}
package org.codeling.lang.heater.mm.state_feature;
import org.codeling.lang.heater.mm.Guard;
import org.codeling.lang.heater.mm.State;
import org.codeling.lang.heater.mm.Update;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD)
public @interface Transitions {
Class<? extends State> target();
Class<? extends Guard> guard();
Class<? extends Update> update();
}
package org.codeling.lang.heater.mm.statemachine_feature;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface Initial {
Class<? extends org.codeling.lang.heater.mm.State> value();
}
package org.codeling.lang.heater.mm.statemachine_feature;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface State {
Class<? extends org.codeling.lang.heater.mm.State>[] value();
}
package org.codeling.lang.heater.mm.statemachine_feature;
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(java.lang.annotation.ElementType.FIELD)
public @interface Variable {
Class<? extends org.codeling.lang.heater.mm.Variable> value();
}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.codeling.lang.heater.metamodel;singleton:=true
Automatic-Module-Name: org.codeling.lang.heater.metamodel
Bundle-Version: 0.1.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.codeling.lang.heater.metamodel.heater,
org.codeling.lang.heater.metamodel.heater.impl,
org.codeling.lang.heater.metamodel.heater.util
Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
#
bin.includes = .,\
model/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src-gen/
output.. = bin/
<?xml version="1.0" encoding="UTF-8"?>
<heater:Component
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:heater="http://org.codeling/examples/heater"
xsi:schemaLocation="http://org.codeling/examples/heater heater.ecore"
name="Heater">
<statemachine
initial="//@statemachine.0/@state.0">
<state name="temperatureOK">
<transitions
target="//@statemachine.0/@state.0">
<guard
expression="measured > target - tolerance &amp;&amp; measured &lt; target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - tolerance - measured) / deltaCool"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.1">
<guard
expression="measured >= target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaCool"/>
<action
statement="warnTemperatureTooHigh()"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.2">
<guard
expression="measured &lt;= target - tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaHeat"/>
<action
statement="startHeating()"/>
<action
statement="sleep()"/>
</transitions>
</state>
<state name="temperatureTooHigh">
<transitions
target="//@statemachine.0/@state.0">
<guard
expression="measured > target - tolerance &amp;&amp; measured &lt; target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - tolerance - measured) / deltaCool"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.1">
<guard
expression="measured > target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaCool"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.2">
<guard
expression="measured &lt; target - tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaCool = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaCool"/>
<action
statement="startHeating()"/>
<action
statement="sleep()"/>
</transitions>
</state>
<state name="temperatureTooLow">
<transitions
target="//@statemachine.0/@state.0">
<guard
expression="measured > target - tolerance &amp;&amp; measured &lt; target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaHeat = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - tolerance - measured) / deltaCool"/>
<action
statement="stopHeating()"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.1">
<guard
expression="measured > target + tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaHeat = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaCool"/>
<action
statement="warnTemperatureTooHigh()"/>
<action
statement="stopHeating()"/>
<action
statement="sleep()"/>
</transitions>
<transitions
target="//@statemachine.0/@state.2">
<guard
expression="measured &lt; target - tolerance"/>
<update
statement="lastMeasured = measured"/>
<update
statement="deltaHeat = (measured - lastMeasured) / sleepTime"/>
<update
statement="sleepTime = (target - measured) / deltaCool"/>
<action
statement="sleep()"/>
</transitions>
</state>
<variable
name="measured"
type="java.lang.Float"/>
<variable
name="lastMeasured"
type="java.lang.Float"/>
<variable
name="target"
type="java.lang.Float"/>
<variable
name="tolerance"
type="java.lang.Float"/>
<variable
name="sleepTime"
type="java.lang.Float"/>
<variable
name="deltaHeat"
type="java.lang.Float"/>
<variable
name="deltaCool"
type="java.lang.Float"/>
</statemachine>
</heater:Component>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="heater" nsURI="http://org.codeling/examples/heater" nsPrefix="heater">
<eClassifiers xsi:type="ecore:EClass" name="Component" eSuperTypes="#//Named">
<eStructuralFeatures xsi:type="ecore:EReference" name="statemachine" upperBound="-1"
eType="#//StateMachine" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="interface" upperBound="-1"
eType="#//Interface" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="required" upperBound="-1"
eType="#//Interface"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Interface" eSuperTypes="#//Named"/>
<eClassifiers xsi:type="ecore:EClass" name="State" eSuperTypes="#//Named">
<eStructuralFeatures xsi:type="ecore:EReference" name="transitions" upperBound="-1"
eType="#//Transition" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Transition">
<eStructuralFeatures xsi:type="ecore:EReference" name="target" lowerBound="1"
eType="#//State"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="guard" upperBound="-1"
eType="#//Guard" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="update" upperBound="-1"
eType="#//Update" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="action" upperBound="-1"
eType="#//Action" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Variable" eSuperTypes="#//Named">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="initialValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="StateMachine">
<eStructuralFeatures xsi:type="ecore:EReference" name="state" upperBound="-1"
eType="#//State" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="variable" upperBound="-1"
eType="#//Variable" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="initial" eType="#//State"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Named" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Guard" eSuperTypes="#//HasExpression"/>
<eClassifiers xsi:type="ecore:EClass" name="Update" eSuperTypes="#//HasStatement"/>
<eClassifiers xsi:type="ecore:EClass" name="Action" eSuperTypes="#//HasStatement"/>
<eClassifiers xsi:type="ecore:EClass" name="HasExpression" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="expression" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="HasStatement" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="statement" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel"
modelDirectory="/org.codeling.lang.heater.metamodel/src-gen" creationIcons="false"
editDirectory="/org.codeling.lang.heater.metamodel.edit/src-gen" editorDirectory="/org.codeling.lang.heater.metamodel.editor/src-gen"
modelPluginID="org.codeling.lang.heater.metamodel" modelName="Heater" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
codeFormatting="true" importerID="org.eclipse.emf.importer.ecore" complianceLevel="10.0"
copyrightFields="false" operationReflection="true" importOrganizing="true">
<foreignModel>heater.ecore</foreignModel>
<testsDirectory xsi:nil="true"/>
<genPackages prefix="Heater" basePackage="org.codeling.lang.heater.metamodel" disposableProviderFactory="true"
ecorePackage="heater.ecore#/">
<genClasses ecoreClass="heater.ecore#//Component">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//Component/statemachine"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//Component/interface"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference heater.ecore#//Component/required"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//Interface"/>
<genClasses ecoreClass="heater.ecore#//State">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//State/transitions"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//Transition">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference heater.ecore#//Transition/target"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//Transition/guard"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//Transition/update"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//Transition/action"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//Variable">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute heater.ecore#//Variable/type"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute heater.ecore#//Variable/initialValue"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//StateMachine">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//StateMachine/state"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference heater.ecore#//StateMachine/variable"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference heater.ecore#//StateMachine/initial"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//Named">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute heater.ecore#//Named/name"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//Guard"/>
<genClasses ecoreClass="heater.ecore#//Update"/>
<genClasses ecoreClass="heater.ecore#//Action"/>
<genClasses ecoreClass="heater.ecore#//HasExpression">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute heater.ecore#//HasExpression/expression"/>
</genClasses>
<genClasses ecoreClass="heater.ecore#//HasStatement">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute heater.ecore#//HasStatement/statement"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
#
pluginName = org.codeling.lang.heater.metamodel
providerName = www.example.org
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
-->
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated heater -->
<package
uri="http://org.codeling/examples/heater"
class="org.codeling.lang.heater.metamodel.heater.HeaterPackage"
genModel="model/heater.genmodel"/>
</extension>
</plugin>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>org.codeling.lang.heater.metamodel</artifactId>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>org.codeling</groupId>
<artifactId>org.codeling.lang.heater</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
</project>
\ No newline at end of file
/**
*/
package org.codeling.lang.heater.metamodel.heater;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Action</b></em>'.
* <!-- end-user-doc -->
*
*
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getAction()
* @model
* @generated
*/
public interface Action extends EObject {
} // Action
/**
*/
package org.codeling.lang.heater.metamodel.heater;
import org.eclipse.emf.common.util.EList;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Component</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.codeling.lang.heater.metamodel.heater.Component#getStatemachine <em>Statemachine</em>}</li>
* <li>{@link org.codeling.lang.heater.metamodel.heater.Component#getInterface <em>Interface</em>}</li>
* <li>{@link org.codeling.lang.heater.metamodel.heater.Component#getRequired <em>Required</em>}</li>
* </ul>
*
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getComponent()
* @model
* @generated
*/
public interface Component extends Named {
/**
* Returns the value of the '<em><b>Statemachine</b></em>' containment reference list.
* The list contents are of type {@link org.codeling.lang.heater.metamodel.heater.StateMachine}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Statemachine</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Statemachine</em>' containment reference list.
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getComponent_Statemachine()
* @model containment="true"
* @generated
*/
EList<StateMachine> getStatemachine();
/**
* Returns the value of the '<em><b>Interface</b></em>' containment reference list.
* The list contents are of type {@link org.codeling.lang.heater.metamodel.heater.Interface}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Interface</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Interface</em>' containment reference list.
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getComponent_Interface()
* @model containment="true"
* @generated
*/
EList<Interface> getInterface();
/**
* Returns the value of the '<em><b>Required</b></em>' reference list.
* The list contents are of type {@link org.codeling.lang.heater.metamodel.heater.Interface}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Required</em>' reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Required</em>' reference list.
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getComponent_Required()
* @model
* @generated
*/
EList<Interface> getRequired();
} // Component
/**
*/
package org.codeling.lang.heater.metamodel.heater;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Guard</b></em>'.
* <!-- end-user-doc -->
*
*
* @see org.codeling.lang.heater.metamodel.heater.HeaterPackage#getGuard()
* @model
* @generated
*/
public interface Guard extends EObject {
} // Guard