更新UCD-API库及文档
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import platform
|
||||
import warnings
|
||||
|
||||
from UniTAP.libs.lib_tsi.tsi_types import TSI_OPF_CALLBACK_STRUCT, TSI_OPF_RETURN_CODE_ABORT
|
||||
import UniTAP.libs.lib_tsi.tsi_types as ci
|
||||
from UniTAP.libs.lib_tsi.tsi_io import DeviceIO
|
||||
from UniTAP.utils import tsi_logging as logging
|
||||
from .handlers import OpfHandlerBase, OpfHandlerDefault
|
||||
@@ -9,11 +9,11 @@ from .handlers import OpfHandlerBase, OpfHandlerDefault
|
||||
if platform.system() == 'Windows':
|
||||
from ctypes import c_int, POINTER, c_void_p, WINFUNCTYPE
|
||||
|
||||
OPF_CALLBACK_TYPE = WINFUNCTYPE(c_int, POINTER(TSI_OPF_CALLBACK_STRUCT), c_void_p)
|
||||
OPF_CALLBACK_TYPE = WINFUNCTYPE(c_int, POINTER(ci.TSI_OPF_CALLBACK_STRUCT), c_void_p)
|
||||
else:
|
||||
from ctypes import c_int, POINTER, c_void_p, CFUNCTYPE
|
||||
|
||||
OPF_CALLBACK_TYPE = CFUNCTYPE(c_int, POINTER(TSI_OPF_CALLBACK_STRUCT), c_void_p)
|
||||
OPF_CALLBACK_TYPE = CFUNCTYPE(c_int, POINTER(ci.TSI_OPF_CALLBACK_STRUCT), c_void_p)
|
||||
|
||||
|
||||
class OperatorFeedbackHandler:
|
||||
@@ -33,8 +33,8 @@ class OperatorFeedbackHandler:
|
||||
self.__handler = OpfHandlerDefault()
|
||||
|
||||
def __get_callback(self):
|
||||
def ofp_impl(_struct: POINTER(TSI_OPF_CALLBACK_STRUCT), context_ptr: c_void_p):
|
||||
opf_struct: TSI_OPF_CALLBACK_STRUCT = _struct.contents
|
||||
def ofp_impl(_struct: POINTER(ci.TSI_OPF_CALLBACK_STRUCT), context_ptr: c_void_p):
|
||||
opf_struct: ci.TSI_OPF_CALLBACK_STRUCT = _struct.contents
|
||||
logging.debug(f"Received OPF dialog with ID: {opf_struct.id()}, Session: {opf_struct.session_id()}.")
|
||||
|
||||
try:
|
||||
@@ -46,7 +46,7 @@ class OperatorFeedbackHandler:
|
||||
opf_struct.parameters())
|
||||
except BaseException as e:
|
||||
warnings.warn(f"OPF Dialog {opf_struct.id()} was aborted due an exception. Exception: {e}")
|
||||
return opf_struct.write_opf_result(TSI_OPF_RETURN_CODE_ABORT)
|
||||
return opf_struct.write_opf_result(ci.TSI_OPF_RETURN_CODE_ABORT)
|
||||
|
||||
return ofp_impl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user