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 cea239a..23f7965 100755 --- a/main.py +++ b/main.py @@ -1,12 +1,15 @@ +# Core imports. +import os +import sys +from functools import partial +SIMULATE=False +if SIMULATE: + 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 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. """ diff --git a/systems/control/backend/epics/controls.py b/systems/control/backend/epics/controls.py index 330d120..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=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