Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

How to handle receiving a signal on a sensor? #69

Open
sphaero opened this issue May 19, 2015 · 1 comment
Open

How to handle receiving a signal on a sensor? #69

sphaero opened this issue May 19, 2015 · 1 comment
Labels

Comments

@sphaero
Copy link
Contributor

sphaero commented May 19, 2015

What's the best approach to handling a received signal on a sensor?
It seems emit_signal is called? However no signal will be emitted?

              for receiver in receivers:
                    # propagate the signal if it changes the value of this node
                    if receiver is not None and self.capability[receiver]['value'] != value:
                        self.emit_signal(receiver, value)

I could check the value of the sensor everytime I receive a message but this is inefficient...

@fieldOfView
Copy link
Contributor

A capability that wants to send ("emit") a signal (ie: tell subscribed nodes that its value has changed) calls emit_signal.

A node that receives a signal from another node implements on_peer_signaled to act on the received signal. See the definition of on_peer_signaled:
https://github.com/z25/pyZOCP/blob/master/src/zocp.py#L499

Note: nodes would not normally override emit_signal. Emit_signal is the method for sending, on_peer_signaled is the callback for receiving.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants