| 1 | package de.uka.ipd.sdq.scheduler.resources.active; |
| 2 | |
| 3 | import de.uka.ipd.sdq.scheduler.IRunningProcess; |
| 4 | import de.uka.ipd.sdq.scheduler.ISchedulableProcess; |
| 5 | import de.uka.ipd.sdq.scheduler.LoggingWrapper; |
| 6 | import de.uka.ipd.sdq.scheduler.SchedulerModel; |
| 7 | import de.uka.ipd.sdq.scheduler.events.DelayEvent; |
| 8 | |
| 9 | public class SimDelayResource extends AbstractActiveResource { |
| 10 | |
| 11 | int num_running; |
| 12 | |
| 13 | public SimDelayResource(SchedulerModel model, String name, String id) { |
| 14 | super(model, -1, name, id); |
| 15 | } |
| 16 | |
| 17 | |
| 18 | public void start() { |
| 19 | this.num_running = 0; |
| 20 | } |
| 21 | |
| 22 | @Override |
| 23 | protected void dequeue(ISchedulableProcess process) { |
| 24 | this.num_running--; |
| 25 | fireStateChange(num_running, 0); |
| 26 | fireDemandCompleted(process); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | protected void doProcessing(ISchedulableProcess process, int resourceServiceId, double demand) { |
| 31 | LoggingWrapper.log("Delay: " + process + " demands " + demand); |
| 32 | new DelayEvent(getModel()).schedule(process, demand); |
| 33 | process.passivate(); |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public double getRemainingDemand(ISchedulableProcess process) { |
| 38 | throw new UnsupportedOperationException("getRemainingDemand() not yet supported!"); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public void updateDemand(ISchedulableProcess process, double demand) { |
| 43 | throw new UnsupportedOperationException("updateDemand() not yet supported!"); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | protected void enqueue(ISchedulableProcess process) { |
| 48 | this.num_running++; |
| 49 | fireStateChange(num_running, 0); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | public void stop() { |
| 54 | |
| 55 | } |
| 56 | |
| 57 | public void registerProcess(IRunningProcess runningProcess) { |
| 58 | |
| 59 | } |
| 60 | |
| 61 | |
| 62 | public int getQueueLengthFor(SimResourceInstance simResourceInstance) { |
| 63 | return this.num_running; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | } |