% ------------------------------------------------------------------------------------------------------
% Demonstrates the ECA runtime with negation (Negation as Failure)

% Uses the \ContractLog\ecaruntime.prova implementation of the ContractLog framework
% ------------------------------------------------------------------------------------------------------

:-eval(consult('ContractLog/math.prova')).
:-eval(consult('ContractLog/list.prova')).
:-eval(consult('ContractLog/list_math.prova')).
:-eval(consult('ContractLog/datetime.prova')).
:-eval(consult('ContractLog/timeinterval.prova')).
:-eval(consult('ContractLog/utils.prova')).
:-eval(consult('ContractLog/update.prova')).
:-eval(consult('ContractLog/ecaruntime.prova')).

%-----------------------------------------------------------------------
% Define ECA rules
%-----------------------------------------------------------------------




% +++++++++++++++  ECA alarm clock: Start alarm every minute if not available ++++++++++++++
% 
%ECA 1

eca(every10Sec(),not(available()),_,startAlarm(),_,ok()). % ECA rule definition

%TIME
every10Sec() :-
	sysTime(DT),
	interval(timespan(0,0,0,10), DT).

%EVENT empty
%availabe().

%CONDITION emtpy

%ACTION
startAlarm() :-	
	println(["not available !!!!"]).
	
	
ok():-
	println(["available"]).

%-----------------------------------------------------------------------
% Start the ECA runtime
%-----------------------------------------------------------------------

start():-
	%hideTimer(), % hide the timer
	startECARuntime(".\examples\function_tests\eca_runtime\ecaNot.prova").
	
:- solve(start()).
	