Skip to content

Commit

Permalink
AI_SyncAmpStorageToGUI: Allow forcing to write all values
Browse files Browse the repository at this point in the history
This is needed on the initial MIES->MCC sync as we don't know if our
internal state is correct or not.
  • Loading branch information
t-b committed Mar 3, 2025
1 parent 4a57b83 commit ae5c619
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions Packages/MIES/MIES_AmplifierInteraction.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,20 @@ Function AI_SyncAmpStorageToGUI(string device, variable headstage)
End

/// @brief Sync the settings from the GUI to the amp storage wave and the MCC application
Function AI_SyncGUIToAmpStorageAndMCCApp(string device, variable headStage, variable clampMode)
Function AI_SyncGUIToAmpStorageAndMCCApp(string device, variable headStage, variable clampMode, [variable force])

string ctrl, list
variable i, numEntries
variable i, numEntries, value, checkBeforeWrite

DAP_AbortIfUnlocked(device)
AI_AssertOnInvalidClampMode(clampMode)

if(ParamIsDefault(force))
force = 0
else
force = !!force
endif

if(DAG_GetNumericalValue(device, "slider_DataAcq_ActiveHeadstage") != headStage)
return NaN
endif
Expand All @@ -494,6 +500,12 @@ Function AI_SyncGUIToAmpStorageAndMCCApp(string device, variable headStage, vari
list = AMPLIFIER_CONTROLS_IC
endif

if(force)
checkBeforeWrite = 0
else
checkBeforeWrite = 1
endif

numEntries = ItemsInList(list)
for(i = 0; i < numEntries; i += 1)
ctrl = StringFromList(i, list)
Expand All @@ -502,7 +514,8 @@ Function AI_SyncGUIToAmpStorageAndMCCApp(string device, variable headStage, vari
continue
endif

AI_UpdateAmpModel(device, ctrl, headStage, checkBeforeWrite = 1, sendToAll = 0, selectAmp = 0)
value = DAG_GetNumericalValue(device, ctrl)
AI_UpdateAmpModel(device, ctrl, headStage, value = value, checkBeforeWrite = checkBeforeWrite, sendToAll = 0, selectAmp = 0)
endfor
End

Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -4331,7 +4331,7 @@ Function DAP_CheckProc_SyncMiesToMCC(STRUCT WMCheckboxAction &cba) : CheckBoxCon
device = cba.win
headstage = DAG_GetNumericalValue(device, "slider_DataAcq_ActiveHeadstage")
clampMode = DAG_GetHeadstageMode(device, headstage)
AI_SyncGUIToAmpStorageAndMCCApp(device, headstage, clampMode)
AI_SyncGUIToAmpStorageAndMCCApp(device, headstage, clampMode, force = 1)
break
default:
break
Expand Down

0 comments on commit ae5c619

Please sign in to comment.