Thing Presence Custom Strategy: Creating a Thing to Use It
After creating a new strategy Thing, the extension can be built and imported as is, enabling you to apply this strategy to Remote Things from the reporting configuration table on those Things within the ThingWorx Platform.
Alternatively, if you have Things to create, you can create them within the extension and pre-apply the new strategy to them. This process is similar to the previous strategy Thing that was created. You will need a new Thing file in the <Project Root>/Entities/Things folder. For this example the name is "RemoteThingWithJavaStrategy", so the file name will be Things_RemoteThingWithJavaStrategy.xml and the content is shown below.
As in the previous example, you should edit the lines that specify the home mashup, the Thing name, and so on. In addition, you should edit the line that sets the reporting strategy to reflect the name of your custom strategy Thing.
The following example is a Thing implementing the Java strategy:
<?xml version="1.0" encoding="UTF-8"?>
<Entities
build="latest"
majorVersion="0"
minorVersion="0"
modelPersistenceProviderPackage="PostgresPersistenceProviderPackage"
revision="0"
schemaVersion="1040"
universal="">
<Things>
<Thing
description=""
documentationContent=""
effectiveThingPackage="RemoteThing"
enabled="true"
homeMashup=""
identifier=""
lastModifiedDate="2018-08-17T15:35:54.051Z"
name="RemoteThingWithJavaStrategy"
projectName=""
published="false"
tags=""
thingTemplate="RemoteThing"
valueStream="">
<ConfigurationTables>
<ConfigurationTable
description="Reporting Settings"
isMultiRow="false"
name="ReportingConfiguration"
ordinal="0">
<DataShape>
<FieldDefinitions>
<FieldDefinition
aspect.defaultValue="AlwaysOnReporting"
aspect.isPrimaryKey="true"
aspect.isReadOnly="false"
aspect.thingTemplate="ReportingStrategy"
baseType="THINGNAME"
description="Strategy to determine health"
name="reportingStrategy"
ordinal="0"/>
</FieldDefinitions>
</DataShape>
<Rows>
<Row>
<reportingStrategy><![CDATA[CustomStrategyJava]]>
</reportingStrategy>
</Row>
</Rows>
</ConfigurationTable>
</ConfigurationTables>
</Thing>
</Things>
</Entities>
Executing the Strategy
As of ThingWorx 8.4.0, the "isReporting" state of a Remote Thing is re-evaluated whenever the Thing binds or unbinds from the ThingWorx Platform. The "isReporting" state of a Remote Thing may also be re-evaluated at any time (for example, by a timer) by executing the EvaluateReporting service available on Remote Things.