コード例 #1
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_send_command(self, command):
     if isinstance(command, str):
         command = CecCommand(command)
     _LOGGER.debug("<< %s", command)
     if command.src is None or command.src == 0xf:
         command.src = self._adapter.get_logical_address()
     self._loop.call_soon_threadsafe(self._adapter.transmit, command)
コード例 #2
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_run(self):
     _LOGGER.debug("Starting device %d", self.logical_address)
     while not self._stop:
         for prop in UPDATEABLE:
             if not self._stop:
                 yield from self.async_request_update(prop[0])
         start_time = self._loop.time()
         while not self._stop and self._loop.time() <= (
                 start_time + self._update_period):
             yield from asyncio.sleep(.3, loop=self._loop)
     _LOGGER.info("HDMI device %s stopped.", self)  # pragma: no cover
コード例 #3
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_init(self):
     _LOGGER.debug("initializing")  # pragma: no cover
     _LOGGER.debug("setting callback")  # pragma: no cover
     self._adapter.set_command_callback(self.command_callback)
     _LOGGER.debug("Callback set")  # pragma: no cover
     task = self._adapter.init(self._initialized_callback)
     self._running = True
     while not (task.done() or task.cancelled()) and self._running:
         _LOGGER.debug("Init pending - %s", task)  # pragma: no cover
         yield from asyncio.sleep(1, loop=self._loop)
     _LOGGER.debug("Init done")  # pragma: no cover
コード例 #4
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def stop(self):
     _LOGGER.debug("HDMI network shutdown.")  # pragma: no cover
     self._running = False
     for d in self._devices.values():
         d.stop()
     if self._managed_loop:
         self._loop.stop()
         while self._loop.is_running():
             time.sleep(.1)
         self._loop.close()
     self._adapter.shutdown()
     _LOGGER.info("HDMI network stopped.")  # pragma: no cover
コード例 #5
0
ファイル: network.py プロジェクト: happyleavesaoc/pyCEC
 def _after_polled(self, device, task):
     self._device_status[device] = task.result()
     if self._device_status[device] and device not in self._devices:
         self._devices[device] = HDMIDevice(device, self, loop=self._loop)
         if self._device_added_callback:
             self._loop.call_soon_threadsafe(self._device_added_callback,
                                             self._devices[device])
         self._loop.create_task(self._devices[device].async_run())
         _LOGGER.debug("Found device %d", device)
     elif not self._device_status[device] and device in self._devices:
         self.get_device(device).stop()
         if self._device_removed_callback:
             self._loop.call_soon_threadsafe(self._device_removed_callback,
                                             self._devices[device])
         del (self._devices[device])
コード例 #6
0
ファイル: network.py プロジェクト: rajlaud/pyCEC
 async def async_run(self):
     _LOGGER.debug("Starting device %d", self.logical_address)
     while not self._stop:
         for prop in UPDATEABLE:
             if not self._stop and (prop != CMD_PHYSICAL_ADDRESS
                                    or self._physical_address is None):
                 # Skip update of physical address unless unset to prevent
                 # unwanted activity on Panasonic television display.
                 _LOGGER.debug("Updating property: %s", UPDATEABLE[prop])
                 await self.async_request_update(prop[0])
         start_time = self._loop.time()
         while not self._stop and self._loop.time() <= (
                 start_time + self._update_period):
             await asyncio.sleep(0.3, loop=self._loop)
     _LOGGER.info("HDMI device %s stopped.", self)  # pragma: no cover
コード例 #7
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_watch(self, loop=None):
     _LOGGER.debug("Start watching...")  # pragma: no cover
     if loop is None:
         loop = self._loop
     _LOGGER.debug("loop: %s", loop)
     while self._running:
         if self.initialized:
             _LOGGER.debug("Scanning...")  # pragma: no cover
             yield from self.async_scan()
             _LOGGER.debug("Sleep...")  # pragma: no cover
             start_time = self._loop.time()
             while self._loop.time() <= (
                     start_time + self._scan_interval) and self._running:
                 yield from asyncio.sleep(.3, loop=loop)
         else:
             _LOGGER.warning("Not initialized. Waiting for init.")
             yield from asyncio.sleep(1, loop=loop)
     _LOGGER.info("No watching anymore")
コード例 #8
0
ファイル: network.py プロジェクト: happyleavesaoc/pyCEC
 def stop(self):
     _LOGGER.debug("HDMI network shutdown.")  # pragma: no cover
     self._running = False
     for d in self.devices:
         d.stop()
     self._adapter.shutdown()
     if self._managed_loop:
         _LOGGER.debug("Stopping HDMI loop.")  # pragma: no cover
         self._loop.stop()
         _LOGGER.debug("Cleanup loop")  # pragma: no cover
         asyncio.sleep(3, loop=self._loop)
         self._loop.close()
     _LOGGER.info("HDMI network stopped.")  # pragma: no cover
コード例 #9
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def command_callback(self, raw_command):
     _LOGGER.debug("%s", raw_command)  # pragma: no cover
     self._loop.call_soon_threadsafe(self._async_callback, raw_command)
コード例 #10
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_power_on(self):
     _LOGGER.debug("Queuing power on")  # pragma: no cover
     self._loop.call_soon_threadsafe(self._adapter.power_on_devices)
コード例 #11
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def async_standby(self):
     _LOGGER.debug("Queuing system standby")  # pragma: no cover
     self._loop.call_soon_threadsafe(self._adapter.standby_devices)
コード例 #12
0
ファイル: network.py プロジェクト: ObsidianX/pyCEC
 def stop(self):  # pragma: no cover
     _LOGGER.debug("HDMI device %s stopping", self)
     self._stop = True
コード例 #13
0
ファイル: __main__.py プロジェクト: konikvranik/kodi_repo
async def async_show_devices(network, loop):
    while True:
        for d in network.devices:
            _LOGGER.debug("Present device %s", d)
        await asyncio.sleep(10, loop=loop)