add files and simulated modes
This commit is contained in:
63
zoom.py
63
zoom.py
@@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# *-----------------------------------------------------------------------*
|
||||
# | |
|
||||
# | Copyright (c) 2022 by Paul Scherrer Institute (http://www.psi.ch) |
|
||||
# | Based on Zac great first implementation |
|
||||
# | Author Thierry Zamofing (thierry.zamofing@psi.ch) |
|
||||
# *-----------------------------------------------------------------------*
|
||||
'''
|
||||
'''
|
||||
|
||||
import json
|
||||
import logging
|
||||
@@ -25,7 +32,7 @@ from PyQt5.QtWidgets import (
|
||||
from PyQt5.uic import loadUiType
|
||||
import epics
|
||||
|
||||
Ui_Zoom, QWidget = loadUiType("epics_widgets/zoom.ui")
|
||||
Ui_Zoom, QWidget = loadUiType("zoom.ui")
|
||||
MIN_ZOOM = 1
|
||||
MAX_ZOOM = 1000
|
||||
SPINNER_SINGLE_STEP = 50
|
||||
@@ -199,7 +206,7 @@ class Zoom(QGroupBox, Ui_Zoom):
|
||||
|
||||
def toggle_backlight(self):
|
||||
bl=QApplication.instance()._backlight
|
||||
if bl.is_in() or bl.is_diode():
|
||||
if bl.is_pos('in'):
|
||||
self.moveBacklight.emit("out")
|
||||
self.blgt_button.setText("Move Backlight IN")
|
||||
else:
|
||||
@@ -277,6 +284,9 @@ class Zoom(QGroupBox, Ui_Zoom):
|
||||
class QopticZoom(object):
|
||||
|
||||
def __init__(self, prefix='SAR-EXPMX-FETURA'):
|
||||
if prefix is None:
|
||||
self._val=1
|
||||
return #simulated mode
|
||||
self._pv=pv=dict()
|
||||
if prefix[-1]!=':': prefix+=':'
|
||||
self._prefix=prefix
|
||||
@@ -291,32 +301,57 @@ class QopticZoom(object):
|
||||
return pv
|
||||
|
||||
def get(self) -> int:
|
||||
pv=self.getPv('POS_RB')
|
||||
try:
|
||||
pv = self.getPv('POS_RB')
|
||||
except AttributeError:
|
||||
val=self._val; _log.info('simulated mode:{}'.format(val))
|
||||
return val
|
||||
else:
|
||||
pv=self.getPv('POS_RB')
|
||||
return pv.get()
|
||||
|
||||
def set(self, val: int):
|
||||
|
||||
pv=self.getPv('POS_SP')
|
||||
pv.put(val)
|
||||
try:
|
||||
pv=self.getPv('POS_SP')
|
||||
except AttributeError:
|
||||
_log.info('simulated mode:{}'.format(val))
|
||||
self._val=val #simulated mode
|
||||
else:
|
||||
pv.put(val)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import time, os, PIL.Image, platform, subprocess
|
||||
import argparse
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--sim", "-s", help="simulate all devices", action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
import sys
|
||||
import backlight
|
||||
import illumination
|
||||
import camera
|
||||
|
||||
_log.info('Start')
|
||||
os.environ['EPICS_CA_ADDR_LIST'] = '129.129.244.255 sf-saresc-cagw.psi.ch:5062 sf-saresc-cagw.psi.ch:5066'
|
||||
app = QApplication(sys.argv)
|
||||
from app_config import settings, appsconf
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
||||
if args.sim:
|
||||
app._backlight = backlight.Backlight(None)
|
||||
app._illumination = illumination.IlluminationControl(None)
|
||||
app._zoom = QopticZoom(None)
|
||||
app._camera = camera.epics_cam(None)
|
||||
else:
|
||||
app._backlight = backlight.Backlight()
|
||||
app._illumination = illumination.IlluminationControl()
|
||||
app._zoom = QopticZoom()
|
||||
app._camera = camera.epics_cam()
|
||||
|
||||
_log.debug('Start')
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
app._backlight = backlight.Backlight()
|
||||
app._illumination = illumination.IlluminationControl("129.129.221.92", 1003)
|
||||
app._zoom = QopticZoom()
|
||||
app._camera = camera.camera_server('SARES30-CAMS156-SMX-OAV')
|
||||
|
||||
simulated = appsconf["microscope"]["zoom"].get("simulate", False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user