Skip to content
Snippets Groups Projects
Commit 4eb9b0d2 authored by Emanuele Laface's avatar Emanuele Laface
Browse files

Update He Levels and Pressures

parent 7c97955f
No related branches found
No related tags found
No related merge requests found
Pipeline #39149 passed
...@@ -3,6 +3,9 @@ import json ...@@ -3,6 +3,9 @@ import json
import time import time
import sys import sys
import numpy import numpy
import pandas
import datetime
import requests
from threading import Thread from threading import Thread
...@@ -55,6 +58,28 @@ def p2t(p): ...@@ -55,6 +58,28 @@ def p2t(p):
return t return t
def get_from_archiver(pv, start_date, end_date):
try:
url = "http://archiver-01.tn.esss.lu.se:17668/retrieval/data/getData.json?pv=ncount({})&from={}&to={}".format(
pv, start_date, end_date
)
entries = int(requests.get(url).json()[0]["data"][0]["val"])
url = "http://archiver-01.tn.esss.lu.se:17668/retrieval/data/getData.json?pv=nth_{}({})&from={}&to={}".format(
int(entries // 100), pv, start_date, end_date
)
r = requests.get(url).json()[0]["data"]
raw_data = pandas.DataFrame.from_dict(r)
return list(
zip(
(raw_data["secs"] * 1000).astype("int")
+ (raw_data["nanos"] / 1e6).astype("int"),
round(raw_data["val"], 3),
)
)
except Exception:
return []
class ts2_helevpresScreen(Thread): class ts2_helevpresScreen(Thread):
def __init__(self, stop_signal): def __init__(self, stop_signal):
Thread.__init__(self) Thread.__init__(self)
...@@ -67,41 +92,74 @@ class ts2_helevpresScreen(Thread): ...@@ -67,41 +92,74 @@ class ts2_helevpresScreen(Thread):
"TS2-010CRM:Cryo-LT-001:MeasValue", "TS2-010CRM:Cryo-LT-001:MeasValue",
"TS2-010CRM:Cryo-LT-002:MeasValue", "TS2-010CRM:Cryo-LT-002:MeasValue",
] ]
intervals = {"2w": 24 * 14, "1w": 24 * 7, "2d": 24 * 2, "1d": 24, "live": 1}
epics_dict = {} epics_dict = {}
for pv in pvs: for pv in pvs:
epics_dict[pv] = epics.PV(pv, auto_monitor=True) epics_dict[pv] = epics.PV(pv, auto_monitor=True)
json_dict = {}
counter = 0
while not self.stop_signal.isSet(): while not self.stop_signal.isSet():
try: try:
json_dict = {}
for pv in epics_dict: for pv in epics_dict:
json_dict[pv] = {}
if epics_dict[pv].connected:
json_dict[pv]["units"] = epics_dict[pv].units
json_dict[pv]["timestamp"] = epics_dict[pv].timestamp
value = epics_dict[pv].value
if type(value) == float:
json_dict[pv]["value"] = round(value, 3)
else:
json_dict[pv]["value"] = value
else:
json_dict[pv]["units"] = "n.c."
json_dict[pv]["timestamp"] = ""
json_dict[pv]["value"] = ""
if pv == "TS2-010CRM:Cryo-PT-003:MeasValue": if pv == "TS2-010CRM:Cryo-PT-003:MeasValue":
json_dict[pv]["temp"] = round(p2t(json_dict[pv]["value"]), 3) json_dict[pv] = {}
if epics_dict[pv].connected:
json_dict[pv]["units"] = epics_dict[pv].units
json_dict[pv]["timestamp"] = epics_dict[pv].timestamp
json_dict[pv]["temp"] = "N/A"
value = epics_dict[pv].value
if type(value) == float:
json_dict[pv]["value"] = round(value, 3)
json_dict[pv]["temp"] = round(
p2t(json_dict[pv]["value"]), 3
)
else:
json_dict[pv]["value"] = value
if pv == "TS2-010CRM:Cryo-PT-004:MeasValue": if pv == "TS2-010CRM:Cryo-PT-004:MeasValue":
if ( json_dict[pv] = {}
numpy.isreal(json_dict[pv]["value"]) if epics_dict[pv].connected:
and json_dict[pv]["value"] <= 65 json_dict[pv]["units"] = epics_dict[pv].units
): json_dict[pv]["timestamp"] = epics_dict[pv].timestamp
json_dict[pv]["temp"] = round(
p2t(json_dict[pv]["value"]), 3
)
else:
json_dict[pv]["temp"] = "N/A" json_dict[pv]["temp"] = "N/A"
value = epics_dict[pv].value
if type(value) == float:
json_dict[pv]["value"] = round(value, 3)
if value <= 65:
json_dict[pv]["temp"] = round(
p2t(json_dict[pv]["value"]), 3
)
else:
json_dict[pv]["value"] = value
if (
pv == "TS2-010CRM:Cryo-LT-001:MeasValue"
or pv == "TS2-010CRM:Cryo-LT-002:MeasValue"
):
if counter % 7200 == 0:
json_dict[pv] = {}
for interval in intervals:
start_date = (
datetime.datetime.now()
- datetime.timedelta(hours=intervals[interval])
).isoformat() + "Z"
end_date = datetime.datetime.now().isoformat() + "Z"
json_dict[pv][interval] = get_from_archiver(
pv, start_date, end_date
)
counter = 0
else:
if epics_dict[pv].connected:
value = epics_dict[pv].value
timestamp = int(epics_dict[pv].timestamp * 1000)
if (
type(value) == float
and timestamp != json_dict[pv]["live"][-1][0]
):
json_dict[pv]["live"] = json_dict[pv]["live"][1:]
json_dict[pv]["live"].append(
(timestamp, round(value, 3))
)
tmp_json = json.dumps(json_dict) tmp_json = json.dumps(json_dict)
tmp_json = tmp_json.replace("NaN", "0") tmp_json = tmp_json.replace("NaN", "0")
...@@ -112,6 +170,7 @@ class ts2_helevpresScreen(Thread): ...@@ -112,6 +170,7 @@ class ts2_helevpresScreen(Thread):
print(sys.exc_info()) print(sys.exc_info())
time.sleep(1) time.sleep(1)
time.sleep(0.5) time.sleep(0.5)
counter += 1
for pv in epics_dict: for pv in epics_dict:
epics_dict[pv].clear_auto_monitor() epics_dict[pv].clear_auto_monitor()
......
...@@ -31,69 +31,56 @@ ...@@ -31,69 +31,56 @@
] ]
}, },
{ {
"title": "Level Probes", "title": "Levels",
"width": 1, "width": 1,
"row": { "row": {
"1": 7, "4": 11,
"2": 7, "5": 1
"3": 7,
"4": 7,
"5": 7,
"6": 7,
"7": 7
}, },
"col": { "col": {
"1": 1,
"2": 1,
"3": 1,
"4": 1, "4": 1,
"5": 1, "5": 5
"6": 1,
"7": 1
}, },
"col_width": 1, "col_width": 2,
"widgets": [ "widgets": [
{ {
"type": "vertical-linear-gauge", "type": "flot_extended_plugin",
"settings": { "settings": {
"title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-LT-001:MeasValue&pv=TS2-010CRM:Cryo-LT-002:MeasValue\" target=\"_blank\">LT-001 Level Sensor 1</a>", "plot_type": "line",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-LT-001:MeasValue\"][\"value\"]", "legend": true,
"units": "%", "height": 4,
"min_value": "0", "value": "var series = document.getElementById(\"time-series\").value;\ndata = [\n {label: 'TS2-010CRM:Cryo-LT-001', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-LT-001:MeasValue\"][series]},\n {label: 'TS2-010CRM:Cryo-LT-002', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-LT-002:MeasValue\"][series]},\n];\nfreeboard.showLoadingIndicator(false);\nreturn data;",
"max_value": 100 "x_timestamp": true,
} "zoom": ""
},
{
"type": "vertical-linear-gauge",
"settings": {
"title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-LT-001:MeasValue&pv=TS2-010CRM:Cryo-LT-002:MeasValue\" target=\"_blank\">LT-002 Level Sensor 2</a>",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-LT-002:MeasValue\"][\"value\"]",
"units": "%",
"min_value": 0,
"max_value": 100
} }
} }
] ]
}, },
{ {
"title": "Pressures", "title": "TS2-010CRM:Cryo-PT-003",
"width": 1, "width": 1,
"row": { "row": {
"2": 7, "2": 7,
"3": 7, "3": 7,
"4": 7 "4": 7,
"5": 7,
"6": 7,
"7": 7
}, },
"col": { "col": {
"2": 2, "2": 2,
"3": 2, "3": 2,
"4": 2 "4": 3,
"5": 2,
"6": 2,
"7": 2
}, },
"col_width": 1, "col_width": 1,
"widgets": [ "widgets": [
{ {
"type": "vertical-linear-gauge", "type": "vertical-linear-gauge",
"settings": { "settings": {
"title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-LT-001:MeasValue&pv=TS2-010CRM:Cryo-PT-003:MeasValue\" target=\"_blank\">TS2-010CRM:Cryo-PT-003</a>", "title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-PT-003:MeasValue\" target=\"_blank\">Pressure</a>",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-003:MeasValue\"][\"value\"]", "value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-003:MeasValue\"][\"value\"]",
"units": "mbar", "units": "mbar",
"min_value": 0, "min_value": 0,
...@@ -103,44 +90,48 @@ ...@@ -103,44 +90,48 @@
{ {
"type": "vertical-linear-gauge", "type": "vertical-linear-gauge",
"settings": { "settings": {
"title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-LT-001:MeasValue&pv=TS2-010CRM:Cryo-PT-004:MeasValue\" target=\"_blank\">TS2-010CRM:Cryo-PT-004</a>", "title": "Temperature",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-004:MeasValue\"][\"value\"]", "value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-003:MeasValue\"][\"temp\"]",
"units": "mbar", "units": "K",
"min_value": 0, "min_value": 0,
"max_value": 67 "max_value": 5
} }
} }
] ]
}, },
{ {
"title": "Temperatures", "title": "TS2-010CRM:Cryo-PT-004",
"width": 1, "width": 1,
"row": { "row": {
"2": 21, "2": 21,
"3": 7, "3": 7,
"4": 7 "4": 7,
"6": 7,
"7": 7
}, },
"col": { "col": {
"2": 1, "2": 1,
"3": 3, "3": 3,
"4": 3 "4": 4,
"6": 3,
"7": 3
}, },
"col_width": 1, "col_width": 1,
"widgets": [ "widgets": [
{ {
"type": "vertical-linear-gauge", "type": "vertical-linear-gauge",
"settings": { "settings": {
"title": "TS2-010CRM-Cryo-PT-003 Temperature", "title": "<a href=\"https://pos.esss.lu.se/plot/retrieval/ui/viewer/archViewer.html?pv=TS2-010CRM:Cryo-PT-004:MeasValue\" target=\"_blank\">Pressure</a>",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-003:MeasValue\"][\"temp\"]", "value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-004:MeasValue\"][\"value\"]",
"units": "K", "units": "mbar",
"min_value": 0, "min_value": 0,
"max_value": 5 "max_value": 67
} }
}, },
{ {
"type": "vertical-linear-gauge", "type": "vertical-linear-gauge",
"settings": { "settings": {
"title": "TS2-010CRM-Cryo-PT-004 Temperature", "title": "Temperature",
"value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-004:MeasValue\"][\"temp\"]", "value": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-PT-004:MeasValue\"][\"temp\"]",
"units": "K", "units": "K",
"min_value": 0, "min_value": 0,
...@@ -148,6 +139,26 @@ ...@@ -148,6 +139,26 @@
} }
} }
] ]
},
{
"title": "Time Selector",
"width": 1,
"row": {
"4": 7
},
"col": {
"4": 1
},
"col_width": 2,
"widgets": [
{
"type": "html",
"settings": {
"html": "<script>\n function setDatasource(event) {\n\t\tfreeboard.showLoadingIndicator(true);\n\t};\n</script>\n<div style=\"position:relative;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;\">\n <select onchange=\"setDatasource()\" id=\"time-series\">\n <option value=\"2w\">Two Weeks</option>\n <option value=\"1w\">One Week</option>\n <option value=\"2d\">Two Days</option>\n <option value=\"1d\">One Day</option>\n <option value=\"live\">Live</option>\n </select>\n</div>",
"height": 1
}
}
]
} }
], ],
"datasources": [ "datasources": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment