Urbi SDK Remote for Java  2.7.5
UAbstractClient.java
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   /// Interface for an URBI wrapper object.
00011   /*! Implementations of this interface are wrappers around the URBI protocol.
00012     It handles URBI messages parsing, callback registration and various
00013     formatting functions.
00014     Implementations of this interface should:
00015     - Redefine errorNotify() as a function able to notify the user of eventual
00016     errors.
00017     - Redfine the four mutual exclusion functions.
00018     - Redefine effectiveSend().
00019     - Fill recvBuffer, update recvBufferPosition and call processRecvBuffer()
00020     when new data is available.
00021     - Provide an execute() function in the namespace urbi, that never returns,
00022     and that will be called after initialization.
00023     - Call onConnection when the connection is established.
00024 
00025    See the liburbi-cpp documentation for more informations on
00026    how to use this class.
00027   */
00028 
00029 public class UAbstractClient extends LockableOstream {
00030   private long swigCPtr;
00031 
00032   public UAbstractClient(long cPtr, boolean cMemoryOwn) {
00033     super(urbiJNI.UAbstractClient_SWIGUpcast(cPtr), cMemoryOwn);
00034     swigCPtr = cPtr;
00035   }
00036 
00037   public static long getCPtr(UAbstractClient obj) {
00038     return (obj == null) ? 0 : obj.swigCPtr;
00039   }
00040 
00041   protected void finalize() {
00042     delete();
00043   }
00044 
00045   public synchronized void delete() {
00046     if (swigCPtr != 0) {
00047       if (swigCMemOwn) {
00048         swigCMemOwn = false;
00049         urbiJNI.delete_UAbstractClient(swigCPtr);
00050       }
00051       swigCPtr = 0;
00052     }
00053     super.delete();
00054   }
00055 
00056       /// Default host.
00057  public  static String default_host() {
00058     return urbiJNI.UAbstractClient_default_host();
00059   }
00060 
00061   public boolean init() {
00062     return urbiJNI.UAbstractClient_init(swigCPtr, this);
00063   }
00064 
00065       /// Return current error status, or zero if no error occurred.
00066  public  int error() {
00067     return urbiJNI.UAbstractClient_error(swigCPtr, this);
00068   }
00069 
00070       /// Send the remainder of the stream.
00071  public  int send(String format) {
00072     return urbiJNI.UAbstractClient_send__SWIG_0(swigCPtr, this, format);
00073   }
00074 
00075       /// Send the remainder of the stream.
00076  public  int send(UValue v) {
00077     return urbiJNI.UAbstractClient_send__SWIG_2(swigCPtr, this, UValue.getCPtr(v), v);
00078   }
00079 
00080       /// Lock the send buffer (for backward compatibility, will be
00081     /// removed in future versions).
00082  public  int startPack() {
00083     return urbiJNI.UAbstractClient_startPack(swigCPtr, this);
00084   }
00085 
00086       /// Unlock the send buffer (for backward compatibility, will be
00087     /// removed in future versions).
00088  public  int endPack() {
00089     return urbiJNI.UAbstractClient_endPack(swigCPtr, this);
00090   }
00091 
00092   public int pack(String format) {
00093     return urbiJNI.UAbstractClient_pack(swigCPtr, this, format);
00094   }
00095 
00096       /// Send urbi commands contained in a file.
00097     /// The file "/dev/stdin" is recognized as referring to std::cin.
00098  public  int sendFile(String f) {
00099     return urbiJNI.UAbstractClient_sendFile(swigCPtr, this, f);
00100   }
00101 
00102   public int sendSound(String device, USound sound, String tag) {
00103     return urbiJNI.UAbstractClient_sendSound__SWIG_0(swigCPtr, this, device, USound.getCPtr(sound), sound, tag);
00104   }
00105 
00106   public int sendSound(String device, USound sound) {
00107     return urbiJNI.UAbstractClient_sendSound__SWIG_1(swigCPtr, this, device, USound.getCPtr(sound), sound);
00108   }
00109 
00110       /// Put a file on the robot's mass storage device.
00111  public  int putFile(String localName, String remoteName) {
00112     return urbiJNI.UAbstractClient_putFile__SWIG_0(swigCPtr, this, localName, remoteName);
00113   }
00114 
00115       /// Put a file on the robot's mass storage device.
00116  public  int putFile(String localName) {
00117     return urbiJNI.UAbstractClient_putFile__SWIG_1(swigCPtr, this, localName);
00118   }
00119 
00120       /// OLD-style callbacks
00121  public  long setCallback(UCallbackWrapper callback, String tag) {
00122     return urbiJNI.UAbstractClient_setCallback__SWIG_0(swigCPtr, this, UCallbackWrapper.getCPtr(callback), callback, tag);
00123   }
00124 
00125       /// Associate a callback function with all error messages from the server
00126  public  long setErrorCallback(UCallbackWrapper callback) {
00127     return urbiJNI.UAbstractClient_setErrorCallback(swigCPtr, this, UCallbackWrapper.getCPtr(callback), callback);
00128   }
00129 
00130       /// Associate a callback with all messages
00131  public  long setWildcardCallback(UCallbackWrapper callback) {
00132     return urbiJNI.UAbstractClient_setWildcardCallback(swigCPtr, this, UCallbackWrapper.getCPtr(callback), callback);
00133   }
00134 
00135       /// Associate a callback with local connection errors
00136  public  long setClientErrorCallback(UCallbackWrapper callback) {
00137     return urbiJNI.UAbstractClient_setClientErrorCallback(swigCPtr, this, UCallbackWrapper.getCPtr(callback), callback);
00138   }
00139 
00140       //@}
00141     /// Get the tag associated with a registered callback.
00142     /// \return 1 and fill tag on success, 0 on failure.
00143  public  int getAssociatedTag(long id, String tag) {
00144     return urbiJNI.UAbstractClient_getAssociatedTag(swigCPtr, this, id, tag);
00145   }
00146 
00147       /// Delete a callback.
00148     /// \return 0 if no callback with this id was found, 1 otherwise.
00149  public  int deleteCallback(long id) {
00150     return urbiJNI.UAbstractClient_deleteCallback(swigCPtr, this, id);
00151   }
00152 
00153       /// Return a identifier, for tags for instance.
00154  public  String fresh() {
00155     return urbiJNI.UAbstractClient_fresh(swigCPtr, this);
00156   }
00157 
00158   public void makeUniqueTag(String tag) {
00159     urbiJNI.UAbstractClient_makeUniqueTag(swigCPtr, this, tag);
00160   }
00161 
00162       /// Pass the given UMessage to all registered callbacks with the
00163     /// corresponding tag, as if it were comming from the URBI server.
00164  public  void notifyCallbacks(UMessage msg) {
00165     urbiJNI.UAbstractClient_notifyCallbacks(swigCPtr, this, UMessage.getCPtr(msg), msg);
00166   }
00167 
00168   public void printf(String format) {
00169     urbiJNI.UAbstractClient_printf(swigCPtr, this, format);
00170   }
00171 
00172       /// Get time in milliseconds since an unspecified but constant
00173     /// reference time.
00174  public  long getCurrentTime() {
00175     return urbiJNI.UAbstractClient_getCurrentTime(swigCPtr, this);
00176   }
00177 
00178   public void setKeepAliveCheck(long pingInterval, long pongTimeout) {
00179     urbiJNI.UAbstractClient_setKeepAliveCheck(swigCPtr, this, pingInterval, pongTimeout);
00180   }
00181 
00182       /// Return the server name or IP address.
00183  public  String getServerName() {
00184     return urbiJNI.UAbstractClient_getServerName(swigCPtr, this);
00185   }
00186 
00187       /// Return the server port.
00188  public  long getServerPort() {
00189     return urbiJNI.UAbstractClient_getServerPort(swigCPtr, this);
00190   }
00191 
00192       /// Called each time new data is available in recvBuffer.
00193  public  void processRecvBuffer() {
00194     urbiJNI.UAbstractClient_processRecvBuffer(swigCPtr, this);
00195   }
00196 
00197   public static void setCLIENTERROR_TAG(String value) {
00198     urbiJNI.UAbstractClient_CLIENTERROR_TAG_set(value);
00199   }
00200 
00201   public static String getCLIENTERROR_TAG() {
00202     return urbiJNI.UAbstractClient_CLIENTERROR_TAG_get();
00203   }
00204 
00205       /// Kernel version string.
00206     /// Call waitForKernelVersion to make sure it is defined (beware
00207     /// that there are two signatures, one for UAbstractClient,
00208     /// another for USyncClient).
00209  public  String kernelVersion() {
00210     return urbiJNI.UAbstractClient_kernelVersion(swigCPtr, this);
00211   }
00212 
00213       /// Major kernel version.  Dies if unknown yet.
00214  public  int kernelMajor() {
00215     return urbiJNI.UAbstractClient_kernelMajor(swigCPtr, this);
00216   }
00217 
00218       /// Minor kernel version.  Dies if unknown yet.
00219  public  int kernelMinor() {
00220     return urbiJNI.UAbstractClient_kernelMinor(swigCPtr, this);
00221   }
00222 
00223       /** Block until kernel version is available or an error occurrs.
00224      * Message processing must not depend on this thread.
00225      */
00226  public  void waitForKernelVersion() {
00227     urbiJNI.UAbstractClient_waitForKernelVersion(swigCPtr, this);
00228   }
00229 
00230   public String connectionID() {
00231     return urbiJNI.UAbstractClient_connectionID(swigCPtr, this);
00232   }
00233 
00234   public int getCurrentTimestamp() {
00235     return urbiJNI.UAbstractClient_getCurrentTimestamp(swigCPtr, this);
00236   }
00237 
00238       /// OLD-style callbacks
00239  public  long setCallback(UCallbackInterface ref, String tag) {
00240     return urbiJNI.UAbstractClient_setCallback__SWIG_6(swigCPtr, this, UCallbackInterface.getCPtr(ref), ref, tag);
00241   }
00242 
00243       /// Send binary data.
00244  public  void sendBin(byte[] bin, int len) {
00245     urbiJNI.UAbstractClient_sendBin__SWIG_0(swigCPtr, this, bin, len);
00246   }
00247 
00248       /// Send binary data.
00249  public  void sendBin(byte[] bin, int len, String header) {
00250     urbiJNI.UAbstractClient_sendBin__SWIG_1(swigCPtr, this, bin, len, header);
00251   }
00252 
00253   public final static int URBI_BUFLEN = 128000;
00254 
00255   public final static int URBI_PORT = 54000;
00256 
00257 }