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

Downtime Calculation using Stream Value

Visitor

Downtime Calculation using Stream Value

Would like to know the best practice to calculate machine downtime by running signal,

For example: running signal was collected and storage in Stream Table, data are timestamp and value 0 (stop) and 1(run)

timestamp0    :   1

timestamp1    :   0

timestamp2    :   1

timestamp3    :   0

timestamp4    :   1

....

Stop time should be: (timestamp2-timestamp1) + (timestamp4-timestamp3) + ....

What is best way to calculate/query in historian value in stream table? 

Thank you so much!

3 REPLIES 3

Re: Downtime Calculation using Stream Value

In a service, you could retrieve(and filter) the property values(Up or down) and its timestamps using QueryNumberPropertyHistory/QueryBooleanPropertyHistory into an infotable and then loop through it to calculate the up time. More details on such functions can be found here

If you are using InfluxDB for your stream, another option would be to use the ELAPSED() 
function of InfluxDB in TWX service by using InfluxDB API /query HTTP endpoint. 

Although this would be a select query, please note that in this case you are dealing directly with the database and sufficient precaution should be exercised to prevent any data corruption when directly interacting with DB.

 

I suppose in your case there will not be many data points. So, first approach should suffice. 

Highlighted

Re: Downtime Calculation using Stream Value

Hello,

 

Just to add to @rjanardan reply, depending on your access pattern you may consider precalculating those values, either at the time of inserting them, or in batch mode on the regular intervals.

 

There's no single "best practice", it really depends on multiple factors, such as:

  1. Where this data comes from, i.e. whether you have programmatic control over the input or not
  2. How much data you already have in this stream
  3. How often do you add entries to this stream
  4. What do you do with the calculated value, and if you display it, then how often
  5. Do you need this data updated immediately, or some delay won't be critical
  6. Is it a full-scale productive application or a throwaway proof-of-concept
  7. ...

Regards,
Constantine

Re: Downtime Calculation using Stream Value

Thank for the reply, my case is calculation OEE of machine (IIoT app), availability, performance are relate to downtime by running signal (we cannot implement the logic and handshaking in the controller, just read via Kepware). In additional, it will be implemented for productive application, not only a concept. Thus I want to know the best way.

The downtime can be minor or major, but the number of data I think it's not too much in one day/shift

Yes, can loop through the data if there is no better way. 

I would like to calculate every hour and store OEE data in another InfoTable and purge old data after period of time, so that i can reduce the load when clients query the OEE data.

Appreciate to hear your idea.

Thanks