Skip to content

Commit

Permalink
updates timeSeries example (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
fyo21103 authored Oct 6, 2024
1 parent e207584 commit 06a01fa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 84 deletions.
Binary file modified examples/TimeSeriesData/aas/TimeSeriesDemo.aasx
Binary file not shown.
2 changes: 2 additions & 0 deletions examples/TimeSeriesData/basyx/aas-env.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ basyx.cors.allowed-methods=GET,POST,PATCH,DELETE,PUT,OPTIONS,HEAD
basyx.aasrepository.feature.registryintegration=http://aas-registry:8080
basyx.submodelrepository.feature.registryintegration=http://sm-registry:8080
basyx.externalurl=http://localhost:8081
spring.servlet.multipart.max-file-size=128MB
spring.servlet.multipart.max-request-size=128MB
23 changes: 7 additions & 16 deletions examples/TimeSeriesData/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '3'
services:

# Time Series Database
influxdb:
image: influxdb:2
Expand Down Expand Up @@ -39,15 +39,13 @@ services:
- '1883:1883'
volumes:
- ./mosquitto:/mosquitto
restart: always
healthcheck:
test:
- CMD-SHELL
- mosquitto_sub -p 1883 -t 'topic' -C 1 -E -i probe -W 3
test: ["CMD-SHELL", mosquitto_sub -p 1883 -t 'topic' -C 1 -E -i probe -W 3]
interval: 5s
timeout: 10s
start_period: 1s
retries: 3
restart: always

# MQTT Publisher (for testing)
mqtt-publisher:
Expand All @@ -57,9 +55,8 @@ services:
- mosquitto
restart: always

# AAS Environment
aas-env:
image: eclipsebasyx/aas-environment:2.0.0-milestone-02
image: eclipsebasyx/aas-environment:2.0.0-SNAPSHOT
container_name: aas-env
volumes:
- ./aas:/application/aas
Expand All @@ -72,30 +69,24 @@ services:
condition: service_healthy
sm-registry:
condition: service_healthy

# AAS Registry
aas-registry:
image: eclipsebasyx/aas-registry-log-mem:2.0.0-milestone-02
image: eclipsebasyx/aas-registry-log-mem:2.0.0-SNAPSHOT
container_name: aas-registry
ports:
- '8082:8080'
volumes:
- ./basyx/aas-registry.yml:/workspace/config/application.yml
restart: always

# Submodel Registry
sm-registry:
image: eclipsebasyx/submodel-registry-log-mem:2.0.0-milestone-02
image: eclipsebasyx/submodel-registry-log-mem:2.0.0-SNAPSHOT
container_name: sm-registry
ports:
- '8083:8080'
volumes:
- ./basyx/sm-registry.yml:/workspace/config/application.yml
restart: always

# AAS Web UI
aas-web-ui:
image: eclipsebasyx/aas-gui:v2-240327
image: eclipsebasyx/aas-gui:v2-241006
container_name: aas-ui
ports:
- '3000:3000'
Expand Down
33 changes: 8 additions & 25 deletions examples/TimeSeriesData/mqtt-publisher/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,30 @@
import random
import paho.mqtt.client as mqtt

# Function to handle incoming messages


def on_message(client, userdata, message):
print(
f"Received message '{str(message.payload.decode('utf-8'))}' on topic '{message.topic}'")


# MQTT settings
broker_address = "mosquitto"
port = 1883
base_topic = "DemoValues/"
static_topic = "StaticStringValue"
base_topic = "EnvironmentalSensor/"

# Connect to MQTT Broker
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, "Client")
client.on_message = on_message
client.connect(broker_address, port)

# Subscribe to the static values topic
client.subscribe(static_topic)

# Start the network loop in a separate thread
client.loop_start()

try:
# Publish a test message to static topic
client.publish(static_topic, "test")


while True:
# Generate different types of dynamic data
int_value = random.randint(0, 100)
double_value = random.uniform(0.0, 100.0)
bool_value = random.choice([True, False])
string_value = random.choice(["Hello", "World", "Test", "MQTT"])
temperatureValue = random.uniform(0, 30)
humidityValue = random.uniform(0.0, 100.0)
airQualityValue = random.uniform(0.0, 1000.0)

# Publish dynamic data to respective subtopics
client.publish(base_topic + "temperature", int_value)
client.publish(base_topic + "speed", double_value)
client.publish(base_topic + "boolProp", bool_value)
client.publish(base_topic + "stringProp", string_value)
client.publish(base_topic + "Temperature", temperatureValue)
client.publish(base_topic + "Humidity", humidityValue)
client.publish(base_topic + "AirQuality", airQualityValue)

# Wait for a short period before publishing the next set of values
time.sleep(1)
Expand Down
46 changes: 3 additions & 43 deletions examples/TimeSeriesData/telegraf/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@

## Topics that will be subscribed to.
topics = [
"DemoValues/speed",
"EnvironmentalSensor/Temperature",
"EnvironmentalSensor/Humidity",
"EnvironmentalSensor/AirQuality",
]

## The message topic will be stored in a tag specified by this value. If set
Expand Down Expand Up @@ -207,45 +209,3 @@
## Value supported is int, float, unit
# [[inputs.mqtt_consumer.topic.types]]
# key = type

## 2. integer
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster.
servers = ["mqtt://mosquitto:1883"]

## Topics that will be subscribed to.
topics = [
"DemoValues/temperature",
]
## Data format to consume.
data_format = "value"
data_type = "integer"
name_override = "int_metric"

## 3. boolean
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster.
servers = ["mqtt://mosquitto:1883"]

## Topics that will be subscribed to.
topics = [
"DemoValues/boolProp",
]
## Data format to consume.
data_format = "value"
data_type = "boolean"
name_override = "bool_metric"

## 4. string
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster.
servers = ["mqtt://mosquitto:1883"]

## Topics that will be subscribed to.
topics = [
"DemoValues/stringProp",
]
## Data format to consume.
data_format = "value"
data_type = "string"
name_override = "string_metric"

0 comments on commit 06a01fa

Please sign in to comment.