Skip to content
yoh-there edited this page Apr 18, 2019 · 5 revisions

While the entire internal data flow is hidden and your activity can either rely on CanzeActivity for handling when it comes to widgets, or you can pick up the data yourself through a listener, sometimes you want to know how on earth the data "gets there". Here is what happens.

The Device object starts a background Thread looping through the requests to be carried out. The specific device implementation (i.e. ELM) fetches the data, and formats it into a Message object. Note: an activity can ask the Device to stop the looping and perform queries in real time, but this is only used for testing and diagnosing.

The message object is passed to onMessageCompleteEvent in the Fields class. This method will update the values of the field(s) that are being fed through this message using the setValue method of the respective Field object.

A call to the setValue method will call the notifyFieldListeners method in the same Field object.

notifyFieldListeners will call the onFieldUpdateEvent of your activity with a Field object as parameter. And this event is what you should handle! There is some optimization so that if a Message comes in with more than one value for which there are listeners attached, your onFieldUpdateEvent will be called for all relevant fields contained in that Message.