Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins/rfid/device.py
blob: 04a82b217e39c0a32ccd5ca71e7a7052296cce30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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.
        """