00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 """
00013
00014 Copyright (c) 2007, Gizmo Daemon Team
00015 Licensed under the Apache License, Version 2.0 (the "License");
00016 you may not use this file except in compliance with the License.
00017 You may obtain a copy of the License at
00018
00019 http://www.apache.org/licenses/LICENSE-2.0
00020
00021 Unless required by applicable law or agreed to in writing, software
00022 distributed under the License is distributed on an "AS IS" BASIS,
00023 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024 See the License for the specific language governing permissions and
00025 limitations under the License.
00026
00027 """
00028
00029
00030
00031
00032
00033 from GizmoDaemon import *
00034 from GizmoDeviceStrings import *
00035
00036
00037
00038
00039
00040 class GizmoDeviceClass:
00041 """
00042 This class is responsible for telling GizmoDaemon what the class
00043 of the devices are that are attached to the system. Ie, if
00044 Gizmo Daemon detects "KeyTronic Keyboard" this class should respond
00045 by setting its type to Gizmod.GizmoClass.Standard -- See the C++ API
00046 documention regarding Gizmo.hpp for a complete list (and description)
00047 of the available enums.
00048
00049 This is provided as a way of manually intervening in the device
00050 registration process. There are cases where certain devices enumerate
00051 themselves with unintuitive descriptions such as "InniTech
00052 Corp Device v.413" or <blank>.
00053
00054 There are a number of device identification fields available
00055 include product and vendor codes.
00056 """
00057
00058
00059
00060
00061
00062 def setDeviceClass(self, DeviceInfo):
00063 """
00064 Calculate the device type from the device ID info
00065
00066 For information regarding the DeviceInformation fields see the API documention for
00067 H::DeviceInfo, but the following fields are available:
00068 - DeviceIDBusType; < Bus Type of the device
00069 - DeviceIDProduct; < Product code of the device
00070 - DeviceIDVendor; < Vendor ID of the device
00071 - DeviceIDVersion; < Version of the device
00072 - DeviceName; < Name of the device
00073 - FileName < Name of the file to watch
00074 """
00075
00076
00077 if [i for i in POWERMATE_GIZMOS if DeviceInfo.DeviceName.lower().find(i) > -1]:
00078 self.DeviceClass = GizmoClass.Powermate
00079 elif [i for i in ATIX10_GIZMOS if DeviceInfo.DeviceName.lower().find(i) > -1]:
00080 self.DeviceClass = GizmoClass.ATIX10
00081 elif [i for i in LIRC_GIZMOS if DeviceInfo.DeviceName.lower().find(i) > -1]:
00082 self.DeviceClass = GizmoClass.LIRC
00083 else:
00084 self.DeviceClass = GizmoClass.Standard
00085
00086
00087
00088
00089
00090 def __init__(self, DeviceInformation):
00091 """
00092 Default Constructor
00093 """
00094
00095 self.DeviceInfo = DeviceInformation
00096 self.DeviceClass = GizmoClass.Standard
00097
00098
00099 self.setDeviceClass(self.DeviceInfo)
00100
00101
00102
00103