Difference between revisions of "Reasoners"

From AMTech WikiDocs
Jump to: navigation, search
Line 1: Line 1:
 
# [[Reasoner by property]]
 
# [[Reasoner by property]]
 
+
# [[Reasoner by Resource]]
=Reasoner by Resource=
+
 
+
[[File:ReasonerByResource.png|1150px|thumbnail|center]]
+
 
+
===Reasoner For each ===
+
 
+
[[File:ReasonerForEachByResourceCreate.png|1150px|thumbnail|center]]
+
 
+
====Create====
+
 
+
# MainMenu/Activities/Reasoner
+
# Click create
+
# Select For Each entity
+
# Enter a Name
+
# Once The Reasoner editor is open
+
# Enter Description
+
# Select the observer
+
# Select Topic from where you are getting the observation
+
# Select Action Create,
+
# Dialog Box for create will be open Select by recurso
+
# Select type of entity you want to create
+
# Enter a label to identify the action
+
# On right side click on action
+
# Select on right side new fields and user can see he can write the info using javascript
+
#: Example:
+
#: <syntaxhighlight lang="javascript">
+
function(newthing,observation,thing,summary){ 
+
    newthing._name ="Entity77"+ new Date().getTime().toString();
+
    newthing.DoubleData = observation.ObsDoubleData;
+
    newthing.description ="Testing Create by recurso";       
+
}
+
</syntaxhighlight>
+
#: '''Note:''' there are required fields if user does not enter them the reasoner wont run
+
# Run reasoner
+
 
+
Expected
+
 
+
For each entity returned by observer system will create a new entity
+
 
+
====Update ====
+
 
+
Same steps as Create
+
 
+
<syntaxhighlight lang="javascript">
+
function(updatething,observation,thing){ 
+
    updatedthing.description ="Bless be the ones who serve others. They are the ones who find heaven on earth.";
+
    updatedthing.CityPopulation = 123000123;
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
The system will update each entity returned by the observer
+
 
+
====Send Notification ====
+
 
+
same as for each send notification by properties
+
 
+
==== Delete ====
+
 
+
same as for each Delete by properties
+
 
+
====Send Observations ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation,thing){ 
+
    newobservation._name = "SendObserRecurso"+ new Date().getTime().toString();
+
    newobservation.topic = observation.topic;  (Required field)
+
    newobservation.producer = observation.producer;  (Required field)
+
}
+
</syntaxhighlight>
+
 
+
'''Note: there are required fields if user does not enter them the reasoner wont run'''
+
 
+
====Schedule Send Observation ====
+
 
+
The same as send observation user just need to specify Initiation Date and time, occurrence and frequency Note:
+
 
+
Occurrence 0 must enter frequency like; sec, mins, hours etc If user for example enters frequency days that means observation will be send every day forever Starting on the Start date and Time
+
 
+
Occurrence 1 frequency will be ignore. The system will send that schedule observation on the Start Date and Time only once
+
 
+
Occurrence 2 or more must enter frequency. The system will send the observation according to frequency and Start Date and Time
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation,thing){ 
+
    newobservation._name = "SendObserRecurso"+ new Date().getTime().toString();
+
    newobservation.topic = observation.topic;  (Required field)
+
    newobservation.producer = observation.producer;  (Required field)
+
}
+
</syntaxhighlight>
+
 
+
'''Note: there are required fields if user does not enter them the reasoner wont run'''
+
 
+
Expected
+
 
+
For each Entity returned by the observer the system will schedule to send a new observation
+
 
+
===Reasoner At Least One ===
+
 
+
====Create ====
+
 
+
# MainMenu/Activities/Reasoner
+
# Click create
+
# Select At least one Entity
+
# Enter a Name
+
# Once The Reasoner editor is open
+
# Enter Description
+
# Select the observer
+
# Select Topic from where you are getting the observation
+
# Select Action Create,
+
# Dialog Box for create will be open Select by recurso
+
# Select type of entity you want to create
+
# Enter a label to identify the action
+
# On right side click on action
+
# Select on right side new fields and user can see he can write the info using javascript
+
#: Example:
+
#: <syntaxhighlight lang="javascript">
+
function(newthing,observation,thing){ 
+
    newthing._name ="Entity55";
+
    newthing.DoubleData = observation.ObsDoubleData;
+
    newthing.description ="Testing Reasoner At least One Create by recurso";
+
}
+
</syntaxhighlight>
+
#: '''Note: there are required fields if user does not enter them the reasoner wont run'''
+
# Run reasoner
+
 
+
 
+
Expected
+
If Observer return at least one Entity the system will create a new entity if observer does not return entity system won't create the new Entity
+
 
+
====Send Notifications ====
+
 
+
same as send Notification by properties
+
 
