Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication with ECOS was much too slow for Rx. I assume the same g… #422

Merged
merged 2 commits into from
Dec 28, 2015

Conversation

kjlisby
Copy link
Contributor

@kjlisby kjlisby commented Dec 28, 2015

…oes for any other direct use of AbstractMRTrafficController.

The fix is not to block the UI thread each time a packet is received from ECOS.

…oes for any other direct use of AbstractMRTrafficController.

The fix is not to block the UI thread each time a packet is received from ECOS.
@pabender
Copy link
Member

This change fundamentally changes the behavior of the AbstractMRTrafficController, and should not be merged.

If you need to make this change for ECOS specifically, override handleOneIncommingReply in the ECOS specific TrafficController derived from AbstractMRTrafficController.

Paul

Sent from my iPad

On Dec 28, 2015, at 4:43 AM, kjlisby notifications@github.com wrote:

…oes for any other direct use of AbstractMRTrafficController.

The fix is not to block the UI thread each time a packet is received from ECOS.

You can view, comment on, or merge this pull request online at:

#422

Commit Summary

Communication with ECOS was much too slow for Rx. I assume the same goes for any other direct use of AbstractMRTrafficController.
File Changes

M java/src/jmri/jmrix/AbstractMRTrafficController.java (2)
Patch Links:

https://github.com/JMRI/JMRI/pull/422.patch
https://github.com/JMRI/JMRI/pull/422.diff

Reply to this email directly or view it on GitHub.

@rhwood
Copy link
Contributor

rhwood commented Dec 28, 2015

