public Object generate() throws SiteWhereException { DeviceAlertCreateRequest request = new DeviceAlertCreateRequest(); request.setSource(ExampleData.EVENT_ALERT1.getSource()); request.setType(ExampleData.EVENT_ALERT1.getType()); request.setLevel(ExampleData.EVENT_ALERT1.getLevel()); request.setMessage(ExampleData.EVENT_ALERT1.getMessage()); request.setEventDate(new Date()); request.setUpdateState(true); return request; } }
((DeviceAlertCreateRequest) alertReq).setEventDate(new Date());
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; } }
@Override public void onLocation(IDeviceEventContext context, IDeviceLocation location) throws SiteWhereException { for (ZoneTest test : zoneTests) { Polygon poly = getZonePolygon(test.getZoneToken()); ZoneContainment containment = (poly.contains(GeoUtils.createPointForLocation(location))) ? ZoneContainment.Inside : ZoneContainment.Outside; if (test.getCondition() == containment) { DeviceAlertCreateRequest alert = new DeviceAlertCreateRequest(); alert.setType(test.getAlertType()); alert.setLevel(test.getAlertLevel()); alert.setMessage(test.getAlertMessage()); alert.setUpdateState(false); alert.setEventDate(new Date()); getDeviceEventManagement().addDeviceAlerts(location.getDeviceAssignmentId(), alert); } } }
alert.setType("engine.overheat"); alert.setMessage("eeeeyyyyyy!"); alert.setEventDate(new Date(System.currentTimeMillis() - (10 * 60 * 1000))); Map<String, String> metadata = new HashMap<String, String>(); metadata.put("name1", "value1");
@Override public void onLocationNotFiltered(IDeviceLocation location) throws SiteWhereException { for (ZoneTest test : zoneTests) { Polygon poly = getZonePolygon(test.getZoneToken()); ZoneContainment containment = (poly.contains(GeoUtils.createPointForLocation(location))) ? ZoneContainment.Inside : ZoneContainment.Outside; if (test.getCondition() == containment) { DeviceAlertCreateRequest alert = new DeviceAlertCreateRequest(); alert.setType(test.getAlertType()); alert.setLevel(test.getAlertLevel()); alert.setMessage(test.getAlertMessage()); alert.setUpdateState(false); alert.setEventDate(new Date()); SiteWhere.getServer().getDeviceEventManagement(getTenant()) .addDeviceAlert(location.getDeviceAssignmentToken(), alert); } } }
request.setEventDate(new Date(alert.getEventDate())); } else { request.setEventDate(new Date());
request.setEventDate(new Date(alert.getEventDate().getValue())); } else { request.setEventDate(new Date());