Closed maxpeng-apc closed 3 years ago
This is a good idea. At first, I hoped I could make a __str__()
method to be Pythonic. But the Singleton pattern that Signal adopts prevents this. So I went with a straightforward solution:
@staticmethod
def to_str(sigid):
return Signal._lookup[sigid]
Usage:
farc.Signal.to_str(farc.Signal.TIME_TICK))
I will commit this shortly.
When I debug the state machine written in
farc
package, I may print the received signal to understand what is going on. After I register a signal usingSignal.register
function, the signal is represented as an int. If I print the signal as a integer, it is difficult to understand its meaning. I propose to add a function toSignal
class for converting the signal to a string.