public byte[] encodeDeviceStreamData(IDeviceStreamData streamData) throws SiteWhereException { try { ProtobufMarshaler.DeviceStreamData.Builder builder = ProtobufMarshaler.DeviceStreamData.newBuilder(); builder.setStreamId(streamData.getStreamId()); builder.setSequenceNumber(streamData.getSequenceNumber()); builder.setData(ByteString.copyFrom(streamData.getData())); builder.setEventData(createDeviceEventData(streamData)); ProtobufMarshaler.DeviceStreamData pb = builder.build(); ByteArrayOutputStream out = new ByteArrayOutputStream(); pb.writeTo(out); return out.toByteArray(); } catch (IOException e) { throw new SiteWhereException("Unable to marshal device alert.", e); } }
/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target * @param isNested */ public static void toDocument(IDeviceStreamData source, Document target, boolean isNested) { MongoDeviceEvent.toDocument(source, target, isNested); target.append(PROP_STREAM_ID, source.getStreamId()); target.append(PROP_SEQUENCE_NUMBER, source.getSequenceNumber()); target.append(PROP_DATA, source.getData()); }
if (!current.getStreamId().equals(streamId)) { continue;