26
26
const hardware::gps::Base& gps = hardware_.getGps();
27
27
json_object* jsonGps = json_object_new_object();
29
logger_.debugStream() << "gps";
31
json_object_object_add(jsonGps, "longitude", json_object_new_double(gps.getLocation().getLongitude()));
32
json_object_object_add(jsonGps, "longitudeError", json_object_new_double(gps.getLocation().getLongitudeError()));
33
json_object_object_add(jsonGps, "latitude", json_object_new_double(gps.getLocation().getLatitude()));
34
json_object_object_add(jsonGps, "latitudeError", json_object_new_double(gps.getLocation().getLatitudeError()));
35
json_object_object_add(jsonGps, "altitude", json_object_new_int(gps.getLocation().getAltitude()));
36
json_object_object_add(jsonGps, "altitudeError", json_object_new_int(gps.getLocation().getAltitudeError()));
37
pt::ptime gpsTime = gps.getTime();
38
std::ostringstream oss;
39
gr::date_facet *datefacet = new gr::date_facet();
40
datefacet->format("%Y-%m-%d");
41
oss.imbue(std::locale(std::locale::classic(), datefacet));
42
oss << gpsTime.date();
43
json_object_object_add(jsonGps, "date", json_object_new_string(oss.str().c_str()));
45
oss << gpsTime.time_of_day();
46
json_object_object_add(jsonGps, "time", json_object_new_string(oss.str().c_str()));
47
json_object_object_add(jsonGps, "ticksPerSecond", json_object_new_double(gps.getTicksPerSecond()));
48
json_object_object_add(jsonGps, "tickError", json_object_new_double(gps.getTickError()));
49
json_object_object_add(jsonGps, "satelliteCount", json_object_new_int(gps.getSatelliteCount()));
50
} catch (exception::Base &e) {
51
logger_.debugStream() << "gps failed";
28
53
char gpsStatus = gps.getStatus();
29
json_object_object_add(jsonGps, "longitude", json_object_new_double(gps.getLocation().getLongitude()));
30
json_object_object_add(jsonGps, "longitudeError", json_object_new_double(gps.getLocation().getLongitudeError()));
31
json_object_object_add(jsonGps, "latitude", json_object_new_double(gps.getLocation().getLatitude()));
32
json_object_object_add(jsonGps, "latitudeError", json_object_new_double(gps.getLocation().getLatitudeError()));
33
json_object_object_add(jsonGps, "altitude", json_object_new_int(gps.getLocation().getAltitude()));
34
json_object_object_add(jsonGps, "altitudeError", json_object_new_int(gps.getLocation().getAltitudeError()));
35
pt::ptime gpsTime = gps.getTime();
36
std::ostringstream oss;
37
gr::date_facet *datefacet = new gr::date_facet();
38
datefacet->format("%Y-%m-%d");
39
oss.imbue(std::locale(std::locale::classic(), datefacet));
40
oss << gpsTime.date();
41
json_object_object_add(jsonGps, "date", json_object_new_string(oss.str().c_str()));
43
oss << gpsTime.time_of_day();
44
json_object_object_add(jsonGps, "time", json_object_new_string(oss.str().c_str()));
45
json_object_object_add(jsonGps, "ticksPerSecond", json_object_new_double(gps.getTicksPerSecond()));
46
json_object_object_add(jsonGps, "tickError", json_object_new_double(gps.getTickError()));
47
54
json_object_object_add(jsonGps, "status", json_object_new_string_len(&gpsStatus, 1));
48
json_object_object_add(jsonGps, "satelliteCount", json_object_new_int(gps.getSatelliteCount()));
49
55
json_object_object_add(jsonGps, "type", json_object_new_string(gps.getType().c_str()));
50
56
json_object_object_add(jsonHardware, "gps", jsonGps);
58
logger_.debugStream() << "comm";
52
59
const hardware::comm::Base& comm = hardware_.getComm();
53
60
json_object* jsonComm = json_object_new_object();
54
61
json_object_object_add(jsonComm, "baudRate", json_object_new_int(comm.getBaudRate()));
55
62
json_object_object_add(jsonComm, "interfaceName", json_object_new_string(comm.getInterfaceName().c_str()));
56
63
json_object_object_add(jsonHardware, "comm", jsonComm);
65
logger_.debugStream() << "process";
58
66
json_object* jsonProcess = json_object_new_object();
59
68
json_object_object_add(jsonProcess, "numberOfSeconds", json_object_new_int(process_.getEventCountBuffer().getActualSize()));
60
69
json_object_object_add(jsonProcess, "numberOfEvents", json_object_new_int(process_.getEventCountBuffer().getSum()));
61
70
json_object_object_add(jsonProcess, "eventsPerSecond", json_object_new_double(process_.getEventCountBuffer().getAverage()));
71
} catch (exception::Base &e) {
62
73
json_object_object_add(jsonResponse_, "process", jsonProcess);