Skip to content

Commit a7711ef

Browse files
authored
fix(snippet): fix all 3ch configs (#43)
- Simplify the MSMU/MPSU constructors - Carry over some changes to MSMU `config` function to the MPSU `config` function - other miscellaneous changes
1 parent ed08b5f commit a7711ef

File tree

1 file changed

+71
-51
lines changed

1 file changed

+71
-51
lines changed

xml-handler/src/resources/sweep/MP5000Sweep.xml

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
---@class Source
8686
---@field values ScalarValue | LogValues | LinearValues | ListValues The value or values to source
87-
---@field range number | "AUTO" The range to use, or Auto
87+
---@field range number | "AUTO" The range to use, or Auto
8888
---@field limiti number The current limit
8989
---@field limitv number | nil The voltage limit
9090
---@field delay number The time to delay before sourcing
@@ -98,7 +98,7 @@
9898
---@field nplc number | nil
9999
---@field aperture number | nil
100100
---@field rate `CONSTANTS.RATE_FAST` | `CONSTANTS.RATE_NORMAL` | nil
101-
---@field range number | "AUTO" The range to use, or Auto
101+
---@field range number | "AUTO" The range to use, or Auto
102102
-- ---@field autozero boolean Whether autozero should be turned on or not
103103
---@field count integer The number of measurments to take
104104
-- ---@field filter_enable boolean Whether to enable the filter or not
@@ -147,7 +147,7 @@
147147
---@class ModelComponent
148148
---@field reset fun(self: Device) The function used to reset the device
149149
---@field config fun(self: Device) The function used to configure the device settings
150-
---@field trigger_model_setup fun(self: Device) The function used to set up the trigger model
150+
---@field trigger_model_setup fun(self: Device, bias_source_event: any | nil, bias_measure_event: any| nil, step_source_event: any | nil, step_measure_event: any | nil, sweep_source_event: any | nil, sweep_measure_event: any | nil, bias_source_complete_events: any[] | nil, bias_measure_complete_events: any[] | nil) The function used to set up the trigger model
151151
---@field trigger_model_initiate fun(self: Device) The function used to initiate the trigger model
152152

153153
UTILITY = {
@@ -268,7 +268,7 @@
268268

269269
---Functions for the MSMU60-2 module for MP5000-series mainframes
270270
---@return Model
271-
MSMU60_2 = function()
271+
MSMU = function()
272272
return {
273273
common = {
274274
--- Resets this MSMU60-2
@@ -282,13 +282,10 @@
282282
self.node.trigger.timer[2].reset()
283283
self.node.trigger.timer[3].reset()
284284
self.node.trigger.timer[4].reset()
285-
--for _, v in ipairs(self.slot.trigger.model.table()) do
286285
self.slot.trigger.model.abort()
287286
self.slot.trigger.model.delete(self.node_name .. " Bias Trigger Model")
288287
self.slot.trigger.model.delete(self.node_name .. " Step Trigger Model")
289288
self.slot.trigger.model.delete(self.node_name .. " Sweep Trigger Model")
290-
-- self.slot.trigger.model.delete(v)
291-
--end
292289
end,
293290
--- Configures this MSMU60-2
294291
---@param self Device
@@ -524,13 +521,13 @@
524521
end
525522

526523
-- Loop back to `bias_wait_sweep_block` until all iterations are complete
527-
if sweep_measure_event ~= nil then
524+
if step_measure_event ~= nil then
528525
tm_add.branch.counter(self.trigger_model, block.loop,
529-
block.wait_sweep,
526+
block.bias_notify,
530527
UTILITY.TOTAL_COUNT)
531-
elseif step_measure_event ~= nil then
528+
elseif sweep_measure_event ~= nil then
532529
tm_add.branch.counter(self.trigger_model, block.loop,
533-
block.bias_notify,
530+
block.wait_sweep,
534531
UTILITY.TOTAL_COUNT)
535532
end
536533
end,
@@ -580,7 +577,6 @@
580577

581578
if step_source_complete_events ~= nil and table.getn(step_source_complete_events) > 0 then
582579
-- Add an optional wait for other sweep events only on the first stepper
583-
--logevent(self, "WAIT ALL STEPS")
584580
UTILITY.make_waitall(self.slot.trigger.model, self.trigger_model,
585581
block.waitall_steps,
586582
step_source_complete_events)
@@ -739,12 +735,12 @@
739735
}
740736
end,
741737

742-
---Functions for the MPSU-2ST module for MP5000-series mainframes
738+
---Functions for MPSU modules for MP5000-series mainframes
743739
---@return Model
744-
MPSU50_2ST = function()
740+
MPSU = function()
745741
return {
746742
common = {
747-
--- Resets this MPSU50_2ST
743+
--- Resets this MPSU
748744
---@param self Device
749745
reset = function(self)
750746
self.channel.reset()
@@ -755,35 +751,32 @@
755751
self.node.trigger.timer[2].reset()
756752
self.node.trigger.timer[3].reset()
757753
self.node.trigger.timer[4].reset()
758-
--for _, v in ipairs(self.slot.trigger.model.table()) do
759754
self.slot.trigger.model.abort()
760-
-- self.slot.trigger.model.delete(v)
761-
--end
762755
end,
763-
--- Configures this MPSU50_2ST
756+
--- Configures this MPSU
764757
---@param self Device
765758
config = function(self)
766759
UTILITY.init_slot_event_ids(self.slot, { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 })
767-
768760

769-
local event_id = UTILITY.get_slot_event_id(self.slot)
770-
if event_id then
771-
self.event_source = event_id
761+
local event_source_id = UTILITY.get_slot_event_id(self.slot)
762+
if event_source_id then
763+
self.event_source = event_source_id
772764
else
773-
error("Unable to assign event ID to channel: all event IDs for slot[" ..
765+
error("Unable to assign event source ID to channel: all event IDs for slot[" ..
774766
self.slot_idx .. "] have been consumed.")
775767
exit()
776768
end
777769

778-
event_id = UTILITY.get_slot_event_id(self.slot)
779-
if event_id then
780-
self.event_measure = event_id
770+
local event_measure_id = UTILITY.get_slot_event_id(self.slot)
771+
if event_measure_id then
772+
self.event_measure = event_measure_id
781773
else
782-
error("Unable to assign event ID to channel: all event IDs for slot[" ..
774+
error("Unable to assign event measure ID to channel: all event IDs for slot[" ..
783775
self.slot_idx .. "] have been consumed.")
784776
exit()
785777
end
786778

779+
787780
-- Source Settings --
788781
-- func, level/list/log/linear
789782
if self.source.values.scalar ~= nil then
@@ -865,32 +858,59 @@
865858
bias = {
866859
--- Configure the trigger model for a Bias
867860
---@param self Device
868-
---@param bias_event nil Unused
869-
---@param step_event any | nil The event ID associated with all the steps completing (only one)
870-
---@param sweep_event any | nil The event ID associated with all the sweep steps completing (only one)
871-
---@param bias_complete_events any[] | nil The event ID(s) associated with all other bias steps completing. Should only be passed to one bias channel.
872-
trigger_model_setup = function(self, bias_event, step_event, sweep_event, bias_complete_events)
861+
---@param bias_source_event nil Unused
862+
---@param bias_measure_event nil Unused
863+
---@param step_source_event any | nil The event ID associated with all the steps completing source actions (only one)
864+
---@param step_measure_event any | nil The event ID associated with all the steps completing measure actions (only one)
865+
---@param sweep_source_event any | nil The event ID associated with all the sweep steps completing source actions (only one)
866+
---@param sweep_measure_event any | nil The event ID associated with all the sweep steps completing measure actions (only one)
867+
---@param bias_source_complete_events any[] | nil The event ID(s) associated with all other bias source-action steps completing. Should only be passed to one bias channel.
868+
---@param bias_measure_complete_events any[] | nil The event ID(s) associated with all other bias measure-action steps completing. Should only be passed to one bias channel.
869+
trigger_model_setup = function(self, bias_source_event, bias_measure_event, step_source_event,
870+
step_measure_event, sweep_source_event, sweep_measure_event,
871+
bias_source_complete_events, bias_measure_complete_events)
872+
UTILITY.MSMU().bias.trigger_model_setup(self, bias_source_event, bias_measure_event,
873+
step_source_event, step_measure_event, sweep_source_event, sweep_measure_event,
874+
bias_source_complete_events, bias_measure_complete_events)
873875
end,
874876
},
875877
step = {
876878
--- Configure the trigger model for a Step
877879
---@param self Device
878-
---@param bias_event any The event that indicates the biases are fully started.
879-
---@param step_event nil Unused
880-
---@param sweep_event any The event that indicates the sweepsare fully started.
881-
---@param step_complete_events any[] | nil The event ID(s) associated with all other steps completing. Should only be passed to one bias channel.
882-
trigger_model_setup = function(self, bias_event, step_event, sweep_event, step_complete_events)
880+
---@param bias_source_event any|nil The event ID associated with all the biases completing source actions (only one)
881+
---@param bias_measure_event any | nil The event ID associated with all the biases completing measure actions (only one)
882+
---@param step_source_event nil Unused
883+
---@param step_measure_event nil Unused
884+
---@param sweep_source_event any | nil The event ID associated with all the sweep steps completing source actions (only one)
885+
---@param sweep_measure_event any | nil The event ID associated with all the sweep steps completing measure actions (only one)
886+
---@param step_source_complete_events any[] | nil The event ID(s) associated with all other source-action steps completing. Should only be passed to one bias channel.
887+
---@param step_measure_complete_events any[] | nil The event ID(s) associated with all other measure-action steps completing. Should only be passed to one bias channel.
888+
trigger_model_setup = function(self, bias_source_event, bias_measure_event, step_source_event,
889+
step_measure_event, sweep_source_event, sweep_measure_event,
890+
step_source_complete_events, step_measure_complete_events)
891+
UTILITY.MSMU().step.trigger_model_setup(self, bias_source_event, bias_measure_event,
892+
step_source_event, step_measure_event, sweep_source_event, sweep_measure_event,
893+
step_source_complete_events, step_measure_complete_events)
883894
end,
884895
},
885896

886897
sweep = {
887898
--- Configure the trigger model for a Step
888899
---@param self Device
889-
---@param bias_event any
890-
---@param step_event any
891-
---@param sweep_event nil Unused
892-
---@param sweep_complete_events any
893-
trigger_model_setup = function(self, bias_event, step_event, sweep_event, sweep_complete_events)
900+
---@param bias_source_event any|nil The event ID associated with all the biases completing source actions (only one)
901+
---@param bias_measure_event any | nil The event ID associated with all the biases completing measure actions (only one)
902+
---@param step_source_event any | nil The event ID associated with all the steps completing source actions (only one)
903+
---@param step_measure_event any | nil The event ID associated with all the steps completing measure actions (only one)
904+
---@param sweep_source_event nil Unused
905+
---@param sweep_measure_event nil Unused
906+
---@param sweep_source_complete_events any
907+
---@param sweep_measure_complete_events any
908+
trigger_model_setup = function(self, bias_source_event, bias_measure_event, step_source_event,
909+
step_measure_event, sweep_source_event, sweep_measure_event,
910+
sweep_source_complete_events, sweep_measure_complete_events)
911+
UTILITY.MSMU().sweep.trigger_model_setup(self, bias_source_event, bias_measure_event,
912+
step_source_event, step_measure_event, sweep_source_event, sweep_measure_event,
913+
sweep_source_complete_events, sweep_measure_complete_events)
894914
end,
895915

896916
},
@@ -901,12 +921,11 @@
901921
---@param device DeviceDetails
902922
---@return Model | nil, "smu" | "psu" | nil
903923
get_model_from_device = function(device)
904-
-- XXX: DEBUG ONLY, REMOVE MSMU200-2
905-
if device.model == "MSMU60-2" then
906-
return UTILITY.MSMU60_2(), "smu"
924+
if string.find(device.model, "MSMU") ~= nil then
925+
return UTILITY.MSMU(), "smu"
907926
end
908-
if device.model == "MPSU50-2ST" then
909-
return UTILITY.MPSU50_2ST(), "psu"
927+
if string.find(device.model, "MPSU") ~= nil then
928+
return UTILITY.MPSU(), "psu"
910929
end
911930
return nil, nil
912931
end,
@@ -1279,13 +1298,13 @@
12791298

12801299
for i, n in ipairs(nodes.biases) do
12811300
for _, buf in ipairs(n.measure.buffers) do
1282-
table.insert(buffers, { heading = "Bias[" .. i .. "]." .. iv_to_string(buf.type), buffer = buf.buffer })
1301+
table.insert(buffers, { heading = "bias[" .. i .. "]." .. iv_to_string(buf.type), buffer = buf.buffer })
12831302
end
12841303
end
12851304

12861305
for i, n in ipairs(nodes.steps) do
12871306
for _, buf in ipairs(n.measure.buffers) do
1288-
table.insert(buffers, { heading = "Step[" .. i .. "]." .. iv_to_string(buf.type), buffer = buf.buffer })
1307+
table.insert(buffers, { heading = "step[" .. i .. "]." .. iv_to_string(buf.type), buffer = buf.buffer })
12891308
end
12901309
end
12911310

@@ -1298,6 +1317,7 @@
12981317
print_table_from_buffers(buffers)
12991318
end
13001319

1320+
13011321
--#endregion Util
13021322

13031323
--==========================================================================
@@ -1530,7 +1550,7 @@
15301550
<substitute name="SWEEP-DEVICE:SRANGE">%SRANGE%</substitute>
15311551
<substitute name="SWEEP-DEVICE:START">%START%</substitute>
15321552
<substitute name="SWEEP-DEVICE:STOP">%STOP%</substitute>
1533-
<substitute name="SWEEP-DEVICE:LIST">%LIST%</substitute>
1553+
<substitute name="SWEEP-DEVICE:LIST">%LIST%</substitute>
15341554
<substitute name="SWEEP-DEVICE:MRANGE">%MRANGE%</substitute>
15351555
<substitute name="SWEEP-DEVICE:MFUNCTION">%MFUNCTION%</substitute>
15361556
<substitute name="SWEEP-DEVICE:SENSE">%SENSE%</substitute>

0 commit comments

Comments
 (0)