本文整理汇总了Python中Data.dataAccess.Sensors.updateSensor方法的典型用法代码示例。如果您正苦于以下问题:Python Sensors.updateSensor方法的具体用法?Python Sensors.updateSensor怎么用?Python Sensors.updateSensor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.dataAccess.Sensors
的用法示例。
在下文中一共展示了Sensors.updateSensor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: actuators
# 需要导入模块: from Data.dataAccess import Sensors [as 别名]
# 或者: from Data.dataAccess.Sensors import updateSensor [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