### Install and Start IoT Data Simulator with Docker Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/README.md These commands pull the necessary Docker images and start the IoT Data Simulator services using docker-compose. Ensure Docker (v. 17.05+) and docker-compose are installed. Run these commands in the directory containing 'docker-compose.yml' and '.env' files from the 'release' folder. ```Shell docker-compose pull docker-compose up ``` -------------------------------- ### Publish to Session Management Command Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Publish a message to this topic to send management commands (start, pause, stop, restart) to a specific session identified by its ID. ```APIDOC Topic: ./sessions.:sessionId Description: Message to manage session execution. Payload: sessionId: Type: string Description: session id property command: Type: string Description: session management command. One of the following: "start" | "pause" | "stop" | "restart" Tags: sessions, management, command ``` -------------------------------- ### Example Dataset with Timestamp Property Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/README.md This JSON snippet illustrates a sample dataset record containing a timestamp property. Such datasets are used when replaying data with updated date/timestamp values, where the simulator can adjust timestamps based on current time or relative differences. ```JSON {"timestamp": 1517303155600, "id": 1 } {"timestamp": 1517303155800, "id": 2 } ... ``` -------------------------------- ### Session Management Command Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for messages used to manage session execution. It includes the session ID and the command to execute, such as 'start', 'pause', 'stop', or 'restart'. ```APIDOC sessionManagementCommandMessage: Payload: sessionId: string - session id property command: string - session management command. One of the following: "start" | "pause" | "stop" | "restart" ``` -------------------------------- ### Connect to WebSocket Server using STOMP Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Handles the click event for the 'Connect' button. It retrieves the WebSocket URL, validates it, initializes a SockJS connection, and then connects using STOMP. Upon successful connection, it updates the UI state and displays a 'Connected' message. ```JavaScript $(function(){ $('#connect').click(function() { var url = $('#url').val(); if(url === ""){ showResponse("Enter url! (e.g. https://localhost:8080/ResolutionRoomsBackend/hello)"); return false; } var socket = new SockJS(url); stompClient = Stomp.over(socket); stompClient.connect( {}, function(frame) { setConnected(true); showResponse('Connected: ' + frame); } ); }); }); ``` -------------------------------- ### IoT Data Simulator API Connection Details Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Provides the necessary details for establishing a connection to the IoT Data Simulator's websocket/STOMP API. ```APIDOC URL: services:8080/ws Scheme: stomp Description: sessions management API ``` -------------------------------- ### JavaScript UI Utility Functions Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html A collection of JavaScript functions designed to enhance user interface interactivity. This includes managing active navigation links based on URL hash, highlighting code blocks using `hljs`, and enabling expandable table rows. Event listeners are set up to trigger these functionalities on page load and hash changes. ```JavaScript function removeCurrentLinkSelection () { var links = document.querySelectorAll('.navigation__list__item-text--link'); if (!links) return; for (var i=0; i < links.length; i++) { links[i].classList.remove('navigation__list__item-text--link--active'); } } function selectCurrentLink () { removeCurrentLinkSelection(); var hash = window.location.hash; if (!hash) return; var link = document.querySelector("a[href='"+hash+"']"); if (!link) return; link.classList.add('navigation__list__item-text--link--active'); } function highlightCode () { var blocks = document.querySelectorAll('.hljs code'); for(var i=0; i < blocks.length; i++) { hljs.highlightBlock(blocks[i]); } } function bindExpandButtons () { var buttons = document.querySelectorAll('.table__expand'); for(var i=0; i < buttons.length; i++) { buttons[i].addEventListener('click', function (e) { var tableRow = document.querySelector('[data-nested-index="' + e.target.attributes['data-index'].value + '"]'); tableRow.classList.toggle('table__body__row--with-nested--expanded'); e.target.classList.toggle('table__expand--open'); }); } } window.addEventListener('hashchange', selectCurrentLink); window.addEventListener('load', selectCurrentLink); window.addEventListener('load', highlightCode); window.addEventListener('load', bindExpandButtons); ``` -------------------------------- ### Initialize STOMP Client and Manage UI Connection State Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Initializes the global 'stompClient' variable to null and defines a 'setConnected' function. This function enables or disables the 'connect' and 'disconnect' buttons and clears the response text area based on the WebSocket connection status, providing visual feedback to the user. ```JavaScript var stompClient = null; function setConnected(connected) { document.getElementById('connect').disabled = connected; document.getElementById('disconnect').disabled = !connected; document.getElementById('response').text = ''; } ``` -------------------------------- ### Publish to Sessions Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Publish an empty message to this topic to trigger the service to provide statuses for all currently active sessions. ```APIDOC Topic: ./sessions Description: An empty message to trigger provision of all active sessions statuses. Payload: (empty) Tags: sessions, status, command ``` -------------------------------- ### Standard Date and Time Regular Expression Mappings Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/regexp/date-formats-regexps.txt This snippet provides a comprehensive set of regular expressions paired with their corresponding date and time format strings. These mappings are essential for applications that need to parse, validate, or convert date and time data from various input formats into a standardized representation. The patterns cover dates, times, and full timestamps with varying levels of precision and separators. ```Configuration ^\d{8}$===yyyyMMdd ^\d{1,2}-\d{1,2}-\d{4}$===dd-MM-yyyy ^\d{4}-\d{1,2}-\d{1,2}$===yyyy-MM-dd ^\d{1,2}/\d{1,2}/\d{4}$===MM/dd/yyyy ^\d{4}/\d{1,2}/\d{1,2}$===yyyy/MM/dd ^\d{1,2}\s[a-z]{3}\s\d{4}$===dd MMM yyyy ^\d{1,2}\s[a-z]{4,}\s\d{4}$===dd MMMM yyyy ^\d{12}$===yyyyMMddHHmm ^\d{8}\s\d{4}$===yyyyMMdd HHmm ^\d{1,2}-\d{1,2}-\d{4}\s\d{1,2}:\d{2}$===dd-MM-yyyy HH:mm ^\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{2}$===yyyy-MM-dd HH:mm ^\d{1,2}/\d{1,2}/\d{4}\s\d{1,2}:\d{2}$===MM/dd/yyyy HH:mm ^\d{4}/\d{1,2}/\d{1,2}\s\d{1,2}:\d{2}$===yyyy/MM/dd HH:mm ^\d{1,2}\s[a-z]{3}\s\d{4}\s\d{1,2}:\d{2}$===dd MMM yyyy HH:mm ^\d{1,2}\s[a-z]{4,}\s\d{4}\s\d{1,2}:\d{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2}:\d{2}\.\d{3}$===yyyy-MM-dd'T'HH:mm:ss.SSS ^\d{1,2}:\d{2}\s[AaPp][Mm]$===hh:mm a ^\d{1,2}:\d{2}:\d{2}\s[AaPp][Mm]$===hh:mm:ss a ``` -------------------------------- ### Process Dataset Entry Without Modification Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/README.md This JavaScript function demonstrates the simplest data processing rule for the IoT Data Simulator. It takes the current state, dataset entry, and device name as input, and returns the dataset entry unchanged, effectively replaying the data as is. ```JavaScript function process(state, datasetEntry, deviceName) { return datasetEntry; } ``` -------------------------------- ### Send Query Message via STOMP Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Handles the click event for the 'Send' button. It retrieves the query content and the controller path from input fields, validates the path, generates a unique 'requestId' header, and then sends the message to the specified STOMP destination using 'stompClient.send()'. ```JavaScript $(function(){ var requestId = 1; $('#sendQuery').click(function(){ var query = $('#query').val(); var path = $('#path').val(); if(path === ""){ showResponse("Enter controller path! (e.g. /app/hello)"); return false; } var headers = { requestId: ++requestId } stompClient.send(path, headers, query); }); }); ``` -------------------------------- ### Basic Styling for WebSocket Client UI Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Defines basic CSS styles for the WebSocket client user interface elements, including body font size, container padding, form control height, button margins, and text area positioning, to ensure a readable and functional layout. ```CSS body { font-size: 20px; } .container, .container>div { padding-top: 10px; } .form-control { height: 50px; font-size: 20px; } .btn-primary { margin-top: 10px; } .col-xs-6 { overflow: hidden; } .col-xs-6>div { padding-top: 15px; } .col-xs-6 button { margin-top: 10px; float: right; } textarea { margin-top: 30px; } ``` -------------------------------- ### Subscribe to User Queue Sessions Status Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic provides active session status information, including the message type, command processing result, and details about active sessions such as ID, state, and any associated errors. ```APIDOC Topic: ./user/queue/sessions Description: Active sesssions status information. Payload: type: Type: string Description: "sessions_status_command_result" message type result: Type: string Description: command processing result. One of the following: "success" | "failure" errorMessage: Type: string Description: contains error description in case of result: "failure" statuses: Type: array(object) Description: active sessions statuses Properties: sessionId: Type: string Description: session id property state: Type: string Description: current active session state. One of the following: "running" | "paused" | "completed" | "failed" errors: Type: array(string) Description: contains session errors in case of session state "failed" Tags: session, status, command, result ``` -------------------------------- ### Generate Data with JavaScript Function Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/README.md This JavaScript function shows how to dynamically generate data within the IoT Data Simulator. It returns an object with a 'timestamp' property set to the current time using `moment().valueOf()`, allowing for on-the-fly data generation without a predefined dataset. ```JavaScript function process(state, datasetEntry, deviceName) { return { timestamp: moment().valueOf() } } ``` -------------------------------- ### Subscribe to Session Status Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic provides real-time status updates for a specific active session, including its current state (running, paused, completed, failed) and any associated errors. ```APIDOC Topic: ./topic/sessions.:sessionId Description: Active sesssions status result message. Payload: type: Type: string Description: "session_status" message type status: Type: object Properties: sessionId: Type: string Description: session id property state: Type: string Description: current active session state. One of the following: "running" | "paused" | "completed" | "failed" errors: Type: array(string) Description: contains session errors in case of session state "failed" Tags: session, status ``` -------------------------------- ### Subscribe to User Queue Session Management Result Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic delivers the results of session management commands for a specific session ID, indicating success or failure and providing an error message if applicable. ```APIDOC Topic: ./user/queue/sessions.:sessionId Description: Active sesssion managemnt command result. Payload: type: Type: string Description: "session_management_command_result" message type sessionId: Type: string Description: session id property result: Type: string Description: command processing result. One of the following: "success" | "failure" errorMessage: Type: string Description: contains error description in case of result: "failure" Tags: sessions, management, command, result ``` -------------------------------- ### Subscribe to STOMP Destination Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Handles the click event for the 'Subscribe' button. It retrieves the subscription destination, validates it, and then subscribes the STOMP client to receive messages from that topic. A callback function is provided to display the body of received messages in the response area. ```JavaScript $(function(){ $('#subscribe').click(function(){ var destination = $('#subscribtion').val(); if(destination === ""){ showResponse("Enter subscription path! (e.g. /topic/greetings)"); return false; } stompClient.subscribe(destination, function(response) { showResponse(response.body); }); showResponse("Subscription N: " + stompClient.counter + "\ndestination: " + destination); }); }); ``` -------------------------------- ### Subscribe to Session Analytics Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic provides analytics messages related to a specific active session. ```APIDOC Topic: ./topic/sessions.:sessionId.analytics Description: Active sesssion analytics message. ``` -------------------------------- ### Command Result Schema Definition Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines a simple schema for command processing results, indicating either 'success' or 'failure'. ```APIDOC commandResult: commandResult: string - command processing result. One of the following: "success" | "failure" ``` -------------------------------- ### Subscribe to User Queue Error Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic is used to receive unexpected error messages generated by the service. The payload includes a string property for the error message. ```APIDOC Topic: ./user/queue/error Description: Services unexpected error message. Payload: message: Type: string Description: error message property Tags: error ``` -------------------------------- ### Append Messages to Response Text Area Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Defines the 'showResponse' function, which appends new messages to the 'response' text area. It checks if the text area already contains content and adds two newline characters before appending the new message to ensure readability and separation of entries. ```JavaScript function showResponse(message) { var $response = $('#response'); if($response.val()){ $response.append('\n\n'); } $response.append(message); } ``` -------------------------------- ### Subscribe to Session Payload Topic Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html This topic delivers messages containing the processed payload data for a specific active session, including the session ID, the message content, and a Unix timestamp. ```APIDOC Topic: ./topic/sessions.:sessionId.payload Description: Active sesssions processed payload message. Payload: type: Type: string Description: "session_payload" message type sessionId: Type: string Description: session id property message: Type: string Description: session payload message which has been successfully sent to external target system timestamp: Type: number Description: unix format timestamp Tags: session, payload ``` -------------------------------- ### JavaScript Function for Counter in IoT Data Simulator Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/README.md This JavaScript function demonstrates how to implement a simple counter that persists its state across data processing iterations within the IoT Data Simulator. It uses the 'ruleState' object to store and increment the counter value, ensuring the count increases with each iteration. ```javascript function custom(ruleState, sessionState, deviceName) { if(typeof ruleState.counter === 'undefined') { ruleState.counter = 0; } ruleState.counter++ return ruleState.counter; } ``` -------------------------------- ### Session Status Schema Definition Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the schema for a session's status, including its ID, current state (running, paused, completed, failed), and any associated errors. ```APIDOC sessionStatus: sessionId: string - session id property state: string - current active session state. One of the following: "running" | "paused" | "completed" | "failed" errors: array(string) - contains session errors in case of session state "failed" ``` -------------------------------- ### Session Statuses Command Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines an empty message used to trigger the provision of all active session statuses. This message serves as a command without specific parameters. ```APIDOC sessionStatusesCommandMessage: Payload: (empty message) ``` -------------------------------- ### API Reference: commandErrorMessage Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Documents the `commandErrorMessage` field, which is a string type used to provide error details when an operation fails. It is typically found in API responses. ```APIDOC commandErrorMessage: Name: commandErrorMessage Title: Type: string Format: Default: Description: contains error description in case of result: "failure" ``` -------------------------------- ### Session Management Command Result Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for the result of a session management command. It indicates success or failure, includes the session ID, and provides an error description if the command failed. ```APIDOC sessionManagementCommandResultMessage: Payload: type: string - "session_management_command_result" message type sessionId: string - session id property result: string - command processing result. One of the following: "success" | "failure" errorMessage: string - contains error description in case of result: "failure" ``` -------------------------------- ### Session Analytics Message Payload (Initial Definition) Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the structure for session analytics messages, including type, tag, session ID, message content, and timestamp. This is the initial definition found in the document, associated with 'session analytics' tags. ```APIDOC Payload: type: string - "session_analytics" message type tag: string - session analytics tag. One of the following: "sessions_started" | "session_completed" | "session_paused" | "session_failed" sessionId: string - session id property message: string - session analytics message timestamp: number - unix format timestamp ``` -------------------------------- ### Session Error Message Payload (Subscription Topic) Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for active session error messages, typically received on the './topic/sessions.:sessionId.errors' subscription topic. It includes the message type, session ID, error message content, and timestamp. ```APIDOC Subscribe ./topic/sessions.:sessionId.errors: Payload: type: string - "session_error" message type sessionId: string - session id property message: string - error message timestamp: number - unix format timestamp ``` -------------------------------- ### Session Statuses Command Result Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for the result of a session statuses command. It provides information about active sessions, including their IDs, current states, and any associated errors, along with the overall command result. ```APIDOC sessionStatusesCommandResultMessage: Payload: type: string - "sessions_status_command_result" message type result: string - command processing result. One of the following: "success" | "failure" errorMessage: string - contains error description in case of result: "failure" statuses: array(object) - active sessions statuses sessionId: string - session id property state: string - current active session state. One of the following: "running" | "paused" | "completed" | "failed" errors: array(string) - contains session errors in case of session state "failed" ``` -------------------------------- ### General Error Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for a general unexpected error message, containing only the error message property. ```APIDOC errorMessage: Payload: message: string - error message property ``` -------------------------------- ### Session Status Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for a single active session's status result message. It includes the message type and a detailed status object containing the session ID, current state, and any errors. ```APIDOC sessionStatusMessage: Payload: type: string - "session_status" message type status: object sessionId: string - session id property state: string - current active session state. One of the following: "running" | "paused" | "completed" | "failed" errors: array(string) - contains session errors in case of session state "failed" ``` -------------------------------- ### Clear Response Text Area Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Handles the click event for the 'Clear' button. When clicked, it sets the text content of the 'response' text area to an empty string, effectively clearing all displayed messages. ```JavaScript $(function(){ $('#clearTextArea').click(function(){ $('#response').text(""); }); }); ``` -------------------------------- ### Sessions Error Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for active session error messages, including the message type, session ID, the error message content, and a timestamp. ```APIDOC sessionsErrorMessage: Payload: type: string - "session_error" message type sessionId: string - session id property message: string - error message timestamp: number - unix format timestamp ``` -------------------------------- ### Sessions Analytics Message Payload Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for active session analytics messages, including type, tag, session ID, message content, and timestamp. This message provides insights into session lifecycle events. ```APIDOC sessionsAnalyticsMessage: Payload: type: string - "session_analytics" message type tag: string - session analytics tag. One of the following: "sessions_started" | "session_completed" | "session_paused" | "session_failed" sessionId: string - session id property message: string - session analytics message timestamp: number - unix format timestamp ``` -------------------------------- ### Disconnect from WebSocket Server Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-client.html Handles the click event for the 'Disconnect' button. It calls the 'disconnect' method on the 'stompClient' object, effectively closing the WebSocket connection. After disconnection, it updates the UI state to reflect the disconnected status and displays a 'Disconnected' message. ```JavaScript $(function(){ $('#disconnect').click(function() { stompClient.disconnect(); setConnected(false); showResponse("Disconnected"); }); }); ``` -------------------------------- ### Sessions Processed Payload Message Source: https://github.com/iba-group-it/iot-data-simulator/blob/master/services/src/main/resources/static/ws-api.html Defines the payload for messages indicating a session's payload has been successfully sent to an external target system. It includes the message type, session ID, the sent message content, and a timestamp. ```APIDOC sessionsPayloadMessage: Payload: type: string - "session_payload" message type sessionId: string - session id property message: string - session payload message which has been successfully sent to external target system timestamp: number - unix format timestamp ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.