FraunhoferCESE / madcap-analysis

Apache License 2.0
0 stars 1 forks source link

Add "Screen On/Off" probe as a bar to the ForegroundProbe timeline at the top #143

Open llayman opened 7 years ago

llayman commented 7 years ago

We should know when the user's screen is on/off for the ForegroundProbe timeline. Perhaps the simplest way would be to add a bar that is colored in when "Screen is on", and empty otherwise?

llayman commented 7 years ago

Please write the steps, in general, for implementing this for the next intern. Also, where to look.

StefanFCMD commented 7 years ago

Sure, @newIntern the algorithm can be something like this:

  1. Fetch all ScreenEntry probes for the same timeframe as you do for the other timeline bars. Make sure to also catch the first entry by timestamp BEFORE the lower bound . Otherwise, the area between midnight and the time of the first entry from the other query will not be covered by data. IMPORTANT: Make sure all your queries order the results by timestamp (This is an important thing in most algorithms of the web application by the way).

  2. Between the end of the refining of the refinedData object and the creation of the actual timeline bars, insert a for loop:

2.1 In the for loop, go through all entries in the result of the fetch from 1. 2.2 When the object at index i has the state ON, save its timestamp in a variable x. 2.3 When the object at index i has the state OFF, create the object {label: “Screen is off”, start: variable x, end: timestamp of object at index i, opaque: 100}. 2.3.1 When end is smaller than the lower bound from 1., do nothing 2.3.2 When start is smaller than the lower bound from 1. but end is higher than the lower bound from 1., set the start value to the lower bound from 1. and push the object onto refinedData.
2.3.3 Else, push the object onto refinedData as it is.

  1. For the creation of the timeline bars, Insert an if else that deals with the label “Screen is off” and advise a new colorCode variable to the objects with this label. I recommend the value 5.

  2. Directly before the rendering of the timeline, create an entry in arrayNum at index 5 with the value 5 and in array Colors at index five with the return value of the method rgb() as value. This is my idea how to do this. Feel free to change it if you want