+
====Send Observations ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation,thing){
+
    newobservation._name = "SendObserRecurso333"; (Mandatory Field)
+
    newobservation.topic = observation.topic;  (Mandatory Field)
+
    newobservation.producer = observation.producer;  (Mandatory Field)
+
}
+
</syntaxhighlight>
+
 
+
====Schedule Send Observations ====
+
The same as send observation user just need to specify Initiation Date and time, occurrence and frequency
+
Note:
+
 
+
Occurrence 0 must enter frequency like; sec, mins, hours etc If user for example enters frequency days that means observation will be send every day forever Starting on the Start date and Time
+
 
+
Occurrence 1 frequency will be ignore. The system will send that schedule observation on the Start Date and Time only once
+
 
+
Occurrence 2 or more must enter frequency. The system will send the observation according to frequency and Start Date and Time
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation){
+
    newobservation.producer = "Copertino";
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If Observer return at least one entity the system will Schedule to send a new Observation
+
 
+
===Reasoner Only Observations ===
+
 
+
==== Create ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newthing,observation){
+
    newthing._name ="EntityObsOnlyRecurso";
+
    newthing.DoubleData = observation.ObsDoubleData;
+
    newthing.description ="Testing Reasoner Obs Only Create by recurso";
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If the run of Observer is positive the system will Create a New Entity
+
 
+
====Send Notifications ====
+
 
+
same as send notification by properties
+
 
+
====Send Observations ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation){
+
    newobservation._name = "SendObserRecursoObsOnly";
+
    newobservation.topic = observation.topic;  (Mandatory field)
+
    newobservation.producer = observation.producer;  (Mandatory field)
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If the run of Observer is positive the system will Send the observation
+
 
+
====Schedule Send Observations ====
+
 
+
The same as send observation on Action select schedule observations user just need to specify Initiation Date and time, occurrence and frequency
+
 
+
'''Note:'''
+
 
+
Occurrence 0 must enter frequency like; sec, mins, hours etc If user for example enters frequency days that means observation will be send every day forever Starting on the Start date and Time
+
 
+
Occurrence 1 frequency will be ignore. The system will send that schedule observation on the Start Date and Time only once
+
 
+
Occurrence 2 or more must enter frequency. The system will send the observation according to frequency and Start Date and Time
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation){
+
    newobservation._name = "ScheduleSendObserRecursoObsOnly";
+
    newobservation.topic = observation.topic; 
+
    newobservation.producer = observation.producer;
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If the run of Observer is positive the system will Send the observation
+
according to the schedule
+
 
+
===Reasoner Absence of things ===
+
 
+
====Create ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newthing,observation){
+
    newthing._name ="EntityDoNotReturnRecurso111";
+
    newthing.DoubleData = observation.ObsDoubleData;
+
    newthing.description ="Testing Reasoner Do not return entity Create by recurso";
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If Observer do not return an entity the system will create a new entity
+
 
+
====Send Notifications ====
+
 
+
====Send Observations ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation){
+
    newobservation._name = "SendObserRecursoNoEntity";
+
    newobservation.topic = observation.topic; 
+
    newobservation.producer = observation.producer;
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If Observer do not return an entity the system will Send Observation
+
 
+
====Schedule Send Observations ====
+
 
+
<syntaxhighlight lang="javascript">
+
function(newobservation,observation){
+
    newobservation._name = "ScheduleSendObserRecursoNoEntity";
+
    newobservation.topic = observation.topic; 
+
    newobservation.producer = observation.producer;     
+
}
+
</syntaxhighlight>
+
 
+
Expected
+
 
+
If Observer do not return an entity the system will Schedule and send observation according to schedule
+
 
+
 
=Reasoner Increment, Decrement, Set =
 
=Reasoner Increment, Decrement, Set =
  

Revision as of 18:27, 23 April 2016

  1. Reasoner by property
  2. Reasoner by Resource

Reasoner Increment, Decrement, Set

First this only works for numeric fields like integer or double when user set a supported property that is double or integer of a type of entity he has to check the check box for atomic updates Then this only works for reasoner for each by property action updates

on the right side user will be able to select from set, increment or decrement then there is an entry box to enter a numeric value on how much you want decrement or increment or set is just to set a fix value

for example Field to update is Temp max that initially was 2 then user select increment then enter 2 then user runs reasoner on temp max the result will be 4

ScreenShotDecIncSet2016-03-11.png

Reasoner proximity Area

Proximity area option will allow the user to set an entity to the proximity area field to a new entity created by the reasoner

User can do this several ways

  • User just selects the entity from the list
  • User does a binding where user selects the proximity area that was selected on the observer
  • Using Javascript he can do the two previous options

example :

proximityarea = observation.proximityarea;

proximityarea = "/amtech/things/entities/TempEntity/TempNewPort";


ReasonerProximityArea.png

Note:In case Entity does not exist results windows wont alert user