Unverified Commit a0d0a19f authored by Michael von Wenckstern's avatar Michael von Wenckstern Committed by GitHub
Browse files

Merge pull request #17 from EmbeddedMontiArc/strepkov-model-test

Strepkov model test
parents ada1ea48 a4c068a9
......@@ -228,6 +228,7 @@
<artifactId>jscience</artifactId>
<version>${jscience.version}</version>
</dependency>
</dependencies>
......
......@@ -91,24 +91,20 @@
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
<host>172.29.1.4</host>
<port>3128</port>
<nonProxyHosts>local.net</nonProxyHosts>
</proxy>
-->
</proxies>
|-->
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
......@@ -344,4 +340,4 @@
</activeProfiles>
</settings>
\ No newline at end of file
</settings>
package de.monticore.lang.monticar.generator;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
public class SimulatorTSTest extends AbstractSymtab{
private TaggingResolver symtab;
@Before
public void setUp() {
symtab = createSymTabAndTaggingResolver("src/test/resources/simulator-ts/visualization");
}
@Test
public void resolveModelDoorStatus() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("doors.doorStatus",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelGameOverTrigger() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("feature.gameOverTrigger",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelBrakeLightsControl() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("lights.brakeLightsControl",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelIndicatorStatus() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("lights.indicatorStatus",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelsLightTimer() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("lights.lightTimer",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModel() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("main.sDCS",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelsConstantVelocity() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("movement.constantVelocity",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
@Test
public void resolveModelsSteeringControl() {
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("movement.steeringControl",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
}
\ No newline at end of file
package doors;
component DoorStatus {
port
in (0km/h:250km/h) velocity,
out B status;
implementation Math {
status = velocity < 1 km/h;
}
}
\ No newline at end of file
package feature;
component GameOverTrigger {
port
in N1 x,
in N1 y,
out B status;
implementation Math {
// The boundaries of the 3D world
B aboveBnd = x > 200;
B belowBnd = x < -200;
B rightBnd = y > 150;
B leftBnd = y < -150;
status = aboveBnd || belowBnd || rightBnd || leftBnd;
}
}
\ No newline at end of file
package lights;
component BrakeLightsControl {
port
in (0s:oos) time,
out B status;
implementation Math {
// Turn brake lights on after 1 second
status = time > 1s;
}
}
\ No newline at end of file
package lights;
component IndicatorStatus {
port
in (0s:oos) time,
out B status;
implementation Math {
status = (time % 2s) < 1s;
}
}
\ No newline at end of file
package lights;
component LightTimer {
port
in (0s:oos) time,
out B status;
implementation Math {
status = time > 1s;
}
}
\ No newline at end of file
package main;
import doors.*;
import lights.*;
import movement.*;
import feature.*;
component SDCS {
port
in (0s:oos) time,
// Distances of the sensors to the track
in (0m:2m) fl, // frontleft
in (0m:2m) fr, // frontright
in (0m:2m) slf, // sideleftfront
in (0m:2m) slb, // sideleftback
in (0m:2m) srf, //siderightfront
in (0m:2m) srb, //siderightback
in (0km/h : 250km/h) velocity,
in N1 x,
in N1 y,
out (-180°:180°) steering,
out (-2m/s^2:2m/s^2) acceleration,
out B lightStatus,
out B indicatorStatus,
out B triggerStatus,
out B brakeLightsStatus,
out B doorStatus;
instance SteeringControl steeringControl;
instance ConstantVelocity constantVelocity;
instance IndicatorStatus indStatus;
instance LightTimer lightTimer;
instance DoorStatus doorStatus;
instance GameOverTrigger trigger;
connect time->constantVelocity.time;
connect velocity->constantVelocity.velocity;
connect fl->steeringControl.fl;
connect fr->steeringControl.fr;
connect slf->steeringControl.slf;
connect slb->steeringControl.slb;
connect srf->steeringControl.srf;
connect srb->steeringControl.srb;
connect time->indStatus.time;
connect velocity->doorStatus.velocity;
connect time->lightTimer.time;
connect x->trigger.x;
connect y->trigger.y;
connect constantVelocity.acceleration->acceleration;
connect steeringControl.steering->steering;
connect indStatus.status->indicatorStatus;
connect doorStatus.status->doorStatus;
connect lightTimer.status->lightStatus;
connect trigger.status->triggerStatus;
}
\ No newline at end of file
package movement;
component ConstantVelocity {
port
in (0km/h : 250km/h) velocity,
in (0s : oos) time,
out (-2 m/s^2 : 2 m/s^2) acceleration;
implementation Math {
B cond = time < 1s;
if cond {
acceleration = 0 m/s^2;
}
else{
acceleration = 2 m/s^2;
}
end
}
}
package movement;
component SteeringControl {
port
// Distances of the sensors to the track
in (0m:2m) fl, //frontleft
in (0m:2m) fr, //frontright
in (0m:2m) slf, //sideleftfront
in (0m:2m) slb, //sideleftback
in (0m:2m) srf, //siderightfront
in (0m:2m) srb, //siderightback
out (-180°:180°) steering;
implementation Math {
Q(0m:2m) threshold = 0.1m;
Q(-2m:0m) thresholdN = -0.1m;
B comp1 = (((fl-fr) > threshold) && ((slf-slb) > threshold)) && ((srb-srf) > threshold);
B comp2 = (((fl-fr) < thresholdN) && ((slf-slb) < thresholdN)) && ((srb-srf) < thresholdN);
B comp3 = (slf<slb) && (srf<srb);
Q(0°:-1°) resComp3 = 0°;
if comp3 {
resComp3 = -1°;
}
else {
resComp3 = 0°;
}
end
Q(5°:-1°) resComp2 = 0°;
if comp2 {
resComp2 = 5°;
}
else {
resComp2 = resComp3;
}
end
if comp1 {
steering = -5°;
}
else {
steering = resComp2;
}
end
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment