-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker.pl
35 lines (29 loc) · 1.84 KB
/
checker.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
wellDefinedPropertyInstances :-
findall((ZId, PId, PropertyType, X, Type), illDefinedPropertyInstance(ZId, PId, PropertyType, X, Type), L),
((L==[], ansi_format([bold,fg(blue)],'### Properties instances are all well defined. ###################',[]), nl, true) ;
(dif(L,[]), ansi_format([bold,fg(red)],'### Some properties instances are not well defined. ###################################################',[]), nl, xwrite(L), false)
).
illDefinedPropertyInstance(ZId, PId, PropertyType, X, Type):-
propertyInstance(ZId, PId, PropertyType, ListOfActuators, ListOfSensors),
( \+ propertyType(PropertyType)
;
((member(X, ListOfActuators), ((actuator(X,Type), dif(Type,PropertyType)); \+ actuator(X,Type)))
;
(member(X, ListOfSensors), ((sensor(X,Type), dif(Type,PropertyType)); \+ sensor(X,Type))))
).
xwrite([]) :- ansi_format([bold,fg(red)],'#######################################################################################################',[]), nl.
xwrite([(ZId, PId, PropertyType, X, Type)|L]) :-
\+ var(Type),
write('- '),ansi_format([bold], X, []), write(' in '), ansi_format([bold], '~w:~w', [ZId,PId]), ansi_format([fg(red)], ' has wrong type ', []),ansi_format([bold,fg(red)], Type, []),
write(' [expected type: '),ansi_format([bold,fg(blue)], PropertyType, []),write(']'),nl,nl,
xwrite(L).
xwrite([(ZId, PId, PropertyType, X, Type)|L]) :-
var(Type),
(
(propertyType(PropertyType), write('- '), ansi_format([bold], X, []), write(' in '), ansi_format([bold], '~w:~w', [ZId,PId]), ansi_format([fg(red)], ' does not exist!', []) )
;
( write('- PropertyType '), ansi_format([bold], PropertyType, []), write(' in '), ansi_format([bold], '~w:~w', [ZId,PId]), ansi_format([fg(red)], ' does not exist!', []) )
),
nl,nl,
xwrite(L).
:- wellDefinedPropertyInstances.