/** * Indicates a location event. * * @return */ public boolean isLocation() { return event.getEventType() == DeviceEventType.Location; }
/** * Indicates a location event. * * @return */ public boolean isLocation() { return event.getEventType() == DeviceEventType.Location; }
/** * Indicates a command invocation event. * * @return */ public boolean isCommandInvocation() { return event.getEventType() == DeviceEventType.CommandInvocation; }
/** * Indicates a measurements event. * * @return */ public boolean isMeasurements() { return event.getEventType() == DeviceEventType.Measurements; }
/** * Returns true if event is an alert. * * @return */ public boolean isAlert() { return event.getEventType() == DeviceEventType.Alert; }
/** * Indicates a command response event. * * @return */ public boolean isCommandResponse() { return event.getEventType() == DeviceEventType.CommandResponse; }
/** * Indicates a command invocation event. * * @return */ public boolean isCommandInvocation() { return event.getEventType() == DeviceEventType.CommandInvocation; }
/** * Indicates a command response event. * * @return */ public boolean isCommandResponse() { return event.getEventType() == DeviceEventType.CommandResponse; }
/** * Indicates a measurement event. * * @return */ public boolean isMeasurement() { return event.getEventType() == DeviceEventType.Measurement; }
/** * Returns true if event is an alert. * * @return */ public boolean isAlert() { return event.getEventType() == DeviceEventType.Alert; }
@Override public DeviceEventType getEventType() { return getWrapped().getEventType(); }
@Override public DeviceEventType getEventType() { return getWrapped().getEventType(); }
/** * Attempts to get the named measurement if the event is a measurements * event. * * @param name * @return */ public Double getMeasurement(String name) { if (event.getEventType() != DeviceEventType.Measurements) { return null; } IDeviceMeasurements mxs = (IDeviceMeasurements) event; Double mx = mxs.getMeasurement(name); if (mx == null) { return null; } return mx; }
switch (event.getEventType()) { case Measurement: { return MongoDeviceMeasurement.toDocument((IDeviceMeasurement) event, false); throw new SiteWhereException("Event type not handled: " + event.getEventType());
switch (event.getEventType()) { case Location: { updateWithLocation(state, (IDeviceLocation) event); LOGGER.warn("Unhandle event type for state: " + event.getEventType().name());
/** * Create object that stores common device event data. * * @param event * @return */ protected ProtobufMarshaler.DeviceEventData createDeviceEventData(IDeviceEvent event) { ProtobufMarshaler.DeviceEventData.Builder builder = ProtobufMarshaler.DeviceEventData.newBuilder(); builder.setId(event.getId()); builder.setEventType(marshalEventType(event.getEventType())); builder.setSiteToken(event.getSiteToken()); builder.setDeviceAssignmentToken(event.getDeviceAssignmentToken()); builder.setAssignmentType(marshalAssignmentType(event.getAssignmentType())); builder.setAssetModuleId(event.getAssetModuleId()); builder.setAssetId(event.getAssetId()); builder.setEventDate(event.getEventDate().getTime()); builder.setReceivedDate(event.getReceivedDate().getTime()); builder.addAllMetadata(asMetadataEntries(event.getMetadata())); return builder.build(); }
/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target * @param isNested */ public static void toDocument(IDeviceEvent source, Document target, boolean isNested) { target.append(PROP_ID, source.getId()); // Only set if there is a value (sparse index). if (source.getAlternateId() != null) { target.append(PROP_ALTERNATE_ID, source.getAlternateId()); } target.append(PROP_EVENT_TYPE, source.getEventType().name()); target.append(PROP_DEVICE_ID, source.getDeviceId()); target.append(PROP_DEVICE_ASSIGNMENT_ID, source.getDeviceAssignmentId()); target.append(PROP_CUSTOMER_ID, source.getCustomerId()); target.append(PROP_AREA_ID, source.getAreaId()); target.append(PROP_ASSET_ID, source.getAssetId()); target.append(PROP_EVENT_DATE, source.getEventDate()); target.append(PROP_RECEIVED_DATE, source.getReceivedDate()); MongoMetadataProvider.toDocument(source, target); }
/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target * @param isNested */ public static void toDocument(IDeviceEvent source, Document target, boolean isNested) { target.append("_id", (source.getId() != null) ? new ObjectId(source.getId()) : new ObjectId()); // Only set if there is a value (sparse index). if (source.getAlternateId() != null) { target.append(PROP_ALTERNATE_ID, source.getAlternateId()); } target.append(PROP_EVENT_TYPE, source.getEventType().name()); target.append(PROP_SITE_TOKEN, source.getSiteToken()); target.append(PROP_DEVICE_ASSIGNMENT_TOKEN, source.getDeviceAssignmentToken()); target.append(PROP_DEVICE_ASSIGNMENT_TYPE, source.getAssignmentType().name()); target.append(PROP_ASSET_MODULE_ID, source.getAssetModuleId()); target.append(PROP_ASSET_ID, source.getAssetId()); target.append(PROP_EVENT_DATE, source.getEventDate()); target.append(PROP_RECEIVED_DATE, source.getReceivedDate()); MongoMetadataProvider.toDocument(source, target); }
/** * Bind fields from a device event to an existing {@link BoundStatement}. * * @param bound * @param event * @throws SiteWhereException */ public static void bindEventFields(BoundStatement bound, IDeviceEvent event) throws SiteWhereException { bound.setUUID(FIELD_DEVICE_ID, event.getDeviceId()); bound.setUUID(FIELD_EVENT_ID, event.getId()); if (event.getAlternateId() != null) { bound.setString(FIELD_ALTERNATE_ID, event.getAlternateId()); } bound.setByte(FIELD_EVENT_TYPE, getIndicatorForEventType(event.getEventType())); bound.setUUID(FIELD_ASSIGNMENT_ID, event.getDeviceAssignmentId()); if (event.getCustomerId() != null) { bound.setUUID(FIELD_CUSTOMER_ID, event.getCustomerId()); } if (event.getAreaId() != null) { bound.setUUID(FIELD_AREA_ID, event.getAreaId()); } if (event.getAssetId() != null) { bound.setUUID(FIELD_ASSET_ID, event.getAssetId()); } bound.setTimestamp(FIELD_EVENT_DATE, event.getEventDate()); bound.setTimestamp(FIELD_RECEIVED_DATE, event.getReceivedDate()); }
grpc.setAlternateId(GOptionalString.newBuilder().setValue(api.getAlternateId()).build()); grpc.setEventType(EventModelConverter.asGrpcDeviceEventType(api.getEventType())); grpc.setDeviceId(CommonModelConverter.asGrpcUuid(api.getDeviceId())); grpc.setDeviceAssignmentId(CommonModelConverter.asGrpcUuid(api.getDeviceAssignmentId()));