Skip to content

Commit

Permalink
Merge pull request #220 from sandialabs/save_metadata_GPIBInstrument
Browse files Browse the repository at this point in the history
fix json encoder bug for GPIBInstrument objects
  • Loading branch information
rsbrost authored Aug 28, 2024
2 parents c28a39e + eee3d39 commit 2e875b8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pyscan/general/pyscan_json_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
import numpy as np
from pyscan.general.item_attribute import ItemAttribute
from pyscan.drivers.instrument_driver import InstrumentDriver
from pyvisa.resources import (
# FirewireInstrument,
GPIBInstrument,
# PXIInstrument,
SerialInstrument,
TCPIPInstrument,
USBInstrument,
# VXIInstrument,
)
import inspect
from pathlib import Path, WindowsPath

Expand Down Expand Up @@ -70,5 +79,20 @@ def default(self, obj, debug=False):
return str(obj)
elif type(obj) is type(iter(range(1))):
return list(obj)
elif isinstance(
obj,
(
# FirewireInstrument,
GPIBInstrument,
# PXIInstrument,
SerialInstrument,
TCPIPInstrument,
USBInstrument,
# VXIInstrument,
),
):
if debug is True:
print(f"obj {obj} is a pyvisa instrument, returning resource name.")
return obj.resource_name
else:
return super().default(obj)

0 comments on commit 2e875b8

Please sign in to comment.