basic config file stuff
This commit is contained in:
parent
26682f1741
commit
9a922762fa
16
charon_vna/config_default.json
Normal file
16
charon_vna/config_default.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"frequency": [
|
||||
1000000000.0,
|
||||
1100000000.0,
|
||||
1200000000.0,
|
||||
1300000000.0,
|
||||
1400000000.0,
|
||||
1500000000.0,
|
||||
1600000000.0,
|
||||
1700000000.0,
|
||||
1800000000.0,
|
||||
1900000000.0,
|
||||
2000000000.0
|
||||
],
|
||||
"power": -5
|
||||
}
|
25
charon_vna/config_default.py
Normal file
25
charon_vna/config_default.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import json
|
||||
import subprocess
|
||||
|
||||
import numpy as np
|
||||
|
||||
from charon_vna.gui import DEFAULT_CONFIG
|
||||
|
||||
config = dict(
|
||||
frequency=np.linspace(1e9, 2e9, 11).tolist(),
|
||||
power=-5,
|
||||
)
|
||||
|
||||
with open(DEFAULT_CONFIG, "w") as f:
|
||||
json.dump(config, f)
|
||||
|
||||
# autoformat
|
||||
subprocess.run(
|
||||
[
|
||||
"python",
|
||||
"-m",
|
||||
"json.tool",
|
||||
DEFAULT_CONFIG.resolve().as_posix(),
|
||||
DEFAULT_CONFIG.resolve().as_posix(),
|
||||
]
|
||||
)
|
|
@ -1,4 +1,5 @@
|
|||
# %% imports
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Callable, List, Literal, Tuple
|
||||
|
@ -28,11 +29,7 @@ from vna import Charon
|
|||
from charon_vna.util import db20, s2vswr
|
||||
|
||||
# %%
|
||||
DEFAULT_CONFIG = dict(
|
||||
frequency=np.arange(1e9, 2e9, 11), # Hz
|
||||
power=-5, # dB
|
||||
)
|
||||
|
||||
DEFAULT_CONFIG = Path(__file__).parent / "config_default.json"
|
||||
CONFIG_SUFFIX = ".json"
|
||||
|
||||
|
||||
|
@ -148,7 +145,6 @@ class PlotWidget(QWidget):
|
|||
self.fig.canvas.draw()
|
||||
|
||||
|
||||
# Subclass QMainWindow to customize your application's main window
|
||||
class MainWindow(QMainWindow):
|
||||
config_path: Path | None
|
||||
# device: Charon
|
||||
|
@ -159,9 +155,11 @@ class MainWindow(QMainWindow):
|
|||
super().__init__()
|
||||
|
||||
self.config_path = None
|
||||
self._frequency = np.linspace(1e9, 2e9, 101) # TODO: read frequency from config
|
||||
with open(DEFAULT_CONFIG, "r") as f:
|
||||
config = json.load(f)
|
||||
self._frequency = config["frequency"]
|
||||
|
||||
self.vna = Charon("ip:192.168.3.1", frequency=DEFAULT_CONFIG["frequency"])
|
||||
self.vna = Charon("ip:192.168.3.1", frequency=self._frequency)
|
||||
|
||||
mpl.use("QtAgg")
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class Charon:
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
uri: str = "192.168.2.1",
|
||||
uri: str = "ip:192.168.2.1",
|
||||
frequency: npt.ArrayLike = np.linspace(1e9, 2e9, 3),
|
||||
ports: Tuple[int] = (1,),
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue
Block a user