Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Trigger API #35

Merged
merged 10 commits into from
Oct 6, 2016
Merged

Improved Trigger API #35

merged 10 commits into from
Oct 6, 2016

Conversation

Tetr4
Copy link
Member

@Tetr4 Tetr4 commented Oct 6, 2016

This includes the following changes:

Rename EvokeEvents to Triggers. Using the "event" terminology for triggers (expressions in the evoke slot), engine and events was very confusing, as events are not required for the evoke slot (i.e. constant time triggers). This will make it a lot easier to mentally differentiate the concepts. For more thoughts on this, see the message of commit a41c445.

There is now an ArdenEvent class for events, that stores its EVENTTIME as well as its primary time (see #8).

Improvements to the Trigger API. There are now methods to:

  • Get the event that triggered an MLM.
  • Get the delay since being triggered.
  • Check an MLM should immediately run for an event (idempotent, i.e. without scheduling triggers that are delayed after an event).

This will be useful to calculate EVENTTIME and TRIGGERTIME, and to support the event call statement in the logic slot, which only checks whether an MLM should run for an event and does not trigger it.

TODO:

  • Update wiki pages to reflect changes

Mike Klimek added 10 commits September 18, 2016 15:07
This should clear some terminology confusion, as event are not required to use the engine (e.g. when using constant time triggers).
Using the 'event' terminology for both triggers and events was very confusing, as events are not required for triggers (i.e. constant time triggers).
This will make it a lot easier to mentally differentiate the two concepts.
These three triggers have exactly the same functionality.
The 'TIME OF an_event' (the primary time) is the clinically relevant time, e.g. the time when a sample was taken.
The 'EVENTTIME' is the time when the relevant data, e.g. the samples measured values, are stored in the database.
This allows using the 'EVENTTIME', to get the matching database entry, while 'TIME OF an_event' can be used for calculation.

Therefore the primary time and eventtime are stored separately.
… callEvent()

This seperates the triggers (expressions in the evoke slot) and the events (variable).
As a result the the ArdenValue superclass is no longer required for Triggers, which removes unused primary time handling for triggers.

Previously it was possible to return FixedDateTriggers or more complex triggers.
Pros:
- It is possible to change evoke conditions for MLMs at runtime, without changing the code of the MLM itself.
Cons:
- It mixes the concept of triggers and events.
- It allows building invalid statements. E.g. for the statement '5 SECONDS AFTER TIME OF an_event', if an_event is a CyclicTrigger, then the behavior is not defined.
- This approach invites to not use evoke statements, which were designed specifically for this task.
- Evoke logic is knowledge and should therefore be part of an MLM.
- Variable events mean that the evoke engine must regularly check (poll) every MLM, if its events have changed, instead of waiting for external events (push).
runOnEvent() can then be used to find all MLMs that should run for the event, but not trigger cyclic or delayed triggers.
This will be used for event calls in the logic slot, that should not start triggers.
This should make it possible to calculate EVENTTIME and TRIGGERTIME
@Tetr4 Tetr4 merged commit eaba857 into PLRI:master Oct 6, 2016
@Tetr4 Tetr4 deleted the triggers branch October 6, 2016 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant