def __init__(self, val=None, is_pointer=False): if type(val) is Void: val = ffi.cast("size_t*", val._ptr) if val is None: super().__init__(ffi.new("size_t*"), is_pointer) else: if is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("size_t*", _val(val)), is_pointer)
def __init__(self, val=None, is_pointer=False): if val is None: super().__init__(ffi.new("UA_Double*"), is_pointer) else: if type(val) is list: super().__init__(ffi.new("UA_Double[]", val), True) elif is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("UA_Double*", _val(val)), is_pointer)
def __init__(self, val: Union[Void, int, List[int]] = None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_StatusCode*", val._ptr) if val is None: super().__init__(ffi.new("UA_StatusCode*"), is_pointer) else: if type(val) is list: super().__init__(ffi.new("UA_StatusCode[]", val), True) elif is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("UA_StatusCode*", _val(val)), is_pointer)
def __init__(self, val=None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_UInt32*", val._ptr) if val is None: super().__init__(ffi.new("UA_UInt32*"), is_pointer) else: if type(val) is list: super().__init__(ffi.new("UA_UInt32[]", val), True) elif is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("UA_UInt32*", _val(val)), is_pointer)
def set_external(self, data_value: UaDataValue, callback: 'UaExternalValueCallback' = None): self._value = ffi.new("UA_ValueBackend*") self._value.backendType = lib.UA_VALUEBACKENDTYPE_EXTERNAL self._data_value = data_value self._value.backend.external.value = ffi.new("UA_DataValue **", data_value._ptr) self._callback = callback self._data_source = None if callback is not None: self._value.backend.external.callback = callback._val
def __init__(self, val: Union[UaType, List] = None, size=None, ua_class=None): c_type = "" if type(val) is list: if ua_class is None: if type(val[0]) is int: c_type = "UA_Int64" ua_class = UaInt64 elif type(val[0]) is float: c_type = "UA_Double" ua_class = UaDouble elif type(val[0]) is str: c_type = "UA_String" ua_class = UaString elif type(val[0]) is bool: c_type = "UA_Boolean" ua_class = UaBoolean elif isinstance(ua_class(), UaType): c_type = _get_c_type(ua_class()._ptr) else: raise AttributeError( "'ua_class' has to be None or a Subclass of UaType.") array = ffi.new(f"{c_type}[]", val) size = len(val) else: if isinstance(ua_class(), UaType): c_type = _get_c_type(ua_class()._ptr) else: raise AttributeError( "'ua_class' has do be None or a subclass of UaType.") if size is None: raise AttributeError( "if 'val' is not a python list 'size' has to be set.") elif isinstance(size, SizeT): size = size._val if isinstance(val, UaType): array = ffi.cast(f"{c_type}[{size}]", val._ptr) elif val is None: array = ffi.new(f"{c_type}[{size}]") else: array = ffi.cast(f"{c_type}[{size}]", val) super().__init__(val=array, is_pointer=True) self._size = size self._ua_type = ua_class self._c_type = c_type
def __init__(self, val: Union[Void, float, List[float]] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_Float*", val._ptr) if val is None: super().__init__(ffi.new("UA_Float*"), is_pointer) else: if type(val) is list: super().__init__(ffi.new("UA_Float[]", val), True) elif is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("UA_Float*", _val(val)), is_pointer)
def __init__(self, val: int = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_LogLevel*", val._ptr) if val is None: super().__init__(ffi.new("UA_LogLevel*"), is_pointer) else: super().__init__(ffi.cast("UA_LogLevel", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_AttributeId*", val._ptr) if val is None: super().__init__(ffi.new("UA_AttributeId*"), is_pointer) else: super().__init__(ffi.cast("UA_AttributeId", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_SecurityTokenRequestType*", val._ptr) if val is None: super().__init__(ffi.new("UA_SecurityTokenRequestType*"), is_pointer) else: super().__init__(ffi.cast("UA_SecurityTokenRequestType", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_DataChangeTrigger*", val._ptr) if val is None: super().__init__(ffi.new("UA_DataChangeTrigger*"), is_pointer) else: super().__init__(ffi.cast("UA_DataChangeTrigger", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_BrowseDirection*", val._ptr) if val is None: super().__init__(ffi.new("UA_BrowseDirection*"), is_pointer) else: super().__init__(ffi.cast("UA_BrowseDirection", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_MonitoringMode*", val._ptr) if val is None: super().__init__(ffi.new("UA_MonitoringMode*"), is_pointer) else: super().__init__(ffi.cast("UA_MonitoringMode", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_RedundancySupport*", val._ptr) if val is None: super().__init__(ffi.new("UA_RedundancySupport*"), is_pointer) else: super().__init__(ffi.cast("UA_RedundancySupport", _val(val)), is_pointer)
def set_data_source(self, data_source: 'UaDataSource'): self._value = ffi.new("UA_ValueBackend*") self._value.backendType = lib.UA_VALUEBACKENDTYPE_DATA_SOURCE_CALLBACK self._data_source = data_source self._value.backend.dataSource = data_source._val self._data_value = None self._callback = None
def __init__(self, val=None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_ClientConfig*", val._ptr) if val is None: val = ffi.new("UA_ClientConfig*") lib.UA_ClientConfig_setDefault(val) super().__init__(val=val, is_pointer=is_pointer) if not self._null: self._client_context = Void(val=val.clientContext, is_pointer=True) self._logger = UaLogger(val=val.logger, is_pointer=False) self._timeout = UaUInt32(val=val.timeout, is_pointer=False) self._client_description = UaUInt32(val=val.clientDescription, is_pointer=False) self._user_identity_token = UaUserIdentityToken( val=val.userIdentityToken, is_pointer=False) self._security_mode = UaMessageSecurityMode(val=val.securityMode, is_pointer=False) self._security_policy_uri = UaString(val=val.securityPolicyUri, is_pointer=False) self._endpoint = UaEndpointDescription(val=val.endpoint, is_pointer=False) self._user_token_policy = UaUserTokenPolicy( val=val.userTokenPolicy, is_pointer=False) self._secure_channel_life_time = UaUInt32( val=val.secureChannelLifeTime, is_pointer=False) self._requested_session_timeout = UaUInt32( val=val.requestedSessionTimeout, is_pointer=False) self._connectivity_check_interval = UaUInt32( val=val.connectivityCheckInterval, is_pointer=False) self._custom_data_types = UaDataTypeArray(val=val.customDataTypes, is_pointer=True)
def __init__(self, val=None, is_pointer=False): if val is None: val = ffi.new("UA_ValueBackend*") super().__init__(val=val, is_pointer=is_pointer) self._backend_type = UaValueBackendType(val=val.backendType) if val.backendType is lib.UA_VALUEBACKENDTYPE_NONE: pass elif val.backendType is lib.UA_VALUEBACKENDTYPE_INTERNAL: self._data_value = UaDataValue(val=val.backend.internal.value) self._callback = UaValueCallback(val=val.backend.internal.callback) self._data_source = None elif val.backendType is lib.UA_VALUEBACKENDTYPE_DATA_SOURCE_CALLBACK: self._data_source = UaDataSource(val=val.backend.dataSource) self._data_value = None self._callback = None elif val.backendType is lib.UA_VALUEBACKENDTYPE_EXTERNAL: self._data_value = UaDataValue(val=val.backend.external.value[0], is_pointer=True) self._callback = UaExternalValueCallback( val=val.backend.external.callback) self._data_source = None # todo: val.backend.internal.value is ** else: raise ValueError(f"Encoding does not exist.")
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_NodeAttributesMask*", val._ptr) if val is None: super().__init__(ffi.new("UA_NodeAttributesMask*"), is_pointer) else: super().__init__(ffi.cast("UA_NodeAttributesMask", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if type(val) is Void: val = ffi.cast("UA_TimestampsToReturn*", val._ptr) if val is None: super().__init__(ffi.new("UA_TimestampsToReturn*"), is_pointer) else: super().__init__(ffi.cast("UA_TimestampsToReturn", _val(val)), is_pointer)
def __init__(self, val: Union[int, Void] = None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_SecureChannelState*", val._ptr) if val is None: super().__init__(ffi.new("UA_SecureChannelState*"), is_pointer) else: super().__init__(ffi.cast("UA_SecureChannelState", _val(val)), is_pointer)
def __init__(self, val: Union[Void, float, List[float]] = None, size: int = None, is_pointer=False): if type(val) is Void: if size is None: val = ffi.cast("UA_Double*", val._ptr) else: val = ffi.cast(f"UA_Double[{size}]", val._ptr) is_pointer = True if val is None: super().__init__(ffi.new("UA_Double*"), is_pointer) else: if type(val) is list: super().__init__(ffi.new("UA_Double[]", val), True) elif is_pointer: super().__init__(val, is_pointer) else: super().__init__(ffi.new("UA_Double*", _val(val)), is_pointer) self._size = size
def set_internal(self, data_value: UaDataValue, callback: UaValueCallback = None): self._value = ffi.new("UA_ValueBackend*") self._value.backendType = lib.UA_VALUEBACKENDTYPE_INTERNAL self._data_value = data_value self._value.backend.internal.value = data_value._val self._callback = callback self._data_source = None if callback is not None: self._value.backend.internal.callback = callback._val
def __init__(self, val: Union[str, Void] = None, is_pointer=False): if isinstance(val, UaType): val = ffi.cast("UA_String*", val._ptr) elif type(val) is str: val = ffi.new("UA_String*", lib.UA_String_fromChars(bytes(val, 'utf-8'))) elif type(val) is bytes: val = ffi.new("UA_String*", lib.UA_String_fromChars(val)) elif type(val) is not None: if not is_pointer: val = ffi.new("UA_String*", val) else: val = ffi.new("UA_String*") super().__init__(val=val, is_pointer=is_pointer) if not self._null: self._length = SizeT(val=val.length, is_pointer=False) self._data = UaByte(val=val.data, is_pointer=True) if _is_null(self._data): self._null = True
def __init__(self, p_val: str = "", is_pointer=True, val=None): if type(val) is Void: val = ffi.cast("char[]", val._ptr) p_val = bytes(p_val, "utf-8") if val is None: super().__init__(ffi.new("char[]", p_val), is_pointer) self._p_value = p_val else: super().__init__(val, is_pointer) if self._null: self._p_value = None else: self._p_value = ffi.string(val)
def __init__(self, val=ffi.new("UA_NetworkStatistics*"), is_pointer=False): super().__init__(val=val, is_pointer=is_pointer) if not self._null: self._current_connection_count = SizeT( val=val.currentConnectionCount, is_pointer=False) self._cumulated_connection_count = SizeT( val=val.cumulatedConnectionCount, is_pointer=False) self._rejected_connection_count = SizeT( val=val.rejectedConnectionCount, is_pointer=False) self._connection_timeout_count = SizeT( val=val.connectionTimeoutCount, is_pointer=False) self._connection_abort_count = SizeT(val=val.connectionAbortCount, is_pointer=False)
def _ptr(val, c_type=""): if c_type == "": c_type = str(val).split("'")[1] c_type = re.sub(r"[^A-Za-z1-9_ ]", "", c_type, re.ASCII).strip() if _is_null(val): return ffi.NULL if "&" in str(val): return ffi.addressof(val) if "*" in str(val) or "[" in str(val): return val else: try: return ffi.cast(c_type + "*", ffi.addressof(val)) except TypeError: return ffi.new(c_type + "*", val)
def __init__(self, val=None, is_pointer=False): if val is None: super().__init__(val=ffi.new("UA_DataSource*"), is_pointer=is_pointer) self._uses_python_read_callback = True self._uses_python_write_callback = True self._value.read = lib.python_wrapper_UA_DataSourceReadCallback self._value.write = lib.python_wrapper_UA_DataSourceWriteCallback self._read_callback = lambda a, b, c, d, e, f, g, h: UA_STATUSCODES.GOOD self._write_callback = lambda a, b, c, d, e, f, g: UA_STATUSCODES.GOOD else: super().__init__(val=val, is_pointer=is_pointer) self._uses_python_read_callback = False self._uses_python_write_callback = False self._read_callback = lambda a, b, c, d, e, f, g, h: UA_STATUSCODES.GOOD self._write_callback = lambda a, b, c, d, e, f, g: UA_STATUSCODES.GOOD
def __init__(self, val=None, is_pointer=False): if val is None: super().__init__(val=ffi.new("UA_ValueCallback*"), is_pointer=is_pointer) self._value[ 0].onRead = lib.python_wrapper_UA_ValueCallbackOnReadCallback self._value[ 0].onWrite = lib.python_wrapper_UA_ValueCallbackOnWriteCallback self.read_callback = lambda a, b, c, d, e, f, g: None self.write_callback = lambda a, b, c, d, e, f, g: None self._uses_python_read_callback = True self._uses_python_write_callback = True else: super().__init__(val=val, is_pointer=is_pointer) self.read_callback = lambda a, b, c, d, e, f, g: None self.write_callback = lambda a, b, c, d, e, f, g: None self._uses_python_read_callback = False self._uses_python_write_callback = False
def __init__(self, val=None, is_pointer=False): if val is None: val = ffi.new("UA_NetworkStatistics*") if isinstance(val, UaType): val = ffi.cast("UA_NetworkStatistics*", val._ptr) super().__init__(val=val, is_pointer=is_pointer) if not self._null: self._current_connection_count = SizeT( val=val.currentConnectionCount, is_pointer=False) self._cumulated_connection_count = SizeT( val=val.cumulatedConnectionCount, is_pointer=False) self._rejected_connection_count = SizeT( val=val.rejectedConnectionCount, is_pointer=False) self._connection_timeout_count = SizeT( val=val.connectionTimeoutCount, is_pointer=False) self._connection_abort_count = SizeT(val=val.connectionAbortCount, is_pointer=False)
def __init__(self, val=ffi.new("UA_SecureChannelStatistics*"), is_pointer=False): super().__init__(val=val, is_pointer=is_pointer) if not self._null: self._current_channel_count = SizeT(val=val.currentChannelCount, is_pointer=False) self._cumulated_channel_count = SizeT( val=val.cumulatedChannelCount, is_pointer=False) self._rejected_channel_count = SizeT(val=val.rejectedChannelCount, is_pointer=False) self._channel_timeout_count = SizeT(val=val.channelTimeoutCount, is_pointer=False) self._channel_abort_count = SizeT(val=val.channelAbortCount, is_pointer=False) self._channel_purge_count = SizeT(val=val.channelPurgeCount, is_pointer=False)