Test.connect 1.24 KB
Newer Older
1
/* Version 2020-07-15  */
2
// --- update definitions ---
3
4
receive Link.CurrentPosition using ParseRobotState, RobotStateToIntPosition ;
send RobotArm.AppropriateSpeed using CreateSpeedMessage, SerializeRobotConfig ;
5
6

// --- dependency definitions ---
7
RobotArm.AppropriateSpeed canDependOn Link.CurrentPosition as dependency1 ;
8
9

// --- mapping definitions ---
10
ParseRobotState maps byte[] bytes to robot.RobotStateOuterClass.RobotState {:
11
  TestCounter.INSTANCE.numberParseLinkState += 1;
12
  return robot.RobotStateOuterClass.RobotState.parseFrom(bytes);
13
14
:}

15
SerializeRobotConfig maps config.Config.RobotConfig rc to byte[] {:
16
  TestCounter.INSTANCE.numberSerializeRobotConfig += 1;
17
18
19
  return rc.toByteArray();
:}

20
RobotStateToIntPosition maps robot.RobotStateOuterClass.RobotState rs to IntPosition {:
21
  TestCounter.INSTANCE.numberLinkStateToIntPosition += 1;
22
23
  robot.RobotStateOuterClass.RobotState.Position p = rs.getPosition();
  return IntPosition.of((int) (Math.round(p.getX() * 10)), (int) (Math.round(p.getY() * 10)), (int) (Math.round(p.getZ() * 10)));
24
:}
25

26
CreateSpeedMessage maps double speed to config.Config.RobotConfig {:
27
  TestCounter.INSTANCE.numberCreateSpeedMessage += 1;
28
  return config.Config.RobotConfig.newBuilder()
29
    .setSpeed(speed)
30
    .build();
31
:}