<aside> 💡 STARTING POINT: There are 2 main sources for the state:

</aside>


ACTIVITY-related STATES

  1. Get the activity through MQTT-IN node.

    Untitled

  2. Use a json to convert from string to object.

  3. Use a switch to match the two classisc states on the activity:

    activity = 0 → UnspecifiedStopState

    activity = 1 → ProducingAtFullSpeedState

    Untitled

    these are the two functions for the two states:

    1. UnspecifiedStopState

      msg.payload = {
      "timestamp_ms": msg.payload["timestamp_ms"],
      "state": 40000
      }
      msg.topic = "ia/factoryinsight/dccaachen/printing/state"
      return msg;
      
    2. ProducingAtFullSpeedState

      msg.payload = {
      "timestamp_ms": msg.payload["timestamp_ms"],
      "state": 10000
      }
      msg.topic = "ia/factoryinsight/dccaachen/printing/state"
      return msg;
      
  4. After that the only thing left to do is to send out the messages via MQTT-OUT.

BUTTONBAR-related STATES

Untitled

  1. Get all the buttons values from MQTT-IN.

  2. Use a json to convert from string to object.

  3. After that we need a function to only send messages if the button got pressed. (msg.payload.value==1)

    Untitled

    if (msg.payload.value == 1){
        msg.payload = msg.payload; 
        return msg
    }
    
  4. Because of the buttons sending up to a handful of values with a 1 we need a limit that drops all the unnecessary values in between.

    Untitled

  5. Finally we need to specifiy the stop state (there is a list of available states in our documentation.) And then the last step is as always to send the state message via MQTT-OUT node.

    if (msg.payload.value == 1){
        msg.payload={
            "timestamp_ms": msg.payload.timestamp_ms,
            "state": 210000
        }
        msg.topic = "ia/factoryinsight/dccaachen/thermosetting/state"
    
        return msg;    
    }
    

Untitled