Unable to fire Analytic over a certain type


#1

Hello all,

I defined a new Analytic with:

Simple Metric:

{
“id”: “VolumeNegative_BasePhysicalMeasurementSeries”,
“name”: “VolumeNegative”,
“srcType”: {
“moduleName”: “structure”,
“typeName”: “BasePhysicalMeasurementSeries”
},
“expression”: “fillMissing(avg(normalized.data.quantity),0)”,
“path”: “self.(measurementType == ‘MeasuredConsumptionWaterTotalNegative’)”,
“description”: “MeasuredConsumptionWaterTotalNegative MeasurementSeries”
}

Compound Metric:

{
“id”: “VolumeNegative”,
“name”: “VolumeNegative”,
“expression”: “VolumeNegative”,
“description”: “Volume Negative Alarm”
}

Simple DFE:

@DFE(period=‘QUARTER_HOUR’, grain=‘QUARTER_HOUR’, metric=‘VolumeNegative’)
type VolumeNegativeAlert mixes TSDataFlowEvent<BasePhysicalMeasurementSeries>

Compound DF:

@DFE(interval=‘QUARTER_HOUR’, period=‘QUARTER_HOUR’)
type VolumeNegativeAlertTriggered mixes CompoundDataFlowEvent<BasePhysicalMeasurementSeries> {
value : VolumeNegativeAlert
}

Analytic:

type VolumeNegativeAlertAnalytic mixes Analytic<VolumeNegativeAlertTriggered, Void> {
process : ~ js server
}

and the

function process(input) {

}

But if I try to fire the Analytic with the command:

AnalyticsContainer.fireAnalytics([{
typeId:Tag.getTypeId(‘my_tag’,‘BasePhysicalMeasurementSeries’),
objId:‘my_id’,
timeRanges: [{start: ‘2017-01-01T00:00:00’,
end:‘2019-01-01T00:00:00’}]}],
[‘VolumeNegativeAlertAnalytic’],
{forceReEval: false})

It gives me the error message:

unable to call processSource for analytic VolumeNegativeAlertAnalytic source RegisterMeasurementSeries

What is wrong with my code?
Thanks,
Aldo


#2

Hey Aldo,

A few things to check:
0. You have the Metric & DFE defined for BasePhysMeasSeries, but the error references a RegisterMeasSeries. Is there anything in your code or loaded data that could explain this? It seems odd to me.

  1. Do your metrics work? Have you run them on their own against a Series?
  2. Are you able to run this method and return the DFE Properly? Try the below snippet in static console, and post what you’re seeing, if you don’t mind.
// instantiate your process function in static console
function process(input) {
…
}

dfe = AnalyticsContainer.loadDFE(<<input parameters for your VolumeNegativeAlertTriggered DFE>>);

analyticResults = process(dfe); // where process() is your process method copied

#3

Hi Columbus,

thanks for your reply.

0: it seems weird to me too, The only thing I verified is that RegisterMeasurementSeries mixes BasePhysicalMeasurementSeries.
1: Yes, metrics works.
2: I have some diffuculty to understand this:

dfe = AnalyticsContainer.loadDFE(<<input parameters for your VolumeNegativeAlertTriggered DFE>>);

what are the input parameters?


#4

@aldo.deramo check the documentation with c3ShowFunc(AnalyticsContainer, 'loadDFE').


#5

This is what i tried but i’m sure it is wrong

dfe = AnalyticsContainer.loadDFE({
typeName:“BasePhysicalMeasurementSeries”,
source:“CTVNZ-002-ConsumoIdricoTotaleNegativo”,
start:“2017-01-01”,
options:{forceReEval=False}
})

output:

Uncaught SyntaxError: Invalid shorthand property initializer


#6

Here’s the documentation for the loadDFE() method:

Note that the source field is a Ref object in the parameters definition, as opposed to the string that you are passing in your api call. That will pose a problem. Check out the Ref Type (c3ShowType(Ref)) to dig in.

Also, forceReEval: False --> That should be a lower case false, as False will not be recognized.


#7

ok I figured out the problem, since options: [TriggerAnalyticsOptions] is an Object I have to assign values using “:” instead “=”.

the correct syntax is:

dfe = AnalyticsContainer.loadDFE(
“VolumeNegativeAlertTriggered”,
{typeName: “BasePhysicalMeasurementSeries”, id: “CTVNZ-002-ConsumoIdricoTotaleNegativo”},
“2017-01-01”,
{forceReEval: false}
)

and this is the output stored in dfe:

Now I’m able to run analyticResults = process(dfe);
So could we assume that the analytic is working?


#8

I think I figured out which is the problem.
Basically is related to the types:
BasePhysicalMeasurementSeries:

Mixes:

RegisterMeasurementSeries:

Mixes:

the MS I run is a Register (and automatically is also a BasePhysical). When I call the fireAnalytics() it looks the “lower level” type of the MS (which is Register) so I changed the metrics and the DFEs to associate them to type RegisterMeasurementSeries, and now everything works.
Thanks!