-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3 click centering monitor now starts with waiting for three click #368
base: md2-raster-2024-1
Are you sure you want to change the base?
Changes from all commits
f48bcd4
a442c57
f2471fc
a74ba49
77169f6
15b2584
8203bf3
6678c7b
77d5b6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ class ControlMain(QtWidgets.QMainWindow): | |
fastShutterSignal = QtCore.Signal(float) | ||
gripTempSignal = QtCore.Signal(float) | ||
ringCurrentSignal = QtCore.Signal(float) | ||
beamAvailableSignal = QtCore.Signal(float) | ||
threeClickSignal = QtCore.Signal(str) | ||
sampleExposedSignal = QtCore.Signal(float) | ||
sampMoveSignal = QtCore.Signal(int, str) | ||
roiChangeSignal = QtCore.Signal(int, str) | ||
|
@@ -1012,6 +1012,7 @@ def createSampleTab(self): | |
self.rasterList = [] | ||
self.rasterDefList = [] | ||
self.polyPointItems = [] | ||
self.threeClickLines = [] | ||
self.rasterPoly = None | ||
self.measureLine = None | ||
self.scene = QtWidgets.QGraphicsScene(0, 0, 640, 512, self) | ||
|
@@ -1424,11 +1425,20 @@ def createSampleTab(self): | |
ringCurrentMessageLabel = QtWidgets.QLabel("Ring(mA):") | ||
self.ringCurrentMessage = QtWidgets.QLabel(str(self.ringCurrent_pv.get())) | ||
beamAvailable = self.beamAvailable_pv.get() | ||
|
||
''' | ||
changing beam available label | ||
|
||
|
||
|
||
''' | ||
|
||
|
||
if beamAvailable: | ||
self.beamAvailLabel = QtWidgets.QLabel("Beam Available") | ||
self.beamAvailLabel.setStyleSheet("background-color: #99FF66;") | ||
else: | ||
self.beamAvailLabel = QtWidgets.QLabel("No Beam") | ||
self.beamAvailLabel = QtWidgets.QLabel("Waiting for Three Click") | ||
self.beamAvailLabel.setStyleSheet("background-color: red;") | ||
sampleExposed = self.sampleExposed_pv.get() | ||
if sampleExposed: | ||
|
@@ -1450,6 +1460,13 @@ def createSampleTab(self): | |
else: | ||
self.cryostreamTempLabel = QtWidgets.QLabel("N/A") | ||
|
||
|
||
|
||
|
||
''' | ||
Adding bottom labels to gui | ||
|
||
''' | ||
fileHBoxLayout.addWidget(gripperLabel) | ||
fileHBoxLayout.addWidget(self.gripperTempLabel) | ||
fileHBoxLayout.addWidget(cryostreamLabel) | ||
|
@@ -2195,6 +2212,12 @@ def processMountedPin(self, mountedPinPos): | |
self.eraseCB() | ||
self.treeChanged_pv.put(1) | ||
|
||
|
||
''' | ||
functions to bottom status variables | ||
|
||
''' | ||
|
||
def processFastShutter(self, shutterVal): | ||
if round(shutterVal) == round(self.fastShutterOpenPos_pv.get()): | ||
self.shutterStateLabel.setText("Shutter State:Open") | ||
|
@@ -2220,13 +2243,18 @@ def processRingCurrent(self, ringCurrentVal): | |
else: | ||
self.ringCurrentMessage.setStyleSheet("background-color: #99FF66;") | ||
|
||
def processBeamAvailable(self, beamAvailVal): | ||
if int(beamAvailVal) == 1: | ||
''' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beam available is supposed to be a global signal of whether the sample would be exposed to X-rays if the shutter were open, regardless of what the user is doing on the GUI. |
||
change beam abailable set text depending on input | ||
|
||
function is processThreClickCentering | ||
''' | ||
def processThreeClickCentering(self, beamAvailVal): | ||
if beamAvailVal == '0': | ||
self.beamAvailLabel.setText("Beam Available") | ||
self.beamAvailLabel.setStyleSheet("background-color: #99FF66;") | ||
else: | ||
self.beamAvailLabel.setText("No Beam") | ||
self.beamAvailLabel.setStyleSheet("background-color: red;") | ||
self.beamAvailLabel.setText(beamAvailVal) | ||
self.beamAvailLabel.setStyleSheet("background-color: yellow") | ||
|
||
def processSampleExposed(self, sampleExposedVal): | ||
if int(sampleExposedVal) == 1: | ||
|
@@ -3058,6 +3086,8 @@ def measurePolyCB(self): | |
def center3LoopCB(self): | ||
logger.info("3-click center loop") | ||
self.threeClickCount = 1 | ||
self.threeClickSignal.emit('{} more clicks'.format(str(4-self.threeClickCount))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest using f strings see section 7.1.1 - https://docs.python.org/3/tutorial/inputoutput.html . the text to emit would look like '{4-self.threeClickCount} more clicks' |
||
#time.sleep(0.3) | ||
self.click3Button.setStyleSheet("background-color: yellow") | ||
if(daq_utils.exporter_enabled): | ||
self.md2.exporter.cmd("startManualSampleCentring", "") | ||
|
@@ -3737,13 +3767,27 @@ def sceneKey(self, event): | |
self.centeringMarksList[i]["graphicsItem"] | ||
) | ||
self.centeringMarksList[i] = None | ||
''' | ||
When picking pixels | ||
|
||
|
||
''' | ||
def pixelSelect(self, event): | ||
super(QtWidgets.QGraphicsPixmapItem, self.pixmap_item).mousePressEvent(event) | ||
x_click = float(event.pos().x()) | ||
y_click = float(event.pos().y()) | ||
penGreen = QtGui.QPen(QtCore.Qt.green) | ||
penRed = QtGui.QPen(QtCore.Qt.red) | ||
''' | ||
For three click centering, this if statement checks the omega state of the motor. | ||
This ideally gives feedback on wether the MD2 is in the rotation portion of the three click centering | ||
|
||
''' | ||
state = self.md2.exporter.read('OmegaState') | ||
if state != 'Ready': | ||
logger.info('waiting for motor rotation') | ||
logger.info('Click not registered') | ||
return | ||
if self.vidActionDefineCenterRadio.isChecked(): | ||
self.vidActionC2CRadio.setChecked( | ||
True | ||
|
@@ -3805,9 +3849,20 @@ def pixelSelect(self, event): | |
current_viewangle = daq_utils.mag3ViewAngle | ||
elif self.zoom4Radio.isChecked(): | ||
current_viewangle = daq_utils.mag4ViewAngle | ||
|
||
''' | ||
Three click centering will update self.threeClickSignal.emit(self.threeClickCount) | ||
|
||
''' | ||
if self.threeClickCount > 0: # 3-click centering | ||
self.threeClickCount = self.threeClickCount + 1 | ||
self.threeClickSignal.emit('{} more clicks'.format(str(4-self.threeClickCount))) | ||
#adding drawing for three click centering | ||
logger.info('Drawing 3 click line {} at x_value: {} and y_value {}'.format(self.threeClickCount, x_click, y_click)) | ||
self.threeClickLines.append( | ||
self.scene.addLine(x_click, 0, x_click, 512, penGreen) | ||
) | ||
|
||
|
||
if daq_utils.exporter_enabled: | ||
correctedC2C_x = x_click + ((daq_utils.screenPixX/2) - (self.centerMarker.x() + self.centerMarkerCharOffsetX)) | ||
correctedC2C_y = y_click + ((daq_utils.screenPixY/2) - (self.centerMarker.y() + self.centerMarkerCharOffsetY)) | ||
|
@@ -3820,9 +3875,19 @@ def pixelSelect(self, event): | |
correctedC2C_x = correctedC2C_x * scale_x | ||
correctedC2C_y = correctedC2C_y * scale_y | ||
self.md2.centring_click.put(f"{correctedC2C_x} {correctedC2C_y}") | ||
#logger.info('waiting for motor rotation') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out text - if necessary, use git history to retrieve it, unless it is likely to be used soon |
||
#time.sleep(0.2) | ||
#self.omegaMoveCheck(0.02,'OmegaState') | ||
|
||
if self.threeClickCount == 4: | ||
self.threeClickCount = 0 | ||
self.threeClickSignal.emit('0') | ||
self.click3Button.setStyleSheet("background-color: None") | ||
#removing drawing for three click centering | ||
logger.info('Removing 3 click lines') | ||
for i in range(len(self.threeClickLines)): | ||
self.scene.removeItem(self.threeClickLines[i]) | ||
self.threeClickLines = [] | ||
return | ||
else: | ||
comm_s = f'center_on_click({correctedC2C_x},{correctedC2C_y},{fov["x"]},{fov["y"]},source="screen",jog=90,viewangle={current_viewangle})' | ||
|
@@ -3832,9 +3897,35 @@ def pixelSelect(self, event): | |
self.aux_send_to_server(comm_s) | ||
if self.threeClickCount == 4: | ||
self.threeClickCount = 0 | ||
self.threeClickSignal.emit('0') | ||
self.click3Button.setStyleSheet("background-color: None") | ||
#removing drawing for three cick centering | ||
logger.info('Removing 3 click lines') | ||
for i in range(len(self.threeClickLines)): | ||
self.scene.removeItem(self.threeClickLines[i]) | ||
logger.info('Removed line {}'.format(i)) | ||
self.threeClickLines = [] | ||
|
||
return | ||
|
||
''' | ||
Function to check if MD motors are rotating or not | ||
''' | ||
def omegaMoveCheck(self, sleeptime,call='OmegaState'): | ||
state = self.md2.exporter.read(call) | ||
while(state == 'Moving'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if these kinds of checks are going to be done in multiple areas of the code, I suggest moving the function into a more central place and have the states as enums or constants (like things in config_params.py) so that small issues such as wrong comparison of strings ("string" != "String") don't lead to functional issues. |
||
time.sleep(sleeptime) | ||
state = self.md2.exporter.read(call) | ||
#logger.info('\nIn Moving\n{}\n'.format(state)) | ||
if state == 'Ready': | ||
logger.info('ready for next click') | ||
return state | ||
else: | ||
logger.info('\ndone moving, current state is: {}'.format(state)) | ||
return state | ||
|
||
|
||
|
||
def editScreenParamsCB(self): | ||
self.screenDefaultsDialog = ScreenDefaultsDialog(self) | ||
self.screenDefaultsDialog.show() | ||
|
@@ -5015,8 +5106,8 @@ def ringCurrentChangedCB(self, value=None, char_value=None, **kw): | |
self.ringCurrentSignal.emit(ringCurrentVal) | ||
|
||
def beamAvailableChangedCB(self, value=None, char_value=None, **kw): | ||
beamAvailableVal = value | ||
self.beamAvailableSignal.emit(beamAvailableVal) | ||
threeClickVal = value | ||
self.threeClickSignal.emit(threeClickVal) | ||
|
||
def sampleExposedChangedCB(self, value=None, char_value=None, **kw): | ||
sampleExposedVal = value | ||
|
@@ -5341,7 +5432,7 @@ def initCallbacks(self): | |
self.cryostreamTemp_pv.add_callback(self.cryostreamTempChangedCB) | ||
self.ringCurrentSignal.connect(self.processRingCurrent) | ||
self.ringCurrent_pv.add_callback(self.ringCurrentChangedCB) | ||
self.beamAvailableSignal.connect(self.processBeamAvailable) | ||
self.threeClickSignal.connect(self.processThreeClickCentering) | ||
self.beamAvailable_pv.add_callback(self.beamAvailableChangedCB) | ||
self.sampleExposedSignal.connect(self.processSampleExposed) | ||
self.sampleExposed_pv.add_callback(self.sampleExposedChangedCB) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it looks like the beam available GUI feature is being replaced with three-click, I suggest using a completely new GUI object instead of re-using an old one. Re-using items with the same name is going to be difficult to debug in the feature than if it is correctly named.