% ------------------------------------------------------------------------------------------------------
% Demonstrates the ECA runtime with a simple alarm clock
% Illustrate the use of the post condition with a very simple test
% 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/ecaruntime.prova')).
:-eval(consult('ContractLog/testcase.prova')).
:-eval(consult('ContractLog/utils.prova')).
:-eval(consult('ContractLog/update.prova')).
:-eval(consult('ContractLog/integrity.prova')).

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




% 
%ECA 1

eca(every10Sec(),_,_,updateKnowledge(),testTC(),_). % ECA rule definition

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

%EVENT empty

%CONDITION emtpy

%ACTION
updateKnowledge() :-	
	update("id1","f(a).f(b).f(c)."). % add knowldege
	
testTC() :- f(a), println(["Test succeeded"]). % very simple test
	
	


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

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