VNA.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # NanoVNASaver
  2. #
  3. # A python program to view and export Touchstone data from a NanoVNA
  4. # Copyright (C) 2019, 2020 Rune B. Broberg
  5. # Copyright (C) 2020 NanoVNA-Saver Authors
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. import logging
  20. from collections import OrderedDict
  21. from time import sleep
  22. from typing import List, Iterator
  23. from Serial import Interface, drain_serial
  24. logger = logging.getLogger(__name__)
  25. class VNA:
  26. name = "VNA"
  27. wait = 0.05
  28. def __init__(self, iface: Interface):
  29. self.iface = iface
  30. self.valid_freq = None
  31. self.valid_power = None
  32. self.valid_bw = None
  33. self.valid_points = None
  34. self.freq_start = None
  35. self.power = None
  36. self.points = None
  37. self.bw = None
  38. def connect(self) -> bool:
  39. self.iface.open()
  40. return self.iface.isOpen()
  41. def disconnect(self) -> bool:
  42. self.iface.close()
  43. return not self.iface.isOpen()
  44. def reconnect(self) -> bool:
  45. self.iface.close()
  46. sleep(self.wait)
  47. self.iface.open()
  48. return self.iface.isOpen()
  49. def set_bw(self):
  50. pass
  51. def set_sweep(self, freq_start: float, freq_end: float, points: int):
  52. pass
  53. def get_bw(self) -> float:
  54. pass
  55. def get_sweep(self) -> List:
  56. pass
  57. def get_info(self) -> Dict:
  58. pass
  59. def run(self) -> List:
  60. pass
  61. def set_power(self, power: float):
  62. pass
  63. def get_power(self) -> float:
  64. pass
  65. def set_cal(self):
  66. pass
  67. def get_cal(self):
  68. pass