├── .gitattributes ├── README.md └── deepstream-ign-rtsp-web ├── README ├── __pycache__ ├── sparkplug_b.cpython-36.pyc └── sparkplug_b_pb2.cpython-36.pyc ├── client_libraries ├── c │ ├── Makefile │ ├── include │ │ ├── pb.h │ │ ├── pb_common.h │ │ ├── pb_decode.h │ │ ├── pb_encode.h │ │ ├── tahu.h │ │ └── tahu.pb.h │ ├── readme.txt │ ├── src │ │ ├── pb_common.c │ │ ├── pb_decode.c │ │ ├── pb_encode.c │ │ ├── tahu.c │ │ ├── tahu.pb │ │ ├── tahu.pb.c │ │ └── tahu.pb.h │ ├── tahu.options │ ├── test.sh │ └── test │ │ ├── .gitignore │ │ └── test.c ├── c_sharp │ ├── readme.txt │ └── src │ │ └── SparkplugBCSharp.cs ├── java │ ├── pom.xml │ ├── readme.txt │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── eclipse │ │ │ │ └── tahu │ │ │ │ ├── SparkplugException.java │ │ │ │ ├── SparkplugInvalidTypeException.java │ │ │ │ ├── SparkplugParsingException.java │ │ │ │ ├── json │ │ │ │ ├── DataSetDeserializer.java │ │ │ │ ├── DeserializerModifier.java │ │ │ │ ├── DeserializerModule.java │ │ │ │ ├── FileSerializer.java │ │ │ │ ├── JsonValidator.java │ │ │ │ └── MetricDeserializer.java │ │ │ │ ├── message │ │ │ │ ├── PayloadDecoder.java │ │ │ │ ├── PayloadEncoder.java │ │ │ │ ├── SparkplugBPayloadDecoder.java │ │ │ │ ├── SparkplugBPayloadEncoder.java │ │ │ │ └── model │ │ │ │ │ ├── DataSet.java │ │ │ │ │ ├── DataSetDataType.java │ │ │ │ │ ├── File.java │ │ │ │ │ ├── Message.java │ │ │ │ │ ├── MessageType.java │ │ │ │ │ ├── MetaData.java │ │ │ │ │ ├── Metric.java │ │ │ │ │ ├── MetricDataType.java │ │ │ │ │ ├── Parameter.java │ │ │ │ │ ├── ParameterDataType.java │ │ │ │ │ ├── PropertyDataType.java │ │ │ │ │ ├── PropertySet.java │ │ │ │ │ ├── PropertyValue.java │ │ │ │ │ ├── Row.java │ │ │ │ │ ├── SparkplugBPayload.java │ │ │ │ │ ├── Template.java │ │ │ │ │ ├── Topic.java │ │ │ │ │ └── Value.java │ │ │ │ ├── protobuf │ │ │ │ └── SparkplugBProto.java │ │ │ │ └── util │ │ │ │ ├── CompressionAlgorithm.java │ │ │ │ ├── GZipUtil.java │ │ │ │ ├── MessageUtil.java │ │ │ │ ├── PayloadUtil.java │ │ │ │ ├── TopicUtil.java │ │ │ │ └── ValidationUtils.java │ │ └── resources │ │ │ └── payload.json │ │ └── test │ │ └── java │ │ └── org │ │ └── eclipse │ │ └── tahu │ │ ├── test │ │ └── SparkplugTest.java │ │ └── util │ │ └── PayloadUtilTest.java ├── javascript │ ├── node-red-contrib-sparkplug │ │ ├── README.md │ │ ├── package.json │ │ └── sparkplug │ │ │ ├── sparkplug.html │ │ │ └── sparkplug.js │ ├── sparkplug-client │ │ ├── LICENSE │ │ ├── README.md │ │ ├── index.js │ │ └── package.json │ └── sparkplug-payload │ │ ├── README.md │ │ ├── index.js │ │ ├── lib │ │ └── sparkplugbpayload.js │ │ └── package.json └── python │ ├── __init__.py │ ├── __pycache__ │ ├── sparkplug_b.cpython-36.pyc │ └── sparkplug_b_pb2.cpython-36.pyc │ ├── readme.txt │ ├── sparkplug_b.py │ ├── sparkplug_b.pyc │ ├── sparkplug_b_pb2.py │ └── sparkplug_b_pb2.pyc ├── deepstream_ign_3_yolo_RTSP_All.py ├── deepstream_ignition_rtsp_out.py ├── deepstream_ignition_usb.py ├── deepstream_ignition_usb_rtsp.py ├── deepstream_test_3.py ├── dstest1_pgie_config.txt ├── sparkplug_b.py ├── sparkplug_b.pyc ├── sparkplug_b ├── raspberry_pi_examples │ ├── java │ │ ├── THIRD-PARTY.txt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ └── eclipse │ │ │ │ └── tahu │ │ │ │ ├── SparkplugRaspberryPiExample.java │ │ │ │ ├── pi │ │ │ │ ├── dio │ │ │ │ │ ├── DigitalOutputPin.java │ │ │ │ │ ├── DioException.java │ │ │ │ │ ├── DioLibrary.java │ │ │ │ │ ├── DioPin.java │ │ │ │ │ ├── PinDirection.java │ │ │ │ │ └── Pins.java │ │ │ │ └── system │ │ │ │ │ ├── BoardModels.java │ │ │ │ │ ├── SystemInfo.java │ │ │ │ │ └── SystemInfoException.java │ │ │ │ └── pibrella │ │ │ │ ├── Pibrella.java │ │ │ │ ├── PibrellaButton.java │ │ │ │ ├── PibrellaBuzzer.java │ │ │ │ ├── PibrellaInputPin.java │ │ │ │ ├── PibrellaInputPins.java │ │ │ │ ├── PibrellaLED.java │ │ │ │ ├── PibrellaLEDs.java │ │ │ │ ├── PibrellaOutputPin.java │ │ │ │ ├── PibrellaOutputPins.java │ │ │ │ └── PibrellaPins.java │ │ │ └── resources │ │ │ └── libdio.so │ └── python │ │ └── example.py ├── sparkplug_b.json ├── sparkplug_b.proto ├── sparkplug_b_c_sharp.proto ├── stand_alone_examples │ ├── c │ │ ├── template_as_custom_props │ │ │ ├── Makefile │ │ │ └── example.c │ │ └── udt_example │ │ │ ├── Makefile │ │ │ └── example.c │ ├── java │ │ ├── THIRD-PARTY.txt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── tahu │ │ │ └── SparkplugExample.java │ ├── java_device_timestamp │ │ ├── THIRD-PARTY.txt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── tahu │ │ │ └── SparkplugExample.java │ ├── java_edge_node_control │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── tahu │ │ │ └── SparkplugExample.java │ ├── java_records │ │ ├── THIRD-PARTY.txt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── tahu │ │ │ └── SparkplugRecordsExample.java │ ├── java_udt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── tahu │ │ │ └── SparkplugExample.java │ ├── js │ │ ├── example.js │ │ └── package.json │ ├── nodered │ │ ├── emulated-device.js │ │ └── package.json │ └── python │ │ ├── THIRD-PARTY.txt │ │ ├── example (copy).py │ │ └── example.py └── tools │ └── java_sparkplug_b_listener │ ├── THIRD-PARTY.txt │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── org │ │ └── eclipse │ │ └── tahu │ │ └── SparkplugListener.java │ └── resources │ └── log4j.properties ├── sparkplug_b_pb2.py └── sparkplug_b_pb2.pyc /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Nvidia Deepstream5+Ignition Maker+Metatdata+Python 3 | 4 | Here is the items and steps you will need to run Nvidia deepstream5 5 | extract metadata and send to Ignition maker using Python. 6 | 7 | 8 | 9 | Here are links to video tutorials to get youre Nano 10 | or Xavier NX setup. 11 | 12 | 13 | 14 | 1.Link to setup Ignition Maker. They have a 64 bit Ignition maker 15 | now so that is another option. 16 | 17 | https://youtu.be/0kvurkDSYt4 18 | 19 | 20 | 21 | 2.Link to setup MySQL database if you want a Database 22 | 23 | https://youtu.be/_D5eCn2LCZY 24 | 25 | 26 | 27 | 3.Link to setup Sparkplug. This will be used as the MQTT 28 | link from Deepstream to Ignition Maker 29 | 30 | https://youtu.be/QJ4EBMoA2sw 31 | 32 | 33 | 34 | 4.Link to instruction on converting Deepstream RTSP outstream 35 | to HTTP stream. 36 | To use in Ignition Maker video player. 37 | 38 | https://youtu.be/3VEvOL_32L8 39 | 40 | 41 | 42 | 43 | 5.Download Deepstream Python Bindings and install at 44 | "/opt/nvidia/deepstream/deepstream-5.0/sources" 45 | 46 | https://github.com/NVIDIA-AI-IOT/deepstream_python_apps 47 | 48 | 49 | 50 | 51 | 6.clone this repo and install and install at 52 | 53 | "/opt/nvidia/deepstream/deepstream-5.0/sources/deepstream_python_apps-1.0/apps" 54 | 55 | 56 | 57 | 7.cd into "/opt/nvidia/deepstream/deepstream-5.0/sources/deepstream_python_apps-1.0/apps/deepstream-ign-rtsp-web" 58 | 59 | 60 | 61 | 8.There are 3 Python Examples in the this repo 62 | 63 | 64 | 9.This sends out a Deepstream RTSP stream from a webcam and sends Deepstream metadata to ignition Maker 65 | 66 | $python3 deepstream_ignition_usb_rtsp.py /dev/video0 67 | 68 | 69 | 70 | 10.This Shows the output of a Deepstream webcam and sends Deepstream metadata to ignition Maker 71 | 72 | $python3 deepstream_ignition_usb.py /dev/video0 73 | 74 | 75 | 76 | 11.This Shows the output of a .h264 file and sends Deepstream metadata to ignition Maker 77 | 78 | $python3 deepstream_ignition_rtsp_out.py /opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 79 | 80 | 81 | 82 | When These Scripts are ran the will automaticly generate the tags in ignition. 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/README: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | ################################################################################ 22 | 23 | Prequisites: 24 | - DeepStreamSDK 5.0 25 | - Python 3.6 26 | - Gst-python 27 | - GstRtspServer 28 | 29 | Installing GstRtspServer and instrospection typelib 30 | =================================================== 31 | $ sudo apt update 32 | $ sudo apt-get install libgstrtspserver-1.0-0 gstreamer1.0-rtsp 33 | For gst-rtsp-server (and other GStreamer stuff) to be accessible in 34 | Python through gi.require_version(), it needs to be built with 35 | gobject-introspection enabled (libgstrtspserver-1.0-0 is already). 36 | Yet, we need to install the introspection typelib package: 37 | $ sudo apt-get install libgirepository1.0-dev 38 | $ sudo apt-get install gobject-introspection gir1.2-gst-rtsp-server-1.0 39 | 40 | To get test app usage information: 41 | $ python3 deepstream_test1_rtsp_out.py -h 42 | 43 | To run the test app with default settings: 44 | $ python3 deepstream_test1_rtsp_out.py -i 45 | 46 | Default RTSP streaming location: 47 | rtsp://:8554/ds-test 48 | 49 | This document shall describe the sample deepstream-test1-rtsp-out application. 50 | 51 | It is meant for simple demonstration of how to use the various DeepStream SDK 52 | elements in the pipeline and extract meaningful insights from a video stream. 53 | The output video data with inference output overlayed is encoded and streamed 54 | using GstRtspServer. 55 | 56 | This sample creates instance of "nvinfer" element. Instance of 57 | the "nvinfer" uses TensorRT API to execute inferencing on a model. Using a 58 | correct configuration for a nvinfer element instance is therefore very 59 | important as considerable behaviors of the instance are parameterized 60 | through these configs. 61 | 62 | For reference, here are the config files used for this sample : 63 | 1. The 4-class detector (referred to as pgie in this sample) uses 64 | dstest1_pgie_config.txt 65 | 66 | In this sample, we first create one instance of "nvinfer", referred as the pgie. 67 | This is our 4 class detector and it detects for "Vehicle , RoadSign, TwoWheeler, 68 | Person". 69 | nvinfer element attach some MetaData to the buffer. By attaching 70 | the probe function at the end of the pipeline, one can extract meaningful 71 | information from this inference. Please refer the "osd_sink_pad_buffer_probe" 72 | function in the sample code. For details on the Metadata format, refer to the 73 | file "gstnvdsmeta.h" 74 | 75 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/__pycache__/sparkplug_b.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/__pycache__/sparkplug_b.cpython-36.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/__pycache__/sparkplug_b_pb2.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/__pycache__/sparkplug_b_pb2.cpython-36.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/Makefile: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014-2019 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | CC := gcc 15 | NAME := tahu 16 | SNAME := lib/lib$(NAME).a 17 | DNAME := lib/lib$(NAME).so 18 | SRC := $(wildcard src/*.c) 19 | OBJ := $(SRC:.c=.o) 20 | #CFLAGS := -Wall -g3 -fPIC -Iinclude/ 21 | CFLAGS := -g -g3 -fPIC -Iinclude/ 22 | LDFLAGS := -L. 23 | #LDLIBS := -l$(...) 24 | 25 | TEST := test 26 | TEST_OBJ := test/test.c 27 | LD_TEST := -Llib -L/usr/local/lib -l$(NAME) 28 | 29 | .PHONY: all clean test re 30 | 31 | all: $(SNAME) $(DNAME) $(TEST) 32 | 33 | $(SNAME): $(OBJ) 34 | mkdir -p lib 35 | $(AR) $(ARFLAGS) $@ $^ 36 | 37 | $(DNAME): LDFLAGS += -shared 38 | $(DNAME): $(OBJ) 39 | $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) 40 | 41 | $(TEST): 42 | $(CC) $(CFLAGS) -o test/test_static $(TEST_OBJ) $(SNAME) -lmosquitto 43 | $(CC) $(CFLAGS) $(LD_TEST) -o test/test_dynamic $(TEST_OBJ) -l$(NAME) -lmosquitto 44 | 45 | clean: 46 | $(RM) $(OBJ) 47 | $(RM) $(SNAME) $(DNAME) 48 | $(RM) test/test_static test/test_dynamic 49 | 50 | re: clean all 51 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/include/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Iterator for pb_field_t list */ 15 | struct pb_field_iter_s { 16 | const pb_field_t *start; /* Start of the pb_field_t array */ 17 | const pb_field_t *pos; /* Current position of the iterator */ 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ 19 | void *dest_struct; /* Pointer to start of the structure */ 20 | void *pData; /* Pointer to current field value */ 21 | void *pSize; /* Pointer to count/has field */ 22 | }; 23 | typedef struct pb_field_iter_s pb_field_iter_t; 24 | 25 | /* Initialize the field iterator structure to beginning. 26 | * Returns false if the message type is empty. */ 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); 28 | 29 | /* Advance the iterator to the next field. 30 | * Returns false when the iterator wraps back to the first field. */ 31 | bool pb_field_iter_next(pb_field_iter_t *iter); 32 | 33 | /* Advance the iterator until it points at a field with the given tag. 34 | * Returns false if no such field exists. */ 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/include/pb_decode.h: -------------------------------------------------------------------------------- 1 | /* pb_decode.h: Functions to decode protocol buffers. Depends on pb_decode.c. 2 | * The main function is pb_decode. You also need an input stream, and the 3 | * field descriptions created by nanopb_generator.py. 4 | */ 5 | 6 | #ifndef PB_DECODE_H_INCLUDED 7 | #define PB_DECODE_H_INCLUDED 8 | 9 | #include "pb.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Structure for defining custom input streams. You will need to provide 16 | * a callback function to read the bytes from your storage, which can be 17 | * for example a file or a network socket. 18 | * 19 | * The callback must conform to these rules: 20 | * 21 | * 1) Return false on IO errors. This will cause decoding to abort. 22 | * 2) You can use state to store your own data (e.g. buffer pointer), 23 | * and rely on pb_read to verify that no-body reads past bytes_left. 24 | * 3) Your callback may be used with substreams, in which case bytes_left 25 | * is different than from the main stream. Don't use bytes_left to compute 26 | * any pointers. 27 | */ 28 | struct pb_istream_s 29 | { 30 | #ifdef PB_BUFFER_ONLY 31 | /* Callback pointer is not used in buffer-only configuration. 32 | * Having an int pointer here allows binary compatibility but 33 | * gives an error if someone tries to assign callback function. 34 | */ 35 | int *callback; 36 | #else 37 | bool (*callback)(pb_istream_t *stream, pb_byte_t *buf, size_t count); 38 | #endif 39 | 40 | void *state; /* Free field for use by callback implementation */ 41 | size_t bytes_left; 42 | 43 | #ifndef PB_NO_ERRMSG 44 | const char *errmsg; 45 | #endif 46 | }; 47 | 48 | /*************************** 49 | * Main decoding functions * 50 | ***************************/ 51 | 52 | /* Decode a single protocol buffers message from input stream into a C structure. 53 | * Returns true on success, false on any failure. 54 | * The actual struct pointed to by dest must match the description in fields. 55 | * Callback fields of the destination structure must be initialized by caller. 56 | * All other fields will be initialized by this function. 57 | * 58 | * Example usage: 59 | * MyMessage msg = {}; 60 | * uint8_t buffer[64]; 61 | * pb_istream_t stream; 62 | * 63 | * // ... read some data into buffer ... 64 | * 65 | * stream = pb_istream_from_buffer(buffer, count); 66 | * pb_decode(&stream, MyMessage_fields, &msg); 67 | */ 68 | bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); 69 | 70 | /* Same as pb_decode, except does not initialize the destination structure 71 | * to default values. This is slightly faster if you need no default values 72 | * and just do memset(struct, 0, sizeof(struct)) yourself. 73 | * 74 | * This can also be used for 'merging' two messages, i.e. update only the 75 | * fields that exist in the new message. 76 | * 77 | * Note: If this function returns with an error, it will not release any 78 | * dynamically allocated fields. You will need to call pb_release() yourself. 79 | */ 80 | bool pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); 81 | 82 | /* Same as pb_decode, except expects the stream to start with the message size 83 | * encoded as varint. Corresponds to parseDelimitedFrom() in Google's 84 | * protobuf API. 85 | */ 86 | bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); 87 | 88 | #ifdef PB_ENABLE_MALLOC 89 | /* Release any allocated pointer fields. If you use dynamic allocation, you should 90 | * call this for any successfully decoded message when you are done with it. If 91 | * pb_decode() returns with an error, the message is already released. 92 | */ 93 | void pb_release(const pb_field_t fields[], void *dest_struct); 94 | #endif 95 | 96 | 97 | /************************************** 98 | * Functions for manipulating streams * 99 | **************************************/ 100 | 101 | /* Create an input stream for reading from a memory buffer. 102 | * 103 | * Alternatively, you can use a custom stream that reads directly from e.g. 104 | * a file or a network socket. 105 | */ 106 | pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize); 107 | 108 | /* Function to read from a pb_istream_t. You can use this if you need to 109 | * read some custom header data, or to read data in field callbacks. 110 | */ 111 | bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); 112 | 113 | 114 | /************************************************ 115 | * Helper functions for writing field callbacks * 116 | ************************************************/ 117 | 118 | /* Decode the tag for the next field in the stream. Gives the wire type and 119 | * field tag. At end of the message, returns false and sets eof to true. */ 120 | bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof); 121 | 122 | /* Skip the field payload data, given the wire type. */ 123 | bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type); 124 | 125 | /* Decode an integer in the varint format. This works for bool, enum, int32, 126 | * int64, uint32 and uint64 field types. */ 127 | bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest); 128 | 129 | /* Decode an integer in the zig-zagged svarint format. This works for sint32 130 | * and sint64. */ 131 | bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest); 132 | 133 | /* Decode a fixed32, sfixed32 or float value. You need to pass a pointer to 134 | * a 4-byte wide C variable. */ 135 | bool pb_decode_fixed32(pb_istream_t *stream, void *dest); 136 | 137 | /* Decode a fixed64, sfixed64 or double value. You need to pass a pointer to 138 | * a 8-byte wide C variable. */ 139 | bool pb_decode_fixed64(pb_istream_t *stream, void *dest); 140 | 141 | /* Make a limited-length substream for reading a PB_WT_STRING field. */ 142 | bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream); 143 | void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream); 144 | 145 | #ifdef __cplusplus 146 | } /* extern "C" */ 147 | #endif 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/readme.txt: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014-2019 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | # To generate the base protobuf tahu NanoPB C library (using Protoc v2.6.1 and Nanopb v0.3.5) 15 | protoc --proto_path=../../ -otahu.pb ../../sparkplug_b/sparkplug_b.proto 16 | ~/nanopb/nanopb-0.3.5-linux-x86/generator/nanopb_generator.py -f tahu.options tahu.pb 17 | mv tahu.pb src/ 18 | mv tahu.pb.c src/ 19 | mv tahu.pb.h include/ 20 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/src/pb_common.c: -------------------------------------------------------------------------------- 1 | /* pb_common.c: Common support functions for pb_encode.c and pb_decode.c. 2 | * 3 | * 2014 Petteri Aimonen 4 | */ 5 | 6 | #include "pb_common.h" 7 | 8 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct) 9 | { 10 | iter->start = fields; 11 | iter->pos = fields; 12 | iter->required_field_index = 0; 13 | iter->dest_struct = dest_struct; 14 | iter->pData = (char*)dest_struct + iter->pos->data_offset; 15 | iter->pSize = (char*)iter->pData + iter->pos->size_offset; 16 | 17 | return (iter->pos->tag != 0); 18 | } 19 | 20 | bool pb_field_iter_next(pb_field_iter_t *iter) 21 | { 22 | const pb_field_t *prev_field = iter->pos; 23 | 24 | if (prev_field->tag == 0) 25 | { 26 | /* Handle empty message types, where the first field is already the terminator. 27 | * In other cases, the iter->pos never points to the terminator. */ 28 | return false; 29 | } 30 | 31 | iter->pos++; 32 | 33 | if (iter->pos->tag == 0) 34 | { 35 | /* Wrapped back to beginning, reinitialize */ 36 | (void)pb_field_iter_begin(iter, iter->start, iter->dest_struct); 37 | return false; 38 | } 39 | else 40 | { 41 | /* Increment the pointers based on previous field size */ 42 | size_t prev_size = prev_field->data_size; 43 | 44 | if (PB_HTYPE(prev_field->type) == PB_HTYPE_ONEOF && 45 | PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF) 46 | { 47 | /* Don't advance pointers inside unions */ 48 | prev_size = 0; 49 | iter->pData = (char*)iter->pData - prev_field->data_offset; 50 | } 51 | else if (PB_ATYPE(prev_field->type) == PB_ATYPE_STATIC && 52 | PB_HTYPE(prev_field->type) == PB_HTYPE_REPEATED) 53 | { 54 | /* In static arrays, the data_size tells the size of a single entry and 55 | * array_size is the number of entries */ 56 | prev_size *= prev_field->array_size; 57 | } 58 | else if (PB_ATYPE(prev_field->type) == PB_ATYPE_POINTER) 59 | { 60 | /* Pointer fields always have a constant size in the main structure. 61 | * The data_size only applies to the dynamically allocated area. */ 62 | prev_size = sizeof(void*); 63 | } 64 | 65 | if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED) 66 | { 67 | /* Count the required fields, in order to check their presence in the 68 | * decoder. */ 69 | iter->required_field_index++; 70 | } 71 | 72 | iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset; 73 | iter->pSize = (char*)iter->pData + iter->pos->size_offset; 74 | return true; 75 | } 76 | } 77 | 78 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag) 79 | { 80 | const pb_field_t *start = iter->pos; 81 | 82 | do { 83 | if (iter->pos->tag == tag && 84 | PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION) 85 | { 86 | /* Found the wanted field */ 87 | return true; 88 | } 89 | 90 | (void)pb_field_iter_next(iter); 91 | } while (iter->pos != start); 92 | 93 | /* Searched all the way back to start, and found nothing. */ 94 | return false; 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/src/tahu.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/c/src/tahu.pb -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/tahu.options: -------------------------------------------------------------------------------- 1 | org.eclipse.tahu.protobuf.Payload.body type:FT_POINTER 2 | org.eclipse.tahu.protobuf.Payload.metrics type:FT_POINTER 3 | org.eclipse.tahu.protobuf.Payload.uuid type:FT_POINTER 4 | org.eclipse.tahu.protobuf.Payload.DataSet.columns type:FT_POINTER 5 | org.eclipse.tahu.protobuf.Payload.DataSet.rows type:FT_POINTER 6 | org.eclipse.tahu.protobuf.Payload.DataSet.types type:FT_POINTER 7 | org.eclipse.tahu.protobuf.Payload.DataSet.DataSetValue.string_value type:FT_POINTER 8 | org.eclipse.tahu.protobuf.Payload.DataSet.Row.elements type:FT_POINTER 9 | org.eclipse.tahu.protobuf.Payload.MetaData.content_type type:FT_POINTER 10 | org.eclipse.tahu.protobuf.Payload.MetaData.description type:FT_POINTER 11 | org.eclipse.tahu.protobuf.Payload.MetaData.file_name type:FT_POINTER 12 | org.eclipse.tahu.protobuf.Payload.MetaData.file_type type:FT_POINTER 13 | org.eclipse.tahu.protobuf.Payload.MetaData.md5 type:FT_POINTER 14 | org.eclipse.tahu.protobuf.Payload.Metric.bytes_value type:FT_POINTER 15 | org.eclipse.tahu.protobuf.Payload.Metric.name type:FT_POINTER 16 | org.eclipse.tahu.protobuf.Payload.Metric.string_value type:FT_POINTER 17 | org.eclipse.tahu.protobuf.Payload.PropertySet.keys type:FT_POINTER 18 | org.eclipse.tahu.protobuf.Payload.PropertySet.values type:FT_POINTER 19 | org.eclipse.tahu.protobuf.Payload.PropertySetList.propertyset type:FT_POINTER 20 | org.eclipse.tahu.protobuf.Payload.PropertyValue.string_value type:FT_POINTER 21 | org.eclipse.tahu.protobuf.Payload.Template.metrics type:FT_POINTER 22 | org.eclipse.tahu.protobuf.Payload.Template.template_ref type:FT_POINTER 23 | org.eclipse.tahu.protobuf.Payload.Template.version type:FT_POINTER 24 | org.eclipse.tahu.protobuf.Payload.Template.parameters type:FT_POINTER 25 | org.eclipse.tahu.protobuf.Payload.Template.Parameter.name type:FT_POINTER 26 | org.eclipse.tahu.protobuf.Payload.Template.Parameter.string_value type:FT_POINTER 27 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/test.sh: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014-2019 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | #!/bin/sh 15 | 16 | #echo "Running static example..." 17 | #./test/test_static 18 | 19 | echo "" 20 | echo "Running dynamic example..." 21 | #echo "Starting LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" 22 | PWD=`pwd` 23 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/lib 24 | #echo "New LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" 25 | ./test/test_dynamic 26 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c/test/.gitignore: -------------------------------------------------------------------------------- 1 | test_dynamic.dSYM 2 | test_static.dSYM 3 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/c_sharp/readme.txt: -------------------------------------------------------------------------------- 1 | # To generate the base protobuf sparkplug_b Java library 2 | protoc --proto_path=../../ --csharp_out=src --csharp_opt=base_namespace=Org.Eclipse.Tahu.Protobuf ../../sparkplug_b/sparkplug_b_c_sharp.proto 3 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../pom.xml 23 | 24 | 25 | tahu-java 26 | jar 27 | Maven Quick Start Archetype 28 | http://maven.apache.org 29 | 30 | 31 | 32 | org.apache.commons 33 | commons-compress 34 | 1.18 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.codehaus.mojo 42 | license-maven-plugin 43 | 1.8 44 | 45 | 46 | add-third-party 47 | package 48 | 49 | add-third-party 50 | download-licenses 51 | 52 | 53 | true 54 | test 55 | (org.eclipse.tahu*) 56 | 57 | 58 | The Apache Software License, Version 59 | 2.0|Apache License, Version 2.0|Apache Public License 60 | 2.0|Apache License 2.0|Apache Software License - 61 | Version 2.0 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/readme.txt: -------------------------------------------------------------------------------- 1 | # To generate the base protobuf sparkplug_b Java library 2 | protoc --proto_path=../../ --java_out=src/main/java ../../sparkplug_b/sparkplug_b.proto 3 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/SparkplugException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu; 15 | 16 | /** 17 | * A Sparkplug Exception 18 | */ 19 | public class SparkplugException extends Exception { 20 | 21 | /** 22 | * Default constructor. 23 | */ 24 | public SparkplugException() { 25 | } 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param message an error message 31 | */ 32 | public SparkplugException(String message) { 33 | super(message); 34 | } 35 | 36 | /** 37 | * Constructor 38 | * 39 | * @param message an error message 40 | * @param exception an underlying exception 41 | */ 42 | public SparkplugException(String message, Throwable exception) { 43 | super(message, exception); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/SparkplugInvalidTypeException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu; 15 | 16 | /** 17 | * An Exception caused by an invalid type. 18 | */ 19 | public class SparkplugInvalidTypeException extends SparkplugException { 20 | 21 | private Class type; 22 | 23 | public SparkplugInvalidTypeException(Class type) { 24 | super("Invalid type " + type); 25 | this.type = type; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/SparkplugParsingException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu; 15 | 16 | /** 17 | * An Exception thrown if an error is encountered while parsing a payload or topic. 18 | */ 19 | public class SparkplugParsingException extends SparkplugException { 20 | 21 | /** 22 | * Constructor 23 | * 24 | * @param message an error message 25 | */ 26 | public SparkplugParsingException(String message) { 27 | super(message); 28 | } 29 | 30 | /** 31 | * Constructor 32 | * 33 | * @param message an error message 34 | * @param exception an underlying exception 35 | */ 36 | public SparkplugParsingException(String message, Throwable exception) { 37 | super(message, exception); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/DataSetDeserializer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | import java.io.IOException; 17 | import java.math.BigInteger; 18 | import java.util.ArrayList; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | import org.apache.log4j.LogManager; 23 | import org.apache.log4j.Logger; 24 | import org.eclipse.tahu.SparkplugException; 25 | import org.eclipse.tahu.message.model.DataSet; 26 | import org.eclipse.tahu.message.model.DataSetDataType; 27 | import org.eclipse.tahu.message.model.Row; 28 | import org.eclipse.tahu.message.model.Value; 29 | import org.eclipse.tahu.message.model.DataSet.DataSetBuilder; 30 | 31 | import com.fasterxml.jackson.core.JsonParser; 32 | import com.fasterxml.jackson.core.JsonProcessingException; 33 | import com.fasterxml.jackson.databind.DeserializationContext; 34 | import com.fasterxml.jackson.databind.JsonNode; 35 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 36 | 37 | /** 38 | * A JSON deserializer for {@link DataSet} instances. 39 | */ 40 | public class DataSetDeserializer extends StdDeserializer { 41 | 42 | private static Logger logger = LogManager.getLogger(DataSetDeserializer.class.getName()); 43 | 44 | private static final String FIELD_SIZE = "numberOfColumns"; 45 | private static final String FIELD_TYPES = "types"; 46 | private static final String FIELD_NAMES = "columnNames"; 47 | private static final String FIELD_ROWS = "rows"; 48 | 49 | /** 50 | * Constructor. 51 | * 52 | * @param clazz 53 | */ 54 | protected DataSetDeserializer(Class clazz) { 55 | super(clazz); 56 | } 57 | 58 | @Override 59 | public DataSet deserialize(JsonParser parser, DeserializationContext context) 60 | throws IOException, JsonProcessingException { 61 | JsonNode node = parser.getCodec().readTree(parser); 62 | long size = (Long) node.get(FIELD_SIZE).numberValue(); 63 | DataSetBuilder builder = new DataSetBuilder(size); 64 | JsonNode namesNode = node.get(FIELD_NAMES); 65 | if (namesNode.isArray()) { 66 | for (JsonNode nameNode : namesNode) { 67 | builder.addColumnName(nameNode.textValue()); 68 | } 69 | } 70 | JsonNode typesNode = node.get(FIELD_TYPES); 71 | List typesList = new ArrayList(); 72 | if (typesNode.isArray()) { 73 | for (JsonNode typeNode : typesNode) { 74 | typesList.add(DataSetDataType.valueOf(typeNode.textValue())); 75 | } 76 | builder.addTypes(typesList); 77 | } 78 | JsonNode rowsNode = node.get(FIELD_ROWS); 79 | if (rowsNode.isArray()) { 80 | for (JsonNode rowNode : rowsNode) { 81 | List> values = new ArrayList>(); 82 | for (int i = 0; i < size; i++) { 83 | JsonNode value = rowNode.get(i); 84 | DataSetDataType type = typesList.get(i); 85 | values.add(getValueFromNode(value, type)); 86 | } 87 | builder.addRow(new Row(values)); 88 | } 89 | } 90 | try { 91 | return builder.createDataSet(); 92 | } catch (SparkplugException e) { 93 | logger.error("Error deserializing DataSet ", e); 94 | } 95 | return null; 96 | } 97 | 98 | /* 99 | * Creates and returns a Value instance 100 | */ 101 | private Value getValueFromNode(JsonNode nodeValue, DataSetDataType type) { 102 | switch (type) { 103 | case Boolean: 104 | return new Value(type, (boolean) nodeValue.asBoolean()); 105 | case DateTime: 106 | return new Value(type, new Date(nodeValue.asLong())); 107 | case Double: 108 | return new Value(type, nodeValue.asDouble()); 109 | case Float: 110 | return new Value(type, (float) nodeValue.asDouble()); 111 | case Int16: 112 | case UInt8: 113 | return new Value(type, (byte) nodeValue.asInt()); 114 | case UInt16: 115 | case Int32: 116 | return new Value(type, nodeValue.asInt()); 117 | case UInt32: 118 | case Int64: 119 | return new Value(type, (long) nodeValue.asLong()); 120 | case Text: 121 | case String: 122 | return new Value(type, nodeValue.asText()); 123 | case UInt64: 124 | return new Value(type, BigInteger.valueOf(nodeValue.asLong())); 125 | case Unknown: 126 | default: 127 | return null; 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/DeserializerModifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | import org.eclipse.tahu.message.model.Metric; 17 | 18 | import com.fasterxml.jackson.databind.BeanDescription; 19 | import com.fasterxml.jackson.databind.DeserializationConfig; 20 | import com.fasterxml.jackson.databind.JsonDeserializer; 21 | import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; 22 | 23 | /** 24 | * 25 | */ 26 | public class DeserializerModifier extends BeanDeserializerModifier { 27 | 28 | @Override 29 | public JsonDeserializer modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, 30 | JsonDeserializer deserializer) { 31 | if (Metric.class.equals(beanDesc.getBeanClass())) { 32 | return new MetricDeserializer(deserializer); 33 | } 34 | 35 | return super.modifyDeserializer(config, beanDesc, deserializer); 36 | } 37 | } -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/DeserializerModule.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | import com.fasterxml.jackson.core.Version; 17 | import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; 18 | import com.fasterxml.jackson.databind.module.SimpleModule; 19 | 20 | /** 21 | * Used to register the {@link DeserializerModifier} instance. 22 | */ 23 | public class DeserializerModule extends SimpleModule { 24 | 25 | private BeanDeserializerModifier deserializerModifier; 26 | 27 | public DeserializerModule(BeanDeserializerModifier deserializerModifier) { 28 | super("DeserializerModule", Version.unknownVersion()); 29 | this.deserializerModifier = deserializerModifier; 30 | } 31 | 32 | @Override 33 | public void setupModule(SetupContext context) { 34 | super.setupModule(context); 35 | context.addBeanDeserializerModifier(deserializerModifier); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/FileSerializer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.internal.websocket.Base64; 19 | import org.eclipse.tahu.message.model.File; 20 | 21 | import com.fasterxml.jackson.core.JsonGenerator; 22 | import com.fasterxml.jackson.databind.SerializerProvider; 23 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 24 | 25 | /** 26 | * Serializes a {@link File} instance. 27 | */ 28 | public class FileSerializer extends StdSerializer { 29 | 30 | /** 31 | * Constructor. 32 | */ 33 | protected FileSerializer() { 34 | super(File.class); 35 | } 36 | 37 | /** 38 | * Constructor. 39 | * 40 | * @param clazz class. 41 | */ 42 | protected FileSerializer(Class clazz) { 43 | super(clazz); 44 | } 45 | 46 | @Override 47 | public void serialize(File value, JsonGenerator generator, SerializerProvider provider) throws IOException { 48 | generator.writeString(Base64.encodeBytes(value.getBytes())); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/JsonValidator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | /** 17 | * Validates JSON. 18 | */ 19 | public class JsonValidator { 20 | 21 | protected static final String JSON_SCHEMA_FILENAME = "payload.json"; 22 | 23 | private static JsonValidator instance = null; 24 | 25 | /** 26 | * Constructor. 27 | */ 28 | protected JsonValidator() { 29 | } 30 | 31 | /** 32 | * Returns the {@link JsonValidator} instance. 33 | * 34 | * @return the {@link JsonValidator} instance. 35 | */ 36 | public static JsonValidator getInstance() { 37 | if (instance == null) { 38 | instance = new JsonValidator(); 39 | } 40 | return instance; 41 | } 42 | 43 | /** 44 | * Returns loads and returns the {@link JsonSchema} instance associated with this validator. 45 | * 46 | * @return the {@link JsonSchema} instance associated with this validator. 47 | * @throws IOException 48 | * @throws ProcessingException 49 | */ 50 | // protected JsonSchema getSchema() throws IOException, ProcessingException { 51 | // // Get file from resources folder 52 | // ClassLoader classLoader = getClass().getClassLoader(); 53 | // File schemaFile = new File(classLoader.getResource(JSON_SCHEMA_FILENAME).getFile()); 54 | // return JsonSchemaFactory.byDefault().getJsonSchema(JsonLoader.fromFile(schemaFile)); 55 | // } 56 | 57 | /** 58 | * Returns true if the supplied JSON text is valid, false otherwise. 59 | * 60 | * @param jsonText a {@link String} representing JSON text. 61 | * @return true if the supplied JSON text is valid, false otherwise. 62 | * @throws ProcessingException 63 | * @throws IOException 64 | */ 65 | // public boolean isJsonValid(String jsonText) throws ProcessingException, IOException { 66 | // return getSchema().validate(JsonLoader.fromString(jsonText)).isSuccess(); 67 | // } 68 | } 69 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/json/MetricDeserializer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.json; 15 | 16 | import java.io.IOException; 17 | import java.util.Base64; 18 | 19 | import org.eclipse.tahu.message.model.File; 20 | import org.eclipse.tahu.message.model.MetaData; 21 | import org.eclipse.tahu.message.model.Metric; 22 | import org.eclipse.tahu.message.model.MetricDataType; 23 | 24 | import com.fasterxml.jackson.core.JsonParser; 25 | import com.fasterxml.jackson.core.JsonProcessingException; 26 | import com.fasterxml.jackson.databind.DeserializationContext; 27 | import com.fasterxml.jackson.databind.JsonDeserializer; 28 | import com.fasterxml.jackson.databind.JsonMappingException; 29 | import com.fasterxml.jackson.databind.deser.ResolvableDeserializer; 30 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 31 | 32 | /** 33 | * A custom JSON deserializer for {@link Metric} instances. 34 | */ 35 | public class MetricDeserializer extends StdDeserializer implements ResolvableDeserializer { 36 | 37 | private final JsonDeserializer defaultDeserializer; 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | protected MetricDeserializer(JsonDeserializer defaultDeserializer) { 43 | super(Metric.class); 44 | this.defaultDeserializer = defaultDeserializer; 45 | } 46 | 47 | @Override 48 | public Metric deserialize(JsonParser parser, DeserializationContext ctxt) 49 | throws IOException, JsonProcessingException { 50 | 51 | Metric metric = (Metric) defaultDeserializer.deserialize(parser, ctxt); 52 | 53 | // Check if the data type is a File 54 | if (metric.getDataType().equals(MetricDataType.File)) { 55 | // Perform the custom logic for File types by building up the File object. 56 | MetaData metaData = metric.getMetaData(); 57 | String fileName = metaData == null ? null : metaData.getFileName(); 58 | File file = new File(fileName, Base64.getDecoder().decode((String) metric.getValue())); 59 | metric.setValue(file); 60 | } 61 | return metric; 62 | } 63 | 64 | @Override 65 | public void resolve(DeserializationContext ctxt) throws JsonMappingException { 66 | ((ResolvableDeserializer) defaultDeserializer).resolve(ctxt); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/PayloadDecoder.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message; 15 | 16 | /** 17 | * An interface for decoding payloads. 18 | * 19 | * @param

