====Daily Operational Timing Example==== ===Our Goal=== The goal is to have daily totals available for how much time has been spent with the machine //running// vs //stopped//. For our purposes, 'running' is when the machine is both **on** and **has a speed greater than 0**. ===Plan=== The plan requires a few steps... ---- 1) Figure out the start and end times for our day, \\ 2) Get the //online status// and //speed// of our line, \\ 3) Find all of the times when the line was running, \\ 4) Get the total time spent running (and not running) \\ ---- ===Step 1: Get Strict Days=== This step gets the last 24 hours up to 6:00AM in the current day. If the user chooses to run this analytic over many days, it will be broken up into 24-hour batches. { "type": "get_day", "upto": "06:00", "comment": "Get The Full Day Span" } ===Step 2: Get the Running Status & Speed=== For each day, we need to get the history of machine status and speed. { "type": "get_query", "query": "'Line' ASSET ('Status - Online','Speed') PROPERTY VALUES", "samples": 1000, "comment": "Get Line Raw Data" } ===Step 3: Break into Time Frames=== Next, we want to break our time into smaller time frames where the line was running. { "type": "timeframes", "condition": "({Line.Status - Online} > 0) && ({Line.Speed} > 0)", "comment": "Find Running Windows" } ===Step 4: Calculate Time Totals=== Finally, we calculate how much of the //total time// has been spent inside these running times. { "type": "timesummary", "inside": "Running", "comment": "Calculate Final Running Times" } ===Full JSON=== { "name": "Daily Painting KPIs", "uniqueid": "{Date}", "keys": ["Painting Percentage","Not Painting Percentage"], "date": "StartTime", "steps": [ { "type": "get_day", "upto": "06:00", "comment": "Get The Full Day Span" }, { "type": "get_query", "query": "'Line' ASSET ('Status - Online','Speed') PROPERTY VALUES", "samples": 1000, "comment": "Get Line Raw Data" }, { "type": "timeframes", "condition": "({Line.Status - Online} > 0) && ({Line.Speed} > 0)", "inside": "Running", "comment": "Find Running Windows" }, { "type": "timesummary", "inside": "Running", "comment": "Calculate Final Running Times" } ] }