check_np0x_hw_status
drunc.apps.check_np0x_hw_status
Script to check the power status (on/off) of the NP0x readout hardware.
For WIBs, each device gets pinged. If reachable, attempt to query its FEMB power status.
Including the AMCs is planned for the future.
Functions:
check_hardware(ip)
Checks the hardware status of a given IP address by first pinging it to determine if it is online, and if it is online, attempting to query its FEMB power status using the WIB library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ip
|
str
|
The IP address of the hardware to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing the online status and FEMB power status of the |
dict
|
hardware, with the following structure: { "online": bool, # True if the device is reachable, False otherwise "fembs": list[bool] # A list of 4 booleans indicating the power status of each FEMB (True for powered, False for not powered) } |
Raises:
| Type | Description |
|---|---|
None
|
All exceptions are caught and handled within the function, with the final status defaulting to "offline" and all FEMBs as "not powered" in case of any errors (e.g. timeouts, subprocess errors, gRPC errors, etc.). |
Source code in drunc/apps/check_np0x_hw_status.py
generate_display(results_map)
Generates the overall display grid for the current results.
This function creates a grid layout using the Rich library, where each apparatus group (e.g. "NP02 CB", "NP02", "NP04 CB", "NP04") is displayed in its own section. For each group, it iterates through the subcategories and creates a table for each using the make_wib_table function. The resulting tables are arranged in columns within the grid. The display is designed to be updated live as results come in, showing the current status of each WIB and its FEMBs based on the results_map provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_map
|
dict
|
A mapping of IP addresses to their hardware status results, where each result is a dictionary containing 'online' status and 'fembs' status. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Table |
Table
|
A Rich Table object representing the current status display for all hardware. |
Source code in drunc/apps/check_np0x_hw_status.py
main()
Prints the power status of the hardware defined in WIB_DATA.
For each WIB, the script first checks if it's online via ping, then if it is online, the FEMB power status is queried using the WIB library. Results are displayed in a live-updating table format.
Source code in drunc/apps/check_np0x_hw_status.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
make_wib_table(category, wibs, results_map)
Creates a Rich Table for a given category of WIBs, showing their online status and FEMB power status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
The name of the category (e.g. "NP02 CB", "CRP4", etc.) to be displayed as the table title. |
required |
wibs
|
dict
|
A mapping of WIB numbers to their corresponding IP addresses for this category. |
required |
results_map
|
dict
|
A mapping of IP addresses to their hardware status results, where each result is a dictionary containing 'online' status and 'fembs' status. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Table |
Table
|
A Rich Table object representing the status of the WIBs in this category, with the WIB number, online status, and FEMB power status displayed in a visually intuitive format (e.g. green checkmarks for online/powered, red Xs for offline/unpowered, and dimmed dots for unknown status). |
Source code in drunc/apps/check_np0x_hw_status.py
setup_wib_path()
Sets up the path to the local copy of the dune-wib-firmware repository if it exists.
Searches for the dune-wib-firmware source directory in the work area root and in sourcecode. If the directory is found, it is added to sys.path for dynamic imports. Returns the path if found, else None.
Returns:
| Type | Description |
|---|---|
|
str or None: The path to the dune-wib-firmware/sw directory if found, else None. |