diff options
author | Pootle daemon <pootle@pootle.sugarlabs.org> | 2011-06-13 14:23:40 (GMT) |
---|---|---|
committer | Pootle daemon <pootle@pootle.sugarlabs.org> | 2011-06-13 14:23:40 (GMT) |
commit | 86e2111461fab98d8c188d50ec8bd0c72c527f73 (patch) | |
tree | 6976b1ce163cb60586011951d748177e3663e937 /plugins/rfid/device.py | |
parent | d0bcef61b8ca9b8ef0066a891819dba950764d40 (diff) | |
parent | c9b92a2a244430c677b2e27645a23c082c6c8188 (diff) |
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
Diffstat (limited to 'plugins/rfid/device.py')
-rw-r--r-- | plugins/rfid/device.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/rfid/device.py b/plugins/rfid/device.py new file mode 100644 index 0000000..04a82b2 --- /dev/null +++ b/plugins/rfid/device.py @@ -0,0 +1,61 @@ +import gobject + +class RFIDDevice(gobject.GObject): + """ + Ancestor class for every supported device. + The main class for the device driver must be called "RFIDReader". + """ + # signal "tag-read" has to be emitted when a tag has been read. + # The handler must receive the ISO-11784 hex value of the tag. + # signal "disconnected" has to be emitted when the device is + # unplugged or an error has been detected. + __gsignals__ = { + 'tag-read': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, + (gobject.TYPE_STRING,)), + 'disconnected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, + (gobject.TYPE_STRING,)) + } + def __init__(self): + """ + Initializer. Subclasses must call this method. + """ + self.__gobject_init__() + + def get_present(self): + """ + This method must detect if the device is present, returning True if so, + or False otherwise. + """ + raise NotImplementedError + + def get_version(self): + """ + Returns a descriptive text of the device. + """ + raise NotImplementedError + + def do_connect(self): + """ + Connects to the device. + Must return True if successfull, False otherwise. + """ + raise NotImplementedError + + def do_disconnect(self): + """ + Disconnects from the device. + """ + raise NotImplementedError + + def read_tag(self): + """ + Returns the 64 bit data in hex format of the last read tag. + """ + raise NotImplementedError + + def write_tag(self, hex_val): + """ + Could be implemented if the device is capable of writing tags. + Receives the hex value (according to ISO 11784) to be written. + Returns True if successfull or False if something went wrong. + """ |