Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel3
indent15px

Functions

newPico

...

getPicoIDByECI

Given an eci, get the pico_id that owns that channel.

ParameterDatatypeRequired
<eci><string>YES


Code Block
titlenewPicoremoveChannel
responsepico_id = engine:newPicogetPicoIDByECI().klog("Response Structure: ")
eci)
/*
  Response Structure:
	{ 		"id" : <new"some_pico_id>id"
	}
*/

Note: newPico does not provide an eci. This function is used in conjunction with engine:createChannel to create a pico with both an id and eci. See wranglerNPE.krl for an example of how to fully create a pico according to a given prototype.

removePico


listChannels

List all the channels for the given pico_id.

ParameterDatatypeRequired
<pico_id><string>YES


Code Block
titleremovePiconewChannel
responsechannels = engine:removePicolistChannels(pico_id).klog("engine:removePico
Response Structure: ")//id is just a string variable
/*
 Response Structure:
	undefined
 //engine:removePico(id) does not return anything
*/

...

Creates a new channel for a pico (identified to the engine by the pico_id parameter).

...

Code Block
titlenewChannel
response = engine:newChannel(id, "channel_name", "channel_type").klog("Response Structure: ")
/*
 Response Structure:
	/*
	[
      {
		"id" : "eci-0...",
		"name": "name 0",
		"type": "type 0"
 	  },
      {
		"id" : id"eci-1...",
		"name": "channel_name 1",
		"type": "channel_type 1"
 	  }
    ]
*/

...

listAllEnabledRIDs

List all the channels for the given pico_idenabled ruleset ids. No parameters are given.

Code Block
titleintall ruleset
rids = engine:listAllEnabledRIDs();
/*
	["io.picolabs.pico", "io.picolabs.logging"]
*/


describeRuleset

Given a ruleset id, get more information about it.

ParameterDatatypeRequired
<pico_id>
<rid><string>YES


Code Block
titlenewChannelintall ruleset
responsedesc = engine engine:listChannel(id).klog("Response Structure: ")
/*
 Response Structure:
	[describeRuleset("io.picolabs.hello_world");
/*
    {
        "rid": "io.picolabs.hello_world",
       { 		"idsrc" : "id-0ruleset io.picolabs.hello_world{ ...<cut for brevity> ... }",
		"name
        "hash": "name 0a096f2f3bfbd63e54bf4f39081814dbc895f3f003ae9918dbe24aec8acc097b9",
		"type": "type 0"
 	  }
        "url": "https://raw.githubusercontent.com/Picolab/node-pico-engine-core/master/test-rulesets/hello-world.krl",
        "timestamp_stored": "2017-05-17T21:31:21.663Z",
      {  		"idtimestamp_enable" : "id-1...",
		"name": "name 1",
		"type": "type 1"
 	2017-05-17T21:31:21.663Z",
        "meta": {
            "name": "Hello World",
            "description": "\nA first ruleset for the Quickstart\n    ",
            "author": "Phil Windley"
        }
    ]}
*/

...


Actions

newPico

Removes a channel whose eci matches the provided eci. This comparison and deletion takes place on the pico with the provided id.Creates a new pico. No parameters are given.

Code Block
titlenewPico
engine:newPico() setting(resp)
/*
	{
		"id" : <new_pico_id>
	}
*/

Note: newPico does not provide an eci. This action is used in conjunction with engine:createChannel to create a pico with both an id and eci. See wranglerNPE.krl for an example of how to fully create a pico according to a given prototype.


removePico


ParameterDatatypeRequired
<eci>
<pico_id><string>YES


Code Block
titleremoveChannelremovePico
response = engine:removeChannel(eci_of_channel).klog("Response Structure: "removePico(id)



newChannel

Creates a new channel for a pico (identified to the engine by the pico_id parameter).

ParameterDatatypeRequired
<pico_id><string>YES
<name><string>YES
<type><string>YES


Code Block
titlenewChannel
engine:newChannel(id, "channel_name", "channel_type") setting(resp)
/*
 Response Structure:
	undefined	{
		"id" : id,
		"name": "channel_name",
		"type": "channel_type"
 	}
*/

getPicoIDByECI

...

removeChannel

Removes a channel whose eci matches the provided eci. This comparison and deletion takes place on the pico with the provided id.

ParameterDatatypeRequired
<eci><string>YES


Code Block
titleremoveChannel
pico_id = engine:getPicoIDByECI(eci).klog("Response Structure: ")
/*
 Response Structure:
	"some_pico_id"
*/removeChannel("eci123...")


registerRuleset

ParameterDatatypeRequired
<url><string>YES
<base><string>NO

...

Code Block
titleregisterRuleset
response = engine:registerRuleset({"url": url, "base": base}).klog("Response Structure: ")
"some.cool.ruleset.krl") setting(resp) with base = "http://example.com/krl-files/"
/*
 Response  Structure: 	"myRuleset"
 Simply returns the rulesetID as a string. The rulesetID is the ruleset's name. 
"some.cool.ruleset.id"
*/


unregisterRuleset

Unregisters the ruleset given by the rid, or list of rids. It will throw an error if the ruleset is installed on any picos, or depended on by another ruleset.

ParameterDatatypeRequired
<rid>string | arrayYES

If your filename is myRuleset.krl, then the ruleset id will be "myRuleset".


Code Block
titleunregisterRuleset
response = engine:unregisterRuleset("myRuleset").klog("Response Structure: ")
/*
 Response Structure:
	undefined

//engine:unregisterRuleset("myRuleset") does not return anything
*/["rid.1", "rid.2"])


installRuleset

Installs ruleset(s) into a pico.  

...

Code Block
titleintall ruleset
response = engineengine:installRuleset( ent:id, "wrangler" ) );
response =setting(resp)
/*
    "wrangler"
*/

engine:installRuleset( ent:id, ["wrangler","Pds"] );
response = setting(resp)
/*
    ["wrangler","Pds"]
*/

engine:installRuleset( ent:id ) setting(resp) with base = <base> and url = <url>;
/*
 Response  Structure: 	"myRuleset"
 Simply returns the rulesetID as a string. If you passed multiple rids it will return the list of rids installed. 
the.rid.at.that.url"
*/


uninstallRuleset

uninstall a ruleset from a pico.  

...

This does not return anything

listAllEnabledRIDs

List all enabled ruleset ids. No parameters are given.

response = engine:describeRuleset("io.picolabs.hello_world"); /* Response Structure: { "rid": "io.picolabs.hello_world", "src": "ruleset io.picolabs.hello_world{ ...<cut for brevity> ... }", "hash": "a096f2f3bfbd63e54bf4f39081814dbc895f3f003ae9918dbe24aec8acc097b9", "url": "https://raw.githubusercontent.com/Picolab/node-pico-engine-core/master/test-rulesets/hello-world.krl", "timestamp_stored": "2017-05-17T21:31:21.663Z", "timestamp_enable": "2017-05-17T21:31:21.663Z", "meta": { "name": "Hello World", "description": "\nA first ruleset for the Quickstart\n ", "author": "Phil Windley" } } */
Code Block
Code Block
titleintall ruleset
titleintall ruleset
response = engine:listAllEnabledRIDs();
/*
 Response Structure:
	["io.picolabs.pico", "io.picolabs.logging"]
*/

describeRuleset

Given a ruleset id, get more information about it.

...

unregisterRuleset
engine:uninstallRuleset( meta:picoId, "myRuleset")


engine:uninstallRuleset( meta:picoId, ["rid.1", "rid.2"])