/** This method is called from a SimProcessAnimation which wants to cooperate as a slave. */ public boolean waitOnCoop() { SimProcess slave = this.currentSimProcess(); boolean out; TimeInstant simTime = this.getModel().presentTime(); boolean init = this.cmdGen.isInitPhase(); Command c; String[] insertSlave = { slave.getName(), Integer.toString(slave.getPriority()), this.slavePriorityAttribute }; if (this.showInAnimation) { try { if (init) c = Command.getCommandInit("setWaitQueue", this.cmdGen.getAnimationTime(simTime)); else c = Command.getCommandTime("setWaitQueue", this.cmdGen.getAnimationTime(simTime)); c.addParameter("WaitQueueId", this.id); c.addParameter("InsertSlave", Parameter.cat(insertSlave)); c.setRemark(this.getGeneratedBy(WaitQueueAnimation.class.getSimpleName())); cmdGen.checkAndLog(c); cmdGen.write(c); } catch (CommandException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } out = super.waitOnCoop(); return out; }
/** * creates a Station for animation * * @param owner * @param name Name and ID of Station * @param pos position * @param showInAnimation */ public TransportStationAnimation( ModelAnimation owner, String name, Position pos, boolean showInAnimation) { super(owner, name); this.model = owner; this.name = name; this.cmdGen = owner.getCmdGen(); this.showInAnimation = showInAnimation; this.id = this.cmdGen.createInternId(name); TimeInstant simTime = this.model.presentTime(); boolean init = this.cmdGen.isInitPhase(); this.position = pos; Command c; Point p = pos.getPoint(); if (this.showInAnimation) { try { if (init) c = Command.getCommandInit("createStation", this.cmdGen.getAnimationTime(simTime)); else c = Command.getCommandTime("createStation", this.cmdGen.getAnimationTime(simTime)); c.addParameter("StationId", this.id); c.addParameter("Name", this.name); c.addParameter("Point", pos.getView() + "|" + p.x + "|" + p.y); c.setRemark(this.getGeneratedBy(TransportStationAnimation.class.getSimpleName())); cmdGen.checkAndLog(c); cmdGen.write(c); } catch (CommandException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
/** * sets begin and end time of experiment, create cmds command "createSimTimeBounds" and starts * experiment * * @param exp * @param begin * @param end * @param timezone * @param initSpeed */ public void experimentStart(Experiment exp, double initSpeed) { this.experiment = exp; if (this.experiment == null) throw new SimulationException("Experiment-Parameter is null"); if (this.experimentEnd != null) this.experiment.stop(this.experimentEnd); Command c; try { c = Command.getCommandInit("createSimTimeBounds", this.getAnimationTimeInit()); c.addParameter("Begin", Long.toString(this.getAnimationTimeInit())); if (exp.getStopTime() != null) c.addParameter("End", Long.toString(this.getAnimationTime(exp.getStopTime()))); c.addParameter("TimeZone", this.timezone.getID()); c.addParameter("Speed", Double.toString(initSpeed)); c.setRemark("erzeugt in CmdGeneration.experimentStart"); this.checkAndLog(c); this.write(c); } catch (CommandException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.initPhase = false; System.out.println("cmdGen: begin of Experiment"); this.experiment.start(this.experimentBegin); System.out.println("cmdGen: End of Experiment"); }
/** * create animation with full parameterization * * @param id internal objectId for animation. Must be unique. * @param pos middle point of animation object * @param form form of animation object * @param showInAnimation switch animation on or off */ public void createAnimation(Position pos, FormExt form, boolean showInAnimation) { this.showInAnimation = showInAnimation; // Achtung super aendert den Namen switch (masterSortOrder) { case WaitQueueAnimation.FIFO: // Neue Elemente werden in der Queue hinten angefuegt. (Hohe Rankzahl) this.masterPriorityAttribute = List.PRIO_LAST; break; case WaitQueueAnimation.LIFO: // Neue Elemente werden in der Queue vorne angefuegt. (Kleine Rankzahl) this.masterPriorityAttribute = List.PRIO_FIRST; break; default: this.masterPriorityAttribute = List.PRIO_LAST; } switch (slaveSortOrder) { case WaitQueueAnimation.FIFO: // Neue Elemente werden in der Queue hinten angefuegt. (Hohe Rankzahl) this.slavePriorityAttribute = List.PRIO_LAST; break; case WaitQueueAnimation.LIFO: // Neue Elemente werden in der Queue vorne angefuegt. (Kleine Rankzahl) this.slavePriorityAttribute = List.PRIO_FIRST; break; default: this.slavePriorityAttribute = List.PRIO_LAST; } TimeInstant simTime = this.getModel().presentTime(); boolean init = this.cmdGen.isInitPhase(); Command c; Point p = pos.getPoint(); Dimension deltaSize = form.getDeltaSize(); String[] pointA = {pos.getView(), Integer.toString(p.x), Integer.toString(p.y)}; if (deltaSize == null) deltaSize = new Dimension(0, 0); String[] deltaSizeA = {Integer.toString(deltaSize.width), Integer.toString(deltaSize.height)}; if (this.showInAnimation) { try { if (init) c = Command.getCommandInit("createWaitQueue", this.cmdGen.getAnimationTime(simTime)); else c = Command.getCommandTime("createWaitQueue", this.cmdGen.getAnimationTime(simTime)); c.addParameter("WaitQueueId", this.id); c.addParameter("Name", this.getName()); c.addParameter("Point", Parameter.cat(pointA)); c.addParameter("DefaultEntityType", form.getDefaultType()); c.addParameter("AnzVisible", Integer.toString(form.getNrVisible())); c.addParameter("Form", form.isHorizontal() ? "horizontal" : "vertikal"); c.addParameter("DeltaSize", Parameter.cat(deltaSizeA)); c.setRemark(this.getGeneratedBy(WaitQueueAnimation.class.getSimpleName())); cmdGen.checkAndLog(c); cmdGen.write(c); } catch (CommandException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
/** * Set an attribute key as velocity attribute. when a entity moves on a route, velocity attribute * describes the speed. Default attribute is velocity. * * @param attributeKey */ public void setVelocity(String attributeKey) { TimeInstant simTime = this.getModel().presentTime(); boolean init = this.cmdGen.isInitPhase(); Command c; if (this.showInAnimation) { try { if (init) c = Command.getCommandInit("setEntity", this.cmdGen.getAnimationTime(simTime)); else c = Command.getCommandTime("setEntity", this.cmdGen.getAnimationTime(simTime)); c.addParameter("EntityId", this.getName()); c.addParameter("Velocity", attributeKey); c.setRemark(this.getGeneratedBy(SimProcessAnimation.class.getSimpleName())); cmdGen.checkAndLog(c); cmdGen.write(c); } catch (CommandException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
/** * createAnimation method of static entities. These entities have a fixed location, and can not be * part of a Container. * * @param entityTypeId entitType of Entity * @param state initial state * @param pos extended position (middle point, angle, direction) * @param showInAnimation is shown in animation */ public void createAnimation( String entityTypeId, String state, PositionExt pos, boolean showInAnimation) { this.showInAnimation = showInAnimation; TimeInstant simTime = this.getModel().presentTime(); boolean init = this.cmdGen.isInitPhase(); this.state = state != null ? state : ""; this.attribute = new Hashtable<String, String>(); Command c; if (this.showInAnimation) { try { if (init) c = Command.getCommandInit("createEntity", this.cmdGen.getAnimationTime(simTime)); else c = Command.getCommandTime("createEntity", this.cmdGen.getAnimationTime(simTime)); c.addParameter("EntityId", this.getName()); c.addParameter("EntityTypeId", entityTypeId); if (state != null) c.addParameter("State", state); if (pos != null) { Point point = pos.getPoint(); String[] position = { pos.getView(), Integer.toString(point.x), Integer.toString(point.y), Double.toString(pos.getAngle()), Boolean.toString(pos.getDirection()) }; c.addParameter("Position", Parameter.cat(position)); } c.setRemark(this.getGeneratedBy(SimProcessAnimation.class.getSimpleName())); cmdGen.checkAndLog(c); cmdGen.write(c); } catch (CommandException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.setAttribute("name", this.getName()); } }