public static void main(String[] args) {
Properties props = parseArgs(args);
loadProperties(props);
Production production = new Production(props);
production.mainThread();
}
主要功能是从命令行或者配置文件中读取相关参数,产生production对象,运行mainThread线程
---------------------------------------------------------------------------------------------------------
(9)调用rti函数enableAsynchronousDelivery,目的是instructs the LRC to begin delivering receive-ordered events to the federate even while no time-advancement service is in progress,其实就是production这个时间受限联邦成员要求在时间批准状态下也能接收RO事件。
RTIambassador created
Federation execution restaurant_1 already exists.
Joined as federate 8
Enabling time constraint...
...constraint enabled at time<0.0>
Enabling time regulation...
...regulation enabled at time<0.0>
This point is after subscribe...
Waiting for ReadyToPopulate...
�5.10)startRegistrationForObjectClass:3
�5.10)startRegistrationForObjectClass:6
...federation synchronized.
type0 increase by interval<1.5> //这里是产生的6个sushi实例,信息包括type和制作时间,其实意思是说6个chef每人做一个
type0 increase by interval<1.5>
type3 increase by interval<4.0>
type1 increase by interval<2.3>
type3 increase by interval<4.0>
type1 increase by interval<2.3>
Waiting for ReadyToRun...
...federation synchronized.
NER to time<1.5> //进入主循环,首先根据第一个sushi制作完成的时间,发出NER to 1.5的时间推进请求
Discovered Boat 115(B_9_0) //此时,外部事件callback队列中首先出现的时间是tranport.java联邦注册的Boat对象,一共8个。这里callback应该是DiscoverObjectInstanceCallback
Discovered Boat 117(B_9_1)
Discovered Boat 118(B_9_2)
Discovered Boat 119(B_9_3)
Discovered Boat 120(B_9_4)
Discovered Boat 121(B_9_5)
Discovered Boat 122(B_9_6)
Discovered Boat 123(B_9_7)
...granted to time<0.01> //下一个外部事件队列中出现的是一个time grant
NER to time<1.5> //重新回到主循环的起始,因为得到的time grant的时间小于第一个sushi制作完成的时间,内部事件队列中并不删除第一个sushi制作完成这个事件,重新发出NER to 1.5的时间推进请求
...granted to time<1.01> //又得到一个外部事件队列事件,是一个time grant
NER to time<1.5> //同理,又发出一个NER to 1.5的时间推进请求
...granted to time<1.5> //这回,终于得到grant了
Dequeued internal event at time<1.5>, chef: 0 //下面就是从_internalQueue中取出两个1.5时间做好的sushi,注册相应的对象实例,并从_internalQueue中删除两个1.5时间做好的sushi
This is dispatch in FinishMakingSushiEvent
Dequeued internal event at time<1.5>, chef: 1
This is dispatch in FinishMakingSushiEvent
NER to time<2.3> //这回,轮到第三个被做好的sushi了
Chef 1 attempting to load boat B_9_1 //下一个外部事件是reflectiveAttributeValues,是transport联邦对Boat实例对象属性的修改更新导致的事件
AODN Serving S_8_1 //再下一个外部事件是AODN callback,即AttributeOwnershipDivestitureNotificationCallback,RTI回调这个服务通知所有权正式转移
...granted to time<2.01> //下一个外部事件是一个time grant
NER to time<2.3> //没有得到了2.3的grant,继续NER to time 2.3
...granted to time<2.3> //终于得到2.3的grant了
Dequeued internal event at time<2.3>, chef: 3 //下面就是从_internalQueue中取出两个2.3时间做好的sushi,注册相应的对象实例,并从_internalQueue中删除两个2.3时间做好的sushi
This is dispatch in FinishMakingSushiEvent
Dequeued internal event at time<2.3>, chef: 5
This is dispatch in FinishMakingSushiEvent
NER to time<4.0> //重新回到循环的起始,取出下一个做好的sushi的时间是4.0
TransferAccepted: S_8_1 from chef serial 1 time<3.01> //下一个事件是接收到一个交互,
...granted to time<3.01>
NER to time<4.0>
...granted to time<4.0>
Dequeued internal event at time<4.0>, chef: 2
This is dispatch in FinishMakingSushiEvent
Dequeued internal event at time<4.0>, chef: 4
This is dispatch in FinishMakingSushiEvent
在production.java中,类public final class ReceiveInteractionEvent extends ExternalEvent是来处理TransferAccepted交互的。即production收到TransferAccepted交互时,将调用上述类中的dispatch方法,而在dispatch方法中,有如下代码:
//put event on internal queue
LogicalTime eventTime = new LogicalTimeDouble(0.0);
eventTime.setTo(_logicalTime);
eventTime.increaseBy(_manufactureTimes[type]);
_internalQueue.enqueue(new FinishMakingSushiEvent(eventTime, chefSerial, type));