π Table of Contents
β¨ About the Project
-
Power generators are basically small power-plants. They allow their owners to generate electricity on-site, as a substitute or complement to electricity from the electric grid.
-
pgmqtt is a simulator generates power generators data and publish it over MQTT.
-
Each power generator will write to its own MQTT topic the following tags:
- Load
- Power
- Temperature
- Fuel Level
- Base Fuel
- Used Fuel
- The message payload of a simulated generator :
{
"Name": "Generator_1",
"Lat": -65.37906,
"Lon": -62.64473,
"Base Fuel": 909.3602
}
- The message payload of a generator's tag :
{
"ItemTopic": "Site/Area/Power-Generators/Generator_8/Load",
"ItemId": "147377909",
"ItemName": "Load",
"ItemValue": 69,
"ItemOldValue": 71,
"ItemDataType": "INT",
"ChangedTimestamp": "2022-07-10T06:42:59+01:00",
"PreviousTimestamp": "2022-07-10T06:42:54+01:00"
}
π· Screenshots
Power-Generator MQTT microservice :
MQTT Client subscribing to topics published by the microservice
π Using the simulator
Check out a scenario of using the simulator :
Watch it on YouTube
- Clone this repository :
git clone [email protected]:amine-amaach/simulators.git && cd examples/pgmqtt/
- Run π
docker compose up
π» Development
Make sure you have GO installed (1.18+)
- Clone this repository :
git clone [email protected]:amine-amaach/simulators.git && cd pgmqtt
- Run π
go run cmd/pgmqtt/main.go
And Happy Coding
π£οΈ Roadmap
- Randomize the delay between messages separately for each generator.
- Simulate multiple generators in a single
microservice
.
- Support TLS connections.
βοΈ Configuration
The application is configured using the following environmental variables:
SITE
- The ISA-95 Model site name. SITE used as the parent topic in the MQTT structure. If this is unset, Site will be used.
AREA
- The ISA-95 Model area name. AREA used as the second topic in the MQTT structure. If this is unset, Area will be used.
MQTT_SERVER_URL
- The address of the MQTT server.
MQTT_SERVER_USER
- The name of the MQTT user with subscribe and publish permissions.
MQTT_SERVER_PWD
- The password for the MQTT user with subscribe and publish permissions.
MQTT_CLIENT_ID
- The client id to use when connecting to the broker.
DELAY_BETWEEN_MESSAGES_MIN
- The minimum delay between messages in seconds.
DELAY_BETWEEN_MESSAGES_MAX
- The maximum delay between messages in seconds.
RANDOM_DELAY_BETWEEN_MESSAGES
- If set to
true
the delay between messages will be randomly generated based on DELAY_BETWEEN_MESSAGES_MIN
and DELAY_BETWEEN_MESSAGES_MIN
env variables, else DELAY_BETWEEN_MESSAGES_MIN
will be set as fixed delay.
GENERATORS_NUMBER
- The number of generators to simulate.
GENERATORS_NUMBER_LIMIT
- The maximum number of generators to simulate, if
GENERATORS_NUMBER
> GENERATORS_NUMBER_LIMIT
the number of generators will be set to GENERATORS_NUMBER_LIMIT
Amine Amaach - LinkedIn - Email
Project Link: https://github.com/amine-amaach/simulators.git
π Contributing
Every bit helps! If you come across any bugs, please send a bug report, or if you feel inclined to fix it yourself, submit a pull request.
π Acknowledgements & Inspiration