Commit 45732622 authored by Ievgen Strepkov's avatar Ievgen Strepkov
Browse files

Added tests for simulatorModel

parent fbc55567
Pipeline #52999 passed with stage
in 10 minutes and 14 seconds
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
public class SimulatorModelTest extends AbstractSymtab {
@Test
public void resolveMainModel() {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources");
ExpandedComponentInstanceSymbol instanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("simulatorModel.mainController",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
Assert.assertNotNull(instanceSymbol);
}
}
\ No newline at end of file
package simulatorModel;
import SteeringController;
import VelocityController;
import StatusController;
component MainController{
ports
in Q(0m:200m) fl,
in Q(0m:200m) fr,
in Q(0m:200m) slf,
in Q(0m:200m) slb,
in Q(0m:200m) srf,
in Q(0m:200m) srb,
in Q(0s:oos) time,
in Q(0m/s:25m/s) velocity,
in Q(-200m:200m) x,
in Q(-200m:200m) y,
out Q(-2m/s^2:2m/s^2) acceleration,
out Q(-180:180) steering,
out B status;
instance SteeringController steeringController;
instance VelocityController velocityController;
instance StatusController trigger;
connect time->velocityController.time;
connect velocity->velocityController.velocity;
connect fl->steeringController.fl;
connect fr->steeringController.fr;
connect slf->steeringController.slf;
connect slb->steeringController.slb;
connect srf->steeringController.srf;
connect srb->steeringController.srb;
connect x->trigger.inx;
connect y->trigger.iny;
connect time ->trigger.time;
connect velocityController.acceleration->acceleration;
connect steeringController.steering->steering;
connect trigger.status->status;
}
\ No newline at end of file
package simulatorModel;
component StatusController {
port
in Q(-200m:200m) inx,
in Q(-200m:200m) iny,
out B status;
implementation Math{
// the track boundaries
B boundariesX = (inx > 200m) || (inx < -200m);
B boundariesY = (iny > 120m) || (iny < -50m);
status = boundariesX || boundariesY;
}
}
\ No newline at end of file
package simulatorModel;
stream StatusControllerTest for StatusController {
inx: 0m tick 200m tick -200m tick 250m;
iny: 0m tick 120m tick -50m tick 50m;
status: false tick false tick false tick true;
}
package simulatorModel;
component SteeringController {
port
in Q(0m:200m) fl,
in Q(0m:200m) fr,
in Q(0m:200m) slf,
in Q(0m:200m) slb,
in Q(0m:200m) srf,
in Q(0m:200m) srb,
in Q(0m:200m) br,
in Q(0m:200m) bl,
out Q(-180:180) steering;
implementation Math{
Q(0m:1m) threshold = 0.1m;
Q(-1m: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);
if (comp3)
steering = -1;
else
steering = 0;
end
if (comp2)
steering = 5;
end
if (comp1)
steering = -5;
end
}
}
\ No newline at end of file
package simulatorModel;
stream SteeringControllerTest for SteeringController {
fl: 70m tick 30m tick 32m;
fr: 70m tick 32m tick 30m;
slf: 5m tick 4m tick 5m;
slb: 5m tick 5m tick 4m;
srf: 5m tick 5m tick 4m;
srb: 5m tick 4m tick 5m;
br: 50m tick 90m tick 90m;
bl: 50m tick 90m tick 90m;
steering: 0 tick -5 tick 5;
}
\ No newline at end of file
package simulatorModel;
component VelocityController {
port
in Q(0m/s : 25m/s) velocity,
in Q(0s:oos) time,
out Q(-2m/s^2:2m/s^2) acceleration;
implementation Math{
if (velocity > 10 m/s)
acceleration = 0m/s^2;
else
acceleration = 1m/s^2;
end
}
}
\ No newline at end of file
package simulatorModel;
stream VelocityControllerTest for VelocityController {
velocity: 0m/s tick 10m/s tick 11m/s;
time: 0s tick 10s tick 11s;
acceleration: 1m/s^2 tick 1m/s^2 tick 0m/s^2;
}
\ 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