]> git.mxchange.org Git - simgear.git/blob - simgear/hla/RTI13Federate.cxx
Move the decision which rti to use into HLAFederate.
[simgear.git] / simgear / hla / RTI13Federate.cxx
1 // Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Library General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16 //
17
18 #include "RTI13Federate.hxx"
19
20 #include "RTI13Ambassador.hxx"
21
22 namespace simgear {
23
24 RTI13Federate::RTI13Federate(const std::list<std::string>& stringList) :
25     _tickTimeout(10),
26     _ambassador(new RTI13Ambassador)
27 {
28     if (stringList.empty()) {
29         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Ignoring non empty connect arguments while connecting to an RTI13 federation!");
30     }
31 }
32
33 RTI13Federate::~RTI13Federate()
34 {
35 }
36
37 bool
38 RTI13Federate::createFederationExecution(const std::string& federationName, const std::string& objectModel)
39 {
40     try {
41         _ambassador->createFederationExecution(federationName, objectModel);
42         return true;
43     } catch (RTI::FederationExecutionAlreadyExists& e) {
44         return true;
45     } catch (RTI::CouldNotOpenFED& e) {
46         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not create federation execution: " << e._name << " " << e._reason);
47         return false;
48     } catch (RTI::ErrorReadingFED& e) {
49         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not create federation execution: " << e._name << " " << e._reason);
50         return false;
51     } catch (RTI::ConcurrentAccessAttempted& e) {
52         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not create federation execution: " << e._name << " " << e._reason);
53         return false;
54     } catch (RTI::RTIinternalError& e) {
55         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not create federation execution: " << e._name << " " << e._reason);
56         return false;
57     }
58 }
59
60 bool
61 RTI13Federate::destroyFederationExecution(const std::string& federation)
62 {
63     try {
64         _ambassador->destroyFederationExecution(federation);
65         return true;
66     } catch (RTI::FederatesCurrentlyJoined& e) {
67         return true;
68     } catch (RTI::FederationExecutionDoesNotExist& e) {
69         return true;
70     } catch (RTI::ConcurrentAccessAttempted& e) {
71         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not destroy federation execution: " << e._name << " " << e._reason);
72         return false;
73     } catch (RTI::RTIinternalError& e) {
74         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not destroy federation execution: " << e._name << " " << e._reason);
75         return false;
76     }
77 }
78
79 bool
80 RTI13Federate::join(const std::string& federateType, const std::string& federationName)
81 {
82     try {
83         _federateHandle = _ambassador->joinFederationExecution(federateType, federationName);
84         SG_LOG(SG_NETWORK, SG_INFO, "RTI: Joined federation \""
85                << federationName << "\" as \"" << federateType << "\"");
86         setFederateType(federateType);
87         setFederationName(federationName);
88         return true;
89     } catch (RTI::FederateAlreadyExecutionMember& e) {
90         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
91         return false;
92     } catch (RTI::FederationExecutionDoesNotExist& e) {
93         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
94         return false;
95     } catch (RTI::CouldNotOpenFED& e) {
96         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
97         return false;
98     } catch (RTI::ErrorReadingFED& e) {
99         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
100         return false;
101     } catch (RTI::ConcurrentAccessAttempted& e) {
102         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
103         return false;
104     } catch (RTI::SaveInProgress& e) {
105         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
106         return false;
107     } catch (RTI::RestoreInProgress& e) {
108         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
109         return false;
110     } catch (RTI::RTIinternalError& e) {
111         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not join federation execution: " << e._name << " " << e._reason);
112         return false;
113     }
114 }
115
116 bool
117 RTI13Federate::resign()
118 {
119     try {
120         _ambassador->resignFederationExecution();
121         SG_LOG(SG_NETWORK, SG_INFO, "RTI: Resigned from federation.");
122         _federateHandle = -1;
123         return true;
124     } catch (RTI::FederateOwnsAttributes& e) {
125         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
126         return false;
127     } catch (RTI::FederateNotExecutionMember& e) {
128         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
129         return false;
130     } catch (RTI::InvalidResignAction& e) {
131         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
132         return false;
133     } catch (RTI::ConcurrentAccessAttempted& e) {
134         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
135         return false;
136     } catch (RTI::RTIinternalError& e) {
137         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
138         return false;
139     }
140 }
141
142 bool
143 RTI13Federate::registerFederationSynchronizationPoint(const std::string& label, const RTIData& tag)
144 {
145     try {
146         _ambassador->registerFederationSynchronizationPoint(label, tag);
147         SG_LOG(SG_NETWORK, SG_INFO, "RTI: registerFederationSynchronizationPoint(" << label << ", tag )");
148         return true;
149     } catch (RTI::FederateNotExecutionMember& e) {
150         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not register federation synchronization point: " << e._name << " " << e._reason);
151         return false;
152     } catch (RTI::ConcurrentAccessAttempted& e) {
153         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not register federation synchronization point: " << e._name << " " << e._reason);
154         return false;
155     } catch (RTI::SaveInProgress& e) {
156         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not register federation synchronization point: " << e._name << " " << e._reason);
157         return false;
158     } catch (RTI::RestoreInProgress& e) {
159         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not register federation synchronization point: " << e._name << " " << e._reason);
160         return false;
161     } catch (RTI::RTIinternalError& e) {
162         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not register federation synchronization point: " << e._name << " " << e._reason);
163         return false;
164     }
165 }
166
167 bool
168 RTI13Federate::waitForFederationSynchronizationPointAnnounced(const std::string& label)
169 {
170     while (!_ambassador->getFederationSynchronizationPointAnnounced(label)) {
171         _ambassador->tick(_tickTimeout, 0);
172         _ambassador->processQueues();
173     }
174     return true;
175 }
176
177 bool
178 RTI13Federate::synchronizationPointAchieved(const std::string& label)
179 {
180     try {
181         _ambassador->synchronizationPointAchieved(label);
182         SG_LOG(SG_NETWORK, SG_INFO, "RTI: synchronizationPointAchieved(" << label << ")");
183         return true;
184     } catch (RTI::SynchronizationPointLabelWasNotAnnounced& e) {
185         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
186         return false;
187     } catch (RTI::FederateNotExecutionMember& e) {
188         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
189         return false;
190     } catch (RTI::ConcurrentAccessAttempted& e) {
191         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
192         return false;
193     } catch (RTI::SaveInProgress& e) {
194         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
195         return false;
196     } catch (RTI::RestoreInProgress& e) {
197         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
198         return false;
199     } catch (RTI::RTIinternalError& e) {
200         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not signal synchronization point: " << e._name << " " << e._reason);
201         return false;
202     }
203 }
204
205 bool
206 RTI13Federate::waitForFederationSynchronized(const std::string& label)
207 {
208     while (!_ambassador->getFederationSynchronized(label)) {
209         _ambassador->tick(_tickTimeout, 0);
210         _ambassador->processQueues();
211     }
212     return true;
213 }
214
215 bool
216 RTI13Federate::enableTimeConstrained()
217 {
218     if (!_ambassador.valid()) {
219         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time constrained at unconnected federate.");
220         return false;
221     }
222
223     if (_ambassador->getTimeConstrainedEnabled()) {
224         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Time constrained is already enabled.");
225         return false;
226     }
227
228     try {
229         _ambassador->enableTimeConstrained();
230     } catch (RTI::TimeConstrainedAlreadyEnabled& e) {
231         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
232         return false;
233     } catch (RTI::EnableTimeConstrainedPending& e) {
234         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
235         return false;
236     } catch (RTI::TimeAdvanceAlreadyInProgress& e) {
237         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
238         return false;
239     } catch (RTI::ConcurrentAccessAttempted& e) {
240         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
241         return false;
242     } catch (RTI::FederateNotExecutionMember& e) {
243         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
244         return false;
245     } catch (RTI::SaveInProgress& e) {
246         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
247         return false;
248     } catch (RTI::RestoreInProgress& e) {
249         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
250         return false;
251     } catch (RTI::RTIinternalError& e) {
252         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
253         return false;
254     }
255
256     while (!_ambassador->getTimeConstrainedEnabled()) {
257         _ambassador->tick(_tickTimeout, 0);
258         _ambassador->processQueues();
259     }
260
261     return true;
262 }
263
264 bool
265 RTI13Federate::disableTimeConstrained()
266 {
267     if (!_ambassador.valid()) {
268         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time constrained at unconnected federate.");
269         return false;
270     }
271
272     if (!_ambassador->getTimeConstrainedEnabled()) {
273         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Time constrained is not enabled.");
274         return false;
275     }
276
277     try {
278         _ambassador->disableTimeConstrained();
279     } catch (RTI::TimeConstrainedWasNotEnabled& e) {
280         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
281         return false;
282     } catch (RTI::FederateNotExecutionMember& e) {
283         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
284         return false;
285     } catch (RTI::ConcurrentAccessAttempted& e) {
286         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
287         return false;
288     } catch (RTI::SaveInProgress& e) {
289         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
290         return false;
291     } catch (RTI::RestoreInProgress& e) {
292         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
293         return false;
294     } catch (RTI::RTIinternalError& e) {
295         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
296         return false;
297     }
298
299     return true;
300 }
301
302 bool
303 RTI13Federate::enableTimeRegulation(const SGTimeStamp& lookahead)
304 {
305     if (!_ambassador.valid()) {
306         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not enable time regulation at unconnected federate.");
307         return false;
308     }
309
310     if (_ambassador->getTimeRegulationEnabled()) {
311         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Time regulation already enabled.");
312         return false;
313     }
314
315     try {
316         _ambassador->enableTimeRegulation(SGTimeStamp(), lookahead);
317     } catch (RTI::TimeRegulationAlreadyEnabled& e) {
318         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
319         return false;
320     } catch (RTI::EnableTimeRegulationPending& e) {
321         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
322         return false;
323     } catch (RTI::TimeAdvanceAlreadyInProgress& e) {
324         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
325         return false;
326     } catch (RTI::InvalidFederationTime& e) {
327         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
328         return false;
329     } catch (RTI::InvalidLookahead& e) {
330         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
331         return false;
332     } catch (RTI::ConcurrentAccessAttempted& e) {
333         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
334         return false;
335     } catch (RTI::FederateNotExecutionMember& e) {
336         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
337         return false;
338     } catch (RTI::SaveInProgress& e) {
339         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
340         return false;
341     } catch (RTI::RestoreInProgress& e) {
342         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
343         return false;
344     } catch (RTI::RTIinternalError& e) {
345         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
346         return false;
347     }
348
349     while (!_ambassador->getTimeRegulationEnabled()) {
350         _ambassador->tick(_tickTimeout, 0);
351         _ambassador->processQueues();
352     }
353
354     return true;
355 }
356
357 bool
358 RTI13Federate::disableTimeRegulation()
359 {
360     if (!_ambassador.valid()) {
361         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation at unconnected federate.");
362         return false;
363     }
364
365     if (!_ambassador->getTimeRegulationEnabled()) {
366         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Time regulation is not enabled.");
367         return false;
368     }
369
370     try {
371         _ambassador->disableTimeRegulation();
372     } catch (RTI::TimeRegulationWasNotEnabled& e) {
373         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
374         return false;
375     } catch (RTI::ConcurrentAccessAttempted& e) {
376         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
377         return false;
378     } catch (RTI::FederateNotExecutionMember& e) {
379         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
380         return false;
381     } catch (RTI::SaveInProgress& e) {
382         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
383         return false;
384     } catch (RTI::RestoreInProgress& e) {
385         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
386         return false;
387     } catch (RTI::RTIinternalError& e) {
388         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
389         return false;
390     }
391
392     return true;
393 }
394
395 bool
396 RTI13Federate::timeAdvanceRequestBy(const SGTimeStamp& dt)
397 {
398     if (!_ambassador.valid()) {
399         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation at unconnected federate.");
400         return false;
401     }
402
403     SGTimeStamp fedTime = _ambassador->getCurrentLogicalTime() + dt;
404     return timeAdvanceRequest(fedTime);
405 }
406
407 bool
408 RTI13Federate::timeAdvanceRequest(const SGTimeStamp& fedTime)
409 {
410     if (!_ambassador.valid()) {
411         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not disable time regulation at unconnected federate.");
412         return false;
413     }
414
415     try {
416         _ambassador->timeAdvanceRequest(fedTime);
417     } catch (RTI::InvalidFederationTime& e) {
418         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
419         return false;
420     } catch (RTI::FederationTimeAlreadyPassed& e) {
421         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
422         return false;
423     } catch (RTI::TimeAdvanceAlreadyInProgress& e) {
424         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
425         return false;
426     } catch (RTI::EnableTimeRegulationPending& e) {
427         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
428         return false;
429     } catch (RTI::EnableTimeConstrainedPending& e) {
430         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
431         return false;
432     } catch (RTI::FederateNotExecutionMember& e) {
433         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
434         return false;
435     } catch (RTI::ConcurrentAccessAttempted& e) {
436         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
437         return false;
438     } catch (RTI::SaveInProgress& e) {
439         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
440         return false;
441     } catch (RTI::RestoreInProgress& e) {
442         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
443         return false;
444     } catch (RTI::RTIinternalError& e) {
445         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
446         return false;
447     }
448
449     while (_ambassador->getTimeAdvancePending()) {
450         _ambassador->tick(_tickTimeout, 0);
451         _ambassador->processQueues();
452     }
453
454     return true;
455 }
456
457 bool
458 RTI13Federate::queryFederateTime(SGTimeStamp& timeStamp)
459 {
460     if (!_ambassador.valid()) {
461         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time.");
462         return false;
463     }
464
465     try {
466         _ambassador->queryFederateTime(timeStamp);
467     } catch (RTI::FederateNotExecutionMember& e) {
468         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason);
469         return false;
470     } catch (RTI::ConcurrentAccessAttempted& e) {
471         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason);
472         return false;
473     } catch (RTI::SaveInProgress& e) {
474         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason);
475         return false;
476     } catch (RTI::RestoreInProgress& e) {
477         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason);
478         return false;
479     } catch (RTI::RTIinternalError& e) {
480         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason);
481         return false;
482     }
483     return true;
484 }
485
486 bool
487 RTI13Federate::modifyLookahead(const SGTimeStamp& timeStamp)
488 {
489     if (!_ambassador.valid()) {
490         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead.");
491         return false;
492     }
493     try {
494         _ambassador->modifyLookahead(timeStamp);
495     } catch (RTI::InvalidLookahead& e) {
496         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
497         return false;
498     } catch (RTI::FederateNotExecutionMember& e) {
499         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
500         return false;
501     } catch (RTI::ConcurrentAccessAttempted& e) {
502         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
503         return false;
504     } catch (RTI::SaveInProgress& e) {
505         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
506         return false;
507     } catch (RTI::RestoreInProgress& e) {
508         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
509         return false;
510     } catch (RTI::RTIinternalError& e) {
511         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not modify lookahead: " << e._name << " " << e._reason);
512         return false;
513     }
514     return true;
515 }
516
517 bool
518 RTI13Federate::queryLookahead(SGTimeStamp& timeStamp)
519 {
520     if (!_ambassador.valid()) {
521         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead.");
522         return false;
523     }
524
525     try {
526         _ambassador->queryLookahead(timeStamp);
527     } catch (RTI::FederateNotExecutionMember& e) {
528         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason);
529         return false;
530     } catch (RTI::ConcurrentAccessAttempted& e) {
531         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason);
532         return false;
533     } catch (RTI::SaveInProgress& e) {
534         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason);
535         return false;
536     } catch (RTI::RestoreInProgress& e) {
537         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason);
538         return false;
539     } catch (RTI::RTIinternalError& e) {
540         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason);
541         return false;
542     }
543     return true;
544 }
545
546 bool
547 RTI13Federate::tick()
548 {
549     bool result = _ambassador->tick();
550     _ambassador->processQueues();
551     return result;
552 }
553
554 bool
555 RTI13Federate::tick(const double& minimum, const double& maximum)
556 {
557     bool result = _ambassador->tick(minimum, maximum);
558     _ambassador->processQueues();
559     return result;
560 }
561
562 RTI13ObjectClass*
563 RTI13Federate::createObjectClass(const std::string& objectClassName, HLAObjectClass* hlaObjectClass)
564 {
565     try {
566         return _ambassador->createObjectClass(objectClassName, hlaObjectClass);
567     } catch (RTI::NameNotFound& e) {
568         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
569         return 0;
570     } catch (RTI::FederateNotExecutionMember& e) {
571         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
572         return 0;
573     } catch (RTI::ConcurrentAccessAttempted& e) {
574         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
575         return 0;
576     } catch (RTI::RTIinternalError& e) {
577         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
578         return 0;
579     }
580 }
581
582 RTI13ObjectInstance*
583 RTI13Federate::getObjectInstance(const std::string& objectInstanceName)
584 {
585     try {
586         return _ambassador->getObjectInstance(objectInstanceName);
587     } catch (RTI::ObjectNotKnown& e) {
588         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
589         return 0;
590     } catch (RTI::FederateNotExecutionMember& e) {
591         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
592         return 0;
593     } catch (RTI::ConcurrentAccessAttempted& e) {
594         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
595         return 0;
596     } catch (RTI::RTIinternalError& e) {
597         SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not get object class: " << e._name << " " << e._reason);
598         return 0;
599     }
600 }
601
602 }