Skip to content

Latest commit

 

History

History
327 lines (208 loc) · 12.6 KB

File metadata and controls

327 lines (208 loc) · 12.6 KB

AAIMBehavior

The AAIMBehavior serves as the central coordinator of the system's behavior on state changes and transitions.

Parameters

  • situationFactory SituationFactory The SituationFactory instance to use for the creation of situations configured in state configurations.
  • defaultService AAIMService The AAIMService instance to use for method calls without a service name specified, may be undefined.

executeState

Executes a state configuration

Parameters

  • config AAIM.StateBehavior The state configuration object

  • Throws Error If the given state configuration can not be executed due to an error.

executeTransition

Executes a transition configuration

Parameters

Returns Promise A Promise to the result of the executed transition.

registerService

Registers a service with a given name.

Parameters

  • name String The non-empty name under which the service should be registered.

  • service AAIMService The actual service implementation to register.

  • Throws Error If name is empty or already taken or service seems not to be a valid AAIMService implementation.

_resolveParameters

Resolves the given array of parameter values and parameter references into an array of values.

Parameters

  • parameters Array The parameter array to resolve.

Returns Array The array of resolved values.

_callService

Performs a service call according to a given configuration object including resolving or fetching parameters and mapping parameters and the result.

Parameters

  • config AAIM.ServiceCall The configuration object of the service call to be performed.

  • defaultParameters Array List of parameter values to use, if no parameters are configured.

  • Throws Error If the given configuration is invalid.

Returns Promise A Promise to the result of the service call.

AAIM.ServiceCall

A structured object defining a service call to be executed.

Type: Object

Properties

  • service String? The name of the service to call or undefined to use the default service
  • name String The name of the service method to call
  • parameters (Array<AAIM.Param> | AAIM.ServiceCall)? The parameters to be handed over to the specified service method or a call to another service method to fetch those
  • parameterMapping Array<AAIM.ServiceCall>? Service methods that are called to map the given parameters one by one mathed by index. That means, the first parameter handed to the first mapping method and so on.
  • resultMapping AAIM.ServiceCall? Service method that is called to map the result of this service call.

Examples

{
 service: <name of registered serivce>,
 name: <method name>,
 parameters: [
   <parameter value> or <data context reference>, ...
 ] or <service call configuration>,
 parameterMapping: [
   <service call configuration>, ...
 ],
 resultMapping: <service call configuration>
}

AAIM.StateBehavior

A structured object configuring the behavior in a state.

Type: Object

Properties

  • situation String The name of the situation that will be handed over to the SituationFactory
  • parameters (Array<AAIM.Param> | AAIM.ServiceCall)? The parameters to be handed over to the SituationFactory or a call to a service method to fetch those
  • parameterMapping Array<AAIM.ServiceCall>? Service methods that are called to map the given parameters one by one mathed by index. That means, the first parameter handed to the first mapping method and so on.

Examples

{
 situation: <situation identifier>,
 parameters: [
   <parameter value> or <data context reference>, ...
 ] or <service call configuration>,
 parameterMapping: [
   <service call configuration>, ...
 ]
}

AAIM.Param

A list of parameter values or data context references. The notation of references to the data context uses the style of expressions in template literals.

Type: Any

Examples

'${foo.bar}' // will be resolved to the value of the "bar" property of the "foo" object in the data context.

AAIM

A structured object representing an Abstract Application Interaction Model (AAIM).

Type: Object

Properties

  • initial String The name of the inital state
  • states Array<AAIM.State> A list of all the states in this AAIM

Examples

{
 initial: <name of initial state>,
 states: [
   {
     name: <name of the state>,
     do: <behavior configuration>
     events: [
       { 
         on: <name of event>, 
         goto: <name of target state>,
         do: <behavior configuration>
       }, ...
     ]
   }, ...
 ]
}

AAIMInterpreter

The AAIMInterpreter takes an AAIM object and interpretes the state machine it represents. The execution of states and transitions triggered by events is delegated to an AAIMBehavior.

Parameters

  • behavior AAIMBehavior The AAIMBehavior implementation the execution of the application states is delegated to.

running

Returns if the interpreter is currently running.

Returns Boolean true, if the interpreter is running, false otherwise

running

Sets the interpreter to run or to pause. The interpreter can only be set to running, if an AAIM is loaded. The interpreter upholds the current state when getting paused and restarted. To restart the AAIM in its initial state call AAIMInterpreter#reset after pausing the interpreter.

Parameters

  • run Boolean true to run the interpreter, false to pause

aaim

Returns the currently loaded AAIM.

Returns Object the currently loaded AAIM or undefined

state

Returns the current state of the AAIM.

Returns Object the current state or undefined

load

Loads an AAIM.

Parameters

  • aaim AAIM The javascript object representing the AAIM.

reset

Resets a paused interpreter. After the reset the interpreter will be in the same state as directly after loading an AAIM (a.k.a. the initial state). Calls to this method will have no effect if the interpreter is currently running.

executeEvent

Executes an event on the current state of the interpreter by its name. An event name not defined for the current state will have no effect. Calls to this method will have no effect if the interpreter is currently paused.

Parameters

  • name String The name of the event so execute

AAIM.State

A structured object representing a single state of an AAIM.

Type: Object

Properties

AAIM.Event

A structured object representing a transition triggered by an event.

Type: Object

Properties

  • name String The name of the event (unique in its containing state)
  • goto String The name of the target state
  • do AAIM.ServiceCall An object containing the behavior configuration to be handed over to the AAIMBehavior

AAIMService

AAIMService serves as a base class for the implementation of configurable services that can be used in AAIM do-configurations.

_functions

Provided methods by name

execute

Calls a function by its name applying the provided parameters.

Parameters

  • method String The name of the method to call.

  • params Array The parameters to call the function with.

  • Throws Error If no function with the requested name is provided by this service.

Returns Promise A promise to the result of the function call

provides

Checks if a function is provided by this service.

Parameters

  • method String The name of the method to check.

Returns Boolean true if a method with the given name is provided by this service, false otherwise.

SituationFactory

create

Parameters

refresh

Parameters