Esempio n. 1
0
 def send_response(self):
     pload = 'CLASS:GLOBAL;{}'.format(self.response_pload)
     u_send_response('INIT', pload)
     log(module=__name__,
         function='send_response',
         dlgid=self.dlgid,
         msg='PLOAD={0}'.format(pload))
     return
Esempio n. 2
0
 def process(self):
     '''
     El procesamiento consiste en logear el string de respuesta y enviarlo al datalogger.
     '''
     log(module=__name__, function='get_response_string', level='SELECT', dlgid=self.dlgid, msg='confPPotLevels_RSP: ({})'.format(self.response))
     pload = 'CLASS:APP_C{}'.format(self.response )
     u_send_response('INIT', pload)
     log(module=__name__, function='send_response', dlgid=self.dlgid, msg='PLOAD={0}'.format(pload))
     return
Esempio n. 3
0
    def process(self):
        '''
        El procesamiento consiste ver si en la BDSPY hay una entrada con el DLGID y el UID.
        '''
        log(module=__name__,
            function='process',
            level='SELECT',
            dlgid=self.dlgid,
            msg='dlgid={0},uid={1}'.format(self.dlgid, self.uid))
        bd = BDSPY(modo=Config['MODO']['modo'])

        if bd.dlg_is_defined(self.dlgid):
            '''
            Comprende los casos ( DLGID OK, UID OK ) y
            ( DLGID OK, UID err )
            En este ultimo, arregla en la BD el UID. 
            '''
            bd.update_uid(self.dlgid, self.uid)
            pload = 'CLASS:AUTH;STATUS:OK'
            u_send_response('INIT', pload)
            log(module=__name__,
                function='send_response',
                dlgid=self.dlgid,
                msg='PLOAD={0}'.format(pload))

        elif bd.uid_is_defined(self.uid):
            dlgid_from_bd = bd.get_dlgid_from_uid(self.uid)
            pload = 'CLASS:AUTH;STATUS:RECONF;DLGID:{}'.format(dlgid_from_bd)
            u_send_response('INIT', pload)
            log(module=__name__,
                function='send_response',
                dlgid=self.dlgid,
                msg='PLOAD={0}'.format(pload))

        else:
            '''
            No encontramos el DLGID ni un UID que permita recuperarnos.
            ERROR
            '''
            pload = 'CLASS:AUTH;STATUS:ERROR_DS'
            u_send_response('INIT', pload)
            log(module=__name__,
                function='send_response',
                dlgid=self.dlgid,
                msg='PLOAD={0}'.format(pload))

        return
Esempio n. 4
0
    def process(self):
        log(module=__name__, function='process', dlgid=self.dlgid, msg='start')

        payload_dict = u_parse_payload(self.payload_str)

        # Selector de las diferentes clases de payload
        payload_class = payload_dict.get('CLASS', 'ERROR')

        if payload_class == 'AUTH':
            '''
            Es un frame de INIT al cual debo verificarle la integridad.
            Lo debo procesar distinto ya que si hay algún problema en el DS debo
            intentar corregirlo en vez de dar error de primera.
            '''
            uid = payload_dict.get('UID', '00000')
            from SPY_init_conf_auth import INIT_CONF_AUTH
            init_conf_auth = INIT_CONF_AUTH(self.dlgid, self.version, uid)
            init_conf_auth.process()
            return

        # Leo toda la configuracion desde la BD en un dict. La leo aqui porque la necesito
        # en todos los frames de INITS.
        # Si no tengo un datasource valido salgo.

        bd = BD(modo=Config['MODO']['modo'], dlgid=self.dlgid)
        if bd.datasource == 'DS_ERROR':
            u_send_response(type='INIT', pload='STATUS:ERROR_DS')
            return

        dlgbdconf_dict = bd.read_dlg_conf()
        if dlgbdconf_dict == {}:
            log(module=__name__,
                function='process',
                dlgid=self.dlgid,
                msg='ERROR: No hay datos en la BD')
            u_send_response(type='INIT', pload='STATUS:ERROR_DICT')
            return

        # NUEVO PROTOCOLO DE INITS DEL DATALOGGER 2019-12-21.

        if payload_class == 'GLOBAL':
            from SPY_init_conf_global import INIT_CONF_GLOBAL
            init_conf_global_frame = INIT_CONF_GLOBAL(self.dlgid, self.version,
                                                      payload_dict,
                                                      dlgbdconf_dict)
            init_conf_global_frame.process()
            return

        if payload_class == 'CONF_BASE':
            from SPY_init_conf_base import INIT_CONF_BASE
            init_conf_base_frame = INIT_CONF_BASE(self.dlgid, self.version,
                                                  dlgbdconf_dict)
            init_conf_base_frame.process()
            return

        if payload_class == 'CONF_ANALOG':
            from SPY_init_conf_analog import INIT_CONF_ANALOG
            init_conf_analog_frame = INIT_CONF_ANALOG(self.dlgid, self.version,
                                                      dlgbdconf_dict)
            init_conf_analog_frame.process()
            return

        if payload_class == 'CONF_DIGITAL':
            from SPY_init_conf_digital import INIT_CONF_DIGITAL
            init_conf_digital_frame = INIT_CONF_DIGITAL(
                self.dlgid, self.version, dlgbdconf_dict)
            init_conf_digital_frame.process()
            return

        if payload_class == 'CONF_COUNTER':
            from SPY_init_conf_counter import INIT_CONF_COUNTER
            init_conf_counter_frame = INIT_CONF_COUNTER(
                self.dlgid, self.version, dlgbdconf_dict)
            init_conf_counter_frame.process()
            return

        if payload_class == 'CONF_PSENSOR':
            from SPY_init_conf_psensor import INIT_CONF_PSENSOR
            init_conf_psensor_frame = INIT_CONF_PSENSOR(
                self.dlgid, self.version, dlgbdconf_dict)
            init_conf_psensor_frame.process()
            return

        if payload_class == 'CONF_RANGE':
            from SPY_init_conf_range import INIT_CONF_RANGE
            init_conf_range_frame = INIT_CONF_RANGE(self.dlgid, self.version,
                                                    dlgbdconf_dict)
            init_conf_range_frame.process()
            return

        if payload_class == 'CONF_APP':
            from SPY_init_conf_app import INIT_CONF_APP
            init_conf_app = INIT_CONF_APP(self.dlgid, self.version,
                                          dlgbdconf_dict)
            init_conf_app.process()
            return

        if payload_class == 'CONF_PPOT_SMS':
            from SPY_init_conf_ppot_sms import INIT_CONF_PPOT_SMS
            init_conf_ppot_sms = INIT_CONF_PPOT_SMS(self.dlgid, self.version,
                                                    dlgbdconf_dict)
            init_conf_ppot_sms.process()
            return

        if payload_class == 'CONF_PPOT_LEVELS':
            from SPY_init_conf_ppot_levels import INIT_CONF_PPOT_LEVELS
            init_conf_ppot_levels = INIT_CONF_PPOT_LEVELS(
                self.dlgid, self.version, dlgbdconf_dict)
            init_conf_ppot_levels.process()
            return

        return