开发者

PHP mobile data collectors

开发者 https://www.devze.com 2023-03-30 02:11 出处:网络
I work in a port company that develops software to manage port operations. I am currently developing a project for data collectors.

I work in a port company that develops software to manage port operations. I am currently developing a project for data collectors.

Data Collector is a portable device used to collect information, which will then be used in a specific system, inventory control, consumption control, reporting in general.

That's right, I am developing a software in php so that operators can manage container ports and other operations that take place in the courtyard of the 开发者_开发问答ports.

Until then I have no problem at all, but as the courtyard of a port is a place subject to much interference factor,signal loss can occur, since the application to work needs to have wi-fi connection. When it loses communication with the php server the application stops working.

We have thought about installing an apache server on each collector, but realize that this is not feasible.

So I come to ask you a suggestion as I would to save the data input by users if a possible signal loss happened.


I assume that you have at least some control over the client devices and can therefore be sure they are using a modern browser. Therefore you could use HTML5 data storage (the localStorage object in Javascript) to record the data on the client device. When they press the buttons, fill the forms or whatever, rather than uploading data to the server, write it to local storage using Javascript. When you've done that, see if you can upload the contents of local storage to the server (using Ajax). If you can, great, remove it from the local storage; if not leave it there for the next attempt.

You'll need to add a button to flush any remaining data, I think, and train them to use it on return to base, otherwise data would remain not uploaded. And that button, maybe the whole interface, would need an indication of success and maybe how much hasn't been uploaded. Or maybe have the data collection page periodically try to upload any outstanding data. The problem with that arises if they (try to) go off to some other page with data uploads outstanding - you can warn them to some extent by having a javascript event on leaving the page which can tell them "data upload outstanding". Because the storage is permanent, it is possible to even close the browser or turn the device off, and reopen the data acquisition page later when in range to complete the upload - the main issue is the human factor in making sure this does actually get done.

And also, you'll need a reliable way of checking that both ends agree the data has been uploaded. It won't be good enough to just rely on a successful response or lack of from the Ajax call, because you may never see it even if the data was successfully uploaded. One way might be to tag the data with an ID at the browser end (perhaps based on session ID and time) so that if you don't get an affirmative response from the server, you think it has failed at the browser end, but if it didn't actually fail the server has stored the id, so the same data uploaded again later will be seen as having already completed so not processed twice.

Another advantage of doing it this way is that even if you are within range but on a slow link, the user doesn't have to wait for the upload to complete before proceeding with the next data entry.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号