ConfigParser configParser = ConfigParser.getInstance();
Configuration configuration = configParser.parse("configTest", content);
assertNotNull(configuration);
ActorSection actorSection = null;
for (Section s : configuration.getSections()) {
if (s instanceof ActorSection) {
actorSection = (ActorSection) s;
}
}
Trajectory trajectory = null;
String trajectoryStr = null;
for (Actor a : actorSection.getActors()) {
if (a.getName().trim().equalsIgnoreCase("actuator_x") && (a instanceof Actuator)) {
trajectoryStr = ((Actuator<?>) a).getTrajectory();
}
}
assertNotNull(trajectoryStr);
trajectory = TrajectoryParser.getInstance().parse(trajectoryStr, TrajectoryType.STEP_BY_STEP);
assertNotNull(trajectory);
assertEquals("[10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,90.0,100.0]", trajectory.getStringTrajectory());
TabStepByStepTrajectory tTrajectory = ((TabStepByStepTrajectory) trajectory);
assertEquals(10, tTrajectory.getPoints().size());
assertEquals(10.0, tTrajectory.getPoints().get(0));
assertEquals(20.0, tTrajectory.getPoints().get(1));
assertEquals(30.0, tTrajectory.getPoints().get(2));
assertEquals(40.0, tTrajectory.getPoints().get(3));
assertEquals(50.0, tTrajectory.getPoints().get(4));
assertEquals(60.0, tTrajectory.getPoints().get(5));
assertEquals(70.0, tTrajectory.getPoints().get(6));
assertEquals(80.0, tTrajectory.getPoints().get(7));
assertEquals(90.0, tTrajectory.getPoints().get(8));
assertEquals(100.0, tTrajectory.getPoints().get(9));
Sensor sensor = null;
for (Actor a : actorSection.getActors()) {
if ((a instanceof Sensor) && (a.getName().equalsIgnoreCase("sensor_a"))) {
sensor = (Sensor) a;
}
}