2.4.1 • Published 7 years ago

giri-sector-control v2.4.1

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

giri-sector-control

npm version Build Status Coveralls

This is a seneca plugin, that contains the sector level microservices of the giri system.

Prerequisites

The plugin needs the following seneca plugins to be used:

Installation

Run the install command:

npm install

Run tests:

$ npm test

To see the coverage, run:

npm run coverage

Usage

To load the plugin:

    seneca.use('giri-sector-control')

Options

There are no options for this plugin.

Actions

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. If there is no sector found with the given id, 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.

  1. The config.mode is set to the new value, which is the value of payload.config.mode property.
  2. If the new payload.config.mode is INACTIVE or AUTO, then the state of the sector is always has to be set to OFF. In case it is MANUAL, then it is set to the value of payload.state.
  3. Send a setState command to the valve according to the new value of the state property of the sector.
  4. If the new config.mode 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. The sector will be set to INACTIVE 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.

References


This project was generated from the seneca-plugin-archetype by the kickoff utility.

2.4.1

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago