wxMathPlot with x-axis in milliseconds? - wxmathplot

I'm working with Sensor HID device and wxWidgets host application respectively.
Process Flow:
1.Sensor sends float value with time-stamp(in milliseconds) for every few milliseconds to seconds.
2.Host application reads the data and represents it in a chart (x-axis as time and y-axis as float value).
I'm using the mpFXYVector and mpScaleX with mpX_TIME.
If the time-stamp is in milliseconds, x-axis time ticks are not coming properly.
Kindly help me to resolve this issue.
Regards,
Rajan.M

The issue is I've passed the time value in milliseconds directly instead of converting it to seconds!
E.g. 45678 milliseconds to 45.678 seconds

Related

Google Spreadsheet time between date - hour calculation

I am at a loss, i looked around the internet and stackoverflow but every so called solution is giving either errors or plainly don't work.
I have the following setup.
4 fields (setup in date dd-mm-yyyy, hour hh:mm:ss) seconds are not important.
start date : 7-1-2020
start hour : 23:30:00
end date : 8-1-2020
end hour : 03:50:00
What i want to happen is to calculate the diffrence in 'hours, minutes' between the end and the start date, hour. But when I calculate and change the end date to lets say 09-01-2020 it does not count the extra 24h at all.
Use Text format:
=text(A3-A1+A4-A2,"[H]:MM")
You need to format the time difference as a duration using the custom format
[h]:mm
for hours and minutes
or
[h]
for whole hours.
There are some good notes on how it works in Excel here and as far as I can tell from testing it Google Sheets is the same.
Alternatively, if I read your question as wanting to drop the minutes and seconds from the times before doing the calculation, you could use
=(B3-B1)*24+hour(B4)-hour(B2)
and just format the result as a normal number.
After alot of fiddeling and this post i came to the conclusion that the main issue was not laying within the mathematical but within the format of the cell.
By default all time values in sheets are 24h max.
So the basic formula =start - end
The time format needed should be
more date time format
elapsed hours : elapsed minutes
apply
Now you should see the correct elapsed hours and minutes

Does steady_clock::now return seconds?

I am trying to figure out what the value of t is ? Is it seconds or milliseconds ? The steady_clock reference does not mention the unit used.
auto t = std::chrono::steady_clock::now() / 1000;
auto p = t/1000;
I am thinking now() returns seconds and t is in milliseconds and p is in microseconds. Let me know if I am getting this right ?
It's std::chrono::time_point<std::chrono::steady_clock> (the documentation on CppReference is generally better quality).
Guessing your next question — to convert from that to seconds you would use time_since_epoch() (the documentation has an example of extracting a dimension-free number of seconds from it), or alternatively as (now - epoch) / 1_second
Unit of value returned by std::chrono::steady_clock::now() is not defined by standard (it is general value of type std::chrono::time_point).
The resolution of the std::chrono::time_point (it stores a value of type Duration indicating the time interval from the start of the Clock's epoch) is implementation dependent (platforms/compiler), and you shouldn't rely on it.
To get a desired unit, you can easily convert the time_point to a value in seconds, milliseconds, etc. by duration casting:
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
(time_since_epoch() returns a duration representing the amount of time between *this and the clock's epoch).

Calculate Percentage From Duration Data in Graphite/Grafana

I have state change duration data between my object state in milliseconds.I am sending this data to graphite. I want to create a single stat panel which show me the percentage of the duration less than 20 seconds. How can I create it? Any idea or any similar scenario example will be useful.
myProjectName.FromStateToState.duration 10000ms
myProjectName.FromStateToState.duration 15000ms
myProjectName.FromStateToState.duration 21000ms
myProjectName.FromStateToState.duration 25000ms
myProjectName.FromStateToState.duration 30000ms
Assume for above scenario I expect my percentage should be %40. Because I have 5 duration data and 2 of them is less than 20 seconds. I am using Graphite as data source and Grafana as visualizing.
Temporary Solution
Because I couldn't get enough attention and any answer, I will add my temprorary solution to here. If I learn exact solution in the future I will post as an answer too.
Basically I created two counter like counterSuccess and counterFail. If state change duration is less than 20 seconds increase counterSuccess otherwise increase counterFail. Then get percentage of the success rate via following basic formula counterSuccess/(counterSuccess + counterFail).
Graphite commands at Grafana Panel:
A : sumSeries(myProjectName.FromStateToState.counterSuccess.count)
B : sumSeries(myProjectName.FromStateToState.counterFail.count)
C : sumSeries(#A, #B)
D : divideSeries(#A,#C)
I defined a single stat at grafana to show it as single percentage;

How to get NSEvent timestamp in milliseconds?

#property(readonly) NSTimeInterval timestamp;
denotes the time when the event occurred in seconds since system startup. I want to compare the timestamps of two events but their differences can also be in milliseconds. So, is there any way to get the timestamp of an event in milliseconds. I know I can use the methods mentioned in this SO question but would that be appropriate to use for events ?
If you want milliseconds you can multiply by 1000.0 but you can compare without multiplying. Documentation of NSTimeInterval:
typedef double NSTimeInterval;
NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.

Android-gps listener

I use this code to get gps sensor data.
mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, mlocListener);
Why does my gps icon continuously turn on and off?
2000 milliseconds is approximatley 0.0333333 seconds. In your code, you have requested for location updates every 0.0333333 seconds.
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, mlocListener);
This means for that the GPS doesn't always have to be updating itself. Thats why the GPS icon continuously turns on and off.

Resources