Skip to content

Commit

Permalink
add CANape 21 function prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 committed Oct 25, 2023
1 parent cf7dc17 commit b109cec
Show file tree
Hide file tree
Showing 2 changed files with 2,082 additions and 349 deletions.
228 changes: 227 additions & 1 deletion src/pycanape/cnp_api/cnp_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ class tAsap3Hdl(ctypes.Structure):


TAsap3Hdl = ctypes.POINTER(tAsap3Hdl)
TAsap3DiagHdl = ctypes.c_ulong
TModulHdl = ctypes.c_ushort
TRecorderID = ctypes.POINTER(ctypes.c_ulong)
TTime = ctypes.c_ulong
TScriptHdl = ctypes.c_ulong
TParamTemplateHdl = ctypes.POINTER(ctypes.c_ulong)
TParamItemHdl = ctypes.POINTER(ctypes.c_ulong)

EVENT_CALLBACK = ctypes.WINFUNCTYPE(None, TAsap3Hdl, ctypes.c_ulong)
EVENT_CALLBACK = ctypes.WINFUNCTYPE(ctypes.c_long, TAsap3Hdl, ctypes.c_ulong)


class TTaskInfo(ctypes.Structure):
Expand Down Expand Up @@ -390,3 +391,228 @@ class TPhysInterface(ctypes.Structure):
("m_CanapPhysInterfaceName", ctypes.c_char_p),
("m_CanapPhysDeviceName", ctypes.c_char_p),
]


class PValues(ctypes.Union):
_fields_ = [
("IVal", ctypes.c_int64),
("UIVal", ctypes.c_uint64),
("FVal", ctypes.c_float),
("DVal", ctypes.c_double),
]


class DiagNumericParameter(ctypes.Structure):
_pack_ = 1
_anonymous_ = ["_values"]
_fields = [
("DiagNumeric", enum_type),
("_values", PValues),
("Values", PValues),
]


class DiagJobResponse(ctypes.Structure):
_pack_ = 1
_fields = [
("job_responsestring", ctypes.c_char_p),
("job_responseValue", ctypes.c_double),
]


class DiagNotificationStruct(ctypes.Structure):
_pack_ = 1
_fields = [
("DiagHandle", TAsap3DiagHdl),
("DiagState", enum_type),
("PrivateData", ctypes.c_void_p),
]


FNCDIAGNOFIFICATION = ctypes.WINFUNCTYPE(
ctypes.c_long, ctypes.c_ulong, ctypes.POINTER(DiagNotificationStruct)
)


class TLayoutCoeffs(ctypes.Structure):
_pack_ = 1
_fields = [
("OffNx", ctypes.c_short),
("OffNy", ctypes.c_short),
("OffX", ctypes.c_short),
("FakX", ctypes.c_short),
("OffY", ctypes.c_short),
("FakY", ctypes.c_short),
("OffW", ctypes.c_short),
("FakWx", ctypes.c_short),
("FakWy", ctypes.c_short),
]


class s_value_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("value", ctypes.c_double),
]


class s_axis_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("dimension", ctypes.c_short),
("pAxis", ctypes.POINTER(ctypes.c_double)),
("oAxis", ctypes.c_ulong),
]


class s_ascii_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("len", ctypes.c_short),
("pAscii", ctypes.c_char_p),
("oAscii", ctypes.c_ulong),
]


class s_curve_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("dimension", ctypes.c_short),
("pAxis", ctypes.POINTER(ctypes.c_double)),
("oAxis", ctypes.c_ulong),
("pValues", ctypes.POINTER(ctypes.c_double)),
("oValues", ctypes.c_ulong),
]


class s_map_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("xDimension", ctypes.c_short),
("yDimension", ctypes.c_short),
("pXAxis", ctypes.POINTER(ctypes.c_double)),
("oXAxis", ctypes.c_ulong),
("pYAxis", ctypes.POINTER(ctypes.c_double)),
("oYAxis", ctypes.c_ulong),
("pValues", ctypes.POINTER(ctypes.c_double)),
("oValues", ctypes.c_ulong),
]


class s_valblk_ex(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", enum_type),
("xDimension", ctypes.c_short),
("yDimension", ctypes.c_short),
("values", ctypes.POINTER(ctypes.c_double)),
("oValues", ctypes.c_ulong),
]


class TCalibrationObjectValueEx(ctypes.Union):
"""Union of calibration object variants.
# :var ctypes.c_uint type:
# See :class:`~pycanape.cnp_api.cnp_constants.ValueType`.
# The enum value determines content of :class:`TCalibrationObjectValueEx`
# :var s_value_ex value:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.VALUE`
# :var s_axis_ex axis:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.AXIS`
# :var s_ascii_ex ascii:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.ASCII`
# :var s_curve_ex curve:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.CURVE`
# :var s_map_ex map:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.MAP`
# :var s_valblk_ex valblk:
# contains the calibration object values if *type* is
# :obj:`~pycanape.cnp_api.cnp_constants.ValueType.VAL_BLK`
"""

_pack_ = 1
_fields_ = [
("type", enum_type),
("value", s_value_ex),
("axis", s_axis_ex),
("ascii", s_ascii_ex),
("curve", s_curve_ex),
("map", s_map_ex),
("valblk", s_valblk_ex),
]


class TCANapeModes(ctypes.Structure):
_pack_ = 1
_fields_ = [
("modes", ctypes.c_uint),
("reserved1", ctypes.c_uint),
("reserved2", ctypes.c_uint),
]


class TSampleObject(ctypes.Structure):
_pack_ = 1
_fields_ = [
("countOfEntires", ctypes.c_long),
("timestamp", TTime),
("data", ctypes.POINTER(ctypes.c_double)),
]


class TSampleBlockObject(ctypes.Structure):
_pack_ = 1
_fields_ = [
("has_buffer_Overrun", wintypes.BOOL),
("has_Error", ctypes.c_long),
("initialized", wintypes.BOOL),
("countofValidEntries", ctypes.c_long),
("countofInitilizedEntries", ctypes.c_long),
("tSample", ctypes.POINTER(ctypes.POINTER(TSampleObject))),
]


class TFifoSize(ctypes.Structure):
_pack_ = 1
_fields_ = [
("module", TModulHdl),
("taskId", ctypes.c_ushort),
("noSamples", ctypes.c_ushort),
]


class TApplicationID(ctypes.Structure):
_pack_ = 1
_fields_ = [
("tApplicationType", enum_type),
("taskId", ctypes.c_char * wintypes.MAX_PATH),
]


class TConverterInfo(ctypes.Structure):
_pack_ = 1
_fields_ = [
("Comment", ctypes.c_char * wintypes.MAX_PATH),
("Name", ctypes.c_char * wintypes.MAX_PATH),
("ID", ctypes.c_char * wintypes.MAX_PATH),
]


class SecProfileEntry(ctypes.Structure):
_pack_ = 1
_fields_ = [
("mId", ctypes.c_uint),
("mName", ctypes.c_char * wintypes.MAX_PATH),
("mDescription", ctypes.c_char * wintypes.MAX_PATH),
]
Loading

0 comments on commit b109cec

Please sign in to comment.