I have some problem with object type in JADE. In order to send object message to another agent I am using a method ACLMessage.setContentObject. However when I want to extract particular values/fields from the received message problem is arising.
Additionaly in sending agent I have created class to make possible sending message with object content:
class BusData implements java.io.Serializable
{
public Double current;
public Double power1;
public Double power2;
public Double voltage;
}
Receiving agent has following code (part):
data = MessageTemplate.MatchConversationId("measure");
ACLMessage data1 = receive(data); //receiving data with defined template
if (data1!=null) {
for (int i = 0; i < Agents.length; ++i) {
try {
Data1 received_data = (Data1)data1.getContentObject();
} catch (UnreadableException e) {
e.printStackTrace();}
//Serializable so = (Serializable)data1;
//System.out.println(Agents[i].getName()); //from whom received
if (data1!=null) {
System.out.println(getLocalName()+ " Info from " + data1.getSender().getName()); //from whom received
}
}
}
Should I add in receiving agent similar class, e.g. BusData1 with similar variables, like in sending agent in order to extract message content? I am quite new in Java so I am asking for understanding.
Every hint will be helpful. Regards