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

CONF: Clear HS association on DAEphys window restore for HS w/o amp #1804

Merged
merged 13 commits into from
Aug 4, 2023

Conversation

MichaelHuth
Copy link
Collaborator

@MichaelHuth MichaelHuth commented Jul 6, 2023

  • Previously the on restore the amplifiers were set plain by headstage. The default configuration of the DAEphys panel is that unless "Clear Associations" is clicked all HS are associated. Also MIES implements that associated HS need to have an amplifier set.

    On saving the DAEphys window there is no GUI control that state explicitly if a HS is associated or not.

    Solution: We assume that the headstages without a set amplifier are unassociated and clear the association for these HS.

since introduction of configuration module

close #1763
close #1811

@MichaelHuth MichaelHuth self-assigned this Jul 6, 2023
@MichaelHuth MichaelHuth assigned t-b and unassigned MichaelHuth Jul 7, 2023
@t-b t-b assigned MichaelHuth and unassigned t-b Jul 7, 2023
@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch 2 times, most recently from e2e74f5 to 078dfc7 Compare July 7, 2023 20:20
@MichaelHuth MichaelHuth assigned t-b and unassigned MichaelHuth Jul 8, 2023
@t-b t-b assigned MichaelHuth and unassigned t-b Jul 10, 2023
@MichaelHuth MichaelHuth assigned timjarsky and unassigned MichaelHuth Jul 10, 2023
@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch from 078dfc7 to cd0aa98 Compare July 10, 2023 16:46
@t-b t-b mentioned this pull request Jul 11, 2023
26 tasks
@timjarsky
Copy link
Collaborator

@t-b Based on our chat yesterday, may I be unassigned from this PR for now?

@t-b t-b assigned t-b and MichaelHuth and unassigned timjarsky and t-b Jul 14, 2023
@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch from cd0aa98 to c71f89b Compare July 21, 2023 04:33
@MichaelHuth MichaelHuth assigned t-b and unassigned MichaelHuth Jul 21, 2023
@t-b
Copy link
Collaborator

t-b commented Jul 21, 2023

d83d874 (Tests: Fix of FixupJSONConfigImplRig to replace only existing amp serials, 2023-07-07)
f121edc (CONF: Clear HS association on DAEphys window restore for HS w/o amp, 2023-07-06)

Already reviewed.

186ddcd (PGC: Add optional argument noRangeCheck to PGC_SetAndActivateControl, 2023-07-21)

No tests because??? I'm also not convinced that this is the right approach. Why not teach the popup menu control have NONE instead?

4f13d36 (CONF: For DAEPhys save DA/AD gain/unit/channels for all active HS, 2023-07-21)

Missing tests. The changed handling of the title entry should also be its own commit.

0ba284d (CONF: For DAEPhys load the AD/DA channels are restored for all active Headstages, 2023-07-21)

I also don't understand

- if originally no DA/AD channel was set, then NaN was saved as channel number,
 this is restored properly to an unset channel number utilizing the noRangeCheck
 argument of PGC_SetAndActivateControl
 The same approach as in DAP_UpdateChanAmpAssignPanel is applied.

does it make sense to write NaN as DA/DA channel number out?

The following window configuration was stored with HS 7 active and no DA/AD channels associated. And loading that as config fails with

  (Dev1) Please select a valid DA and AD channel in "DAC Channel and Device Associations" in the Hardware tab.
  Configuration restore aborted at file .

Note the missing filename.

NoAmplifier.zip

Missing tests and please also check the wording in the commit message.

c71f89b (DAEPhys: Increased width of AD/DA gain setVar fields, 2023-07-21)

Looks good.

I also saw that the hiding and restoring of the DAEphys panel has changed in this PR. Now it is shown when the controls are configured on load.

Are the changes in DAP_CheckHeastage missing?

@t-b t-b assigned MichaelHuth and unassigned t-b Jul 21, 2023
@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch from c71f89b to 638b46f Compare July 21, 2023 16:58
@t-b
Copy link
Collaborator

t-b commented Jul 31, 2023

@timjarsky Feel free to test already as the changes Michael needs to do are not functionality wise.

@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch from ca36a2f to c25f929 Compare August 3, 2023 00:05
@MichaelHuth MichaelHuth removed their assignment Aug 3, 2023
timjarsky
timjarsky previously approved these changes Aug 3, 2023
@timjarsky timjarsky assigned t-b and MichaelHuth and unassigned timjarsky Aug 3, 2023
@t-b
Copy link
Collaborator

t-b commented Aug 3, 2023

@MichaelHuth Please rebase and assign me.

…ials

- Before we assumed to have a HS0 and HS1 with amplifier for the
  configuration tests, future configuration tests have more versatile
  amplifier settings.
  Thus, a more general approach for the fixup is to replace amplifier serials
  only for amplifiers that are already present in the configuration.
- Some gains are as small as 0.0005 and were cut off by the field width
  these are now fully visible
- The daephys panel version was increased
- Previously this was cleared by "Clear Headstage Association" to an
  invalid PopupMenu index that resulted in an empty PopupMenu.
  this has two disadvantages:
  1. The user can not set No-Channel himself
  2. The code must handle invalid list indices

- The panel controls were updated and repositioned to fit the larger size
- The DAEPhys panel version was increased
- The update and readout of the DA/AD channel popup menus was adapted
…ings

