RoconAppManager.java
Go to the documentation of this file.
00001 package com.ros.turtlebot.apps.rocon;
00002 
00003 import org.ros.namespace.GraphName;
00004 import org.ros.node.AbstractNodeMain;
00005 import org.ros.node.ConnectedNode;
00006 import org.ros.node.service.ServiceResponseBuilder;
00007 
00008 import android.util.Log;
00009 
00010 import rocon_app_manager_msgs.* ;
00011 
00012 public class RoconAppManager extends AbstractNodeMain {
00013 
00014         public static final String ACTION_PLATFORMINFO = "platform_info";
00015         public static final String ACTION_APPLIST = "list_apps";
00016         public static final String ACTION_INVITE = "invite";
00017         public static final String ACTION_STATUS = "status";
00018         public static final String ACTION_STARTAPP = "start_app";
00019 
00020         private ServiceResponseBuilder<GetPlatformInfoRequest, GetPlatformInfoResponse> platformInfoResponseBuilder = null ;
00021         private ServiceResponseBuilder<GetAppListRequest, GetAppListResponse> appListResponseBuilder = null ;
00022         private ServiceResponseBuilder<InviteRequest, InviteResponse> inviteResponseBuilder = null ;
00023         private ServiceResponseBuilder<StatusRequest, StatusResponse> statusResponseBuilder = null ;
00024         private ServiceResponseBuilder<StartAppRequest, StartAppResponse> startAppResponseBuilder = null ;
00025         
00026         private ConnectedNode connectedNode = null ;
00027         
00028         private String nodeName = "" ;
00029         private String actionName = "" ;
00030         private String serviceName = "";
00031         
00032         private RosBaseActivity parent = null ;
00033         
00034 
00035         public RoconAppManager(String nodeName, String actionName) {
00036                 this.nodeName = nodeName ;
00037                 this.actionName = actionName ;
00038         }
00039         
00040 
00041         @Override
00042         public GraphName getDefaultNodeName() {
00043                 // TODO Auto-generated method stub
00044                 return null;
00045         }
00046         
00047         @Override
00048         public void onStart(ConnectedNode connectedNode) {
00049                 // TODO Auto-generated method stub
00050                 Log.d("RoconAppManager", "onStart() - " + actionName);
00051                 this.connectedNode = connectedNode ;
00052                 if(actionName.equals(ACTION_PLATFORMINFO))
00053                         onStartPlatformInfo() ;
00054                 else if(actionName.equals(ACTION_APPLIST))
00055                         onStartAppList() ;
00056                 else if(actionName.equals(ACTION_STATUS))
00057                         onStartStatus() ;
00058                 else if(actionName.equals(ACTION_INVITE))
00059                         onStartInvite() ;
00060                 else if(actionName.equals(ACTION_STARTAPP))
00061                         onStartApp() ;
00062         }
00063         
00064         private void onStartPlatformInfo() {
00065                 Log.d("RoconAppManager", "onStartPlatformInfo()");
00066                 serviceName = nodeName + "/" + ACTION_PLATFORMINFO ;
00067                 if(connectedNode != null)
00068                         connectedNode.newServiceServer (serviceName, GetPlatformInfo._TYPE, platformInfoResponseBuilder) ;
00069                 else
00070                         Log.e("RoconAppManager", "onStartPlatformInfo()-connectedNode is null");
00071                 
00072         }
00073         
00074         private void onStartAppList() {
00075                 Log.d("RoconAppManager", "onStartAppList()");
00076                 serviceName = nodeName + "/" + ACTION_APPLIST ;
00077                 if(connectedNode != null)
00078                         connectedNode.newServiceServer(serviceName, GetAppList._TYPE, appListResponseBuilder) ;
00079                 else
00080                         Log.e("RoconAppManager", "onStartAppList()-connectedNode is null");
00081                 
00082         }
00083         
00084         private void onStartStatus() {
00085                 Log.d("RoconAppManager", "onStartStatus()");
00086                 serviceName = nodeName + "/" + ACTION_STATUS ;
00087                 if(connectedNode != null)
00088                         connectedNode.newServiceServer(serviceName, Status._TYPE, statusResponseBuilder) ;
00089                 else
00090                         Log.e("RoconAppManager", "onStartStatus()-connectedNode is null");
00091                 
00092         }
00093         
00094         private void onStartInvite() {
00095                 Log.d("RoconAppManager", "onStartInvite()");
00096                 serviceName = nodeName + "/" + ACTION_INVITE ;
00097                 if(connectedNode != null)
00098                         connectedNode.newServiceServer(serviceName, Invite._TYPE, inviteResponseBuilder) ;
00099                 else
00100                         Log.e("RoconAppManager", "onStartInvite()-connectedNode is null");
00101                 parent.onServerConnected(ACTION_INVITE);
00102         }
00103         
00104         private void onStartApp() {
00105                 Log.d("RoconAppManager", "onStartApp()");
00106                 serviceName = nodeName + "/" + ACTION_STARTAPP ;
00107                 if(connectedNode != null)
00108                         connectedNode.newServiceServer(serviceName, StartApp._TYPE, startAppResponseBuilder) ;
00109                 else
00110                         Log.e("RoconAppManager", "onStartApp()-connectedNode is null");
00111                 
00112         }
00113         
00114         
00115         public void setNodeName(String nodeName) {
00116                 this.nodeName = nodeName ;
00117         }
00118         
00119         public void setActionName(String actionName) {
00120                 this.actionName = actionName ;
00121         }
00122         
00123         public String getActionName() {
00124                 return this.actionName ;
00125         }
00126         
00127         public void setPlatformInfoResponseBuilder(
00128                         ServiceResponseBuilder<GetPlatformInfoRequest, GetPlatformInfoResponse> platformInfoResponseBuilder) {
00129                 this.platformInfoResponseBuilder = platformInfoResponseBuilder ;
00130         }
00131         
00132         public void setAppListResponseBuilder(
00133                         ServiceResponseBuilder<GetAppListRequest, GetAppListResponse> appListResponseBuilder) {
00134                 this.appListResponseBuilder = appListResponseBuilder ;
00135         }
00136         
00137         public void setInviteResponseBuilder(
00138                         ServiceResponseBuilder<InviteRequest, InviteResponse> inviteResponseBuilder) {
00139                 this.inviteResponseBuilder = inviteResponseBuilder ;
00140         }
00141         
00142         public void setStatusResponseBuilder(
00143                         ServiceResponseBuilder<StatusRequest, StatusResponse> statusResponseBuilder) {
00144                 this.statusResponseBuilder = statusResponseBuilder ;
00145         }
00146         
00147         public void setStartAppResponseBuilder(
00148                         ServiceResponseBuilder<StartAppRequest, StartAppResponse> startAppResponseBuilder) {
00149                 this.startAppResponseBuilder = startAppResponseBuilder ;
00150         }
00151         
00152         public ConnectedNode getConnectedNode() {
00153                 return this.connectedNode ;
00154         }
00155         
00156         public void setParent(RosBaseActivity parent) {
00157                 this.parent = parent ;
00158         }
00159 
00160 }


android_remocons
Author(s): Daniel Stonier , Kazuto Murase
autogenerated on Wed Aug 26 2015 10:40:28