From f94695929688099dd642a975cdbb0185f2139499 Mon Sep 17 00:00:00 2001 From: Daniel Cogswell Date: Mon, 16 Dec 2024 19:51:03 -0500 Subject: [PATCH] This commit is for debugging purposes only. It tells you where to look in BTSDA to get the correct range multiplier when a missing range is encountered. It finds the first instance of the missing range with a non-zero current and prints an error message. --- NewareNDA/NewareNDA.py | 8 +++++++- NewareNDA/NewareNDAx.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NewareNDA/NewareNDA.py b/NewareNDA/NewareNDA.py index fd44238..9b8172e 100644 --- a/NewareNDA/NewareNDA.py +++ b/NewareNDA/NewareNDA.py @@ -256,7 +256,13 @@ def _bytes_to_list(bytes): if Index == 0 or Status == 0: return [] - multiplier = multiplier_dict[Range] + try: + multiplier = multiplier_dict[Range] + except KeyError: + multiplier = float('nan') + if Current != 0: + raise KeyError(f"Missing range multiplier {Range}. Using BTSDA, get the current at index {Index} and divide by {Current}.") + pass # Create a dictionary for the record list = [ diff --git a/NewareNDA/NewareNDAx.py b/NewareNDA/NewareNDAx.py index 44f043b..4ead38b 100644 --- a/NewareNDA/NewareNDAx.py +++ b/NewareNDA/NewareNDAx.py @@ -497,7 +497,13 @@ def _bytes_to_list_ndc(bytes): [Y, M, D, h, m, s] = struct.unpack('