events.pl 1.2 KB
Newer Older
Thierry Martinez's avatar
Thierry Martinez committed
1 2 3
:- module(
  events,
  [
Thierry Martinez's avatar
Thierry Martinez committed
4
    % Public API
Thierry Martinez's avatar
Thierry Martinez committed
5
    add_event/2,
Thierry Martinez's avatar
Thierry Martinez committed
6 7
    list_events/0,
    list_model_events/0
Thierry Martinez's avatar
Thierry Martinez committed
8 9 10 11
  ]
).


Thierry Martinez's avatar
Thierry Martinez committed
12 13 14
:- devdoc('\\section{Commands}').


Thierry Martinez's avatar
Thierry Martinez committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
add_event(Condition, ParameterValues) :-
  biocham_command(*),
  type(Condition, condition),
  type(ParameterValues, '*'(parameter = simple_kinetics)),
  doc('
    sets up an event that will be fired each time the condition given as first
    argument goes from false to true.
    This command is effective in numerical simulations only.
    Upon firing, the parameters receive new values
    computed from the expression.
    The initial values of the parameters are restored after the simulation.'),
  \+ (
    member(ParameterValue, ParameterValues),
    \+ (
      add_item(event, event(Condition, ParameterValue))
    )
  ).


list_events :-
  biocham_command,
  doc('lists all the declared events.'),
  list_items([kind: event]).
Thierry Martinez's avatar
Thierry Martinez committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53


:- devdoc('\\section{Private predicates}').


list_model_events :-
  devdoc('
    lists all the events in a loadable syntax
    (auxiliary predicate of list_model).
  '),
  \+ (
    item([no_inheritance, kind: event, item: event(Condition, ParameterValue)]),
    \+ (
      format('add_event(~w, ~w).\n', [Condition, ParameterValue])
    )
  ).