Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/epics"]
path = external/epics
url = https://github.com/MatthewJCameron/epics
1 change: 1 addition & 0 deletions external/epics
Submodule epics added at 04e667
12 changes: 7 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -32,7 +35,6 @@
datefmt='%H:%M:%S',
level=logging.INFO
)

"""
MAIN CLASS: Application starts here.
"""
Expand Down
14 changes: 7 additions & 7 deletions systems/control/backend/epics/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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']:
Expand All @@ -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)
Expand All @@ -173,7 +173,7 @@ def write(self,value,mode='absolute'):
maxRetrties = 3
BDST=self.pv['BDST'].get()
while (abs(newPosition-predictedPosition)>BDST) and (retryCounter<maxRetrties):
logging.error("Motor {} did not move to {}. Retry #{} of {}.".format(self.pv['DESC'],predictedPosition,retryCounter+1,maxRetrties))
logging.error("Motor {} did not move to {}. Retry #{} of {}.".format(self.pv['DESC'].get(),predictedPosition,retryCounter+1,maxRetrties))
self.pv['VAL'].put(predictedPosition)
time.sleep(0.2)
while self.pv['DMOV'].get() == 0:
Expand All @@ -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

Expand Down