HeaRTDroid is a rule-based inference engine both for Android mobile devices, and desktop solutions
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pub:software:heartdroid:tutorials:callbacks [2016/12/28 13:31] admin [Actions] |
pub:software:heartdroid:tutorials:callbacks [2017/01/12 13:09] admin [Use case] |
||
---|---|---|---|
Line 24: | Line 24: | ||
The problem here is that the values for day, hour and location can be automatically obtained from the system, we should not provide these information //by hand//. | The problem here is that the values for day, hour and location can be automatically obtained from the system, we should not provide these information //by hand//. | ||
These is what are the **callbacks** for. | These is what are the **callbacks** for. | ||
+ | |||
+ | You an download the model with callbacks created from {{:pub:software:heartdroid:tutorials:parking-zones-clb.zip|here}}. However, we encourage you to follow the rest of the tutorial and try to build it on your own. | ||
Additionally, the notification to the user about whether he or she should start paying for parking should also be somehow presented to him/her, as the Linux console (or Android LogCat) is not very user-friendly tool for regular users. | Additionally, the notification to the user about whether he or she should start paying for parking should also be somehow presented to him/her, as the Linux console (or Android LogCat) is not very user-friendly tool for regular users. | ||
Line 97: | Line 99: | ||
There are several differences though: | There are several differences though: | ||
* Actions are associated with rules and are fired when the rule fires | * Actions are associated with rules and are fired when the rule fires | ||
+ | * Each rule may have severl actions assigned | ||
* Actions should implement Action interface, instead of Callback interface | * Actions should implement Action interface, instead of Callback interface | ||
* Action cannot modify the state of attributes, although have insight into the current state of the system (current values of all the attributes from the model) | * Action cannot modify the state of attributes, although have insight into the current state of the system (current values of all the attributes from the model) | ||
+ | |||
+ | To add an action to your rule, use the ''<nowiki>**></nowiki>'' operator, like in the listing below: | ||
+ | <code> | ||
+ | xrule parkingReminder/1: | ||
+ | [ | ||
+ | location eq pay_zone, | ||
+ | tariff eq pay | ||
+ | ] | ||
+ | ==> | ||
+ | [ | ||
+ | notification set start_parking_fee | ||
+ | ] | ||
+ | **> | ||
+ | [ | ||
+ | 'ShowNotification', | ||
+ | 'StartPayment' | ||
+ | ].#1 | ||
+ | </code> | ||
+ | |||