Garden irrigator system - sector control microservices plugin
npm install giri-sector-controlgiri-sector-control
===================
[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[![Coveralls][BadgeCoveralls]][Coveralls]
This is a seneca plugin, that contains the sector level microservices of the giri system.
The plugin needs the following seneca plugins to be used:
Run the install command:
npm install
Run tests:
$ npm test
To see the coverage, run:
npm run coverage
To load the plugin:
``JavaScript`
seneca.use('giri-sector-control')
There are no options for this plugin.
All actions provide results via the standard callback format: function(error,data){ ... }.
#### role: giri-sector-control, cmd: getSectors
Get a list on all of the sectors available.
_Parameters:_
- None
_Response:_
- The array of available sector objects.
#### role: giri-sector-control, cmd: getClusterSectors
Get a list on all of the sectors available and belongs to the selected cluster.
_Parameters:_
- clusterId: The id of the cluster the sectors belong to. It is the clusterId property of the sector object.
_Response:_
- The array of available sector objects with the given clusterId.
#### role: giri-sector-control, cmd: getSector
Get the sector selected by its id
_Parameters:_
- payload:idx
- : the index of the sector in the cluster,
_Response:_
- payload: The sector object, incl. the properties listed below.name
- : the name of the sector,clusterId
- : the id of the cluster the sector belongs to,idx
- : the index of the sector in the cluster,config
- : the actual configuration of the sector:mode
- : The working mode of the sector, that is one of the following value: INACTIVE, MANUAL, AUTO,startAt
- : cron pattern string of start the active period, if mode is AUTO,duration
- : length of period in minutes, if mode is AUTO,state
- : the required state of the sector,port
- : the port configuration parameters, the sector is using, including:deviceId
- : the physical device id of the port device used by the sector to switch the solenoid,portIdx
- : the index of the port on the physical device.
#### role: giri-sector-control, cmd: createSector
Create a new sector, with a generated unique id.
_Parameters:_
- payload: The sector object, to create. The sector object may have the following properties:name
- : the name of the sector,clusterId
- : the id of the cluster the sector belongs to,idx
- : the index of the sector in the cluster,config
- : the actual configuration of the sector:mode
- : The working mode of the sector, that is one of the following value: INACTIVE, MANUAL, AUTO,startAt
- : cron pattern string of start the active period, if mode is AUTO,duration
- : length of period in minutes, if mode is AUTO,state
- : the required state of the sector,port
- : the port configuration parameters, the sector is using, including:deviceId
- : the physical device id of the port device used by the sector to switch the solenoid,portIdx
- : the index of the port on the physical device.
_Response:_
- The sector object, which equals to the incoming message payload object, incl. the properties listed above, plus the id.
After creation the sector immediately goes into the working mode that is defined by the config and state properties.
#### role: giri-sector-control, cmd: updateSector
Updates the properties of a sector, selected by its id.id
If there is no sector found with the given , then it creates a new one with this id,
and sets its actual properties according to the input parameters.
_Parameters:_
- payload: The sector object, to create. The sector object may have the following properties:id
- : the unique id of the sector,name
- : the name of the sector,clusterId
- : the id of the cluster the sector belongs to,idx
- : the index of the sector in the cluster,config
- : the actual configuration of the sector:mode
- : The working mode of the sector, that is one of the following value: INACTIVE, MANUAL, AUTO,startAt
- : cron pattern string of start the active period, if mode is AUTO,duration
- : length of period in minutes, if mode is AUTO,state
- : the required state of the sector,port
- : the port configuration parameters, the sector is using, including:deviceId
- : the physical device id of the port device used by the sector to switch the solenoid,portIdx
- : the index of the port on the physical device.
_Response:_
- The updated sector object which equals to the incoming message payload object.
The update may cause state transition of the sector, depending on its actual state before the update, and the incoming
payload. The current state and the payload's config and state properties will determine the new mode and state
accoring to the execution of the following steps:
1. If the actual config.mode is AUTO, then change to INACTIVE mode:
1.1 stop the timer, that is actually running,
1.2 set config.mode to INACTIVE,
1.3 remove the timer parameters.
2. The config.mode is set to the new value, which is the value of payload.config.mode property.payload.config.mode
3. If the new is INACTIVE or AUTO, then the state of the sector is always has to be set to OFF.MANUAL
In case it is , then it is set to the value of payload.state.setState
4. Send a command to the valve according to the new value of the state property of the sector.config.mode
5. If the new is AUTO, then start the timer, with its startAt and duration parameters.
In AUTO mode, the timer will activate the valve, when the active period starts, and will deactivate, when the period ends.
#### role: giri-sector-control, cmd: resetSector
Reset the sector selected by its id.INACTIVE
The sector will be set to mode, and the state to OFF.
_Parameters:_
- payload: An object, which holds the id of the sector to reset.id
- . The id of the sector to reset.
_Response:_
- An empty {}` object.
- giri home page
- Seneca.js
- How to Write a Seneca Plugin
- Seneca plugins
- Chai Assertion Library / BDD API Reference
- node-schedule
- cron-parser
---
This project was generated from the seneca-plugin-archetype
by the kickoff utility.
[npm-badge]: https://badge.fury.io/js/giri-sector-control.svg
[npm-url]: https://badge.fury.io/js/giri-sector-control
[travis-badge]: https://api.travis-ci.org/tombenke/giri-sector-control.svg
[travis-url]: https://travis-ci.org/tombenke/giri-sector-control
[Coveralls]: https://coveralls.io/github/tombenke/giri-sector-control?branch=master
[BadgeCoveralls]: https://coveralls.io/repos/github/tombenke/giri-sector-control/badge.svg?branch=master