org.robokind.api.motion.messaging
Class RemoteRobotHost

java.lang.Object
  extended by org.robokind.api.motion.messaging.RemoteRobotHost

public class RemoteRobotHost
extends Object

Hosts a Robot to be controlled by a RemoteRobotClient through some Messaging channel. Receives RobotRequest Messages and replies with RobotResponse Messages.

Author:
Matthew Stevenson

Constructor Summary
  RemoteRobotHost(Robot robot, String sourceId, String destinationId, org.robokind.api.messaging.MessageSender<RobotResponse> sender, org.robokind.api.messaging.MessageAsyncReceiver<RobotRequest> receiver, RobotResponseFactory factory, org.robokind.api.messaging.MessageAsyncReceiver<MotionFrameEvent> motionFrameReceiver, org.jflux.api.core.Listener<MotionFrameEvent> moveHandler)
          Creates a new RemoteRobotHost to host the given Robot.
protected RemoteRobotHost(String sourceId, String destinationId)
          Creates an empty RemoteRobotHost.
 
Method Summary
 String getDestinationId()
          Returns a String identifying a client.
protected  Joint getRequestedJoint(RobotRequest req)
          Retrieves the Joint specified in the RobotRequest.
 org.robokind.api.messaging.MessageSender<RobotResponse> getResponseSender()
           
 Robot getRobot()
           
 Robot.Id getRobotId()
          Returns the hosted Robot's id.
 String getSourceId()
          Returns a String identifying this host.
protected  void handleConnectionStatusRequest(RobotRequest req)
          Creates and sends a RobotStatusResponse with the Robot's connection status
protected  void handleConnectRequest(RobotRequest req)
          Calls connect() on the hosted Robot.
protected  void handleCurrentPositionRequest(RobotRequest req)
          Sends a RobotPositionResponse with the Robot's current positions.
protected  void handleDefaultPositionRequest(RobotRequest req)
          Sends a RobotPositionResponse with the Robot's default positions.
protected  void handleDefinitionRequest(RobotRequest req)
          Creates and sends a RobotDefinitionResponse.
protected  void handleDisableRequest(RobotRequest req)
          Calls setEnabled(false) on the hosted Robot.
protected  void handleDisableRequestForJoint(RobotRequest req)
          Calls setEnabled(true) on the hosted Robot's Joint.
protected  void handleDisconnectRequest(RobotRequest req)
          Calls disconnect() on the hosted Robot.
protected  void handleEnabledStatusRequest(RobotRequest req)
          Creates and sends a RobotStatusResponse with the Robot's enabled status
protected  void handleEnabledStatusRequestForJoint(RobotRequest req)
          Creates and sends a RobotStatusResponse with the Joint's connection status
protected  void handleEnableRequest(RobotRequest req)
          Calls setEnabled(true) on the hosted Robot.
protected  void handleEnableRequestForJoint(RobotRequest req)
          Calls setEnabled(true) on the hosted Robot's Joint.
protected  void handleGoalPositionRequest(RobotRequest req)
          Sends a RobotPositionResponse with the Robot's goal positions.
 void setMotionFrameReceiver(org.robokind.api.messaging.MessageAsyncReceiver<MotionFrameEvent> receiver)
          Sets the MessageReceiver to receive MotionFrames
 void setMoveHandler(org.jflux.api.core.Listener<MotionFrameEvent> moveHandler)
          Sets the Listener to handle MotionFrames from clients.
 void setRequestReceiver(org.robokind.api.messaging.MessageAsyncReceiver<RobotRequest> receiver)
          Sets the MessageReceiver to receive RobotRequests.
 void setResponseFactory(RobotResponseFactory factory)
          Sets the factory to use for creating new RobotResponse Messages.
 void setResponseSender(org.robokind.api.messaging.MessageSender<RobotResponse> sender)
          Sets the MessageSender to send RobotResponses.
 void setRobot(Robot robot)
          Sets the Robot to host.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteRobotHost

public RemoteRobotHost(Robot robot,
                       String sourceId,
                       String destinationId,
                       org.robokind.api.messaging.MessageSender<RobotResponse> sender,
                       org.robokind.api.messaging.MessageAsyncReceiver<RobotRequest> receiver,
                       RobotResponseFactory factory,
                       org.robokind.api.messaging.MessageAsyncReceiver<MotionFrameEvent> motionFrameReceiver,
                       org.jflux.api.core.Listener<MotionFrameEvent> moveHandler)
Creates a new RemoteRobotHost to host the given Robot.

Parameters:
robot - Robot to host
sourceId - arbitrary String identifying this host
destinationId - arbitrary String identifying a client
sender - MessageSender to send RobotResponses
receiver - MessageReceiver to receive RobotRequests from a client
factory - factory for creating new RobotResponse Messages
motionFrameReceiver - MessageReceiver to receive MotionFrameEvents
moveHandler - Listener to handle MotionFrameEvents from clients

