Support for various app and slic wrapper
This commit is contained in:
@ -1 +1,3 @@
|
||||
from .reichebscombined import ReicheBSCombined
|
||||
from .magnet import Magnet
|
||||
from .camacquisition import CamAcquisition
|
||||
from .counteradjustable import CounterAdjustable
|
||||
|
41
ext/camacquisition.py
Normal file
41
ext/camacquisition.py
Normal file
@ -0,0 +1,41 @@
|
||||
from time import sleep
|
||||
from tqdm import trange
|
||||
import h5py
|
||||
|
||||
from cam_server_client import PipelineClient
|
||||
from cam_server_client.utils import get_host_port_from_stream_address
|
||||
from bsread import source, SUB
|
||||
|
||||
|
||||
from slic.core.acquisition.acquisition import Acquisition
|
||||
class CamAcquisition(Acquisition):
|
||||
|
||||
def getConnection(self,cam):
|
||||
pipeline_client = PipelineClient()
|
||||
cam_instance_name = str(cam) + "_sp1"
|
||||
stream_address = pipeline_client.get_instance_stream(cam_instance_name)
|
||||
self.host, self.port = get_host_port_from_stream_address(stream_address)
|
||||
print(self.host,self.port)
|
||||
|
||||
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
||||
print("my routine")
|
||||
print("extra kwargs:", kwargs)
|
||||
args = (filename, n_pulses, channels)
|
||||
args = ", ".join(repr(i) for i in args)
|
||||
print("acquire({})".format(args))
|
||||
print(f"dummy acquire to {filename}:")
|
||||
|
||||
# stream_host,stream_port = getPipeLine(channels[0])
|
||||
# time.wait(1)
|
||||
data= []
|
||||
with source(host=self.host, port=self.port, mode=SUB) as input_stream:
|
||||
input_stream.connect()
|
||||
for i in range(n_pulses):
|
||||
print('Camera Images', i)
|
||||
message = input_stream.receive()
|
||||
data.append(message.data.data)
|
||||
hid = h5py.File(filename,'w')
|
||||
gid = hid.create_group(channels[0])
|
||||
for key in data[0].keys():
|
||||
gid.create_dataset(key, data = [rec[key].value for rec in data])
|
||||
hid.close()
|
23
ext/counteradjustable.py
Normal file
23
ext/counteradjustable.py
Normal file
@ -0,0 +1,23 @@
|
||||
from slic.core.adjustable import Adjustable
|
||||
|
||||
class CounterAdjustable(Adjustable):
|
||||
def __init__(self, adjustable1, adjustable2):
|
||||
self.adj1=adjustable1
|
||||
self.adj2=adjustable2
|
||||
self.ref_values() # implementation needs reference values to convert absolute scan to relative scan
|
||||
|
||||
def ref_value(self):
|
||||
self.val1 = self.adj1.get_current_value(readback = False)
|
||||
self.val2 = self.adj2.get_current_value(readback = False)
|
||||
|
||||
def set_target_value(self, value):
|
||||
t1 = self.adj1.set_target_value(self.val1 + value)
|
||||
t2 = self.adj2.set_target_value(self.val2 - value)
|
||||
t1.wait()
|
||||
t2.wait()
|
||||
|
||||
def get_current_value(self):
|
||||
return self.adj1.get_current_value()
|
||||
|
||||
def is_moving(self):
|
||||
return any([self.adj1.is_moving(),self.adj2.is_moving()])
|
21
ext/magnet.py
Normal file
21
ext/magnet.py
Normal file
@ -0,0 +1,21 @@
|
||||
from slic.core.adjustable import PVAdjustable
|
||||
from slic.utils import typename
|
||||
|
||||
class Magnet(PVAdjustable):
|
||||
|
||||
def __init__(self,name):
|
||||
self.name=name
|
||||
pvsv='%s:I-SET' % name
|
||||
pvrb='%s:I-READ' % name
|
||||
tol = 0.075
|
||||
super().__init__(pvsv,pvname_readback=pvrb,accuracy=tol,internal=True)
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return "Cycling"
|
||||
|
||||
def __repr__(self):
|
||||
tn = typename(self)
|
||||
return f"{tn} \"{self.name}\" is {self.status}"
|
@ -1,12 +0,0 @@
|
||||
from slic.core.sensor.bsmonitor import BSMonitor
|
||||
|
||||
class ReicheBSCombined(BSMonitor):
|
||||
|
||||
# Du brauchst kein extra init. BSMonitor tut schon das richtige...
|
||||
|
||||
def _unpack(self, data):
|
||||
# data ist ein dict mit allen Deinen Kanälen
|
||||
pid = data["pid"] # der effektive Channel-Name der Pulse ID
|
||||
# hier dein Code
|
||||
# am Ende sollte eine Zahl rauskommen:
|
||||
return data
|
Reference in New Issue
Block a user