Functions
newPico
...
getPicoIDByECI
Given an eci, get the pico_id that owns that channel.
Parameter | Datatype | Required |
---|
<eci> | <string> | YES |
Code Block |
---|
title | newPicoremoveChannel |
---|
|
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.
Parameter | Datatype | Required |
---|
<pico_id> | <string> | YES |
Code Block |
---|
title | removePiconewChannel |
---|
|
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 |
---|
|
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"
}
]
*/ |
...
List all the channels for the given pico_idenabled ruleset ids. No parameters are given.
Code Block |
---|
|
rids = engine:listAllEnabledRIDs();
/*
["io.picolabs.pico", "io.picolabs.logging"]
*/ |
Given a ruleset id, get more information about it.
Parameter | Datatype | Required |
---|
<pico_id>
Code Block |
---|
title | newChannelintall 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 |
---|
|
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
Parameter | Datatype | Required |
---|
<eci>
Code Block |
---|
title | removeChannelremovePico |
---|
|
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).
Parameter | Datatype | Required |
---|
<pico_id> | <string> | YES |
<name> | <string> | YES |
<type> | <string> | YES |
Code Block |
---|
|
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.
Parameter | Datatype | Required |
---|
<eci> | <string> | YES |
Code Block |
---|
|
pico_id = engine:getPicoIDByECI(eci).klog("Response Structure: ")
/*
Response Structure:
"some_pico_id"
*/removeChannel("eci123...") |
registerRuleset
Parameter | Datatype | Required |
---|
<url> | <string> | YES |
<base> | <string> | NO |
...
Code Block |
---|
|
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.
Parameter | Datatype | Required |
---|
<rid> | string | array | YES |
If your filename is myRuleset.krl, then the ruleset id will be "myRuleset".
Code Block |
---|
|
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 |
---|
|
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"
*/ |
uninstall a ruleset from a pico.
...
This does not return anything
List all enabled ruleset ids. No parameters are given.
Code Block |
---|
Code Block |
---|
|
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"
}
}
*/ |
response = engine:listAllEnabledRIDs();
/*
Response Structure:
["io.picolabs.pico", "io.picolabs.logging"]
*/ |
Given a ruleset id, get more information about it.
...
|
engine:uninstallRuleset( meta:picoId, "myRuleset")
engine:uninstallRuleset( meta:picoId, ["rid.1", "rid.2"]) |