Exemple #1
0
    def __init__(self, sock):
        self.logger = logging.getLogger('RemoteTargetServerHandler')
        self.command_ack_packet = None
        self.command_status_packet = None

        FasitHandler.__init__(self, sock, name='RemoteTargetServerHandler')

        device_status_request = fasit_packet_pd.FasitPacketPd()
        status_request = fasit_packet_pd.FasitPacketPd.EventCommand()
        status_request.command_id = fasit_packet_pd.EVENT_CMD_REQ_STATUS
        device_status_request.data = status_request
        self.push(device_status_request.pack())
    def event_command_handler(self):
        self.logger.info('event_command_handler()')

        pd_packet = fasit_packet_pd.FasitPacketPd(self.received_data)

        #print `pd_packet`

        try:
            self._event_cmd_to_handler[pd_packet.data.command_id](
                self, pd_packet.data)
        except (KeyError):
            self.event_cmd_default_handler()
    def audio_command_handler(self):
        self.logger.info('audio_command_handler()')

        if (self.target_type != fasit_packet_pd.PD_TYPE_SES):
            self.send_cmd_ack(ack='F')
            return

        pd_packet = fasit_packet_pd.FasitPacketPd(self.received_data)

        if (self.__device__.audio_command(
                function_code=pd_packet.data.function_code,
                track_number=pd_packet.data.track_number,
                volume=pd_packet.data.volume,
                play_mode=pd_packet.data.play_mode) == True):
            self.send_cmd_ack(ack='S')
        else:
            self.send_cmd_ack(ack='F')
    def config_muzzle_flash_handler(self):
        self.logger.info('config_muzzle_flash_handler()')

        capabilities = self.__device__.get_device_capabilities()
        if ((capabilities & fasit_packet_pd.PD_CAP_MUZZLE_FLASH) !=
                fasit_packet_pd.PD_CAP_MUZZLE_FLASH):
            self.send_cmd_ack(ack='F')
            return

        pd_packet = fasit_packet_pd.FasitPacketPd(self.received_data)
        self.__device__.configure_muzzle_flash(
            onoff=pd_packet.data.on_off,
            mode=pd_packet.data.mode,
            initial_delay=pd_packet.data.initial_delay,
            repeat_delay=pd_packet.data.repeat_delay)

        self.send_muzzle_flash_status()
Exemple #5
0
    def _process_packet(self):
        """We have read the entire packet"""
        self.logger.debug('_process_packet()')

        self.in_packet = fasit_packet.FasitPacket(self.received_data)

        self.logger.debug( ` fasit_packet_pd.FasitPacketPd(self.received_data)
                           `)

        try:
            self._msg_num_to_handler[self.in_packet.message_number](self)
        except (KeyError):
            self.default_handler()

        self.set_terminator(self.in_packet.header_length())
        self.in_packet = None
        self.received_data = ''
        self.process_data = self._process_header
    def config_miles_shootback_handler(self):
        self.logger.info('config_miles_shootback_handler()')

        capabilities = self.__device__.get_device_capabilities()
        if ((capabilities & fasit_packet_pd.PD_CAP_MILES_SHOOTBACK) !=
                fasit_packet_pd.PD_CAP_MILES_SHOOTBACK):
            self.send_cmd_ack(ack='F')
            return

        pd_packet = fasit_packet_pd.FasitPacketPd(self.received_data)

        self.__device__.configure_miles(
            basic_code=pd_packet.data.basic_miles_code,
            ammo_type=pd_packet.data.ammo_type,
            player_id=pd_packet.data.player_id,
            fire_delay=pd_packet.data.fire_delay)

        self.send_miles_shootback_status()
Exemple #7
0
 def device_status_handler(self):
     self.logger.info('device_status_handler()')
     self.command_status_packet = fasit_packet_pd.FasitPacketPd(
         self.received_data)
Exemple #8
0
 def command_ack_handler(self):
     self.logger.info('command_ack_handler()')
     self.command_ack_packet = fasit_packet_pd.FasitPacketPd(
         self.received_data)