- Supported operations are: || && == != <= < >= > + - * / % ^
- The use of paranthesis are also supported
- Variable names start with an under-score (e.g _thisIsAVariable)
- Everything else is considered a constant
- White spaces are allowed between symbols
An emiter registers itself to the bus by calling the setEmitter method with a specific code (message identifier) that it emits.
A listener registers for a specific code by calling the addListener method, and it can stop listening for that message by calling the removeListener method.
When a listener registers for a message, the MessageTracker finds the emitter for that message and calls it's addListener method with the arguments the actual listener passed in. So it acts as the middle man for the addListener calls not the actual messages.
Emitters have to implement the following functions:
function addListener(listener, options)
function removeListener(listener, options)
Listeners have to implement the specific callback functions that are defined by the emitter of the message they subscribe to.
Example
//Create a message tracker
var message_tracker = new MessageTracker();
//Set the emitter for the message "my_message"
message_tracker.setEmitter("my_message", {
addListener : function(listener, options) {
add listener to the local listeners list
},
removeListener : function(listener, options) {
remove listener from the local listeners list
},
someFunctionToCallTheEvent : function() {
for(var key in this.__listeners)
this.__listeners[key].onMyMessage("what's up?");
}
});
//Add a listener for the "my_message" message
message_tracker.addListener("my_message", {
onMyMessage : function(some_var) {
// message received, do something with it...
}
});
onTriggerReleased: ```onTriggerReleased(code)```
Example Trigger Definition
"SPEED_OVER_DRIVE_LIMIT" : {
"options" : {
"conditions" : "_speed>30"
}
}
SPEED_OVER_DRIVE_LIMIT: This is the name of the trigger. Other entities that'll use this trigger will reference it by this name.
options: Contains the configuration options for this trigger.
conditions: This expression defines the condition that turns this trigger "ON". When these conditions are not met the trigger will be "OFF". When the trigger switches from "ON->OFF" it sends an "onTriggerRelease" event. When the trigger switches from "OFF->ON" it sends an "onTriggerFire" event.
onEventRaised: ```onEventRaised(code)```
onEventRepeated: ```onEventRepeated(code)```
Example Event Definition
"DRIVE" : {
"options" : {
"raise_trigger" : "SPEED_OVER_DRIVE_LIMIT",
"raise_delay" : 5000,
"reset_trigger" : "SPEED_BELOW_STOP_LIMIT",
"reset_delay" : 10000,
"repeat_interval" : 5000
}
}
DRIVE: Name of the event. This will be used to refer to this event.
options: Contains the configuration options
raise_trigger: trigger that will shitch this event on
raise_delay: raise_trigger has to stay on for this many milliseconds before this event switches on
reset_trigger: trigger that will shitch this event off
reset_delay: reset_trigger has to stay on for this many milliseconds before this event switches off
repeat_interval: An additional message will be emited every repeat_interval milliseconds if this is greater than 0
Transactions capture information and emmit an onTransactionFinalized message when they are invoked.
A transaction can be invoked automatically buy binding it to an event or it can be invoked manually by calling the invoke method of the TransactionManager.
If the transaction is set to manual but still is bound to an event than the event is used to enable or disable the transaction
Emitted when the transaction is invoked and all the data it needs to capture is captured.
onTransactionEnabled: ```onTransactionEnabled(code)```
Emitted when the bound event condition is satisfied if the transaction is manual.
onTransactionDisabled: ```onTransactionDisabled(code)```
Emitted when the bound event condition is not satisfied if the transaction is manual.
onTransactionInputRequired: ```onTransactionInputRequired(transaction_instance, list_of_required_values)```
Emitted when the transaction needs to capture additional data that can't be obtained from the ValueTracker (i.e. user inputs)
Example Transact Definition
"DRIVE_START" : {
"options" : {
"automatic" : true,
"listen_to" : {
"event" : "DRIVE",
"stage" : "RAISE"
},
"capture" : {
"system" : ["speed", "odometer"],
"user" : ["user_name", "password"]
}
}
}
DRIVE_START: Name of the transaction
options: Contains the configuration options for the transaction
automatic: Declares the transaction as eigther automatic or manual
listen_to: The event binding options
event: Name of the event to invoke this transaction (or enable it if the transaction is manual)
stage: Stage (raise, reset, repeat) of the event to invoke this transaction (or enable it if the transaction is manual. only raise and reset are relevant for manual events)
capture: Data capture configuration
system: Data to be captured from the system (a.k.a. ValueTracker)
user: Data to be captured from the user
When an activity starts
code: the activity name
end_transaction: the name of the transaction that will end this activity
activity_instance: the activity instance that has a guid and holds the data that was captured
onActivityEnded: ```onActivityEnded(code, activity_instance)```
When activity ends
code: the activity name
activity_instance: the activity instance that has a guid and holds the data that was captured
onActivityPick: ```onActivityPick(code, activity_instance, data)```
When there is multiple instances of an activity available when the end transaction is invoked. The listener of this message has to tell the system which activity is the one that needs to be ended. The listener does this by returning true when the activity_instance is the one it wants to end
code: the activity name
activity_instance: the activity instance that has a guid and holds the data that was captured
data: the data that was captured by the end transaction
Example Activity Definition
"LOADING" : {
"options" : {
"start_transact" : "LOAD_START",
"end_transact" : "LOAD_END"
}
}
LOADING: Name of this activity
options: Contains the configuration options
start_transact: The transaction that'll cause this activity to start
end_transact: The transaction that'll cause this activity to end