Skip to content

Commit 2e875b8

Browse files
authored
Merge pull request #220 from sandialabs/save_metadata_GPIBInstrument
fix json encoder bug for GPIBInstrument objects
2 parents c28a39e + eee3d39 commit 2e875b8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pyscan/general/pyscan_json_encoder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
import numpy as np
33
from pyscan.general.item_attribute import ItemAttribute
44
from pyscan.drivers.instrument_driver import InstrumentDriver
5+
from pyvisa.resources import (
6+
# FirewireInstrument,
7+
GPIBInstrument,
8+
# PXIInstrument,
9+
SerialInstrument,
10+
TCPIPInstrument,
11+
USBInstrument,
12+
# VXIInstrument,
13+
)
514
import inspect
615
from pathlib import Path, WindowsPath
716

@@ -70,5 +79,20 @@ def default(self, obj, debug=False):
7079
return str(obj)
7180
elif type(obj) is type(iter(range(1))):
7281
return list(obj)
82+
elif isinstance(
83+
obj,
84+
(
85+
# FirewireInstrument,
86+
GPIBInstrument,
87+
# PXIInstrument,
88+
SerialInstrument,
89+
TCPIPInstrument,
90+
USBInstrument,
91+
# VXIInstrument,
92+
),
93+
):
94+
if debug is True:
95+
print(f"obj {obj} is a pyvisa instrument, returning resource name.")
96+
return obj.resource_name
7397
else:
7498
return super().default(obj)

0 commit comments

Comments
 (0)