forked from N5GEH/n5geh.services.controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from djs0109/rework
Rework
- Loading branch information
Showing
14 changed files
with
1,224 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
{ | ||
"annotations": { | ||
"list": [ | ||
{ | ||
"builtIn": 1, | ||
"datasource": "-- Grafana --", | ||
"enable": true, | ||
"hide": true, | ||
"iconColor": "rgba(0, 211, 255, 1)", | ||
"name": "Annotations & Alerts", | ||
"type": "dashboard" | ||
} | ||
] | ||
}, | ||
"editable": true, | ||
"gnetId": null, | ||
"graphTooltip": 0, | ||
"id": 2, | ||
"links": [], | ||
"panels": [ | ||
{ | ||
"columns": [], | ||
"datasource": "Controller", | ||
"fontSize": "100%", | ||
"gridPos": { | ||
"h": 4, | ||
"w": 13, | ||
"x": 0, | ||
"y": 0 | ||
}, | ||
"id": 6, | ||
"links": [], | ||
"pageSize": 2, | ||
"scroll": true, | ||
"showHeader": true, | ||
"sort": { | ||
"col": 0, | ||
"desc": true | ||
}, | ||
"styles": [ | ||
{ | ||
"alias": "Heater power", | ||
"dateFormat": "YYYY-MM-DD HH:mm:ss", | ||
"pattern": "heater_power_info", | ||
"type": "number", | ||
"unit": "watt" | ||
}, | ||
{ | ||
"alias": "time", | ||
"colorMode": null, | ||
"colors": [ | ||
"rgba(245, 54, 54, 0.9)", | ||
"rgba(237, 129, 40, 0.89)", | ||
"rgba(50, 172, 45, 0.97)" | ||
], | ||
"decimals": 2, | ||
"pattern": "time", | ||
"thresholds": [], | ||
"type": "date", | ||
"unit": "short" | ||
} | ||
], | ||
"targets": [ | ||
{ | ||
"format": "table", | ||
"group": [], | ||
"metricColumn": "entity_type", | ||
"rawQuery": false, | ||
"rawSql": "SELECT\n timeinstant AS \"time\",\n entity_type AS metric,\n heater_power_info \nFROM etheater\nORDER BY 1,2", | ||
"refId": "A", | ||
"select": [ | ||
[ | ||
{ | ||
"params": [ | ||
"heater_power_info " | ||
], | ||
"type": "column" | ||
} | ||
] | ||
], | ||
"table": "etheater", | ||
"timeColumn": "timeinstant ", | ||
"where": [] | ||
} | ||
], | ||
"timeFrom": null, | ||
"timeShift": null, | ||
"title": "Heater Power", | ||
"transform": "table", | ||
"type": "table" | ||
}, | ||
{ | ||
"aliasColors": {}, | ||
"bars": false, | ||
"dashLength": 10, | ||
"dashes": false, | ||
"datasource": "Controller", | ||
"fill": 1, | ||
"gridPos": { | ||
"h": 8, | ||
"w": 22, | ||
"x": 0, | ||
"y": 4 | ||
}, | ||
"id": 4, | ||
"legend": { | ||
"avg": false, | ||
"current": false, | ||
"max": false, | ||
"min": false, | ||
"show": true, | ||
"total": false, | ||
"values": false | ||
}, | ||
"lines": true, | ||
"linewidth": 1, | ||
"links": [], | ||
"nullPointMode": "null", | ||
"percentage": false, | ||
"pointradius": 2, | ||
"points": false, | ||
"renderer": "flot", | ||
"seriesOverrides": [], | ||
"spaceLength": 10, | ||
"stack": false, | ||
"steppedLine": false, | ||
"targets": [ | ||
{ | ||
"format": "time_series", | ||
"group": [], | ||
"metricColumn": "entity_type ", | ||
"rawQuery": false, | ||
"rawSql": "SELECT\n timeinstant AS \"time\",\n entity_type AS metric,\n temperature \nFROM ettemperaturesensor \nORDER BY 1,2", | ||
"refId": "A", | ||
"select": [ | ||
[ | ||
{ | ||
"params": [ | ||
"temperature " | ||
], | ||
"type": "column" | ||
} | ||
] | ||
], | ||
"table": "ettemperaturesensor ", | ||
"timeColumn": "timeinstant ", | ||
"where": [] | ||
} | ||
], | ||
"thresholds": [], | ||
"timeFrom": null, | ||
"timeRegions": [], | ||
"timeShift": null, | ||
"title": "Zone Temperature", | ||
"tooltip": { | ||
"shared": true, | ||
"sort": 0, | ||
"value_type": "individual" | ||
}, | ||
"type": "graph", | ||
"xaxis": { | ||
"buckets": null, | ||
"mode": "time", | ||
"name": null, | ||
"show": true, | ||
"values": [] | ||
}, | ||
"yaxes": [ | ||
{ | ||
"format": "celsius", | ||
"label": null, | ||
"logBase": 1, | ||
"max": "40", | ||
"min": "-10", | ||
"show": true | ||
}, | ||
{ | ||
"format": "short", | ||
"label": null, | ||
"logBase": 1, | ||
"max": null, | ||
"min": null, | ||
"show": true | ||
} | ||
], | ||
"yaxis": { | ||
"align": false, | ||
"alignLevel": null | ||
} | ||
} | ||
], | ||
"refresh": "5s", | ||
"schemaVersion": 18, | ||
"style": "dark", | ||
"tags": [], | ||
"templating": { | ||
"list": [] | ||
}, | ||
"time": { | ||
"from": "now-15m", | ||
"to": "now" | ||
}, | ||
"timepicker": { | ||
"refresh_intervals": [ | ||
"5s", | ||
"10s", | ||
"30s", | ||
"1m", | ||
"5m", | ||
"15m", | ||
"30m", | ||
"1h", | ||
"2h", | ||
"1d" | ||
], | ||
"time_options": [ | ||
"5m", | ||
"15m", | ||
"1h", | ||
"6h", | ||
"12h", | ||
"24h", | ||
"2d", | ||
"7d", | ||
"30d" | ||
] | ||
}, | ||
"timezone": "", | ||
"title": "FiwareController", | ||
"uid": "KS-M0eYnL", | ||
"version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
[ | ||
{ | ||
"timezone": "Europe/London", | ||
"timestamp": null, | ||
"apikey": "buildings", | ||
"endpoint": null, | ||
"protocol": "IoTA-JSON", | ||
"transport": "MQTT", | ||
"expressionLanguage": null, | ||
"explicitAttrs": false, | ||
"device_id": "device:001", | ||
"service": "controller", | ||
"service_path": "/buildings", | ||
"entity_name": "urn:ngsi-ld:WeatherStation:001", | ||
"entity_type": "WeatherStation", | ||
"lazy": [], | ||
"commands": [], | ||
"attributes": [ | ||
{ | ||
"name": "simtime", | ||
"type": "Number", | ||
"metadata": {}, | ||
"expression": null, | ||
"entity_name": null, | ||
"entity_type": null, | ||
"reverse": null, | ||
"object_id": "t_sim" | ||
}, | ||
{ | ||
"name": "temperature", | ||
"type": "Number", | ||
"metadata": {}, | ||
"expression": null, | ||
"entity_name": null, | ||
"entity_type": null, | ||
"reverse": null, | ||
"object_id": "t_amb" | ||
} | ||
], | ||
"static_attributes": [], | ||
"internal_attributes": [], | ||
"ngsiVersion": "v2" | ||
}, | ||
{ | ||
"timezone": "Europe/London", | ||
"timestamp": null, | ||
"apikey": "buildings", | ||
"endpoint": null, | ||
"protocol": "IoTA-JSON", | ||
"transport": "MQTT", | ||
"expressionLanguage": null, | ||
"explicitAttrs": false, | ||
"device_id": "device:002", | ||
"service": "controller", | ||
"service_path": "/buildings", | ||
"entity_name": "urn:ngsi-ld:TemperatureSensor:001", | ||
"entity_type": "TemperatureSensor", | ||
"lazy": [], | ||
"commands": [], | ||
"attributes": [ | ||
{ | ||
"name": "simtime", | ||
"type": "Number", | ||
"metadata": {}, | ||
"expression": null, | ||
"entity_name": null, | ||
"entity_type": null, | ||
"reverse": null, | ||
"object_id": "t_sim" | ||
}, | ||
{ | ||
"name": "temperature", | ||
"type": "Number", | ||
"metadata": {}, | ||
"expression": null, | ||
"entity_name": null, | ||
"entity_type": null, | ||
"reverse": null, | ||
"object_id": "t_zone" | ||
} | ||
], | ||
"static_attributes": [ | ||
{ | ||
"name": "measuredBy", | ||
"type": "Relationship", | ||
"value": "PID_1", | ||
"link": { | ||
"attributes": ["temperature"], | ||
"name": "providedBy", | ||
"type": "PID_Controller" | ||
} | ||
} | ||
], | ||
"internal_attributes": [], | ||
"ngsiVersion": "v2" | ||
}, | ||
{ | ||
"timezone": "Europe/London", | ||
"timestamp": null, | ||
"apikey": "buildings", | ||
"endpoint": null, | ||
"protocol": "IoTA-JSON", | ||
"transport": "MQTT", | ||
"expressionLanguage": null, | ||
"explicitAttrs": false, | ||
"device_id": "device:003", | ||
"service": "controller", | ||
"service_path": "/buildings", | ||
"entity_name": "urn:ngsi-ld:Heater:001", | ||
"entity_type": "Heater", | ||
"lazy": [], | ||
"commands": [ | ||
{ | ||
"name": "heater_power", | ||
"type": "Number" | ||
} | ||
], | ||
"attributes": [ | ||
{ | ||
"name": "simtime", | ||
"type": "Number", | ||
"metadata": {}, | ||
"expression": null, | ||
"entity_name": null, | ||
"entity_type": null, | ||
"reverse": null, | ||
"object_id": "t_sim" | ||
} | ||
], | ||
"static_attributes": [], | ||
"internal_attributes": [], | ||
"ngsiVersion": "v2" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
# # Example: Tune the parameters of pid4fiware online. | ||
# Procedure: | ||
1. Run this script to start the simulation | ||
2. Open Grafana to visualize the room temperature | ||
3. Tune the controller parameters in panel | ||
""" | ||
|
||
from simulation_main import simulation | ||
|
||
|
||
if __name__ == '__main__': | ||
# Simulation with small time step to allow online tuning | ||
simulation( | ||
TEMPERATURE_MAX=10, # maximal ambient temperature | ||
TEMPERATURE_MIN=-5, # minimal ambient temperature | ||
TEMPERATURE_ZONE_START=10, # start value of the zone temperature | ||
T_SIM_START=0, # simulation start time in seconds | ||
T_SIM_END=24 * 60 * 60, # simulation end time in seconds | ||
COM_STEP=5, # 5 seconds communication step | ||
SLEEP_TIME=0.5 # sleep 0.5 second between every simulation step | ||
) |
Oops, something went wrong.