%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% comm.pl         6/25/2002 
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
%                      Communication predicates 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

:- ['./comm/ixwrap', './comm/newutil']. 
:- ['./comm/address.db']. 


t1 :-
   exec(_, post_issue(header, issue_occ(test, body))). 

t2 :-
   exec(_, retrieve_issue(Issue)), 
   write('---- test: receive issue --------'), nl, 
   write(Issue),nl,nl. 
   

%%%%%%%%%%%% post issue %%%%%%%%%%
% work: need to replace the communication mechanisms !! 
% 
%  write_to_chars(issue_occ(X, Y), String), 
%  name(Atom, String), 

exec(_, post_issue(Header, Issue)) :- 

     Message = issue_packet(Header, Issue), 

     ix_port(edinburgh, Port), 
     ix_send(9876, Port, Message). 

%%%%%%%%%%%% receive issue %%%%%%%%%%

exec(_, retrieve_issue(issue_occ(X, Y))) :- 
    
    wfe_read_message(Sender, Message), 
    write('----- exec: receive sender and msg ------'), nl, 
    write(Sender),nl,
    write(Message),
    
    Message = issue_packet(_Header, issue_occ(X, Y)), 
    assert(dyn(Message)). 


%%%%%%%%%%%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%%
