]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/Robot_Demo/src/org/ocera/orte/demo/PwrVoltageSubscribe.java
ROBOT_DEMO: use new constants and fix behavior of callback functions
[orte.git] / orte / Robot_Demo / src / org / ocera / orte / demo / PwrVoltageSubscribe.java
index 98529882c3bb71d7786df42b4aa8834afcb94bdd..70cf02558e3fca219655748ef698e967cbdd6d04 100644 (file)
@@ -11,6 +11,7 @@ import org.ocera.orte.types.MessageData;
 import org.ocera.orte.types.NtpTime;
 import org.ocera.orte.types.RecvInfo;
 import org.ocera.orte.types.SubsProp;
+import org.ocera.orte.types.ORTEConstant;
 
 import android.os.Bundle;
 import android.os.Handler;
@@ -18,9 +19,6 @@ import android.os.Message;
 
 public class PwrVoltageSubscribe extends SubscriptionCallback{
 
-    public final static int IMMEDIATE    = 0x02;
-    public final static int BEST_EFFORTS = 0x01;
-
     static Handler handler;
     
        private Subscription sub;
@@ -46,8 +44,8 @@ public class PwrVoltageSubscribe extends SubscriptionCallback{
                                                        "pwr_voltage",                                  
                                                        minSeparation,  
                                                        deadline,
-                                                       IMMEDIATE,
-                                                       BEST_EFFORTS,
+                                                       ORTEConstant.IMMEDIATE,
+                                                       ORTEConstant.BEST_EFFORTS,
                                                        0);
        }
        
@@ -81,11 +79,13 @@ public class PwrVoltageSubscribe extends SubscriptionCallback{
        }
        
     public void callback(RecvInfo info, MessageData msg) {
-       Message message = handler.obtainMessage();
-       Bundle bundle = new Bundle();
-       
-       bundle.putDoubleArray("voltages", ((PwrVoltageType)msg).voltage.clone());
-       message.setData(bundle);
-       handler.sendMessage(message);
+      if (info.getRecvStatus() == ORTEConstant.NEW_DATA) {
+        Message message = handler.obtainMessage();
+        Bundle bundle = new Bundle();
+
+        bundle.putDoubleArray("voltages", ((PwrVoltageType)msg).voltage.clone());
+        message.setData(bundle);
+        handler.sendMessage(message);
+      }
     }
-}
\ No newline at end of file
+}