Why is this change bad (or how does this "fundamentally alter the AbstractMRTrafficController and what is wrong with doing so)?

Alternatively, should any traffic controllers that require the Swing UI be allowed to block them, override handleOneIncomingReply while allowing most traffic controllers to hand off the reply and not wait on it?

Randall Wood

On Dec 28, 2015, at 09:51, Paul Bender notifications@github.com wrote:

This change fundamentally changes the behavior of the AbstractMRTrafficController, and should not be merged.

If you need to make this change for ECOS specifically, override handleOneIncommingReply in the ECOS specific TrafficController derived from AbstractMRTrafficController.

Paul

Sent from my iPad

On Dec 28, 2015, at 4:43 AM, kjlisby notifications@github.com wrote:

…oes for any other direct use of AbstractMRTrafficController.

The fix is not to block the UI thread each time a packet is received from ECOS.

You can view, comment on, or merge this pull request online at:

#422

Commit Summary

Communication with ECOS was much too slow for Rx. I assume the same goes for any other direct use of AbstractMRTrafficController.
File Changes

M java/src/jmri/jmrix/AbstractMRTrafficController.java (2)
Patch Links:

https://github.com/JMRI/JMRI/pull/422.patch
https://github.com/JMRI/JMRI/pull/422.diff

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

@pabender
Copy link
Member

On Dec 28, 2015 10:07 AM, "Randall Wood" notifications@github.com wrote:

Why is this change bad (or how does this "fundamentally alter the
AbstractMRTrafficController and what is wrong with doing so)?

Because this is a message-response protocol and by using invoke later we
cannot ensure order of the recieved replies.

Alternatively, should any traffic controllers that require the Swing UI
be allowed to block them, override handleOneIncomingReply while allowing
most traffic controllers to hand off the reply and not wait on it?

No, because the contract with the AbstractMRTrafficController has always
been that delivery of messages to the listeners is in order. If the
default threading invokes the dispatch thread later, you cannot garantee
the messages are delivered in recieved order to the listeners.

Paul

@bobjacobsen
Copy link
Member

I agree this needs some thought. Might be good, might not.

It's not about the TrafficCintroller needing a UI. It's about which thread layout events occur on: http://jmri.sourceforge.net/help/en/html/doc/Technical/Threads.shtml

InvokeAndWait ensures that all the consequences of the layout event happen (the basic object change, eg Sensor or Turnout, plus the cascade that follows) before next going out to the layout.

That might or might not be needed. Would interleaving of those be a problem? Not clear.

But since this is a base class for lots of protocols, a bit of care is required. Paul's (@pabender) suggestion to make it ECOS-specific is a good one, I think. Then we can get some experience.

@kjlisby
Copy link
Contributor Author

kjlisby commented Dec 28, 2015

I have now made the change specific to ECOS.

@kjlisby
Copy link
Contributor Author

kjlisby commented Dec 28, 2015

As already mentioned, I have made this ECOS specific with the second commit.

But regarding the experience gaining that Bob mentions: As far as I can see, the Loconet implementation already uses invokeLater(). This is actually shown in the thread model document that Bob links to above.

So I guess there is plenty of experience with using invokeLater().

I think as many as possible should try it out now that I have prepared it for optional use.

@bobjacobsen
Copy link
Member

The LocoNet TrafficController is already working in an event-driven environment. That's not so clear in poll-response setups. For example, I'm not sure that the CMRI implementation of debouncing will be 100% reliable if responses can get interleaved. Maybe it already is, maybe it's easy to ensure that it is, but I haven't had time to do that yet.

The children of AbstractMRTrafficController are:

  • jmri.jmrix.can.AbstractCanTrafficController
  • jmri.jmrix.AbstractMRNodeTrafficController (which has seven systems as children of its own)
  • jmri.jmrix.dcc4pc.Dcc4PcTrafficController
  • jmri.jmrix.dccpp.DCCppTrafficController
  • jmri.jmrix.easydcc.EasyDccTrafficController
  • jmri.jmrix.ecos.EcosTrafficController
  • jmri.jmrix.jmriclient.JMRIClientTrafficController
  • jmri.jmrix.jmriclient.JMRIClientTrafficController
  • jmri.jmrix.marklin.MarklinTrafficController
  • jmri.jmrix.nce.NceTrafficController
  • jmri.jmrix.rfid.RfidTrafficController
  • jmri.jmrix.powerline.SerialTrafficController
  • jmri.jmrix.tmcc.SerialTrafficController
  • jmri.jmrix.srcp.SRCPTrafficController
  • jmri.jmrix.tams.TamsTrafficController
  • jmri.jmrix.lenz.XNetTrafficController
  • jmri.jmrix.roco.z21.z21TrafficController

and some of those have connection-specific subclasses.

Thanks for moving the change into the ECOS-specific code so what people can try it out. With your work, ECOS is likely to get some more usage, which is good.

I think it would be good to look through the code in a couple others and see if there's anything that indicates a problem. I'll check C/MRI. Then we can make the change in a couple more systems early in this release cycle, and see what emerges. I've opened issue #434 for further discussion.

bobjacobsen added a commit that referenced this pull request Dec 28, 2015
Communication with ECOS was much too slow for Rx. I assume the same g…
@bobjacobsen bobjacobsen merged commit ab1468e into JMRI:master Dec 28, 2015
@pabender
Copy link
Member

Sent from my iPad

On Dec 28, 2015, at 5:49 PM, Bob Jacobsen notifications@github.com wrote:

The LocoNet TrafficController is already working in an event-driven environment. That's not so clear in poll-response setups. For example, I'm not sure that the CMRI implementation of debouncing will be 100% reliable if responses can get interleaved. Maybe it already is, maybe it's easy to ensure that it is, but I haven't had time to do that yet.

I can pretty much guarantee interleaved responses will create issues with turnouts on XPressNet systems. This may also cause issues with automatic error recovery. ( The issue with XPressNet in these cases is that the responses just indicate success or failure ( with a cause ) but not the message being replied to. )

The z21 code will suffer similar issues because the Roco systems are derived from systems Lenz created for Roco.

Paul

@bobjacobsen bobjacobsen added this to the 4.3.1 milestone Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants