简体   繁体   English

如何将 ACLMessage 从在 Windows 上运行的 JADE 平台发送到在 Raspberry pi (Raspbian) 上运行的另一个 JADE 平台?

[英]How can I send an ACLMessage from a JADE Platform running on a windows to another JADE Platform running on a Raspberry pi (Raspbian)?

I am trying to have a Multi-Agent System on a distributed network (a Windows computer and a Raspberry pi with Raspbian OS installed on).我正在尝试在分布式网络(一台 Windows 计算机和一个安装了 Raspbian 操作系统的 Raspberry pi)上安装一个多代理系统。 I start my jade platform on windows using this command:我使用以下命令在 Windows 上启动我的 jade 平台:

java mylibrary jade.Boot -gui -platfrom-id Platform1 -agents starter:Starter

I also start my jade platform on Raspbian using this command:我还使用以下命令在 Raspbian 上启动我的 jade 平台:

java mylibrary jade.Boot -gui -platform-id Raspy1 -agents starter:Starter

This is Starter.java in both computers:这是两台计算机中的 Starter.java:

import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;

import java.util.Arrays;

public class Starter extends Agent {

    @Override
    protected void setup() {
        System.out.println("Setup of starter agent");

        addBehaviour(new ReceiveBehaviour());

    }

    private class ReceiveBehaviour extends CyclicBehaviour {

        @Override
        public void action() {
            ACLMessage msg = myAgent.receive();
            if (msg != null) {
                System.out.println(msg.getContent());
                System.out.println(Arrays.toString(msg.getSender().getAddressesArray()));
                ACLMessage reply = msg.createReply();
                reply.setContent("I got it. Thank you " + msg.getSender().getName());
                myAgent.send(reply);
            } else {
                block();
            }
        }
    }
}

Also, this is the mtpaddress in my windows: http://192.168.1.6:7778/acc and this is the mtpaddress on my raspbian: http://raspy1:7778/acc此外,这是在我的窗户mtpaddress: http://192.168.1.6:7778/acc ,这是对我的raspbian的mtpaddress: http://raspy1:7778/acc

Both my computers are connected to a local network (a wireless modem) using wifi.我的两台电脑都使用 wifi 连接到本地网络(无线调制解调器)。

Now what happens is that, I start my platform on both computers, start a DummyAgent on windows and try to send a message to the raspbian platform.现在发生的事情是,我在两台计算机上启动我的平台,在 Windows 上启动一个 DummyAgent 并尝试向 raspbian 平台发送消息。 So I add a receiver and put the name and address like the image所以我添加了一个接收器并把名字和地址像图片一样

below: DymmyAgent in my windows to send message to my raspberry下面:我窗口中的 DymmyAgent 向我的树莓派发送消息

and this is the console output:这是控制台输出:

Mar 06, 2020 7:45:33 PM jade.core.messaging.MessagingService deliverNow
WARNING: Cannot deliver message to address: http://raspy1:7778/acc [jade.mtp.MTPException: raspy1 - Caused by:  raspy1]. Trying the next one...
Mar 06, 2020 7:45:33 PM jade.core.messaging.MessageManager$Deliverer run
WARNING: Deliverer Thread Deliverer-4 - Delivery-time over threshold (9322). Receiver = da0, message size = 301
( (action ( agent-identifier :name starter@Platform1  :addresses (sequence http://192.168.1.6:7778/acc )) (ACLMessage) ) (MTS-error ( agent-identifier :name da0@Raspy1  :addresses (sequence http://raspy1:7778/acc )) (internal-error "Foreign agent unreachable: No valid address contained within the AID da0@Raspy1")) )
[http://192.168.1.6:7778/acc]

I can send a message from a DummyAgent on raspberry to my windows platform but the opposite way wont happen.我可以从树莓派上的 DummyAgent 向我的 Windows 平台发送消息,但相反的方式不会发生。 What can I do?我能做什么?

We are using JADE communication between different machines (Win, Linux, Mac) extensively in a distributed Smart Grid environment.我们在分布式智能电网环境中广泛使用不同机器(Win、Linux、Mac)之间的 JADE 通信。

In order to allow communication between our agents, we have setup a central agent called CEA (short for Central Exectuion Agent) that serves a communication mediator between agents.为了允许我们的代理之间进行通信,我们设置了一个名为 CEA(Central Exectuion Agent 的缩写)的中央代理,它为代理之间的通信中介提供服务。 Eg he owns and maintains a central phonebook.例如,他拥有并维护一个中央电话簿。 All agents register themselves at this CEA agent.所有代理都在此 CEA 代理处注册。 In turn, the CEA agent can provide the exact addresses of known application agents.反过来,CEA 代理可以提供已知应用程序代理的准确地址。

To register at the CEA, the agents needs to know the address of it.要在 CEA 注册,代理商需要知道它的地址。 The address contains of the agents name, the platform name, the CEA's MTP-URL and MTP-port.该地址包含代理名称、平台名称、CEA 的 MTP-URL 和 MTP-端口。 In the example below you'll find how we configure an AID, if we are on different machines.在下面的示例中,如果我们在不同的机器上,您将了解我们如何配置 AID。

 public AID getAID(){

    String ceaName = this.getAgentName();
    String platformName = this.getPlatformName();
    String mtpProtocol = this.getMtpType();
    String mtpUrl = this.getUrlOrIp();
    int mtpPort = this.getMtpPort();

    String ceaGUID = ceaName + "@" + platformName;
    String ceaMTPAddress = mtpProtocol.toLowerCase() + "://" + mtpUrl + ":" + mtpPort + "/acc";

    AID aid = new AID(ceaGUID, true);
    aid.addAddresses(ceaMTPAddress);
    return aid;
}

So the most important thing is that in contrast to local ACLMessages (send between agents on the same platform), you need to add the MTP information for the remote JADE platform to the AID.所以最重要的是,相对于本地的ACLMessages(同平台的agent之间发送),需要在AID中添加远程JADE平台的MTP信息。 I'm not sure, if the JADE visualization / UI is able to do that.我不确定 JADE 可视化/用户界面是否能够做到这一点。

With respect to the shown MTP address of your R'Pi, I doubt that the URL http://raspy1:7778/acc can be resolved in your local network (unless you have a DNS running that translates 'raspy1').关于显示的 R'Pi 的 MTP 地址,我怀疑 URL http://raspy1:7778/acc能否在您的本地网络中解析(除非您运行的 DNS 可以翻译“raspy1”)。 Better you start both platforms with specific MTP settings so that IP addresses are used instead of names (Have a look at the JADE Adminstrator's Guide).最好使用特定的 MTP 设置启动两个平台,以便使用 IP 地址而不是名称(查看 JADE 管理员指南)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM