当前位置: 首页>>代码示例>>Python>>正文


Python mopak_o_dcl.MopakODclParser类代码示例

本文整理汇总了Python中mi.dataset.parser.mopak_o_dcl.MopakODclParser的典型用法代码示例。如果您正苦于以下问题:Python MopakODclParser类的具体用法?Python MopakODclParser怎么用?Python MopakODclParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MopakODclParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_long_stream_rate

 def test_long_stream_rate(self):
     """
     Test a long (normal length file) with accel and rate particles
     """
     stream_handle = open(os.path.join(RESOURCE_PATH,
                                       '20140313_191853.3dmgx3.log'))
     parser = MopakODclParser(self.config, stream_handle,
                              '20140313_191853.3dmgx3.log',
                              self.exception_callback)
     result = parser.get_records(148)
     self.assertEqual(result[0], self.particle_a11_accel)
     self.assertEqual(result[-1], self.particle_last_rate)
     self.assertEqual(self.exception_callback_value, [])
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:13,代码来源:test_mopak_o_dcl.py

示例2: test_long_stream_yml

    def test_long_stream_yml(self):
        """
        Verify an entire file against a yaml result file.
        """
        with open(os.path.join(RESOURCE_PATH, '20140120_140004.mopak.log'), 'rb') as stream_handle:
            parser = MopakODclParser(self.config, stream_handle,
                                     '20140120_140004.mopak.log',
                                     self.exception_callback)

            particles = parser.get_records(10)

            self.assert_particles(particles, 'first_mopak_recov.result.yml', RESOURCE_PATH)
            self.assertEqual(self.exception_callback_value, [])
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:13,代码来源:test_mopak_o_dcl.py

示例3: test_long_stream

    def test_long_stream(self):
        """
        Test a long (normal length file)
        """
        stream_handle = open(os.path.join(RESOURCE_PATH,
                                          '20140120_140004_extradata.mopak.log'))
        parser = MopakODclParser(self.config, stream_handle,
                                 '20140120_140004.mopak.log',
                                 self.exception_callback)

        result = parser.get_records(11964)
        self.assertEqual(result[0], self.particle_a_accel)
        self.assertEqual(result[-1], self.particle_last_accel)
        self.assertEqual(self.exception_callback_value, [])
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:14,代码来源:test_mopak_o_dcl.py

示例4: test_non_data_exception

    def test_non_data_exception(self):
        """
        Test that we get a sample exception from non data being found in the file
        """
        self.stream_handle = open(os.path.join(RESOURCE_PATH, 'noise.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)

        # next get accel records
        result = self.parser.get_records(5)
        self.assertEqual(result, [self.particle_a_accel,
                                  self.particle_b_accel,
                                  self.particle_c_accel,
                                  self.particle_d_accel,
                                  self.particle_e_accel])
        self.assertEqual(self.parser._state[StateKey.POSITION], 218)
        self.assertEqual(self.state_callback_value[StateKey.POSITION], 218)
        self.assertEqual(self.parser._state[StateKey.TIMER_START], self._timer_start)
        self.assertEqual(self.state_callback_value[StateKey.TIMER_START], self._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[0], self.particle_a_accel)
        self.assertEqual(self.publish_callback_value[1], self.particle_b_accel)
        self.assertEqual(self.publish_callback_value[2], self.particle_c_accel)
        self.assertEqual(self.publish_callback_value[3], self.particle_d_accel)
        self.assertEqual(self.publish_callback_value[4], self.particle_e_accel)
        self.assertEqual(self.file_ingested_value, True)
        self.assert_(isinstance(self.exception_callback_value, SampleException))
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:30,代码来源:test_mopak_o_dcl.py

示例5: test_set_state_rate

    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,
                     StateKey.TIMER_ROLLOVER:0,
                     StateKey.TIMER_START:self._first_rate_timer_start}
        self.stream_handle = open(os.path.join(RESOURCE_PATH,
                                               'first_rate.mopak.log'))
        self.parser =  MopakODclParser(self.config, self.start_state, self.stream_handle,
                                       '20140313_191853.3dmgx3.log',
                                       self.state_callback, self.pub_callback,
                                       self.except_callback)
        result = self.parser.get_records(1)
        self.assert_result(result, 43, self.particle_a1_accel, False, self._first_rate_timer_start)

        # set the new state, the essentially skips b accel, a rate
        self.parser.set_state(new_state)
        result = self.parser.get_records(1)
        self.assert_result(result, 148, self.particle_b_rate, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 179, self.particle_c_rate, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 210, self.particle_d_rate, True, self._first_rate_timer_start)
        self.assertEqual(self.exception_callback_value, None)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:27,代码来源:test_mopak_o_dcl.py

示例6: test_get_many

 def test_get_many(self):
     """
     Read test data and pull out multiple data particles at one time.
     Assert that the results are those we expected.
     """
     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)
     # next get accel records
     result = self.parser.get_records(5)
     self.assertEqual(result, [self.particle_a_accel,
                               self.particle_b_accel,
                               self.particle_c_accel,
                               self.particle_d_accel,
                               self.particle_e_accel])
     self.assertEqual(self.parser._state[StateKey.POSITION], 215)
     self.assertEqual(self.state_callback_value[StateKey.POSITION], 215)
     self.assertEqual(self.parser._state[StateKey.TIMER_START], self._timer_start)
     self.assertEqual(self.state_callback_value[StateKey.TIMER_START], self._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[0], self.particle_a_accel)
     self.assertEqual(self.publish_callback_value[1], self.particle_b_accel)
     self.assertEqual(self.publish_callback_value[2], self.particle_c_accel)
     self.assertEqual(self.publish_callback_value[3], self.particle_d_accel)
     self.assertEqual(self.publish_callback_value[4], self.particle_e_accel)
     self.assertEqual(self.file_ingested_value, True)
     self.assertEqual(self.exception_callback_value, None)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:31,代码来源:test_mopak_o_dcl.py

