npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

giri-sector-control

v2.4.1

Published

Garden irrigator system - sector control microservices plugin

Downloads

12

Readme

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.