-
Notifications
You must be signed in to change notification settings - Fork 0
Modules
Ava's functionalities are designed in modules. A modules consist of sets of intents, sets of triggers and a matrix mapping.
To control which module will be called with respect to a specific action, Ava uses a class called the Manager. The manager triggers every event in the system, controls all modules and maintains the state of all Intents. So every instance of a module has a member pointing to the manager instance to communicate with other intents and to notify its current status. i.e.
class Environment(Intent) :
def __init__(self, manager, generator) :
super(Environment, self).__init__(manager)
self.manager = manager
self.generator = generator
self.manager.listen(self)
def call(self, state, stemma) :
getattr(self, stemma.stem(1))(state, stemma)
def start(self, state, stemma) :
self.trigger(Intent.stemmas().start)
super(Environment, self).start()
def finish(self, state, stemma) :
self.trigger(Intent.stemmas().finish)
super(Environment, self).finish()
def pause(self, state, stemma) :
self.trigger(Intent.stemmas().pause)
super(Environment, self).pause()
def resume(self, state, stemma) :
self.trigger(Intent.stemmas().resume)
super(Environment, self)
def trigger(self, stemma) :
self.manager.trigger(stemma)
log = Logger(Environment).log
This is the skeleton of the environment module (Environment module handles all non behavior based actions e.g. unknown respondent, bad connectivity etc).
In this example, call
is the method called every time an event that has to do with this module is trigger, state
is the current state of the system (including conversation, respondents etc). stemma
is the string indicating the event triggered, see also stemma.
The example like every modules in the system must inherit from Intent which maintains the state of the module. Due to sequential execution of application programs, if an intent requires a user reaction, it must have a persistent state to continue from whence the action was required. The super class helps with this.
note: after meeting a desired requirement, all intents and modules are unpacked and states will be lost
The manager not only maintains the state of all intents, the manager coordinates every event in the system: stopping the right intent with an interrupt
message for pause
to take a higher priority intent a start
and finish
then to resume
the paused module.