2015-02-10 36 views
0

我正在使用JADE(Java代理開發框架),並試圖編寫一種行爲,使代理從容器移動到另一個。我試過這個命令:JADE中間件中的移動性

public void action() { 
    ACLMessage msg = myAgent.receive(template); 
    if (msg != null) { 
     moveRequest = msg; 
     String destination = 
     doMove(new ContainerID(destination, null)); 
    } 
    else { 
    block(); 
    } 
} 

但似乎我在運動失敗:

jade.core.mobility.AgentMobilityService$CommandSourceSink handleInformMoved Grave: Mobility protocol not supported. Aborting transfer 

這將是更好的,如果我得到一個完整的行爲的源代碼。
在此先感謝

+0

什麼是失敗?沒有更多信息,您的問題很難診斷 – Avery 2015-02-10 17:47:12

+0

這是顯示的故障:jade.core.mobility.AgentMobilityService $ CommandSourceSink handleInformMoved 嚴重:不支持移動協議。墮胎轉移 – steevn 2015-02-17 11:04:56

回答

0

這是啓動玉平臺代碼:

import jade.core.Profile; 
import jade.core.ProfileImpl; 
import jade.core.Runtime; 
import jade.wrapper.AgentContainer; 
import jade.wrapper.AgentController; 


public class Run { 

    public Run() { 
     Runtime rt = Runtime.instance(); 
     rt.setCloseVM(true); 
     AgentContainer mc = rt.createMainContainer(new ProfileImpl()); 

     Profile p = new ProfileImpl(); 
     p.setParameter("container-name", "Foo"); 
     AgentContainer ac = rt.createAgentContainer(p); 

     try{ 
      AgentController rma = mc.createNewAgent("rma", "jade.tools.rma.rma", null); 
      rma.start(); 
      AgentController ma = mc.createNewAgent("MA", "MobileAgent", null); 
      ma.start(); 
     } 
     catch(Exception e){ 
      e.printStackTrace(); 
     } 
    } 

    public static void main(String[] args) { 
     new Run(); 
    } 
} 

這是移動代理的代碼。代理創建後,代理立即移動到容器Foo。

import jade.core.Agent; 
import jade.core.Location; 

public class MobileAgent extends Agent { 

    private static final long serialVersionUID = 1L; 

    @Override 
    protected void setup() { 
     System.out.println("Hello World"); 
     Location destination = new jade.core.ContainerID("Foo", null); 
     doMove(destination); 
     super.setup(); 
    } 

    @Override 
    protected void beforeMove() { 
     System.out.println("Preparing to move"); 
     super.beforeMove(); 
    } 

    @Override 
    protected void afterMove() { 
     System.out.println("Arrived to destination"); 
     super.afterMove(); 
    } 
} 
+0

仍然有同樣的問題,我不知道問題出在哪裏,可能在我的plateforme本身,無論如何感謝阿尤布先生 – steevn 2015-03-04 22:16:45