Bagarre / Pi2D2

A Raspberry Pi knock off of the Dynon D2 artificial horizon that leverages the stratux project.
20 stars 6 forks source link

Could make poll dependent on response #2

Open RobertGary1 opened 8 years ago

RobertGary1 commented 8 years ago

Sometimes the polls pile up such that some are canceled. Perhaps we could call the poll only on response of the previous request?

-Robert

Bagarre commented 8 years ago

Yeah, the polling is incredibly naive and not right. I tossed it in just to get the data from Stratux and exercise the UI. It needs a much better method. I'm open to suggestions on how to do it better.

It also needs to be able to detect when it can't get valid data so it can set the 'inop' flags on the appropriate widgets.

Its worth mentioning that www/js/test/.js is a bunch of duct tape functions.

Bagarre commented 8 years ago

https://github.com/Bagarre/Pi2D2/commit/a3216883f23db83d48723f052a8fc5c933ddcdb1

Should help. Delay is 100 microseconds since the last ajax call so they dont stack up. On success, a timestamp is set (lastPoll) and every second we check that lastPoll is no more than 3 seconds old. If it's older (meaning we can't poll and the data we have is 3 seconds old) the UI sets the widgets to INOP. On next successful poll, the screen will update and INOPs taken away.

RobertGary1 commented 8 years ago

What code is responsible for polling now? I don't see a poll now in test.js other than the INOP check. So now I just see it come up as INOP.

-Robert

Bagarre commented 8 years ago

I need to take a few hours to clean and organize things better. https://github.com/Bagarre/Pi2D2/blob/master/www/js/test.js#L22-L58 I comment that out when running on my local system. forgot to uncomment it.