|
Urbi SDK Remote for Java
2.7.5
|
00001 /* ---------------------------------------------------------------------------- 00002 * This file was automatically generated by SWIG (http://www.swig.org). 00003 * Version 2.0.4 00004 * 00005 * Do not make changes to this file unless you know what you are doing--modify 00006 * the SWIG interface file instead. 00007 * ----------------------------------------------------------------------------- */ 00008 00009 package urbi; 00010 /// UClient linux implementation with support for synchronous extra 00011 /// functions. 00012 /*! This class provides extra functions to synchronously request 00013 values. These functions can safely be called frow within a 00014 callback function. 00015 00016 All callbacks will be called in a separate thread created in the 00017 constructor. 00018 When one of those callbacks calls a synchronous function, new incoming 00019 messages are kept on hold until the response from the synchronous call 00020 is received. 00021 00022 If you want to call these callbacks in a different 00023 thread, call stopCallbackThread(), then regularly call 00024 processEvents(). Each call will call callbacks for all pending 00025 messages in the current thread. */ 00026 00027 public class USyncClient extends UClient { 00028 private long swigCPtr; 00029 00030 public USyncClient(long cPtr, boolean cMemoryOwn) { 00031 super(urbiJNI.USyncClient_SWIGUpcast(cPtr), cMemoryOwn); 00032 swigCPtr = cPtr; 00033 } 00034 00035 public static long getCPtr(USyncClient obj) { 00036 return (obj == null) ? 0 : obj.swigCPtr; 00037 } 00038 00039 protected void finalize() { 00040 delete(); 00041 } 00042 00043 public synchronized void delete() { 00044 if (swigCPtr != 0) { 00045 if (swigCMemOwn) { 00046 swigCMemOwn = false; 00047 urbiJNI.delete_USyncClient(swigCPtr); 00048 } 00049 swigCPtr = 0; 00050 } 00051 super.delete(); 00052 } 00053 00054 public USyncClient(String host, long port, long buflen) { 00055 this(urbiJNI.new_USyncClient__SWIG_0(host, port, buflen), true); 00056 } 00057 00058 public USyncClient(String host, long port) { 00059 this(urbiJNI.new_USyncClient__SWIG_1(host, port), true); 00060 } 00061 00062 public USyncClient(String host) { 00063 this(urbiJNI.new_USyncClient__SWIG_2(host), true); 00064 } 00065 00066 /// Synchronously evaluate an Urbi expression. The expression must 00067 /// not start with a tag or channel. 00068 public UMessage syncGet(String expression) { 00069 long cPtr = urbiJNI.USyncClient_syncGet__SWIG_0(swigCPtr, this, expression); 00070 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00071 } 00072 00073 /// Synchronously evaluate an Urbi expression. The expression must 00074 /// not start with a tag or channel. 00075 public UMessage syncGet(long useconds, String expression) { 00076 long cPtr = urbiJNI.USyncClient_syncGet__SWIG_2(swigCPtr, this, useconds, expression); 00077 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00078 } 00079 00080 public UMessage syncGetTag(String expression, String mtag, String mmod) { 00081 long cPtr = urbiJNI.USyncClient_syncGetTag__SWIG_0(swigCPtr, this, expression, mtag, mmod); 00082 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00083 } 00084 00085 public UMessage syncGetTag(long useconds, String expression, String mtag, String mmod) { 00086 long cPtr = urbiJNI.USyncClient_syncGetTag__SWIG_1(swigCPtr, this, useconds, expression, mtag, mmod); 00087 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00088 } 00089 00090 public int syncGetValue(String valName, UValue val, long useconds) { 00091 return urbiJNI.USyncClient_syncGetValue__SWIG_0(swigCPtr, this, valName, UValue.getCPtr(val), val, useconds); 00092 } 00093 00094 public int syncGetValue(String valName, UValue val) { 00095 return urbiJNI.USyncClient_syncGetValue__SWIG_1(swigCPtr, this, valName, UValue.getCPtr(val), val); 00096 } 00097 00098 public int syncGetValue(String tag, String valName, UValue val, long useconds) { 00099 return urbiJNI.USyncClient_syncGetValue__SWIG_2(swigCPtr, this, tag, valName, UValue.getCPtr(val), val, useconds); 00100 } 00101 00102 public int syncGetValue(String tag, String valName, UValue val) { 00103 return urbiJNI.USyncClient_syncGetValue__SWIG_3(swigCPtr, this, tag, valName, UValue.getCPtr(val), val); 00104 } 00105 00106 public int syncGetDevice(String device, SWIGTYPE_p_double val, long useconds) { 00107 return urbiJNI.USyncClient_syncGetDevice__SWIG_0(swigCPtr, this, device, SWIGTYPE_p_double.getCPtr(val), useconds); 00108 } 00109 00110 public int syncGetDevice(String device, SWIGTYPE_p_double val) { 00111 return urbiJNI.USyncClient_syncGetDevice__SWIG_1(swigCPtr, this, device, SWIGTYPE_p_double.getCPtr(val)); 00112 } 00113 00114 public int syncGetResult(String command, SWIGTYPE_p_double val, long useconds) { 00115 return urbiJNI.USyncClient_syncGetResult__SWIG_0(swigCPtr, this, command, SWIGTYPE_p_double.getCPtr(val), useconds); 00116 } 00117 00118 public int syncGetResult(String command, SWIGTYPE_p_double val) { 00119 return urbiJNI.USyncClient_syncGetResult__SWIG_1(swigCPtr, this, command, SWIGTYPE_p_double.getCPtr(val)); 00120 } 00121 00122 public int syncGetNormalizedDevice(String device, SWIGTYPE_p_double val, long useconds) { 00123 return urbiJNI.USyncClient_syncGetNormalizedDevice__SWIG_0(swigCPtr, this, device, SWIGTYPE_p_double.getCPtr(val), useconds); 00124 } 00125 00126 public int syncGetNormalizedDevice(String device, SWIGTYPE_p_double val) { 00127 return urbiJNI.USyncClient_syncGetNormalizedDevice__SWIG_1(swigCPtr, this, device, SWIGTYPE_p_double.getCPtr(val)); 00128 } 00129 00130 public int syncGetDevice(String device, String field, SWIGTYPE_p_double val, long useconds) { 00131 return urbiJNI.USyncClient_syncGetDevice__SWIG_2(swigCPtr, this, device, field, SWIGTYPE_p_double.getCPtr(val), useconds); 00132 } 00133 00134 public int syncGetDevice(String device, String field, SWIGTYPE_p_double val) { 00135 return urbiJNI.USyncClient_syncGetDevice__SWIG_3(swigCPtr, this, device, field, SWIGTYPE_p_double.getCPtr(val)); 00136 } 00137 00138 public int syncGetSound(String device, int duration, USound sound, long useconds) { 00139 return urbiJNI.USyncClient_syncGetSound__SWIG_0(swigCPtr, this, device, duration, USound.getCPtr(sound), sound, useconds); 00140 } 00141 00142 public int syncGetSound(String device, int duration, USound sound) { 00143 return urbiJNI.USyncClient_syncGetSound__SWIG_1(swigCPtr, this, device, duration, USound.getCPtr(sound), sound); 00144 } 00145 00146 /// Wait until a message with specified tag is received. Returned 00147 /// message must be deleted. 00148 public UMessage waitForTag(String tag, long useconds) { 00149 long cPtr = urbiJNI.USyncClient_waitForTag__SWIG_0(swigCPtr, this, tag, useconds); 00150 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00151 } 00152 00153 /// Wait until a message with specified tag is received. Returned 00154 /// message must be deleted. 00155 public UMessage waitForTag(String tag) { 00156 long cPtr = urbiJNI.USyncClient_waitForTag__SWIG_1(swigCPtr, this, tag); 00157 return (cPtr == 0) ? null : new UMessage(cPtr, false); 00158 } 00159 00160 public void lockQueue() { 00161 urbiJNI.USyncClient_lockQueue(swigCPtr, this); 00162 } 00163 00164 /// Overriding UAbstractclient implementation 00165 public void notifyCallbacks(UMessage msg) { 00166 urbiJNI.USyncClient_notifyCallbacks(swigCPtr, this, UMessage.getCPtr(msg), msg); 00167 } 00168 00169 /** 00170 * Check message queue for pending messages, notify callbacks synchronously. 00171 * @param timeout If different -1 process events for at most @a timeout 00172 * microseconds. This is useful if you don't want 00173 * processEvents() to take to much time if there are many 00174 * many pending messages. 00175 * @return true if at least one message was processed, false otherwise. 00176 * Callbacks functions are called synchronously in the caller thread. 00177 */ 00178 public boolean processEvents(long timeout) { 00179 return urbiJNI.USyncClient_processEvents__SWIG_0(swigCPtr, this, timeout); 00180 } 00181 00182 /** 00183 * Check message queue for pending messages, notify callbacks synchronously. 00184 * @param timeout If different -1 process events for at most @a timeout 00185 * microseconds. This is useful if you don't want 00186 * processEvents() to take to much time if there are many 00187 * many pending messages. 00188 * @return true if at least one message was processed, false otherwise. 00189 * Callbacks functions are called synchronously in the caller thread. 00190 */ 00191 public boolean processEvents() { 00192 return urbiJNI.USyncClient_processEvents__SWIG_1(swigCPtr, this); 00193 } 00194 00195 /** 00196 * Stop the callback processing thread. 00197 * The user is responsible for calling processEvents() regularily 00198 * once this function has been called. 00199 */ 00200 public void stopCallbackThread() { 00201 urbiJNI.USyncClient_stopCallbackThread(swigCPtr, this); 00202 } 00203 00204 public void callbackThread() { 00205 urbiJNI.USyncClient_callbackThread(swigCPtr, this); 00206 } 00207 00208 public void setSynchronous(boolean enable) { 00209 urbiJNI.USyncClient_setSynchronous(swigCPtr, this, enable); 00210 } 00211 00212 /** Block until kernel version is available or an error occurrs. 00213 * Message processing must not depend on this thread. 00214 */ 00215 public void waitForKernelVersion(boolean hasProcessingThread) { 00216 urbiJNI.USyncClient_waitForKernelVersion__SWIG_1(swigCPtr, this, hasProcessingThread); 00217 } 00218 00219 public void onConnect() { 00220 urbiJNI.USyncClient_onConnect(swigCPtr, this); 00221 } 00222 00223 /// @return true if the current thread is the callback thread. 00224 public boolean isCallbackThread() { 00225 return urbiJNI.USyncClient_isCallbackThread(swigCPtr, this); 00226 } 00227 00228 }