示例#1
0
文件: Nodes.py 项目: ximarx/icse-ie
    def leftActivation(self, tok, wme):

        #assert isinstance(wme, WME), \
        #    "wme non e' un WME"
        
        # se il token viene da un dummyjoinnode
        # devo provvedere a convertirlo?
        new_token = Token(self, tok, wme)
        
        #self._items.insert(0, new_token)
        self._items[new_token] = new_token
        
        for w in self._amem.get_items():
            if self._perform_tests(w, new_token):
                njr = NegativeJoinResult(new_token, w)
                
                new_token.add_njresult(njr)
                w.add_njresult(njr)
                
        # attiva solo se non ci sono match (e' un nodo negativo)
        if new_token.count_njresults() == 0 :
            for child in self._children:
                assert isinstance(child, ReteNode), \
                    "child non e' un ReteNode"
                    
                # attenzione, la leftActivation viene fornita senza la WME
                # quindi solo i join node sono preparati a riceverla?????
                # TODO refactoring
                #print child
                child.leftActivation(new_token, None)
示例#2
0
文件: Nodes.py 项目: ximarx/icse-ie
 def leftActivation(self, tok, wme):
     
     assert isinstance(tok, Token), \
         "tok non e' un Token"
         
     assert isinstance(wme, WME), \
         "wme non e' un WME"
     
     new_result = Token(self, tok, wme)
     
     # Cerchiamo il token padre di questo che possa rappresentare
     # correttamente l'owner del nuovo token.
     # risaliamo il percorso per trovare il token che e' emerso
     # dalla join della precedente condizione
     
     owner_t = tok
     owner_w = wme
     for _ in range(0, self._conjuctions):
         owner_w = owner_t.get_wme()
         owner_t = owner_t.get_parent()
     
     # cerchiamo per un token nella memoria del nodo ncc
     # che abbia gia come owner owner_t trovato e
     # come wme l'wme trovato
     for ncc_token in self._nccnode.get_items():
         assert isinstance(ncc_token, Token)
         if ncc_token.get_parent() == owner_t \
                 and ncc_token.get_wme() == owner_w:
             
             # c'e' ne gia uno
             # aggiungiamo new_result come 
             # nuovo figlio ncc-result del token
             # trovato (e chiaramente colleghiamo come owner
             # l'owner trovato al nuovo result
             ncc_token.add_nccresult(new_result)
             new_result.set_owner(ncc_token)
             
             # visto che il token ha avuto un match
             # dobbiamo provvedere ad eliminare tutti
             # gli eventuali discendenti che ci sono
             # in quanto la condizione negativa
             # non e' piu valida
             
             ncc_token.deleteDescendents()
             
             # abbiamo trovato un match, non ha senso continuare
             # oltre nel ciclo (e nella funzione)
             return
     
     # non abbiamo trovato nessun match nell'ncc-node
     # questo significa che la sotto-rete negativa
     # ha trovato un match ma che il ncc-node
     # non e' ancora stato attivato
     # (in quanto ultimo dei figli del padre della sottorete)
     # memorizzo il risultato nel buffer e aspetto
     # pazientemente l'attivazione
     # del ncc-node
     #self._resultbuffer.insert(0, new_result)
     self._resultbuffer.appendleft(new_result)
示例#3
0
文件: Nodes.py 项目: ximarx/icse-ie
 def leftActivation(self, tok, wme):
     
     new_token = Token(self, tok, wme)
     #self._items.insert(0, new_token)
     self._items[new_token] = new_token
     
     results = self.get_partner().flush_resultbuffer()
     for r in results:
         assert isinstance(r, Token), \
             "r non e' un Token"
         new_token.add_nccresult(r)
         
         r.set_owner(new_token)
         
     # controllo se ho trovato match
     if new_token.count_nccresults() == 0:
         # e nel caso non ci siano attivo i figlioli
         
         for child in self.get_children():
             child.leftActivation(new_token, None)