I am working on calculating machine uptime and downtime through VBA programming in PI Processbook.

I have a PI tag with number of filled containers. I have start and end datetime for machine runtime.

Logic is simple: As long as # of containers are rising, machine is running and duration is counted as uptime.

If any events occur during this period because of machine stops momentarily (few min to few hours), than this duration is considered downtime.

I want to calculate accumulative uptime and downtime.

Hi Mitesh,

Adding my understanding below of the requirement .

Based on the rising value of the containers you are calculating the uptime and downtime of the machine.

Can I suggest using

AF Analysisfor these calculation? we have the functions in AF that supports the time range that you are trying to achieve line TimeEq()- gives the total duration between a period that meets the criteria.I would like to understand the event for the downtime, for example the containers are not raising for certain period is considered as machine downtime.

If you want to achieve in PB, could you help me with the logic that you have created. So we can get to a better solution ?

on top level please find the solution that I would go for(considering the containers are not raising for 2 hrs as downtime).

-> two container tags, x, y

-> if previous value of x < current value of x or previous value of y < current value of y then 1 (or similar machine running state)

-> if difference between current value of x (and y) and system time is greater than 120min then 0 (downtime)

-Shibu