1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2%
    3% FILE: Env/dev_managers.pl
    4%
    5%  AUTHOR : Sebastian Sardina (2004)
    6%  EMAIL  : ssardina@cs.toronto.edu
    7%  WWW    : www.cs.toronto.edu/~ssardina www.cs.toronto.edu/cogrobo
    8%  TYPE   : system independent code
    9%  TESTED : SWI Prolog 5.0.10 http://www.swi-prolog.org
   10%           ECLIPSE 5.4 http://www.icparc.ic.ac.uk/eclipse/
   11%
   12% Definition of defaults device managers for different environments
   13%
   14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   15%
   16%                             July 9, 2002
   17%
   18% This software was developed by the Cognitive Robotics Group under the
   19% direction of Hector Levesque and Ray Reiter.
   20%
   21%        Do not distribute without permission.
   22%        Include this notice in any copy made.
   23%
   24%
   25%         Copyright (c) 2000 by The University of Toronto,
   26%                        Toronto, Ontario, Canada.
   27%
   28%                          All Rights Reserved
   29%
   30% Permission to use, copy, and modify, this software and its
   31% documentation for non-commercial research purpose is hereby granted
   32% without fee, provided that the above copyright notice appears in all
   33% copies and that both the copyright notice and this permission notice
   34% appear in supporting documentation, and that the name of The University
   35% of Toronto not be used in advertising or publicity pertaining to
   36% distribution of the software without specific, written prior
   37% permission.  The University of Toronto makes no representations about
   38% the suitability of this software for any purpose.  It is provided "as
   39% is" without express or implied warranty.
   40% THE UNIVERSITY OF TORONTO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
   41% SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
   42% FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TORONTO BE LIABLE FOR ANY
   43% SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
   44% RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
   45% CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
   46% CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   47% 
   48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   49%
   50%
   51% The following definition are required:
   52%
   53% -- executable_path(A, P) : P is the executable path for software A
   54%
   55% The following definition of constants are provided:
   56%
   57% -- device_manager(+S, +P, -C, [+Host, +Port]) : 
   58%         Retract comand C for environment P on plataform P with 
   59%         manager listeling at address Host/Port
   60%
   61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   69build_call(Platform,ManagerHost,ManagerPort,File,Options,xterm,Command) :-
   70	build_call2(Platform,ManagerHost,ManagerPort,File,Options,Command2),
   71    executable_path(xterm, Exterm),
   72	concat_atom([Exterm, ' -e ', Command2], Command).
   73
   74build_call(Platform,ManagerHost,ManagerPort,File,Options,silent,Command) :-
   75	build_call2(Platform,ManagerHost,ManagerPort,File,Options,Command2),
   76%	concat_atom([Command2, ' 1>/dev/null 2>/dev/null'], Command).
   77	concat_atom([Command2, ' 1>debug.txt 2>debug.txt'], Command).
   78
   79
   80build_call2(eclipse,ManagerHost,ManagerPort,File,Options,Command) :-
   81        executable_path(eclipse, Eeclipse),
   82        concat_atom([Eeclipse, ' -g 10M host=', ManagerHost, 
   83                     ' port=', ManagerPort, 
   84                     ' -b ', File, ' -e ', ' start ', Options], Command).
   85build_call2(swi,ManagerHost,ManagerPort,File,Options,Command) :-
   86        executable_path(swi, Eswi),
   87        concat_atom([Eswi, ' -t ', ' start', 
   88                    ' -f ', File,
   89		 		    ' host=', ManagerHost, 
   90		 		    ' port=', ManagerPort,' ', Options], Command).
   91
   92
   93
   94
   95
   96%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   97%
   98% SIMULATOR DEVICE 
   99%
  100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  101device_manager(simulator, Platform, Command, [Host, Port]):- 
  102        main_dir(Dir),
  103        concat_atom([Dir,'Env/env_sim.pl'], File),
  104		build_call(Platform,Host,Port,File,'',xterm,Command).
  105		     
  106
  107
  108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  109%
  110% RCX LEGO MINDSTORM DEVICE 
  111%
  112%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  113device_manager(rcx, eclipse, Command, [Host, Port]):- 
  114        main_dir(Dir),
  115        concat_atom([Dir,'Env/env_rcx.pl'], File),
  116		build_call(eclipse,Host,Port,File,'',xterm,Command).
  117      
  118
  119%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  120%
  121% INTERNET/SYSTEM DEVICE 
  122%
  123%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  124device_manager(internet, Platform, Command, [Host, Port]):- 
  125        main_dir(Dir),
  126        concat_atom([Dir,'Env/env_int.pl'], File),
  127		build_call(Platform,Host,Port,File,'',xterm,Command).
  128
  129
  130%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  131%
  132% ER1 DEVICE: to control the Evolution ER1 robot
  133%
  134%  ER1 CONFIGURATION FOR UOFT (DONE BY SIMON WEBER-BROWN)
  135%
  136%	1. Configure the robot laptop to lease an IP address via DHCP.
  137%
  138%	Its IP settings should be as follows:
  139%
  140%		IP: 	 172.31.0.150
  141%		SUBMASK: 255.255.0.0
  142%		GATEWAY: 172.31.0.254
  143%
  144%	2. SSH to er1.cs.toronto.edu as user <er1> (with the corresponding password)
  145%
  146%	3. To talk to the robot from outside, connect to er1.cs.toronto.edu on port 9000
  147%   
  148%	You should now be "talking" to the robot
  149%
  150% ER1 account at CS: er1 / come1er1
  151% ER1 account at evolution web page: er1uoft@cs.toronto.edu / come1er1
  152%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  153device_manager(er1, swi, Command, [Host, Port]):- 
  154        main_dir(Dir),
  155        er1_location(IPER1, PORTER1),
  156        concat_atom([Dir,'Env/env_er1.pl'], File),
  157			% Use this if not debugging 
  158%        concat_atom([' iper1=', IPER1, ' porter1=', PORTER1], Options),
  159			% Use this instead if you want debugging mode 
  160        concat_atom(['debug=4 ',' iper1=', IPER1, ' porter1=', PORTER1], Options),
  161		build_call(swi,Host,Port,File,Options,xterm,Command).
  162
  163% This is the address of the ER1 server
  164er1_location('er1.cs.toronto.edu', 9000).
  165
  166
  167
  168%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  169%
  170% WUMPUS WORLD SIMULATOR DEVICE 
  171%
  172%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  173%wumpus_location('127.0.0.1', 9002).
  174wumpus_location('10.10.10.111', 9002).
  175
  176% With terminal
  177device_manager(virtual_wumpus, swi, Command, [Host, Port]):- 
  178        main_dir(Dir),
  179        wumpus_location(IPW, PORTW),
  180        wumpus_config(TIDRun,Size,PPits,NoGolds,TIDScenario),
  181        term_to_atom(TIDRun, IDRun),
  182        term_to_atom(TIDScenario, IDScenario),
  183        concat_atom([Dir,'Env/env_wumpus.pl'], File),
  184        concat_atom([' debug=1',
  185                     ' ipwumpus=', IPW, ' portwumpus=', PORTW, 
  186                     ' ppits=', PPits, ' nogolds=', NoGolds, ' size=', Size, 
  187                     ' idrun=\'', IDRun, '\' idscenario=\'', IDScenario,'\''
  188                     ], Options),
  189		build_call(swi,Host,Port,File,Options,xterm,Command).
  190
  191% Without terminal
  192device_manager(virtual_wumpus_silent, swi, Command, [Host, Port]):- 
  193        main_dir(Dir),
  194        wumpus_location(IPW, PORTW),
  195        wumpus_config(TIDRun,Size,PPits,NoGolds,TIDScenario),
  196        term_to_atom(TIDRun, IDRun),
  197        term_to_atom(TIDScenario, IDScenario),
  198        concat_atom([Dir,'Env/env_wumpus.pl'], File),
  199        concat_atom([' debug=1',
  200                     ' ipwumpus=', IPW, ' portwumpus=', PORTW, 
  201                     ' ppits=', PPits, ' nogolds=', NoGolds, ' size=', Size, 
  202                     ' idrun=\'', IDRun, '\' idscenario=\'', IDScenario,'\''
  203                     ], Options),
  204		build_call(swi,Host,Port,File,Options,silent,Command).
  205
  206
  207% Without terminal
  208device_manager(virtual_wumpus_vworld, swi, Command, [Host, Port]):- 
  209        main_dir(Dir),
  210        wumpus_location(IPW, PORTW),
  211        wumpus_config(TIDRun,Size,PPits,NoGolds,TIDScenario),
  212        term_to_atom(TIDRun, IDRun),
  213        term_to_atom(TIDScenario, IDScenario),
  214        concat_atom([Dir,'Env/env_wumpus.pl'], File),
  215        concat_atom([' debug=1',
  216                     ' ipwumpus=', IPW, ' portwumpus=', PORTW, 
  217                     ' ppits=', PPits, ' nogolds=', NoGolds, ' size=', Size, 
  218                     ' idrun=\'', IDRun, '\' idscenario=\'', IDScenario,'\''
  219                     ], Options),
  220		build_call(swi,Host,Port,File,Options,xterm,Command).
  221
  222
  223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  224% CLIMA GAME SIMULATOR DEVICE: to communicate with the game simulator
  225%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  226device_manager(clima07(LOptions), swi, (Command, LArgs), [HostEM, PortEM]):- 
  227        main_dir(Dir),
  228        clima_location(IPCLIMA, PORTCLIMA),
  229        clima_agentID(TAgentName, TAgentPass),
  230        term_to_atom(TAgentName, AgentName),
  231        term_to_atom(TAgentPass, AgentPass),
  232        concat_atom([Dir,'Env/env_clima.pl'], File),
  233	(member(debug(Debug), LOptions) -> true ; Debug=3),
  234		% Build the set of arguments
  235	concat_atom(['host=', HostEM], ArgHost),
  236	concat_atom(['port=', PortEM], ArgPort),
  237	concat_atom(['debug=', Debug], ArgDebug),
  238	concat_atom(['ipsim=', IPCLIMA], ArgIPCLIMA),
  239	concat_atom(['portsim=', PORTCLIMA], ArgPortCLIMA),
  240	concat_atom(['agentLogin=', AgentName], ArgAgentLog),
  241	concat_atom(['agentPass=', AgentPass], ArgAgentPass),
  242       	LPrologArgs=['-t','start','-f',File,ArgHost,ArgPort,ArgDebug,ArgIPCLIMA,ArgPortCLIMA,
  243				ArgAgentLog,ArgAgentPass],
  244		% Now build the final pair of (Command, LArgs)
  245    executable_path(swi, Eswi),
  246    executable_path(xterm, Exterm),
  247	(member(quiet, LOptions) ->
  248        	append(LPrologArgs,[' >/dev/null 2>/dev/null'],LPrologArgs2),
  249		join_atom([Eswi|LPrologArgs2], ' ',Arg),
  250		LArgs=['-c', Arg],
  251		Command=sh
  252	;
  253        	join_atom([Eswi|LPrologArgs], ' ',Arg),
  254		LArgs=['-e', Arg],
  255		Command=Exterm
  256	).
  257
  258
  259% This is the address of the CLIMA server
  260% (this would be defined in the main_xxx.pl application file)
  261%clima_location('localhost', 12300).
  262%clima_agentID(china1, 1).
  263
  264
  265
  266
  267%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  268% MESSENGER SERVER
  269%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  270device_manager(messenger(LOptions), swi, (Command, LArgs), [HostEM, PortEM]):- 
  271        main_dir(Dir),
  272        mess_location(IPMESS, PORTMESS),
  273        agentID(TAgentName),
  274        term_to_atom(TAgentName, AgentName),
  275        concat_atom([Dir,'Env/env_mess.pl'], File),
  276	(member(debug(Debug), LOptions) -> true ; Debug=3),
  277		% Build the set of arguments
  278	concat_atom(['host=', HostEM], ArgHost),
  279	concat_atom(['port=', PortEM], ArgPort),
  280	concat_atom(['debug=', Debug], ArgDebug),
  281	concat_atom(['ipmess=', IPMESS], ArgIPMESS),
  282	concat_atom(['portmess=', PORTMESS], ArgPortMESS),
  283	concat_atom(['agentLogin=', AgentName], ArgAgent),
  284       	LPrologArgs=['-t','start','-f',File,ArgHost,ArgPort,ArgDebug,ArgIPMESS,ArgPortMESS,ArgAgent],
  285		% Now build the final pair of (Command, LArgs)
  286    executable_path(swi, Eswi),
  287    executable_path(xterm, Exterm),
  288	(member(quiet, LOptions) ->
  289        	append(LPrologArgs,[' >/dev/null 2>/dev/null'],LPrologArgs2),
  290		join_atom([Eswi|LPrologArgs2], ' ',Arg),
  291		LArgs=['-c', Arg],
  292		Command=sh
  293	;
  294        	join_atom([Eswi|LPrologArgs], ' ',Arg),
  295		LArgs=['-e',Arg],
  296		Command=Exterm
  297	).
  298
  299
  300% This is the address of the MESSENGER server
  301% (this would be defined in the main_xxx.pl application file)
  302%mess_location('localhost', 3900).
  303%agentID(china1).
  304
  305
  306
  307
  308
  309
  310
  311
  312%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  313% JAVA SWING SIMULATOR DEVICE: to communicate with a java swing
  314% Stefano from Rome 2008
  315%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  316% requires swing_location/2.
  317device_manager(javaswing, swi, Command, [Host, Port]):- 
  318    main_dir(Dir),
  319	swing_location(IPSW, PORTSW),
  320    concat_atom([Dir,'Env/env_java_swing.pl'], File),
  321    concat_atom([' ipswing=', IPSW, ' portswing=', PORTSW], Options),
  322 	build_call(swi, Host, Port, File, Options, xterm, Command).
  323
  324
  325
  326
  327%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  328% JAVA MULTISWING SIMULATOR DEVICE: to communicate with a java swing
  329% Stefano from Rome 2008
  330%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  331% requires swing_location/2.
  332device_manager(javaswings(Id), swi, Command, [Host, Port]):- 
  333    main_dir(Dir),
  334	swing_location(IPSW, PORTSW, Id),
  335    concat_atom([Dir,'Env/env_java_swing_id.pl'], File),
  336    concat_atom([' ipswing=', IPSW, ' portswing=', PORTSW,' id=',Id], Options),
  337 	build_call(swi, Host, Port, File, Options, xterm, Command).
  338
  339
  340
  341
  342
  343
  344
  345%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  346% EOF: Env/dev_managers.pl
  347%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%