Pi2D2 icon indicating copy to clipboard operation
Pi2D2 copied to clipboard

Could make poll dependent on response

Open RobertGary1 opened this issue 9 years ago • 4 comments

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

-Robert

RobertGary1 avatar Dec 01 '15 05:12 RobertGary1

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 avatar Dec 01 '15 15:12 Bagarre

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.

Bagarre avatar Dec 01 '15 21:12 Bagarre

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

RobertGary1 avatar Dec 02 '15 05:12 RobertGary1

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.

Bagarre avatar Dec 02 '15 16:12 Bagarre