예제 #1
0
    def setUp(self):
        ParserUnitTestCase.setUp(self)

        self.error_callback_values = []
        self.state_callback_values = []
        self.publish_callback_values = []

        self.parser_config = {
            ParserConfigKey.ORBNAME: ParserConfigKey.ORBNAME,
            ParserConfigKey.SELECT: ParserConfigKey.SELECT,
            ParserConfigKey.REJECT: ParserConfigKey.REJECT,
        }

        self.parser_state = None

        self.PKT_ID = PKT_ID = 123
        self.PKT_TYPE = PKT_TYPE = 'GENC'
        self.PKT_DATA = PKT_DATA = 1, 2, 3, 4
        self.PKT_TIME = PKT_TIME = 999
        self.PKT_SAMPRATE = PKT_SAMPRATE = 666
        self.PKT_NET = PKT_NET = 'net'
        self.PKT_STA = PKT_STA = 'sta'
        self.PKT_CHAN = PKT_CHAN = 'chan'
        self.PKT_LOC = PKT_LOC = 'loc'

        from mi.core.kudu import _pkt
        pkt = _pkt._newPkt()
        _pkt._Pkt_pkttype_set(pkt, PKT_TYPE)
        pktchan = _pkt._newPktChannel()
        _pkt._PktChannel_data_set(pktchan, PKT_DATA)
        _pkt._PktChannel_samprate_set(pktchan, PKT_SAMPRATE)
        _pkt._PktChannel_time_set(pktchan, PKT_TIME)
        _pkt._PktChannel_net_set(pktchan, PKT_NET)
        _pkt._PktChannel_sta_set(pktchan, PKT_STA)
        _pkt._PktChannel_chan_set(pktchan, PKT_CHAN)
        _pkt._PktChannel_loc_set(pktchan, PKT_LOC)
        _pkt._Pkt_channels_set(pkt, [
            pktchan,
        ])
        pkttype, packet, srcname, time = _pkt._stuffPkt(pkt)
        _pkt._freePkt(pkt)

        with patch(
                'mi.dataset.parser.antelope_orb.OrbReapThr') as MockOrbReapThr:
            self.parser = AntelopeOrbParser(self.parser_config,
                                            self.parser_state,
                                            self.state_callback,
                                            self.pub_callback,
                                            self.error_callback)
        self.parser._orbreapthr.get = MagicMock(return_value=(PKT_ID, srcname,
                                                              time, packet))
예제 #2
0
 def _build_parser(self):
     """
     Build and return the parser
     """
     config = self._parser_config
     config.update({
         'particle_module': 'mi.dataset.parser.antelope_orb',
         'particle_class': ['AntelopeOrbPacketParticle']
     })
     log.debug("My Config: %s", config)
     log.debug("My parser state: %s", self._driver_state)
     self._parser = AntelopeOrbParser(
         config,
         self._driver_state.get(DriverStateKey.PARSER_STATE),
         self._save_parser_state,
         self._data_callback,
         self._sample_exception_callback,
     )
     return self._parser