@Override public void createLocation(String assignmentToken, double latitude, double longitude, double elevation, boolean updateState) throws SiteWhereException { DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setLatitude(latitude); location.setLongitude(longitude); location.setElevation(elevation); location.setEventDate(new Date()); location.setUpdateState(updateState); getDeviceEventManagement().addDeviceLocation(assignmentToken, location); }
@Override public void createLocation(IDeviceAssignment assignment, double latitude, double longitude, double elevation, boolean updateState) throws SiteWhereException { DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setLatitude(latitude); location.setLongitude(longitude); location.setElevation(elevation); location.setEventDate(new Date()); location.setUpdateState(updateState); getDeviceEventManagement().addDeviceLocations(assignment.getId(), location); }
public Object generate() throws SiteWhereException { DeviceLocationCreateRequest request = new DeviceLocationCreateRequest(); request.setLatitude(ExampleData.EVENT_LOCATION1.getLatitude()); request.setLongitude(ExampleData.EVENT_LOCATION1.getLongitude()); request.setElevation(ExampleData.EVENT_LOCATION1.getElevation()); request.setEventDate(new Date()); request.setUpdateState(true); return request; } }
public Object generate() throws SiteWhereException { DeviceEventBatch batch = new DeviceEventBatch(); batch.setHardwareId(ExampleData.TRACKER.getHardwareId()); DeviceMeasurementsCreateRequest mx = new DeviceMeasurementsCreateRequest(); mx.setMeasurements(ExampleData.EVENT_MEASUREMENT1.getMeasurements()); mx.setEventDate(new Date()); mx.setUpdateState(true); batch.getMeasurements().add(mx); DeviceLocationCreateRequest loc = new DeviceLocationCreateRequest(); loc.setLatitude(ExampleData.EVENT_LOCATION1.getLatitude()); loc.setLongitude(ExampleData.EVENT_LOCATION1.getLongitude()); loc.setElevation(ExampleData.EVENT_LOCATION1.getElevation()); loc.setEventDate(new Date()); loc.setUpdateState(true); batch.getLocations().add(loc); DeviceAlertCreateRequest alert = new DeviceAlertCreateRequest(); alert.setSource(ExampleData.EVENT_ALERT1.getSource()); alert.setType(ExampleData.EVENT_ALERT1.getType()); alert.setLevel(ExampleData.EVENT_ALERT1.getLevel()); alert.setMessage(ExampleData.EVENT_ALERT1.getMessage()); alert.setEventDate(new Date()); alert.setUpdateState(true); batch.getAlerts().add(alert); return batch; } }
/** * Send a location event request via JSON/MQTT. * * @throws SiteWhereException */ public void sendLocationOverMqtt() throws SiteWhereException { DeviceRequest request = new DeviceRequest(); request.setDeviceToken("39430-GALAXYTAB3-7481908"); request.setType(Type.DeviceLocation); DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setEventDate(new Date()); location.setLatitude(34.10469794977326); location.setLongitude(-84.23966646194458); location.setElevation(0.0); Map<String, String> metadata = new HashMap<String, String>(); metadata.put("fromMQTT", "true"); location.setMetadata(metadata); location.setUpdateState(true); request.setRequest(location); try { String payload = MarshalUtils.PRETTY_MAPPER.writeValueAsString(request); connection.publish("SiteWhere/default/input/json", payload.getBytes(), QoS.AT_MOST_ONCE, false); } catch (JsonProcessingException e) { throw new SiteWhereException(e); } catch (Exception e) { throw new SiteWhereException(e); } }
metadata.put("metadata", "value"); location.setMetadata(metadata); location.setUpdateState(true); request.getLocations().add(location); mx.setValue(123.45); location.setMetadata(metadata); location.setUpdateState(true); request.getMeasurements().add(mx); alert.setLevel(AlertLevel.Error); location.setMetadata(metadata); location.setUpdateState(true); request.getAlerts().add(alert);
request.setUpdateState(location.getUpdateState());
request.setUpdateState(location.getUpdateState().getValue());