Difference between revisions of "Execution engine"

From AMTech WikiDocs
Jump to: navigation, search
(Security context)
(Security context)
Line 36: Line 36:
 
[[File:action_security.png|650px|thumbnail|center|Security for objects being created]]
 
[[File:action_security.png|650px|thumbnail|center|Security for objects being created]]
  
Check [[Access_control#Access_while_executing_observers_in_the_reasoner.27s_engine|this section]] fur further details.
+
Check [[Access_control#Access_while_executing_observers_in_the_reasoner.27s_engine|this section]] for further details.
  
 
== Extension module ==
 
== Extension module ==

Revision as of 12:54, 12 July 2018

CEP (Complex Event Processing — now called Event Stream Processing)

AMTech execution engine is an implementation of a CEP; it encapsulates CEP's complexity in the DAP design.

Execution feedback and/or errors

When an activity is being executed by the execution engine an observationlifecycle type is sent to the activity_lifecycle topic. Some events are reported through the property event, among this events:

  • Start of a reasoner (BEGIN)
  • End of a reasoner (END)
  • Execution errors (ERROR)

The following example illustrates activity "producer": "thingsInBoardroom" reporting action "resourceuri": "/amtech/activities/thingsInBoardroom/reasoners/createThingInBoardroomFromEddystoneBeacon/actions/ReportThingInBoardroom" started "event": "BEGIN"

    {
        "topic": "/activity_lifecycle/thingsInBoardroom",
        "guesttenants": [
            "_ALL"
        ],
        "event": "BEGIN",
        "@type": "/amtech/linkeddata/types/composite/observation/observationlifecycle",
        "producer": "thingsInBoardroom",
        "resourceuri": "/amtech/activities/thingsInBoardroom/reasoners/createThingInBoardroomFromEddystoneBeacon/actions/ReportThingInBoardroom",
        "detectiontime": "Tue Apr 26 21:41:09 UTC 2016",
        "@id": "/amtech/things/observations/983c488f-c3d4-44ec-85f2-795428d12d83",
        "occurrencetime": "Tue Apr 26 21:41:08 UTC 2016"
    }
This is a strong mechanism you can use to trace the execution of your activities if, at a given moment, you think they are not working as expected.

Security context

When creating a reasoner, the user can select if the security info for executing the observer and running the reasoner's actions should be taken from the observation triggering the reasoner, or from the service to which the reasoner belongs.

Security from observation or service
  • If using the observation security
    • The observer will return only those things readable by the tenant of the observation. Also, all actions that create objects (things, observations, notifications, etc) will initialize the security context of the object being created with the security context of the observation being consumed.
    • The actions will be executed using the tenant of the observation
  • If using the service security
    • The observer will return all the things readable by the service. Also, all actions that create objects (things, observations, notifications, etc) will ask you to select between the security context of the observation being consumed and the security context of the thing being visited as the security context of the object being created.
    • The actions will be executed using the service (representing all tenants subscribed to the service)
Security for objects being created

Check this section for further details.

Extension module

EPC

Electronic product code Tag Data Translation implemented according to the GS1 EPC Tag Data Translation 1.6 specification (http://www.gs1.org/epc/tag-data-translation-standard) Exposed as 2 JavaScript functions available for reasoner's JavaScript binding:

* epcEncode
* epcDecode

They support the following codings:

  • SGTIN-96, SGTIN-198, SSCC-96, SGLN-96, SGLN-195, GRAI-96, GRAI-170, GSRN-96, GSRNP-96, GDTI-96, GDTI-174, GID-96.

Debug

(See check reasoner)

Geospatial libraries

A couple of libraries are available in JavaScript bindings:

You can make use of these libraries using the variables geolib and terraformer that are initialized as follows:

 var geolib = require('geolib');
 var terraformer = require('terraformer');

Example binding location property to a new created geofence thing, using the location from observation and calculating a circle with 300 radius

function(observation)
{
    var location;
    //get wkt json
    var loc = JSON.parse(observation.location);
    //parse longitude and latitude from wkt text
    var point = terraformer.WKT.parse(loc.wkt);
    //create a circle with 100 metres radius
    var circle = new terraformer.Circle([point.coordinates[0], point.coordinates[1]], 100, 64);
    //create location wkt 
    location = terraformer.WKT.convert(circle.geometry);
    //wkt poligon location bind to created geofence thing
    return location;
}