更新UCD-API库及文档
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from UniTAP.libs.lib_tsi.tsi_io import PortIO
|
||||
from UniTAP.libs.lib_tsi.tsi import *
|
||||
import UniTAP.libs.lib_tsi.tsi_types as ci
|
||||
from .cec_types import *
|
||||
from .cec_private_types import *
|
||||
from typing import Union
|
||||
@@ -29,7 +29,7 @@ class CecRx:
|
||||
Args:
|
||||
state (`bool`)
|
||||
"""
|
||||
self.__io.set(TSI_HDRX_CEC_CONTROL, state, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_CONTROL, state, c_uint32)
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
"""
|
||||
@@ -38,7 +38,7 @@ class CecRx:
|
||||
Returns:
|
||||
object of `bool` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDRX_CEC_CONTROL, c_uint32)[1] & 0x1 == 1
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_CONTROL, c_uint32)[1] & 0x1 == 1
|
||||
|
||||
@property
|
||||
def logical_address(self) -> LogicalAddressEnum:
|
||||
@@ -48,11 +48,11 @@ class CecRx:
|
||||
Returns:
|
||||
object of `LogicalAddressEnum` type
|
||||
"""
|
||||
return LogicalAddressEnum(self.__io.get(TSI_HDRX_CEC_LOGICAL_ADDRESS, c_uint32)[1])
|
||||
return LogicalAddressEnum(self.__io.get(ci.TSI_HDRX_CEC_LOGICAL_ADDRESS, c_uint32)[1])
|
||||
|
||||
@logical_address.setter
|
||||
def logical_address(self, address: LogicalAddressEnum):
|
||||
self.__io.set(TSI_HDRX_CEC_LOGICAL_ADDRESS, address.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_LOGICAL_ADDRESS, address.value, c_uint32)
|
||||
|
||||
@property
|
||||
def destination(self) -> LogicalAddressEnum:
|
||||
@@ -62,11 +62,11 @@ class CecRx:
|
||||
Returns:
|
||||
object of `LogicalAddressEnum` type
|
||||
"""
|
||||
return LogicalAddressEnum(self.__io.get(TSI_HDRX_CEC_DESTINATION, c_uint32)[1])
|
||||
return LogicalAddressEnum(self.__io.get(ci.TSI_HDRX_CEC_DESTINATION, c_uint32)[1])
|
||||
|
||||
@destination.setter
|
||||
def destination(self, address: LogicalAddressEnum):
|
||||
self.__io.set(TSI_HDRX_CEC_DESTINATION, address.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_DESTINATION, address.value, c_uint32)
|
||||
|
||||
@property
|
||||
def phy_address(self) -> int:
|
||||
@@ -76,11 +76,11 @@ class CecRx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDRX_CEC_PHYSICAL_ADDRESS, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_PHYSICAL_ADDRESS, c_uint32)[1]
|
||||
|
||||
@phy_address.setter
|
||||
def phy_address(self, address: int):
|
||||
self.__io.set(TSI_HDRX_CEC_PHYSICAL_ADDRESS, address, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_PHYSICAL_ADDRESS, address, c_uint32)
|
||||
|
||||
@property
|
||||
def op_code(self) -> int:
|
||||
@@ -90,11 +90,11 @@ class CecRx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDRX_CEC_OP_CODE, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_OP_CODE, c_uint32)[1]
|
||||
|
||||
@op_code.setter
|
||||
def op_code(self, code: int):
|
||||
self.__io.set(TSI_HDRX_CEC_OP_CODE, code, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_OP_CODE, code, c_uint32)
|
||||
|
||||
@property
|
||||
def op_code_param(self) -> Union[int, list]:
|
||||
@@ -104,12 +104,12 @@ class CecRx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDRX_CEC_OP_CODE_PARAM, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_OP_CODE_PARAM, c_uint32)[1]
|
||||
|
||||
@op_code_param.setter
|
||||
def op_code_param(self, code_param: Union[int, list]):
|
||||
data_count = len(code_param) if isinstance(code_param, list) else 1
|
||||
self.__io.set(TSI_HDRX_CEC_OP_CODE_PARAM, code_param, c_uint32, data_count=data_count)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_OP_CODE_PARAM, code_param, c_uint32, data_count=data_count)
|
||||
|
||||
@property
|
||||
def device_type(self) -> DeviceType:
|
||||
@@ -119,7 +119,7 @@ class CecRx:
|
||||
Returns:
|
||||
object of `DeviceType` type
|
||||
"""
|
||||
data = self.__io.get(TSI_HDRX_CEC_DEVICE_TYPE, DeviceTypePrivate)[1]
|
||||
data = self.__io.get(ci.TSI_HDRX_CEC_DEVICE_TYPE, DeviceTypePrivate)[1]
|
||||
return DeviceType(data.cecSwitch, data.audioSystem, data.pbDevice, data.tuner, data.recDev, data.tv)
|
||||
|
||||
@device_type.setter
|
||||
@@ -134,7 +134,7 @@ class CecRx:
|
||||
value = dev_type & 0xFF
|
||||
else:
|
||||
raise TypeError(f"Unsupported type: {type(dev_type)}")
|
||||
self.__io.set(TSI_HDRX_CEC_DEVICE_TYPE, value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_DEVICE_TYPE, value, c_uint32)
|
||||
|
||||
@property
|
||||
def status(self) -> CECStatus:
|
||||
@@ -144,7 +144,7 @@ class CecRx:
|
||||
Returns:
|
||||
object of `CECStatus` type
|
||||
"""
|
||||
data = self.__io.get(TSI_HDRX_CEC_STATUS_R, CECStatusPrivate)[1]
|
||||
data = self.__io.get(ci.TSI_HDRX_CEC_STATUS_R, CECStatusPrivate)[1]
|
||||
return CECStatus(data.bufferOverflowed)
|
||||
|
||||
@property
|
||||
@@ -155,7 +155,7 @@ class CecRx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDRX_CEC_RECEIVED_CNT_R, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_RECEIVED_CNT_R, c_uint32)[1]
|
||||
|
||||
@property
|
||||
def data(self) -> list:
|
||||
@@ -165,8 +165,8 @@ class CecRx:
|
||||
Returns:
|
||||
object of `list` type
|
||||
"""
|
||||
data_size = self.__io.get(TSI_HDRX_CEC_DATA_SIZE_R, c_uint32)[1]
|
||||
return self.__io.get(TSI_HDRX_CEC_DATA_RECIEVED, c_uint32, data_size)[1]
|
||||
data_size = self.__io.get(ci.TSI_HDRX_CEC_DATA_SIZE_R, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDRX_CEC_DATA_RECIEVED, c_uint32, data_size)[1]
|
||||
|
||||
def reset_data(self, command: CecResetDataCommand):
|
||||
"""
|
||||
@@ -175,10 +175,10 @@ class CecRx:
|
||||
Returns:
|
||||
object of `CecResetDataCommand` type
|
||||
"""
|
||||
self.__io.set(TSI_HDRX_CEC_DATA_RESET_W, command.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_DATA_RESET_W, command.value, c_uint32)
|
||||
|
||||
def __read_version(self) -> (int, int):
|
||||
version = self.__io.get(TSI_HDRX_CEC_VERSION_R, CECVersion)[1]
|
||||
version = self.__io.get(ci.TSI_HDRX_CEC_VERSION_R, CECVersion)[1]
|
||||
return version.minor, version.major
|
||||
|
||||
def add_command(self, command: CECCommand = CECCommand()):
|
||||
@@ -250,7 +250,7 @@ class CecRx:
|
||||
self.__send_cec_command()
|
||||
|
||||
def __send_cec_command(self):
|
||||
self.__io.set(TSI_HDRX_CEC_COMMAND, 1, c_uint32)
|
||||
self.__io.set(ci.TSI_HDRX_CEC_COMMAND, 1, c_uint32)
|
||||
|
||||
@property
|
||||
def commands(self) -> list:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from UniTAP.libs.lib_tsi.tsi_io import PortIO
|
||||
from UniTAP.libs.lib_tsi.tsi import *
|
||||
import UniTAP.libs.lib_tsi.tsi_types as ci
|
||||
from .cec_types import *
|
||||
from .cec_private_types import *
|
||||
from typing import Union
|
||||
@@ -29,7 +29,7 @@ class CecTx:
|
||||
Args:
|
||||
state (`bool`)
|
||||
"""
|
||||
self.__io.set(TSI_HDTX_CEC_CONTROL, state, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_CONTROL, state, c_uint32)
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
"""
|
||||
@@ -38,7 +38,7 @@ class CecTx:
|
||||
Returns:
|
||||
object of `bool` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDTX_CEC_CONTROL, c_uint32)[1] & 0x1 == 1
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_CONTROL, c_uint32)[1] & 0x1 == 1
|
||||
|
||||
@property
|
||||
def logical_address(self) -> LogicalAddressEnum:
|
||||
@@ -48,11 +48,11 @@ class CecTx:
|
||||
Returns:
|
||||
object of `LogicalAddressEnum` type
|
||||
"""
|
||||
return LogicalAddressEnum(self.__io.get(TSI_HDTX_CEC_LOGICAL_ADDRESS, c_uint32)[1])
|
||||
return LogicalAddressEnum(self.__io.get(ci.TSI_HDTX_CEC_LOGICAL_ADDRESS, c_uint32)[1])
|
||||
|
||||
@logical_address.setter
|
||||
def logical_address(self, address: LogicalAddressEnum):
|
||||
self.__io.set(TSI_HDTX_CEC_LOGICAL_ADDRESS, address.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_LOGICAL_ADDRESS, address.value, c_uint32)
|
||||
|
||||
@property
|
||||
def destination(self) -> LogicalAddressEnum:
|
||||
@@ -62,11 +62,11 @@ class CecTx:
|
||||
Returns:
|
||||
object of `LogicalAddressEnum` type
|
||||
"""
|
||||
return LogicalAddressEnum(self.__io.get(TSI_HDTX_CEC_DESTINATION, c_uint32)[1])
|
||||
return LogicalAddressEnum(self.__io.get(ci.TSI_HDTX_CEC_DESTINATION, c_uint32)[1])
|
||||
|
||||
@destination.setter
|
||||
def destination(self, address: LogicalAddressEnum):
|
||||
self.__io.set(TSI_HDTX_CEC_DESTINATION, address.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_DESTINATION, address.value, c_uint32)
|
||||
|
||||
@property
|
||||
def phy_address(self) -> int:
|
||||
@@ -76,11 +76,11 @@ class CecTx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDTX_CEC_PHYSICAL_ADDRESS, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_PHYSICAL_ADDRESS, c_uint32)[1]
|
||||
|
||||
@phy_address.setter
|
||||
def phy_address(self, address: int):
|
||||
self.__io.set(TSI_HDTX_CEC_PHYSICAL_ADDRESS, address, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_PHYSICAL_ADDRESS, address, c_uint32)
|
||||
|
||||
@property
|
||||
def op_code(self) -> int:
|
||||
@@ -90,11 +90,11 @@ class CecTx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDTX_CEC_OP_CODE, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_OP_CODE, c_uint32)[1]
|
||||
|
||||
@op_code.setter
|
||||
def op_code(self, code: int):
|
||||
self.__io.set(TSI_HDTX_CEC_OP_CODE, code, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_OP_CODE, code, c_uint32)
|
||||
|
||||
@property
|
||||
def op_code_param(self) -> Union[int, list]:
|
||||
@@ -104,12 +104,12 @@ class CecTx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDTX_CEC_OP_CODE_PARAM, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_OP_CODE_PARAM, c_uint32)[1]
|
||||
|
||||
@op_code_param.setter
|
||||
def op_code_param(self, code_param: Union[int, list]):
|
||||
data_count = len(code_param) if isinstance(code_param, list) else 1
|
||||
self.__io.set(TSI_HDTX_CEC_OP_CODE_PARAM, code_param, c_uint32, data_count=data_count)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_OP_CODE_PARAM, code_param, c_uint32, data_count=data_count)
|
||||
|
||||
@property
|
||||
def device_type(self) -> DeviceType:
|
||||
@@ -119,7 +119,7 @@ class CecTx:
|
||||
Returns:
|
||||
object of `DeviceType` type
|
||||
"""
|
||||
data = self.__io.get(TSI_HDTX_CEC_DEVICE_TYPE, DeviceTypePrivate)[1]
|
||||
data = self.__io.get(ci.TSI_HDTX_CEC_DEVICE_TYPE, DeviceTypePrivate)[1]
|
||||
return DeviceType(data.cecSwitch, data.audioSystem, data.pbDevice, data.tuner, data.recDev, data.tv)
|
||||
|
||||
@device_type.setter
|
||||
@@ -134,7 +134,7 @@ class CecTx:
|
||||
value = dev_type & 0xFF
|
||||
else:
|
||||
raise TypeError(f"Unsupported type: {type(dev_type)}")
|
||||
self.__io.set(TSI_HDTX_CEC_DEVICE_TYPE, value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_DEVICE_TYPE, value, c_uint32)
|
||||
|
||||
@property
|
||||
def status(self) -> CECStatus:
|
||||
@@ -144,7 +144,7 @@ class CecTx:
|
||||
Returns:
|
||||
object of `CECStatus` type
|
||||
"""
|
||||
data = self.__io.get(TSI_HDTX_CEC_STATUS_R, CECStatusPrivate)[1]
|
||||
data = self.__io.get(ci.TSI_HDTX_CEC_STATUS_R, CECStatusPrivate)[1]
|
||||
return CECStatus(data.bufferOverflowed)
|
||||
|
||||
@property
|
||||
@@ -155,7 +155,7 @@ class CecTx:
|
||||
Returns:
|
||||
object of `int` type
|
||||
"""
|
||||
return self.__io.get(TSI_HDTX_CEC_RECEIVED_CNT_R, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_RECEIVED_CNT_R, c_uint32)[1]
|
||||
|
||||
@property
|
||||
def data(self) -> list:
|
||||
@@ -165,8 +165,8 @@ class CecTx:
|
||||
Returns:
|
||||
object of `list` type
|
||||
"""
|
||||
data_size = self.__io.get(TSI_HDTX_CEC_DATA_SIZE_R, c_uint32)[1]
|
||||
return self.__io.get(TSI_HDTX_CEC_DATA_RECEIVED_R, c_uint32, data_size)[1]
|
||||
data_size = self.__io.get(ci.TSI_HDTX_CEC_DATA_SIZE_R, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_HDTX_CEC_DATA_RECEIVED_R, c_uint32, data_size)[1]
|
||||
|
||||
def reset_data(self, command: CecResetDataCommand):
|
||||
"""
|
||||
@@ -175,10 +175,10 @@ class CecTx:
|
||||
Returns:
|
||||
object of `CecResetDataCommand` type
|
||||
"""
|
||||
self.__io.set(TSI_HDTX_CEC_DATA_RESET_W, command.value, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_DATA_RESET_W, command.value, c_uint32)
|
||||
|
||||
def __read_version(self) -> (int, int):
|
||||
version = self.__io.get(TSI_HDTX_CEC_VERSION_R, CECVersion)[1]
|
||||
version = self.__io.get(ci.TSI_HDTX_CEC_VERSION_R, CECVersion)[1]
|
||||
return version.minor, version.major
|
||||
|
||||
def add_command(self, command: CECCommand = CECCommand()):
|
||||
@@ -250,7 +250,7 @@ class CecTx:
|
||||
self.__send_cec_command()
|
||||
|
||||
def __send_cec_command(self):
|
||||
self.__io.set(TSI_HDTX_CEC_COMMAND, 1, c_uint32)
|
||||
self.__io.set(ci.TSI_HDTX_CEC_COMMAND, 1, c_uint32)
|
||||
|
||||
@property
|
||||
def commands(self) -> list:
|
||||
|
||||
Reference in New Issue
Block a user