packmlsimulator

The technical documentation of the microservice packmlsimulator

This microservice is a community contribution and is not part of the main stack of the United Manufacturing Hub, but it is enabled by default.

Getting Started

This microservice simulates a PackML machine which sends and receives MQTT messages, make sure to look at our Node-RED flows to see how to utilize them to generate custom data. You can read the documentation of the standalone application here. Make sure to look at our PACKML simulator guide to see how to utilize them to generate custom data.

The simulator requires a running MQTT server accessible for the simulator.

If you want the simulated messages to be converted into processValues or other message types, just quickly adjust them via a Node-RED flow. We have some templates in our Node-RED repository.

Using docker you can build a container with the following command:

docker run -it -e SITE=Site -e AREA=Area -e LINE=Line -e MQTT_URL=mqtt://broker.hivemq.com -m 30m spruiktec/packml-simulator

Make sure to adjust the site, area, line and MQTT URL to change it to fit your setup.

In combination with the United Manufacturing Hub, it will build by default with all the other pods. You can adjust the environment variables in the values.yaml

Environment variables

This chapter explains all the variables used in PackMLSimulator.

Variable nameDescriptionTypePossible valuesExample value
MQTT_URLServer URL of the MQTT serverstringvalid MQTT server addressmqtt://united-manufacturing-hub-vernemq-local-service:1883
MQTT_PORTPort of the MQTT server, if blank the library will determine it on its ownstringa valid port8008
MQTT_USERNAMEName of the MQTT user with subscribe and publish permission, can be left empty if the server does not manage permissions.stringanyuser
MQTT_PASSWORDPassword of the MQTT user with sub and pub permission, can be left empty if username was left empty.stringallchangeme
MQTT_CLIENT_IDClient id to use when connecting to the brokerstringanymqttconnect
CLIENT_TYPEWhich payload specifications should be usedstringmqtt, sparkplugbmqtt
SPARKPLUG_GROUP_IDIf you use Sparkplug B specifications, it defines the group ID her, if undefined the simulator instead copies the SITE environment variablestringanyshopflooralpha
SPARKPLUG_EDGE_NODEIf you use Sparkplug B specifications, it defines the edge node ID, if undefined the simulator instead copies the AREA environment variablestringallbands
TICKTick speed in ms, if undefined it defaults to 1000intpositive numbers1000
SITEISA-95 site name of the line, parent topic in the MQTT Site is default valuestringanyaachen
AREAISA-95 area name of the line, middle topic in the MQTT Area is default valuestringanydcc
LINEISA-95 line name of the line, parent topic in the MQTT Line is default valuestringanybands

Commands

You interface with the simulated machines by sending MQTT it subscribes to. In the following image the state model is described and below are specifications for the messages you need to send to control the simulated machine and send it from one state to another.

Grafana through MQTT stack flow

Available commands

TopicValuesFunction
<SITE>/<AREA>/<LINE>/Command/Clear1, 0Clear Command
<SITE>/<AREA>/<LINE>/Command/Reset1, 0Reset Command
<SITE>/<AREA>/<LINE>/Command/Start1, 0Start Command
<SITE>/<AREA>/<LINE>/Command/Hold1, 0Hold Command
<SITE>/<AREA>/<LINE>/Command/Unhold1, 0Unhold Command
<SITE>/<AREA>/<LINE>/Command/Complete1, 0Complete Command
<SITE>/<AREA>/<LINE>/Command/Stop1, 0Stop Command
<SITE>/<AREA>/<LINE>/Command/Abort1, 0Abort Command
<SITE>/<AREA>/<LINE>/Command/UnitModeStringUnit Mode Command (Production, Manual, Maintenance)
<SITE>/<AREA>/<LINE>/Command/MachSpeedDecimalMachine Speed Command
<SITE>/<AREA>/<LINE>/Command/Parameter/*n*/IDIntegerParameter n ID
<SITE>/<AREA>/<LINE>/Command/Parameter/*n*/NameStringParameter n Name
<SITE>/<AREA>/<LINE>/Command/Parameter/*n*/UnitStringParameter n Unit
<SITE>/<AREA>/<LINE>/Command/Parameter/*n*/ValueDecimalParameter n Value
<SITE>/<AREA>/<LINE>/Command/Product/*i*/IDIntegerProduct n ID
<SITE>/<AREA>/<LINE>/Command/Product/*i*/ProcessParameter/*j*/IDIntegerProduct i Process Parameter j ID
<SITE>/<AREA>/<LINE>/Command/Product/*i*/ProcessParameter/*j*/NameIntegerProduct i Process Parameter j Name
<SITE>/<AREA>/<LINE>/Command/Product/*i*/ProcessParameter/*j*/UnitIntegerProduct i Process Parameter j Unit
<SITE>/<AREA>/<LINE>/Command/Product/*i*/ProcessParameter/*j*/ValueIntegerProduct i Process Parameter j Value
<SITE>/<AREA>/<LINE>/Command/Product/*i*/Ingredient/*j*/IDIntegerProduct i Ingredient n ID
<SITE>/<AREA>/<LINE>/Command/Product/*i*/Ingredient/*j*/Parameter/*k*/IDIntegerProduct i Ingredient j Parameter k ID
<SITE>/<AREA>/<LINE>/Command/Product/*i*/Ingredient/*j*/Parameter/*k*/NameIntegerProduct i Ingredient j Parameter k Name
<SITE>/<AREA>/<LINE>/Command/Product/*i*/Ingredient/*j*/Parameter/*k*/UnitIntegerProduct i Ingredient j Parameter k Unit
<SITE>/<AREA>/<LINE>/Command/Product/*i*/Ingredient/*j*/Parameter/*k*/ValueIntegerProduct i Ingredient j Parameter k Value