RemoteRobotHost

protected RemoteRobotHost(String sourceId,
                          String destinationId)
Creates an empty RemoteRobotHost.

Parameters:
sourceId - arbitrary String identifying this host
destinationId - arbitrary String identifying a client
Method Detail

setRobot

public void setRobot(Robot robot)
Sets the Robot to host.

Parameters:
robot - Robot to host

setResponseSender

public void setResponseSender(org.robokind.api.messaging.MessageSender<RobotResponse> sender)
Sets the MessageSender to send RobotResponses.

Parameters:
sender - MEssageSender to use

getResponseSender

public org.robokind.api.messaging.MessageSender<RobotResponse> getResponseSender()

setRequestReceiver

public void setRequestReceiver(org.robokind.api.messaging.MessageAsyncReceiver<RobotRequest> receiver)
Sets the MessageReceiver to receive RobotRequests.

Parameters:
receiver - MessageReceiver to use

setResponseFactory

public void setResponseFactory(RobotResponseFactory factory)
Sets the factory to use for creating new RobotResponse Messages.

Parameters:
factory - factory to use for creating new RobotResponse Messages

setMotionFrameReceiver

public void setMotionFrameReceiver(org.robokind.api.messaging.MessageAsyncReceiver<MotionFrameEvent> receiver)
Sets the MessageReceiver to receive MotionFrames

Parameters:
receiver - MessageReceiver to use

setMoveHandler

public void setMoveHandler(org.jflux.api.core.Listener<MotionFrameEvent> moveHandler)
Sets the Listener to handle MotionFrames from clients.

Parameters:
moveHandler - Listener to handle MotionFrames from clients

getRobotId

public Robot.Id getRobotId()
Returns the hosted Robot's id.

Returns:
hosted Robot's id

getSourceId

public String getSourceId()
Returns a String identifying this host. Currently unused.

Returns:
String identifying this host

getDestinationId

public String getDestinationId()
Returns a String identifying a client. Currently unused.

Returns:
String identifying a client

getRobot

public Robot getRobot()

handleDefinitionRequest

protected void handleDefinitionRequest(RobotRequest req)
Creates and sends a RobotDefinitionResponse.

Parameters:
req - RobotRequest the host is responding to

handleConnectRequest

protected void handleConnectRequest(RobotRequest req)
Calls connect() on the hosted Robot. The return value from that call is returned in a RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleDisconnectRequest

protected void handleDisconnectRequest(RobotRequest req)
Calls disconnect() on the hosted Robot. The return value from that call is returned in a RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleConnectionStatusRequest

protected void handleConnectionStatusRequest(RobotRequest req)
Creates and sends a RobotStatusResponse with the Robot's connection status

Parameters:
req - RobotRequest the host is responding to

handleEnableRequest

protected void handleEnableRequest(RobotRequest req)
Calls setEnabled(true) on the hosted Robot. Sends a successful RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleDisableRequest

protected void handleDisableRequest(RobotRequest req)
Calls setEnabled(false) on the hosted Robot. Sends a successful RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleEnabledStatusRequest

protected void handleEnabledStatusRequest(RobotRequest req)
Creates and sends a RobotStatusResponse with the Robot's enabled status

Parameters:
req - RobotRequest the host is responding to

handleEnableRequestForJoint

protected void handleEnableRequestForJoint(RobotRequest req)
Calls setEnabled(true) on the hosted Robot's Joint. Sends a successful RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleDisableRequestForJoint

protected void handleDisableRequestForJoint(RobotRequest req)
Calls setEnabled(true) on the hosted Robot's Joint. Sends a successful RobotStatusResponse.

Parameters:
req - RobotRequest the host is responding to

handleEnabledStatusRequestForJoint

protected void handleEnabledStatusRequestForJoint(RobotRequest req)
Creates and sends a RobotStatusResponse with the Joint's connection status

Parameters:
req - RobotRequest the host is responding to

getRequestedJoint

protected Joint getRequestedJoint(RobotRequest req)
Retrieves the Joint specified in the RobotRequest.

Parameters:
req - RobotRequest specifying a Joint
Returns:
Joint specified in the RobotRequest

handleDefaultPositionRequest

protected void handleDefaultPositionRequest(RobotRequest req)
Sends a RobotPositionResponse with the Robot's default positions.

Parameters:
req - RobotRequest the host is responding to

handleGoalPositionRequest

protected void handleGoalPositionRequest(RobotRequest req)
Sends a RobotPositionResponse with the Robot's goal positions.

Parameters:
req - RobotRequest the host is responding to

handleCurrentPositionRequest

protected void handleCurrentPositionRequest(RobotRequest req)
Sends a RobotPositionResponse with the Robot's current positions.

Parameters:
req - RobotRequest the host is responding to


Copyright © 2011-2013. All Rights Reserved.