ThingWorx C SDK
Macros
Property Declaration Macros

Macros

#define TW_PROPERTY(propertyName, description, type)   twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, TW_PUSH_TYPE_ALWAYS,REPORT_ALL_CHANGES)
 Defines a Property of A Thing. This macro must be proceeded by either TW_DECLARE_SHAPE,TW_DECLARE_TEMPLATE or TW_MAKE_THING because these macros declare variables used by the TW_PROPERTY that follow them. Note that when using TW_PROPERTY to declare a property you are accepting the use of the default property handler. This property handler will allocate and manage the storage used for this property automatically. More...
 
#define TW_PROPERTY_LONG(propertyName, description, type, pushType, threshold)   twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, pushType,threshold)
 Defines a Property of A Thing. This version of TW_PROPERTY provides more options. This macro must be proceeded by either TW_DECLARE_SHAPE,TW_DECLARE_TEMPLATE or TW_MAKE_THING because these macros declare variables used by the TW_PROPERTY that follow them. More...
 
#define TW_ADD_NUMBER_ASPECT(propertyName, aspectName, valuedouble)   twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromNumber(valuedouble))
 Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign numeric values to aspects. More...
 
#define TW_ADD_BOOLEAN_ASPECT(propertyName, aspectName, valuebool)   twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromBoolean(valuebool))
 Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign boolean values to aspects. More...
 
#define TW_ADD_STRING_ASPECT(propertyName, aspectName, valuestring)   twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromString(valuestring, TRUE))
 Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign string values to aspects. More...
 

Detailed Description

Macro Definition Documentation

#define TW_ADD_BOOLEAN_ASPECT (   propertyName,
  aspectName,
  valuebool 
)    twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromBoolean(valuebool))

Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign boolean values to aspects.

Parameters
propertyNameconst char * [in] The name of the property to apply this Aspect to.
aspectNameconst char * [in] The name of the Aspect to add to a property. Some aspects are {TW_ASPECT_ISPERSISTENT, TW_ASPECT_ISREADONLY,TW_ASPECT_DATASHAPE,TW_ASPECT_ISLOGGED,TW_ASPECT_PUSHTYPE,TW_ASPECT_DATACHANGETYPE,TW_ASPECT_DATACHANGETHRESHOLD,TW_ASPECT_ISFOLDED,TW_ASPECT_DEFAULT_VALUE}
valueboolchar [in] A boolean value to apply for this aspect. Acceptable values are {TRUE,FALSE}
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_ERROR_ALLOCATING_MEMORY,TW_INVALID_PARAM,TW_ERROR_ITEM_EXISTS} on failure
#define TW_ADD_NUMBER_ASPECT (   propertyName,
  aspectName,
  valuedouble 
)    twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromNumber(valuedouble))

Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign numeric values to aspects.

Parameters
propertyNameconst char * [in] The name of the property to apply this Aspect to.
aspectNameconst char * [in] The name of the Aspect to add to a property. Some aspects are {TW_ASPECT_ISPERSISTENT, TW_ASPECT_ISREADONLY,TW_ASPECT_DATASHAPE,TW_ASPECT_ISLOGGED,TW_ASPECT_PUSHTYPE,TW_ASPECT_DATACHANGETYPE,TW_ASPECT_DATACHANGETHRESHOLD,TW_ASPECT_ISFOLDED,TW_ASPECT_DEFAULT_VALUE}
valuedoubledouble [in] A value to apply for this aspect. Not all aspects accept all types (NUMBER,STRING,BOOLEAN)
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_ERROR_ALLOCATING_MEMORY,TW_INVALID_PARAM,TW_ERROR_ITEM_EXISTS} on failure
#define TW_ADD_STRING_ASPECT (   propertyName,
  aspectName,
  valuestring 
)    twApi_AddAspectToProperty(_tw_thing_name, propertyName, aspectName, twPrimitive_CreateFromString(valuestring, TRUE))

Aspects modify the behavior of a Property. See the ThingWorx composer for examples of available aspects of a Property. This macro is used to assign string values to aspects.

Parameters
propertyNameconst char * [in] The name of the property to apply this Aspect to.
aspectNameconst char * [in] The name of the Aspect to add to a property. Some aspects are {TW_ASPECT_ISPERSISTENT, TW_ASPECT_ISREADONLY,TW_ASPECT_DATASHAPE,TW_ASPECT_ISLOGGED,TW_ASPECT_PUSHTYPE,TW_ASPECT_DATACHANGETYPE,TW_ASPECT_DATACHANGETHRESHOLD,TW_ASPECT_ISFOLDED,TW_ASPECT_DEFAULT_VALUE}
valueboolconst char * [in] A string value to apply for this aspect.
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_ERROR_ALLOCATING_MEMORY,TW_INVALID_PARAM,TW_ERROR_ITEM_EXISTS} on failure
#define TW_PROPERTY (   propertyName,
  description,
  type 
)    twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, TW_PUSH_TYPE_ALWAYS,REPORT_ALL_CHANGES)

Defines a Property of A Thing. This macro must be proceeded by either TW_DECLARE_SHAPE,TW_DECLARE_TEMPLATE or TW_MAKE_THING because these macros declare variables used by the TW_PROPERTY that follow them. Note that when using TW_PROPERTY to declare a property you are accepting the use of the default property handler. This property handler will allocate and manage the storage used for this property automatically.

Parameters
propertyNameconst char * [in] The identifying name for this Property.
descriptionconst char * [in] An optional text description of the meaning of this event. If not provided use TW_NO_DESCRIPTION.
typetwPrimitive * [in] A ThingWorx primitive type. Use of of the enum BaseType values. Examples are {TW_STRING,TW_NUMBER,TW_BOOLEAN}
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_ERROR_ALLOCATING_MEMORY,TW_INVALID_PARAM,TW_ERROR_ITEM_EXISTS} on failure
#define TW_PROPERTY_LONG (   propertyName,
  description,
  type,
  pushType,
  threshold 
)    twExt_RegisterStandardProperty(_tw_thing_name, propertyName, _tw_thing_namespace ,type, description, pushType,threshold)

Defines a Property of A Thing. This version of TW_PROPERTY provides more options. This macro must be proceeded by either TW_DECLARE_SHAPE,TW_DECLARE_TEMPLATE or TW_MAKE_THING because these macros declare variables used by the TW_PROPERTY that follow them.

Parameters
propertyNameconst char * [in] The identifying name for this Property.
descriptionconst char * [in] An optional text description of the meaning of this event. If not provided use TW_NO_DESCRIPTION.
typetwPrimitive * [in] A ThingWorx primitive type. Use of of the enum BaseType values. Examples are {TW_STRING,TW_NUMBER,TW_BOOLEAN}
pushTypeconst char * [in] Defines a strategy for determining if your property value has changed significantly enough to warrant pushing it up to the server. Valid values are TW_PUSH_TYPE_ALWAYS,TW_PUSH_TYPE_VALUE or TW_PUSH_TYPE_NEVER.
thresholddouble [in] If your strategy set in pushType is TW_PUSH_TYPE_VALUE this is the numerical difference that must occur between the last and the current property value to consider the change significant enough to push to the server.
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_ERROR_ALLOCATING_MEMORY,TW_INVALID_PARAM,TW_ERROR_ITEM_EXISTS} on failure