Class RemoteSimulatorClient

Class RemoteSimulatorClient

java.lang.Object
   |
   +----Simulator
           |
           +----RemoteSimulatorClient

class RemoteSimulatorClient
extends Simulator
The class RemoteSimulatorClient is a client class that controls a simulator server remotely. The class is a wrapper for the communication with the server.
See Also:
RemoteSimulatorServer, TestSimulatorServer, ClipsSimulatorServer
Version:
1.0
Author:
Henrik Eriksson

nc
The network client object
port
The socket number
server
The internet address of the server host
si
The input TCP/IP stream (back stream)
so
The output TCP/IP stream

RemoteSimulatorClient(NuclearPlant, String, int)
Construct a RemoteSimulatorClient and initialize it.

blow(Component)
Blow up a device.
close()
Close the simulator server
decodeComponent(String)
Translate a string to a component object.
readValue()
Read a value from the simulator server
stop()
Stop the remote simulation
timeStep(int)
Calculates the next state of the simulation.

nc
  protected NetworkClient nc
The network client object
so
  protected DataOutputStream so
The output TCP/IP stream
si
  protected DataInputStream si
The input TCP/IP stream (back stream)
server
  protected String server
The internet address of the server host
port
  protected int port
The socket number

RemoteSimulatorClient
  public RemoteSimulatorClient(NuclearPlant p,
                               String s,
                               int prt)
Construct a RemoteSimulatorClient and initialize it.
Parameters:
p - the NuclearPlant applet
s - the server internet address (or localhost)
prt - the socket number (port number) to connect to

decodeComponent
  protected Component decodeComponent(String obj)
Translate a string to a component object.
Parameters:
obj - the string representing the component object
Returns:
The component object

readValue

  protected synchronized void readValue()
Read a value from the simulator server

close

  public synchronized void close()
Close the simulator server

stop

  public void stop()
Stop the remote simulation
Overrides:
stop in class Simulator

timeStep

  public synchronized void timeStep(int n)
Calculates the next state of the simulation. This calculation is perfomed by the simulator server. The results are then returned and received by the method readValue().
Parameters:
n - The number of steps to calculate before returning
Overrides:
timeStep in class Simulator

blow

  public void blow(Component device)
Blow up a device. This method sends a "blow" message to the simulator server.
Parameters:
device - The device to blow (e.g., a turbine object)
Overrides:
blow in class Simulator