program_core.py 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. from typing import Optional
  2. from program_public_tools import ProgramPublicTools
  3. from instrument_controller import InstrumentController
  4. from serial_device_controller import SerialDeviceController
  5. from powerline_adapter import PowerlineAdapter
  6. from local_file_service import LocalFileService
  7. class ProgramCore(object):
  8. def __init__(self, pubtools: Optional[ProgramPublicTools]):
  9. if pubtools is None:
  10. pubtools = ProgramPublicTools()
  11. self.pubtools: ProgramPublicTools = pubtools
  12. self.serial_controller: SerialDeviceController = SerialDeviceController(self.pubtools)
  13. self.powerline_adapter: PowerlineAdapter = PowerlineAdapter(self.pubtools)
  14. self.local_file_service: LocalFileService = LocalFileService()
  15. self.start_core()
  16. self.instrument_controller: InstrumentController = InstrumentController(self.pubtools)
  17. self.instrument_controller.auto_connect()
  18. if self.instrument_controller.services.digital_oscilloscope is not None:
  19. self.instrument_controller.services.digital_oscilloscope.keep_listening()
  20. if self.instrument_controller.services.digital_multimeter is not None:
  21. self.instrument_controller.services.digital_multimeter.keep_listening()
  22. def start_core(self):
  23. self.local_file_service.start()
  24. self.auto_connect()
  25. def auto_connect(self):
  26. self.serial_controller.auto_connect()
  27. self.powerline_adapter.init()
  28. self.local_file_service.start()