jade笔记(编辑修改稿)内容摘要:
is))。 }// } 按照以前记 载,在 beans 属性中加入库,然后再运行参数中,设置,主类依然为 ,参数为 baz: bob:,运行成功后,以下是输出结果: baz: about to propose marriage to bob bob: I wonder if anybody wants to marry me? bob:baz has asked me to marry him! bob:I39。 m going to agree. baz: 吼吼 ! bob 已经同意嫁给我了 , I39。 m so excited! baz:bob has informed me of the status of my request. They said : I Do! 上例中, 应用了 SimpleAchieveREInitiator 和 SimpleAchieveREResponder 两个 基类 ,适用于两个 Agent 之间的交互。 可以看出发起者对于不同的回应有不同的执行动作。 技巧:从 AMS 中获取所有 Agent 的 AID。 引用文件: import。 import .*。 调用示例: AMSAgentDescription [] agents = null。 try { SearchConstraints c = new SearchConstraints()。 (new Long(1))。 agents = ( this, new AMSAgentDescription (), c )。 } catch (Exception e) { ( Problem searching AMS: + e )。 ()。 } ACLMessage msg = new ACLMessage()。 ( Ping )。 for (int i=0。 i。 i++){ if ( agents[i].getName().equals(getAID()) ){ //如果不是自己则加入到接收者 数组中 continue。 } ( agents[i].getName() )。 } : MessageTemplate class 利用 MessageTemplate 可以针对 ACLMessage 的每个属性设置模式,以达到过滤消息的目的。 为了可以构建更复杂的匹配规则, 多 个 模式也可以进行 and,or, not运算。 最有用的一些规则或方法包括:通信行为匹配,发送者匹配,会话 ID匹配。 比如 MatchPerformative( performative ) 是 通信行为的匹配。 这里 performative 可能是 : 还有发送者匹配 MatchSender( AID ),会话匹配 MatchConversationID( String ), 通信协议匹配 MatchProtocol( String ) ,本体匹配 MatchOntology( String)。 比如 : MessageTemplate mt = ( ( ), ( new AID( a1, )))。 相当于建立了一个模板, 表示消息规则为 INFORM 行为并 且发送者为“ a1”。 接收过程如下: ACLMessage msg = receive( mt )。 if (msg != null) { ... handle message } block()。 示例: package。 import。 import。 import .*。 import .*。 public class Template extends Agent { MessageTemplate mt1 = ( ( ), ( new AID( a1,)))。 protected void setup() { // Send messages to a1 and a2 ACLMessage msg = new ACLMessage()。 ( Ping )。 for (int i = 1。 i=2。 i++) ( new AID( a + i, ) )。 send(msg)。 // Setup Behaviour 1 addBehaviour(new CyclicBehaviour(this) { public void action( ) { (Behaviour ONE: )。 ACLMessage msg= receive( mt1 )。 if (msg!=null ( gets + () + from + ().getLocalName() + = + () )。 else ( gets NULL )。 block()。 } })。 // Setup Behaviour 2 addBehaviour(new CyclicBehaviour(this) { public void action() { (Behaviour TWO: )。 ACLMessage msg= receive()。 if (msg!=null) ( gets + () + from + ().getLocalName() + = + () )。 else ( gets NULL )。 block()。 } })。 } } package。 import。 import .*。 import .*。 public class Responder extends Agent { protected void setup() { addBehaviour(new CyclicBehaviour(this) { public void action() { ACLMessage msg = receive()。 if (msg!=null) { ACLMessage reply = ()。 ( )。 ( Gossip..... )。 send(reply)。 ( )。 ( Really sexy stuff... cheap! )。 send(reply)。 } block()。 } })。 } } 输出结果: :发送消息为 java序列化对象 在 JADE 中 ,支持 agents 之间通信的消息内容使用序列化的 java对象 ,对本地应用 ,特别是所有 agent 都用 java 实现的情况下也是很有用的 . 看实例:一个 ObjectSender 负责发送一个 Person 对象, ObjectReceiver 负责接收后打印出接收到的内容。 源文件: package。 import .*。 import。 public class Person implements Serializable { String name。 String surname。 Date birthdate。 int age。 Person(String n, String s, Date d, int a) { name = n。 surname = s。 birthdate = d。 age = a。 } public String toString() { return(name+ + surname + born on +()+ age = +age)。 } } 文件 2: package。 import。 import。 import .*。 import。 public class ObjectSender extends Agent { protected void setup() { try{ ACLMessage msg = new ACLMessage()。 ( Ping )。 AID personR = new AID( personR, )。 (personR )。 Person p = new Person(Name1, Surname1, new Date(), 1)。 (p)。 (JavaSerialization)。 send(msg)。 (getLocalName()+ sent 1st msg +msg)。 send(msg)。 } catch (IOException e ) { ()。 } doDelete()。 // kill itself because it has pleted its task. } } 文件三: package。 import .*。 import。 import。 import。 public class ObjectReceiver extends Agent { protected void setup() { addBehaviour(new CyclicBehaviour(this) { public void action() { try{ ACLMessage msg = blockingReceive()。 (getLocalName()+ rx msg+msg)。 if (JavaSerialization.equals(())) { Person p = (Person)()。 (getLocalName()+ 获取 Java对象: )。 (().getName())。 (())。 } } catch(UnreadableException e3){ (getLocalName()+ catched exception +())。 } block()。 } })。 } } 外部应用程序。jade笔记(编辑修改稿)
相关推荐
.................. 11 ment。 ...................................................................................12 class ...............................................................................
(both amp。 amp。 idx=) { if ((idx)==39。 39。 ){ while((idx)!=39。 39。 ) idx++。 idx++。 } if ((idx)==39。 amp。 39。 amp。 amp。 (idx+1)!=39。 39。 ){ while ((idx)!= 39。 39。 )idx++。 idx++。 } tmp0 = (0,idx)。 tmp1
ee scrollAmount=39。 +speed+39。 style=width:39。 +marqueewidth+39。 39。 +marqueecontents+39。 /marquee39。 ) function regenerate(){ () } function regenerate2(){ if (){ setTimeout(=regenerate,450) intiali
“7” 07H “F” 71H ( 2. 由于显示的数字 0- 9的字形码没有规律可循,只能采用查表的方式来完成我们所需的要求了。 这样我们按着数字 0- 9 的顺序,把每个数字的笔段代码按顺序排好。 建立的表格如下所示: TABLE DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH 5.程序框图 图 6. 汇编源程序 ORG 0 START
个常用的类 和 . 可以用来序列化对象并把它们放到文件中,或者将它们通过输出流将它们输出 到网络。 它所加载的是已经生成的 report 或者已经被输出为 xml 格式的最终的JasperReports 文档。 和上一个读取序列化的文档不同,这个是要解析 xml 内容,并建立一个 类型的副本。 这个可以通过 类来实现,里面有静态的方法通过解析 xml内容可以建立 inmemory
ition=y) 这个是页面被载入和调出时 的一些特效。 duration 表示特效的持续时间,以秒为单位。 transition 表示使用哪种特效,取值为 123: 0 矩形缩小 1 矩形扩大 2 圆形缩小 3 圆形扩大 4 下到上刷新 5 上到下刷新 6 左到右刷新 7 右到左刷新 8 竖百叶窗 9 横百叶窗 10 错位横百叶窗 11 错位竖百叶窗 12 点扩散 13 左右到中间刷新 14