walkner-hydro
Water pump station control and monitoring application in Node.js.
Requirements
Node.js
Node.js is a server side software system designed for writing scalable Internet applications in JavaScript.
- Version: 8.x.x
- Website: http://nodejs.org/
- Download: http://nodejs.org/download/
- Installation guide: https://github.com/joyent/node/wiki/Installation
MongoDB
MongoDB is a scalable, high-performance, open source NoSQL database.
- Version: 3.6.x
- Website: http://mongodb.org/
- Download: http://www.mongodb.org/downloads
- Installation guide: http://docs.mongodb.org/manual/installation/
MODBUS PLC Simulator (optional)
MODBUS TCP protocol simulator for Windows. Can be used to test the application without any changes to the configuration (if run on the same machine).
- Website: http://www.plcsimulator.org/
- Download: http://www.plcsimulator.org/downloads
Installation
Clone the repository:
git clone http://github.com/morkai/walkner-hydro.git
or download and extract it.
Go to the project's directory and install the dependencies:
cd walkner-hydro/
npm install -g grunt-cli
npm install
Configuration
Application servers are started like so:
node walkner-hydro/backend/main.js <config-file.js>
where <config-file.js>
is a path to a JavaScript file relative
to the walkner-hydro/backend/main.js
file.
The JS config file should export at least two properties:
-
id
- a string identifying the server process, -
modules
- a list of modules to start. A module can be an ID string or an object withid
andname
properties. If only the ID is specified, name is assumed to be equal to the ID. Theid
is a name of one of the files/directories underwalkner-hydro/backend/modules/
. Thename
is a unique name of the module used throughout the configuration (in case one module is started multiple times with different configuration).
Additionally, config file can export properties for each of the listed modules.
Property name must equal to the module name
and its value must be an object that will be merged
with the module's default config and passed to the module instance.
Each application module may export the DEFAULT_CONFIG
object which can be used to check what
options are available for configuration.
See an example config files under the walkner-hydro/config/
directory.
Building
To run the application in the production environment (NODE_ENV=production
), an optimized version
of the frontend/
directory must be generated by executing the following command:
grunt build-frontend
If the command finishes without an error, then a new directory named frontend-build/
should appear
with:
- all EJS templates compiled to JS AMD templates,
- all MessageFormat JSON files compiled MessageFormat JS AMD files,
- all JS and CSS files minified,
- all used JS files concatenated into one file (
frontend-build/main.js
), - all used CSS files concatenated into one file (
frontend-build/assets/main.css
).
Starting
Manual
- Start the MongoDB server.
- Set the
NODE_ENV
environmental variable todevelopment
(default) orproduction
(expects thefrontend-build/
directory). - Start the
controller
server:node backend/main.js ../config/controller.js
- Start the
alarms
server:node backend/main.js ../config/alarms.js
- Start the
frontend
server:node backend/main.js ../config/frontend.js
- Optionally, for testing purposes, start the MODBUS PLC Simulator.
- Go to http://127.0.0.1/ or https://127.0.0.1/
- Log in using
root
/1337
.
pm2
The three server processes can be managed by the pm2 (not available on Windows).
Install the pm2
package (globally):
npm install -g pm2
Go to the walkner-hydro/bin/
directory:
cd walkner-hydro/bin/
and execute:
pm2 start processes.json
To keep the processes alive after restarts (only on Ubuntu and CentOS), execute the following command:
pm2 startup
License
walkner-hydro is released under the CC BY-NC-SA 4.0 License.
Copyright (c) 2018, Łukasz Walukiewicz (lukasz@miracle.systems). Some Rights Reserved.