-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelicsPublications.java
843 lines (672 loc) · 27.5 KB
/
HelicsPublications.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
/*Certain portions of this software are Copyright (c) 2006-2017 Vanderbilt University, Institute for Software Integrated Systems
Certain portions of this software are contributed as a public service by The National Institute of Standards and Technology (NIST) and are not subject to U.S. Copyright
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above Vanderbilt University copyright notice, NIST contribution notice and this permission and disclaimer notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE AUTHORS OR COPYRIGHT HOLDERS SHALL NOT HAVE ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
package GatewayTest;
import java.util.HashSet;
import java.util.Set;
import hla.rti.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.cpswt.utils.CpswtUtils;
import org.cpswt.hla.*;
/**
* The HelicsPublications class implements the HelicsPublications object in the
* GatewayTest simulation.
*/
public class HelicsPublications extends ObjectRoot {
private static final Logger logger = LogManager.getLogger(HelicsPublications.class);
/**
* Default constructor -- creates an instance of the HelicsPublications object
* class with default attribute values.
*/
public HelicsPublications() { }
private static int _doubleValue_handle;
private static int _stringValue_handle;
/**
* Returns the handle (RTI assigned) of the "doubleValue" attribute of
* its containing object class.
*
* @return the handle (RTI assigned) of the "doubleValue" attribute
*/
public static int get_doubleValue_handle() { return _doubleValue_handle; }
/**
* Returns the handle (RTI assigned) of the "stringValue" attribute of
* its containing object class.
*
* @return the handle (RTI assigned) of the "stringValue" attribute
*/
public static int get_stringValue_handle() { return _stringValue_handle; }
private static boolean _isInitialized = false;
private static int _handle;
/**
* Returns the handle (RTI assigned) of the HelicsPublications object class.
* Note: As this is a static method, it is NOT polymorphic, and so, if called on
* a reference will return the handle of the class pertaining to the reference,\
* rather than the handle of the class for the instance referred to by the reference.
* For the polymorphic version of this method, use {@link #getClassHandle()}.
*/
public static int get_handle() { return _handle; }
/**
* Returns the fully-qualified (dot-delimited) name of the HelicsPublications
* object class.
* Note: As this is a static method, it is NOT polymorphic, and so, if called on
* a reference will return the name of the class pertaining to the reference,\
* rather than the name of the class for the instance referred to by the reference.
* For the polymorphic version of this method, use {@link #getClassName()}.
*/
public static String get_class_name() { return "ObjectRoot.HelicsPublications"; }
/**
* Returns the simple name (the last name in the dot-delimited fully-qualified
* class name) of the HelicsPublications object class.
*/
public static String get_simple_class_name() { return "HelicsPublications"; }
private static Set< String > _datamemberNames = new HashSet< String >();
private static Set< String > _allDatamemberNames = new HashSet< String >();
/**
* Returns a set containing the names of all of the non-hidden attributes in the
* HelicsPublications object class.
* Note: As this is a static method, it is NOT polymorphic, and so, if called on
* a reference will return a set of parameter names pertaining to the reference,\
* rather than the parameter names of the class for the instance referred to by
* the reference. For the polymorphic version of this method, use
* {@link #getAttributeNames()}.
*/
public static Set< String > get_attribute_names() {
return new HashSet< String >(_datamemberNames);
}
/**
* Returns a set containing the names of all of the attributes in the
* HelicsPublications object class.
* Note: As this is a static method, it is NOT polymorphic, and so, if called on
* a reference will return a set of parameter names pertaining to the reference,\
* rather than the parameter names of the class for the instance referred to by
* the reference. For the polymorphic version of this method, use
* {@link #getAttributeNames()}.
*/
public static Set< String > get_all_attribute_names() {
return new HashSet< String >(_allDatamemberNames);
}
private static AttributeHandleSet _publishedAttributeHandleSet;
private static Set< String > _publishAttributeNameSet = new HashSet< String >();
private static AttributeHandleSet _subscribedAttributeHandleSet;
private static Set< String > _subscribeAttributeNameSet = new HashSet< String >();
static {
_classNameSet.add("ObjectRoot.HelicsPublications");
_classNameClassMap.put("ObjectRoot.HelicsPublications", HelicsPublications.class);
_datamemberClassNameSetMap.put("ObjectRoot.HelicsPublications", _datamemberNames);
_allDatamemberClassNameSetMap.put("ObjectRoot.HelicsPublications", _allDatamemberNames);
_datamemberNames.add("doubleValue");
_datamemberNames.add("stringValue");
_allDatamemberNames.add("doubleValue");
_allDatamemberNames.add("stringValue");
_datamemberTypeMap.put("doubleValue", "double");
_datamemberTypeMap.put("stringValue", "String");
_classNamePublishAttributeNameMap.put("ObjectRoot.HelicsPublications", _publishAttributeNameSet);
_publishedAttributeHandleSet = _factory.createAttributeHandleSet();
_classNamePublishedAttributeMap.put("ObjectRoot.HelicsPublications", _publishedAttributeHandleSet);
_classNameSubscribeAttributeNameMap.put("ObjectRoot.HelicsPublications", _subscribeAttributeNameSet);
_subscribedAttributeHandleSet = _factory.createAttributeHandleSet();
_classNameSubscribedAttributeMap.put("ObjectRoot.HelicsPublications", _subscribedAttributeHandleSet);
}
private static String initErrorMessage = "Error: ObjectRoot.HelicsPublications: could not initialize: ";
protected static void init(RTIambassador rti) {
if (_isInitialized) return;
_isInitialized = true;
ObjectRoot.init(rti);
boolean isNotInitialized = true;
while(isNotInitialized) {
try {
_handle = rti.getObjectClassHandle("ObjectRoot.HelicsPublications");
isNotInitialized = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", initErrorMessage);
logger.error(f);
return;
} catch (NameNotFound n) {
logger.error("{} Name Not Found", initErrorMessage);
logger.error(n);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
_classNameHandleMap.put("ObjectRoot.HelicsPublications", get_handle());
_classHandleNameMap.put(get_handle(), "ObjectRoot.HelicsPublications");
_classHandleSimpleNameMap.put(get_handle(), "HelicsPublications");
isNotInitialized = true;
while(isNotInitialized) {
try {
_doubleValue_handle = rti.getAttributeHandle("doubleValue", get_handle());
_stringValue_handle = rti.getAttributeHandle("stringValue", get_handle());
isNotInitialized = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", initErrorMessage);
logger.error(f);
return;
} catch (ObjectClassNotDefined i) {
logger.error("{} Object Class Not Defined", initErrorMessage);
logger.error(i);
return;
} catch (NameNotFound n) {
logger.error("{} Name Not Found", initErrorMessage);
logger.error(n);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
_datamemberNameHandleMap.put("ObjectRoot.HelicsPublications,doubleValue", get_doubleValue_handle());
_datamemberNameHandleMap.put("ObjectRoot.HelicsPublications,stringValue", get_stringValue_handle());
_datamemberHandleNameMap.put(get_doubleValue_handle(), "doubleValue");
_datamemberHandleNameMap.put(get_stringValue_handle(), "stringValue");
}
private static boolean _isPublished = false;
private static String publishErrorMessage = "Error: ObjectRoot.HelicsPublications: could not publish: ";
/**
* Publishes the HelicsPublications object class for a federate.
*
* @param rti handle to the Local RTI Component
*/
public static void publish(RTIambassador rti) {
if (_isPublished) return;
init(rti);
_publishedAttributeHandleSet.empty();
for(String attributeName : _publishAttributeNameSet) {
try {
_publishedAttributeHandleSet.add(_datamemberNameHandleMap.get("ObjectRoot.HelicsPublications," + attributeName));
} catch (Exception e) {
logger.error("{} Could not publish \"" + attributeName + "\" attribute.", publishErrorMessage);
}
}
synchronized(rti) {
boolean isNotPublished = true;
while(isNotPublished) {
try {
rti.publishObjectClass(get_handle(), _publishedAttributeHandleSet);
isNotPublished = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", publishErrorMessage);
logger.error(f);
return;
} catch (ObjectClassNotDefined i) {
logger.error("{} Object Class Not Defined", publishErrorMessage);
logger.error(i);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
}
_isPublished = true;
}
private static String unpublishErrorMessage = "Error: ObjectRoot.HelicsPublications: could not unpublish: ";
/**
* Unpublishes the HelicsPublications object class for a federate.
*
* @param rti handle to the Local RTI Component
*/
public static void unpublish(RTIambassador rti) {
if (!_isPublished) return;
init(rti);
synchronized(rti) {
boolean isNotUnpublished = true;
while(isNotUnpublished) {
try {
rti.unpublishObjectClass(get_handle());
isNotUnpublished = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", unpublishErrorMessage);
logger.error(f);
return;
} catch (ObjectClassNotDefined i) {
logger.error("{} Object Class Not Defined", unpublishErrorMessage);
logger.error(i);
return;
} catch (ObjectClassNotPublished i) {
logger.error("{} Object Class Not Published", unpublishErrorMessage);
logger.error(i);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
}
_isPublished = false;
}
private static boolean _isSubscribed = false;
private static String subscribeErrorMessage = "Error: ObjectRoot.HelicsPublications: could not subscribe: ";
/**
* Subscribes a federate to the HelicsPublications object class.
*
* @param rti handle to the Local RTI Component
*/
public static void subscribe(RTIambassador rti) {
if (_isSubscribed) return;
init(rti);
_subscribedAttributeHandleSet.empty();
for(String attributeName : _subscribeAttributeNameSet) {
try {
_subscribedAttributeHandleSet.add(_datamemberNameHandleMap.get("ObjectRoot.HelicsPublications," + attributeName));
} catch (Exception e) {
logger.error("{} Could not subscribe to \"" + attributeName + "\" attribute.", subscribeErrorMessage);
}
}
synchronized(rti) {
boolean isNotSubscribed = true;
while(isNotSubscribed) {
try {
rti.subscribeObjectClassAttributes(get_handle(), _subscribedAttributeHandleSet);
isNotSubscribed = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", subscribeErrorMessage);
logger.error(f);
return;
} catch (ObjectClassNotDefined i) {
logger.error("{} Object Class Not Defined", subscribeErrorMessage);
logger.error(i);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
}
_isSubscribed = true;
}
private static String unsubscribeErrorMessage = "Error: ObjectRoot.HelicsPublications: could not unsubscribe: ";
/**
* Unsubscribes a federate from the HelicsPublications object class.
*
* @param rti handle to the Local RTI Component
*/
public static void unsubscribe(RTIambassador rti) {
if (!_isSubscribed) return;
init(rti);
synchronized(rti) {
boolean isNotUnsubscribed = true;
while(isNotUnsubscribed) {
try {
rti.unsubscribeObjectClass(get_handle());
isNotUnsubscribed = false;
} catch (FederateNotExecutionMember f) {
logger.error("{} Federate Not Execution Member", unsubscribeErrorMessage);
logger.error(f);
return;
} catch (ObjectClassNotDefined i) {
logger.error("{} Object Class Not Defined", unsubscribeErrorMessage);
logger.error(i);
return;
} catch (ObjectClassNotSubscribed i) {
logger.error("{} Object Class Not Subscribed", unsubscribeErrorMessage);
logger.error(i);
return;
} catch (Exception e) {
logger.error(e);
CpswtUtils.sleepDefault();
}
}
}
_isSubscribed = false;
}
/**
* Return true if "handle" is equal to the handle (RTI assigned) of this class
* (that is, the HelicsPublications object class).
*
* @param handle handle to compare to the value of the handle (RTI assigned) of
* this class (the HelicsPublications object class).
* @return "true" if "handle" matches the value of the handle of this class
* (that is, the HelicsPublications object class).
*/
public static boolean match(int handle) { return handle == get_handle(); }
/**
* Returns the handle (RTI assigned) of this instance's object class .
*
* @return the handle (RTI assigned) if this instance's object class
*/
public int getClassHandle() { return get_handle(); }
/**
* Returns the fully-qualified (dot-delimited) name of this instance's object class.
*
* @return the fully-qualified (dot-delimited) name of this instance's object class
*/
public String getClassName() { return get_class_name(); }
/**
* Returns the simple name (last name in its fully-qualified dot-delimited name)
* of this instance's object class.
*
* @return the simple name of this instance's object class
*/
public String getSimpleClassName() { return get_simple_class_name(); }
/**
* Returns a set containing the names of all of the non-hiddenattributes of an
* object class instance.
*
* @return set containing the names of all of the attributes of an
* object class instance
*/
public Set< String > getAttributeNames() { return get_attribute_names(); }
/**
* Returns a set containing the names of all of the attributes of an
* object class instance.
*
* @return set containing the names of all of the attributes of an
* object class instance
*/
public Set< String > getAllAttributeNames() { return get_all_attribute_names(); }
/**
* Publishes the object class of this instance of the class for a federate.
*
* @param rti handle to the Local RTI Component
*/
public void publishObject(RTIambassador rti) { publish(rti); }
/**
* Unpublishes the object class of this instance of this class for a federate.
*
* @param rti handle to the Local RTI Component
*/
public void unpublishObject(RTIambassador rti) { unpublish(rti); }
/**
* Subscribes a federate to the object class of this instance of this class.
*
* @param rti handle to the Local RTI Component
*/
public void subscribeObject(RTIambassador rti) { subscribe(rti); }
/**
* Unsubscribes a federate from the object class of this instance of this class.
*
* @param rti handle to the Local RTI Component
*/
public void unsubscribeObject(RTIambassador rti) { unsubscribe(rti); }
/**
* Returns a data structure containing the handles of all attributes for this object
* class that are currently marked for subscription. To actually subscribe to these
* attributes, a federate must call <objectclassname>.subscribe(RTIambassador rti).
*
* @return data structure containing the handles of all attributes for this object
* class that are currently marked for subscription
*/
public AttributeHandleSet getSubscribedAttributeHandleSet() { return _subscribedAttributeHandleSet; }
public String toString() {
return "HelicsPublications("
+ "doubleValue:" + get_doubleValue()
+ "," + "stringValue:" + get_stringValue()
+ ")";
}
/**
* Publishes the "doubleValue" attribute of the attribute's containing object
* class for a federate.
* Note: This method only marks the "doubleValue" attribute for publication.
* To actually publish the attribute, the federate must (re)publish its containing
* object class.
* (using <objectClassName>.publish( RTIambassador rti ) ).
*/
public static void publish_doubleValue() {
_publishAttributeNameSet.add( "doubleValue" );
}
/**
* Unpublishes the "doubleValue" attribute of the attribute's containing object
* class for a federate.
* Note: This method only marks the "doubleValue" attribute for unpublication.
* To actually publish the attribute, the federate must (re)publish its containing
* object class.
* (using <objectClassName>.publish( RTIambassador rti ) ).
*/
public static void unpublish_doubleValue() {
_publishAttributeNameSet.remove( "doubleValue" );
}
/**
* Subscribes a federate to the "doubleValue" attribute of the attribute's
* containing object class.
* Note: This method only marks the "doubleValue" attribute for subscription.
* To actually subscribe to the attribute, the federate must (re)subscribe to its
* containing object class.
* (using <objectClassName>.subscribe( RTIambassador rti ) ).
*/
public static void subscribe_doubleValue() {
_subscribeAttributeNameSet.add( "doubleValue" );
}
/**
* Unsubscribes a federate from the "doubleValue" attribute of the attribute's
* containing object class.
* Note: This method only marks the "doubleValue" attribute for unsubscription.
* To actually unsubscribe to the attribute, the federate must (re)subscribe to its
* containing object class.
* (using <objectClassName>.subscribe( RTIambassador rti ) ).
*/
public static void unsubscribe_doubleValue() {
_subscribeAttributeNameSet.remove( "doubleValue" );
}
/**
* Publishes the "stringValue" attribute of the attribute's containing object
* class for a federate.
* Note: This method only marks the "stringValue" attribute for publication.
* To actually publish the attribute, the federate must (re)publish its containing
* object class.
* (using <objectClassName>.publish( RTIambassador rti ) ).
*/
public static void publish_stringValue() {
_publishAttributeNameSet.add( "stringValue" );
}
/**
* Unpublishes the "stringValue" attribute of the attribute's containing object
* class for a federate.
* Note: This method only marks the "stringValue" attribute for unpublication.
* To actually publish the attribute, the federate must (re)publish its containing
* object class.
* (using <objectClassName>.publish( RTIambassador rti ) ).
*/
public static void unpublish_stringValue() {
_publishAttributeNameSet.remove( "stringValue" );
}
/**
* Subscribes a federate to the "stringValue" attribute of the attribute's
* containing object class.
* Note: This method only marks the "stringValue" attribute for subscription.
* To actually subscribe to the attribute, the federate must (re)subscribe to its
* containing object class.
* (using <objectClassName>.subscribe( RTIambassador rti ) ).
*/
public static void subscribe_stringValue() {
_subscribeAttributeNameSet.add( "stringValue" );
}
/**
* Unsubscribes a federate from the "stringValue" attribute of the attribute's
* containing object class.
* Note: This method only marks the "stringValue" attribute for unsubscription.
* To actually unsubscribe to the attribute, the federate must (re)subscribe to its
* containing object class.
* (using <objectClassName>.subscribe( RTIambassador rti ) ).
*/
public static void unsubscribe_stringValue() {
_subscribeAttributeNameSet.remove( "stringValue" );
}
private Attribute< Double > _doubleValue =
new Attribute< Double >( new Double( 0 ) );
/**
* Set the value of the "doubleValue" attribute to "value" for this object.
*
* @param value the new value for the "doubleValue" attribute
*/
public void set_doubleValue( double value ) {
_doubleValue.setValue( value );
_doubleValue.setTime( getTime() );
}
/**
* Returns the value of the "doubleValue" attribute of this object.
*
* @return the value of the "doubleValue" attribute
*/
public double get_doubleValue() {
return _doubleValue.getValue();
}
/**
* Returns the current timestamp of the "doubleValue" attribute of this object.
*
* @return the current timestamp of the "doubleValue" attribute
*/
public double get_doubleValue_time() {
return _doubleValue.getTime();
}
private Attribute< String > _stringValue =
new Attribute< String >( new String( "" ) );
/**
* Set the value of the "stringValue" attribute to "value" for this object.
*
* @param value the new value for the "stringValue" attribute
*/
public void set_stringValue( String value ) {
_stringValue.setValue( value );
_stringValue.setTime( getTime() );
}
/**
* Returns the value of the "stringValue" attribute of this object.
*
* @return the value of the "stringValue" attribute
*/
public String get_stringValue() {
return _stringValue.getValue();
}
/**
* Returns the current timestamp of the "stringValue" attribute of this object.
*
* @return the current timestamp of the "stringValue" attribute
*/
public double get_stringValue_time() {
return _stringValue.getTime();
}
protected HelicsPublications( ReflectedAttributes datamemberMap, boolean initFlag ) {
super( datamemberMap, false );
if ( initFlag ) setAttributes( datamemberMap );
}
protected HelicsPublications( ReflectedAttributes datamemberMap, LogicalTime logicalTime, boolean initFlag ) {
super( datamemberMap, logicalTime, false );
if ( initFlag ) setAttributes( datamemberMap );
}
/**
* Creates an instance of the HelicsPublications object class, using
* "datamemberMap" to initialize its attribute values.
* "datamemberMap" is usually acquired as an argument to an RTI federate
* callback method, such as "receiveInteraction".
*
* @param datamemberMap data structure containing initial values for the
* attributes of this new HelicsPublications object class instance
*/
public HelicsPublications( ReflectedAttributes datamemberMap ) {
this( datamemberMap, true );
}
/**
* Like {@link #HelicsPublications( ReflectedAttributes datamemberMap )}, except this
* new HelicsPublications object class instance is given a timestamp of
* "logicalTime".
*
* @param datamemberMap data structure containing initial values for the
* attributes of this new HelicsPublications object class instance
* @param logicalTime timestamp for this new HelicsPublications object class
* instance
*/
public HelicsPublications( ReflectedAttributes datamemberMap, LogicalTime logicalTime ) {
this( datamemberMap, logicalTime, true );
}
/**
* Creates a new HelicsPublications object class instance that is a duplicate
* of the instance referred to by HelicsPublications_var.
*
* @param HelicsPublications_var HelicsPublications object class instance of which
* this newly created HelicsPublications object class instance will be a
* duplicate
*/
public HelicsPublications( HelicsPublications HelicsPublications_var ) {
super( HelicsPublications_var );
set_doubleValue( HelicsPublications_var.get_doubleValue() );
set_stringValue( HelicsPublications_var.get_stringValue() );
}
/**
* Returns the value of the attribute whose name is "datamemberName"
* for this object.
*
* @param datamemberName name of attribute whose value is to be
* returned
* @return value of the attribute whose name is "datamemberName"
* for this object
*/
public Object getAttribute( String datamemberName ) {
if ( "doubleValue".equals( datamemberName ) ) return new Double(get_doubleValue());
else if ( "stringValue".equals( datamemberName ) ) return get_stringValue();
else return super.getAttribute( datamemberName );
}
/**
* Returns the value of the attribute whose handle (RTI assigned)
* is "datamemberHandle" for this object.
*
* @param datamemberHandle handle (RTI assigned) of attribute whose
* value is to be returned
* @return value of the attribute whose handle (RTI assigned) is
* "datamemberHandle" for this object
*/
public Object getAttribute( int datamemberHandle ) {
if ( get_doubleValue_handle() == datamemberHandle ) return new Double(get_doubleValue());
else if ( get_stringValue_handle() == datamemberHandle ) return get_stringValue();
else return super.getAttribute( datamemberHandle );
}
protected boolean setAttributeAux( int param_handle, String val ) {
boolean retval = true;
if ( param_handle == get_doubleValue_handle() ) set_doubleValue( Double.parseDouble(val) );
else if ( param_handle == get_stringValue_handle() ) set_stringValue( val );
else retval = super.setAttributeAux( param_handle, val );
return retval;
}
protected boolean setAttributeAux( String datamemberName, String val ) {
boolean retval = true;
if ( "doubleValue".equals( datamemberName ) ) set_doubleValue( Double.parseDouble(val) );
else if ( "stringValue".equals( datamemberName ) ) set_stringValue( val );
else retval = super.setAttributeAux( datamemberName, val );
return retval;
}
protected boolean setAttributeAux( String datamemberName, Object val ) {
boolean retval = true;
if ( "doubleValue".equals( datamemberName ) ) set_doubleValue( (Double)val );
else if ( "stringValue".equals( datamemberName ) ) set_stringValue( (String)val );
else retval = super.setAttributeAux( datamemberName, val );
return retval;
}
protected SuppliedAttributes createSuppliedDatamembers( boolean force ) {
SuppliedAttributes datamembers = super.createSuppliedDatamembers( force );
boolean isPublished = false;
try {
isPublished = _publishedAttributeHandleSet.isMember( get_doubleValue_handle() );
} catch ( Exception e ) {
logger.error("ERROR: ObjectRoot.HelicsPublications.createSuppliedAttributes: could not determine if doubleValue is published.");
isPublished = false;
}
if ( isPublished && _doubleValue.shouldBeUpdated( force ) ) {
datamembers.add( get_doubleValue_handle(), Double.toString(get_doubleValue()).getBytes() );
_doubleValue.setHasBeenUpdated();
}
try {
isPublished = _publishedAttributeHandleSet.isMember( get_stringValue_handle() );
} catch ( Exception e ) {
logger.error("ERROR: ObjectRoot.HelicsPublications.createSuppliedAttributes: could not determine if stringValue is published.");
isPublished = false;
}
if ( isPublished && _stringValue.shouldBeUpdated( force ) ) {
datamembers.add( get_stringValue_handle(), get_stringValue().getBytes() );
_stringValue.setHasBeenUpdated();
}
return datamembers;
}
public void copyFrom( Object object ) {
super.copyFrom( object );
if ( object instanceof HelicsPublications ) {
HelicsPublications data = (HelicsPublications)object;
_doubleValue = data._doubleValue;
_stringValue = data._stringValue;
}
}
}