本文整理汇总了Python中monitor.Monitor.sensorCount方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.sensorCount方法的具体用法?Python Monitor.sensorCount怎么用?Python Monitor.sensorCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.sensorCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_monitor
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import sensorCount [as 别名]
class test_monitor(TestCase):
def setUp(self):
self.cases = range(len(SERIAL_LINE))
self.mon = Monitor()
self.mon.setSerial(MockSerial, None, None)
self.mon.setThresholds(DEFAULT_THRESHOLD,INDIVIDUAL_THRESHOLDS)
def test_get_serial_data(self):
for i in self.cases:
self.assertEqual(self.mon.getDistances(),POS_LIST[i])
def test_list_closed_sensors(self):
for i in self.cases:
self.assertEqual(self.mon.getClosedSensors(),CLOSED_SENSORS[i])
def test_list_open_sensors(self):
for i in self.cases:
self.assertEqual(self.mon.getOpenSensors(),OPEN_SENSORS[i])
def test_sensor_count_too_early_raises_exception(self):
self.assertRaises(SerialNotYetPolledError, self.mon.sensorCount)
def test_list_sensor_count(self):
self.mon.readline()
self.assertEqual(len(POS_LIST[0]), self.mon.sensorCount())
def test_only_lists_one_triggered_sensor(self):
for i in self.cases:
self.assertIn(self.mon.getCurrentSensor(),[None]+self.cases)
def test_when_no_sensors_are_closed_return_none(self):
self.readMany(2)
self.assertEqual(self.mon.getCurrentSensor(),None)
def test_once_a_sensor_is_current_it_remains(self):
for i in self.cases:
self.assertEqual(self.mon.getCurrentSensor(),CURRENT_SENSOR[i])
def test_getNextSensor_blocks_until_a_sensor_closes(self):
self.readMany(7)
self.assertEqual(self.mon.getNextSensor(),CURRENT_SENSOR[10])
def test_flush_occurs_on_first_readline(self):
self.readMany(5)
self.mon.flush()
self.assertEqual(self.mon.getDistances(),POS_LIST[0])
def readMany(self, readlines):
for i in range(readlines):
self.mon.readline()
def test_can_get_previous_distances(self):
self.mon.readline()
self.assertEqual(self.mon.getPreviousDistances(),None)
self.mon.readline()
self.mon.readline()
self.assertEqual(self.mon.getPreviousDistances(),POS_LIST[1])