Skip to content

Conversation

@FreddieAkeroyd
Copy link
Member

@FreddieAkeroyd FreddieAkeroyd commented Apr 27, 2020

This is used, for example, in the simulated gamry device. It sends a "charge complete"
unsolicited message some seconds after being sent a command to "start charging".

The PR adds a unsolicited_reply() method so code like the following in the device
StreamInterface can accomplish this:

# function to send unsolicited message when charging complete
def charged(self):
    self.handler.unsolicited_reply("STOPPED")

# Device commanded to start charging
def start_charging(self):
    t = Timer(self.charging_time, self.charged)
    t.start()
    return "STARTED"

This is used in the gamry device. It sends a "charge complete"
message some seconds after being sent a command to "start charging".

This is accomplished by code similar to the following
in the device StreamInterface:

    def charged(self):
        self.handler.unsolicitedReply("STOPPED")

    def start_charging(self):
        t = Timer(self.charging_time, self.charged)
        t.start()
        return "STARTED"
@DominicOram
Copy link
Contributor

@mattclarke, would you like to take a look at this? Otherwise I'm happy to merge it.

Copy link
Contributor

@mattclarke mattclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the suggested renaming, it looks good to me

Co-authored-by: Matt Clarke <matt.clarke@ess.eu>
@mattclarke mattclarke merged commit 961957c into ISISComputingGroup:master May 5, 2020
@FreddieAkeroyd FreddieAkeroyd deleted the add_unsolicited_replies branch May 5, 2020 11:47
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.

3 participants