Skip to content

Commit

Permalink
UI: manage SC state from one source
Browse files Browse the repository at this point in the history
Make sure that sample changer state is managed by the SET_SC_STATE
action only.

Previously the sample changer state was set by two different actions,
one originating from SampleChanger HW object and the other from
SampleChangerMaint HW object.

That creates problems, as the state can potentionally be set to different
values by these two objects. Let the SampleChanger HW object be the
source of truth for the current sample changer state.
  • Loading branch information
elmjag authored and marcus-oscarsson committed Aug 29, 2023
1 parent ea53d05 commit 337efd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 8 additions & 2 deletions mxcube3/routes/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,18 @@ def sc_contents_update():
server.emit("sc_contents_update")


def sc_maintenance_update(state_list, cmd_state, message):
def sc_maintenance_update(*args):
if len(args) == 3:
# be backward compatible with older HW objects,
# which are emitting signal with 3 arguments
_, cmd_state, message = args
else:
cmd_state, message = args

try:
server.emit(
"sc_maintenance_update",
{
"state": json.dumps(state_list),
"commands_state": json.dumps(cmd_state),
"message": message,
},
Expand Down
6 changes: 0 additions & 6 deletions ui/src/reducers/sampleChanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ export default (state = INITIAL_STATE, action) => {
case 'SET_SC_SELECTED_DROP': {
return { ...state, selectedDrop: action.drop_index };
}
case 'SET_SC_GLOBAL_STATE': {
return {
...state,
state: JSON.parse(action.data.state).state,
};
}
default: {
return state;
}
Expand Down
2 changes: 0 additions & 2 deletions ui/src/reducers/sampleChangerMaintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export default (state = INITIAL_STATE, action) => {
case 'SET_SC_GLOBAL_STATE': {
return {
...state,
state: JSON.parse(action.data.state),
global_state: JSON.parse(action.data.global_state),
commands_state: JSON.parse(action.data.commands_state),
message: action.data.message,
};
Expand Down

0 comments on commit 337efd3

Please sign in to comment.