rescuecore
Class Command

java.lang.Object
  extended byrescuecore.Command
All Implemented Interfaces:
RescueConstants

public class Command
extends java.lang.Object
implements RescueConstants

This class encapsulates a command to the server.

See Also:
RescueConstants.AK_CONNECT, RescueConstants.AK_MOVE, RescueConstants.AK_SAY, RescueConstants.AK_TELL, RescueConstants.AK_EXTINGUISH, RescueConstants.AK_CLEAR, RescueConstants.AK_RESCUE, RescueConstants.AK_LOAD, RescueConstants.AK_UNLOAD, RescueConstants.AK_REST, RescueConstants.COMMAND_CONNECT, RescueConstants.COMMAND_ACKNOWLEDGE, RescueConstants.COMMAND_MOVE, RescueConstants.COMMAND_SAY, RescueConstants.COMMAND_TELL, RescueConstants.COMMAND_EXTINGUISH, RescueConstants.COMMAND_CLEAR, RescueConstants.COMMAND_RESCUE, RescueConstants.COMMAND_LOAD, RescueConstants.COMMAND_UNLOAD, RescueConstants.COMMAND_REST

Field Summary
 
Fields inherited from interface rescuecore.RescueConstants
AGENT_TYPE_AMBULANCE_CENTER, AGENT_TYPE_AMBULANCE_TEAM, AGENT_TYPE_ANY, AGENT_TYPE_ANY_AGENT, AGENT_TYPE_ANY_BUILDING, AGENT_TYPE_ANY_MOBILE, AGENT_TYPE_CIVILIAN, AGENT_TYPE_FIRE_BRIGADE, AGENT_TYPE_FIRE_STATION, AGENT_TYPE_POLICE_FORCE, AGENT_TYPE_POLICE_OFFICE, AK_ACKNOWLEDGE, AK_CLEAR, AK_CONNECT, AK_EXTINGUISH, AK_LOAD, AK_MOVE, AK_RESCUE, AK_REST, AK_SAY, AK_TELL, AK_UNLOAD, BYTE_SIZE, COMMAND_ACKNOWLEDGE, COMMAND_CLEAR, COMMAND_CONNECT, COMMAND_EXTINGUISH, COMMAND_LOAD, COMMAND_MOVE, COMMAND_RESCUE, COMMAND_REST, COMMAND_SAY, COMMAND_TELL, COMMAND_UNLOAD, FIERYNESS_BURNING, FIERYNESS_BURNT_OUT, FIERYNESS_HEATING, FIERYNESS_INFERNO, FIERYNESS_MODERATELY_BURNT, FIERYNESS_NOT_BURNT, FIERYNESS_SLIGHTLY_BURNT, FIERYNESS_VERY_BURNT, GK_CONNECT_ERROR, GK_CONNECT_OK, HEADER_NULL, INT_SIZE, INTERNAL_TYPE_AMBULANCE_CENTER, INTERNAL_TYPE_AMBULANCE_TEAM, INTERNAL_TYPE_ANY_BUILDING, INTERNAL_TYPE_ANY_HUMANOID, INTERNAL_TYPE_ANY_PLATOON, INTERNAL_TYPE_BUILDING, INTERNAL_TYPE_CAR, INTERNAL_TYPE_CIVILIAN, INTERNAL_TYPE_FIRE_BRIGADE, INTERNAL_TYPE_FIRE_STATION, INTERNAL_TYPE_NODE, INTERNAL_TYPE_POLICE_FORCE, INTERNAL_TYPE_POLICE_OFFICE, INTERNAL_TYPE_REFUGE, INTERNAL_TYPE_RIVER, INTERNAL_TYPE_RIVER_NODE, INTERNAL_TYPE_ROAD, INTERNAL_TYPE_WORLD, KA_CONNECT_ERROR, KA_CONNECT_OK, KA_HEAR, KA_SENSE, KG_ACKNOWLEDGE, KG_CONNECT, KG_UPDATE, KS_COMMANDS, KS_CONNECT_ERROR, KS_CONNECT_OK, KS_UPDATE, KV_CONNECT_ERROR, KV_CONNECT_OK, KV_UPDATE, MAX_CENTER_MESSAGES, MAX_EXTINGUISH_DISTANCE, MAX_EXTINGUISH_POWER, MAX_HP, MAX_PLATOON_MESSAGES, MAX_RESCUE_DISTANCE, MAX_WATER, PROPERTY_BLOCK, PROPERTY_BROKENNESS, PROPERTY_BUILDING_APEXES, PROPERTY_BUILDING_AREA_GROUND, PROPERTY_BUILDING_AREA_TOTAL, PROPERTY_BUILDING_ATTRIBUTES, PROPERTY_BUILDING_CODE, PROPERTY_BUILDING_SHAPE_ID, PROPERTY_BURIEDNESS, PROPERTY_CARS_PASS_TO_HEAD, PROPERTY_CARS_PASS_TO_TAIL, PROPERTY_DAMAGE, PROPERTY_DIRECTION, PROPERTY_EDGES, PROPERTY_ENTRANCES, PROPERTY_FIERYNESS, PROPERTY_FLOORS, PROPERTY_HEAD, PROPERTY_HP, PROPERTY_HUMANS_PASS_TO_HEAD, PROPERTY_HUMANS_PASS_TO_TAIL, PROPERTY_IGNITION, PROPERTY_LATITUDE, PROPERTY_LENGTH, PROPERTY_LINES_TO_HEAD, PROPERTY_LINES_TO_TAIL, PROPERTY_LONGITUDE, PROPERTY_MAX, PROPERTY_MEDIAN_STRIP, PROPERTY_NULL, PROPERTY_POCKET_TO_TURN_ACROSS, PROPERTY_POSITION, PROPERTY_POSITION_EXTRA, PROPERTY_POSITION_HISTORY, PROPERTY_REPAIR_COST, PROPERTY_ROAD_KIND, PROPERTY_SHORTCUT_TO_TURN, PROPERTY_SIGNAL, PROPERTY_SIGNAL_TIMING, PROPERTY_STAMINA, PROPERTY_START_TIME, PROPERTY_STRETCHED_LENGTH, PROPERTY_TAIL, PROPERTY_TYPE_BOOLEAN, PROPERTY_TYPE_INT, PROPERTY_TYPE_INT_ARRAY, PROPERTY_WATER_QUANTITY, PROPERTY_WIDTH, PROPERTY_WIDTH_FOR_WALKERS, PROPERTY_WIND_DIRECTION, PROPERTY_WIND_FORCE, PROPERTY_X, PROPERTY_Y, SAY_LENGTH, SHORT_SIZE, SK_ACKNOWLEDGE, SK_CONNECT, SK_UPDATE, TELL_LENGTH, TYPE_AMBULANCE_CENTER, TYPE_AMBULANCE_TEAM, TYPE_BUILDING, TYPE_CAR, TYPE_CIVILIAN, TYPE_FIRE_BRIGADE, TYPE_FIRE_STATION, TYPE_NODE, TYPE_NULL, TYPE_POLICE_FORCE, TYPE_POLICE_OFFICE, TYPE_REFUGE, TYPE_RIVER, TYPE_RIVER_NODE, TYPE_ROAD, TYPE_WORLD, VK_ACKNOWLEDGE, VK_CONNECT
 
