next up previous
Next: Motions Up: Simulator Back-end Previous: Simulator Back-end


DeviceSimulation

The DeviceSimulation object resolves device motions into joint motions. Recall that the RcclSimulationServer's open() method is called to initialize a device. This method creates a new instance of the appropriate DeviceSimulation subclass. Here is the definition of a typical subclass:


package acme.simulator;

import acme.Kinematics;
import acme.DeviceId;
import acme.kinematics.StageKinematics;

public class TestStationSimulation extends DeviceSimulation {

  public TestStationSimulation () {
    super ("stage");
  }

  public int
  getDeviceId()
  {
    return DeviceId.TEST_STATION;
  }

  protected Kinematics
  getKinematics()
  {
    if (kinematics == null) {
      return new StageKinematics(deviceName);
    }
    return kinematics;
  }
}

Since devices may move simultaneously, each DeviceSimulation runs in its own thread. This thread takes motion blocks from a queue and processes them using a Kinematics subclass. When the queue is empty, the thread blocks until RcclSimulationServer enqueues another motion block. The thread exits when the user program uninstalls the device.

After it creates a DeviceSimulation instance, the simulation server registers the viewer as a listener for that instance. Since the DeviceSimulation keeps a vector of listeners, it is possible, in principle, to have any number of viewers displaying a single simulation.

Once the kinematics of a motion have been resolved, it is time-stamped and marked as RUNNING. The DeviceSimulation instance then notifies its listeners, handing them the processed motion. When the viewer is notified, it updates the scene. The viewer signals motion completion via the DeviceSimulation doneMotion() callback, which puts another time-stamp on the motion, and marks it COMPLETED.


next up previous
Next: Motions Up: Simulator Back-end Previous: Simulator Back-end
Tim Wellhausen
2000-01-20