|
| 1 | +import ctypes |
| 2 | +from ansys.dpf.gate import utils |
| 3 | +from ansys.dpf.gate import errors |
| 4 | +from ansys.dpf.gate.generated import capi |
| 5 | +from ansys.dpf.gate.generated import fbs_ref_abstract_api |
| 6 | +from ansys.dpf.gate.generated.data_processing_capi import DataProcessingCAPI |
| 7 | + |
| 8 | +#------------------------------------------------------------------------------- |
| 9 | +# FbsRef |
| 10 | +#------------------------------------------------------------------------------- |
| 11 | + |
| 12 | +class FbsRefCAPI(fbs_ref_abstract_api.FbsRefAbstractAPI): |
| 13 | + |
| 14 | + @staticmethod |
| 15 | + def init_fbs_ref_environment(object): |
| 16 | + # get core api |
| 17 | + DataProcessingCAPI.init_data_processing_environment(object) |
| 18 | + object._deleter_func = (DataProcessingCAPI.data_processing_delete_shared_object, lambda obj: obj) |
| 19 | + |
| 20 | + @staticmethod |
| 21 | + def fbs_ref_new(client, channel_address, req_slice, req_offset): |
| 22 | + errorSize = ctypes.c_int(0) |
| 23 | + sError = ctypes.c_wchar_p() |
| 24 | + res = capi.dll.FbsRef_new(client, utils.to_char_ptr(channel_address), req_slice, req_offset, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 25 | + if errorSize.value != 0: |
| 26 | + raise errors.DPFServerException(sError.value) |
| 27 | + return res |
| 28 | + |
| 29 | + @staticmethod |
| 30 | + def fbs_ref_get_from_db(id): |
| 31 | + errorSize = ctypes.c_int(0) |
| 32 | + sError = ctypes.c_wchar_p() |
| 33 | + res = capi.dll.FbsRef_getFromDB(id, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 34 | + if errorSize.value != 0: |
| 35 | + raise errors.DPFServerException(sError.value) |
| 36 | + return res |
| 37 | + |
| 38 | + @staticmethod |
| 39 | + def fbs_ref_get_id(obj): |
| 40 | + errorSize = ctypes.c_int(0) |
| 41 | + sError = ctypes.c_wchar_p() |
| 42 | + res = capi.dll.FbsRef_getID(obj._internal_obj if obj is not None else None, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 43 | + if errorSize.value != 0: |
| 44 | + raise errors.DPFServerException(sError.value) |
| 45 | + return res |
| 46 | + |
| 47 | + @staticmethod |
| 48 | + def any_get_as_fbs_ref(obj, client, channel_address, req_slice, req_offset): |
| 49 | + errorSize = ctypes.c_int(0) |
| 50 | + sError = ctypes.c_wchar_p() |
| 51 | + res = capi.dll.Any_getAs_FbsRef(obj._internal_obj if obj is not None else None, client, utils.to_char_ptr(channel_address), req_slice, req_offset, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 52 | + if errorSize.value != 0: |
| 53 | + raise errors.DPFServerException(sError.value) |
| 54 | + return res |
| 55 | + |
| 56 | + @staticmethod |
| 57 | + def fbs_ref_start_or_get_thread_server(get_existing, ip, port, address): |
| 58 | + errorSize = ctypes.c_int(0) |
| 59 | + sError = ctypes.c_wchar_p() |
| 60 | + res = capi.dll.FbsRef_StartOrGetThreadServer(get_existing, utils.to_char_ptr(ip), utils.to_int32(port), utils.to_char_ptr(address), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 61 | + if errorSize.value != 0: |
| 62 | + raise errors.DPFServerException(sError.value) |
| 63 | + return res |
| 64 | + |
| 65 | + @staticmethod |
| 66 | + def fbs_ref_new_on_client(client, channel, channel_address, req_slice, req_offset): |
| 67 | + errorSize = ctypes.c_int(0) |
| 68 | + sError = ctypes.c_wchar_p() |
| 69 | + res = capi.dll.FbsRef_new_on_client(client._internal_obj if client is not None else None, channel, utils.to_char_ptr(channel_address), req_slice, req_offset, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 70 | + if errorSize.value != 0: |
| 71 | + raise errors.DPFServerException(sError.value) |
| 72 | + return res |
| 73 | + |
| 74 | + @staticmethod |
| 75 | + def fbs_ref_start_or_get_thread_server_on_client(client, get_existing, ip, port, address): |
| 76 | + errorSize = ctypes.c_int(0) |
| 77 | + sError = ctypes.c_wchar_p() |
| 78 | + res = capi.dll.FbsRef_StartOrGetThreadServer_on_client(client._internal_obj if client is not None else None, get_existing, utils.to_char_ptr(ip), utils.to_int32(port), utils.to_char_ptr(address), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError)) |
| 79 | + if errorSize.value != 0: |
| 80 | + raise errors.DPFServerException(sError.value) |
| 81 | + return res |
| 82 | + |
0 commit comments