Calculation task (wrong calculation method coded)

Paul G 4 years ago in bOS Configurator 0

The calculation task does not work when both inputs change at the same time and the output of such input is used for further calculation, this is because the Calculation function, as explained in the manual, and confirmed by the trace log, runs a calculation immediately when one of the parameters in the polynom changes. 

Effectively, because in practice the two variables of the polynom do not effectively get updated at the same time, there are a few seconds of difference, probably because bOS serialises tasks rather than parallelise them, then this yields to errors. In summary do not use the calculation task is the variables change at the same time because you will get wrong calculation. This is an interesting bug.....

Example, a water line running a main pipe split in two branches, you do not need three water counters, but just two to know the water consumption of the two branches and the total.

Total water counter A

Partial water counter B

Partial water counter C, the result of subtracting A-B

what bOS incorrectly does

KNX water counter A

KNX water counter B

Calculation task C, which is the result of A-B

When water is used in one of the branches, let's say branch B, then two counters get updated, counter A and counter B, because the counter update do not happen at the same time, but serialised as done by bOS then the sequence is as followed

a) Counter A updated

b) Counter C calculated because one of the variables in polynom changes

c) Counter B updated

d) Counter C calculated again because one of the variables in polynom changes

Because C has changed twice, then if you use the ouput of the calculation as input to a CounterLog, then you will get disastrous results in your Counterlog, the counter log will take the incorrect value calculated in step b as an input, hence contaminating the counterlog. 

Because there is no documentation of this, it has taken a significant amount of time to find the root cause that was driving my CounterLog to go nuts, it is just bad this situation happens and it is not documented anywhere. I assume not many integrator are using calculation tasks because to me this is very basic