本文整理匯總了Python中Data.dataAccess.Sensors.getSensor方法的典型用法代碼示例。如果您正苦於以下問題:Python Sensors.getSensor方法的具體用法?Python Sensors.getSensor怎麽用?Python Sensors.getSensor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Data.dataAccess.Sensors
的用法示例。
在下文中一共展示了Sensors.getSensor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: actuators
# 需要導入模塊: from Data.dataAccess import Sensors [as 別名]
# 或者: from Data.dataAccess.Sensors import getSensor [as 別名]
class actuators():
def __init__ (self):
self._env = Environment(self._setup_switch)
self._sensors = Sensors()
def _setup_switch(self,switch):
print "Switch found!", switch.name
def start(self):
self._env.start()
def _getName(self):
sensorName=self._env.list_switches()
return sensorName[0]
def _getNameList(self):
sensorNameList=self._env.list_switches()
return sensorNameList
def _getIdFromName(self, name):
if name=='Lamp01':
idSensor='91'
elif name=='LivingRoomLamp':
idSensor='92'
elif name=='KitchenCoffeMachine':
idSensor='93'
elif name=='LivingRoomTV':
idSensor='94'
else:
idSensor=null
return idSensor
def _getValue(self, name):
if name=='Lamp01':
idSensor='91'
elif name=='LivingRoomLamp':
idSensor='92'
elif name=='KitchenCoffeMachine':
idSensor='93'
elif name=='LivingRoomTV':
idSensor='94'
else:
idSensor=null
return self._sensors.getSensor(idSensor)
def _get_switch(self, name):
return self._env.get_switch(name)
def _on_switch(self, switch):
switch.basicevent.SetBinaryState(BinaryState=1)
def _off_switch(self, switch):
switch.basicevent.SetBinaryState(BinaryState=0)
def setOn(self, name):
self._sensors.updateSensor(self._getIdFromName(name), 1.0, 'On')
print " %s has been switched On" % name
def setOff(self, name):
self._sensors.updateSensor(self._getIdFromName(name), 0.0, 'Off')
print " %s has been switched Off" % name