Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/MQTT-docker-compose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/MQTT-docker_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/docker-compose-simulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/example_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/example_run_logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/example_run_with_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/grafana-influx-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/grafana-login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/grafana-new-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/image-data-simulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/telegraf-influx-grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions vms/client/simulator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:alpine3.19
FROM python:alpine3.19
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]
CMD ["python", "main.py"]
45 changes: 33 additions & 12 deletions vms/client/simulator/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,44 @@ version: "3"

services:
temp_sensor:
image: antonaleks/data-simulator
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.1.1
- SIM_NAME=TIRCAHL24
- SIM_PERIOD=5
- SIM_HOST=192.168.0.101
- SIM_NAME=TEMP1
- SIM_PERIOD=2
- SIM_TYPE=temperature
pressure_sensor:
image: antonaleks/data-simulator
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.1.1
- SIM_NAME=PIRCAHL11
- SIM_PERIOD=10
- SIM_HOST=192.168.0.101
- SIM_NAME=PRESS1
- SIM_PERIOD=2
- SIM_TYPE=pressure
current_sensor:
image: antonaleks/data-simulator
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.1.1
- SIM_NAME=A0_CURRENT
- SIM_PERIOD=1
- SIM_HOST=192.168.0.101
- SIM_NAME=CURRENT1
- SIM_PERIOD=2
- SIM_TYPE=current
co_sensor:
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.0.101
- SIM_NAME=CO1
- SIM_PERIOD=2
- SIM_TYPE=carbon_oxid
temp_sensor_2:
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.0.101
- SIM_NAME=TEMP2
- SIM_PERIOD=4
- SIM_TYPE=temperature
co_sensor_2:
image: annagajna/data-simulator
environment:
- SIM_HOST=192.168.0.101
- SIM_NAME=CO2
- SIM_PERIOD=6
- SIM_TYPE=carbon_oxid
59 changes: 8 additions & 51 deletions vms/client/simulator/entity/sensor.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,11 @@
import random


class Sensor:
value: float
name: str
type: str

def __init__(self, name):
self.name = name

def generate_new_value(self):
pass

def get_data(self):
return self.value

def __str__(self):
return {"type": self.type, "name": self.name, "value": self.value}


class Temperature(Sensor):
step = 25

def __init__(self, name):
super().__init__(name)
self.type = "temp"

def generate_new_value(self):
self.value = random.random() + self.step


class Pressure(Sensor):
step = 55

def __init__(self, name):
super().__init__(name)
self.type = "pressure"

def generate_new_value(self):
self.value = random.random() + self.step - 56.48 + 25 * 7


class Current(Sensor):
class CO(Sensor):
step = 0

def __init__(self, name):
def __init__(self,name):
super().__init__(name)
self.type = "current"

self.type = "carbon oxid"
def generate_new_value(self):
import math
self.value = math.sin(self.step)
self.step = self.step + 1
self.value = self.step * 1e6
self.step = self.step + 0.001

7 changes: 4 additions & 3 deletions vms/client/simulator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from entity.sensor import *

broker = "localhost" if "SIM_HOST" not in environ.keys() else environ["SIM_HOST"]
port = 1883 if "SIM_PORT" not in environ.keys() else int(environ["SIM_PORT"])
port = 1883 if "SIM_PORT" not in environ.keys() else environ["SIM_PORT"]
name = "sensor" if "SIM_NAME" not in environ.keys() else environ["SIM_NAME"]
period = 1 if "SIM_PERIOD" not in environ.keys() else int(environ["SIM_PERIOD"])
type_sim = "temperature" if "SIM_TYPE" not in environ.keys() else environ["SIM_TYPE"]
sensors = {"temperature": Temperature, "pressure": Pressure, "current": Current}

sensors = {"temperature": Temperature, "pressure": Pressure, "current": Current, "carbon_oxid": CO}


def on_publish(client, userdata, result): # create function for callback
Expand All @@ -24,4 +25,4 @@ def on_publish(client, userdata, result): # create function for callback
while True:
sensor.generate_new_value()
ret = client1.publish("sensors/" + sensor.type + "/" + sensor.name, sensor.get_data()) # publish
time.sleep(period)
time.sleep(period)
9 changes: 9 additions & 0 deletions vms/gateway/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3"
services:
broker:
image: eclipse-mosquitto
container_name: broker
volumes:
- ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
ports:
- "1883:1883"
2 changes: 1 addition & 1 deletion vms/gateway/mosquitto/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
listener 1883
allow_anonymous true
allow_anonymous true
1 change: 0 additions & 1 deletion vms/server/infra/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ services:
networks:
- server-net


volumes:
influx_data: {}
grafana_data: {}
Expand Down
Loading