Constructor Summary
Command(int type, byte[] data)
          Construct a new Command
 
Method Summary
static Command AK_ACKNOWLEDGE(int id)
          Create an AK_ACKNOWLEDGE message
static Command AK_CLEAR(int id, int target)
          Create an AK_CLEAR message
static Command AK_CONNECT(int tempID, int type, int version)
          Create an AK_CONNECT message
static Command AK_EXTINGUISH(int agentID, int targetID)
          Create an AK_EXTINGUISH message that will use the maximum extinguish power and ignore the direction,x and y parameters
static Command AK_EXTINGUISH(int agentID, int targetID, int direction, int x, int y)
          Create an AK_EXTINGUISH message that will use the maximum extinguish power
static Command AK_EXTINGUISH(int agentID, int targetID, int direction, int x, int y, int water)
          Create an AK_EXTINGUISH message
static Command AK_LOAD(int id, int target)
          Create an AK_LOAD message
static Command AK_MOVE(int id, int[] path)
          Create an AK_MOVE message
static Command AK_RESCUE(int id, int target)
          Create an AK_RESCUE message
static Command AK_SAY(int id, byte[] msg)
          Create an AK_SAY message
static Command AK_TELL(int id, byte[] msg)
          Create an AK_TELL message
static Command AK_UNLOAD(int id)
          Create an AK_UNLOAD message
 byte[] getData()
          Get the data of this command
 java.io.DataInput getDataInput()
          Get the data of this command as a DataInput
 int getKernelType()
          Get the type of this command, as the rescue simulation kernel sees it
 int getType()
          Get the type of this command
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Command

public Command(int type,
               byte[] data)
Construct a new Command

Parameters:
type - The type of this command
data - The command-dependant data to be sent to the kernal
See Also:
RescueConstants.COMMAND_CONNECT, RescueConstants.COMMAND_ACKNOWLEDGE, RescueConstants.COMMAND_MOVE, RescueConstants.COMMAND_SAY, RescueConstants.COMMAND_TELL, RescueConstants.COMMAND_EXTINGUISH, RescueConstants.COMMAND_CLEAR, RescueConstants.COMMAND_RESCUE, RescueConstants.COMMAND_LOAD, RescueConstants.COMMAND_UNLOAD, RescueConstants.COMMAND_REST
Method Detail

getType

public int getType()
Get the type of this command

Returns:
This command's type
See Also:
RescueConstants.COMMAND_CONNECT, RescueConstants.COMMAND_ACKNOWLEDGE, RescueConstants.COMMAND_MOVE, RescueConstants.COMMAND_SAY, RescueConstants.COMMAND_TELL, RescueConstants.COMMAND_EXTINGUISH, RescueConstants.COMMAND_CLEAR, RescueConstants.COMMAND_RESCUE, RescueConstants.COMMAND_LOAD, RescueConstants.COMMAND_UNLOAD, RescueConstants.COMMAND_REST