示例7: test_simple_rate

    def test_simple_rate(self):
        """
        Read test data and pull out data particles one at a time.
        Assert that the results are those we expected.
        """
        self.stream_handle = open(os.path.join(RESOURCE_PATH,
                                               'first_rate.mopak.log'))
        self.parser =  MopakODclParser(self.config, self.start_state, self.stream_handle,
                                       '20140313_191853.mopak.log',
                                       self.state_callback, self.pub_callback,
                                       self.except_callback)
        # next get accel and rate records
        result = self.parser.get_records(1)
        self.assert_result(result, 43, self.particle_a1_accel, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 86, self.particle_b1_accel, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 117, self.particle_a_rate, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 148, self.particle_b_rate, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 179, self.particle_c_rate, False, self._first_rate_timer_start)
        result = self.parser.get_records(1)
        self.assert_result(result, 210, self.particle_d_rate, True, self._first_rate_timer_start)

        # no data left, dont move the position
        result = self.parser.get_records(1)
        self.assertEqual(result, [])
        self.assertEqual(self.parser._state[StateKey.POSITION], 210)
        self.assertEqual(self.state_callback_value[StateKey.POSITION], 210)
        self.assert_(isinstance(self.publish_callback_value, list))
        self.assertEqual(self.publish_callback_value[0], self.particle_d_rate)
        self.assertEqual(self.exception_callback_value, None)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:33,代码来源:test_mopak_o_dcl.py

