Skip to content
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

Fix beamstop and capillary not shown #1447

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion demo/beamstop.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<object class="ExporterNStateMockup">
<username>beamstop</username>
<values>{"OUT": "OFF", "IN": "BEAM"}</values>
<values>{"IN": "BEAM", "OUT": "OFF"}</values>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The front-end expects the "good" state (green) to come first.

<use_hwstate>True</use_hwstate>
</object>
4 changes: 2 additions & 2 deletions demo/mxcube-web/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ beamline_setup:
id: beamline_setup
components:
- label: Beamstop
attribute: beamstop
attribute: diffractometer.beamstop
- label: Capillary
attribute: capillary
attribute: diffractometer.capillary
Comment on lines +103 to +105
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the two attributes appear in the UI.

- label: Fast Shutter
attribute: fast_shutter
- label: Safety shutter
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/MotorInput/BaseMotorInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function BaseMotorInput(props) {
state === HW_STATE.OFF;

return (
<form noValidate onSubmit={handleSubmit}>
<form className="d-flex" noValidate onSubmit={handleSubmit}>
<Form.Control
className={className}
style={style}
Expand All @@ -72,7 +72,7 @@ function BaseMotorInput(props) {
max={max}
min={min}
disabled={disabled || !isReady}
data-testId={testId}
data-testid={testId}
data-dirty={isEdited || undefined}
data-busy={isBusy || undefined}
data-warning={isWarning || undefined}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/MotorInput/OneAxisTranslationControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function OneAxisTranslationControl(props) {
className={`${styles.input} rw-input`}
style={{
width: `${Number.parseFloat(precision) + 2}em`,
height: '2.1em',
height: 'auto',
display: 'inline-block',
marginLeft: '5px',
marginRight: '5px',
Expand Down
25 changes: 9 additions & 16 deletions ui/src/containers/BeamlineSetupContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import InOutSwitch from '../components/InOutSwitch/InOutSwitch';
import DeviceState from '../components/DeviceState/DeviceState';
import MachInfo from '../components/MachInfo/MachInfo';
import OneAxisTranslationControl from '../components/MotorInput/OneAxisTranslationControl';
import * as sampleViewActions from '../actions/sampleview'; // eslint-disable-line import/no-namespace

import { find, filter } from 'lodash';

Expand All @@ -23,32 +22,27 @@ function BeamlineSetupContainer(props) {
beamline,
sampleChanger,
sampleview,
sampleViewActions,
uiproperties,
setAttribute,
stopBeamlineAction,
sendCommand,
} = props;

function handleSetAttribute(name, value) {
setAttribute(name, value);
}

function renderBeamstopAlignmentOverlay() {
const { hardwareObjects } = beamline;
const motorInputList = [];
let popover = null;

const motor = hardwareObjects.beamstop_alignemnt_x;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a typo, but the hardware object is no longer called beamstop_alignment_x anyway but diffractometer.beamstop_distance.

This and the changes below fix the beamstop distance overlay as shown in the third screenshot (the cog icon + overlay with OneAxisTranslationControl).

const motor = hardwareObjects['diffractometer.beamstop_distance'];
const step = sampleview.motorSteps.beamstop_distance;

if (motor !== undefined && motor.state !== 0) {
if (motor) {
motorInputList.push(
<div key={`bsao-${motor.name}`} style={{ padding: '0.5em' }}>
<p className="motor-name"> Beamstop distance: </p>
<div key={`bsao-${motor.name} d-flex`} style={{ padding: '0.5em' }}>
<p className="motor-name mb-1"> Beamstop distance:</p>
<OneAxisTranslationControl
save={sampleViewActions.updateMotorPosition}
value={motor.position}
save={setAttribute}
value={motor.value}
min={motor.limits[0]}
max={motor.limits[1]}
step={step}
Expand Down Expand Up @@ -92,7 +86,7 @@ function BeamlineSetupContainer(props) {
labelText={uiprop.label}
pkey={key}
value={beamline.hardwareObjects[key].value}
onSave={handleSetAttribute}
onSave={setAttribute}
optionsOverlay={renderBeamstopAlignmentOverlay()}
/>
</Nav.Item>,
Expand All @@ -108,7 +102,7 @@ function BeamlineSetupContainer(props) {
labelText={uiprop.label}
pkey={key}
value={beamline.hardwareObjects[key].value}
onSave={handleSetAttribute}
onSave={setAttribute}
/>
</Nav.Item>,
);
Expand Down Expand Up @@ -164,7 +158,7 @@ function BeamlineSetupContainer(props) {
format={uiprop.format}
precision={uiprop.precision}
suffix={uiprop.suffix}
onSave={(value) => handleSetAttribute(uiprop.attribute, value)}
onSave={(value) => setAttribute(uiprop.attribute, value)}
onCancel={() => stopBeamlineAction(uiprop.attribute)}
/>
</td>,
Expand Down Expand Up @@ -268,7 +262,6 @@ function mapStateToProps(state) {

function mapDispatchToProps(dispatch) {
return {
sampleViewActions: bindActionCreators(sampleViewActions, dispatch),
setAttribute: bindActionCreators(setAttribute, dispatch),
sendCommand: bindActionCreators(sendCommand, dispatch),
stopBeamlineAction: bindActionCreators(stopBeamlineAction, dispatch),
Expand Down
Loading