本文整理汇总了Python中mi.dataset.parser.mopak_o_dcl.MopakODclParser.set_state方法的典型用法代码示例。如果您正苦于以下问题:Python MopakODclParser.set_state方法的具体用法?Python MopakODclParser.set_state怎么用?Python MopakODclParser.set_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.dataset.parser.mopak_o_dcl.MopakODclParser
的用法示例。
在下文中一共展示了MopakODclParser.set_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MopakODclParserUnitTestCase
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import set_state [as 别名]
#.........这里部分代码省略.........
self.except_callback)
result = self.parser.get_records(148)
self.assertEqual(result[0], self.particle_a11_accel)
self.assertEqual(result[-1], self.particle_last_rate)
self.assertEqual(self.parser._state[StateKey.POSITION], 5560)
self.assertEqual(self.state_callback_value[StateKey.POSITION], 5560)
self.assertEqual(self.parser._state[StateKey.TIMER_START], self._rate_long_timer_start)
self.assertEqual(self.state_callback_value[StateKey.TIMER_START], self._rate_long_timer_start)
self.assertEqual(self.parser._state[StateKey.TIMER_ROLLOVER], 0)
self.assertEqual(self.state_callback_value[StateKey.TIMER_ROLLOVER], 0)
self.assertEqual(self.publish_callback_value[-1], self.particle_last_rate)
self.assertEqual(self.exception_callback_value, None)
def test_mid_state_start(self):
"""
Test starting the parser in a state in the middle of processing
"""
new_state = {StateKey.POSITION:86,
StateKey.TIMER_ROLLOVER:0,
StateKey.TIMER_START:self._timer_start}
self.stream_handle = open(os.path.join(RESOURCE_PATH,
'first.mopak.log'))
self.parser = MopakODclParser(self.config, new_state, self.stream_handle,
'20140120_140004.mopak.log', self.state_callback, self.pub_callback,
self.except_callback)
result = self.parser.get_records(1)
self.assert_result(result, 129, self.particle_c_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 172, self.particle_d_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 215, self.particle_e_accel, True, self._timer_start)
self.assertEqual(self.exception_callback_value, None)
def test_set_state(self):
"""
Test changing to a new state after initializing the parser and
reading data, as if new data has been found and the state has
changed
"""
new_state = {StateKey.POSITION:129,
StateKey.TIMER_ROLLOVER:0,
StateKey.TIMER_START:self._timer_start}
self.stream_handle = open(os.path.join(RESOURCE_PATH,
'first.mopak.log'))
self.parser = MopakODclParser(self.config, self.start_state, self.stream_handle,
'20140120_140004.mopak.log',
self.state_callback, self.pub_callback,
self.except_callback)
result = self.parser.get_records(1)
self.assert_result(result, 43, self.particle_a_accel, False, self._timer_start)
# set the new state, the essentially skips b and c
self.parser.set_state(new_state)
result = self.parser.get_records(1)
self.assert_result(result, 172, self.particle_d_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 215, self.particle_e_accel, True, self._timer_start)
self.assertEqual(self.exception_callback_value, None)
def test_set_state_rate(self):
"""
Test changing to a new state after initializing the parser and
reading data, as if new data has been found and the state has
changed
"""
new_state = {StateKey.POSITION:117,