Aspect.jadd 2.03 KB
Newer Older
Johannes Mey's avatar
Johannes Mey committed
1
2
3
4
5
6
7
8
9
10
aspect Aspect {

  public static final String ASTNode.aspectIndent = "  ";

  public String Program.generateAspect() {
    StringBuilder sb = new StringBuilder();
    generateAspect(sb);
    return sb.toString();
  }

11
  @Deprecated
Johannes Mey's avatar
Johannes Mey committed
12
13
14
15
16
17
18
19
  public void Program.generateAspect(StringBuilder sb) {

    sb.append("aspect ROS2RAG {\n");

    // TODO generate getters and setters for ROS2RAG terminals (and attributes?)

    sb.append("}\n");
  }
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

  public String Ros2Rag.generateAspect() {
    StringBuilder sb = new StringBuilder();
    generateAspect(sb);
    return sb.toString();
  }

  // from "[always] read Joint.CurrentPosition using PoseToPosition;" generate method connectTo
//    Joint j;
//    j.getCurrentPosition().connectTo("/robot/joint2/pos");

  public void Ros2Rag.generateAspect(StringBuilder sb) {
    sb.append("aspect ROS2RAG {\n");

    for (SyncDefinition def : getSyncDefinitionList()) {
      def.generateAspect(sb);
    }

    sb.append("}\n");
  }

  abstract void SyncDefinition.generateAspect(StringBuilder sb);
  @Override
  void UpdateDefinition.generateAspect(StringBuilder sb) {
    // TODO
  }

  // will be "addConnectionJoint_CurrentPosition" in example
/* // see discussion in codimd (InstanceLocation), why this won't work here
  Position.connectTo(String topic) {
    mqttUpdater().addConnectionJoint_CurrentPosition(this, topic);
  }
  MqttUpdater.addConnectionJoint_CurrentPosition(Position target, String topic) {
    // either
    topicActionMap.put(topic, new Action(JOINT_CURRENTPOSITION, target));
    // or
    topicForJoint_CurrentPosition.put(topic, target);
  }
 */
 */
  @Override
  void ReadFromMqttDefinition.generateAspect(StringBuilder sb) {
    sb.append("public void ").append(type).append(".connectTo(String topic) {\n")
      .append(aspectIndent).append("mqttUpdater().addConnection")
      .append(getTargetType().getID()).append("_")
      .append(getTargetChild())
      .append("(this, topic);\n")
      .append("}\n");
  }

  @Override
  void WriteToMqttDefinition.generateAspect(StringBuilder sb) {
    // TODO
  }
Johannes Mey's avatar
Johannes Mey committed
74
}