Here are some of my findings. I gathered them here to hopefully help 
others. I hope they are correct, but I can’t guarantee it. These are based 
on using the XType as a tag, I haven’t yet delved into direct calls from 
other services/processing. This is based on 5.0.2 plus commits up to 
3625c02.

If one raises a CannotCalculate in the XType get_scalar, for the time 
periods ‘$current’ and ‘$latest’, it will bubble up to the ‘tag’ layer 
where it will become a ‘None’ value.

For the get_aggregation, the CannotCalculate is not caught and will bubble 
all the way, causing report generation to halt. Based on the above 
behavior, I am catching any CannotCalculate from a get_scalar call and 
returning a ‘None’ value from get_aggregation.

Based on the above two observations, if get_scalar raises a CannotCalculate 
exception due to missing data that is required, a debug message is logged. 
If it is for some other reason, an error debug message is logged. Errors 
might be due to bad configuration. I’m currently looking at if it is 
possible to detect all of these at start up.

The only way to break out of the XType get_aggregation is to return a 
value. In my case the ‘sum’ aggregate does not make much sense. But if I 
don’t return a value the XTypeTable will perform it (assuming I have 
prepended my XType into the system). Since I can easily calculate the 
‘sum’, I do… (See below, I don’t think there is any benefit to my 
implementation. But its my XType and I want control… ha ha. Well it does 
stop the XType system for looking for an implementation)

Some of the aggregation types supported by XTypeTable can be ‘expensive’. 
One may/should prepend the Xtype to ‘override’ these. This is because the 
‘default’ has to loop through and calculate all the values in the interval. 
In my case, only calculating the ‘sum’ and ‘avg’ require this. Others could 
be computed after a single sql query.
 
I’ll post any other findings/ramblings/corrections I find. Hope this helps 
someone.
 rich
 

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/61b661a1-f6ae-4d12-8bd4-6ecc36e9186bn%40googlegroups.com.

Reply via email to