Commit 2ccf3f2b authored by Alexander Ryndin's avatar Alexander Ryndin
Browse files

issue-47: add test

parent 4b0c5dd7
......@@ -30,6 +30,17 @@ public class GeneratorCppCliTest extends AbstractSymtabTest {
generateAndCompareMyComponentX(10);
}
@Test
public void testServerWrapperCanBeGenerated() {
String[] args = new String[]{
formatParam(GeneratorCppCli.OPTION_MODELS_PATH, "src/test/resources"),
formatParam(GeneratorCppCli.OPTION_ROOT_MODEL, "testing.serverwrapper.myComponent"),
formatParam(GeneratorCppCli.OPTION_OUTPUT_PATH, "./target/generated-sources-cpp/testing/ServerWrapperTest"),
String.format("--%s", GeneratorCppCli.OPTION_FLAG_SERVER_WRAPPER.getLongOpt()),
};
GeneratorCppCli.main(args);
}
private void generateAndCompareMyComponentX(int x) throws IOException {
generateAndCompare(
String.format("testing.subpackage%1$s.myComponent%1$s", x),
......
package testing.serverwrapper;
component MyComponent {
port
// length of simulation time frame
// e.g. when simulation frequency is 200 Hz
// this value will be equal to 5ms
in Q (0.0 s : 0.001 s : 1.0 s) timeIncrement,
// current velocity
in Q (0.0 m/s : 0.01 m/s : oo m/s) currentVelocity,
// current vehicle's position
in Q (-oo m : 0.01 m : oo m) x,
in Q (-oo m : 0.01 m : oo m) y,
// orientation angle (also sometimes called yaw angle) in radians
// it is measured from from the positive Y axis direction
// to the actual vehicle's direction counter-clockwise
// Example 1: vehicle has direction (-1.0; -1.0)
// compass = 0.25 * PI (positive)
// Example 2: vehicle has direction (1.0; 0.0) i.e. it is directed along the X axis
// compass = -0.5 * PI (negative)
in Q (-oo : 0.001 : oo) compass,
// current engine actuation
in Q (0.0 : 0.001 : 2.5) currentEngine,
// current steering actuation
// negative value: left turn
// positive value: right turn
in Q (-0.785 : 0.001 : 0.785) currentSteering,
// current brakes actuation
in Q (0.0 : 0.001 : 3.0) currentBrakes,
// planned trajectory (with look ahead 100-200m)
// represented by two arrays trajectory_x[] and trajectory_y[]
// which both have length trajectory_length
in Z (0 : 100) trajectory_length,
in Q (-oo m : 0.01 m : oo m) ^ {1,100} trajectory_x,
in Q (-oo m : 0.01 m : oo m) ^ {1,100} trajectory_y,
// output actuation commands
out Q (0.0 : 0.001 : 2.5) engine,
out Q (-0.785 : 0.001 : 0.785) steering,
out Q (0.0 : 0.001 : 3.0) brakes;
implementation Math {
engine = currentEngine;
steering = currentSteering;
brakes = currentBrakes;
}
}
Supports Markdown
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