the type of payload. 20 | */ 21 | public interface PayloadDecoder

{ 22 | 23 | /** 24 | * Builds a payload from a supplied byte array. 25 | * 26 | * @param bytes the bytes representing the payload 27 | * @return a payload object built from the byte array 28 | * @throws Exception 29 | */ 30 | public P buildFromByteArray(byte[] bytes) throws Exception; 31 | } 32 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/PayloadEncoder.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message; 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * An interface for encoding payloads. 20 | * 21 | * @param

the type of payload. 22 | */ 23 | public interface PayloadEncoder

{ 24 | 25 | /** 26 | * Converts a payload object into a byte array. 27 | * 28 | * @param payload a payload object 29 | * @return the byte array representing the payload 30 | * @throws IOException 31 | */ 32 | public byte[] getBytes(P payload) throws IOException; 33 | } 34 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/DataSetDataType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Date; 18 | 19 | import org.eclipse.tahu.SparkplugInvalidTypeException; 20 | 21 | /** 22 | * A enumeration of data types of values in a {@link DataSet} 23 | */ 24 | public enum DataSetDataType { 25 | 26 | // Basic Types 27 | Int8(1, Byte.class), 28 | Int16(2, Short.class), 29 | Int32(3, Integer.class), 30 | Int64(4, Long.class), 31 | UInt8(5, Short.class), 32 | UInt16(6, Integer.class), 33 | UInt32(7, Long.class), 34 | UInt64(8, BigInteger.class), 35 | Float(9, Float.class), 36 | Double(10, Double.class), 37 | Boolean(11, Boolean.class), 38 | String(12, String.class), 39 | DateTime(13, Date.class), 40 | Text(14, String.class), 41 | 42 | // Unknown 43 | Unknown(0, Object.class); 44 | 45 | private Class clazz = null; 46 | private int intValue = 0; 47 | 48 | private DataSetDataType(int intValue, Class clazz) { 49 | this.intValue = intValue; 50 | this.clazz = clazz; 51 | } 52 | 53 | public void checkType(Object value) throws SparkplugInvalidTypeException { 54 | if (value != null && !clazz.isAssignableFrom(value.getClass())) { 55 | throw new SparkplugInvalidTypeException(value.getClass()); 56 | } 57 | } 58 | 59 | /** 60 | * Returns an integer representation of the data type. 61 | * 62 | * @return an integer representation of the data type. 63 | */ 64 | public int toIntValue() { 65 | return this.intValue; 66 | } 67 | 68 | /** 69 | * Converts the integer representation of the data type into a {@link DataSetDataType} instance. 70 | * 71 | * @param i the integer representation of the data type. 72 | * @return a {@link DataSetDataType} instance. 73 | */ 74 | public static DataSetDataType fromInteger(int i) { 75 | switch (i) { 76 | case 1: 77 | return Int8; 78 | case 2: 79 | return Int16; 80 | case 3: 81 | return Int32; 82 | case 4: 83 | return Int64; 84 | case 5: 85 | return UInt8; 86 | case 6: 87 | return UInt16; 88 | case 7: 89 | return UInt32; 90 | case 8: 91 | return UInt64; 92 | case 9: 93 | return Float; 94 | case 10: 95 | return Double; 96 | case 11: 97 | return Boolean; 98 | case 12: 99 | return String; 100 | case 13: 101 | return DateTime; 102 | case 14: 103 | return Text; 104 | default: 105 | return Unknown; 106 | } 107 | } 108 | 109 | /** 110 | * Returns the class type for this DataType 111 | * 112 | * @return the class type for this DataType 113 | */ 114 | public Class getClazz() { 115 | return clazz; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/File.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.Arrays; 17 | 18 | import org.eclipse.tahu.json.FileSerializer; 19 | 20 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 21 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 22 | 23 | @JsonIgnoreProperties(value = { "fileName" }) 24 | @JsonSerialize(using = FileSerializer.class) 25 | public class File { 26 | 27 | private String fileName; 28 | private byte[] bytes; 29 | 30 | public File() { 31 | super(); 32 | } 33 | 34 | public File(String fileName, byte[] bytes) { 35 | super(); 36 | this.fileName = fileName == null 37 | ? null 38 | : fileName.replace("/", System.getProperty("file.separator")).replace("\\", 39 | System.getProperty("file.separator")); 40 | this.bytes = Arrays.copyOf(bytes, bytes.length); 41 | } 42 | 43 | public String getFileName() { 44 | return fileName; 45 | } 46 | 47 | public void setFileName(String fileName) { 48 | this.fileName = fileName; 49 | } 50 | 51 | public byte[] getBytes() { 52 | return bytes; 53 | } 54 | 55 | public void setBytes(byte[] bytes) { 56 | this.bytes = bytes; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | StringBuilder builder = new StringBuilder(); 62 | builder.append("File [fileName="); 63 | builder.append(fileName); 64 | builder.append(", bytes="); 65 | builder.append(Arrays.toString(bytes)); 66 | builder.append("]"); 67 | return builder.toString(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/Message.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | /** 17 | * A class to represent a Message. 18 | */ 19 | public class Message { 20 | 21 | private Topic topic; 22 | 23 | private SparkplugBPayload payload; 24 | 25 | /** 26 | * @param topic 27 | * @param payload 28 | */ 29 | private Message(Topic topic, SparkplugBPayload payload) { 30 | super(); 31 | this.topic = topic; 32 | this.payload = payload; 33 | } 34 | 35 | public Topic getTopic() { 36 | return topic; 37 | } 38 | 39 | public SparkplugBPayload getPayload() { 40 | return payload; 41 | } 42 | 43 | /** 44 | * A builder for creating a {@link SparkplugBPayload} instance. 45 | */ 46 | public static class MessageBuilder { 47 | 48 | private Topic topic; 49 | 50 | private SparkplugBPayload payload; 51 | 52 | public MessageBuilder(Topic topic, SparkplugBPayload payload) { 53 | this.topic = topic; 54 | this.payload = payload; 55 | } 56 | 57 | public MessageBuilder() { 58 | } 59 | 60 | public MessageBuilder topic(Topic topic) { 61 | this.topic = topic; 62 | return this; 63 | } 64 | 65 | public MessageBuilder payload(SparkplugBPayload payload) { 66 | this.payload = payload; 67 | return this; 68 | } 69 | 70 | public Message build() { 71 | return new Message(this.topic, this.payload); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/MessageType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import org.eclipse.tahu.SparkplugParsingException; 17 | 18 | /** 19 | * An enumeration of Sparkplug MQTT message types. The type provides an indication as to what the MQTT Payload of 20 | * message will contain. 21 | */ 22 | public enum MessageType { 23 | 24 | /** 25 | * Birth certificate for MQTT Edge of Network (EoN) Nodes. 26 | */ 27 | NBIRTH, 28 | 29 | /** 30 | * Death certificate for MQTT Edge of Network (EoN) Nodes. 31 | */ 32 | NDEATH, 33 | 34 | /** 35 | * Birth certificate for MQTT Devices. 36 | */ 37 | DBIRTH, 38 | 39 | /** 40 | * Death certificate for MQTT Devices. 41 | */ 42 | DDEATH, 43 | 44 | /** 45 | * Edge of Network (EoN) Node data message. 46 | */ 47 | NDATA, 48 | 49 | /** 50 | * Device data message. 51 | */ 52 | DDATA, 53 | 54 | /** 55 | * Edge of Network (EoN) Node command message. 56 | */ 57 | NCMD, 58 | 59 | /** 60 | * Device command message. 61 | */ 62 | DCMD, 63 | 64 | /** 65 | * Critical application state message. 66 | */ 67 | STATE, 68 | 69 | /** 70 | * Device record message. 71 | */ 72 | DRECORD, 73 | 74 | /** 75 | * Edge of Network (EoN) Node record message. 76 | */ 77 | NRECORD; 78 | 79 | public static MessageType parseMessageType(String type) throws SparkplugParsingException { 80 | for (MessageType messageType : MessageType.values()) { 81 | if (messageType.name().equals(type)) { 82 | return messageType; 83 | } 84 | } 85 | throw new SparkplugParsingException("Invalid message type: " + type); 86 | } 87 | 88 | public boolean isDeath() { 89 | return this.equals(DDEATH) || this.equals(NDEATH); 90 | } 91 | 92 | public boolean isCommand() { 93 | return this.equals(DCMD) || this.equals(NCMD); 94 | } 95 | 96 | public boolean isData() { 97 | return this.equals(DDATA) || this.equals(NDATA); 98 | } 99 | 100 | public boolean isBirth() { 101 | return this.equals(DBIRTH) || this.equals(NBIRTH); 102 | } 103 | 104 | public boolean isRecord() { 105 | return this.equals(DRECORD) || this.equals(NRECORD); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/MetricDataType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Date; 18 | 19 | import org.apache.log4j.LogManager; 20 | import org.apache.log4j.Logger; 21 | import org.eclipse.tahu.SparkplugInvalidTypeException; 22 | 23 | /** 24 | * An enumeration of data types associated with the value of a {@link Metric} 25 | */ 26 | public enum MetricDataType { 27 | 28 | // Basic Types 29 | Int8(1, Byte.class), 30 | Int16(2, Short.class), 31 | Int32(3, Integer.class), 32 | Int64(4, Long.class), 33 | UInt8(5, Short.class), 34 | UInt16(6, Integer.class), 35 | UInt32(7, Long.class), 36 | UInt64(8, BigInteger.class), 37 | Float(9, Float.class), 38 | Double(10, Double.class), 39 | Boolean(11, Boolean.class), 40 | String(12, String.class), 41 | DateTime(13, Date.class), 42 | Text(14, String.class), 43 | 44 | // Custom Types for Metrics 45 | UUID(15, String.class), 46 | DataSet(16, DataSet.class), 47 | Bytes(17, byte[].class), 48 | File(18, File.class), 49 | Template(19, Template.class), 50 | 51 | // Unknown 52 | Unknown(0, Object.class); 53 | 54 | private static Logger logger = LogManager.getLogger(MetricDataType.class.getName()); 55 | 56 | private Class clazz = null; 57 | private int intValue = 0; 58 | 59 | private MetricDataType(int intValue, Class clazz) { 60 | this.intValue = intValue; 61 | this.clazz = clazz; 62 | } 63 | 64 | public void checkType(Object value) throws SparkplugInvalidTypeException { 65 | if (value != null && !clazz.isAssignableFrom(value.getClass())) { 66 | logger.warn( 67 | "Failed type check - " + clazz + " != " + ((value != null) ? value.getClass().toString() : "null")); 68 | throw new SparkplugInvalidTypeException(value.getClass()); 69 | } 70 | } 71 | 72 | /** 73 | * Returns an integer representation of the data type. 74 | * 75 | * @return an integer representation of the data type. 76 | */ 77 | public int toIntValue() { 78 | return this.intValue; 79 | } 80 | 81 | /** 82 | * Converts the integer representation of the data type into a {@link MetricDataType} instance. 83 | * 84 | * @param i the integer representation of the data type. 85 | * @return a {@link MetricDataType} instance. 86 | */ 87 | public static MetricDataType fromInteger(int i) { 88 | switch (i) { 89 | case 1: 90 | return Int8; 91 | case 2: 92 | return Int16; 93 | case 3: 94 | return Int32; 95 | case 4: 96 | return Int64; 97 | case 5: 98 | return UInt8; 99 | case 6: 100 | return UInt16; 101 | case 7: 102 | return UInt32; 103 | case 8: 104 | return UInt64; 105 | case 9: 106 | return Float; 107 | case 10: 108 | return Double; 109 | case 11: 110 | return Boolean; 111 | case 12: 112 | return String; 113 | case 13: 114 | return DateTime; 115 | case 14: 116 | return Text; 117 | case 15: 118 | return UUID; 119 | case 16: 120 | return DataSet; 121 | case 17: 122 | return Bytes; 123 | case 18: 124 | return File; 125 | case 19: 126 | return Template; 127 | default: 128 | return Unknown; 129 | } 130 | } 131 | 132 | /** 133 | * Returns the class type for this DataType 134 | * 135 | * @return the class type for this DataType 136 | */ 137 | public Class getClazz() { 138 | return clazz; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/Parameter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.Objects; 17 | 18 | import org.eclipse.tahu.SparkplugInvalidTypeException; 19 | 20 | import com.fasterxml.jackson.annotation.JsonGetter; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import com.fasterxml.jackson.annotation.JsonSetter; 23 | 24 | /** 25 | * A class to represent a parameter associated with a template. 26 | */ 27 | public class Parameter { 28 | 29 | /** 30 | * The name of the parameter 31 | */ 32 | @JsonProperty("name") 33 | private String name; 34 | 35 | /** 36 | * The data type of the parameter 37 | */ 38 | @JsonProperty("type") 39 | private ParameterDataType type; 40 | 41 | /** 42 | * The value of the parameter 43 | */ 44 | @JsonProperty("value") 45 | private Object value; 46 | 47 | public Parameter() { 48 | } 49 | 50 | /** 51 | * Constructs a Parameter instance. 52 | * 53 | * @param name The name of the parameter. 54 | * @param type The type of the parameter. 55 | * @param value The value of the parameter. 56 | * @throws SparkplugInvalidTypeException 57 | */ 58 | public Parameter(String name, ParameterDataType type, Object value) throws SparkplugInvalidTypeException { 59 | this.name = name; 60 | this.type = type; 61 | this.value = value; 62 | this.type.checkType(value); 63 | } 64 | 65 | @JsonGetter("name") 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | @JsonSetter("name") 71 | public void setName(String name) { 72 | this.name = name; 73 | } 74 | 75 | public ParameterDataType getType() { 76 | return type; 77 | } 78 | 79 | public void setType(ParameterDataType type) { 80 | this.type = type; 81 | } 82 | 83 | public Object getValue() { 84 | return value; 85 | } 86 | 87 | public void setValue(Object value) { 88 | this.value = value; 89 | } 90 | 91 | @Override 92 | public boolean equals(Object object) { 93 | if (this == object) { 94 | return true; 95 | } 96 | if (object == null || this.getClass() != object.getClass()) { 97 | return false; 98 | } 99 | Parameter param = (Parameter) object; 100 | return Objects.equals(name, param.getName()) && Objects.equals(type, param.getType()) 101 | && Objects.equals(value, param.getValue()); 102 | } 103 | 104 | @Override 105 | public String toString() { 106 | StringBuilder builder = new StringBuilder(); 107 | builder.append("Parameter [name="); 108 | builder.append(name); 109 | builder.append(", type="); 110 | builder.append(type); 111 | builder.append(", value="); 112 | builder.append(value); 113 | builder.append("]"); 114 | return builder.toString(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/ParameterDataType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Date; 18 | 19 | import org.apache.log4j.LogManager; 20 | import org.apache.log4j.Logger; 21 | import org.eclipse.tahu.SparkplugInvalidTypeException; 22 | 23 | /** 24 | * An enumeration of data types for the value of a {@link Parameter} for a {@link Template} 25 | */ 26 | public enum ParameterDataType { 27 | 28 | // Basic Types 29 | Int8(1, Byte.class), 30 | Int16(2, Short.class), 31 | Int32(3, Integer.class), 32 | Int64(4, Long.class), 33 | UInt8(5, Short.class), 34 | UInt16(6, Integer.class), 35 | UInt32(7, Long.class), 36 | UInt64(8, BigInteger.class), 37 | Float(9, Float.class), 38 | Double(10, Double.class), 39 | Boolean(11, Boolean.class), 40 | String(12, String.class), 41 | DateTime(13, Date.class), 42 | Text(14, String.class), 43 | 44 | // Unknown 45 | Unknown(0, Object.class); 46 | 47 | private static Logger logger = LogManager.getLogger(ParameterDataType.class.getName()); 48 | 49 | private Class clazz = null; 50 | private int intValue = 0; 51 | 52 | private ParameterDataType(int intValue, Class clazz) { 53 | this.intValue = intValue; 54 | this.clazz = clazz; 55 | } 56 | 57 | public void checkType(Object value) throws SparkplugInvalidTypeException { 58 | if (value != null && !clazz.isAssignableFrom(value.getClass())) { 59 | logger.warn("Failed type check - " + clazz + " != " + value.getClass().toString()); 60 | throw new SparkplugInvalidTypeException(value.getClass()); 61 | } 62 | } 63 | 64 | /** 65 | * Returns an integer representation of the data type. 66 | * 67 | * @return an integer representation of the data type. 68 | */ 69 | public int toIntValue() { 70 | return this.intValue; 71 | } 72 | 73 | /** 74 | * Converts the integer representation of the data type into a {@link ParameterDataType} instance. 75 | * 76 | * @param i the integer representation of the data type. 77 | * @return a {@link ParameterDataType} instance. 78 | */ 79 | public static ParameterDataType fromInteger(int i) { 80 | switch (i) { 81 | case 1: 82 | return Int8; 83 | case 2: 84 | return Int16; 85 | case 3: 86 | return Int32; 87 | case 4: 88 | return Int64; 89 | case 5: 90 | return UInt8; 91 | case 6: 92 | return UInt16; 93 | case 7: 94 | return UInt32; 95 | case 8: 96 | return UInt64; 97 | case 9: 98 | return Float; 99 | case 10: 100 | return Double; 101 | case 11: 102 | return Boolean; 103 | case 12: 104 | return String; 105 | case 13: 106 | return DateTime; 107 | case 14: 108 | return Text; 109 | default: 110 | return Unknown; 111 | } 112 | } 113 | 114 | /** 115 | * Returns the class type for this DataType 116 | * 117 | * @return the class type for this DataType 118 | */ 119 | public Class getClazz() { 120 | return clazz; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/PropertyDataType.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Date; 18 | import java.util.List; 19 | 20 | import org.apache.log4j.LogManager; 21 | import org.apache.log4j.Logger; 22 | import org.eclipse.tahu.SparkplugInvalidTypeException; 23 | 24 | /** 25 | * An enumeration of data types for values of a {@link PropertySet} 26 | */ 27 | public enum PropertyDataType { 28 | 29 | // Basic Types 30 | Int8(1, Byte.class), 31 | Int16(2, Short.class), 32 | Int32(3, Integer.class), 33 | Int64(4, Long.class), 34 | UInt8(5, Short.class), 35 | UInt16(6, Integer.class), 36 | UInt32(7, Long.class), 37 | UInt64(8, BigInteger.class), 38 | Float(9, Float.class), 39 | Double(10, Double.class), 40 | Boolean(11, Boolean.class), 41 | String(12, String.class), 42 | DateTime(13, Date.class), 43 | Text(14, String.class), 44 | 45 | // Custom Types for PropertySets 46 | PropertySet(20, PropertySet.class), 47 | PropertySetList(21, List.class), 48 | 49 | // Unknown 50 | Unknown(0, Object.class); 51 | 52 | private static Logger logger = LogManager.getLogger(PropertyDataType.class.getName()); 53 | 54 | private Class clazz = null; 55 | private int intValue = 0; 56 | 57 | private PropertyDataType(int intValue, Class clazz) { 58 | this.intValue = intValue; 59 | this.clazz = clazz; 60 | } 61 | 62 | public void checkType(Object value) throws SparkplugInvalidTypeException { 63 | if (value != null && !clazz.isAssignableFrom(value.getClass())) { 64 | if (clazz == List.class && value instanceof List) { 65 | // Allow List subclasses 66 | } else { 67 | logger.warn("Failed type check - " + clazz + " != " + value.getClass().toString()); 68 | throw new SparkplugInvalidTypeException(value.getClass()); 69 | } 70 | } 71 | } 72 | 73 | /** 74 | * Returns an integer representation of the data type. 75 | * 76 | * @return an integer representation of the data type. 77 | */ 78 | public int toIntValue() { 79 | return this.intValue; 80 | } 81 | 82 | /** 83 | * Converts the integer representation of the data type into a {@link PropertyDataType} instance. 84 | * 85 | * @param i the integer representation of the data type. 86 | * @return a {@link PropertyDataType} instance. 87 | */ 88 | public static PropertyDataType fromInteger(int i) { 89 | switch (i) { 90 | case 1: 91 | return Int8; 92 | case 2: 93 | return Int16; 94 | case 3: 95 | return Int32; 96 | case 4: 97 | return Int64; 98 | case 5: 99 | return UInt8; 100 | case 6: 101 | return UInt16; 102 | case 7: 103 | return UInt32; 104 | case 8: 105 | return UInt64; 106 | case 9: 107 | return Float; 108 | case 10: 109 | return Double; 110 | case 11: 111 | return Boolean; 112 | case 12: 113 | return String; 114 | case 13: 115 | return DateTime; 116 | case 14: 117 | return Text; 118 | case 20: 119 | return PropertySet; 120 | case 21: 121 | return PropertySetList; 122 | default: 123 | return Unknown; 124 | } 125 | } 126 | 127 | /** 128 | * Returns the class type for this DataType 129 | * 130 | * @return the class type for this DataType 131 | */ 132 | public Class getClazz() { 133 | return clazz; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/PropertySet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.Collection; 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | import java.util.Set; 20 | 21 | import org.eclipse.tahu.SparkplugInvalidTypeException; 22 | 23 | import com.fasterxml.jackson.annotation.JsonIgnore; 24 | 25 | /** 26 | * A class that maintains a set of properties associated with a {@link Metric}. 27 | */ 28 | public class PropertySet implements Map { 29 | 30 | @JsonIgnore 31 | private Map map; 32 | 33 | public PropertySet() { 34 | this.map = new HashMap<>(); 35 | } 36 | 37 | private PropertySet(Map propertyMap) { 38 | this.map = propertyMap; 39 | } 40 | 41 | @JsonIgnore 42 | public PropertyValue getPropertyValue(String name) { 43 | return this.map.get(name); 44 | } 45 | 46 | @JsonIgnore 47 | public void setProperty(String name, PropertyValue value) { 48 | this.map.put(name, value); 49 | } 50 | 51 | @JsonIgnore 52 | public void removeProperty(String name) { 53 | this.map.remove(name); 54 | } 55 | 56 | @JsonIgnore 57 | public void clear() { 58 | this.map.clear(); 59 | } 60 | 61 | @JsonIgnore 62 | public Set getNames() { 63 | return map.keySet(); 64 | } 65 | 66 | @JsonIgnore 67 | public Collection getValues() { 68 | return map.values(); 69 | } 70 | 71 | @JsonIgnore 72 | public Map getPropertyMap() { 73 | return map; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "PropertySet [propertyMap=" + map + "]"; 79 | } 80 | 81 | @Override 82 | public int size() { 83 | return map.size(); 84 | } 85 | 86 | @Override 87 | public boolean isEmpty() { 88 | return map.isEmpty(); 89 | } 90 | 91 | @Override 92 | public boolean containsKey(Object key) { 93 | return map.containsKey(key); 94 | } 95 | 96 | @Override 97 | public boolean containsValue(Object value) { 98 | return map.containsValue(value); 99 | } 100 | 101 | @Override 102 | public PropertyValue get(Object key) { 103 | return map.get(key); 104 | } 105 | 106 | @Override 107 | public PropertyValue put(String key, PropertyValue value) { 108 | return map.put(key, value); 109 | } 110 | 111 | @Override 112 | public PropertyValue remove(Object key) { 113 | return map.remove(key); 114 | } 115 | 116 | @Override 117 | public void putAll(Map m) { 118 | map.putAll(m); 119 | } 120 | 121 | @Override 122 | public Set keySet() { 123 | return map.keySet(); 124 | } 125 | 126 | @Override 127 | public Collection values() { 128 | return map.values(); 129 | } 130 | 131 | @Override 132 | public Set> entrySet() { 133 | return map.entrySet(); 134 | } 135 | 136 | /** 137 | * A builder for a PropertySet instance 138 | */ 139 | public static class PropertySetBuilder { 140 | 141 | private Map propertyMap; 142 | 143 | public PropertySetBuilder() { 144 | this.propertyMap = new HashMap<>(); 145 | } 146 | 147 | public PropertySetBuilder(Map propertyMap) { 148 | this.propertyMap = propertyMap; 149 | } 150 | 151 | public PropertySetBuilder(PropertySet propertySet) throws SparkplugInvalidTypeException { 152 | this.propertyMap = new HashMap<>(); 153 | for (String name : propertySet.getNames()) { 154 | PropertyValue value = propertySet.getPropertyValue(name); 155 | propertyMap.put(name, new PropertyValue(value.getType(), value.getValue())); 156 | } 157 | } 158 | 159 | public PropertySetBuilder addProperty(String name, PropertyValue value) { 160 | this.propertyMap.put(name, value); 161 | return this; 162 | } 163 | 164 | public PropertySetBuilder addProperties(Map properties) { 165 | this.propertyMap.putAll(properties); 166 | return this; 167 | } 168 | 169 | public PropertySet createPropertySet() { 170 | return new PropertySet(propertyMap); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/PropertyValue.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.Objects; 17 | 18 | import org.eclipse.tahu.SparkplugInvalidTypeException; 19 | 20 | import com.fasterxml.jackson.annotation.JsonIgnore; 21 | 22 | /** 23 | * The value of a property in a {@link PropertySet}. 24 | */ 25 | public class PropertyValue { 26 | 27 | private PropertyDataType type; 28 | private Object value; 29 | private Boolean isNull = null; 30 | 31 | public PropertyValue() { 32 | } 33 | 34 | /** 35 | * A constructor. 36 | * 37 | * @param type the property type 38 | * @param value the property value 39 | * @throws SparkplugInvalidTypeException 40 | */ 41 | public PropertyValue(PropertyDataType type, Object value) throws SparkplugInvalidTypeException { 42 | this.type = type; 43 | this.value = value; 44 | isNull = (value == null) ? true : false; 45 | type.checkType(value); 46 | } 47 | 48 | public PropertyDataType getType() { 49 | return type; 50 | } 51 | 52 | public void setType(PropertyDataType type) { 53 | this.type = type; 54 | } 55 | 56 | public Object getValue() { 57 | return value; 58 | } 59 | 60 | public void setValue(Object value) { 61 | this.value = value; 62 | isNull = (value == null) ? true : false; 63 | } 64 | 65 | @JsonIgnore 66 | public Boolean isNull() { 67 | return isNull; 68 | } 69 | 70 | @Override 71 | public boolean equals(Object object) { 72 | if (this == object) { 73 | return true; 74 | } 75 | if (object == null || this.getClass() != object.getClass()) { 76 | return false; 77 | } 78 | PropertyValue propValue = (PropertyValue) object; 79 | return Objects.equals(type, propValue.getType()) && Objects.equals(value, propValue.getValue()); 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | StringBuilder builder = new StringBuilder(); 85 | builder.append("PropertyValue [type="); 86 | builder.append(type); 87 | builder.append(", value="); 88 | builder.append(value); 89 | builder.append(", isNull="); 90 | builder.append(isNull); 91 | builder.append("]"); 92 | return builder.toString(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/Row.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Collection; 18 | import java.util.List; 19 | 20 | /** 21 | * A class for representing a row of a data set. 22 | */ 23 | public class Row { 24 | 25 | private List> values; 26 | 27 | public Row() { 28 | this.values = new ArrayList<>(); 29 | } 30 | 31 | public Row(List> values) { 32 | this.values = values; 33 | } 34 | 35 | public List> getValues() { 36 | return values; 37 | } 38 | 39 | public void setValues(List> values) { 40 | this.values = values; 41 | } 42 | 43 | public void addValue(Value value) { 44 | this.values.add(value); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Row [values=" + values + "]"; 50 | } 51 | 52 | /** 53 | * Converts a {@link Row} instance to a {@link List} of Objects representing the values. 54 | * 55 | * @param row a {@link Row} instance. 56 | * @return a {@link List} of Objects. 57 | */ 58 | public static List toValues(Row row) { 59 | List list = new ArrayList(row.getValues().size()); 60 | for (Value value : row.getValues()) { 61 | list.add(value.getValue()); 62 | } 63 | return list; 64 | } 65 | 66 | /** 67 | * A builder for creating a {@link Row} instance. 68 | */ 69 | public static class RowBuilder { 70 | 71 | private List> values; 72 | 73 | public RowBuilder() { 74 | this.values = new ArrayList>(); 75 | } 76 | 77 | public RowBuilder(Row row) { 78 | this.values = new ArrayList>(row.getValues()); 79 | } 80 | 81 | public RowBuilder addValue(Value value) { 82 | this.values.add(value); 83 | return this; 84 | } 85 | 86 | public RowBuilder addValues(Collection> values) { 87 | this.values.addAll(values); 88 | return this; 89 | } 90 | 91 | public Row createRow() { 92 | return new Row(values); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/SparkplugBPayload.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import java.util.Collection; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | import com.fasterxml.jackson.annotation.JsonIgnore; 23 | import com.fasterxml.jackson.annotation.JsonInclude; 24 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 25 | 26 | /** 27 | * A class representing a Sparkplug B payload 28 | */ 29 | @JsonInclude(Include.NON_NULL) 30 | public class SparkplugBPayload { 31 | 32 | private Date timestamp; 33 | private List metrics; 34 | private long seq = -1; 35 | private String uuid; 36 | private byte[] body; 37 | 38 | public SparkplugBPayload() { 39 | } 40 | 41 | public SparkplugBPayload(Date timestamp, List metrics, long seq, String uuid, byte[] body) { 42 | this.timestamp = timestamp; 43 | this.metrics = metrics; 44 | this.seq = seq; 45 | this.uuid = uuid; 46 | this.body = body; 47 | } 48 | 49 | public Date getTimestamp() { 50 | return timestamp; 51 | } 52 | 53 | public void setTimestamp(Date timestamp) { 54 | this.timestamp = timestamp; 55 | } 56 | 57 | public void addMetric(Metric metric) { 58 | metrics.add(metric); 59 | } 60 | 61 | public void addMetric(int index, Metric metric) { 62 | metrics.add(index, metric); 63 | } 64 | 65 | public void addMetrics(List metrics) { 66 | this.metrics.addAll(metrics); 67 | } 68 | 69 | public Metric removeMetric(int index) { 70 | return metrics.remove(index); 71 | } 72 | 73 | public boolean removeMetric(Metric metric) { 74 | return metrics.remove(metric); 75 | } 76 | 77 | public List getMetrics() { 78 | return metrics; 79 | } 80 | 81 | @JsonIgnore 82 | public Integer getMetricCount() { 83 | return metrics.size(); 84 | } 85 | 86 | public void setMetrics(List metrics) { 87 | this.metrics = metrics; 88 | } 89 | 90 | public long getSeq() { 91 | return seq; 92 | } 93 | 94 | public void setSeq(long seq) { 95 | this.seq = seq; 96 | } 97 | 98 | public String getUuid() { 99 | return uuid; 100 | } 101 | 102 | public void setUuid(String uuid) { 103 | this.uuid = uuid; 104 | } 105 | 106 | public byte[] getBody() { 107 | return body; 108 | } 109 | 110 | public void setBody(byte[] body) { 111 | this.body = body; 112 | } 113 | 114 | @Override 115 | public String toString() { 116 | StringBuilder builder = new StringBuilder(); 117 | builder.append("SparkplugBPayload [timestamp="); 118 | builder.append(timestamp); 119 | builder.append(", metrics="); 120 | builder.append(metrics); 121 | builder.append(", seq="); 122 | builder.append(seq); 123 | builder.append(", uuid="); 124 | builder.append(uuid); 125 | builder.append(", body="); 126 | builder.append(Arrays.toString(body)); 127 | builder.append("]"); 128 | return builder.toString(); 129 | } 130 | 131 | /** 132 | * A builder for creating a {@link SparkplugBPayload} instance. 133 | */ 134 | public static class SparkplugBPayloadBuilder { 135 | 136 | private Date timestamp; 137 | private List metrics; 138 | private long seq = -1; 139 | private String uuid; 140 | private byte[] body; 141 | 142 | public SparkplugBPayloadBuilder(long sequenceNumber) { 143 | this.seq = sequenceNumber; 144 | metrics = new ArrayList(); 145 | } 146 | 147 | public SparkplugBPayloadBuilder() { 148 | metrics = new ArrayList(); 149 | } 150 | 151 | public SparkplugBPayloadBuilder addMetric(Metric metric) { 152 | this.metrics.add(metric); 153 | return this; 154 | } 155 | 156 | public SparkplugBPayloadBuilder addMetrics(Collection metrics) { 157 | this.metrics.addAll(metrics); 158 | return this; 159 | } 160 | 161 | public SparkplugBPayloadBuilder setTimestamp(Date timestamp) { 162 | this.timestamp = timestamp; 163 | return this; 164 | } 165 | 166 | public SparkplugBPayloadBuilder setSeq(long seq) { 167 | this.seq = seq; 168 | return this; 169 | } 170 | 171 | public SparkplugBPayloadBuilder setUuid(String uuid) { 172 | this.uuid = uuid; 173 | return this; 174 | } 175 | 176 | public SparkplugBPayloadBuilder setBody(byte[] body) { 177 | this.body = body; 178 | return this; 179 | } 180 | 181 | public SparkplugBPayload createPayload() { 182 | return new SparkplugBPayload(timestamp, metrics, seq, uuid, body); 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/Topic.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | import com.fasterxml.jackson.annotation.JsonInclude; 17 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 18 | 19 | /** 20 | * A Sparkplug MQTT Topic 21 | */ 22 | @JsonInclude(Include.NON_NULL) 23 | public class Topic { 24 | 25 | /** 26 | * The Sparkplug namespace version. 27 | */ 28 | private String namespace; 29 | 30 | /** 31 | * The ID of the logical grouping of Edge of Network (EoN) Nodes and devices. 32 | */ 33 | private String groupId; 34 | 35 | /** 36 | * The ID of the Edge of Network (EoN) Node. 37 | */ 38 | private String edgeNodeId; 39 | 40 | /** 41 | * The ID of the device. 42 | */ 43 | private String deviceId; 44 | 45 | /** 46 | * The message type. 47 | */ 48 | private MessageType type; 49 | 50 | /** 51 | * A Constructor. 52 | * 53 | * @param namespace the namespace. 54 | * @param groupId the group ID. 55 | * @param edgeNodeId the edge node ID. 56 | * @param deviceId the device ID. 57 | * @param type the message type. 58 | */ 59 | public Topic(String namespace, String groupId, String edgeNodeId, String deviceId, MessageType type) { 60 | super(); 61 | this.namespace = namespace; 62 | this.groupId = groupId; 63 | this.edgeNodeId = edgeNodeId; 64 | this.deviceId = deviceId; 65 | this.type = type; 66 | } 67 | 68 | /** 69 | * A Constructor. 70 | * 71 | * @param namespace the namespace. 72 | * @param groupId the group ID. 73 | * @param edgeNodeId the edge node ID. 74 | * @param type the message type. 75 | */ 76 | public Topic(String namespace, String groupId, String edgeNodeId, MessageType type) { 77 | super(); 78 | this.namespace = namespace; 79 | this.groupId = groupId; 80 | this.edgeNodeId = edgeNodeId; 81 | this.deviceId = null; 82 | this.type = type; 83 | } 84 | 85 | /** 86 | * Returns the Sparkplug namespace version. 87 | * 88 | * @return the namespace 89 | */ 90 | public String getNamespace() { 91 | return namespace; 92 | } 93 | 94 | /** 95 | * Returns the ID of the logical grouping of Edge of Network (EoN) Nodes and devices. 96 | * 97 | * @return the group ID 98 | */ 99 | public String getGroupId() { 100 | return groupId; 101 | } 102 | 103 | /** 104 | * Returns the ID of the Edge of Network (EoN) Node. 105 | * 106 | * @return the edge node ID 107 | */ 108 | public String getEdgeNodeId() { 109 | return edgeNodeId; 110 | } 111 | 112 | /** 113 | * Returns the ID of the device. 114 | * 115 | * @return the device ID 116 | */ 117 | public String getDeviceId() { 118 | return deviceId; 119 | } 120 | 121 | /** 122 | * Returns the message type. 123 | * 124 | * @return the message type 125 | */ 126 | public MessageType getType() { 127 | return type; 128 | } 129 | 130 | @Override 131 | public String toString() { 132 | StringBuilder sb = new StringBuilder(getNamespace()).append("/").append(getGroupId()).append("/") 133 | .append(getType()).append("/").append(getEdgeNodeId()); 134 | if (getDeviceId() != null) { 135 | sb.append("/").append(getDeviceId()); 136 | } 137 | return sb.toString(); 138 | } 139 | 140 | /** 141 | * Returns true if this topic's type matches the passes in type, false otherwise. 142 | * 143 | * @param type the type to check 144 | * @return true if this topic's type matches the passes in type, false otherwise 145 | */ 146 | public boolean isType(MessageType type) { 147 | return this.type != null && this.type.equals(type); 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/message/model/Value.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.message.model; 15 | 16 | public class Value { 17 | 18 | private DataSetDataType type; 19 | private V value; 20 | 21 | public Value() { 22 | super(); 23 | } 24 | 25 | public Value(DataSetDataType type, V value) { 26 | super(); 27 | this.type = type; 28 | this.value = value; 29 | } 30 | 31 | public DataSetDataType getType() { 32 | return type; 33 | } 34 | 35 | public void setType(DataSetDataType type) { 36 | this.type = type; 37 | } 38 | 39 | public V getValue() { 40 | return value; 41 | } 42 | 43 | public void setValue(V value) { 44 | this.value = value; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | StringBuilder builder = new StringBuilder(); 50 | builder.append("Value [type="); 51 | builder.append(type); 52 | builder.append(", value="); 53 | builder.append(value); 54 | builder.append("]"); 55 | return builder.toString(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/util/CompressionAlgorithm.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.util; 15 | 16 | /** 17 | * An enumeration of supported payload compression algorithms 18 | */ 19 | public enum CompressionAlgorithm { 20 | 21 | GZIP, 22 | DEFLATE; 23 | 24 | public static CompressionAlgorithm parse(String algorithm) { 25 | return CompressionAlgorithm.valueOf(algorithm.toUpperCase()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/util/GZipUtil.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.util; 15 | 16 | import java.io.ByteArrayInputStream; 17 | import java.io.ByteArrayOutputStream; 18 | import java.util.zip.GZIPInputStream; 19 | import java.util.zip.GZIPOutputStream; 20 | 21 | public class GZipUtil { 22 | 23 | public static byte[] decompress(byte[] compressedData) throws Exception { 24 | ByteArrayInputStream bais = new ByteArrayInputStream(compressedData); 25 | GZIPInputStream gis = null; 26 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 27 | byte[] decompressedData = null; 28 | int bufferSize = 1024; 29 | 30 | try { 31 | gis = new GZIPInputStream(bais); 32 | byte[] buffer = new byte[bufferSize]; 33 | int bytesRead = -1; 34 | while ((bytesRead = gis.read(buffer, 0, bufferSize)) != -1) { 35 | baos.write(buffer, 0, bytesRead); 36 | } 37 | 38 | baos.flush(); 39 | decompressedData = baos.toByteArray(); 40 | } finally { 41 | if (gis != null) { 42 | gis.close(); 43 | } 44 | if (bais != null) { 45 | bais.close(); 46 | } 47 | if (baos != null) { 48 | baos.close(); 49 | } 50 | } 51 | return decompressedData; 52 | } 53 | 54 | public static byte[] compress(byte[] uncompressedData) throws Exception { 55 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 56 | GZIPOutputStream gos = null; 57 | byte[] compressedData = null; 58 | 59 | try { 60 | gos = new GZIPOutputStream(baos); 61 | gos.write(uncompressedData, 0, uncompressedData.length); 62 | gos.finish(); 63 | gos.flush(); 64 | baos.flush(); 65 | compressedData = baos.toByteArray(); 66 | } finally { 67 | if (gos != null) { 68 | gos.close(); 69 | } 70 | if (baos != null) { 71 | baos.close(); 72 | } 73 | } 74 | return compressedData; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/util/TopicUtil.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2016, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.util; 15 | 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | import org.eclipse.tahu.SparkplugParsingException; 20 | import org.eclipse.tahu.message.model.MessageType; 21 | import org.eclipse.tahu.message.model.Topic; 22 | 23 | import com.fasterxml.jackson.core.JsonProcessingException; 24 | import com.fasterxml.jackson.databind.ObjectMapper; 25 | 26 | /** 27 | * Provides utility methods for handling Sparkplug MQTT message topics. 28 | */ 29 | public class TopicUtil { 30 | 31 | private static final Map SPLIT_TOPIC_CACHE = new HashMap(); 32 | 33 | public static String[] getSplitTopic(String topic) { 34 | String[] splitTopic = SPLIT_TOPIC_CACHE.get(topic); 35 | if (splitTopic == null) { 36 | splitTopic = topic.split("/"); 37 | SPLIT_TOPIC_CACHE.put(topic, splitTopic); 38 | } 39 | 40 | return splitTopic; 41 | } 42 | 43 | /** 44 | * Serializes a {@link Topic} instance in to a JSON string. 45 | * 46 | * @param topic a {@link Topic} instance 47 | * @return a JSON string 48 | * @throws JsonProcessingException 49 | */ 50 | public static String toJsonString(Topic topic) throws JsonProcessingException { 51 | ObjectMapper mapper = new ObjectMapper(); 52 | return mapper.writeValueAsString(topic); 53 | } 54 | 55 | /** 56 | * Parses a Sparkplug MQTT message topic string and returns a {@link Topic} instance. 57 | * 58 | * @param topic a topic string 59 | * @return a {@link Topic} instance 60 | * @throws SparkplugParsingException if an error occurs while parsing 61 | */ 62 | public static Topic parseTopic(String topic) throws SparkplugParsingException { 63 | return parseTopic(TopicUtil.getSplitTopic(topic)); 64 | } 65 | 66 | /** 67 | * Parses a Sparkplug MQTT message topic string and returns a {@link Topic} instance. 68 | * 69 | * @param splitTopic a topic split into tokens 70 | * @return a {@link Topic} instance 71 | * @throws SparkplugParsingException if an error occurs while parsing 72 | */ 73 | @SuppressWarnings("incomplete-switch") 74 | public static Topic parseTopic(String[] splitTopic) throws SparkplugParsingException { 75 | MessageType type; 76 | String namespace, edgeNodeId, groupId; 77 | int length = splitTopic.length; 78 | 79 | if (length < 4 || length > 5) { 80 | throw new SparkplugParsingException("Invalid number of topic elements: " + length); 81 | } 82 | 83 | namespace = splitTopic[0]; 84 | groupId = splitTopic[1]; 85 | type = MessageType.parseMessageType(splitTopic[2]); 86 | edgeNodeId = splitTopic[3]; 87 | 88 | if (length == 4) { 89 | // A node topic 90 | switch (type) { 91 | case STATE: 92 | case NBIRTH: 93 | case NCMD: 94 | case NDATA: 95 | case NDEATH: 96 | case NRECORD: 97 | return new Topic(namespace, groupId, edgeNodeId, type); 98 | } 99 | } else { 100 | // A device topic 101 | switch (type) { 102 | case STATE: 103 | case DBIRTH: 104 | case DCMD: 105 | case DDATA: 106 | case DDEATH: 107 | case DRECORD: 108 | return new Topic(namespace, groupId, edgeNodeId, splitTopic[4], type); 109 | } 110 | } 111 | throw new SparkplugParsingException("Invalid number of topic elements " + length + " for topic type " + type); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/java/org/eclipse/tahu/util/ValidationUtils.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.util; 15 | 16 | public class ValidationUtils { 17 | 18 | public static final String JSON_V4_SCHEMA_IDENTIFIER = "http://json-schema.org/draft-04/schema#"; 19 | public static final String JSON_SCHEMA_IDENTIFIER_ELEMENT = "$schema"; 20 | 21 | // public static JsonNode getJsonNode(String jsonText) throws IOException { 22 | // return JsonLoader.fromString(jsonText); 23 | // } // getJsonNode(text) ends 24 | // 25 | // public static JsonNode getJsonNode(File jsonFile) throws IOException { 26 | // return JsonLoader.fromFile(jsonFile); 27 | // } // getJsonNode(File) ends 28 | // 29 | // public static JsonNode getJsonNode(URL url) throws IOException { 30 | // return JsonLoader.fromURL(url); 31 | // } // getJsonNode(URL) ends 32 | // 33 | // public static JsonNode getJsonNodeFromResource(String resource) throws IOException { 34 | // return JsonLoader.fromResource(resource); 35 | // } // getJsonNode(Resource) ends 36 | // 37 | // public static JsonSchema getSchemaNode(String schemaText) throws IOException, ProcessingException { 38 | // final JsonNode schemaNode = getJsonNode(schemaText); 39 | // return _getSchemaNode(schemaNode); 40 | // } // getSchemaNode(text) ends 41 | // 42 | // public static JsonSchema getSchemaNode(File schemaFile) throws IOException, ProcessingException { 43 | // final JsonNode schemaNode = getJsonNode(schemaFile); 44 | // return _getSchemaNode(schemaNode); 45 | // } // getSchemaNode(File) ends 46 | // 47 | // public static JsonSchema getSchemaNode(URL schemaFile) throws IOException, ProcessingException { 48 | // final JsonNode schemaNode = getJsonNode(schemaFile); 49 | // return _getSchemaNode(schemaNode); 50 | // } // getSchemaNode(URL) ends 51 | // 52 | // public static JsonSchema getSchemaNodeFromResource(String resource) throws IOException, ProcessingException { 53 | // final JsonNode schemaNode = getJsonNodeFromResource(resource); 54 | // return _getSchemaNode(schemaNode); 55 | // } // getSchemaNode() ends 56 | // 57 | // public static void validateJson(JsonSchema jsonSchemaNode, JsonNode jsonNode) throws ProcessingException { 58 | // ProcessingReport report = jsonSchemaNode.validate(jsonNode); 59 | // if (!report.isSuccess()) { 60 | // for (ProcessingMessage processingMessage : report) { 61 | // throw new ProcessingException(processingMessage); 62 | // } 63 | // } 64 | // } // validateJson(Node) ends 65 | // 66 | // public static boolean isJsonValid(JsonSchema jsonSchemaNode, JsonNode jsonNode) throws ProcessingException { 67 | // ProcessingReport report = jsonSchemaNode.validate(jsonNode); 68 | // return report.isSuccess(); 69 | // } // validateJson(Node) ends 70 | // 71 | // public static boolean isJsonValid(String schemaText, String jsonText) throws ProcessingException, IOException { 72 | // final JsonSchema schemaNode = getSchemaNode(schemaText); 73 | // final JsonNode jsonNode = getJsonNode(jsonText); 74 | // return isJsonValid(schemaNode, jsonNode); 75 | // } // validateJson(Node) ends 76 | // 77 | // public static boolean isJsonValid(File schemaFile, File jsonFile) throws ProcessingException, IOException { 78 | // final JsonSchema schemaNode = getSchemaNode(schemaFile); 79 | // final JsonNode jsonNode = getJsonNode(jsonFile); 80 | // return isJsonValid(schemaNode, jsonNode); 81 | // } // validateJson(Node) ends 82 | // 83 | // public static boolean isJsonValid(URL schemaURL, URL jsonURL) throws ProcessingException, IOException { 84 | // final JsonSchema schemaNode = getSchemaNode(schemaURL); 85 | // final JsonNode jsonNode = getJsonNode(jsonURL); 86 | // return isJsonValid(schemaNode, jsonNode); 87 | // } // validateJson(Node) ends 88 | // 89 | // public static void validateJson(String schemaText, String jsonText) throws IOException, ProcessingException { 90 | // final JsonSchema schemaNode = getSchemaNode(schemaText); 91 | // final JsonNode jsonNode = getJsonNode(jsonText); 92 | // validateJson(schemaNode, jsonNode); 93 | // } // validateJson(text) ends 94 | // 95 | // public static void validateJson(File schemaFile, File jsonFile) throws IOException, ProcessingException { 96 | // final JsonSchema schemaNode = getSchemaNode(schemaFile); 97 | // final JsonNode jsonNode = getJsonNode(jsonFile); 98 | // validateJson(schemaNode, jsonNode); 99 | // } // validateJson(File) ends 100 | // 101 | // public static void validateJson(URL schemaDocument, URL jsonDocument) throws IOException, ProcessingException { 102 | // final JsonSchema schemaNode = getSchemaNode(schemaDocument); 103 | // final JsonNode jsonNode = getJsonNode(jsonDocument); 104 | // validateJson(schemaNode, jsonNode); 105 | // } // validateJson(URL) ends 106 | // 107 | // public static void validateJsonResource(String schemaResource, String jsonResource) 108 | // throws IOException, ProcessingException { 109 | // final JsonSchema schemaNode = getSchemaNode(schemaResource); 110 | // final JsonNode jsonNode = getJsonNodeFromResource(jsonResource); 111 | // validateJson(schemaNode, jsonNode); 112 | // } // validateJsonResource() ends 113 | // 114 | // private static JsonSchema _getSchemaNode(JsonNode jsonNode) throws ProcessingException { 115 | // final JsonNode schemaIdentifier = jsonNode.get(JSON_SCHEMA_IDENTIFIER_ELEMENT); 116 | // if (null == schemaIdentifier) { 117 | // ((ObjectNode) jsonNode).put(JSON_SCHEMA_IDENTIFIER_ELEMENT, JSON_V4_SCHEMA_IDENTIFIER); 118 | // } 119 | // 120 | // final JsonSchemaFactory factory = JsonSchemaFactory.byDefault(); 121 | // return factory.getJsonSchema(jsonNode); 122 | // } // _getSchemaNode() ends 123 | } 124 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/main/resources/payload.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "Sparkplug B Payload", 4 | "description": "A Sparkplug B payload", 5 | "definitions" : { 6 | "parameter" : { 7 | "type" : "object", 8 | "properties" : { 9 | "name" : { "type" : "string" }, 10 | "type" : { "type" : "string" }, 11 | "value" : { "type" : [ "string", "number", "integer", "boolean" ] } 12 | }, 13 | "additionalProperties" : false 14 | }, 15 | "template" : { 16 | "type" : "object", 17 | "properties" : { 18 | "version" : { "type" : "string" }, 19 | "reference" : { "type" : "string" }, 20 | "isDefinition" : { "type" : "boolean" }, 21 | "parameters" : { 22 | "type" : "array", 23 | "items" : { "$ref" : "#/definitions/parameter" } 24 | }, 25 | "metrics" : { 26 | "type" : "array", 27 | "items" : { "$ref" : "#/definitions/metric" } 28 | } 29 | }, 30 | "additionalProperties" : false 31 | }, 32 | "dataset" : { 33 | "type" : "object", 34 | "properties" : { 35 | "numberOfColumns" : { "type" : "integer" }, 36 | "columnNames" : { 37 | "type" : "array", 38 | "items" : { "type" : "string" } 39 | }, 40 | "types" : { 41 | "type" : "array", 42 | "items" : { "type" : "string" } 43 | }, 44 | "rows" : { 45 | "type" : "array", 46 | "items" : { 47 | "type" : "array", 48 | "items" : { "type" : [ "string", "number", "integer", "boolean" ] } 49 | } 50 | } 51 | }, 52 | "additionalProperties" : false 53 | }, 54 | 55 | "property" : { 56 | "type" : "object", 57 | "properties" : { 58 | "type" : { "type" : "string" }, 59 | "value" : { 60 | "oneOf" : [ 61 | { "type" : [ "string", "number", "integer", "boolean", "null" ] }, 62 | { "$ref" : "#/definitions/propertySet" }, 63 | { 64 | "type" : "array", 65 | "items" : { "$ref" : "#/definitions/propertySet" } 66 | } 67 | ] 68 | } 69 | }, 70 | "additionalProperties" : false 71 | }, 72 | 73 | "propertySet" : { 74 | "type" : "object", 75 | "additionalProperties" : { "$ref" : "#/definitions/property" } 76 | }, 77 | 78 | "metadata" : { 79 | "type" : "object", 80 | "properties" : { 81 | "contentType" : { "type" : "string" }, 82 | "isMultiPart" : { "type" : "boolean" }, 83 | "seq" : { "type" : "integer" }, 84 | "size" : { "type" : "integer" }, 85 | "fileName" : { "type" : "string" }, 86 | "fileType" : { "type" : "string" }, 87 | "md5" : { "type" : "string" }, 88 | "description" : { "type" : "string" } 89 | } 90 | }, 91 | 92 | "metric" : { 93 | "type" : "object", 94 | "properties" : { 95 | "name" : { "type" : "string" }, 96 | "alias" : { "type" : "integer" }, 97 | "timestamp" : { "type" : "integer" }, 98 | "datatype" : { "type" : "string" }, 99 | "isHistorical" : { "type" : "boolean" }, 100 | "isTransient" : { "type" : "boolean" }, 101 | "metadata" : { "$ref" : "#/definitions/metadata" }, 102 | "properties" : { "$ref" : "#/definitions/propertySet" }, 103 | "value" : { 104 | "oneOf" : [ 105 | { "type" : [ "string", "number", "integer", "boolean", "null" ] }, 106 | { "$ref" : "#/definitions/dataset" }, 107 | { "$ref" : "#/definitions/template" } 108 | ] 109 | } 110 | } 111 | } 112 | }, 113 | 114 | "type": "object", 115 | "properties": { 116 | "timestamp" : { 117 | "description" : "A timestamp in milliseconds", 118 | "type" : "integer" 119 | }, 120 | "seq" : { 121 | "description" : "A sequence number", 122 | "type" : "integer" 123 | }, 124 | "uuid" : { 125 | "description" : "A unique identifier", 126 | "type" : "string" 127 | }, 128 | "body" : { 129 | "description" : "A UTF-8 encoded string representing a byte array", 130 | "type" : "string" 131 | }, 132 | "metrics" : { 133 | "description" : "An array of metrics", 134 | "type" : "array", 135 | "items" : { "$ref" : "#/definitions/metric" } 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/java/src/test/java/org/eclipse/tahu/util/PayloadUtilTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2016, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu.util; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | 18 | import java.util.Arrays; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | import org.apache.log4j.ConsoleAppender; 23 | import org.apache.log4j.Level; 24 | import org.apache.log4j.Logger; 25 | import org.apache.log4j.PatternLayout; 26 | import org.eclipse.tahu.message.model.Metric; 27 | import org.eclipse.tahu.message.model.MetricDataType; 28 | import org.eclipse.tahu.message.model.SparkplugBPayload; 29 | import org.eclipse.tahu.message.model.Metric.MetricBuilder; 30 | import org.eclipse.tahu.message.model.SparkplugBPayload.SparkplugBPayloadBuilder; 31 | import org.eclipse.tahu.util.CompressionAlgorithm; 32 | import org.eclipse.tahu.util.PayloadUtil; 33 | import org.testng.annotations.BeforeClass; 34 | import org.testng.annotations.DataProvider; 35 | import org.testng.annotations.Test; 36 | 37 | /** 38 | * Unit tests for PayloadUtil. 39 | */ 40 | public class PayloadUtilTest { 41 | 42 | private Date testTime; 43 | 44 | public PayloadUtilTest() { 45 | this.testTime = new Date(); 46 | } 47 | 48 | @BeforeClass 49 | public void beforeClass() { 50 | Logger rootLogger = Logger.getRootLogger(); 51 | rootLogger.setLevel(Level.ALL); 52 | rootLogger.addAppender(new ConsoleAppender(new PatternLayout("%-6r [%p] %c - %m%n"))); 53 | } 54 | 55 | @DataProvider 56 | public Object[][] compressionData() throws Exception { 57 | return new Object[][] { 58 | { CompressionAlgorithm.DEFLATE, 59 | new SparkplugBPayloadBuilder().setTimestamp(testTime).setSeq(0).setUuid("123456789") 60 | .setBody("Hello".getBytes()) 61 | .addMetric( 62 | new MetricBuilder("TestInt", MetricDataType.Int32, 1234567890).createMetric()) 63 | .createPayload() }, 64 | { CompressionAlgorithm.GZIP, 65 | new SparkplugBPayloadBuilder().setTimestamp(testTime).setSeq(0).setUuid("123456789") 66 | .setBody("Hello".getBytes()) 67 | .addMetric( 68 | new MetricBuilder("TestInt", MetricDataType.Int32, 1234567890).createMetric()) 69 | .createPayload() } }; 70 | } 71 | 72 | @Test(dataProvider = "compressionData") 73 | public void testCompression(CompressionAlgorithm algorithm, SparkplugBPayload payload) throws Exception { 74 | 75 | // Compress the payload 76 | SparkplugBPayload compressedPayload = PayloadUtil.compress(payload, algorithm); 77 | 78 | // Test that there is a body (the compressed bytes) 79 | assertThat(compressedPayload.getBody() != null).isTrue(); 80 | 81 | // Test that the sequence number is the same 82 | assertThat(compressedPayload.getSeq()).isEqualTo(payload.getSeq()); 83 | 84 | // Test that the UUID is set correctly 85 | assertThat(compressedPayload.getUuid()).isEqualTo(PayloadUtil.UUID_COMPRESSED); 86 | 87 | // Decompress the payload 88 | SparkplugBPayload decompressedPayload = PayloadUtil.decompress(compressedPayload); 89 | 90 | // Test that the decompressed payload matches the original 91 | assertThat(decompressedPayload.getTimestamp()).isEqualTo(payload.getTimestamp()); 92 | assertThat(decompressedPayload.getSeq()).isEqualTo(payload.getSeq()); 93 | assertThat(decompressedPayload.getUuid()).isEqualTo(payload.getUuid()); 94 | assertThat(Arrays.equals(decompressedPayload.getBody(), payload.getBody())).isTrue(); 95 | // Test metrics 96 | List decompressedMetrics = decompressedPayload.getMetrics(); 97 | List metrics = payload.getMetrics(); 98 | for (int i = 0; i < metrics.size(); i++) { 99 | Metric decompressedMetric = decompressedMetrics.get(i); 100 | Metric metric = metrics.get(i); 101 | assertThat(decompressedMetric.getName()).isEqualTo(metric.getName()); 102 | assertThat(decompressedMetric.getValue()).isEqualTo(metric.getValue()); 103 | assertThat(decompressedMetric.getDataType()).isEqualTo(metric.getDataType()); 104 | } 105 | 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/node-red-contrib-sparkplug/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-red-contrib-sparkplug", 3 | "version": "2.1.1", 4 | "description": "A Sparkplug node for Node-RED", 5 | "license": "EPL-2.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/eclipse/tahu.git" 9 | }, 10 | "node-red": { 11 | "nodes": { 12 | "sparkplug": "sparkplug/sparkplug.js" 13 | } 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/eclipse/tahu/issues" 17 | }, 18 | "homepage": "https://github.com/eclipse/tahu", 19 | "main": "sparkplug.js", 20 | "keywords": [ 21 | "tahu", 22 | "mqtt", 23 | "sparkplug", 24 | "node-red" 25 | ], 26 | "author": "Chad Kienle (http://www.cirrus-link.com)", 27 | "dependencies": { 28 | "sparkplug-client": "^3.0.0" 29 | }, 30 | "files": [ 31 | "sparkplug/sparkplug.html", 32 | "sparkplug/sparkplug.js", 33 | "LICENSE", 34 | "README.md" 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/node-red-contrib-sparkplug/sparkplug/sparkplug.html: -------------------------------------------------------------------------------- 1 | 15 | 16 | 49 | 50 | 101 | 102 | 106 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/sparkplug-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sparkplug-client", 3 | "version": "3.2.2", 4 | "description": "A client module for MQTT communication using the Sparkplug specification from Cirrus Link Solutions", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/eclipse/tahu.git" 9 | }, 10 | "keywords": [ 11 | "tahu", 12 | "mqtt", 13 | "sparkplug" 14 | ], 15 | "author": "Chad Kienle (http://www.cirrus-link.com)", 16 | "license": "EPL-2.0", 17 | "bugs": { 18 | "url": "https://github.com/eclipse/tahu/issues" 19 | }, 20 | "homepage": "https://github.com/eclipse/tahu", 21 | "files": [ 22 | "index.js", 23 | "README.md", 24 | "LICENSE" 25 | ], 26 | "dependencies": { 27 | "mqtt": "^2.16.0", 28 | "sparkplug-payload": "^1.0.1", 29 | "pako": "^1.0.6", 30 | "winston": "^2.4.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/sparkplug-payload/README.md: -------------------------------------------------------------------------------- 1 | Sparkplug Payload 2 | ========= 3 | 4 | A library that provides tools for encoding and decoding payload objects using 5 | the Sparkplug Google Protocol Buffer Schema described in the Sparkplug 6 | Specification from Cirrus Link Solutions. 7 | 8 | https://s3.amazonaws.com/cirrus-link-com/Sparkplug+Topic+Namespace+and+State+ManagementV2.1+Apendix++Payload+B+format.pdf 9 | 10 | ## Installation 11 | 12 | npm install sparkplug-b-payload 13 | 14 | ## Usage 15 | 16 | This library supports the Sparkplug Google Protocol Buffer Schemas for the 17 | following Sparkplug namespaces: 18 | 19 | * spBv1.0 20 | * spAv1.0 (deprecated) 21 | 22 | 23 | ### Encoding a payload 24 | 25 | Here is a code example of encoding a payload: 26 | 27 | ```javascript 28 | var sparkplug = require('sparkplug-payload').get("spBv1.0"), 29 | payload = { 30 | "timestamp" : new Date().getTime(), 31 | "metrics" : [ 32 | { 33 | "name" : "intMetric", 34 | "value" : 1, 35 | "type" : "Int32" 36 | } 37 | ] 38 | }, 39 | encoded = sparkplug.encodePayload(payload); 40 | ``` 41 | 42 | ### Decoding a payload 43 | 44 | Here is a code example of decoding an encoded payload: 45 | 46 | ```javascript 47 | var decoded = sparkplug.decodePayload(encoded); 48 | ``` 49 | 50 | ## Release History 51 | 52 | * 1.0.0 Initial release 53 | 54 | ## License 55 | 56 | Copyright (c) 2017 Cirrus Link Solutions 57 | 58 | All rights reserved. This program and the accompanying materials 59 | are made available under the terms of the Eclipse Public License v1.0 60 | which accompanies this distribution, and is available at 61 | http://www.eclipse.org/legal/epl-v10.html 62 | 63 | Contributors: Cirrus Link Solutions 64 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/sparkplug-payload/index.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2017, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | var sparkplugbpayload = require('./lib/sparkplugbpayload.js'); 15 | 16 | exports.get = function(namespace) { 17 | if (namespace !== undefined && namespace !== null) { 18 | if (namespace === "spBv1.0") { 19 | return sparkplugbpayload; 20 | } 21 | } 22 | return null; 23 | }; 24 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/javascript/sparkplug-payload/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sparkplug-payload", 3 | "version": "1.0.1", 4 | "description": "A library for encoding and decoding Sparkplug payloads", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/eclipse/tahu.git" 9 | }, 10 | "keywords": [ 11 | "tahu", 12 | "mqtt", 13 | "sparkplug", 14 | "payload" 15 | ], 16 | "author": "Chad Kienle (http://www.cirrus-link.com)", 17 | "license": "EPL-2.0", 18 | "bugs": { 19 | "url": "https://github.com/eclipse/tahu/issues" 20 | }, 21 | "homepage": "https://github.com/eclipse/tahu", 22 | "files": [ 23 | "index.js", 24 | "lib/sparkplugbpayload.js", 25 | "README.md", 26 | "LICENSE" 27 | ], 28 | "dependencies": { 29 | "protobufjs": "^6.8.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/python/__init__.py -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/__pycache__/sparkplug_b.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/python/__pycache__/sparkplug_b.cpython-36.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/__pycache__/sparkplug_b_pb2.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/python/__pycache__/sparkplug_b_pb2.cpython-36.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/readme.txt: -------------------------------------------------------------------------------- 1 | # To generate the base protobuf sparkplug_b Python library 2 | protoc -I=../../sparkplug_b/ --python_out=. ../../sparkplug_b/sparkplug_b.proto 3 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/sparkplug_b.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/python/sparkplug_b.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/client_libraries/python/sparkplug_b_pb2.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/client_libraries/python/sparkplug_b_pb2.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/dstest1_pgie_config.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the "Software"), 6 | # to deal in the Software without restriction, including without limitation 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | # and/or sell copies of the Software, and to permit persons to whom the 9 | # Software is furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | ################################################################################ 22 | 23 | # Following properties are mandatory when engine files are not specified: 24 | # int8-calib-file(Only in INT8) 25 | # Caffemodel mandatory properties: model-file, proto-file, output-blob-names 26 | # UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names 27 | # ONNX: onnx-file 28 | # 29 | # Mandatory properties for detectors: 30 | # num-detected-classes 31 | # 32 | # Optional properties for detectors: 33 | # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) 34 | # custom-lib-path, 35 | # parse-bbox-func-name 36 | # 37 | # Mandatory properties for classifiers: 38 | # classifier-threshold, is-classifier 39 | # 40 | # Optional properties for classifiers: 41 | # classifier-async-mode(Secondary mode only, Default=false) 42 | # 43 | # Optional properties in secondary mode: 44 | # operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes), 45 | # input-object-min-width, input-object-min-height, input-object-max-width, 46 | # input-object-max-height 47 | # 48 | # Following properties are always recommended: 49 | # batch-size(Default=1) 50 | # 51 | # Other optional properties: 52 | # net-scale-factor(Default=1), network-mode(Default=0 i.e FP32), 53 | # model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path, 54 | # mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary), 55 | # custom-lib-path, network-mode(Default=0 i.e FP32) 56 | # 57 | # The values in the config file are overridden by values set through GObject 58 | # properties. 59 | 60 | [property] 61 | gpu-id=0 62 | net-scale-factor=0.0039215697906911373 63 | model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel 64 | proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt 65 | model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine 66 | labelfile-path=../../../../samples/models/Primary_Detector/labels.txt 67 | int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin 68 | force-implicit-batch-dim=1 69 | batch-size=1 70 | network-mode=1 71 | num-detected-classes=4 72 | interval=0 73 | gie-unique-id=1 74 | output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid 75 | #scaling-filter=0 76 | #scaling-compute-hw=0 77 | 78 | [class-attrs-all] 79 | pre-cluster-threshold=0.2 80 | eps=0.2 81 | group-threshold=1 82 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/sparkplug_b.pyc -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | 2 | Lists of 5 third-party dependencies. 3 | (New BSD license) Protocol Buffer Java API (com.google.protobuf:protobuf-java:2.6.1 - https://developers.google.com/protocol-buffers/) 4 | (The Apache Software License, Version 2.0) Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) 5 | (Eclipse Public License - Version 1.0) org.eclipse.paho.client.mqttv3 (org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2 - http://www.eclipse.org/paho/org.eclipse.paho.client.mqttv3) 6 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.5 - http://www.slf4j.org) 7 | (MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org) 8 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_raspberry_pi_example 27 | 0.5.8 28 | jar 29 | Maven Quick Start Archetype 30 | 31 | 32 | Kura Releases 33 | Kura Repository - Releases 34 | https://repo.eclipse.org/content/repositories/kura-releases/ 35 | 36 | 37 | 38 | 39 | org.eclipse.tahu 40 | tahu-java 41 | ${tahu.version} 42 | 43 | 44 | org.eclipse.kura 45 | jdk.dio 46 | 1.0.400 47 | 48 | 49 | javax.xml.bind 50 | jaxb-api 51 | 2.3.0 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-deploy-plugin 59 | 2.7 60 | 61 | true 62 | 63 | 64 | 65 | 66 | 67 | org.apache.maven.plugins 68 | maven-shade-plugin 69 | 2.4.1 70 | 71 | 72 | package 73 | 74 | shade 75 | 76 | 77 | 78 | 79 | *:* 80 | 81 | META-INF/*.SF 82 | META-INF/*.DSA 83 | META-INF/*.RSA 84 | 85 | 86 | 87 | 88 | 90 | org.eclipse.tahu.SparkplugRaspberryPiExample 91 | 92 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.codehaus.mojo 101 | license-maven-plugin 102 | 1.8 103 | 104 | 105 | add-third-party 106 | package 107 | 108 | add-third-party 109 | download-licenses 110 | 111 | 112 | true 113 | test 114 | (org.eclipse.tahu*) 115 | 116 | 117 | The Apache Software License, Version 118 | 2.0|Apache License, Version 2.0|Apache Public License 119 | 2.0|Apache License 2.0|Apache Software License - 120 | Version 2.0 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/dio/DigitalOutputPin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.dio; 14 | 15 | /** 16 | * Defines digital output pin 17 | */ 18 | public class DigitalOutputPin extends DioPin { 19 | 20 | public DigitalOutputPin(String name) { 21 | super(name); 22 | } 23 | 24 | /** 25 | * Sets pin high 26 | * 27 | * @throws DioException 28 | */ 29 | public void setHigh() throws DioException { 30 | try { 31 | getGpioPin().setValue(true); 32 | } catch (Exception e) { 33 | throw new DioException("failed to set " + getPinName() + " HIGH", e); 34 | } 35 | } 36 | 37 | /** 38 | * Sets pin low 39 | * 40 | * @throws DioException 41 | */ 42 | public void setLow() throws DioException { 43 | try { 44 | getGpioPin().setValue(false); 45 | } catch (Exception e) { 46 | throw new DioException("failed to set " + getPinName() + " LOW", e); 47 | } 48 | } 49 | 50 | /** 51 | * Sets pin state 52 | * 53 | * @param state - pin state as {@link boolean} 54 | * @throws DioException 55 | */ 56 | public void setState(boolean state) throws DioException { 57 | try { 58 | getGpioPin().setValue(state); 59 | } catch (Exception e) { 60 | throw new DioException("failed to set state of " + getPinName() + " to " + state, e); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/dio/DioException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.dio; 14 | 15 | /** 16 | * Defines DIO Exception 17 | */ 18 | public class DioException extends Exception { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | public DioException(String msg) { 23 | super(msg); 24 | } 25 | 26 | public DioException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/dio/DioPin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.dio; 14 | 15 | import jdk.dio.DeviceManager; 16 | import jdk.dio.gpio.GPIOPin; 17 | import jdk.dio.gpio.GPIOPinConfig; 18 | 19 | /** 20 | * Defines digital I/O pin 21 | */ 22 | public class DioPin { 23 | 24 | private String pinName; 25 | private GPIOPin gpioPin; 26 | 27 | public DioPin(String name) { 28 | this.pinName = name; 29 | } 30 | 31 | /** 32 | * Reports pin name 33 | * 34 | * @return pin name as {@link String} 35 | */ 36 | public String getPinName() { 37 | return this.pinName; 38 | } 39 | 40 | /** 41 | * Gets GPIO pin 42 | * 43 | * @return GPIO pin as {@link GPIOPin} 44 | */ 45 | public GPIOPin getGpioPin() { 46 | return this.gpioPin; 47 | } 48 | 49 | /** 50 | * Sets GPIO pin 51 | * 52 | * @param gpioPin - GPIO pin as {@link GPIOPin} 53 | */ 54 | public void setGpioPin(GPIOPin gpioPin) { 55 | this.gpioPin = gpioPin; 56 | } 57 | 58 | public static GPIOPin open(String pinName, GPIOPinConfig gpioPinConfig) throws DioException { 59 | GPIOPin pin; 60 | try { 61 | pin = DeviceManager.open(GPIOPin.class, gpioPinConfig); 62 | } catch (Exception e) { 63 | throw new DioException("failed to open GPIO pin: " + pinName, e); 64 | } 65 | return pin; 66 | } 67 | 68 | /** 69 | * Closes GPIO pin 70 | * 71 | * @throws DioException 72 | */ 73 | public void close() throws DioException { 74 | try { 75 | if (this.gpioPin.isOpen()) { 76 | this.gpioPin.close(); 77 | } 78 | } catch (Exception e) { 79 | throw new DioException("failed to close " + this.pinName, e); 80 | } 81 | } 82 | 83 | /** 84 | * Reports if GPIO pin state 85 | * 86 | * @return GPIO pin state as {@link boolean} 87 | * @throws DioException 88 | */ 89 | public boolean isHigh() throws DioException { 90 | boolean ret = false; 91 | try { 92 | ret = this.gpioPin.getValue(); 93 | } catch (Exception e) { 94 | throw new DioException("Failed obtain a state of " + this.pinName, e); 95 | } 96 | return ret; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/dio/PinDirection.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.dio; 14 | 15 | /** 16 | * Enumerates DPIO pin directions 17 | */ 18 | public enum PinDirection { 19 | INPUT, OUTPUT; 20 | } 21 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/dio/Pins.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.dio; 14 | 15 | /** 16 | * Enumerates Raspbery Pi pins 17 | */ 18 | public enum Pins { 19 | P3(2, "GPIO2 (SDA1, I2C)"), 20 | P5(3, "GPIO3 (SCL1, I2C)"), 21 | P7(4, "GPIO4 (GPIO_GCLK)"), 22 | P8(14, "GPIO14 (TXD0)"), 23 | P10(15, "GPIO15 (RXD0)"), 24 | P11(17, "GPIO17 (GPIO_GEN0)"), 25 | P12(18, "GPIO18 (GPIO_GEN1)"), 26 | P13(27, "GPIO27 (GPIO_GEN2)"), 27 | P15(22, "GPIO22 (GPIO_GEN3)"), 28 | P16(23, "GPIO23 (GPIO_GEN4)"), 29 | P18(24, "GPIO24 (GPIO_GEN5)"), 30 | P19(10, "GPIO10, (SPI_MOSI)"), 31 | P21(9, "GPIO9, (SPI_MISO)"), 32 | P22(25, "GPIO25, (GPIO_GEN6)"), 33 | P23(11, "GPIO11 (SPI_CLK)"), 34 | P24(8, "GPIO8 (SPI_CE0_N)"), 35 | P26(7, "GPIO7 (SPI_CE1_N)"), 36 | P27(0, "ID_SD (I2C ID EEPROM)"), 37 | P28(1, "ID_SC (I2C ID EEPROM)"), 38 | P29(5, "GPIO5"), 39 | P31(6, "GPIO6"), 40 | P32(12, "GPIO12"), 41 | P33(13, "GPIO13"), 42 | P35(19, "GPIO19"), 43 | P36(16, "GPIO16"), 44 | P337(26, "GPIO26"), 45 | P38(20, "GPIO20"), 46 | P40(21, "GPIO21"); 47 | 48 | private int gpio; 49 | private String name; 50 | 51 | private Pins (int gpio, String name) { 52 | this.gpio = gpio; 53 | this.name = name; 54 | } 55 | 56 | public int getGPIO() { 57 | return this.gpio; 58 | } 59 | 60 | public String getName() { 61 | return this.name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/system/BoardModels.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.system; 14 | 15 | /** 16 | * Enumerates Raspberry Pi board models 17 | */ 18 | public enum BoardModels { 19 | // Obtained from https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md 20 | CODE_900021("900021", Constants.A_PLUS, 1.1f, 512, Constants.SONY_UK), 21 | CODE_900032("900032", Constants.B_PLUS, 1.2f, 512, Constants.SONY_UK), 22 | CODE_900092("900092", Constants.ZERO, 1.2f, 512, Constants.SONY_UK), 23 | CODE_920092("920092", Constants.ZERO, 1.2f, 512, Constants.EMBEST), 24 | CODE_900093("900093", Constants.ZERO, 1.3f, 512, Constants.SONY_UK), 25 | CODE_9000C1("9000c1", Constants.ZERO_W, 1.1f, 512, Constants.SONY_UK), 26 | CODE_920093("920093", Constants.ZERO, 1.3f, 512, Constants.SONY_UK), 27 | CODE_A01040("a01040", Constants.B2, 1.0f, 10124, Constants.SONY_UK), 28 | CODE_A01041("a01041", Constants.B2, 1.1f, 1024, Constants.SONY_UK), 29 | CODE_A02082("a02082", Constants.B3, 1.2f, 1024, Constants.SONY_UK), 30 | CODE_A020A0("a020a0", Constants.CM3, 1.0f, 1024, Constants.SONY_UK), 31 | CODE_A21041("a21041", Constants.B2, 1.1f, 1024, Constants.EMBEST), 32 | CODE_A22042("a22042", Constants.B2_BCM2837, 1.2f, 1024, Constants.EMBEST), 33 | CODE_A22082("a22082", Constants.B3, 1.2f, 1024, Constants.EMBEST), 34 | CODE_A32082("a32082", Constants.B3, 1.2f, 1024, Constants.SONY_JAPAN), 35 | CODE_A52082("a52082", Constants.B3, 1.2f, 1024, Constants.STADIUM), 36 | CODE_A020D3("a020d3", Constants.B3_PLUS, 1.3f, 10124, Constants.SONY_UK), 37 | CODE_9020E0("9020e0", Constants.A3_PLUS, 1.0f, 512, Constants.SONY_UK); 38 | 39 | private String code; 40 | private String model; 41 | private float revision; 42 | private int ramSize; 43 | private String manufacturer; 44 | 45 | private BoardModels(String code, String model, float revision, int ramSize, String manufacturer) { 46 | this.code = code; 47 | this.model = model; 48 | this.revision = revision; 49 | this.ramSize = ramSize; 50 | this.manufacturer = manufacturer; 51 | } 52 | 53 | public String getCode() { 54 | return code; 55 | } 56 | 57 | public String getModel() { 58 | return this.model; 59 | } 60 | 61 | public float getRevision() { 62 | return this.revision; 63 | } 64 | 65 | public int getRamSize() { 66 | return this.ramSize; 67 | } 68 | 69 | public String getManufacturer() { 70 | return this.manufacturer; 71 | } 72 | 73 | private static class Constants { 74 | private static final String A_PLUS = "A+"; 75 | private static final String B_PLUS = "B+"; 76 | private static final String ZERO = "Zero"; 77 | private static final String ZERO_W = "Zero W"; 78 | private static final String B2 = "2B"; 79 | private static final String B3 = "3B"; 80 | private static final String CM3 = "CM3"; 81 | private static final String B2_BCM2837 = "2B (with BCM2837)"; 82 | private static final String A3_PLUS = "3A+"; 83 | private static final String B3_PLUS = "3B+"; 84 | 85 | private static final String SONY_UK = "Sony UK"; 86 | private static final String EMBEST = "Embest"; 87 | private static final String SONY_JAPAN = "Sony Japan"; 88 | private static final String STADIUM = "Stadium"; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pi/system/SystemInfoException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pi.system; 14 | 15 | /** 16 | * Defines SystemInfoException 17 | */ 18 | public class SystemInfoException extends Exception { 19 | private static final long serialVersionUID = 1L; 20 | 21 | public SystemInfoException(String msg) { 22 | super(msg); 23 | } 24 | 25 | public SystemInfoException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/Pibrella.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import java.io.IOException; 16 | import java.util.EnumMap; 17 | import java.util.Map; 18 | 19 | import org.eclipse.tahu.pi.dio.DioException; 20 | 21 | import jdk.dio.gpio.GPIOPin; 22 | 23 | /** 24 | * Defines Pibrella class 25 | */ 26 | public class Pibrella { 27 | 28 | private static Pibrella instance; 29 | 30 | // Pibrella I/O pins 31 | private Map pins; 32 | 33 | private Pibrella() { 34 | this.pins = new EnumMap<>(PibrellaPins.class); 35 | } 36 | 37 | /** 38 | * Gets an instance of Pibrella class 39 | * 40 | * @return an instance of Pibrella class as {@link Pibrella} 41 | */ 42 | public static Pibrella getInstance() { 43 | if (instance == null) { 44 | instance = new Pibrella(); 45 | } 46 | return instance; 47 | } 48 | 49 | /** 50 | * Gets registered Pibrella I/O pins 51 | * 52 | * @return a map of registered Pibrella I/O pins as {@link Map} 53 | */ 54 | public Map getRegisteredPins() { 55 | return this.pins; 56 | } 57 | 58 | /** 59 | * Registers specified Pibrella I/O pin 60 | * 61 | * @param pin - Pibrella pin as {@link PibrellaPins} 62 | * @param gpioPin - GPIO pin as {@link GPIOPin} 63 | */ 64 | public void registerPin(PibrellaPins pin, GPIOPin gpioPin) { 65 | this.pins.put(pin, gpioPin); 66 | } 67 | 68 | /** 69 | * Gets specified Pibrella input 70 | * 71 | * @param input - Pibrella input pin as {@link PibrellaInputPins} 72 | * @return Pibrella Input pin as {@link PibrellaInputPin} 73 | * @throws DioException 74 | */ 75 | public PibrellaInputPin getInput(PibrellaInputPins input) throws DioException { 76 | return PibrellaInputPin.getInstance(input); 77 | } 78 | 79 | /** 80 | * Gets specified Pibrella output 81 | * 82 | * @param output Pibrella output pin as {@link PibrellaOutputPins} 83 | * @return Pibrella output pin as {@link PibrellaOutputPin} 84 | * @throws DioException 85 | */ 86 | public PibrellaOutputPin getOutput(PibrellaOutputPins output) throws DioException { 87 | return PibrellaOutputPin.getInstance(output); 88 | } 89 | 90 | /** 91 | * Gets Pibrella button 92 | * 93 | * @return Pibrella button as {@link PibrellaButton} 94 | * @throws DioException 95 | */ 96 | public PibrellaButton getButton() throws DioException { 97 | return PibrellaButton.getInstance(); 98 | } 99 | 100 | /** 101 | * Gets Pibrella buzzer 102 | * 103 | * @return Pibrella buzzer as {@link PibrellaBuzzer} 104 | * @throws DioException 105 | */ 106 | public PibrellaBuzzer getBuzzer() throws DioException { 107 | return PibrellaBuzzer.getInstance(); 108 | } 109 | 110 | /** 111 | * Gets specified Pibrella LED 112 | * 113 | * @param led - Pibrella LED as {@link PibrellaLEDs} 114 | * @return Pibrella LED as {@link PibrellaLED} 115 | * @throws DioException 116 | */ 117 | public PibrellaLED getLED(PibrellaLEDs led) throws DioException { 118 | return PibrellaLED.getInstance(led); 119 | } 120 | 121 | /** 122 | * Closes all Pibrella I/O pins 123 | */ 124 | public void closeAllIOpins() { 125 | this.pins.keySet().forEach(pin -> { 126 | GPIOPin gpioPin = this.pins.get(pin); 127 | try { 128 | gpioPin.close(); 129 | } catch (IOException e) { 130 | System.out.println("Failed ot close Pibrella pin: " + pin.getDescription()); 131 | } 132 | }); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaButton.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import org.eclipse.tahu.pi.dio.DioException; 16 | import org.eclipse.tahu.pi.dio.DioPin; 17 | 18 | import jdk.dio.DeviceConfig; 19 | import jdk.dio.gpio.GPIOPin; 20 | import jdk.dio.gpio.GPIOPinConfig; 21 | 22 | /** 23 | * Defines Pibrella button 24 | */ 25 | public class PibrellaButton extends DioPin { 26 | 27 | private static PibrellaButton instance; 28 | 29 | private PibrellaButton() { 30 | super(PibrellaPins.BUTTON.getName()); 31 | } 32 | 33 | /** 34 | * Gets an instance of Pibrella button 35 | * 36 | * @return instance of Pibrella button as {@link PibrellaButton} 37 | * @throws DioException 38 | */ 39 | public static PibrellaButton getInstance() throws DioException { 40 | if (instance == null) { 41 | instance = new PibrellaButton(); 42 | } 43 | GPIOPin gpioPin = Pibrella.getInstance().getRegisteredPins().get(PibrellaPins.BUTTON); 44 | if (gpioPin == null || !gpioPin.isOpen()) { 45 | gpioPin = open(PibrellaPins.BUTTON.getName(), 46 | new GPIOPinConfig(DeviceConfig.DEFAULT, PibrellaPins.BUTTON.getGPIO(), GPIOPinConfig.DIR_INPUT_ONLY, 47 | GPIOPinConfig.MODE_INPUT_PULL_DOWN, GPIOPinConfig.TRIGGER_BOTH_EDGES, false)); 48 | instance.setGpioPin(gpioPin); 49 | Pibrella.getInstance().registerPin(PibrellaPins.BUTTON, gpioPin); 50 | } 51 | return instance; 52 | } 53 | 54 | /** 55 | * Reports if button is pressed 56 | * 57 | * @return button state as {@link boolean} 58 | * @throws DioException 59 | */ 60 | public boolean isPressed() throws DioException { 61 | return isHigh(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaBuzzer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import org.eclipse.tahu.pi.dio.DigitalOutputPin; 16 | import org.eclipse.tahu.pi.dio.DioException; 17 | 18 | import jdk.dio.DeviceConfig; 19 | import jdk.dio.gpio.GPIOPin; 20 | import jdk.dio.gpio.GPIOPinConfig; 21 | 22 | /** 23 | * Defines Pibrella buzzer 24 | */ 25 | public class PibrellaBuzzer extends DigitalOutputPin { 26 | 27 | private static PibrellaBuzzer instance; 28 | private Object lock = new Object(); 29 | 30 | private PibrellaBuzzer() { 31 | super(PibrellaPins.BUZZER.getName()); 32 | } 33 | 34 | /** 35 | * Gets an instance of Pibrella buzzer 36 | * 37 | * @return instance of Pibrella buzzer as {@link PibrellaBuzzer} 38 | * @throws DioException 39 | */ 40 | public static PibrellaBuzzer getInstance() throws DioException { 41 | if (instance == null) { 42 | instance = new PibrellaBuzzer(); 43 | } 44 | GPIOPin gpioPin = Pibrella.getInstance().getRegisteredPins().get(PibrellaPins.BUZZER); 45 | if (gpioPin == null || !gpioPin.isOpen()) { 46 | gpioPin = open(PibrellaPins.BUZZER.getName(), 47 | new GPIOPinConfig(DeviceConfig.DEFAULT, PibrellaPins.BUZZER.getGPIO(), 48 | GPIOPinConfig.DIR_OUTPUT_ONLY, GPIOPinConfig.MODE_OUTPUT_PUSH_PULL, 49 | GPIOPinConfig.TRIGGER_NONE, false)); 50 | instance.setGpioPin(gpioPin); 51 | Pibrella.getInstance().registerPin(PibrellaPins.BUZZER, gpioPin); 52 | } 53 | return instance; 54 | } 55 | 56 | /** 57 | * Starts the buzzer at specified frequency for a specified duration (in milliseconds) 58 | * 59 | * @param frequency as {@link int} 60 | * @param duration number of milliseconds as {@link int} 61 | */ 62 | public void buzz(int frequency, int duration) { 63 | new Buzzer(frequency, duration).start(); 64 | } 65 | 66 | /* 67 | * Defines buzzer 68 | */ 69 | private class Buzzer extends Thread { 70 | 71 | private int frequency; 72 | private int duration; 73 | 74 | private Buzzer(int frequency, int duration) { 75 | this.frequency = frequency; 76 | this.duration = duration; 77 | } 78 | 79 | @Override 80 | public void run() { 81 | synchronized (lock) { 82 | long startTime = System.currentTimeMillis(); 83 | int halfPeriod = 1000 / (2 * this.frequency); 84 | while ((System.currentTimeMillis() - startTime) < this.duration) { 85 | try { 86 | setHigh(); 87 | lock.wait(halfPeriod); 88 | setLow(); 89 | } catch (Exception e) { 90 | System.out.println("failed to buzz"); 91 | break; 92 | } 93 | } 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaInputPin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import java.util.EnumMap; 16 | import java.util.Map; 17 | 18 | import org.eclipse.tahu.pi.dio.DioException; 19 | import org.eclipse.tahu.pi.dio.DioPin; 20 | 21 | import jdk.dio.DeviceConfig; 22 | import jdk.dio.gpio.GPIOPin; 23 | import jdk.dio.gpio.GPIOPinConfig; 24 | 25 | /** 26 | * Defines Pibrella input pin 27 | */ 28 | public class PibrellaInputPin extends DioPin { 29 | 30 | private static Map inputs = new EnumMap<>(PibrellaInputPins.class); 31 | 32 | private PibrellaInputPin(PibrellaInputPins input) { 33 | super(input.getName()); 34 | } 35 | 36 | /** 37 | * Gets an instance of PibrellaInputPin class 38 | * 39 | * @param input - pibrella input pin 40 | * @return instance of PibrellaInputPin class as {@link PibrellaInputPin} 41 | * @throws DioException 42 | */ 43 | public static PibrellaInputPin getInstance(PibrellaInputPins input) throws DioException { 44 | PibrellaInputPin pibrellaInput = inputs.get(input); 45 | if (inputs.get(input) == null) { 46 | pibrellaInput = new PibrellaInputPin(input); 47 | inputs.put(input, pibrellaInput); 48 | } 49 | GPIOPin gpioPin = Pibrella.getInstance().getRegisteredPins().get(input.getPin()); 50 | if (gpioPin == null || !gpioPin.isOpen()) { 51 | gpioPin = open(input.getName(), 52 | new GPIOPinConfig(DeviceConfig.DEFAULT, input.getPin().getGPIO(), GPIOPinConfig.DIR_INPUT_ONLY, 53 | GPIOPinConfig.MODE_INPUT_PULL_DOWN, GPIOPinConfig.TRIGGER_BOTH_EDGES, false)); 54 | pibrellaInput.setGpioPin(gpioPin); 55 | Pibrella.getInstance().registerPin(input.getPin(), gpioPin); 56 | } 57 | return pibrellaInput; 58 | } 59 | 60 | /** 61 | * Closes all Pibrella input pins 62 | */ 63 | public static void closeAll() { 64 | inputs.values().forEach(input -> { 65 | try { 66 | input.close(); 67 | } catch (Exception e) { 68 | System.out.println("failed to close " + input.getPinName()); 69 | } 70 | }); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaInputPins.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | /** 16 | * Enumerates Pibrella input pins 17 | */ 18 | public enum PibrellaInputPins { 19 | A(PibrellaPins.INA), 20 | B(PibrellaPins.INB), 21 | C(PibrellaPins.INC), 22 | D(PibrellaPins.IND); 23 | 24 | private PibrellaPins pin; 25 | 26 | private PibrellaInputPins(PibrellaPins pin) { 27 | this.pin = pin; 28 | } 29 | 30 | public PibrellaPins getPin() { 31 | return this.pin; 32 | } 33 | 34 | public int getGPIO() { 35 | return this.pin.getGPIO(); 36 | } 37 | 38 | public String getName() { 39 | return this.getPin().getName(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaLED.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import java.util.EnumMap; 16 | import java.util.Map; 17 | 18 | import org.eclipse.tahu.pi.dio.DigitalOutputPin; 19 | import org.eclipse.tahu.pi.dio.DioException; 20 | 21 | import jdk.dio.DeviceConfig; 22 | import jdk.dio.gpio.GPIOPin; 23 | import jdk.dio.gpio.GPIOPinConfig; 24 | 25 | /** 26 | * Defines Pibrella LED 27 | */ 28 | public class PibrellaLED extends DigitalOutputPin { 29 | 30 | private static Map leds = new EnumMap<>(PibrellaLEDs.class); 31 | 32 | private PibrellaLED(PibrellaLEDs led) { 33 | super(led.getName()); 34 | } 35 | 36 | /** 37 | * Gets an instance of PibrellaLED class 38 | * 39 | * @param led - Pibrellas LED 40 | * @return instance of PibrellaLED class as {@link PibrellaLED} 41 | * @throws DioException 42 | */ 43 | public static PibrellaLED getInstance(PibrellaLEDs led) throws DioException { 44 | PibrellaLED pibrellaLED = leds.get(led); 45 | if (leds.get(led) == null) { 46 | pibrellaLED = new PibrellaLED(led); 47 | leds.put(led, pibrellaLED); 48 | } 49 | GPIOPin gpioPin = Pibrella.getInstance().getRegisteredPins().get(led.getPin()); 50 | if (gpioPin == null || !gpioPin.isOpen()) { 51 | gpioPin = open(led.getName(), 52 | new GPIOPinConfig(DeviceConfig.DEFAULT, led.getPin().getGPIO(), GPIOPinConfig.DIR_OUTPUT_ONLY, 53 | GPIOPinConfig.MODE_OUTPUT_PUSH_PULL, GPIOPinConfig.TRIGGER_NONE, false)); 54 | pibrellaLED.setGpioPin(gpioPin); 55 | Pibrella.getInstance().registerPin(led.getPin(), gpioPin); 56 | } 57 | return pibrellaLED; 58 | } 59 | 60 | /** 61 | * Closes all LEDs 62 | */ 63 | public static void closeAll() { 64 | leds.values().forEach(led -> { 65 | try { 66 | led.close(); 67 | } catch (Exception e) { 68 | System.out.println("failed to close " + led.getPinName()); 69 | } 70 | }); 71 | } 72 | 73 | /** 74 | * Turns LED on 75 | * 76 | * @throws DioException 77 | */ 78 | public void turnOn() throws DioException { 79 | setHigh(); 80 | } 81 | 82 | /** 83 | * Turns LED off 84 | * 85 | * @throws DioException 86 | */ 87 | public void turnOff() throws DioException { 88 | setLow(); 89 | } 90 | 91 | /** 92 | * Reports if LED is on 93 | * 94 | * @return LED state as {@link boolean} 95 | * @throws DioException 96 | */ 97 | public boolean isOn() throws DioException { 98 | return isHigh(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaLEDs.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | /** 16 | * Enumerates Pibrella LEDs 17 | */ 18 | public enum PibrellaLEDs { 19 | GREEN (PibrellaPins.LEDG), 20 | YELLOW (PibrellaPins.LEDY), 21 | RED (PibrellaPins.LEDR); 22 | 23 | private PibrellaPins pin; 24 | 25 | private PibrellaLEDs(PibrellaPins pin) { 26 | this.pin = pin; 27 | } 28 | 29 | public PibrellaPins getPin() { 30 | return this.pin; 31 | } 32 | 33 | public int getGPIO() { 34 | return this.pin.getGPIO(); 35 | } 36 | 37 | public String getName() { 38 | return this.getPin().getName(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaOutputPin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import java.util.EnumMap; 16 | import java.util.Map; 17 | 18 | import org.eclipse.tahu.pi.dio.DigitalOutputPin; 19 | import org.eclipse.tahu.pi.dio.DioException; 20 | 21 | import jdk.dio.DeviceConfig; 22 | import jdk.dio.gpio.GPIOPin; 23 | import jdk.dio.gpio.GPIOPinConfig; 24 | 25 | /** 26 | * Defines Pibrella output pin 27 | */ 28 | public class PibrellaOutputPin extends DigitalOutputPin { 29 | 30 | private static Map outputs = new EnumMap<>(PibrellaOutputPins.class); 31 | 32 | private PibrellaOutputPin(PibrellaOutputPins output) { 33 | super(output.getName()); 34 | } 35 | 36 | /** 37 | * Gets an instance of PibrellaOutputPin class 38 | * 39 | * @param output - Pibrella output pin 40 | * @return instance of PibrellaOutputPin class as {@link PibrellaOutputPin} 41 | * @throws DioException 42 | */ 43 | public static PibrellaOutputPin getInstance(PibrellaOutputPins output) throws DioException { 44 | PibrellaOutputPin pibrellaOutput = outputs.get(output); 45 | if (outputs.get(output) == null) { 46 | pibrellaOutput = new PibrellaOutputPin(output); 47 | outputs.put(output, pibrellaOutput); 48 | } 49 | GPIOPin gpioPin = Pibrella.getInstance().getRegisteredPins().get(output.getPin()); 50 | if (gpioPin == null || !gpioPin.isOpen()) { 51 | gpioPin = open(output.getName(), 52 | new GPIOPinConfig(DeviceConfig.DEFAULT, output.getPin().getGPIO(), GPIOPinConfig.DIR_OUTPUT_ONLY, 53 | GPIOPinConfig.MODE_OUTPUT_PUSH_PULL, GPIOPinConfig.TRIGGER_NONE, false)); 54 | pibrellaOutput.setGpioPin(gpioPin); 55 | Pibrella.getInstance().registerPin(output.getPin(), gpioPin); 56 | } 57 | return pibrellaOutput; 58 | } 59 | 60 | /** 61 | * Closes all Pibrella output pins 62 | */ 63 | public static void closeAll() { 64 | outputs.values().forEach(output -> { 65 | try { 66 | output.close(); 67 | } catch (Exception e) { 68 | System.out.println("failed to close " + output.getPinName()); 69 | } 70 | }); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaOutputPins.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | /** 16 | * Enumerates Pibrella output pins 17 | */ 18 | public enum PibrellaOutputPins { 19 | E(PibrellaPins.OUTE), 20 | F(PibrellaPins.OUTF), 21 | G(PibrellaPins.OUTG), 22 | H(PibrellaPins.OUTH); 23 | 24 | private PibrellaPins pin; 25 | 26 | private PibrellaOutputPins(PibrellaPins pin) { 27 | this.pin = pin; 28 | } 29 | 30 | public PibrellaPins getPin() { 31 | return this.pin; 32 | } 33 | 34 | public int getGPIO() { 35 | return this.pin.getGPIO(); 36 | } 37 | 38 | public String getName() { 39 | return this.getPin().getName(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/java/org/eclipse/tahu/pibrella/PibrellaPins.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | package org.eclipse.tahu.pibrella; 14 | 15 | import org.eclipse.tahu.pi.dio.PinDirection; 16 | import org.eclipse.tahu.pi.dio.Pins; 17 | 18 | /** 19 | * Enumerates Pibrella I/O pins 20 | */ 21 | public enum PibrellaPins { 22 | INA(Pins.P21, PinDirection.INPUT, "Input A", "Inputs/a"), 23 | INB(Pins.P26, PinDirection.INPUT, "Input B", "Inputs/b"), 24 | INC(Pins.P24, PinDirection.INPUT, "Input C", "Inputs/c"), 25 | IND(Pins.P19, PinDirection.INPUT, "Input D", "Inputs/d"), 26 | BUTTON(Pins.P23, PinDirection.INPUT, "Button", "button"), 27 | OUTE(Pins.P15, PinDirection.OUTPUT, "Output E", "Outputs/e"), 28 | OUTF(Pins.P16, PinDirection.OUTPUT, "Output F", "Outputs/f"), 29 | OUTG(Pins.P18, PinDirection.OUTPUT, "Output G", "Outputs/g"), 30 | OUTH(Pins.P22, PinDirection.OUTPUT, "Output H", "Outputs/h"), 31 | LEDG(Pins.P7, PinDirection.OUTPUT, "Green LED", "Outputs/LEDs/green"), 32 | LEDY(Pins.P11, PinDirection.OUTPUT, "Yellow LED", "Outputs/LEDs/yellow"), 33 | LEDR(Pins.P13, PinDirection.OUTPUT, "Red LED", "Outputs/LEDs/red"), 34 | BUZZER(Pins.P12, PinDirection.OUTPUT, "Buzzer", "buzzer"); 35 | 36 | private Pins pin; 37 | private PinDirection direction; 38 | private String name; 39 | private String description; 40 | 41 | private PibrellaPins(Pins pin, PinDirection direction, String name, String description) { 42 | this.pin = pin; 43 | this.direction = direction; 44 | this.name = name; 45 | this.description = description; 46 | } 47 | 48 | public Pins getPin() { 49 | return this.pin; 50 | } 51 | 52 | public int getGPIO() { 53 | return this.pin.getGPIO(); 54 | } 55 | 56 | public PinDirection getDirection() { 57 | return this.direction; 58 | } 59 | 60 | public String getName() { 61 | return this.name; 62 | } 63 | 64 | public String getDescription() { 65 | return this.description; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/resources/libdio.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/sparkplug_b/raspberry_pi_examples/java/src/main/resources/libdio.so -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/sparkplug_b.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "Sparkplug B Payload", 4 | "description": "A Sparkplug B payload", 5 | "definitions" : { 6 | "parameter" : { 7 | "type" : "object", 8 | "properties" : { 9 | "name" : { "type" : "string" }, 10 | "type" : { "type" : "string" }, 11 | "value" : { "type" : [ "string", "number", "integer", "boolean" ] } 12 | }, 13 | "additionalProperties" : false 14 | }, 15 | "template" : { 16 | "type" : "object", 17 | "properties" : { 18 | "version" : { "type" : "string" }, 19 | "reference" : { "type" : "string" }, 20 | "isDefinition" : { "type" : "boolean" }, 21 | "parameters" : { 22 | "type" : "array", 23 | "items" : { "$ref" : "#/definitions/parameter" } 24 | }, 25 | "metrics" : { 26 | "type" : "array", 27 | "items" : { "$ref" : "#/definitions/metric" } 28 | } 29 | }, 30 | "additionalProperties" : false 31 | }, 32 | "dataset" : { 33 | "type" : "object", 34 | "properties" : { 35 | "numberOfColumns" : { "type" : "integer" }, 36 | "columnNames" : { 37 | "type" : "array", 38 | "items" : { "type" : "string" } 39 | }, 40 | "types" : { 41 | "type" : "array", 42 | "items" : { "type" : "string" } 43 | }, 44 | "rows" : { 45 | "type" : "array", 46 | "items" : { 47 | "type" : "array", 48 | "items" : { "type" : [ "string", "number", "integer", "boolean" ] } 49 | } 50 | } 51 | }, 52 | "additionalProperties" : false 53 | }, 54 | 55 | "property" : { 56 | "type" : "object", 57 | "properties" : { 58 | "type" : { "type" : "string" }, 59 | "value" : { 60 | "oneOf" : [ 61 | { "type" : [ "string", "number", "integer", "boolean", "null" ] }, 62 | { "$ref" : "#/definitions/propertySet" }, 63 | { 64 | "type" : "array", 65 | "items" : { "$ref" : "#/definitions/propertySet" } 66 | } 67 | ] 68 | } 69 | }, 70 | "additionalProperties" : false 71 | }, 72 | 73 | "propertySet" : { 74 | "type" : "object", 75 | "additionalProperties" : { "$ref" : "#/definitions/property" } 76 | }, 77 | 78 | "metadata" : { 79 | "type" : "object", 80 | "properties" : { 81 | "contentType" : { "type" : "string" }, 82 | "isMultiPart" : { "type" : "boolean" }, 83 | "seq" : { "type" : "integer" }, 84 | "size" : { "type" : "integer" }, 85 | "fileName" : { "type" : "string" }, 86 | "fileType" : { "type" : "string" }, 87 | "md5" : { "type" : "string" }, 88 | "description" : { "type" : "string" } 89 | } 90 | }, 91 | 92 | "metric" : { 93 | "type" : "object", 94 | "properties" : { 95 | "name" : { "type" : "string" }, 96 | "alias" : { "type" : "integer" }, 97 | "timestamp" : { "type" : "integer" }, 98 | "datatype" : { "type" : "string" }, 99 | "isHistorical" : { "type" : "boolean" }, 100 | "isTransient" : { "type" : "boolean" }, 101 | "metadata" : { "$ref" : "#/definitions/metadata" }, 102 | "properties" : { "$ref" : "#/definitions/propertySet" }, 103 | "value" : { 104 | "oneOf" : [ 105 | { "type" : [ "string", "number", "integer", "boolean", "null" ] }, 106 | { "$ref" : "#/definitions/dataset" }, 107 | { "$ref" : "#/definitions/template" } 108 | ] 109 | } 110 | } 111 | } 112 | }, 113 | 114 | "type": "object", 115 | "properties": { 116 | "timestamp" : { 117 | "description" : "A timestamp in milliseconds", 118 | "type" : "integer" 119 | }, 120 | "seq" : { 121 | "description" : "A sequence number", 122 | "type" : "integer" 123 | }, 124 | "uuid" : { 125 | "description" : "A unique identifier", 126 | "type" : "string" 127 | }, 128 | "body" : { 129 | "description" : "A UTF-8 encoded string representing a byte array", 130 | "type" : "string" 131 | }, 132 | "metrics" : { 133 | "description" : "An array of metrics", 134 | "type" : "array", 135 | "items" : { "$ref" : "#/definitions/metric" } 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/c/template_as_custom_props/Makefile: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | TARGET = example 15 | LIBS = ../../../../client_libraries/c/lib/libsparkplug_b.a -Llib -L/usr/local/lib -lmosquitto 16 | CC = gcc 17 | CFLAGS = -g -Wall -I../../../../client_libraries/c/include/ 18 | 19 | .PHONY: default all clean 20 | 21 | default: $(TARGET) 22 | all: default 23 | 24 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) 25 | HEADERS = $(wildcard *.h) 26 | 27 | %.o: %.c $(HEADERS) 28 | $(CC) $(CFLAGS) -c $< -o $@ 29 | 30 | .PRECIOUS: $(TARGET) $(OBJECTS) 31 | 32 | $(TARGET): $(OBJECTS) 33 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@ 34 | 35 | clean: 36 | -rm -f *.o 37 | -rm -f $(TARGET) 38 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/c/udt_example/Makefile: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | TARGET = example 15 | LIBS = ../../../../client_libraries/c/lib/libsparkplug_b.a -Llib -L/usr/local/lib -lmosquitto 16 | CC = gcc 17 | CFLAGS = -g -Wall -I../../../../client_libraries/c/include/ 18 | 19 | .PHONY: default all clean 20 | 21 | default: $(TARGET) 22 | all: default 23 | 24 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) 25 | HEADERS = $(wildcard *.h) 26 | 27 | %.o: %.c $(HEADERS) 28 | $(CC) $(CFLAGS) -c $< -o $@ 29 | 30 | .PRECIOUS: $(TARGET) $(OBJECTS) 31 | 32 | $(TARGET): $(OBJECTS) 33 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@ 34 | 35 | clean: 36 | -rm -f *.o 37 | -rm -f $(TARGET) 38 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | 2 | Lists of 5 third-party dependencies. 3 | (New BSD license) Protocol Buffer Java API (com.google.protobuf:protobuf-java:2.6.1 - https://developers.google.com/protocol-buffers/) 4 | (The Apache Software License, Version 2.0) Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) 5 | (Eclipse Public License - Version 1.0) org.eclipse.paho.client.mqttv3 (org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2 - http://www.eclipse.org/paho/org.eclipse.paho.client.mqttv3) 6 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.5 - http://www.slf4j.org) 7 | (MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org) 8 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_example 27 | 0.5.8 28 | jar 29 | Maven Quick Start Archetype 30 | http://maven.apache.org 31 | 32 | 33 | org.eclipse.tahu 34 | tahu-java 35 | ${tahu.version} 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-deploy-plugin 43 | 2.7 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-shade-plugin 53 | 2.4.1 54 | 55 | 56 | package 57 | 58 | shade 59 | 60 | 61 | 62 | 63 | *:* 64 | 65 | META-INF/*.SF 66 | META-INF/*.DSA 67 | META-INF/*.RSA 68 | 69 | 70 | 71 | 72 | 74 | org.eclipse.tahu.SparkplugExample 75 | 76 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.codehaus.mojo 85 | license-maven-plugin 86 | 1.8 87 | 88 | 89 | add-third-party 90 | package 91 | 92 | add-third-party 93 | download-licenses 94 | 95 | 96 | true 97 | test 98 | (org.eclipse.tahu*) 99 | 100 | 101 | The Apache Software License, Version 102 | 2.0|Apache License, Version 2.0|Apache Public License 103 | 2.0|Apache License 2.0|Apache Software License - 104 | Version 2.0 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_device_timestamp/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | 2 | Lists of 5 third-party dependencies. 3 | (New BSD license) Protocol Buffer Java API (com.google.protobuf:protobuf-java:2.6.1 - https://developers.google.com/protocol-buffers/) 4 | (The Apache Software License, Version 2.0) Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) 5 | (Eclipse Public License - Version 1.0) org.eclipse.paho.client.mqttv3 (org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2 - http://www.eclipse.org/paho/org.eclipse.paho.client.mqttv3) 6 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.5 - http://www.slf4j.org) 7 | (MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org) 8 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_device_timestamp/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_device_timestamp_example 27 | 0.5.8 28 | jar 29 | Maven Quick Start Archetype 30 | http://maven.apache.org 31 | 32 | 33 | org.eclipse.tahu 34 | tahu-java 35 | ${tahu.version} 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-deploy-plugin 43 | 2.7 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-shade-plugin 53 | 2.4.1 54 | 55 | 56 | package 57 | 58 | shade 59 | 60 | 61 | 62 | 63 | *:* 64 | 65 | META-INF/*.SF 66 | META-INF/*.DSA 67 | META-INF/*.RSA 68 | 69 | 70 | 71 | 72 | 74 | org.eclipse.tahu.SparkplugExample 75 | 76 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.codehaus.mojo 85 | license-maven-plugin 86 | 1.8 87 | 88 | 89 | add-third-party 90 | package 91 | 92 | add-third-party 93 | download-licenses 94 | 95 | 96 | true 97 | test 98 | (org.eclipse.tahu*) 99 | 100 | 101 | The Apache Software License, Version 102 | 2.0|Apache License, Version 2.0|Apache Public License 103 | 2.0|Apache License 2.0|Apache Software License - 104 | Version 2.0 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_edge_node_control/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_edge_node_control 27 | 0.5.8 28 | jar 29 | 30 | Maven Quick Start Archetype 31 | http://maven.apache.org 32 | 33 | 34 | 35 | org.eclipse.tahu 36 | tahu-java 37 | ${tahu.version} 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-deploy-plugin 46 | 2.7 47 | 48 | true 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-shade-plugin 56 | 2.4.1 57 | 58 | 59 | package 60 | 61 | shade 62 | 63 | 64 | 65 | 66 | *:* 67 | 68 | META-INF/*.SF 69 | META-INF/*.DSA 70 | META-INF/*.RSA 71 | 72 | 73 | 74 | 75 | 77 | org.eclipse.tahu.SparkplugExample 78 | 79 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.codehaus.mojo 88 | license-maven-plugin 89 | 1.8 90 | 91 | 92 | add-third-party 93 | package 94 | 95 | add-third-party 96 | download-licenses 97 | 98 | 99 | true 100 | test 101 | 102 | (org.eclipse.tahu*) 103 | 104 | 105 | The Apache Software License, Version 106 | 2.0|Apache License, Version 2.0|Apache Public License 107 | 2.0|Apache License 2.0|Apache Software License - 108 | Version 2.0 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_records/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | 2 | Lists of 5 third-party dependencies. 3 | (New BSD license) Protocol Buffer Java API (com.google.protobuf:protobuf-java:2.6.1 - https://developers.google.com/protocol-buffers/) 4 | (The Apache Software License, Version 2.0) Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) 5 | (Eclipse Public License - Version 1.0) org.eclipse.paho.client.mqttv3 (org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2 - http://www.eclipse.org/paho/org.eclipse.paho.client.mqttv3) 6 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.5 - http://www.slf4j.org) 7 | (MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org) 8 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_records/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_records_example 27 | jar 28 | Maven Quick Start Archetype 29 | http://maven.apache.org 30 | 31 | 32 | org.eclipse.tahu 33 | tahu-java 34 | ${tahu.version} 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-deploy-plugin 42 | 2.7 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-shade-plugin 52 | 2.4.1 53 | 54 | 55 | package 56 | 57 | shade 58 | 59 | 60 | 61 | 62 | *:* 63 | 64 | META-INF/*.SF 65 | META-INF/*.DSA 66 | META-INF/*.RSA 67 | 68 | 69 | 70 | 71 | 73 | org.eclipse.tahu.SparkplugRecordsExample 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | org.codehaus.mojo 84 | license-maven-plugin 85 | 1.8 86 | 87 | 88 | add-third-party 89 | package 90 | 91 | add-third-party 92 | download-licenses 93 | 94 | 95 | true 96 | test 97 | (org.eclipse.tahu*) 98 | 99 | 100 | The Apache Software License, Version 101 | 2.0|Apache License, Version 2.0|Apache Public License 102 | 2.0|Apache License 2.0|Apache Software License - 103 | Version 2.0 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/java_udt/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_udt_example 27 | 0.5.8 28 | jar 29 | Maven Quick Start Archetype 30 | http://maven.apache.org 31 | 32 | 33 | org.eclipse.tahu 34 | tahu-java 35 | ${tahu.version} 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-deploy-plugin 43 | 2.7 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-shade-plugin 53 | 2.4.1 54 | 55 | 56 | package 57 | 58 | shade 59 | 60 | 61 | 62 | 63 | *:* 64 | 65 | META-INF/*.SF 66 | META-INF/*.DSA 67 | META-INF/*.RSA 68 | 69 | 70 | 71 | 72 | 74 | org.eclipse.tahu.SparkplugExample 75 | 76 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.codehaus.mojo 85 | license-maven-plugin 86 | 1.8 87 | 88 | 89 | add-third-party 90 | package 91 | 92 | add-third-party 93 | download-licenses 94 | 95 | 96 | true 97 | test 98 | (org.eclipse.tahu*) 99 | 100 | 101 | The Apache Software License, Version 102 | 2.0|Apache License, Version 2.0|Apache Public License 103 | 2.0|Apache License 2.0|Apache Software License - 104 | Version 2.0 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/js/package.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "name" : "example", 4 | "version" : "1.0.1-SNAPSHOT", 5 | "description" : "An example Sparkplug B module written in JavaScript", 6 | "license" : "EPL-1.0", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/Cirrus-Link/Sparkplug.git" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/nodered/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "example", 3 | "version" : "1.0.0-SNAPSHOT", 4 | "description" : "An example Sparkplug B Node-RED node", 5 | "license" : "EPL-1.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/Cirrus-Link/Sparkplug.git" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/stand_alone_examples/python/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | (1) Eclipse Paho Client 2 | Copyright © 2014 Eclipse Paho. All Rights Reserved. 3 | The Software contains Eclipse Paho Client, which is protected under the Eclipse Public License, Version 1.0. 4 | You can get the full source code for Eclipse Paho Client at: https://repo.eclipse.org/content/repositories/paho-releases. 5 | A copy of the Eclipse Public License, Version 1.0 is available at http://www.eclipse.org/legal/epl-v10.html 6 | 7 | (2) Google Protocol Buffers 8 | Copyright 2014, Google Inc. All rights reserved. 9 | The Software contains Google Protocol Buffers, which is protected under a BSD style license. 10 | You can get the full source code for Google Protocol Buffers at: https://github.com/google/protobuf. 11 | A copy of the license is available at https://github.com/google/protobuf/blob/master/LICENSE 12 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/tools/java_sparkplug_b_listener/THIRD-PARTY.txt: -------------------------------------------------------------------------------- 1 | 2 | Lists of 5 third-party dependencies. 3 | (New BSD license) Protocol Buffer Java API (com.google.protobuf:protobuf-java:2.6.1 - https://developers.google.com/protocol-buffers/) 4 | (The Apache Software License, Version 2.0) Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) 5 | (Eclipse Public License - Version 1.0) org.eclipse.paho.client.mqttv3 (org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2 - http://www.eclipse.org/paho/org.eclipse.paho.client.mqttv3) 6 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.5 - http://www.slf4j.org) 7 | (MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org) 8 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/tools/java_sparkplug_b_listener/pom.xml: -------------------------------------------------------------------------------- 1 | 14 | 16 | 4.0.0 17 | 18 | 19 | org.eclipse.tahu 20 | tahu 21 | 0.5.8 22 | ../../../pom.xml 23 | 24 | 25 | org.eclipse.tahu.example 26 | sparkplug_b_listener 27 | 0.5.8 28 | jar 29 | Maven Quick Start Archetype 30 | http://maven.apache.org 31 | 32 | 33 | org.eclipse.tahu 34 | tahu-java 35 | ${tahu.version} 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-deploy-plugin 43 | 2.7 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-shade-plugin 53 | 2.4.1 54 | 55 | 56 | package 57 | 58 | shade 59 | 60 | 61 | false 62 | 63 | 64 | *:* 65 | 66 | META-INF/*.SF 67 | META-INF/*.DSA 68 | META-INF/*.RSA 69 | 70 | 71 | 72 | 73 | 75 | org.eclipse.tahu.SparkplugListener 76 | 77 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | org.codehaus.mojo 86 | license-maven-plugin 87 | 1.8 88 | 89 | 90 | add-third-party 91 | package 92 | 93 | add-third-party 94 | download-licenses 95 | 96 | 97 | true 98 | test 99 | (org.eclipse.tahu*) 100 | 101 | 102 | The Apache Software License, Version 103 | 2.0|Apache License, Version 2.0|Apache Public License 104 | 2.0|Apache License 2.0|Apache Software License - 105 | Version 2.0 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/tools/java_sparkplug_b_listener/src/main/java/org/eclipse/tahu/SparkplugListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0. 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Cirrus Link Solutions - initial implementation 12 | ********************************************************************************/ 13 | 14 | package org.eclipse.tahu; 15 | 16 | import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; 17 | import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; 18 | import org.eclipse.paho.client.mqttv3.MqttClient; 19 | import org.eclipse.paho.client.mqttv3.MqttConnectOptions; 20 | import org.eclipse.paho.client.mqttv3.MqttMessage; 21 | import org.eclipse.tahu.message.SparkplugBPayloadDecoder; 22 | import org.eclipse.tahu.message.model.SparkplugBPayload; 23 | import org.eclipse.tahu.message.model.Topic; 24 | import org.eclipse.tahu.util.TopicUtil; 25 | 26 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 27 | import com.fasterxml.jackson.databind.ObjectMapper; 28 | 29 | public class SparkplugListener implements MqttCallbackExtended { 30 | 31 | // Configuration 32 | private String serverUrl = "tcp://localhost:1883"; 33 | private String clientId = "SparkplugBListenerEdgeNode"; 34 | private String username = "admin"; 35 | private String password = "changeme"; 36 | private MqttClient client; 37 | 38 | public static void main(String[] args) { 39 | SparkplugListener listener = new SparkplugListener(); 40 | listener.run(); 41 | } 42 | 43 | public void run() { 44 | try { 45 | // Connect to the MQTT Server 46 | MqttConnectOptions options = new MqttConnectOptions(); 47 | options.setAutomaticReconnect(true); 48 | options.setCleanSession(true); 49 | options.setConnectionTimeout(30); 50 | options.setKeepAliveInterval(30); 51 | options.setUserName(username); 52 | options.setPassword(password.toCharArray()); 53 | client = new MqttClient(serverUrl, clientId); 54 | client.setTimeToWait(5000); // short timeout on failure to connect 55 | client.connect(options); 56 | client.setCallback(this); 57 | 58 | // Just listen to all DDATA messages on spAv1.0 topics and wait for inbound messages 59 | client.subscribe("spBv1.0/#", 0); 60 | } catch(Exception e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | 65 | @Override 66 | public void connectComplete(boolean reconnect, String serverURI) { 67 | System.out.println("Connected!"); 68 | } 69 | 70 | @Override 71 | public void connectionLost(Throwable cause) { 72 | System.out.println("The MQTT Connection was lost! - will auto-reconnect"); 73 | } 74 | 75 | @Override 76 | public void messageArrived(String topic, MqttMessage message) throws Exception { 77 | Topic sparkplugTopic = TopicUtil.parseTopic(topic); 78 | ObjectMapper mapper = new ObjectMapper(); 79 | mapper.setSerializationInclusion(Include.NON_NULL); 80 | 81 | System.out.println("Message Arrived on Sparkplug topic " + sparkplugTopic.toString()); 82 | 83 | SparkplugBPayloadDecoder decoder = new SparkplugBPayloadDecoder(); 84 | SparkplugBPayload inboundPayload = decoder.buildFromByteArray(message.getPayload()); 85 | 86 | // Convert the message to JSON and print to system.out 87 | try { 88 | String payloadString = mapper.writeValueAsString(inboundPayload); 89 | System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(inboundPayload)); 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } 93 | } 94 | 95 | @Override 96 | public void deliveryComplete(IMqttDeliveryToken token) { 97 | System.out.println("Published message: " + token); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b/tools/java_sparkplug_b_listener/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #/******************************************************************************** 2 | # * Copyright (c) 2014, 2018 Cirrus Link Solutions and others 3 | # * 4 | # * This program and the accompanying materials are made available under the 5 | # * terms of the Eclipse Public License 2.0 which is available at 6 | # * http://www.eclipse.org/legal/epl-2.0. 7 | # * 8 | # * SPDX-License-Identifier: EPL-2.0 9 | # * 10 | # * Contributors: 11 | # * Cirrus Link Solutions - initial implementation 12 | # ********************************************************************************/ 13 | 14 | # Root logger option 15 | log4j.rootLogger=ERROR, stdout 16 | 17 | # Direct log messages to stdout 18 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 19 | log4j.appender.stdout.Target=System.out 20 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n -------------------------------------------------------------------------------- /deepstream-ign-rtsp-web/sparkplug_b_pb2.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valdivj/Xavier-NX_Ignition_Maker/3263ca9f83352f5e67c2c7ed622235adf099a87a/deepstream-ign-rtsp-web/sparkplug_b_pb2.pyc --------------------------------------------------------------------------------