brata-hsdc / brata.station

Automatically exported from code.google.com/p/brata.station
Apache License 2.0
0 stars 0 forks source link

Station.start() should be called before Station.onReady() #24

Open ellerychan opened 8 years ago

ellerychan commented 8 years ago

@scortiz1, @sminster: I'm opening an issue for this so you can respond to it.

In StationLoader (main.py), the StationLoader.start() method contains the following code:

        self.State = State.READY
        self._station.start()
        self._connectionManager.startListening()

It transitions the station to the READY state, which causes the stations onReady() method to get called. Then it calls the station's start() method, which seems like the right place to put initialization code. start() should only get called once, but onReady() will get called every time the station receives a Reset message from the MS. So, I think start() should get called before the state transition to READY. I propose to change the code to this:

        self._station.start()  # initialize the station
        self.State = State.READY  # transition the station to READY state
        self._connectionManager.startListening()

Please let me know if this will break your stuff. It would also be nice to let me know if you agree.