"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freedesktop.Gypsy.Device");
-
-// # see mdbus -s org.freesmartphone.ogpsd /org/freedesktop/Gypsy
-// gps = self.bus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
-// self.gps = dbus.Interface(gps, "org.freedesktop.Gypsy.Device")
-// self.gps_time = dbus.Interface(gps, "org.freedesktop.Gypsy.Time")
-// self.gps_position = dbus.Interface(gps, 'org.freedesktop.Gypsy.Position')
-// self.gps_ubx = dbus.Interface(gps, 'org.freesmartphone.GPS.UBX')
- usage.ResourceChanged += on_resourcechanged;
- }
-
- public void on_resourcechanged(dynamic DBus.Object pos, string name, bool state, HashTable<string, Value?> attributes)
- {
- zavai.log.info("RESOURCE CHANGED " + name);
}
/// Request GPS resource
}
}
-public class Monitor : zavai.Service
-{
- static const int NAV_STATUS=0;
- static const int NAV_SVINFO=1;
- static const int NAV_MAX=2;
-
- dynamic DBus.Object ubx;
- dynamic DBus.Object time;
-
- public signal void sat_info(PtrArray< HashTable<string, Value?> > data);
-
- /*
- string[] filters = { "NAV-STATUS", "NAV_SVINFO" };
-
- int debug_busy;
- int debug_want;
- int debug_have;
- int debug_error;
- */
-
-
- public Monitor()
- {
- name = "gps.monitor";
-
- ubx = zavai.registry.sbus.get_object(
- "org.freesmartphone.ogpsd",
- "/org/freedesktop/Gypsy",
- "org.freesmartphone.GPS.UBX");
- /*
- time = zavai.registry.sbus.get_object(
- "org.freesmartphone.ogpsd",
- "/org/freedesktop/Gypsy",
- "org.freedesktop.Gypsy.Time");
-
- zavai.log.info("SETSIG1");
- time.TimeChanged += timechanged;
- zavai.log.info("SETSIG2");
- */
-
- zavai.log.info("DEBUG1");
- ubx.DebugPacket += on_ubxdebug_packet;
- zavai.log.info("DEBUG2");
-
-/*
- // This piece of machinery is taken from Zhone
- debug_busy = -1;
- debug_want = (1 << NAV_STATUS) | (1 << NAV_SVINFO);
- debug_have = 0;
- debug_error = 0;
-*/
- }
-
-/*
- protected void timechanged(dynamic DBus.Object pos, int t)
- {
- zavai.log.info("TIMECHANGED");
- }
-*/
-
-/*
- protected void debug_update() throws GLib.Error
- {
- zavai.log.debug("UPDATE");
- if (debug_busy != -1)
- return;
- zavai.log.debug("UPD1");
- int pending = debug_want & (~debug_have) & (~debug_error);
- if (pending == 0)
- return;
- zavai.log.debug("UPD2");
- for (int i = 0; i < NAV_MAX; ++i)
- if ((pending & (1<<i)) != 0)
- {
- debug_busy = i;
- break;
- }
- zavai.log.debug("UPD3 " + filters[debug_busy]);
-
- ubx.SetDebugFilter(
- filters[debug_busy],
- true,
- on_debug_reply
-// on_debug_error
- );
- zavai.log.debug("UPD4");
- }
-
- protected void debug_request() throws GLib.Error
- {
- debug_have = 0;
- debug_update();
- }
-
- protected void on_debug_reply() throws GLib.Error
- {
- debug_have |= (1<<debug_busy);
- debug_busy = -1;
- debug_update();
- }
-
- protected void on_debug_error(string e) throws GLib.Error
- {
- string name = debug_busy == -1 ? "none" : filters[debug_busy];
- zavai.log.error("error while requesting debug packet " + name + ": " + e);
- debug_error |= (1<<debug_busy);
- debug_busy = -1;
- debug_update();
- }
-*/
-
- /*
- protected void on_satellites_changed(satellites)
- {
-// zavai.info("gps monitor: satellites changed")
-// self.debug_request()
- }
- */
-
- protected void on_ubxdebug_packet(dynamic DBus.Object ubx, string clid, int length,
- PtrArray< HashTable<string, Value?> > data)
- //HashTable<string, Value?>[] data)
- {
- zavai.log.info("gps monitor: UBX debug packet");
- /*
- message("ZAZA %s %d", clid, length);
- message("ZAZA %u %lu", data.length, sizeof(HashTable<string, Value?>));
- message("ZAZA %p %p", (void*)data.length, this);
- message("ZAZA %p", data[0]);
- message("ZAZA %p", data[1]);
- message("ZAZA %p", data[2]);
- */
- /*
- message("ZAZA %u", data[0].size());
- foreach (string k in data[0].get_keys())
- message("ZAZA %s", k);
- */
- //PtrArray< HashTable<string, Value?> >* prova = (PtrArray< HashTable<string, Value?> >)data;
- //message("ZAZA %u", prova->len);
- /*
- foreach (string k in prova[0].get_keys())
- message("ZAZA %s", k);
- */
- /*
- for (int i = 0; data[i] != null; ++i)
- {
- zavai.log.info("ZAZA");
- }
- */
- //message("Size: %d", data.size());
-// self.notify("satellites", clid, length, data)
- sat_info(data);
- }
-
- protected override void start()
- {
- if (started) return;
-
- zavai.log.info("Starting GPS Monitor");
- gps.request("gps.monitor");
-// # TODO: find out how come sometimes these events are not sent
-// self.gps.bus.add_signal_receiver(
-// self.on_satellites_changed, 'SatellitesChanged', 'org.freedesktop.Gypsy.Satellite',
-// 'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
- //ubx.DebugPacket += prova;
- //try {
- //ubx.SetDebugFilter("NAV-STATUS", true);
- //ubx.SetDebugFilter("NAV-SVINFO", true);
- //debug_request();
- base.start();
- //} catch (GLib.Error e) {
- //zavai.log.error(e.message);
- //}
- }
-
- protected override void stop()
- {
- if (!started) return;
- zavai.log.info("Stopping GPS Monitor");
-// self.gps.bus.remove_signal_receiver(
-// self.on_satellites_changed, 'SatellitesChanged', 'org.freedesktop.Gypsy.Satellite',
-// 'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
- try {
- ubx.SetDebugFilter("NAV-STATUS", false);
- ubx.SetDebugFilter("NAV-SVINFO", false);
- } catch (GLib.Error e) {
- zavai.log.error(e.message);
- }
- ubx.DebugPacket -= on_ubxdebug_packet;
- //ubx.DebugPacket -= prova;
- gps.release("gps.monitor");
- base.stop();
- }
-}
-
-
public class Position : zavai.Service
{
dynamic DBus.Object position;
// # 'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
// # return False
// #
-// # def on_fix_status_changed(self, status):
-// # if status not in [2, 3]: return
-// #
-// # zavai.info("Got GPS fix")
-// # self.bus.remove_signal_receiver(
-// # self.on_fix_status_changed, 'FixStatusChanged', 'org.freedesktop.Gypsy.Device',
-// # 'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
-// #
-// # if self.waiting_for_fix:
-// # self.waiting_for_fix()
-// # self.waiting_for_fix = None
-// #
-//
// # def start_recording(self):
// # if self.gps_monitor:
// # self.gps_monitor.stop()
}
}
-// # def record(self):
-// # self.audio = Audio(self.make_waypoint)
-// # self.gps = GPS()
-// # # Get a fix and start recording
-// # if not self.gps.wait_for_fix(self.start_recording):
-// # self.gps_monitor = GPSMonitor(self.gps)
-// # self.gps_monitor.start()
-// #
-// # def monitor(self):
-// # self.audio = None
-// # self.gps = GPS()
-// # self.gps_monitor = GPSMonitor(self.gps)
-// # self.gps_monitor.start()
-// #
-// #
-// # def make_waypoint(self):
-// # if self.gpx is None:
-// # return
-// # if self.last_pos is None:
-// # self.last_pos = self.gps.gps_position.GetPosition()
-// # (fields, tstamp, lat, lon, alt) = self.last_pos
-// # self.gpx.waypoint(tstamp, lat, lon, alt)
-// # zavai.info("Making waypoint at %s: %f, %f, %f" % (
-// # time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(tstamp)), lat, lon, alt))
-
public zavai.gps.GPS gps = null;
-public zavai.gps.Monitor monitor = null;
public zavai.gps.Position position = null;
public zavai.gps.GPX gpx = null;
public void init()
{
gps = new GPS();
- monitor = new Monitor();
position = new Position();
gpx = new GPX();