source: trunk/hardware/driverFactory.py @ 250

Revision 250, 2.5 KB checked in by fma, 5 years ago (diff)

New driver types updated

  • Property svn:keywords set to Id
Line 
1# -*- coding: iso-8859-1 -*-
2
3""" Panohead remote control.
4
5License
6=======
7
8 - B{papywizard} (U{http://trac.gbiloba.org/papywizard}) is Copyright:
9  - (C) 2007-2008 Frédéric Mantegazza
10
11This software is governed by the B{CeCILL} license under French law and
12abiding by the rules of distribution of free software.  You can  use,
13modify and/or redistribute the software under the terms of the CeCILL
14license as circulated by CEA, CNRS and INRIA at the following URL
15U{http://www.cecill.info}.
16
17As a counterpart to the access to the source code and  rights to copy,
18modify and redistribute granted by the license, users are provided only
19with a limited warranty  and the software's author,  the holder of the
20economic rights,  and the successive licensors  have only  limited
21liability.
22
23In this respect, the user's attention is drawn to the risks associated
24with loading,  using,  modifying and/or developing or reproducing the
25software by the user in light of its specific status of free software,
26that may mean  that it is complicated to manipulate,  and  that  also
27therefore means  that it is reserved for developers  and  experienced
28professionals having in-depth computer knowledge. Users are therefore
29encouraged to load and test the software's suitability as regards their
30requirements in conditions enabling the security of their systems and/or
31data to be ensured and,  more generally, to use and operate it in the
32same conditions as regards security.
33
34The fact that you are presently reading this means that you have had
35knowledge of the CeCILL license and that you accept its terms.
36
37Module purpose
38==============
39
40Hardware driver
41
42Implements
43==========
44
45- DriverFactory
46
47@author: Frédéric Mantegazza
48@copyright: (C) 2007-2008 Frédéric Mantegazza
49@license: CeCILL
50"""
51
52__revision__ = "$Id$"
53
54from papywizard.common.exception import HardwareError
55
56
57class DriverFactory(object):
58    """ Class for creating hardware driver.
59    """
60    def create(self, type_):
61        """ create a hardware driver object.
62
63        @param type_: type of hardware object
64        @type type_: str
65
66        @raise HardwareError: unknown type
67        """
68        if type_ == "bluetooth":
69            from bluetoothDriver import BluetoothDriver
70            return BluetoothDriver()
71        elif type_ == "serial":
72            from serialDriver import SerialDriver
73            return SerialDriver()
74        elif type_ == "usb":
75            from usbDriver import USBDriver
76            return USBDriver()
77
78        else:
79            raise HardwareError("Unknow '%s' driver type" % type_)
Note: See TracBrowser for help on using the repository browser.