From c8d089ca021784885b5048710429ef077069d261 Mon Sep 17 00:00:00 2001 From: MatthewJCameron Date: Wed, 4 Dec 2019 17:10:51 +1100 Subject: [PATCH 1/4] added ability to fake epics - noPyOpenCL changes not committed --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index cea239a..e8b08d3 100755 --- a/main.py +++ b/main.py @@ -1,12 +1,15 @@ +# Core imports. +import os +import sys +from functools import partial +SIMULATE=True +if SIMULATE: + sys.path.insert(1,"C:\\Users\\Mathew\\Desktop\\mattpystuff") #gives path to fake epics so it loads before real epics # Internal imports. from resources import config, ui import systems import QsWidgets from systems.imageGuidance import nonOrthogonalImaging -# Core imports. -import os -import sys -from functools import partial # Sitepackages imports. import numpy as np from PyQt5.QtCore import pyqtSlot as Slot @@ -32,7 +35,6 @@ datefmt='%H:%M:%S', level=logging.INFO ) - """ MAIN CLASS: Application starts here. """ From 3a89698e980437e9b1a006c009be03882a5e8d50 Mon Sep 17 00:00:00 2001 From: MatthewJCameron Date: Thu, 5 Dec 2019 10:29:57 +1100 Subject: [PATCH 2/4] Added submodule fake epics with associated subdirectory 'external' to allow addition of external to path when using fake epics (having 'epics' at top level forces loading of fake epics preferentially to pyepics in all cases - this setup avoids that) --- .gitmodules | 3 +++ external/epics | 1 + main.py | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 external/epics diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d1d1918 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/epics"] + path = external/epics + url = https://github.com/MatthewJCameron/epics diff --git a/external/epics b/external/epics new file mode 160000 index 0000000..04e6674 --- /dev/null +++ b/external/epics @@ -0,0 +1 @@ +Subproject commit 04e66747eea2eed5e4f12fc81266b38e071c7521 diff --git a/main.py b/main.py index e8b08d3..23f7965 100755 --- a/main.py +++ b/main.py @@ -2,9 +2,9 @@ import os import sys from functools import partial -SIMULATE=True +SIMULATE=False if SIMULATE: - sys.path.insert(1,"C:\\Users\\Mathew\\Desktop\\mattpystuff") #gives path to fake epics so it loads before real epics + sys.path.insert(1,"external") #gives path to fake epics so it loads before real epics # Internal imports. from resources import config, ui import systems From 27bf5916b817e95c13848ce68ce6c6c594609bcc Mon Sep 17 00:00:00 2001 From: MatthewJCameron Date: Thu, 5 Dec 2019 10:39:58 +1100 Subject: [PATCH 3/4] added .get() to calls to RBV --- systems/control/backend/epics/controls.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/systems/control/backend/epics/controls.py b/systems/control/backend/epics/controls.py index 330d120..d64cd8c 100644 --- a/systems/control/backend/epics/controls.py +++ b/systems/control/backend/epics/controls.py @@ -186,14 +186,14 @@ def write(self,value,mode='absolute'): def checkAbsLimit(self,value): stillInLimitBool=False - if float(value)<=float(self.pv['HLM']) and float(value)>=float(self.pv['LLM']): + if float(value)<=float(self.pv['HLM'].get()) and float(value)>=float(self.pv['LLM'].get()): stillInLimitBool=True return stillInLimitBool def checkRelLimit(self,value): stillInLimitBool=False - if (float(value)+float(self.pv['RBV']))>=float(self.pv['LLM']) \ - and (float(value)+float(self.pv['RBV']))<=float(self.pv['HLM']) : + if (float(value)+float(self.pv['RBV'].get()))>=float(self.pv['LLM'].get()) \ + and (float(value)+float(self.pv['RBV'].get()))<=float(self.pv['HLM'].get()) : stillInLimitBool=True return stillInLimitBool From b25565875dd3c0ba14b943bec10fbb0ab494edcb Mon Sep 17 00:00:00 2001 From: MatthewJCameron Date: Thu, 5 Dec 2019 10:53:02 +1100 Subject: [PATCH 4/4] added extra .get() commands where appropriate. Confirmed that fakeEpics submodule works as expected with 'git submodule init; git submodule update' in fresh clone. main.py simulate bool set to False by default. --- systems/control/backend/epics/controls.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/systems/control/backend/epics/controls.py b/systems/control/backend/epics/controls.py index d64cd8c..dfab621 100644 --- a/systems/control/backend/epics/controls.py +++ b/systems/control/backend/epics/controls.py @@ -118,7 +118,7 @@ def writeValue(self,attribute,value): if attribute == 'TWV': self.pv[attribute].put(value) else: - while self.pv['DMOV'] == 0: + while self.pv['DMOV'].get() == 0: pass self.pv[attribute].put(value) @@ -141,7 +141,7 @@ def write(self,value,mode='absolute'): if self.checkAbsLimit(value): self.pv['VAL'].put(float(value)) else: - logging.error("Cannot move {} to {} - motorlimit will be reached.\nH.Lim:{}\tL.Lim:{}".format(self.pv['DESC'],value,self.pv['HLM'],self.pv['LLM'])) + logging.error("Cannot move {} to {} - motorlimit will be reached.\nH.Lim:{}\tL.Lim:{}".format(self.pv['DESC'].get(),value,self.pv['HLM'].get(),self.pv['LLM'].get())) return elif mode=='relative': if self.pv['TWV']: @@ -159,7 +159,7 @@ def write(self,value,mode='absolute'): # Do nothing. pass else: - logging.error("Cannot move {} by {} - motorlimit will be reached.\nH.Lim:{}\tL.Lim:{}".format(self.pv['DESC'],value,self.pv['HLM'],self.pv['LLM'])) + logging.error("Cannot move {} by {} - motorlimit will be reached.\nH.Lim:{}\tL.Lim:{}".format(self.pv['DESC'].get(),value,self.pv['HLM'].get(),self.pv['LLM'].get())) return # Give epics 100ms to get the command to the motor. time.sleep(0.2) @@ -173,7 +173,7 @@ def write(self,value,mode='absolute'): maxRetrties = 3 BDST=self.pv['BDST'].get() while (abs(newPosition-predictedPosition)>BDST) and (retryCounter