- outputs now also the headstage number that has problematic settings as
  it might not be the currently visible headstage configuration and, thus
  visually hidden
- Instead of setting the control content directly,
  use PGC_SetAndActivateControl because this also calls the associated GUI
  procedure and updates GUI state waves.
- Due to setting the controls triggers a resynchronisation of GUI to CAA wave,
  it works on a copy of the CAA wave.
The consistency of the GetChannelClampMode gets corrupted.

The function DAP_RemoveClampModeSettings clears unused clamp mode settings.
However, it is only called if a headstage is unchecked or the clamp mode is
switched.
For the case the DAEPhys panel is closed and reopened the clamp mode wave with
the previous setting is kept in the former and now again current device
data folder. Though, the default headstage state in the panel is unchecked.
If one was using headstage 2 and 3 before and starts using head stage 0 and 1
in the current DAEPhys panel with at least partially the same DA/AD channels
then the setup of the new DAQ config wave fails in DC_PlaceDataInDAQConfigWave.
This is due to remaining entries in the clamp mode wave from headstage 2 and 3
that are now not used. The remaining entries cause DC_GetFilteredChannelState
to create an invalid mapping because the twice appearing DAC channel is counted
twice for a single headstage (through AFH_GetHeadstageFromDAC).

Fix:
Kill clamp mode wave on locking of DAEPhys panel.
Since
d4b24fc (DA_Ephys: Make "Save amplifier settings" checkbox dependent on "Require amplifier", 2022-07-29)
the control check_Settings_SaveAmpSettings was setup as dependent control of
check_Settings_RequireAmpConn where is gets unchecked and disabled if the main
control gets unchecked.

However, if the main control is unchecked the user can still setup amplifiers
for head stages that were not saved to the LNB then.

The fix is to remove the dependency as amplifier information should always be
saved if an amplifier was enabled and check_Settings_SaveAmpSettings was
checked.
- Previously the on restore the amplifiers were set plain by headstage.
  The default configuration of the DAEphys panel is that unless
  "Clear Associations" is clicked all HS are associated.
  Also MIES implements that associated HS need to have an amplifier set.

  On saving the DAEphys window there is no GUI control that state explicitly
  if a HS is associated or not.

  Solution:
  Before the solution is introduced some details to the previous behavior.
  When a DAEPhys panel is configured some settings are stored in the MIES
  DF and restored if the DAEPhys panel is opened at a later time again.
  To prevent any influence by that the test kills the MIES DF after saving
  the configuration.
  When restoring the DAEPhys panel the specific code ran in the following
  order:
  1. Restore the DAEPhys panel as generic window respecting the control
     priority settings
  2. Restore HeadStage associations
  3. Restore UserPressure settings

  At point 1 the HeadStage checkboxes and the DA/AD channel checkboxes have
  both the same priority (Inf). By default a "virgin" DAEPhys panel has
  HS 0 - 3 associated. Thus, depending on the order of HS or Channel
  checkboxes activates they influence the setting of the other automatically.
  Thus, it makes no sense to attribute a priority order for HS vs Channel CBs.

  A better solution is to set the HeadStage association first before generally
  restoring the window state. If the association is set, then enabling a
  channel results in enabling a headstage if associated. And enabling an
  associated headstage checkbox enables the DA/AD channels. This is consistent.
  Considering unassociated headstages, then enabling a DA channel does not
  influence the headstage setting and vice versa.

  To apply the HeadStage association first, the DAEPhys panel must be locked
  first. Some code has been added for that. the generic window restore will
  attempt to lock again with the same values, but that is ok.

  In the headstage association function if no amplifier for a headstage is set
  it is treated as unassociated and the HS association is cleared.

since introduction of configuration module

Move DAEPhys window minimize to earlier point in restore logic

- Due to the earlier headstage association restore the window minimize has to be
  also done earlier
…e headstages

- also Gain and Unit is restored.
- if originally no DA/AD channel was set, then NaN is saved as channel number
  from the chanAmpAssign wave, this is restored properly to an "None" channel
  number.
- To stay compatible with older config files, the existence of all these config
  entries is checked before evaluation. For that two utility function were
  added: CONF_OnExistSetAndActivateControlVar and
  CONF_OnExistSetAndActivateControlStr
- The abort error message only showed a file name if a file name was set as
  argument of the function. Thus, when calling the function with an empty
  file name and then using the file dialog, no file name was shown in the
  error message.
- Fix: use the fullFilePath the LoadTextFile returns for the error
- checks if the chanAmp values are in line with the settings in the
  DA/AD channel tabs
- there was no check before for active HS without amplifier
@MichaelHuth MichaelHuth force-pushed the bugfix/1804-restore_unassocDA_state_on_config_load branch from c25f929 to 0fd90a4 Compare August 3, 2023 18:22
@MichaelHuth MichaelHuth removed their assignment Aug 3, 2023
@t-b t-b enabled auto-merge August 3, 2023 18:24
@t-b t-b removed their assignment Aug 3, 2023
@t-b t-b merged commit 3ff5cf0 into main Aug 4, 2023
@t-b t-b deleted the bugfix/1804-restore_unassocDA_state_on_config_load branch August 4, 2023 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DAEphys with no amplifier issues JSON Configuration: Allow configuration of unassociated AD/DA channels
3 participants