Sends a command and waits for the answer in parallel to other thread’s execution, allowing other thread’s to poll if the response have been received.
Parameters: |
|
---|
Note
Notice the command is sent when the object is created.
A property for retrieving the response object generated by the command.
This property should be used when sending is False.
A property that indicates whether the object is still waiting for a response.
from pyrobotics import BB
from pyrobotics.parallel_senders import ParallelSender as PS
from otherModule import fastCommand, slowCommand
function_map = {
'fast_command': fastCommand,
'slow_command': slowCommand
def initialize():
global function_map
BB.Initialize(2000, function_map)
BB.Start()
BB.SetReady()
def main():
initialize()
p = PS(Command('command_name', 'command_params'), 3000)
while p.sending:
#do something
print 'sending message...'
if not p.response:
print 'Sending failed, probably timed out.'
return
if p.response.result:
print 'command was successful!'
else:
print 'command execution was UNsuccessful!'}
BB.Wait()
if __name__ == '__main__':
main()