1 package cz.cuni.amis.pogamut.udk.utils;
2
3 import java.util.List;
4
5 import cz.cuni.amis.pogamut.base.agent.IAgentId;
6 import cz.cuni.amis.pogamut.base.agent.impl.AgentId;
7 import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
8 import cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner;
9 import cz.cuni.amis.pogamut.base.communication.connection.impl.socket.SocketConnectionAddress;
10 import cz.cuni.amis.pogamut.base.factory.IAgentFactory;
11 import cz.cuni.amis.pogamut.base.utils.Pogamut;
12 import cz.cuni.amis.pogamut.base.utils.PogamutPlatform;
13 import cz.cuni.amis.pogamut.base.utils.PogamutProperty;
14 import cz.cuni.amis.pogamut.udk.agent.params.UDKAgentParameters;
15 import cz.cuni.amis.pogamut.udk.observer.IUDKObserver;
16 import cz.cuni.amis.utils.exception.PogamutException;
17
18
19
20
21
22
23
24
25
26
27
28
29 public class UDKObserverRunner<OBSERVER extends IUDKObserver, PARAMS extends UDKAgentParameters> extends AgentRunner<OBSERVER, PARAMS> {
30
31
32
33
34 protected String host;
35
36
37
38
39 protected int port;
40
41
42
43
44 protected String name;
45
46
47
48
49
50
51
52
53
54 public UDKObserverRunner(IAgentFactory<OBSERVER, PARAMS> factory, String name, String host, int port) {
55 super(factory);
56 this.name = name;
57 this.port = port;
58 this.host = host;
59 }
60
61
62
63
64
65
66
67 public UDKObserverRunner(IAgentFactory<OBSERVER, PARAMS> factory, String name) {
68 this(
69 factory,
70 name,
71 Pogamut.getPlatform().getProperty(PogamutUDKProperty.POGAMUT_UDK_OBSERVER_HOST.getKey()),
72 Pogamut.getPlatform().getIntProperty(PogamutUDKProperty.POGAMUT_UDK_OBSERVER_PORT.getKey())
73 );
74 }
75
76
77
78
79
80
81
82 public UDKObserverRunner(IAgentFactory<OBSERVER, PARAMS> factory) {
83 this(factory, "UDKObserver");
84 }
85
86 @Override
87 public OBSERVER startAgent() throws PogamutException {
88 return super.startAgent();
89 }
90
91 @Override
92 public List<OBSERVER> startAgents(int count) throws PogamutException {
93 return super.startAgents(count);
94 }
95
96 @Override
97 public List<OBSERVER> startAgents(PARAMS... agentParameters) throws PogamutException {
98 return super.startAgents(agentParameters);
99 };
100
101
102
103
104
105 @Override
106 protected IAgentParameters newDefaultAgentParameters() {
107 return new UDKAgentParameters().setAgentId(new AgentId(name)).setWorldAddress(new SocketConnectionAddress(host, port));
108 }
109
110 }