示例#1
0
 def add_card(self,net_msg):        
     c_dir = net_msg.params[0]
     b_dir = net_msg.params[1]
     type = net_msg.params[2]
     
     ret_msg = NetMsg()
     channels = self.rt_core.channels
     ch_key = "Bus_%d" % b_dir        
     
     if not type in Bus.supported_card_types:
         ret_msg.error_code = -1
         ret_msg.error_msg = 'El tipo de targeta %s no existe ' % type
         return ret_msg
     
     if not ch_key in channels:
         try :
             ch = Bus(b_dir,True)
         except ChannelException, e:                    
             e.log(self.logger_instance)
             
             ret_msg.error_code = -1
             ret_msg.error_msg = 'Error: el canal %d no pudo ser creado' % b_dir
             return ret_msg            
         
         self.rt_core.add_channel(ch,False) 
         ch.start()
示例#2
0
    def set_ports(self,net_msg):
        ret_msg = NetMsg()
        
        missing_ports = []
        
        ports = net_msg.params[0]
        for p_k, p in ports.items():
            if p_k in self.rt_core.out_ports:
                self.rt_core.out_ports[p_k].set_value(p.get_value())
                print "%s %d %s" % (p_k,
                                    id(self.rt_core.out_ports[p_k]),
                                    self.rt_core.out_ports[p_k])
            if p_k in self.rt_core.in_ports:
                self.rt_core.in_ports[p_k].set_value(p.get_value())
                print "%s %d %s" % (p_k,
                                    id(self.rt_core.in_ports[p_k]),
                                    self.rt_core.in_ports[p_k])
            else:
                missing_ports.append(p_k)
                
        if not len(missing_ports):
            ret_msg.response = 'Se seteo el puerto OK'
            ret_msg.error_code = 0
        else:
            ret_msg.error_code = -1
            ret_msg.error_msg = "Se produjeron errores al setear \
los puertos %s" % string.join( missing_ports,',') 
        return ret_msg
示例#3
0
 def handle_call(self):
      self.out_data = True # None
      net_msg = self.in_data
      
      exp_methods = self.control.get_exported_methods()
      
      if net_msg.method in exp_methods :
           method_params = exp_methods[ net_msg.method ]
           if len(net_msg.params) != method_params :
                self.logger_instance.error(
                     "Error: cliente %s, metodo %s, params count (%d,%d)" % (self.client_full_address,
                                                                             net_msg.method,
                                                                             method_params,
                                                                             len(net_msg.params))
                     )
                
                res_msg = NetMsg()
                res_msg.error_core = -1
                res_msg.error_msg = 'Cantidad de parametros invalida, (%d != %d)' % (
                     method_params,
                     len(net_msg.params))                    
                
                self.out_data = res_msg
           
           self.logger_instance.debug("El cliente %s llamo al metodo %s" % (self.client_full_address,net_msg.method))
           f = eval("self.control.%s" % net_msg.method )
           self.out_data=f(net_msg)
      else:
           res_msg = NetMsg()
           res_msg.error_code = -1
           res_msg.error_msg = 'Nombre de metodo invalido (%s)' % net_msg.method
           self.out_data = res_msg
           self.logger_instance.error(
                "Error: cliente %s, el metodo %s no existe" % (self.client_full_address,
                                                               net_msg.method )
                )
             
           
      self.request_errors = 0
示例#4
0
                ch = Bus(b_dir,True)
            except ChannelException, e:                    
                e.log(self.logger_instance)
                
                ret_msg.error_code = -1
                ret_msg.error_msg = 'Error: el canal %d no pudo ser creado' % b_dir
                return ret_msg            
            
            self.rt_core.add_channel(ch,False) 
            ch.start()
        else :
            ch = channels[ch_key]
            
        if  c_dir in channels[ch_key].cards :
            ret_msg.error_code = -1
            ret_msg.error_msg = 'Error: la placa que desea agregar ya existe'
            return ret_msg                        
        
        ch.pause()
        try :
            if type == 'Digital' :
                ch.add_card( Digital(ch.channel_id,c_dir) )
            elif type == 'Analogic' :
                ch.add_card( Analogic(ch.channel_id,c_dir) )
            else:
                ch.add_card( DebugCard(ch.channel_id,c_dir) ) 
            
        except Exception, e:
            cce=ControlCoreException("No se pudo agregar la placa con \
direccion %s al bus %s, excepcion %s " % (c_dir,ch.channel_id,e.message))
            cce.log(self.logger_instance)