Skip to content

Commit f4ffe4e

Browse files
committed
Add single-array CLI arg for easy use of combined array demos
1 parent 94933b3 commit f4ffe4e

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

‎demos/common/espargos_application.py‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,36 @@ def __init__(
8282
format_group.add_argument(
8383
"--lltf",
8484
default=False,
85-
help="Use only CSI from L-LTF",
85+
help="Use only CSI from L-LTF (set up backlog and application accordingly)",
8686
action="store_true",
8787
)
8888
format_group.add_argument(
8989
"--ht40",
9090
default=False,
91-
help="Use only CSI from HT40",
91+
help="Use only CSI from HT40 (set up backlog and application accordingly)",
9292
action="store_true",
9393
)
9494
format_group.add_argument(
9595
"--ht20",
9696
default=False,
97-
help="Use only CSI from HT20",
97+
help="Use only CSI from HT20 (set up backlog and application accordingly)",
9898
action="store_true",
9999
)
100100

101-
if not ESPARGOSApplicationFlags.COMBINED_ARRAY in self.flags:
101+
if ESPARGOSApplicationFlags.COMBINED_ARRAY in self.flags:
102+
parser.add_argument(
103+
"-s",
104+
"--single-array",
105+
type=str,
106+
default="",
107+
help="Array consists of a single ESPARGOS device in horizontal orientation, specify host address (IP or hostname) of device",
108+
)
109+
else:
102110
parser.add_argument(
103111
"hosts",
104112
type=str,
105113
default="",
106-
help="Comma-separated list of host addresses (IP or hostname) of ESPARGOS controllers",
114+
help="Comma-separated list of host addresses (IP or hostname) of ESPARGOS devices",
107115
)
108116

109117
self.args = parser.parse_args()
@@ -150,6 +158,26 @@ def __init__(
150158
"ht40": self.args.ht40,
151159
}
152160

161+
# In single-array mode, auto-generate combined array config
162+
if "single_array" in self.args and len(self.args.single_array) > 0:
163+
host = self.args.single_array
164+
165+
self.initial_config["combined-array"] = {
166+
"boards": {
167+
"arr": {
168+
"host": host,
169+
"cable": {
170+
"length": 0.0,
171+
"velocity_factor": 1.0,
172+
},
173+
}
174+
},
175+
"array": [
176+
["arr.0.0", "arr.0.1", "arr.0.2", "arr.0.3"],
177+
["arr.1.0", "arr.1.1", "arr.1.2", "arr.1.3"],
178+
],
179+
}
180+
153181
# If hosts are provided on command line, override pool config
154182
if "hosts" in self.args and len(self.args.hosts) > 0:
155183
hosts = self.args.hosts.split(",")
@@ -214,14 +242,20 @@ def initialize_pool(
214242
Initialize ESPARGOS Pool. Also triggers creation of pool drawer backend.
215243
"""
216244
if ESPARGOSApplicationFlags.COMBINED_ARRAY in self.flags:
245+
combined_array_cfg = self.get_initial_config("combined-array")
246+
247+
# Check if combined_array_cfg was provided (not just empty dictionary)
248+
if combined_array_cfg is None or combined_array_cfg == {}:
249+
raise ValueError("Combined array configuration is required for applications using COMBINED_ARRAY mode. You must either provide it via config file or use the --single-array option.")
250+
217251
(
218252
self.indexing_matrix,
219253
hosts,
220254
cable_lengths,
221255
cable_velocity_factors,
222256
self.n_rows,
223257
self.n_cols,
224-
) = espargos.util.parse_combined_array_config(self.get_initial_config("combined-array"))
258+
) = espargos.util.parse_combined_array_config(combined_array_cfg)
225259

226260
additional_calibrate_args["cable_lengths"] = cable_lengths
227261
additional_calibrate_args["cable_velocity_factors"] = cable_velocity_factors

0 commit comments

Comments
 (0)