]> ToastFreeware Gitweb - gregoa/zavai.git/blobdiff - src/gps.vala
Merge branch 'master' into gregoa
[gregoa/zavai.git] / src / gps.vala
index cf4dd35d9007c5f7002b28405d9e6bfd48e53bde..64037ce3a849c56b54d56bef02c47a19ce2d002a 100644 (file)
@@ -52,42 +52,39 @@ public class GPS: zavai.ScriptService
 
     protected bool on_input_data(IOChannel source, IOCondition condition)
     {
-        while (libgps.waiting(ref data))
+        int res = libgps.poll(ref data);
+        if (res != 0)
+            zavai.log.error(libgps.errstr(res));
+
+        if (data.status != old_fix_status)
+        {
+            fix_status_changed(data.status);
+            old_fix_status = data.status;
+        }
+
+        uint cur_time = (uint)data.fix.time;
+        if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time)
+        {
+            time_changed(cur_time);
+            old_time = cur_time;
+        }
+
+        double lat = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.latitude);
+        double lon = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.longitude);
+        if (lat != old_lat || lon != old_lon)
+            pos_changed();
+
+        /*
+        stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status);
+        stderr.printf("SATUSED %d\n", data.satellites_used);
+        stderr.printf("SWT %f\n", data.skyview_time);
+        stderr.printf("SATVIS %d\n", data.satellites_visible);
+        for (int i = 0; i < data.satellites_visible; ++i)
         {
-            int res = libgps.poll(ref data);
-            if (res != 0)
-                zavai.log.error(libgps.errstr(res));
-
-            if (data.status != old_fix_status)
-            {
-                fix_status_changed(data.status);
-                old_fix_status = data.status;
-            }
-
-            uint cur_time = (uint)data.fix.time;
-            if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time)
-            {
-                time_changed(cur_time);
-                old_time = cur_time;
-            }
-
-            double lat = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.latitude);
-            double lon = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.longitude);
-            if (lat != old_lat || lon != old_lon)
-                pos_changed();
-
-            stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status);
-            stderr.printf("SATUSED %d\n", data.satellites_used);
-            stderr.printf("SWT %f\n", data.skyview_time);
-            stderr.printf("SATVIS %d\n", data.satellites_visible);
-            for (int i = 0; i < data.satellites_visible; ++i)
-            {
-                stderr.printf("PRN %d ELE %d AZI %d SS %f\n",
-                    data.PRN[i], data.elevation[i], data.azimuth[i], data.ss[i]);
-            }
-            /*
-            */
+            stderr.printf("PRN %d ELE %d AZI %d SS %f\n",
+                data.PRN[i], data.elevation[i], data.azimuth[i], data.ss[i]);
         }
+        */
         return true;
     }
 
@@ -113,7 +110,7 @@ public class GPS: zavai.ScriptService
             return;
         }
 
-        res = libgps.send(ref data, "?SKY;");
+        //res = libgps.send(ref data, "?SKY;");
         //res = libgps.send(ref data, "?WATCH;");
         //if (res != 0) zavai.log.error(libgps.errstr(res));
 
@@ -189,7 +186,7 @@ public class GPS: zavai.ScriptService
 public class GPX : Service
 {
     protected uint wpt_seq = 0;
-    protected uint log_id = 0;
+    protected zavai.log.Log log = null;
 
     public GPX()
     {
@@ -200,7 +197,7 @@ public class GPX : Service
     {
         if (!started)
         {
-            log_id = log.log.start("track", "GPS track");
+            log = zavai.log.log.start("track", "GPS track");
             base.start();
         }
     }
@@ -209,8 +206,8 @@ public class GPX : Service
     {
         if (started)
         {
-            log.log.end(log_id);
-            log_id = 0;
+            zavai.log.log.end(log);
+            log = null;
             base.stop();
         }
     }
@@ -218,7 +215,7 @@ public class GPX : Service
     // Mark a waypoint
     public void waypoint(string? name = null)
     {
-        if (log_id == 0) return;
+        if (log == null) return;
 
         string wptname;
         if (name == null)
@@ -229,7 +226,7 @@ public class GPX : Service
             wptname = name;
         }
 
-        log.log.add(log_id, wptname);
+        log.add(wptname);
     }
 }