Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 3.49 KB | None | 0 0
  1. %This module will handle the exploration of additional monitoring
  2. % information that is necessary for error identification.
  3.  
  4. :-ensure_loaded('RTXutil.pl').
  5.  
  6. :-dynamic x_before/1.
  7. :-dynamic y_before/1.
  8. :-dynamic z_before/1.
  9.  
  10. :-dynamic x_is_near/1.
  11. :-dynamic z_is_near/1.
  12. :-dynamic y_is_near/1.
  13. :-dynamic up/2.
  14. :-dynamic down/2.
  15.  
  16.  
  17.  
  18. %define your new facts for monitoring operations here
  19. %pick aditional information as described in [SupInt-5-2019.pdf]
  20. monitoring:-
  21.     x_is_at(X),
  22.     \+ x_before(X),
  23.     %retracts previous facts x_before(_) and assert to the newest x_before(X)
  24.     assert_once(x_before(X)).
  25.  
  26.  
  27. %asserting betweeness for xx axis
  28. monitoring:-
  29.     \+ x_is_at(_), % xx is not on a sensor position
  30.     x_before(X),
  31.     x_moving(1), %% moving to the right
  32.     Xbetween is X +0.5,
  33.     assert_once(x_is_near(Xbetween)).
  34.  
  35. monitoring:-
  36.     \+ x_is_at(_), % xx is not on a sensor position
  37.     x_before(X),
  38.     x_moving(-1), %% moving to the left
  39.     Xbetween is X -0.5,
  40.     assert_once(x_is_near(Xbetween)).
  41.  
  42.  
  43. %asserting betweeness for zz axis
  44. monitoring:-
  45.     \+ z_is_at(_), % zz is not on a sensor position
  46.     z_before(Z),
  47.     z_moving(1), %% moving up
  48.     Zbetween is Z +0.5,
  49.     assert_once(z_is_near(Zbetween)).
  50. monitoring:-
  51.     \+ z_is_at(_), % zz is not on a sensor position
  52.     z_before(Z),
  53.     z_moving(-1), %% moving down
  54.     Zbetween is Z -0.5,
  55.     assert_once(z_is_near(Zbetween)).
  56.  
  57. monitoring:-
  58.     z_is_at(Z),
  59.     \+z_before(Z),
  60.     assert_once(z_was_at(Z)).
  61. % monitor each situation HERE, with more monitoring rules, like the previous
  62.  
  63. %asserting betweeness for yy axis
  64. monitoring:-
  65.     \+ y_is_at(_), % yy is not on a sensor position
  66.     y_before(Y),
  67.     y_moving(1), %% moving inside
  68.     Ybetween is Y +0.5,
  69.     assert_once(y_is_near(Ybetween)).
  70. monitoring:-
  71.     \+ y_is_at(_), % yy is not on a sensor position
  72.     y_before(Y),
  73.     y_moving(-1), %% moving outside
  74.     Ybetween is Y -0.5,
  75.     assert_once(y_is_near(Ybetween)).
  76.  
  77. monitoring:-
  78.     y_is_at(Y),
  79.     \+ y_before(Y),
  80.  
  81.     %retracts previous facts y_before(_) and assert to the newest y_before(Y)
  82.     assert_once(y_before(Y)).
  83.  
  84. monitoring:-  %time up events
  85.     %List of states that we need to UP events
  86.     List = [x_is_at(_), y_is_at(_), z_is_at(_) /*other states*/],
  87.     findall(__IGNORE,
  88.           (
  89.                 member(State, List),
  90.                 (      State,
  91.                     \+up(State, _),
  92.                     currTimeMili(T),
  93.                     assert( up(State, T))
  94.                     ; %OR
  95.                     \+State,
  96.                     retractall(up(state, _))
  97.                 )
  98.            ),___IGNORE).
  99.  
  100. monitoring:-  %time up events
  101.     %List of states that we need to UP events
  102.     List = [x_is_at(_), y_is_at(_), z_is_at(_) /*other states*/],
  103.     findall(__IGNORE,
  104.           (
  105.                 member(State, List),
  106.                 (      State,
  107.                     \+down(State, _),
  108.                     currTimeMili(T),
  109.                     assert( down(State, T))
  110.                     ; %OR
  111.                     \+State,
  112.                     retractall(down(state, _))
  113.                 )
  114.            ),____IGNORE).
  115.  
  116.  
  117. save_warehouse_states:-
  118.     tell('kbase/warehouse_saved.pl'),
  119.     listing(x_is_near),
  120.     listing(x_before),
  121.     listing(z_is_near),
  122.     listing(z_before),
  123.     listing(y_is_near),
  124.     listing(y_before),
  125.  
  126.     %other facts like: listing(cell)
  127.     told.
  128.  
  129. currTimeMili(Time):-
  130.     get_time(CurrTime),
  131.     Time is CurrTime*1000.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement