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

New TS2 Screen with Archiver data

parent 7f717610
No related branches found
No related tags found
No related merge requests found
Pipeline #39012 failed
...@@ -2,6 +2,9 @@ import epics ...@@ -2,6 +2,9 @@ import epics
import json import json
import time import time
import sys import sys
import pandas
import requests
import datetime
from threading import Thread from threading import Thread
...@@ -16,7 +19,7 @@ class ts2_screensScreen(Thread): ...@@ -16,7 +19,7 @@ class ts2_screensScreen(Thread):
"TS2-010CDL:Cryo-TE-82313:MeasValue", "TS2-010CDL:Cryo-TE-82313:MeasValue",
"TS2-010CDL:Cryo-TE-82360:MeasValue", "TS2-010CDL:Cryo-TE-82360:MeasValue",
"TS2-010CRM:Cryo-TE-068:MeasValue", "TS2-010CRM:Cryo-TE-068:MeasValue",
"TS2-010CRM:Cryo-TE-063:MeasValue", # "TS2-010CRM:Cryo-TE-063:MeasValue",
"TS2-010CRM:Cryo-TE-069:MeasValue", "TS2-010CRM:Cryo-TE-069:MeasValue",
"TS2-010CRM:Cryo-TE-064:MeasValue", "TS2-010CRM:Cryo-TE-064:MeasValue",
"TS2-010CDL:Cryo-TE-82365:MeasValue", "TS2-010CDL:Cryo-TE-82365:MeasValue",
...@@ -28,23 +31,46 @@ class ts2_screensScreen(Thread): ...@@ -28,23 +31,46 @@ class ts2_screensScreen(Thread):
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)
counter = 0
while not self.stop_signal.isSet(): while not self.stop_signal.isSet():
try: try:
json_dict = {} if counter%7200 == 0:
json_dict = {}
for pv in epics_dict:
start_date=(datetime.datetime.now()-datetime.timedelta(days=14)).isoformat()+'Z'
end_date=datetime.datetime.now().isoformat()+'Z'
url = 'http://archiver-01.tn.esss.lu.se:17668/retrieval/data/getData.json?pv=count({})&from={}&to={}'.format(pv,start_date,end_date)
r = requests.get(url).json()[0]['data']
entries = 0
for i in r:
entries+=i['val']
url = 'http://archiver-01.tn.esss.lu.se:17668/retrieval/data/getData.json?pv=nth_{}({})&from={}&to={}'.format(int(entries//1400),pv,start_date,end_date)
r = requests.get(url).json()[0]['data']
raw_data = pandas.DataFrame.from_dict(r)
final_data={}
final_data['2w'] = raw_data.groupby(raw_data.index//(raw_data.shape[0]/100)).mean()
tmp = raw_data[raw_data['secs']>(datetime.datetime.now()-datetime.timedelta(days=7)).timestamp()]
final_data['1w'] = tmp.groupby(tmp.index//(tmp.shape[0]/100)).mean()
tmp = raw_data[raw_data['secs']>(datetime.datetime.now()-datetime.timedelta(days=2)).timestamp()]
final_data['2d'] = tmp.groupby(tmp.index//(tmp.shape[0]/100)).mean()
tmp = raw_data[raw_data['secs']>(datetime.datetime.now()-datetime.timedelta(days=1)).timestamp()]
final_data['1d'] = tmp.groupby(tmp.index//(tmp.shape[0]/100)).mean()
final_data['live'] = raw_data[-100:]
json_dict[pv] = {}
json_dict[pv]['2w']=list(zip((final_data['2w']['secs']*1000).astype('int')+(final_data['2w']['nanos']/1e6).astype('int'), round(final_data['2w']['val'],3)))
json_dict[pv]['1w']=list(zip((final_data['1w']['secs']*1000).astype('int')+(final_data['1w']['nanos']/1e6).astype('int'), round(final_data['1w']['val'],3)))
json_dict[pv]['2d']=list(zip((final_data['2d']['secs']*1000).astype('int')+(final_data['2d']['nanos']/1e6).astype('int'), round(final_data['2d']['val'],3)))
json_dict[pv]['1d']=list(zip((final_data['1d']['secs']*1000).astype('int')+(final_data['1d']['nanos']/1e6).astype('int'), round(final_data['1d']['val'],3)))
json_dict[pv]['live']=list(zip((final_data['live']['secs']*1000).astype('int')+(final_data['live']['nanos']/1e6).astype('int'), round(final_data['live']['val'],3)))
counter = 0
for pv in epics_dict: for pv in epics_dict:
json_dict[pv] = {}
if epics_dict[pv].connected: 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 value = epics_dict[pv].value
if type(value) == float: timestamp = int(epics_dict[pv].timestamp*1000)
json_dict[pv]["value"] = round(value, 3) if type(value) == float and timestamp != json_dict[pv]['live'][-1][0]:
else: json_dict[pv]['live']=json_dict[pv]['live'][1:]
json_dict[pv]["value"] = value json_dict[pv]['live'].append((timestamp, round(value, 3)))
else:
json_dict[pv]["units"] = "n.c."
json_dict[pv]["timestamp"] = ""
json_dict[pv]["value"] = ""
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")
...@@ -55,6 +81,7 @@ class ts2_screensScreen(Thread): ...@@ -55,6 +81,7 @@ class ts2_screensScreen(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()
......
...@@ -202,4 +202,4 @@ ...@@ -202,4 +202,4 @@
} }
], ],
"columns": 4 "columns": 4
} }
\ No newline at end of file
...@@ -4,6 +4,26 @@ ...@@ -4,6 +4,26 @@
"allow_edit": false, "allow_edit": false,
"plugins": [], "plugins": [],
"panes": [ "panes": [
{
"title": "Time Selector",
"width": 1,
"row": {
"3": 7
},
"col": {
"3": 1
},
"col_width": 4,
"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
}
}
]
},
{ {
"width": 1, "width": 1,
"row": { "row": {
...@@ -35,7 +55,7 @@ ...@@ -35,7 +55,7 @@
"row": { "row": {
"1": 7, "1": 7,
"2": 7, "2": 7,
"3": 7, "3": 11,
"4": 7, "4": 7,
"5": 39, "5": 39,
"6": 39, "6": 39,
...@@ -53,51 +73,37 @@ ...@@ -53,51 +73,37 @@
"col_width": 4, "col_width": 4,
"widgets": [ "widgets": [
{ {
"type": "highcharts-timeseries", "type": "flot_extended_plugin",
"settings": { "settings": {
"timeframe": 300, "plot_type": "line",
"blocks": 4, "legend": true,
"chartType": "spline", "height": 4,
"xaxis": "{\"title\":{\"text\" : \"Time\"}, \"type\": \"datetime\", \"floor\":0}", "value": "var series = document.getElementById(\"time-series\").value;\ndata = [\n {label: 'CrS-TICP:Cryo-TE-31491', data: datasources[\"TS2\"][\"CrS-TICP:Cryo-TE-31491:Val\"][series]},\n {label: 'TS2-010CDL:Cryo-TE-82313', data: datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82313:MeasValue\"][series]},\n {label: 'TS2-010CDL:Cryo-TE-82360', data: datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82360:MeasValue\"][series]}\n];\nfreeboard.showLoadingIndicator(false);\nreturn data;",
"yaxis": "{\"title\":{\"text\" : \"Values\"}, \"minorTickInterval\":\"auto\", \"floor\":0}", "x_timestamp": true,
"series1": "datasources[\"TS2\"][\"CrS-TICP:Cryo-TE-31491:Val\"][\"value\"]", "zoom": ""
"series1label": "CrS-TICP:Cryo-TE-31491",
"series2": "datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82313:MeasValue\"][\"value\"]",
"series2label": "TS2-010CDL:Cryo-TE-82313",
"series3": "datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82360:MeasValue\"][\"value\"]",
"series3label": "TS2-010CDL:Cryo-TE-82360"
} }
}, },
{ {
"type": "highcharts-timeseries", "type": "flot_extended_plugin",
"settings": { "settings": {
"timeframe": 300, "plot_type": "line",
"blocks": 4, "legend": true,
"chartType": "spline", "height": 4,
"xaxis": "{\"title\":{\"text\" : \"Time\"}, \"type\": \"datetime\", \"floor\":0}", "value": "var series = document.getElementById(\"time-series\").value;\ndata = [\n {label: 'TS2-010CRM:Cryo-TE-068', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-068:MeasValue\"][series]},\n {label: 'TS2-010CRM:Cryo-TE-064', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-064:MeasValue\"][series]},\n {label: 'TS2-010CRM:Cryo-TE-069', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-069:MeasValue\"][series]}\n];\nfreeboard.showLoadingIndicator(false);\nreturn data;\n",
"yaxis": "{\"title\":{\"text\" : \"Values\"}, \"minorTickInterval\":\"auto\", \"floor\":0}", "x_timestamp": true,
"series1": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-068:MeasValue\"][\"value\"]", "zoom": ""
"series1label": "TS2-010CRM:Cryo-TE-068",
"series2": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-064:MeasValue\"][\"value\"]",
"series2label": "TS2-010CRM:Cryo-TE-064",
"series3": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-069:MeasValue\"][\"value\"]",
"series3label": "TS2-010CRM:Cryo-TE-069"
} }
}, },
{ {
"type": "highcharts-timeseries", "type": "flot_extended_plugin",
"settings": { "settings": {
"timeframe": 300, "plot_type": "line",
"blocks": 4, "legend": true,
"chartType": "spline", "height": 4,
"xaxis": "{\"title\":{\"text\" : \"Time\"}, \"type\": \"datetime\", \"floor\":0}", "value": "var series = document.getElementById(\"time-series\").value;\ndata = [\n {label: 'TS2-010CRM:Cryo-TE-064', data: datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-064:MeasValue\"][series]},\n {label: 'TS2-010CDL:Cryo-TE-82314', data: datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82314:MeasValue\"][series]},\n {label: 'CrS-TICP:Cryo-TE-31492', data: datasources[\"TS2\"][\"CrS-TICP:Cryo-TE-31492:Val\"][series]}\n];\nfreeboard.showLoadingIndicator(false);\nreturn data;",
"yaxis": "{\"title\":{\"text\" : \"Values\"}, \"minorTickInterval\":\"auto\", \"floor\":0}", "xticks": "",
"series1": "datasources[\"TS2\"][\"TS2-010CRM:Cryo-TE-064:MeasValue\"][\"value\"]", "x_timestamp": true,
"series1label": "TS2-010CRM:Cryo-TE-064", "zoom": ""
"series2": "datasources[\"TS2\"][\"TS2-010CDL:Cryo-TE-82314:MeasValue\"][\"value\"]",
"series2label": "TS2-010CDL:Cryo-TE-82314",
"series3": "datasources[\"TS2\"][\"CrS-TICP:Cryo-TE-31492:Val\"][\"value\"]",
"series3label": "CrS-TICP:Cryo-TE-31492:Val"
} }
} }
] ]
...@@ -122,5 +128,5 @@ ...@@ -122,5 +128,5 @@
} }
} }
], ],
"columns": 4 "columns": 3
} }
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