Commit bcf063e258d11727f0bc00ecc26e56b9254d49f8
- Diff rendering mode:
- inline
- side by side
core/web/handler/jsonhelper.cpp
(11 / 2)
|   | |||
| 26 | 26 | ||
| 27 | 27 | #include "core/web/json.h" | |
| 28 | 28 | ||
| 29 | #include "core/datetools.h" | ||
| 30 | |||
| 29 | 31 | #include "core/model/devicereference.h" | |
| 30 | 32 | #include "core/model/device.h" | |
| 31 | 33 | #include "core/model/set.h" | |
| … | … | ||
| 38 | 38 | namespace dss { | |
| 39 | 39 | ||
| 40 | 40 | boost::shared_ptr<JSONObject> toJSON(const DeviceReference& _device) { | |
| 41 | DateTime tmp_date; | ||
| 42 | |||
| 41 | 43 | boost::shared_ptr<JSONObject> result(new JSONObject()); | |
| 42 | 44 | result->addProperty("id", _device.getDSID().toString()); | |
| 43 | 45 | result->addProperty("isSwitch", _device.hasSwitch()); | |
| … | … | ||
| 50 | 50 | result->addProperty("circuitID", _device.getDevice().getDSMeterID()); | |
| 51 | 51 | result->addProperty("busID", _device.getDevice().getShortAddress()); | |
| 52 | 52 | result->addProperty("isPresent", _device.getDevice().isPresent()); | |
| 53 | result->addProperty("lastDiscovered", _device.getDevice().getLastDiscovered()); | ||
| 54 | result->addProperty("firstSeen", _device.getDevice().getFirstSeen()); | ||
| 53 | |||
| 54 | tmp_date = _device.getDevice().getLastDiscovered(); | ||
| 55 | result->addProperty("lastDiscovered", tmp_date.fromUTC()); | ||
| 56 | |||
| 57 | tmp_date = _device.getDevice().getFirstSeen(); | ||
| 58 | result->addProperty("firstSeen", tmp_date.fromUTC()); | ||
| 59 | |||
| 55 | 60 | result->addProperty("on", _device.getDevice().isOn()); | |
| 56 | 61 | result->addProperty("locked", _device.getDevice().getIsLockedInDSM()); | |
| 57 | 62 | return result; |
core/web/handler/meteringrequesthandler.cpp
(4 / 2)
|   | |||
| 155 | 155 | { | |
| 156 | 156 | boost::shared_ptr<JSONArrayBase> valuePair(new JSONArrayBase()); | |
| 157 | 157 | valuesArray->addElement("", valuePair); | |
| 158 | boost::shared_ptr<JSONValue<int> > timeVal(new JSONValue<int>(iValue->getTimeStamp().secondsSinceEpoch())); | ||
| 158 | DateTime tmp_date = iValue->getTimeStamp(); | ||
| 159 | boost::shared_ptr<JSONValue<int> > timeVal(new JSONValue<int>(tmp_date.fromUTC().secondsSinceEpoch())); | ||
| 159 | 160 | boost::shared_ptr<JSONValue<double> > valueVal(new JSONValue<double>(iValue->getValue())); | |
| 160 | 161 | valuePair->addElement("", timeVal); | |
| 161 | 162 | valuePair->addElement("", valueVal); | |
| … | … | ||
| 239 | 239 | modulator->addProperty("dsid", dsMeter->getDSID().toString()); | |
| 240 | 240 | modulator->addProperty("value", isEnergy ? dsMeter->getCachedEnergyMeterValue() : dsMeter->getCachedPowerConsumption()); | |
| 241 | 241 | ||
| 242 | modulator->addProperty("date", isEnergy ? dsMeter->getCachedEnergyMeterTimeStamp().toString() : dsMeter->getCachedPowerConsumptionTimeStamp().toString()); | ||
| 242 | DateTime temp_date = isEnergy ? dsMeter->getCachedEnergyMeterTimeStamp() : dsMeter->getCachedPowerConsumptionTimeStamp(); | ||
| 243 | modulator->addProperty("date", temp_date.fromUTC().toString()); | ||
| 243 | 244 | ||
| 244 | 245 | modulators->addElement("", modulator); | |
| 245 | 246 | } catch (std::runtime_error&) { |
core/web/handler/systemrequesthandler.cpp
(1 / 1)
|   | |||
| 37 | 37 | return success(DSS::getInstance()->versionString()); | |
| 38 | 38 | } else if (_request.getMethod() == "time") { | |
| 39 | 39 | std::stringstream s; | |
| 40 | s << DateTime().secondsSinceEpoch(); | ||
| 40 | s << DateTime().fromUTC().secondsSinceEpoch(); | ||
| 41 | 41 | return success(s.str()); | |
| 42 | 42 | } | |
| 43 | 43 | throw std::runtime_error("Unhandled function"); |

