Skip to content

Commit

Permalink
2023 tim johann (#134)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Child <[email protected]>
Co-authored-by: Johann Drayne <[email protected]>

Updates from Jan 2023 CD
  • Loading branch information
johann997 authored May 2, 2023
1 parent dae1a91 commit 3879b9c
Show file tree
Hide file tree
Showing 6 changed files with 438 additions and 89 deletions.
47 changes: 29 additions & 18 deletions Required/ScanController.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,14 @@ function scv_sanitizeSetpoints(start_list, fin_list, items, starts, fins)

starts = replaceString(" ", start_list, "")
fins = replaceString(" ", fin_list, "")

// Make sure the starts/ends don't have commas at the end (igor likes to put them in unnecessarily when making lists)
if (cmpstr(starts[strlen(starts)-1], ",") == 0) // Zero if equal (I know... stupid)
starts = starts[0, strlen(starts)-2]
endif
if (cmpstr(fins[strlen(fins)-1], ",") == 0) // Zero if equal (I know... stupid)
fins = fins[0, strlen(fins)-2]
endif
end


Expand Down Expand Up @@ -988,7 +996,7 @@ function/S scg_initializeGraphs(S)
else
ylabel = S.y_label
endif
buffer = scg_initializeGraphsForWavenames(waveNames, S.x_label, is2d=S.is2d, y_label=ylabel)
buffer = scg_initializeGraphsForWavenames(waveNames, S.x_label, for_2d=S.is2d, y_label=ylabel)
if(raw==1) // Raw waves
sc_rawGraphs1D = buffer
endif
Expand All @@ -998,15 +1006,15 @@ function/S scg_initializeGraphs(S)
end


function/S scg_initializeGraphsForWavenames(wavenames, x_label, [is2d, y_label])
function/S scg_initializeGraphsForWavenames(wavenames, x_label, [for_2d, y_label])
// Ensures a graph is open and tiles graphs for each wave in comma separated wavenames
// Returns list of graphIDs of active graphs
string wavenames, x_label, y_label
variable is2d
variable for_2d

y_label = selectString(paramisDefault(y_label), y_label, "")
string y_label_2d = y_label
string y_label_1d = selectString(is2d, y_label, "") // Only use the y_label for 1D graphs if the scan is 1D (otherwise gets confused with y sweep gate)
string y_label_1d = selectString(for_2d, y_label, "") // Only use the y_label for 1D graphs if the scan is 1D (otherwise gets confused with y sweep gate)


string wn, openGraphID, graphIDs = ""
Expand All @@ -1023,7 +1031,7 @@ function/S scg_initializeGraphsForWavenames(wavenames, x_label, [is2d, y_label])
graphIDs = addlistItem(openGraphID, graphIDs, ";", INF)


if (is2d)
if (for_2d)
wn = wn+"_2d"
openGraphID = scg_graphExistsForWavename(wn)
if (cmpstr(openGraphID, "")) // Graph is already open (str != "")
Expand Down Expand Up @@ -2167,10 +2175,12 @@ function/s scw_createConfig()
string sysinfo = igorinfo(3)
tmpstr = addJSONkeyval(tmpstr, "OS", StringByKey("OS", sysinfo), addQuotes = 1)
tmpstr = addJSONkeyval(tmpstr, "IGOR_VERSION", StringByKey("IGORFILEVERSION", sysinfo), addQuotes = 1)


configstr = addJSONkeyval(configstr, "system_info", tmpstr)

// log instrument info
configstr = addJSONkeyval(configstr, "instruments", textWave2StrArray(sc_Instr))
configstr = addJSONkeyval(configstr, "instruments", textWave2StrArray(sc_Instr)) /// <<<<<<<< I think some thing with textwave2strarray is broken... seems like a lot of the logs are lost after this

// wave names
tmpstr = ""
Expand Down Expand Up @@ -2688,26 +2698,27 @@ function scc_checkSameDeviceFD(S, [x_only, y_only])
struct ScanVars &s
variable x_only, y_only // whether to check only one axis (e.g. other is babydac)

variable device_dacs
variable device_buffer
variable device_x
variable device_y
variable device_adc
string channels
if (!y_only)
channels = scf_getChannelNumsOnFD(S.channelsx, device_dacs) // Throws error if not all channels on one FastDAC
channels = scf_getChannelNumsOnFD(S.channelsx, device_x) // Throws error if not all channels on one FastDAC
endif
if (!x_only)
channels = scf_getChannelNumsOnFD(S.channelsy, device_buffer)
if (device_dacs > 0 && device_buffer > 0 && device_buffer != device_dacs)
abort "ERROR[scc_checkSameDeviceFD]: X channels and Y channels are not on same device" // TODO: Maybe this should raise an error?
elseif (device_dacs <= 0 && device_buffer > 0)
device_dacs = device_buffer
channels = scf_getChannelNumsOnFD(S.channelsy, device_y)
if (device_x > 0 && device_y > 0 && device_y != device_x && S.instrIDx == S.instrIDy)
abort "ERROR[scc_checkSameDeviceFD]: X channels and Y channels are not on same device but InstrIDx/y are the same"
// elseif (device_dacs <= 0 && device_buffer > 0)
// device_dacs = device_buffer
endif
endif

channels = scf_getChannelNumsOnFD(s.AdcList, device_buffer, adc=1) // Raises error if ADCs aren't on same device
if (device_dacs > 0 && device_buffer != device_dacs)
abort "ERROR[scc_checkSameDeviceFD]: ADCs are not on the same device as DACs" // TODO: Maybe should only raise error if x channels not on same device as ADCs?
channels = scf_getChannelNumsOnFD(s.AdcList, device_adc, adc=1) // Raises error if ADCs aren't on same device
if (device_x > 0 && device_adc != device_x)
abort "ERROR[scc_checkSameDeviceFD]: ADCs are not on the same device as X axis DAC"
endif
return device_buffer // Return adc device number
return device_adc // Return adc device number
end


Expand Down
8 changes: 5 additions & 3 deletions Required/ScanController_IO.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function addMetaFiles(hdf5_id_list, [S, logs_only, comments])
Struct ScanVars &S
variable logs_only // 1=Don't save any sweep information to HDF
make/Free/T/N=1 cconfig = {""}
cconfig = prettyJSONfmt(scw_createConfig())
// cconfig = prettyJSONfmt(scw_createConfig()) //<< 2023/01 -- I think someting about this is chopping off a lot of the info
cconfig = scw_createConfig() // << This is the temporary fix -- at least the info is saved even if not perfect

if (!logs_only)
make /FREE /T /N=1 sweep_logs = prettyJSONfmt(sc_createSweepLogs(S=S))
Expand Down Expand Up @@ -128,7 +129,7 @@ function addMetaFiles(hdf5_id_list, [S, logs_only, comments])
endif

// may as well save this config file, since we already have it
scw_saveConfig(cconfig[0])
scw_saveConfig(cconfig[0])

endfor
end
Expand Down Expand Up @@ -185,7 +186,8 @@ function sc_instrumentLogs(jstr)
// Runs all getinstrStatus() functions, and adds results to json string (to be stored in sweeplogs)
// Note: all log strings must be valid JSON objects
string &jstr


sc_openInstrConnections(0) // Reopen connections before asking for status in case it has been a long time since the beginning of the scan
wave /t sc_Instr
variable i=0, j=0, addQuotes=0
string command="", val=""
Expand Down
Loading

0 comments on commit 3879b9c

Please sign in to comment.