ThingWorx C SDK
Macros
Property Access Macros

Macros

#define TW_SET_PROPERTY(thingName, propertyName, value)   twExt_SetPropertyValue(thingName, propertyName, value,0,0)
 Set a value for a property previously declared using TW_PROPERTY. The setting of a property value does not push it to the server. It records this value change for later delivery using the TW_PUSH macro. Multiple values along with the current time set using TW_SET_PROPERTY will be stored in memory until TW_PUSH is called unless. Do not attempt to use this macro on a property not declared using TW_PROPERTY. All property change listeners will be notified of this change. More...
 
#define TW_GET_PROPERTY(thingName, propertyName)   twExt_GetPropertyValue(thingName,propertyName)->val
 Returns the current Primitive value of this property. It is up to you to select the correct field from the returned twPrimitive* which is returned. Do not attempt to use this macro on a property not declared using TW_PROPERTY. More...
 
#define TW_GET_PROPERTY_TYPE(thingName, propertyName)   twExt_GetPropertyValue(thingName,propertyName)->type
 Returns the ThingWorx Primitive type of an existing property. More...
 
#define TW_GET_STRING_PROPERTY(thingName, propertyName)   twExt_GetPropertyValue(thingName,propertyName)->val.bytes.data
 A convenience version of TW_GET_PROPERTY which always returns a String. Do not attempt to use this macro on a property not declared using TW_PROPERTY. More...
 
#define TW_PUSH_PROPERTIES_FOR(thingName, force)   twApi_PushSubscribedProperties(thingName, force);
 Delivers any property changes made with TW_SET_PROPERTY to the server. More...
 
#define TW_BIND()   twApi_BindThing(_tw_thing_name);
 Will bind a Thing definition to the ThingWorx server. Can only be used after a call to TW_MAKE_THING because it requires the variables this macro declares. Binding is the processes of informing the ThingWorx server that a Thing is supported by your application. Binding can be done with your application either connected or disconnected from the server. If done before connection, all bind messages will be consolidated into a single message to the server. If done after connection, each bind message will be sent as soon as this macro is used. More...
 

Detailed Description

Macro Definition Documentation

#define TW_BIND ( )    twApi_BindThing(_tw_thing_name);

Will bind a Thing definition to the ThingWorx server. Can only be used after a call to TW_MAKE_THING because it requires the variables this macro declares. Binding is the processes of informing the ThingWorx server that a Thing is supported by your application. Binding can be done with your application either connected or disconnected from the server. If done before connection, all bind messages will be consolidated into a single message to the server. If done after connection, each bind message will be sent as soon as this macro is used.

Parameters
thingNameconst char * [in] The name of the the Thing to Bind.
Returns
TW_OK on success. {TW_UNKNOWN_ERROR,TW_NULL_OR_INVALID_API_SINGLETON,TW_INVALID_PARAM} on failure.
#define TW_GET_PROPERTY (   thingName,
  propertyName 
)    twExt_GetPropertyValue(thingName,propertyName)->val

Returns the current Primitive value of this property. It is up to you to select the correct field from the returned twPrimitive* which is returned. Do not attempt to use this macro on a property not declared using TW_PROPERTY.

Parameters
thingNameconst char * [in] The name of the the Thing to return the property value of.
propertyNameconst char * [in] The name of the property who's value you want returned.
Returns
the ->val field of a twPrimitive*. This is useful because you can then select the apropriate field of val to get a specific C value. Example: TW_GET_PROPERTY("MyThing","propertyA").number or TW_GET_PROPERTY("MyThing","propertyA").boolean
#define TW_GET_PROPERTY_TYPE (   thingName,
  propertyName 
)    twExt_GetPropertyValue(thingName,propertyName)->type

Returns the ThingWorx Primitive type of an existing property.

Parameters
thingNameconst char * [in] The name of the the Thing to return the property type of.
propertyNameconst char * [in] The name of the property who's type you want returned.
Returns
one of the values of enum BaseType. Examples would be {TW_STRING,TW_NUMBER,TW_BOOLEAN}.
#define TW_GET_STRING_PROPERTY (   thingName,
  propertyName 
)    twExt_GetPropertyValue(thingName,propertyName)->val.bytes.data

A convenience version of TW_GET_PROPERTY which always returns a String. Do not attempt to use this macro on a property not declared using TW_PROPERTY.

Parameters
thingNameconst char * [in] The name of the the Thing to return the property value of.
propertyNameconst char * [in] The name of the property who's value you want returned.
Returns
const char* to the string Primitives ->val.bytes.data field which contains the actual string value.
#define TW_PUSH_PROPERTIES_FOR (   thingName,
  force 
)    twApi_PushSubscribedProperties(thingName, force);

Delivers any property changes made with TW_SET_PROPERTY to the server.

Parameters
thingNameconst char * [in] The name of the the Thing who's property changes have been previously set. To push all stored values use TW_PUSH_ALL_THINGS.
forcechar [in] Should a connection be established to deliver these changes if one does not already exist? Acceptable values are TW_PUSH_CONNECT_FORCE, TW_PUSH_CONNECT_LATER
Returns
TW_OK on success. {TW_UNKNOWN_ERROR,TW_SUBSCRIBED_PROPERTY_LIST_PERSISTED,TW_SUBSCRIBEDPROP_MGR_NOT_INTIALIZED, TW_PRECONDITION_FAILED} on failure.
#define TW_SET_PROPERTY (   thingName,
  propertyName,
  value 
)    twExt_SetPropertyValue(thingName, propertyName, value,0,0)

Set a value for a property previously declared using TW_PROPERTY. The setting of a property value does not push it to the server. It records this value change for later delivery using the TW_PUSH macro. Multiple values along with the current time set using TW_SET_PROPERTY will be stored in memory until TW_PUSH is called unless. Do not attempt to use this macro on a property not declared using TW_PROPERTY. All property change listeners will be notified of this change.

Parameters
thingNameconst char * [in] The name of the the Thing to apply this property change to.
propertyNameconst char * [in] The name of the property who's value you intend to change.
valuetwPrimitive * [in] The value to set this property to. This must be provided in the form of a ThingWorx Primitive. Primitives are created using one of these macros: TW_MAKE_NUMBER,TW_MAKE_INT,TW_MAKE_STRING ,TW_MAKE_BOOL,TW_MAKE_DATETIME, TW_MAKE_DATETIME_NOW,TW_MAKE_EMPTY,TW_MAKE_LOC.
Returns
TW_OK on success, {TW_NULL_OR_INVALID_API_SINGLETON,TW_INVALID_PARAM,TW_SUBSCRIBED_PROPERTY_NOT_FOUND} on failure.