Available statuses

TopicValuesFunction
<SITE>/<AREA>/<LINE>/Status/StateCurrentStringCurrent PackML State
<SITE>/<AREA>/<LINE>/Status/StateCurrentStrIntegerCurrent PackML State as String
<SITE>/<AREA>/<LINE>/Status/UnitModeIntegerCurrent PackML Model
<SITE>/<AREA>/<LINE>/Status/UnitModeStrStringCurrent PackML Model as String
<SITE>/<AREA>/<LINE>/Status/CurMachSpeedDecimalCurrent Machine Speed
<SITE>/<AREA>/<LINE>/Status/MachSpeedDecimalCurrent Machine Speed Setpoint
<SITE>/<AREA>/<LINE>/Status/Parameter/*n*/IDIntegerParameter n ID
<SITE>/<AREA>/<LINE>/Status/Parameter/*n*/NameStringParameter n Name
<SITE>/<AREA>/<LINE>/Status/Parameter/*n*/UnitStringParameter n Unit
<SITE>/<AREA>/<LINE>/Status/Parameter/*n*/ValueDecimalParameter n Value
<SITE>/<AREA>/<LINE>/Status/Product/*i*/IDIntegerProduct n ID
<SITE>/<AREA>/<LINE>/Status/Product/*i*/ProcessParameter/*j*/IDIntegerProduct i Process Parameter j ID
<SITE>/<AREA>/<LINE>/Status/Product/*i*/ProcessParameter/*j*/NameIntegerProduct i Process Parameter j Name
<SITE>/<AREA>/<LINE>/Status/Product/*i*/ProcessParameter/*j*/UnitIntegerProduct i Process Parameter j Unit
<SITE>/<AREA>/<LINE>/Status/Product/*i*/ProcessParameter/*j*/ValueIntegerProduct i Process Parameter j Value
<SITE>/<AREA>/<LINE>/Status/Product/*i*/Ingredient/*j*/IDIntegerProduct i Ingredient n ID
<SITE>/<AREA>/<LINE>/Status/Product/*i*/Ingredient/*j*/Parameter/*k*/IDIntegerProduct i Ingredient j Parameter k ID
<SITE>/<AREA>/<LINE>/Status/Product/*i*/Ingredient/*j*/Parameter/*k*/NameIntegerProduct i Ingredient j Parameter k Name
<SITE>/<AREA>/<LINE>/Status/Product/*i*/Ingredient/*j*/Parameter/*k*/UnitIntegerProduct i Ingredient j Parameter k Unit
<SITE>/<AREA>/<LINE>/Status/Product/*i*/Ingredient/*j*/Parameter/*k*/ValueIntegerProduct i Ingredient j Parameter k Value

Available Admin Statuses

TopicValuesFunction
<SITE>/<AREA>/<LINE>/Admin/MachDesignSpeedStringCurrent PackML State
<SITE>/<AREA>/<LINE>/Admin/ProdConsumedCount/*i*/IDStringConsumed Counter ID
<SITE>/<AREA>/<LINE>/Admin/ProdConsumedCount/*i*/NameStringConsumed Counter Name
<SITE>/<AREA>/<LINE>/Admin/ProdConsumedCount/*i*/UnitStringConsumed Counter Units
<SITE>/<AREA>/<LINE>/Admin/ProdConsumedCount/*i*/CountStringConsumed Counter Count since reset
<SITE>/<AREA>/<LINE>/Admin/ProdConsumedCount/*i*/AccCountStringConsumed Counter Total Count
<SITE>/<AREA>/<LINE>/Admin/ProdProcessedCount/*i*/IDStringProcessed Counter ID
<SITE>/<AREA>/<LINE>/Admin/ProdProcessedCount/*i*/NameStringProcessed Counter Name
<SITE>/<AREA>/<LINE>/Admin/ProdProcessedCount/*i*/UnitStringProcessed Counter Units
<SITE>/<AREA>/<LINE>/Admin/ProdProcessedCount/*i*/CountStringProcessed Counter Count since reset
<SITE>/<AREA>/<LINE>/Admin/ProdProcessedCount/*i*/AccCountStringProcessed Counter Total Count
<SITE>/<AREA>/<LINE>/Admin/ProdDefectiveCount/*i*/IDStringDefective Counter ID
<SITE>/<AREA>/<LINE>/Admin/ProdDefectiveCount/*i*/NameStringDefective Counter Name
<SITE>/<AREA>/<LINE>/Admin/ProdDefectiveCount/*i*/UnitStringDefective Counter Units
<SITE>/<AREA>/<LINE>/Admin/ProdDefectiveCount/*i*/CountStringDefective Counter Count since reset
<SITE>/<AREA>/<LINE>/Admin/ProdDefectiveCount/*i*/AccCountStringDefective Counter Total Count