cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically change the Data Change Type

Highlighted
Newbie

Dynamically change the Data Change Type

I have a situation where I ordinarily only want to log a data change when there is a change greater than a particular value. But I have a requirement that I capture data more frequently and accurately when triggered into that mode. Is it possible to change the Data Change Type / Threshold via a service from the platform? can it be done on the edge?

2 REPLIES 2

Re: Dynamically change the Data Change Type

If you have a subcription on any property Datachange Event this can be done to log the data change on that specific property  , you can get the new

data for that property as var newValue = eventData.newValue;

Old value as var oldValue = eventData.oldValue;

you can check something like

if (newValue > someVal)

{

// log the values here you can call any service Things['logdata'].Triggerlog()

}

If you have not and subcription on property Add Subcription on that property and select event as DataChange

Hope this helps

Re: Dynamically change the Data Change Type

Hi, just extending on what Nilesh mentioned you can also do this from the Edge device for this you will need to address the Aspect ​ for that property, e.g.

//Create the property definition with name, description, and baseType
PropertyDefinition property1 = new PropertyDefinition(
  "Property1",
  "Description for Property1",
  BaseTypes.BOOLEAN);

//Create an aspect collection to hold all of the different aspects
AspectCollection aspects = new AspectCollection();

//Add the dataChangeType aspect
aspects.put(Aspects.ASPECT_DATACHANGETYPE,
new StringPrimitive(DataChangeType.NEVER.name()));

//Add the dataChangeThreshold aspect
aspects.put(Aspects.ASPECT_DATACHANGETHRESHOLD, new NumberPrimitive(0.0));


//Set the aspects of the property definition


//Add the property definition to the VirtualThing

For more have a look at the Edge Help Center > Aspects of Properties