5 #ifndef TW_C_SDK_TWMACROS_H
6 #define TW_C_SDK_TWMACROS_H
12 #define TW_THING_TEMPLATE_GENERIC "GenericEdgeThingTemplate"
13 #define TW_THING_TEMPLATE_EMPTY "EmptyTemplate"
14 #define TW_UNUSED_VARIABLE(x) ((void)x)
26 #define VAR_ARG_END NULL
41 #define TW_DECLARE_SHAPE(aThingName,shapeName,thing_namespace) const char* _tw_thing_name=aThingName;const char* _tw_thing_namespace = thing_namespace;const char* _tw_shape_name=shapeName;TW_UNUSED_VARIABLE(_tw_thing_namespace);TW_UNUSED_VARIABLE(_tw_thing_name);TW_UNUSED_VARIABLE(_tw_shape_name);
51 #define TW_SHAPE(aThingName,shapeName,thing_namespace) const char* _tw_thing_name=aThingName;const char* _tw_thing_namespace = thing_namespace;const char* _tw_shape_name=shapeName;TW_UNUSED_VARIABLE(_tw_thing_namespace);TW_UNUSED_VARIABLE(_tw_thing_name);TW_UNUSED_VARIABLE(_tw_shape_name);
61 #define TW_DECLARE_TEMPLATE(aThingName,templateName,inheritsTemplate) const char* _tw_thing_name=aThingName;const char* _tw_thing_namespace = TW_NO_NAMESPACE;const char* _tw_template_name=templateName;twExt_InheritFromTemplate(aThingName, inheritsTemplate);TW_UNUSED_VARIABLE(_tw_thing_name);TW_UNUSED_VARIABLE(_tw_thing_namespace);TW_UNUSED_VARIABLE(_tw_template_name);
70 #define TW_TEMPLATE(aThingName,templateName,inheritsTemplate) const char* _tw_thing_name=aThingName;const char* _tw_thing_namespace = TW_NO_NAMESPACE;const char* _tw_template_name=templateName;twExt_InheritFromTemplate(aThingName, inheritsTemplate);TW_UNUSED_VARIABLE(_tw_thing_name);TW_UNUSED_VARIABLE(_tw_thing_namespace);TW_UNUSED_VARIABLE(_tw_template_name);
82 #define TW_DECLARE_EVENT(eventName,eventDescription,eventDataShape) twApi_RegisterEvent(TW_THING, _tw_thing_name, eventName, eventDescription, eventDataShape);
93 #define TW_EVENT(eventName,eventDescription,eventDataShape) twApi_RegisterEvent(TW_THING, _tw_thing_name, eventName, eventDescription, eventDataShape)
112 #define TW_PROPERTY(propertyName,description,type) twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, TW_PUSH_TYPE_ALWAYS,REPORT_ALL_CHANGES)
127 #define TW_PROPERTY_LONG(propertyName,description,type,pushType,threshold) twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, pushType,threshold)
138 #define TW_ADD_NUMBER_ASPECT(propertyName,aspectName,valuedouble) twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromNumber(valuedouble))
149 #define TW_ADD_BOOLEAN_ASPECT(propertyName,aspectName,valuebool) twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromBoolean(valuebool))
161 #define TW_ADD_STRING_ASPECT(propertyName,aspectName,valuestring) twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromString(valuestring, TRUE))
181 #define TW_SET_PROPERTY(thingName, propertyName,value) twExt_SetPropertyValue(thingName, propertyName, value,0,0)
191 #define TW_GET_PROPERTY(thingName, propertyName) twExt_GetPropertyValue(thingName,propertyName)->val
199 #define TW_GET_PROPERTY_TYPE(thingName, propertyName) twExt_GetPropertyValue(thingName,propertyName)->type
208 #define TW_GET_STRING_PROPERTY(thingName, propertyName) twExt_GetPropertyValue(thingName,propertyName)->val.bytes.data
219 #define TW_PUSH_PROPERTIES_FOR(thingName,force) twApi_PushSubscribedProperties(thingName, force);
230 #define TW_BIND() twApi_BindThing(_tw_thing_name);
251 #define TW_MAKE_DATASHAPE(shapeName,firstShape,...) twDataShape_CreateFromEntries(shapeName,firstShape,##__VA_ARGS__,VAR_ARG_END)
263 #define TW_DECLARE_DS_ENTRY(fieldName,description,type) twDataShapeEntry_Create(fieldName, description, type)
275 #define TW_DS_ENTRY(fieldName,description,type) twDataShapeEntry_Create(fieldName, description, type)
298 #define TW_DECLARE_SERVICE(serviceName, description,inputShape,outputType,outputShape,serviceHandler) twExt_RegisterNamespacedService(_tw_thing_name, serviceName, _tw_thing_namespace , description, inputShape, outputType, outputShape, serviceHandler, NULL)
314 #define TW_SERVICE(serviceName, description,inputShape,outputType,outputShape,serviceHandler) twExt_RegisterNamespacedService(_tw_thing_name, serviceName, _tw_thing_namespace , description, inputShape, outputType, outputShape, serviceHandler, NULL)
323 #define TW_GET_STRING_PARAM(params,paramName) twInfoTable_GetString(params, #paramName, 0, ¶mName);
332 #define TW_GET_NUMBER_PARAM(params,paramName) twInfoTable_GetNumber(params, #paramName, 0, ¶mName);
347 #define TW_MAKE_NUMBER(numberValue) twPrimitive_CreateFromNumber((double)numberValue)
356 #define TW_MAKE_INT(intValue) twPrimitive_CreateFromInteger(intValue)
365 #define TW_MAKE_STRING(stringValue) twPrimitive_CreateFromString((char*)stringValue,TRUE)
374 #define TW_MAKE_BOOL(boolValue) twPrimitive_CreateFromBoolean(boolValue)
383 #define TW_MAKE_DATETIME(timestamp) twPrimitive_CreateFromDatetime(timestamp)
392 #define TW_MAKE_DATETIME_NOW twPrimitive_CreateFromDatetime(twGetSystemTime(TRUE))
400 #define TW_MAKE_EMPTY twPrimitive_Create()
411 #define TW_MAKE_LOC(latitude,longitude,elevation) twPrimitive_CreateFromLocationAndDelete(twCreateLocationFrom(latitude,longitude,elevation))
426 #define TW_DECLARE_IT_ROW(primitive,...) twInfoTable_CreateRowFromEntries(primitive,##__VA_ARGS__,VAR_ARG_END)
434 #define TW_IT_ROW(primitive,...) twInfoTable_CreateRowFromEntries(primitive,##__VA_ARGS__,VAR_ARG_END)
443 #define TW_MAKE_INFOTABLE(dataShape,...) twInfoTable_CreateInfoTableFromRows(dataShape,##__VA_ARGS__,VAR_ARG_END)
452 #define TW_MAKE_IT(dataShape,...) twInfoTable_CreateInfoTableFromRows(dataShape,##__VA_ARGS__,VAR_ARG_END)
467 #define TW_MAKE_THING(thingName,templateName,...) char * _tw_thing_name=thingName;const char* _tw_thing_namespace = TW_NO_NAMESPACE;twExt_CreateThingFromTemplate(thingName,templateName,##__VA_ARGS__,VAR_ARG_END);TW_UNUSED_VARIABLE(_tw_thing_namespace);TW_UNUSED_VARIABLE(_tw_thing_name)
482 #define TW_FIRE_EVENT(thingName,eventName,eventInfoTable) twApi_FireEvent(TW_THING, thingName, eventName, eventInfoTable, -1, TRUE)
494 #define TW_ADD_FILE_TRANSFER_SHAPE() twFileManager_Create()
502 #define TW_SHARE_DIRECTORY(alias,path) twFileManager_AddVirtualDir(_tw_thing_name, alias, path)
505 #endif //TW_C_SDK_TWMACROS_H