|
| 1 | +#ifndef _OBJECT_DEVICE_SETTINGS_H_ |
| 2 | +#define _OBJECT_DEVICE_SETTINGS_H_ |
| 3 | + |
| 4 | +#include <Python.h> |
| 5 | +#include <structmember.h> |
| 6 | +#if (defined(_WIN32) || defined(__WIN32__)) |
| 7 | + #ifndef USING_STUDIO_8 |
| 8 | + #define USING_STUDIO_8 1 |
| 9 | + #endif |
| 10 | + #include <icsnVC40.h> |
| 11 | +#else |
| 12 | + #include <icsnVC40.h> |
| 13 | +#endif |
| 14 | + |
| 15 | +#include "defines.h" |
| 16 | +#include "object_fire_settings.h" |
| 17 | +//#include "object_fire_vnet_settings.h" |
| 18 | +#include "object_cyan_settings.h" |
| 19 | +#include "object_vcan3_settings.h" |
| 20 | +#include "object_rad_galaxy_settings.h" |
| 21 | +//#include "object_rad_star2_settings.h" |
| 22 | +//#include "object_vcan4_settings.h" |
| 23 | +#include "object_vcan412_settings.h" |
| 24 | +//#include "object_neoecu_avb_settings.h" |
| 25 | +//#include "object_rad_supermoon_settings.h" |
| 26 | +//#include "object_rad_moon2_settings.h" |
| 27 | +#include "object_vividcan_settings.h" |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +#define DEVICE_SETTINGS_OBJECT_NAME "DeviceSettings" |
| 32 | + |
| 33 | +#if PY_MAJOR_VERSION < 3 |
| 34 | +#define PyUnicode_CompareWithASCIIString(uni, string) strcmp(PyString_AsString(uni), string) |
| 35 | +#endif |
| 36 | + |
| 37 | + |
| 38 | +typedef struct { |
| 39 | + PyObject_HEAD |
| 40 | + PyObject* fire; |
| 41 | + PyObject* firevnet; |
| 42 | + PyObject* cyan; |
| 43 | + PyObject* vcan3; |
| 44 | + PyObject* radgalaxy; |
| 45 | + PyObject* radstar2; |
| 46 | + PyObject* vcan4; |
| 47 | + PyObject* vcan4_12; |
| 48 | + PyObject* vividcan; |
| 49 | + |
| 50 | + SDeviceSettings s; |
| 51 | +} device_settings_object; |
| 52 | + |
| 53 | +#if 0 |
| 54 | +typedef struct _SDeviceSettings |
| 55 | +{ |
| 56 | + EDeviceSettingsType DeviceSettingType; |
| 57 | + union { |
| 58 | + SFireSettings fire; |
| 59 | + SFireVnetSettings firevnet; |
| 60 | + SCyanSettings cyan; |
| 61 | + SVCAN3Settings vcan3; |
| 62 | + SRADGalaxySettings radgalaxy; |
| 63 | + SRADStar2Settings radstar2; |
| 64 | + SVCAN4Settings vcan4; |
| 65 | + VCAN412Settings vcan4_12; |
| 66 | + SVividCANSettings vividcan; |
| 67 | + // |
| 68 | + // add new settings type for each new settings structure in the union |
| 69 | + // |
| 70 | + } Settings; |
| 71 | +} SDeviceSettings; |
| 72 | + |
| 73 | +#endif |
| 74 | +static PyMemberDef device_settings_object_members[] = { |
| 75 | + |
| 76 | + { "DeviceSettingType", T_ULONG, offsetof(device_settings_object, s.DeviceSettingType), 0, "" }, |
| 77 | + { "fire", T_OBJECT_EX, offsetof(device_settings_object, fire), 0, MODULE_NAME "." FIRE_SETTINGS_OBJECT_NAME" Object" }, |
| 78 | + //{ "firevnet", T_OBJECT_EX, offsetof(device_settings_object, firevnet), 0, MODULE_NAME "." FIREVNET_SETTINGS_OBJECT_NAME" Object" }, |
| 79 | + { "cyan", T_OBJECT_EX, offsetof(device_settings_object, cyan), 0, MODULE_NAME "." CYAN_SETTINGS_OBJECT_NAME" Object" }, |
| 80 | + { "vcan3", T_OBJECT_EX, offsetof(device_settings_object, vcan3), 0, MODULE_NAME "." VCAN3_SETTINGS_OBJECT_NAME" Object" }, |
| 81 | + { "radgalaxy", T_OBJECT_EX, offsetof(device_settings_object, radgalaxy), 0, MODULE_NAME "." RADGALAXY_SETTINGS_OBJECT_NAME" Object" }, |
| 82 | + //{ "radstar2", T_OBJECT_EX, offsetof(device_settings_object, radstar2), 0, MODULE_NAME "." RADSTAR2_SETTINGS_OBJECT_NAME" Object" }, |
| 83 | + //{ "vcan4", T_OBJECT_EX, offsetof(device_settings_object, vcan4), 0, MODULE_NAME "." VCAN4_SETTINGS_OBJECT_NAME" Object" }, |
| 84 | + { "vcan4_12", T_OBJECT_EX, offsetof(device_settings_object, vcan4_12), 0, MODULE_NAME "." VCAN412_SETTINGS_OBJECT_NAME" Object" }, |
| 85 | + { "vividcan", T_OBJECT_EX, offsetof(device_settings_object, vividcan), 0, MODULE_NAME "." VIVIDCAN_SETTINGS_OBJECT_NAME" Object" }, |
| 86 | + |
| 87 | + { NULL, 0, 0, 0, 0 }, |
| 88 | +}; |
| 89 | + |
| 90 | +static int device_settings_object_init(device_settings_object* self, PyObject* args, PyObject* kwds) |
| 91 | +{ |
| 92 | + // Initialize all struct values to 0 |
| 93 | + memset(&(self->s), 0, sizeof(self->s)); |
| 94 | + |
| 95 | + self->fire = PyObject_CallObject((PyObject*)&fire_settings_object_type, NULL); |
| 96 | + //self->firevnet = PyObject_CallObject((PyObject*)&firevnet_settings_object_type, NULL); |
| 97 | + self->cyan = PyObject_CallObject((PyObject*)&cyan_settings_object_type, NULL); |
| 98 | + self->vcan3 = PyObject_CallObject((PyObject*)&vcan3_settings_object_type, NULL); |
| 99 | + self->radgalaxy = PyObject_CallObject((PyObject*)&rad_galaxy_settings_object_type, NULL); |
| 100 | + //self->radstar2 = PyObject_CallObject((PyObject*)&rad_star2_settings_object_type, NULL); |
| 101 | + //self->vcan4 = PyObject_CallObject((PyObject*)&vcan4_settings_object_type, NULL); |
| 102 | + self->vcan4_12 = PyObject_CallObject((PyObject*)&vcan412_settings_object_type, NULL); |
| 103 | + self->vividcan = PyObject_CallObject((PyObject*)&vividcan_settings_object_type, NULL); |
| 104 | + |
| 105 | + return 0; |
| 106 | +} |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +extern PyTypeObject device_settings_object_type; |
| 111 | + |
| 112 | + |
| 113 | +// Copied from tupleobject.h |
| 114 | +#define PyDeviceSettings_Check(op) \ |
| 115 | + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BASETYPE) |
| 116 | +#define PyDeviceSettings_CheckExact(op) (Py_TYPE(op) == &device_settings_object_type) |
| 117 | + |
| 118 | +bool setup_device_settings_object(PyObject* module); |
| 119 | + |
| 120 | +void device_settings_object_update_from_struct(PyObject* settings); |
| 121 | +void device_settings_object_update_from_objects(PyObject* settings); |
| 122 | + |
| 123 | +#endif // _OBJECT_DEVICE_SETTINGS_H_ |
0 commit comments