1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""TemperatureSensor
15
16 TemperatureSensor is an abstraction of a temperature sensor or probe.
17
18 $Id: TemperatureSensor.py,v 1.7 2004/04/06 22:33:24 edahl Exp $"""
19
20 __version__ = "$Revision: 1.7 $"[11:-2]
21
22 from Globals import InitializeClass
23
24 from Products.ZenRelations.RelSchema import *
25
26 from HWComponent import HWComponent
27
28 from Products.ZenModel.ZenossSecurity import *
29
31 """TemperatureSensor object"""
32
33 portal_type = meta_type = 'TemperatureSensor'
34
35 state = "unknown"
36
37 _properties = HWComponent._properties + (
38 {'id':'state', 'type':'string', 'mode':'w'},
39 )
40
41 _relations = HWComponent._relations + (
42 ("hw", ToOne(
43 ToManyCont, "Products.ZenModel.DeviceHW", "temperaturesensors")),
44 )
45
46
47 factory_type_information = (
48 {
49 'id' : 'TemperatureSensor',
50 'meta_type' : 'TemperatureSensor',
51 'description' : """Arbitrary device grouping class""",
52 'icon' : 'TemperatureSensor_icon.gif',
53 'product' : 'ZenModel',
54 'factory' : 'manage_addTemperatureSensor',
55 'immediate_view' : 'viewTemperatureSensor',
56 'actions' :
57 (
58 { 'id' : 'status'
59 , 'name' : 'Status'
60 , 'action' : 'viewTemperatureSensor'
61 , 'permissions' : ('View',)
62 },
63 { 'id' : 'perfConf'
64 , 'name' : 'Template'
65 , 'action' : 'objTemplates'
66 , 'permissions' : ("Change Device", )
67 },
68 { 'id' : 'viewHistory'
69 , 'name' : 'Modifications'
70 , 'action' : 'viewHistory'
71 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
72 },
73 )
74 },
75 )
76
77
79 """
80 Return the current temperature in degrees celsius
81 """
82 tempC = self.cacheRRDValue('temperature_celsius', default)
83 if tempC is None:
84 tempF = self.cacheRRDValue('temperature_fahrenheit', default)
85 if tempF is not None: tempC = (tempF - 32) / 9 * 5
86 if tempC is not None:
87 return long(tempC)
88 return None
89 temperature = temperatureCelsius
90
91
93 """
94 Return the current temperature in degrees fahrenheit
95 """
96 tempC = self.temperatureCelsius(default)
97 if tempC is not None:
98 tempF = tempC * 9 / 5 + 32
99 return long(tempF)
100 return None
101
102
104 """
105 Return the current temperature in degrees celsius as a string
106 """
107 tempC = self.temperature()
108 return tempC is None and "unknown" or "%dC" % (tempC,)
109 temperatureString = temperatureCelsiusString
110
111
113 """
114 Return the current temperature in degrees fahrenheit as a string
115 """
116 tempF = self.temperatureFahrenheit()
117 return tempF is None and "unknown" or "%dF" % (tempF,)
118
119
122 name = viewName
123
124 InitializeClass(TemperatureSensor)
125