示例8: test_simple

    def test_simple(self):
        """
        Read test data and pull out data particles one at a time.
        Assert that the results are those we expected.
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'first.mopak.log'))
        parser = MopakODclParser(self.config, stream_handle,
                                 '20140120_140004.mopak.log',
                                 self.exception_callback)
        # next get acceleration records
        result = parser.get_records(1)
        self.assertEqual(result[0], self.particle_a_accel)
        self.assertEqual(self.exception_callback_value, [])

        result = parser.get_records(1)
        self.assertEqual(result[0], self.particle_b_accel)
        self.assertEqual(self.exception_callback_value, [])

        result = parser.get_records(1)
        self.assertEqual(result[0], self.particle_c_accel)
        self.assertEqual(self.exception_callback_value, [])

        result = parser.get_records(1)
        self.assertEqual(result[0], self.particle_d_accel)
        self.assertEqual(self.exception_callback_value, [])

        result = parser.get_records(1)
        self.assertEqual(result[0], self.particle_e_accel)
        self.assertEqual(self.exception_callback_value, [])

        # no data left, don't move the position
        result = parser.get_records(1)
        self.assertEqual(result, [])
        self.assertEqual(self.exception_callback_value, [])
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:34,代码来源:test_mopak_o_dcl.py

示例9: test_get_many

 def test_get_many(self):
     """
     Read test data and pull out multiple data particles at one time.
     Assert that the results are those we expected.
     """
     stream_handle = open(os.path.join(RESOURCE_PATH,
                                       'first.mopak.log'))
     parser = MopakODclParser(self.config, stream_handle,
                              '20140120_140004.mopak.log',
                              self.exception_callback)
     # next get accel records
     result = parser.get_records(5)
     self.assertEqual(result, [self.particle_a_accel,
                               self.particle_b_accel,
                               self.particle_c_accel,
                               self.particle_d_accel,
                               self.particle_e_accel])
     self.assertEqual(self.exception_callback_value, [])
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:18,代码来源:test_mopak_o_dcl.py

示例10: test_bad_checksum

    def test_bad_checksum(self):
        """
        This tests that the parser raises a Configuration Exception if the
        required configuration items are not present
        """

        stream_handle = open(os.path.join(RESOURCE_PATH,
                                          '20140313_191853_bad_chksum.3dmgx3.log'))

        parser = MopakODclParser(self.config, stream_handle,
                                 '20140313_191853.3dmgx3.log',
                                 self.exception_callback)

        result = parser.get_records(10)

        self.assertEqual(len(result), 5)
        self.assertEqual(len(self.exception_callback_value), 2)
        self.assert_(isinstance(self.exception_callback_value[0], SampleException))
        self.assert_(isinstance(self.exception_callback_value[1], SampleException))
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:19,代码来源:test_mopak_o_dcl.py

示例11: test_non_data_exception

    def test_non_data_exception(self):
        """
        Test that we get a sample exception from non data being found in the file
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'noise.mopak.log'))
        parser = MopakODclParser(self.config, stream_handle,
                                 '20140120_140004.mopak.log',
                                 self.exception_callback)

        # next get accel records
        result = parser.get_records(5)
        self.assertEqual(result, [self.particle_a_accel,
                                  self.particle_b_accel,
                                  self.particle_c_accel,
                                  self.particle_d_accel,
                                  self.particle_e_accel])

        self.assertEqual(len(self.exception_callback_value), 1)
        self.assert_(isinstance(self.exception_callback_value[0], SampleException))
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:19,代码来源:test_mopak_o_dcl.py

示例12: test_bad_config

    def test_bad_config(self):
        """
        This tests that the parser raises a Configuration Exception if the
        required configuration items are not present
        """

        self.stream_handle = open(os.path.join(RESOURCE_PATH,
                                               'first.mopak.log'))

        config ={}

        with self.assertRaises(ConfigurationException):
            self.parser =  MopakODclParser(config, self.start_state, self.stream_handle,
                                           '20140120_140004.mopak.log',
                                           self.state_callback, self.pub_callback,
                                           self.except_callback)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:16,代码来源:test_mopak_o_dcl.py

示例13: test_mid_state_start

 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)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:19,代码来源:test_mopak_o_dcl.py

示例14: test_long_stream

 def test_long_stream(self):
     """
     Test a long (normal length file)
     """
     self.stream_handle = open(os.path.join(RESOURCE_PATH,
                                            '20140120_140004.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(11964)
     self.assertEqual(result[0], self.particle_a_accel)
     self.assertEqual(result[-1], self.particle_last_accel)
     self.assertEqual(self.parser._state[StateKey.POSITION], 514452)
     self.assertEqual(self.state_callback_value[StateKey.POSITION], 514452)
     self.assertEqual(self.parser._state[StateKey.TIMER_START], self._timer_start)
     self.assertEqual(self.state_callback_value[StateKey.TIMER_START], self._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_accel)
     self.assertEqual(self.exception_callback_value, None)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:20,代码来源:test_mopak_o_dcl.py

示例15: test_long_stream_rate

 def test_long_stream_rate(self):
     """
     Test a long (normal length file) with accel and rate particles
     """
     self.stream_handle = open(os.path.join(RESOURCE_PATH,
                                            '20140313_191853.3dmgx3.log'))
     self.parser =  MopakODclParser(self.config, self.start_state, self.stream_handle,
                                    '20140313_191853.3dmgx3.log',
                                    self.state_callback, self.pub_callback,
                                    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)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:21,代码来源:test_mopak_o_dcl.py


注:本文中的mi.dataset.parser.mopak_o_dcl.MopakODclParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。