public Builder(double latitude, double longitude) { request.setLatitude(latitude); request.setLongitude(longitude); request.setElevation(0.0); }
public Builder(double latitude, double longitude) { request.setLatitude(latitude); request.setLongitude(longitude); request.setElevation(0.0); }
@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); } }
/** * Convert device location create request from GRPC to API. * * @param grpc * @return * @throws SiteWhereException */ public static DeviceLocationCreateRequest asApiDeviceLocationCreateRequest(GDeviceLocationCreateRequest grpc) throws SiteWhereException { DeviceLocationCreateRequest api = new DeviceLocationCreateRequest(); api.setLatitude(grpc.hasLatitude() ? grpc.getLatitude().getValue() : null); api.setLongitude(grpc.hasLongitude() ? grpc.getLongitude().getValue() : null); api.setElevation(grpc.hasElevation() ? grpc.getElevation().getValue() : null); EventModelConverter.copyApiDeviceEventCreateRequest(grpc.getEvent(), api); return api; }
@Test public void testAddDeviceLocation() throws Exception { CoapClient client = createClientFor(getBaseDeviceUrl() + "/locations"); DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setLatitude(33.7490); location.setLongitude(-84.3880); location.setElevation(0.0); handleResponse(client.post(MarshalUtils.marshalJson(location), MediaTypeRegistry.APPLICATION_JSON)); }
location.setEventDate(new Date()); location.setLatitude(34.10469794977326); location.setLongitude(-84.23966646194458); location.setElevation(0.0); Map<String, String> metadata = new HashMap<String, String>();
DeviceLocationCreateRequest request = new DeviceLocationCreateRequest(); request.setLatitude(location.getLatitude()); request.setLongitude(location.getLongitude()); request.setElevation(location.getElevation());
DeviceLocationCreateRequest request = new DeviceLocationCreateRequest(); request.setLatitude(location.getLatitude().getValue()); request.setLongitude(location.getLongitude().getValue()); request.setElevation(location.getElevation().getValue());