01.2025
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import ch.psi.utils.DataAPI as DataAPI
|
||||
|
||||
#da = DataAPI("https://data-api.psi.ch/sf")
|
||||
da = DataAPI("https://data-api.psi.ch/sf-databuffer")
|
||||
|
||||
|
||||
ret = da.queryData(["S10BC01-DBLM065:B1_LOSS"], 23251652441, 23251653739)
|
||||
plot([d['value'] for d in ret[0]['data']], xdata=[d['pulseId'] for d in ret[0]['data']])
|
||||
|
||||
ret = da.queryData(["S10BC01-DBLM065:B1_LOSS"], "2025-01-21T16:06:00.000", "2025-01-21T16:06:02.000")
|
||||
plot([d['value'] for d in ret[0]['data']], xdata=[d['pulseId'] for d in ret[0]['data']])
|
||||
@@ -0,0 +1,84 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
class DataBuffer:
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
|
||||
def get_response(self, response, is_json=True):
|
||||
if response.status_code != 200:
|
||||
raise Exception(response.text)
|
||||
return json.loads(response.text) if is_json else response.text
|
||||
|
||||
def get_binary_response(self, response):
|
||||
if response.status_code != 200:
|
||||
raise Exception(response.text)
|
||||
return response.raw.read()
|
||||
|
||||
def get_data(self, req):
|
||||
return self.get_response(requests.post(url=self.url+"/query", json=req))
|
||||
|
||||
def get_channels(self):
|
||||
data = {
|
||||
"regex":"DWSC090",
|
||||
"backends":[
|
||||
"sf-databuffer"
|
||||
],
|
||||
"ordering":"asc",
|
||||
"reload":True
|
||||
}
|
||||
print self.url+"/channels"
|
||||
return self.get_response(requests.post(url=self.url+"/channels", json=data))
|
||||
|
||||
|
||||
|
||||
req = {
|
||||
"channels":[
|
||||
"S10BC01-DBLM065:B1_LOSS"
|
||||
],
|
||||
"range":{
|
||||
#"startPulseId":23251652441,
|
||||
#"endPulseId":23251653739,
|
||||
|
||||
"startDate":"2025-01-21T16:20:00.000",
|
||||
"startInclusive":True,
|
||||
"startExpansion":False,
|
||||
"endDate":"2025-01-21T16:20:01.000",
|
||||
"endInclusive":True,
|
||||
"endExpansion":False
|
||||
|
||||
|
||||
},
|
||||
"ordering":"asc",
|
||||
"configFields":[
|
||||
"globalDate",
|
||||
"type"
|
||||
],
|
||||
"eventFields":[
|
||||
"pulseId",
|
||||
"globalDate",
|
||||
"value"
|
||||
],
|
||||
"aggregation":{
|
||||
"aggregationType":"value",
|
||||
"aggregations":[
|
||||
"min",
|
||||
"mean",
|
||||
"max"
|
||||
],
|
||||
"nrOfBins":20
|
||||
},
|
||||
"response":{
|
||||
"format":"json",
|
||||
"compression":"none",
|
||||
},
|
||||
"mapping":{
|
||||
"incomplete":"provide-as-is"
|
||||
}
|
||||
}
|
||||
|
||||
db = DataBuffer ("http://data-api.psi.ch/sf-databuffer")
|
||||
#c = db.get_channels()
|
||||
ret = db.get_data(req)
|
||||
print ret
|
||||
plot([d[0]['value']['mean'] for d in ret['data']], xdata=[d[0]['pulseId'] for d in ret['data']])
|
||||
@@ -1,11 +1,11 @@
|
||||
CAMERA = "SARES20-CAMS142-M3"
|
||||
CAMERA = "SARFE10-PSSS059"
|
||||
#CAMERA = "SARFE10-PSSS059"
|
||||
#CAMERA = "SATES31-CAMS187-RIXS1"
|
||||
#CAMERA = "SAROP21-PPRM138"
|
||||
#CAMERA = "SARES20-CAMS142-C2"
|
||||
#CAMERA = "SATBD02-DSCR050"
|
||||
#CAMERA = "SARCL01-DSCR170"
|
||||
|
||||
CAMERA = "SATBD02-DSCR050"
|
||||
CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://")
|
||||
#CAMERA_URL= "tcp://sf-sioc-cs-83:9020"
|
||||
#sCAMERA_URL= "tcp://sf-daqsync-17:9002"
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
#cam_server.stop()
|
||||
#cam_server.start("stream_example")
|
||||
cam_server.start("bs_timing_test")
|
||||
cam_server.start("simulation_sp", True)
|
||||
cam_server.stream.waitCacheChange(3000)
|
||||
|
||||
bscan (cam_server.stream, 100, save=False)
|
||||
#
|
||||
#bscan (cam_server.stream, 100, save=False)
|
||||
|
||||
names=[]
|
||||
data=[]
|
||||
for k,v in cam_server.value.items():
|
||||
#for k,v in cam_server.value.items():
|
||||
# names.append(k)
|
||||
# data.append(v)
|
||||
|
||||
for k in cam_server.value.keys():
|
||||
names.append(k)
|
||||
#data.append(v)
|
||||
|
||||
for v in cam_server.value.values():
|
||||
#names.append(k)
|
||||
data.append(v)
|
||||
|
||||
|
||||
plot(data, names)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user