IoT Drivers applications is build based on nodejs which use ZeroMQ as messaging queue using broker-less architecture and pub-sub model. Driver is user interactable (command-line tool), based on the command provided by user driver initiates the requests to simulator. If there is no response from the Simulator, timeout occurs after 3 secs for each request.
Clone the code from below git
git clone https://github.com/sathyendranv/NodeMasterSlaveSimulator.git
Nodejs (Version 12.22.12) - Tested with this version.
Following node modules needs to be installed using the package manager npm.
-
ZeroMQ used as broker-less architecture to communicate between the driver and Simulator on Socket ports using pub-sub model.
> cd NodeMasterSlaveSimulator NodeMasterSlaveSimulator> npm install zeromq
> cd NodeMasterSlaveSimulator
NodeMasterSlaveSimulator> cd driver
NodeMasterSlaveSimulator/driver> node driver_main.js
NodeMasterSlaveSimulator/driver> node driver_main.js
Cmd?> ?
Supported command:
Command Description
-------- -------------
device online To Check whether the Device is online(connected)
help/? Show Help Window
quit/exit/q Exit or Quit the Driver
connect simulator Connect or reconnect to Simulator
s/S Request to send current stable weight from Simulator
Cmd?> s
Sending Request to get the Current Weight...
Current Weight Response Received...
Current Stable Net Weight Value is 909 Kilogram (kg) measured at Thu Jul 28 2022 00:36:01 GMT+0530 (India Standard Time)
Balance in overload Range
Cmd?> s
Sending Request to get the Current Weight...
Current Weight Response Received...
Current Stable Net Weight Value is 118 Tonne (t) measured at Thu Jul 28 2022 00:36:08 GMT+0530 (India Standard Time)
Balance in underload Range
Cmd?> s
Sending Request to get the Current Weight...
Current Weight Response Received...
Current Stable Net Weight Value is 387 Decagram (dag) measured at Thu Jul 28 2022 00:36:10 GMT+0530 (India Standard Time)
NodeMasterSlaveSimulator/driver> node driver_main.js
Cmd?> device online
Checking the Simulator is online...
Simulator is not online. Please start the simulator.
Cmd?>
> cd NodeMasterSlaveSimulator
NodeMasterSlaveSimulator> cd simulator
NodeMasterSlaveSimulator/simulator> node simulator.js
Every request and response, received or sent are logged to console.
Received Request to check Simulator Online?. Sending response now...
----------------------------------------------------------------------------
Received Request for Sending Current Stable Weight
Sending...
Current Weight: 0
Weight unit: na
----------------------------------------------------------------------------
Received Request for Sending Current Stable Weight
Generating random weight value...
Sending...
Current Weight: 454
Weight unit: g
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.