def set_json(path, value, only_writeable_nodes=False): path = helper.fix_string_encoding(path) value = helper.fix_string_encoding(value) f = _get_lib().nxLibSetJson f.argtypes = [POINTER(c_int32), c_char_p, c_char_p, c_int32] error_code = c_int32(0) f(byref(error_code), path, value, only_writeable_nodes) return error_code.value
def wait_for_string_value(path, value, wait_for_equal): path = helper.fix_string_encoding(path) value = helper.fix_string_encoding(value) f = _get_lib().nxLibWaitForStringValue f.argtypes = [POINTER(c_int32), c_char_p, c_char_p, c_int32] error_code = c_int32(0) f(byref(error_code), path, value, wait_for_equal) return error_code.value
def make_unique_item(path, item_name): path = helper.fix_string_encoding(path) item_name = helper.fix_string_encoding(item_name) f = _get_lib().nxLibMakeUniqueItem f.restype = c_char_p f.argtypes = [POINTER(c_int32), c_char_p, c_char_p] error_code = c_int32(0) new_path = f(byref(error_code), path, item_name) if new_path is not None: new_path = new_path.decode() return new_path, error_code.value
def wait_for_type(path, awaited_type, wait_for_equal): path = helper.fix_string_encoding(path) f = _get_lib().nxLibWaitForType f.argtypes = [POINTER(c_int32), c_char_p, c_int32, c_int32] error_code = c_int32(0) f(byref(error_code), path, awaited_type, wait_for_equal) return error_code.value
def wait_for_change(path): path = helper.fix_string_encoding(path) f = _get_lib().nxLibWaitForChange f.argtypes = [POINTER(c_int32), c_char_p] error_code = c_int32(0) f(byref(error_code), path) return error_code.value
def get_binary_info(path): path = helper.fix_string_encoding(path) f = _get_lib().nxLibGetBinaryInfo f.argtypes = [ POINTER(c_int32), c_char_p, POINTER(c_int32), POINTER(c_int32), POINTER(c_int32), POINTER(c_int32), POINTER(c_int32), POINTER(c_double) ] error_code = c_int32(0) width = c_int32(0) height = c_int32(0) channel_count = c_int32(0) bytes_per_element = c_int32(0) is_float = c_int32(0) timestamp = c_double(0) f(byref(error_code), path, byref(width), byref(height), byref(channel_count), byref(bytes_per_element), byref(is_float), byref(timestamp)) return (width.value, height.value, channel_count.value, bytes_per_element.value, is_float.value == 1, timestamp.value, error_code.value)
def set_null(path): path = helper.fix_string_encoding(path) f = _get_lib().nxLibSetNull f.argtypes = [POINTER(c_int32), c_char_p] error_code = c_int32(0) f(byref(error_code), path) return error_code.value
def set_binary(path, buffer, buffer_size): path = helper.fix_string_encoding(path) f = _get_lib().nxLibSetBinary f.argtypes = [POINTER(c_int32), c_char_p, POINTER(c_void_p), c_int32] buffer = cast(buffer, POINTER(c_void_p)) error_code = c_int32(0) f(byref(error_code), path, buffer, buffer_size) return error_code.value
def connect(hostname, port): if not _lib_is_remote(): raise NxLibError("Cannot use connect function from a normal NxLib.") hostname = helper.fix_string_encoding(hostname) return_code = c_int32(0) f = _get_lib().nxLibConnect f.argtypes = [POINTER(c_int32), c_char_p, c_int32] f(byref(return_code), hostname, port) check_return_code(return_code.value)
def get_json(path, pretty_print, number_precision, scientific_number_format): path = helper.fix_string_encoding(path) f = _get_lib().nxLibGetJson f.restype = c_char_p f.argtypes = [POINTER(c_int32), c_char_p, c_int32, c_int32, c_int32] error_code = c_int32(0) result = f(byref(error_code), path, pretty_print, number_precision, scientific_number_format) if result is not None: result = result.decode() return result, error_code.value
def set_binary_formatted(path, buffer, width, height, channel_count, bytes_per_element, is_float): path = helper.fix_string_encoding(path) f = _get_lib().nxLibSetBinaryFormatted f.argtypes = [ POINTER(c_int32), c_char_p, POINTER(c_void_p), c_int32, c_int32, c_int32, c_int32, c_int32 ] buffer = cast(buffer, POINTER(c_void_p)) error_code = c_int32(0) f(byref(error_code), path, buffer, width, height, channel_count, bytes_per_element, is_float) return error_code.value
def get_binary(path, destination_buffer, buffer_size): path = helper.fix_string_encoding(path) f = _get_lib().nxLibGetBinary f.argtypes = [ POINTER(c_int32), c_char_p, POINTER(c_void_p), c_int32, POINTER(c_int32), POINTER(c_double) ] error_code = c_int32(0) destination_buffer = cast(destination_buffer, POINTER(c_void_p)) # destination_buffer = c_void_p(buffer_size) #(c_ubyte * buffer_size)() bytes_copied = c_int32(0) timestamp = c_double(0) f(byref(error_code), path, destination_buffer, buffer_size, byref(bytes_copied), byref(timestamp)) return bytes_copied.value, timestamp.value, error_code.value
def _get(f, path): path = helper.fix_string_encoding(path) error_code = c_int32(0) result = f(byref(error_code), path) return result, error_code.value
def set_string(path, value): value = helper.fix_string_encoding(value) f = _get_lib().nxLibSetString f.argtypes = [POINTER(c_int32), c_char_p, c_char_p] return _set(f, path, value)
def _set(f, path, value): path = helper.fix_string_encoding(path) error_code = c_int32(0) f(byref(error_code), path, value) return error_code.value