Warning, Untested Example
Picos can be created using prototypes that describe what state a pico should be created in.
Picos can have certain rulesets, channels, and subscriptions that control what a pico is, Prototypes directly reflect this.
here is an example of a Prototype.
Code Block | ||
---|---|---|
| ||
{
"meta" : {
"discription": "picoLabExample prototype"
},
"rids": [
"b16x29.prod",
"b507901x6.prod"
],
"channels" : [{
"name" : "_wellKnown_app_eci",
"type" : "WellKnown",
"attributes" : "none",
"policy" : "not implemented"
}
],
"prototypes" : [],
"subscriptions_request": [],
"Prototype_events" : [],
"PDS" : {
"profile" : {
"name":"base",
"description":"discription of the general pds created",
"location":"40.252683,-111.657486",
"model":"unknown",
"model_description":"no model at this time",
"photo":""
},
"general" : {"test":{"subtest":"just a test"}},
"settings": {"b507901x1.prod":{
"name":"wrangler",
"keyed_rid" :"b507901x1.prod",
"schema":["im","a","schema"],
"data_key":"first_key",
"value":"first_value"
}
}
}
} |
Prototypes are json objects which have desired things to be added at creation.
Before a child_creation event you can add a prototype by url, and have wrangler use this prototype to create the pico accordingly.
Code Block | ||
---|---|---|
| ||
rule createPicoWithPrototypeURL {
select when owner need_new_pico
pre {}
/*action*/{ noop();}
always {
raise wrangler event "add_prototype"
with prototype_name = 'NewPrototypeExample'
and url = 'https://raw.githubusercontent.com/burdettadam/Practice-with-KRL/master/manifold/NewPrototypeExample.json';// ----------------------------------------------needs url to prototype. ---------------------------------------------------------
raise wrangler event "child_creation"
with name = 'PrototypeExample'
and prototype = 'NewPrototypeExample'; // must be the same name you used above
log("SUCCESS OFTEN COMES AFTER DISAPPOINTMENTS.");// just a friendly log.
}
} |
While the url is hard coded in this example you could easily use a attribute to dynamically pass in any prototype you would like.