sendDefinition.mustache 795 Bytes
Newer Older
1
  private String {{parentTypeName}}.{{sendTopic}} = null;
René Schöne's avatar
René Schöne committed
2
3
4
  private byte[] {{parentTypeName}}.{{lastValue}} = null;

  public void {{parentTypeName}}.{{connectMethod}}(String topic, boolean writeCurrentValue) {
5
    {{sendTopic}} = topic;
René Schöne's avatar
René Schöne committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    {{updateMethod}}();
    if (writeCurrentValue) {
      {{writeMethod}}();
    }
  }

  protected boolean {{parentTypeName}}.{{updateMethod}}() {
    {{tokenResetMethod}}();
    {{> mappingApplication}}
    {{lastValue}} = {{lastResult}};
    return true;
  }

  protected void {{parentTypeName}}.{{writeMethod}}() {
    {{#loggingEnabledForWrites}}
21
    System.out.println("[Send] {{tokenName}} = " + get{{tokenName}}() + " -> " + {{sendTopic}});
René Schöne's avatar
René Schöne committed
22
    {{/loggingEnabledForWrites}}
23
    {{mqttHandlerAttribute}}().publish({{sendTopic}}, {{lastValue}});
René Schöne's avatar
René Schöne committed
24
  }