Using Edge Extensions with the ThingWorx Edge C SDK > Macros for the Edge Extensions > Defining Aspects for Properties (Edge Extensions)
Defining Aspects for Properties (Edge Extensions)
Properties have a collection of aspects that you can configure on them. These macros are similar to the standard API calls but are provided for consistency:
TW_ADD_NUMBER_ASPECT(propertyName,aspectName,valuedouble)
TW_ADD_BOOLEAN_ASPECT(propertyName,aspectName,valuebool)
TW_ADD_STRING_ASPECT(propertyName,aspectName,valuestring)
Each of these macros attaches an aspect name to an existing property declared by TW_PROPERTY() and must be used in the context, {}, of a TW_MAKE_THING or TW_DECLARE_SHAPE or TW_DECLARE_TEMPLATE. The following example uses indentation for readability only:

{
TW_MAKE_THING(thingName,TW_THING_TEMPLATE_GENERIC);
TW_PROPERTY("FaultStatus", TW_NO_DESCRIPTION, TW_BOOLEAN);
TW_PROPERTY("InletValve", TW_NO_DESCRIPTION, TW_BOOLEAN);
TW_PROPERTY("Pressure", TW_NO_DESCRIPTION, TW_NUMBER);
TW_PROPERTY("Temperature", TW_NO_DESCRIPTION, TW_NUMBER);
TW_PROPERTY("TemperatureLimit", TW_NO_DESCRIPTION, TW_NUMBER);
TW_ADD_NUMBER_ASPECT("TemperatureLimit", TW_ASPECT_DEFAULT_VALUE,50.5);
TW_ADD_STRING_ASPECT("TemperatureLimit", TW_ASPECT_PUSHTYPE,PUSH_TYPE_ALWAYS );
TW_PROPERTY("TotalFlow", TW_NO_DESCRIPTION, TW_NUMBER);
TW_PROPERTY("BigGiantString", TW_NO_DESCRIPTION, TW_STRING);
TW_PROPERTY("Location", TW_NO_DESCRIPTION, TW_LOCATION);
}
All commands for adding aspects call this underlying C SDK function:

int twApi_AddAspectToProperty(char * entityName, char * propertyName,
char * aspectName, twPrimitive * aspectValue);
where the appropriate twPrimitive* value is created by the macro.
Was this helpful?