- Timestamp:
- 07/18/13 23:52:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/experiment/Simulator.java
r102 r103 4 4 import com.framsticks.communication.queries.NeedFile; 5 5 import com.framsticks.communication.queries.NeedFileAcceptor; 6 import com.framsticks.core.ListChange; 6 7 import com.framsticks.core.Path; 7 8 import com.framsticks.core.Tree; 8 9 import com.framsticks.core.ValueChange; 10 import com.framsticks.params.AccessOperations; 11 import com.framsticks.params.CastFailure; 9 12 import com.framsticks.params.EventListener; 10 13 import com.framsticks.params.FramsClass; … … 12 15 import com.framsticks.params.annotations.FramsClassAnnotation; 13 16 import com.framsticks.params.annotations.ParamAnnotation; 17 import com.framsticks.params.types.BooleanParam; 14 18 import com.framsticks.params.types.EventParam; 15 19 import com.framsticks.params.types.ProcedureParam; … … 59 63 assert experiment.isActive(); 60 64 61 log. debug("simulator ready {}", this);65 log.info("simulator ready {}", this); 62 66 63 67 runningListener = new EventListener<ValueChange>() { 64 68 @Override 65 69 public void action(ValueChange argument) { 66 log.debug("running state of {} changed: {}", this, argument); 70 try { 71 boolean running = simulatorClass.getParamEntry("running", BooleanParam.class).reassign(argument.value, null).getValue(); 72 log.debug("running state of {} changed: {}", Simulator.this, running); 73 if (!running) { 74 Simulator.this.experiment.simulators.fireChildrenChange(Simulator.this, ListChange.Action.Modify, "ready", "stoped"); 75 } 76 } catch (CastFailure e) { 77 log.error("failure: ", e); 78 } 67 79 } 68 80 }; … … 147 159 @ParamAnnotation(paramType = ProcedureParam.class) 148 160 public void start() { 161 log.debug("starting simulator {}", this); 162 call(simulatorPath, "start", new Object[] {}, Object.class, FutureHandler.doNothing(Object.class, this)); 149 163 } 150 164 151 165 @ParamAnnotation(paramType = ProcedureParam.class) 152 166 public void stop() { 167 log.debug("stoping simulator {}", this); 153 168 } 154 169 … … 156 171 public void abort() { 157 172 assert isActive(); 158 log. debug("explicitly aborting {}", this);173 log.info("explicitly aborting {}", this); 159 174 experiment.removeSimulator(this); 160 175 interruptJoinable(); … … 184 199 protected final AtomicInteger netloadIdCounter = new AtomicInteger(); 185 200 186 public void uploadNet(final File file, final Future<Object> future) {201 public <N> void netload(final N net, final Future<Object> future) { 187 202 final String netloadId = "NetLoadSaveLogic" + netloadIdCounter.getAndIncrement(); 188 203 204 final File file = AccessOperations.convert(File.class, net, getRemoteTree().getRegistry()); 189 205 log.debug("uploading file {} to {} identified by {}", file, simulatorPath, netloadId); 190 206 … … 215 231 simulatorPath.getTree().addNeedFileAcceptor(Integer.MIN_VALUE, acceptor.get()); 216 232 217 call(simulatorPath, getFramsClass(simulatorPath).getParamEntry("netload_id", ProcedureParam.class), new Object[] { netloadId }, new FutureHandler<Object>(future) {233 call(simulatorPath, getFramsClass(simulatorPath).getParamEntry("netload_id", ProcedureParam.class), new Object[] { netloadId }, Object.class, new FutureHandler<Object>(future) { 218 234 219 235 @Override … … 225 241 226 242 } 243 244 public <N> void netsave(Class<N> netJavaClass, final Future<N> futureNet) { 245 call(simulatorPath, getFramsClass(simulatorPath).getParamEntry("netsave", ProcedureParam.class), new Object[] { }, netJavaClass, new FutureHandler<N>(futureNet) { 246 247 @Override 248 protected void result(N net) { 249 log.debug("download of {} done", net); 250 futureNet.pass(net); 251 } 252 }); 253 254 } 227 255 }
Note: See TracChangeset
for help on using the changeset viewer.