getKernelType

public int getKernelType()
Get the type of this command, as the rescue simulation kernel sees it

Returns:
This command's kernel type
See Also:
RescueConstants.AK_CONNECT, RescueConstants.AK_MOVE, RescueConstants.AK_SAY, RescueConstants.AK_TELL, RescueConstants.AK_EXTINGUISH, RescueConstants.AK_CLEAR, RescueConstants.AK_RESCUE, RescueConstants.AK_LOAD, RescueConstants.AK_UNLOAD, RescueConstants.AK_REST

getData

public byte[] getData()
Get the data of this command

Returns:
This command's data

getDataInput

public java.io.DataInput getDataInput()
Get the data of this command as a DataInput

Returns:
This command's data as a DataInput

toString

public java.lang.String toString()

AK_CONNECT

public static Command AK_CONNECT(int tempID,
                                 int type,
                                 int version)
Create an AK_CONNECT message

Parameters:
tempID - The temporary ID for the connecting agent
type - The type of agent connecting. Should be the logical OR of one or more of AGENT_TYPE_CIVILIAN, AGENT_TYPE_FIRE_BRIGADE, AGENT_TYPE_FIRE_STATION, AGENT_TYPE_AMBULANCE_TEAM, AGENT_TYPE_AMBULANCE_CENTER, AGENT_TYPE_POLICE_FORCE, AGENT_TYPE_POLICE_STATION
version - The version number to send. Should be zero, but can use 1 if we are using shared memory
Returns:
A filled-in AK_CONNECT message

AK_ACKNOWLEDGE

public static Command AK_ACKNOWLEDGE(int id)
Create an AK_ACKNOWLEDGE message

Parameters:
id - The id of the agent sending the acknowledgement
Returns:
A filled-in AK_ACKNOWLEDGE message

AK_EXTINGUISH

public static Command AK_EXTINGUISH(int agentID,
                                    int targetID)
Create an AK_EXTINGUISH message that will use the maximum extinguish power and ignore the direction,x and y parameters

Parameters:
agentID - The id of the agent sending the extinguish command
targetID - The id of the burning building
Returns:
A filled-in AK_EXTINGUISH message

AK_EXTINGUISH

public static Command AK_EXTINGUISH(int agentID,
                                    int targetID,
                                    int direction,
                                    int x,
                                    int y)
Create an AK_EXTINGUISH message that will use the maximum extinguish power

Parameters:
agentID - The id of the agent sending the extinguish command
targetID - The id of the burning building
direction - The direction from the nozzle to the building
x - The x coordinate of the nozzle
y - The y coordinate of the nozzle
Returns:
A filled-in AK_EXTINGUISH message

AK_EXTINGUISH

public static Command AK_EXTINGUISH(int agentID,
                                    int targetID,
                                    int direction,
                                    int x,
                                    int y,
                                    int water)
Create an AK_EXTINGUISH message

Parameters:
agentID - The id of the agent sending the extinguish command
targetID - The id of the burning building
direction - The direction from the nozzle to the building
x - The x coordinate of the nozzle
y - The y coordinate of the nozzle
water - The amount of water to extinguish with, in 1/1000 m^3/min
Returns:
A filled-in AK_EXTINGUISH message

AK_CLEAR

public static Command AK_CLEAR(int id,
                               int target)
Create an AK_CLEAR message

Parameters:
id - The id of the agent sending the clear command
target - The id of the road to be cleared
Returns:
A filled-in AK_CLEAR message

AK_RESCUE

public static Command AK_RESCUE(int id,
                                int target)
Create an AK_RESCUE message

Parameters:
id - The id of the agent sending the rescue command
target - The id of the civilian to be rescued
Returns:
A filled-in AK_RESCUE message

AK_LOAD

public static Command AK_LOAD(int id,
                              int target)
Create an AK_LOAD message

Parameters:
id - The id of the agent sending the load command
target - The id of the civilian to be loaded
Returns:
A filled-in AK_LOAD message

AK_UNLOAD

public static Command AK_UNLOAD(int id)
Create an AK_UNLOAD message

Parameters:
id - The id of the agent sending the unload command
Returns:
A filled-in AK_UNLOAD message

AK_MOVE

public static Command AK_MOVE(int id,
                              int[] path)
Create an AK_MOVE message

Parameters:
id - The id of the agent sending the move command
path - A list of ids (nodes, roads, rivers, rivernodes, buildings) the describe the path
Returns:
A filled-in AK_MOVE message

AK_SAY

public static Command AK_SAY(int id,
                             byte[] msg)
Create an AK_SAY message

Parameters:
id - The id of the agent saying something
msg - The message
Returns:
A filled-in AK_SAY message

AK_TELL

public static Command AK_TELL(int id,
                              byte[] msg)
Create an AK_TELL message

Parameters:
id - The id of the agent saying something
msg - The message
Returns:
A filled-in AK_TELL message