├── .classpath
├── .gitignore
├── .project
├── .settings
├── net.sf.jautodoc.prefs
├── org.eclipse.jdt.core.prefs
└── org.eclipse.m2e.core.prefs
├── LICENSE
├── README.md
├── pom.xml
├── repo
└── hla
│ ├── mak
│ └── hla
│ │ └── 4.4.0
│ │ └── hla-4.4.0.jar
│ └── pitch
│ ├── booster1516
│ └── 5.0.1
│ │ └── booster1516-5.0.1.jar
│ ├── prti
│ └── 5.0.1
│ │ └── prti-5.0.1.jar
│ ├── prti1516e
│ └── 5.0.1
│ │ └── prti1516e-5.0.1.jar
│ └── prticore
│ └── 5.0.1
│ └── prticore-5.0.1.jar
└── src
├── main
├── java
│ └── dkf
│ │ ├── coder
│ │ ├── Coder.java
│ │ ├── HLAasciiCharCoder.java
│ │ ├── HLAasciiStringCoder.java
│ │ ├── HLAbooleanCoder.java
│ │ ├── HLAbyteCoder.java
│ │ ├── HLAfloat32BECoder.java
│ │ ├── HLAfloat32LECoder.java
│ │ ├── HLAfloat64BECoder.java
│ │ ├── HLAfloat64LECoder.java
│ │ ├── HLAinteger16BECoder.java
│ │ ├── HLAinteger16LECoder.java
│ │ ├── HLAinteger32BECoder.java
│ │ ├── HLAinteger32LECoder.java
│ │ ├── HLAinteger64BECoder.java
│ │ ├── HLAinteger64LECoder.java
│ │ ├── HLAunicodeCharCoder.java
│ │ └── HLAunicodeStringCoder.java
│ │ ├── config
│ │ ├── Configuration.java
│ │ ├── ConfigurationFactory.java
│ │ ├── ConfigurationFactoryInterface.java
│ │ └── ConfigurationInterface.java
│ │ ├── core
│ │ ├── DKFAbstractFederate.java
│ │ ├── DKFAbstractFederateAmbassador.java
│ │ ├── DKFFederateInterface.java
│ │ ├── DKFHLAModule.java
│ │ ├── DKFRTIAmbassador.java
│ │ ├── ExecutionTask.java
│ │ └── observer
│ │ │ └── Subject.java
│ │ ├── exception
│ │ ├── ConfigurationSyntaxException.java
│ │ ├── FirewallExeption.java
│ │ ├── PublishException.java
│ │ ├── RegisterElementNameException.java
│ │ ├── SubscribeException.java
│ │ ├── TimeRepresentationException.java
│ │ ├── UnsubscribeException.java
│ │ └── UpdateException.java
│ │ ├── model
│ │ ├── Order.java
│ │ ├── Sharing.java
│ │ ├── Transportation.java
│ │ ├── interaction
│ │ │ ├── InteractionClassEntity.java
│ │ │ ├── InteractionClassModel.java
│ │ │ ├── InteractionClassModelManager.java
│ │ │ ├── InteractionClassModelParser.java
│ │ │ └── annotations
│ │ │ │ ├── InteractionClass.java
│ │ │ │ └── Parameter.java
│ │ ├── object
│ │ │ ├── AbstractClassEntity.java
│ │ │ ├── NameReservationStatus.java
│ │ │ ├── ObjectClassEntity.java
│ │ │ ├── ObjectClassHandleEntity.java
│ │ │ ├── ObjectClassModel.java
│ │ │ ├── ObjectClassModelManager.java
│ │ │ ├── ObjectClassModelParser.java
│ │ │ ├── ObjectModelStatus.java
│ │ │ └── annotations
│ │ │ │ ├── Attribute.java
│ │ │ │ ├── ObjectClass.java
│ │ │ │ ├── Ownership.java
│ │ │ │ └── UpdateType.java
│ │ └── parser
│ │ │ └── AbstractObjectModelParser.java
│ │ ├── time
│ │ ├── Float64Time.java
│ │ ├── Integer64Time.java
│ │ ├── TimeAbstract.java
│ │ ├── TimeFactory.java
│ │ ├── TimeFactoryInterface.java
│ │ └── TimeInterface.java
│ │ └── utility
│ │ ├── JulianDateType.java
│ │ ├── SystemUtility.java
│ │ ├── TimeUnit.java
│ │ ├── TimeUtility.java
│ │ └── access
│ │ ├── FOMDataInspector.java
│ │ ├── FOMDataInspectoryFactory.java
│ │ └── TimeType.java
└── resources
│ └── log4j2.xml
└── test
├── java
└── dkf
│ ├── config
│ └── ConfigurationFactoryTest.java
│ ├── core
│ └── DKFAbstractFederateTest.java
│ └── utility
│ └── access
│ └── FOMDataInspectorTest.java
└── resources
└── configuration.json
/.classpath:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /logs/
3 | /repo/
4 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | HLADevelopmentKit
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/net.sf.jautodoc.prefs:
--------------------------------------------------------------------------------
1 | add_header=true
2 | add_todo=false
3 | create_dummy_doc=false
4 | eclipse.preferences.version=1
5 | filter_fields=false
6 | filter_methods=false
7 | filter_types=false
8 | header_text=/*****************************************************************\r\n\r\n${project} - A Java framework to develop HLA Federates.\r\nCopyright (c) ${year}, ${owner}, \r\nAll rights reserved.\r\n\r\nGNU Lesser General Public License (GNU LGPL).\r\n\r\nThis library is free software; you can redistribute it and/or\r\nmodify it under the terms of the GNU Lesser General Public\r\nLicense as published by the Free Software Foundation; either\r\nversion 3.0 of the License, or (at your option) any later version.\r\n\r\nThis library is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r\nLesser General Public License for more details.\r\n\r\nYou should have received a copy of the GNU Lesser General Public\r\nLicense along with this library. \r\nIf not, see ${lgpl_website}\r\n\r*****************************************************************/
9 | project_specific_settings=true
10 | properties=project,owner,year,lgpl_website,
11 | properties.lgpl_website=http\://http\://www.gnu.org/licenses/
12 | properties.owner=SMASH Lab - University of Calabria (Italy)
13 | properties.project=HLADevelopmentKit
14 | properties.year=2015
15 | replace_header=true
16 | replacements=\n\n\nGets the\nSets the\nAdds the\nEdits the\nRemoves the\nInits the\nParses the\nCreates the\nBuilds the\nChecks if is\nPrints the\nChecks for\n\n\n
17 | single_line_comment=false
18 | visibility_package=false
19 | visibility_private=false
20 | visibility_protected=false
21 | visibility_public=false
22 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.7
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
12 | org.eclipse.jdt.core.compiler.source=1.7
13 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 |
10 | This version of the GNU Lesser General Public License incorporates
11 | the terms and conditions of version 3 of the GNU General Public
12 | License, supplemented by the additional permissions listed below.
13 |
14 | 0. Additional Definitions.
15 |
16 | As used herein, "this License" refers to version 3 of the GNU Lesser
17 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
18 | General Public License.
19 |
20 | "The Library" refers to a covered work governed by this License,
21 | other than an Application or a Combined Work as defined below.
22 |
23 | An "Application" is any work that makes use of an interface provided
24 | by the Library, but which is not otherwise based on the Library.
25 | Defining a subclass of a class defined by the Library is deemed a mode
26 | of using an interface provided by the Library.
27 |
28 | A "Combined Work" is a work produced by combining or linking an
29 | Application with the Library. The particular version of the Library
30 | with which the Combined Work was made is also called the "Linked
31 | Version".
32 |
33 | The "Minimal Corresponding Source" for a Combined Work means the
34 | Corresponding Source for the Combined Work, excluding any source code
35 | for portions of the Combined Work that, considered in isolation, are
36 | based on the Application, and not on the Linked Version.
37 |
38 | The "Corresponding Application Code" for a Combined Work means the
39 | object code and/or source code for the Application, including any data
40 | and utility programs needed for reproducing the Combined Work from the
41 | Application, but excluding the System Libraries of the Combined Work.
42 |
43 | 1. Exception to Section 3 of the GNU GPL.
44 |
45 | You may convey a covered work under sections 3 and 4 of this License
46 | without being bound by section 3 of the GNU GPL.
47 |
48 | 2. Conveying Modified Versions.
49 |
50 | If you modify a copy of the Library, and, in your modifications, a
51 | facility refers to a function or data to be supplied by an Application
52 | that uses the facility (other than as an argument passed when the
53 | facility is invoked), then you may convey a copy of the modified
54 | version:
55 |
56 | a) under this License, provided that you make a good faith effort to
57 | ensure that, in the event an Application does not supply the
58 | function or data, the facility still operates, and performs
59 | whatever part of its purpose remains meaningful, or
60 |
61 | b) under the GNU GPL, with none of the additional permissions of
62 | this License applicable to that copy.
63 |
64 | 3. Object Code Incorporating Material from Library Header Files.
65 |
66 | The object code form of an Application may incorporate material from
67 | a header file that is part of the Library. You may convey such object
68 | code under terms of your choice, provided that, if the incorporated
69 | material is not limited to numerical parameters, data structure
70 | layouts and accessors, or small macros, inline functions and templates
71 | (ten or fewer lines in length), you do both of the following:
72 |
73 | a) Give prominent notice with each copy of the object code that the
74 | Library is used in it and that the Library and its use are
75 | covered by this License.
76 |
77 | b) Accompany the object code with a copy of the GNU GPL and this license
78 | document.
79 |
80 | 4. Combined Works.
81 |
82 | You may convey a Combined Work under terms of your choice that,
83 | taken together, effectively do not restrict modification of the
84 | portions of the Library contained in the Combined Work and reverse
85 | engineering for debugging such modifications, if you also do each of
86 | the following:
87 |
88 | a) Give prominent notice with each copy of the Combined Work that
89 | the Library is used in it and that the Library and its use are
90 | covered by this License.
91 |
92 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
93 | document.
94 |
95 | c) For a Combined Work that displays copyright notices during
96 | execution, include the copyright notice for the Library among
97 | these notices, as well as a reference directing the user to the
98 | copies of the GNU GPL and this license document.
99 |
100 | d) Do one of the following:
101 |
102 | 0) Convey the Minimal Corresponding Source under the terms of this
103 | License, and the Corresponding Application Code in a form
104 | suitable for, and under terms that permit, the user to
105 | recombine or relink the Application with a modified version of
106 | the Linked Version to produce a modified Combined Work, in the
107 | manner specified by section 6 of the GNU GPL for conveying
108 | Corresponding Source.
109 |
110 | 1) Use a suitable shared library mechanism for linking with the
111 | Library. A suitable mechanism is one that (a) uses at run time
112 | a copy of the Library already present on the user's computer
113 | system, and (b) will operate properly with a modified version
114 | of the Library that is interface-compatible with the Linked
115 | Version.
116 |
117 | e) Provide Installation Information, but only if you would otherwise
118 | be required to provide such information under section 6 of the
119 | GNU GPL, and only to the extent that such information is
120 | necessary to install and execute a modified version of the
121 | Combined Work produced by recombining or relinking the
122 | Application with a modified version of the Linked Version. (If
123 | you use option 4d0, the Installation Information must accompany
124 | the Minimal Corresponding Source and Corresponding Application
125 | Code. If you use option 4d1, you must provide the Installation
126 | Information in the manner specified by section 6 of the GNU GPL
127 | for conveying Corresponding Source.)
128 |
129 | 5. Combined Libraries.
130 |
131 | You may place library facilities that are a work based on the
132 | Library side by side in a single library together with other library
133 | facilities that are not Applications and are not covered by this
134 | License, and convey such a combined library under terms of your
135 | choice, if you do both of the following:
136 |
137 | a) Accompany the combined library with a copy of the same work based
138 | on the Library, uncombined with any other library facilities,
139 | conveyed under the terms of this License.
140 |
141 | b) Give prominent notice with the combined library that part of it
142 | is a work based on the Library, and explaining where to find the
143 | accompanying uncombined form of the same work.
144 |
145 | 6. Revised Versions of the GNU Lesser General Public License.
146 |
147 | The Free Software Foundation may publish revised and/or new versions
148 | of the GNU Lesser General Public License from time to time. Such new
149 | versions will be similar in spirit to the present version, but may
150 | differ in detail to address new problems or concerns.
151 |
152 | Each version is given a distinguishing version number. If the
153 | Library as you received it specifies that a certain numbered version
154 | of the GNU Lesser General Public License "or any later version"
155 | applies to it, you have the option of following the terms and
156 | conditions either of that published version or of any later version
157 | published by the Free Software Foundation. If the Library as you
158 | received it does not specify a version number of the GNU Lesser
159 | General Public License, you may choose any version of the GNU Lesser
160 | General Public License ever published by the Free Software Foundation.
161 |
162 | If the Library as you received it specifies that a proxy can decide
163 | whether future versions of the GNU Lesser General Public License shall
164 | apply, that proxy's public statement of acceptance of any version is
165 | permanent authorization for you to choose that version for the
166 | Library.
167 |
168 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HLA Development Kit
2 |
3 | The development of a HLA Federation with its Federates is a quite complex task and there are few training resources for developers [2, 4]. The HLA Development Kit aims at easing the development of HLA Federates by providing the following resources: (i) a _software framework (the DKF)_ for the development in Java of HLA Federates; (ii) a _technical documentation_ that describes the DKF; (iii) a _user guide_ to support developers in the use of the DKF; (iv) a set of _reference examples_ of HLA Federates created by using the DKF; and, (v) _video-tutorials_, which show how to create both the structure and the behavior of a HLA Federate by using the DKF.
4 | The DKF is a general-purpose, domain-independent framework, released under the open source policy Lesser GNU Public License (LGPL), which facilitates the development of HLA Federates. Indeed, the DKF allows developers to focus on the specific aspects of their own Federates rather than dealing with the common HLA functionalities, such as the management of the simulation time; the connection/disconnection on/from the HLA RTI [1, 3]; the publishing, subscribing and updating of ObjectClass and InteractionClass elements.
5 |
The DKF is fully implemented in the Java language and is based on the following three principles: (i) _Interoperability_, DKF is fully compliant with the IEEE 1516-2010 specifications; as a consequence, it is platform-independent and can interoperate with different HLA RTI implementations (e.g. PITCH, VT/MÄK, PoRTIco, CERTI); (ii) _Portability and Uniformity_, DKF provides a homogeneous set of APIs that are independent from the underlying HLA RTI and Java version. In this way, developers could decide the HLA RTI and the Java run-time environment at development-time; and (iii) _Usability_, the complexity of the features provided by the DKF framework are hidden behind an intuitive set of APIs.
6 |
7 | The HLA Development Kit is designed, developed, released and managed by the SEI (Systems Engineering and Integration) team, operating in the System Modeling and Simulation Hub (SMASH) Lab of the Department of Informatics, Modeling, Electronics and Systems Engineering (DIMES), University of Calabria (Italy), working in cooperation with NASA JSC (Johnson Space Center), Houston (TX, USA).
8 |
9 |
10 | ## **External links**
11 |
12 | * Official website [link](https://smash-lab.github.io/HLA-Development-Kit/);
13 | * DKF all-in-one package [link](https://drive.google.com/open?id=0B6Txsul1iIJmVFdTX0Roc2tGeFk);
14 | * Documentation (API) [link](https://smash-lab.github.io/HLA-Development-Kit/docs/index.html);
15 | * Technical documentations [link](https://smash-lab.github.io/HLA-Development-Kit/document/HLA_Development_Kit_ver_0.0.1.pdf);
16 | * Examples and video-tutorials: How to build a Federate from scratch in 30 minutes! [link](https://drive.google.com/open?id=0B6Txsul1iIJma3pITXE1M2hSOVk);
17 | * The [SEE](http://exploresim.com/) HLA Starter Kit: The SEE-specific extension of the HLA Development Kit [link](https://code.google.com/p/see-hla-starterkit/).
18 |
19 | ## **Working team**
20 |
21 | * Alfredo Garro, [alfredo.garro@unical.it](mailto:alfredo.garro@unical.it) (coordinator);
22 | * Alberto Falcone, [alberto.falcone@dimes.unical.it](mailto:alberto.falcone@dimes.unical.it) (main developer);
23 | * Andrea Tundis, [andrea.tundis@dimes.unical.it](mailto:andrea.tundis@dimes.unical.it) (developer).
24 |
25 | ## **Acknowledgments**
26 |
27 | The DKF working team would like to thank Edwin Z. Crues (NASA JCS) for his precious advice and suggestions in the development of the HLA Development Kit. A special note of thanks goes also to all the NASA staff involved in the Simulation Exploration Experience (SEE) Project: Priscilla Elfrey, Stephen Paglialonga, Michael Conroy, Dan Dexter, Daniel Oneil, to Björn Möller (PITCH Technologies), and to all the members of SEE teams.
28 |
29 |
30 |
31 | ##**References**
32 |
33 | 1. Anagnostou, A., Chaudhry, N.R., Falcone, A., Garro, A., Salah, O., Taylor, S.J.E., _Easing the development of HLA Federates: the HLA Development Kit and its exploitation in the SEE Project_. In Proc. of the 19th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications (ACM/IEEE DS-RT), Chengdu, China, October, 14-16, IEEE Computer Society, (2015).
34 |
35 | 2. Anagnostou, A., Chaudhry, N.R., Falcone, A., Garro, A., Salah, O., Taylor, S.J.E., _A Prototype HLA Development Kit: Results from the 2015 Simulation Exploration Experience_. In Proc. of the ACM SIGSIM PADS 2015, London, UK, June, 10-12, (2015).
36 |
37 | 3. Bocciarelli, P., D’Ambrogio, A., Falcone, A., Garro, A., Giglio, A., _A model-driven approach to enable the distributed simulation of complex systems_. In Proc. of the 6th Complex Systems Design & Management (CSD&M) 2015, Paris, France, November 23-25, (2015).
38 |
39 | 4. Falcone, A., Garro, A., Longo, F., Spadafora, F., _SimulationExploration Experience: A Communication System and a 3D Real Time Visualization for a Moon base simulated scenario_. In Proc. of the 18th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications (ACM/IEEE DS-RT), Toulouse, France, October, 1-3, IEEE Computer Society, (2014).
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.unical.smashlab
5 | HLADevelopmentKit
6 | 0.0.2
7 | HLADevelopmentKit
8 |
9 |
10 | 1.7
11 | ${basedir}/target
12 | dkf
13 |
14 |
15 |
16 |
17 | localrepository
18 | file://${basedir}/repo
19 |
20 |
21 |
22 |
23 |
24 | org.apache.commons
25 | commons-collections4
26 | 4.0
27 |
28 |
29 | joda-time
30 | joda-time
31 | 2.8
32 |
33 |
34 | com.fasterxml.jackson.core
35 | jackson-databind
36 | 2.8.11
37 |
38 |
39 | com.fasterxml.jackson.datatype
40 | jackson-datatype-joda
41 | 2.8.11
42 |
43 |
44 | org.apache.logging.log4j
45 | log4j-core
46 | 2.3
47 |
48 |
49 |
50 | org.jodd
51 | jodd-core
52 | 3.6.6
53 |
54 |
55 |
56 | junit
57 | junit
58 | 4.12
59 |
61 | provided
62 |
63 |
64 |
65 | org.jdom
66 | jdom2
67 | 2.0.6
68 |
69 |
70 |
71 | jaxen
72 | jaxen
73 | 1.1.6
74 |
75 |
76 |
77 |
78 | hla.pitch
79 | booster1516
80 | 5.0.1
81 |
83 | provided
84 |
85 |
86 | hla.pitch
87 | prti
88 | 5.0.1
89 |
91 | provided
92 |
93 |
94 | hla.pitch
95 | prti1516e
96 | 5.0.1
97 |
99 | provided
100 |
101 |
102 | hla.pitch
103 | prticore
104 | 5.0.1
105 |
107 | provided
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | org.apache.maven.plugins
118 | maven-eclipse-plugin
119 | 2.10
120 |
121 | true
122 | false
123 |
124 |
125 |
126 |
127 |
128 | org.apache.maven.plugins
129 | maven-compiler-plugin
130 | 2.3.2
131 |
132 | ${jdk.version}
133 | ${jdk.version}
134 |
135 |
136 |
137 |
138 |
139 | org.apache.maven.plugins
140 | maven-assembly-plugin
141 | 2.5.5
142 |
143 |
144 |
145 | jar-with-dependencies
146 |
147 |
148 |
149 | ${jar.name}-${project.version}
150 | false
151 |
152 |
153 |
154 |
155 |
156 | org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
157 |
158 |
159 |
160 |
161 |
162 | make-assembly
163 |
164 | package
165 |
166 | single
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 | org.apache.maven.plugins
175 | maven-javadoc-plugin
176 | 2.10.3
177 |
178 | test.*
179 | ${targerDir}/
180 | docs
181 |
182 |
183 |
184 | attach-javadoc
185 |
186 | prepare-package
187 |
188 | aggregate
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/repo/hla/mak/hla/4.4.0/hla-4.4.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SMASH-Lab/HLA-Development-Kit/84dce897d8c5d475dfbca93e574715475b23e2ee/repo/hla/mak/hla/4.4.0/hla-4.4.0.jar
--------------------------------------------------------------------------------
/repo/hla/pitch/booster1516/5.0.1/booster1516-5.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SMASH-Lab/HLA-Development-Kit/84dce897d8c5d475dfbca93e574715475b23e2ee/repo/hla/pitch/booster1516/5.0.1/booster1516-5.0.1.jar
--------------------------------------------------------------------------------
/repo/hla/pitch/prti/5.0.1/prti-5.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SMASH-Lab/HLA-Development-Kit/84dce897d8c5d475dfbca93e574715475b23e2ee/repo/hla/pitch/prti/5.0.1/prti-5.0.1.jar
--------------------------------------------------------------------------------
/repo/hla/pitch/prti1516e/5.0.1/prti1516e-5.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SMASH-Lab/HLA-Development-Kit/84dce897d8c5d475dfbca93e574715475b23e2ee/repo/hla/pitch/prti1516e/5.0.1/prti1516e-5.0.1.jar
--------------------------------------------------------------------------------
/repo/hla/pitch/prticore/5.0.1/prticore-5.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SMASH-Lab/HLA-Development-Kit/84dce897d8c5d475dfbca93e574715475b23e2ee/repo/hla/pitch/prticore/5.0.1/prticore-5.0.1.jar
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/Coder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.encoding.DecoderException;
25 |
26 | public interface Coder {
27 |
28 | public T decode(byte[] code) throws DecoderException;
29 |
30 | public byte[] encode(T element);
31 |
32 | public Class getAllowedType();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAasciiCharCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAASCIIchar;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAasciiCharCoder implements Coder {
31 |
32 | private HLAASCIIchar coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAasciiCharCoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAASCIIchar();
38 | }
39 |
40 | public Byte decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(Byte value) {
46 | coder.setValue(value);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return Byte.class;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAasciiStringCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAASCIIstring;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAasciiStringCoder implements Coder {
31 |
32 | private HLAASCIIstring coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAasciiStringCoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAASCIIstring();
38 | }
39 |
40 | public String decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(String element) {
46 | coder.setValue(element);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return String.class;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAbooleanCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAboolean;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAbooleanCoder implements Coder{
33 |
34 | private HLAboolean coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAbooleanCoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAboolean();
40 | }
41 |
42 | public Boolean decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Boolean element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Boolean.class;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAbyteCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAbyte;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAbyteCoder implements Coder{
33 |
34 | private HLAbyte coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAbyteCoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAbyte();
40 | }
41 |
42 | public Byte decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Byte element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Byte.class;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAfloat32BECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAfloat32BE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAfloat32BECoder implements Coder{
33 |
34 | private HLAfloat32BE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAfloat32BECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAfloat32BE();
40 | }
41 |
42 | public Float decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Float element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Float.class;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAfloat32LECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAfloat32LE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAfloat32LECoder implements Coder{
33 |
34 | private HLAfloat32LE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAfloat32LECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAfloat32LE();
40 | }
41 |
42 | public Float decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Float element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Float.class;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAfloat64BECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAfloat64BE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAfloat64BECoder implements Coder{
31 |
32 | private HLAfloat64BE coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAfloat64BECoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAfloat64BE();
38 | }
39 |
40 | public Double decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(Double element) {
46 | coder.setValue(element);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return Double.class;
52 | }
53 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAfloat64LECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAfloat64LE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAfloat64LECoder implements Coder{
31 |
32 | private HLAfloat64LE coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAfloat64LECoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAfloat64LE();
38 | }
39 |
40 | public Double decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(Double element) {
46 | coder.setValue(element);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return Double.class;
52 | }
53 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger16BECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger16BE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 | public class HLAinteger16BECoder implements Coder{
32 |
33 | private HLAinteger16BE coder = null;
34 | private EncoderFactory factory = null;
35 |
36 | public HLAinteger16BECoder() throws RTIinternalError {
37 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
38 | this.coder = factory.createHLAinteger16BE();
39 | }
40 |
41 | public Short decode(byte[] code) throws DecoderException {
42 | coder.decode(code);
43 | return coder.getValue();
44 | }
45 |
46 | public byte[] encode(Short element) {
47 | coder.setValue(element);
48 | return coder.toByteArray();
49 | }
50 |
51 | public Class getAllowedType() {
52 | return Short.class;
53 | }
54 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger16LECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger16LE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 | public class HLAinteger16LECoder implements Coder{
32 |
33 | private HLAinteger16LE coder = null;
34 | private EncoderFactory factory = null;
35 |
36 | public HLAinteger16LECoder() throws RTIinternalError {
37 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
38 | this.coder = factory.createHLAinteger16LE();
39 | }
40 |
41 | public Short decode(byte[] code) throws DecoderException {
42 | coder.decode(code);
43 | return coder.getValue();
44 | }
45 |
46 | public byte[] encode(Short element) {
47 | coder.setValue(element);
48 | return coder.toByteArray();
49 | }
50 |
51 | public Class getAllowedType() {
52 | return Short.class;
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger32BECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger32BE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAinteger32BECoder implements Coder{
33 |
34 | private HLAinteger32BE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAinteger32BECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAinteger32BE();
40 | }
41 |
42 | public Integer decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Integer element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Integer.class;
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger32LECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger32LE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAinteger32LECoder implements Coder{
33 |
34 | private HLAinteger32LE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAinteger32LECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAinteger32LE();
40 | }
41 |
42 | public Integer decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Integer element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Integer.class;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger64BECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger64BE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAinteger64BECoder implements Coder{
33 |
34 | private HLAinteger64BE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAinteger64BECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAinteger64BE();
40 | }
41 |
42 | public Long decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Long element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Long.class;
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAinteger64LECoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAinteger64LE;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 |
31 |
32 | public class HLAinteger64LECoder implements Coder{
33 |
34 | private HLAinteger64LE coder = null;
35 | private EncoderFactory factory = null;
36 |
37 | public HLAinteger64LECoder() throws RTIinternalError {
38 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
39 | this.coder = factory.createHLAinteger64LE();
40 | }
41 |
42 | public Long decode(byte[] code) throws DecoderException {
43 | coder.decode(code);
44 | return coder.getValue();
45 | }
46 |
47 | public byte[] encode(Long element) {
48 | coder.setValue(element);
49 | return coder.toByteArray();
50 | }
51 |
52 | public Class getAllowedType() {
53 | return Long.class;
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAunicodeCharCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAunicodeChar;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAunicodeCharCoder implements Coder {
31 |
32 | private HLAunicodeChar coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAunicodeCharCoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAunicodeChar();
38 | }
39 |
40 | public Short decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(Short value) {
46 | coder.setValue(value);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return Short.class;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/dkf/coder/HLAunicodeStringCoder.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.coder;
23 |
24 | import hla.rti1516e.RtiFactoryFactory;
25 | import hla.rti1516e.encoding.DecoderException;
26 | import hla.rti1516e.encoding.EncoderFactory;
27 | import hla.rti1516e.encoding.HLAunicodeString;
28 | import hla.rti1516e.exceptions.RTIinternalError;
29 |
30 | public class HLAunicodeStringCoder implements Coder {
31 |
32 | private HLAunicodeString coder = null;
33 | private EncoderFactory factory = null;
34 |
35 | public HLAunicodeStringCoder() throws RTIinternalError {
36 | this.factory = RtiFactoryFactory.getRtiFactory().getEncoderFactory();
37 | this.coder = factory.createHLAunicodeString();
38 | }
39 |
40 | public String decode(byte[] code) throws DecoderException {
41 | coder.decode(code);
42 | return coder.getValue();
43 | }
44 |
45 | public byte[] encode(String element) {
46 | coder.setValue(element);
47 | return coder.toByteArray();
48 | }
49 |
50 | public Class getAllowedType() {
51 | return String.class;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/dkf/config/Configuration.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.config;
23 |
24 | import java.io.File;
25 | import java.util.regex.Matcher;
26 | import java.util.regex.Pattern;
27 |
28 | import org.joda.time.DateTime;
29 |
30 | /**
31 | *
32 | * @author SMASH-Lab University of Calabria
33 | * @version 0.1
34 | *
35 | */
36 | public class Configuration implements ConfigurationInterface {
37 |
38 |
39 | private static final String IP_PATTERN = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
40 | "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
41 | "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
42 | "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
43 |
44 | private boolean isAsynchronousDelivery;
45 | private String crcHost;
46 | private int crcPort;
47 | private String federationName;
48 | private String federateName;
49 | private String federateType;
50 | private File fomDirectory;
51 | private boolean isRealtime;
52 | private boolean isTimeConstrained;
53 | private boolean isTimeRegulating;
54 | private DateTime simulationEphoc;
55 |
56 | protected Configuration() {}
57 |
58 | public boolean isAsynchronousDelivery() {
59 | return isAsynchronousDelivery;
60 | }
61 |
62 | public void setAsynchronousDelivery(boolean isAsynchronousDelivery) {
63 | this.isAsynchronousDelivery = isAsynchronousDelivery;
64 | }
65 |
66 | public String getCrcHost() {
67 | return crcHost;
68 | }
69 |
70 | public void setCrcHost(String crcHost) {
71 | if( crcHost == null || (!crcHost.equalsIgnoreCase("localhost") && !ipIsValid(crcHost)) )
72 | throw new IllegalArgumentException("Invalid IP Address");
73 | this.crcHost = crcHost;
74 | }
75 |
76 | public int getCrcPort() {
77 | return crcPort;
78 | }
79 |
80 | public void setCrcPort(int crcPort) {
81 | if(crcPort < 1024 || crcPort > 49151)
82 | throw new IllegalArgumentException("Invalid CRC Port, The CRC Port must be in the range [1024 - 49151]");
83 | this.crcPort = crcPort;
84 | }
85 |
86 | public String getFederationName() {
87 | return federationName;
88 | }
89 |
90 | public void setFederationName(String federationName) {
91 | this.federationName = federationName;
92 | }
93 |
94 | public String getFederateName() {
95 | return federateName;
96 | }
97 |
98 | public void setFederateName(String federateName) {
99 | this.federateName = federateName;
100 | }
101 |
102 | public String getFederateType() {
103 | return federateType;
104 | }
105 |
106 | public void setFederateType(String federateType) {
107 | this.federateType = federateType;
108 | }
109 |
110 | public File getFomDirectory() {
111 | return fomDirectory;
112 | }
113 |
114 | public void setFomDirectory(File fomDirectory) {
115 | if(fomDirectory == null || !fomDirectory.isDirectory())
116 | throw new IllegalArgumentException("The parameter must be a directory");
117 | this.fomDirectory = fomDirectory;
118 | }
119 |
120 | public boolean isRealtime() {
121 | return isRealtime;
122 | }
123 |
124 | public void setRealtime(boolean isRealtime) {
125 | this.isRealtime = isRealtime;
126 | }
127 |
128 | public boolean isTimeConstrained() {
129 | return isTimeConstrained;
130 | }
131 |
132 | public void setTimeConstrained(boolean isTimeConstrained) {
133 | this.isTimeConstrained = isTimeConstrained;
134 | }
135 |
136 | public boolean isTimeRegulating() {
137 | return isTimeRegulating;
138 | }
139 |
140 | public void setTimeRegulating(boolean isTimeRegulating) {
141 | this.isTimeRegulating = isTimeRegulating;
142 | }
143 |
144 | private boolean ipIsValid(String ip){
145 |
146 | Pattern pattern = Pattern.compile(IP_PATTERN);
147 | Matcher matcher = pattern.matcher(ip);
148 | return matcher.matches();
149 | }
150 |
151 | public DateTime getSimulationEphoc() {
152 | return simulationEphoc;
153 | }
154 |
155 | public void setSimulationEphoc(DateTime simulationEphoc) {
156 | this.simulationEphoc = simulationEphoc;
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/src/main/java/dkf/config/ConfigurationFactory.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.config;
23 |
24 | import java.io.File;
25 | import java.io.IOException;
26 |
27 | import org.apache.logging.log4j.LogManager;
28 | import org.apache.logging.log4j.Logger;
29 |
30 | import com.fasterxml.jackson.core.JsonGenerationException;
31 | import com.fasterxml.jackson.core.JsonParseException;
32 | import com.fasterxml.jackson.databind.JsonMappingException;
33 | import com.fasterxml.jackson.databind.MapperFeature;
34 | import com.fasterxml.jackson.databind.ObjectMapper;
35 | import com.fasterxml.jackson.databind.SerializationFeature;
36 | import com.fasterxml.jackson.datatype.joda.JodaModule;
37 |
38 | public class ConfigurationFactory implements ConfigurationFactoryInterface {
39 |
40 | Logger logger = LogManager.getLogger(ConfigurationFactory.class);
41 |
42 | private ObjectMapper mapper = null;
43 |
44 | public Configuration importConfiguration(File file) throws JsonParseException, JsonMappingException, IOException {
45 | logger.info("Importing the DKF configuration file");
46 | return getObjectMapper().readValue(file, Configuration.class);
47 |
48 | }
49 |
50 |
51 | public void exportConfiguration(Configuration config, File outputFile) throws JsonGenerationException, JsonMappingException, IOException {
52 | logger.info("Exporting the DKF configuration file");
53 | getObjectMapper().writerWithDefaultPrettyPrinter().writeValue(outputFile, config);
54 |
55 | }
56 |
57 | public Configuration createConfiguration() {
58 | return new Configuration();
59 | }
60 |
61 | private ObjectMapper getObjectMapper() {
62 | if(mapper == null){
63 | mapper = new ObjectMapper();
64 | mapper.registerModule(new JodaModule());
65 | mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
66 | mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
67 | }
68 | return mapper;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/dkf/config/ConfigurationFactoryInterface.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.config;
23 |
24 | import java.io.File;
25 | import java.io.FileNotFoundException;
26 | import java.io.IOException;
27 |
28 | import com.fasterxml.jackson.core.JsonParseException;
29 | import com.fasterxml.jackson.databind.JsonMappingException;
30 |
31 | /**
32 | *
33 | * @author SMASH-Lab University of Calabria
34 | * @version 0.1
35 | *
36 | */
37 | public interface ConfigurationFactoryInterface {
38 |
39 | /**
40 | * Imports the configuration parameters from a given file
41 | * @param file configuration file
42 | * @throws FileNotFoundException
43 | * @throws IOException
44 | * @throws JsonMappingException
45 | * @throws JsonParseException
46 | */
47 | public Configuration importConfiguration(File file) throws FileNotFoundException, JsonParseException, JsonMappingException, IOException;
48 |
49 | /**
50 | * Export the configuration parameters into a given directory
51 | * @param config AbstractConfiguration object
52 | * @param outputFile output file
53 | * @throws IOException
54 | */
55 | public void exportConfiguration(Configuration config, File outputFile) throws IOException;
56 |
57 |
58 | /**
59 | * Create an empty Configuration object
60 | * @return an empty Configuration object
61 | */
62 | public Configuration createConfiguration();
63 |
64 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/config/ConfigurationInterface.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.config;
23 |
24 | import java.io.File;
25 |
26 | import org.joda.time.DateTime;
27 |
28 | /**
29 | *
30 | * The root interface in the Configuration hierarchy.
31 | * A configuration is a set of parameters, which are used by the DKF framework
32 | * to set up a Federate on the specific RTI infrastructure.
33 | *
34 | * @author SMASH-Lab University of Calabria
35 | * @version 0.1
36 | *
37 | */
38 | public interface ConfigurationInterface {
39 |
40 | /**
41 | * @return The IP address of the host
42 | */
43 | public String getCrcHost();
44 |
45 | /**
46 | * @return The CRC port
47 | */
48 | public int getCrcPort();
49 |
50 | /**
51 | * @return The name of the SEE Federation
52 | */
53 | public String getFederationName();
54 |
55 | /**
56 | * @return The name of the SEE Federate
57 | */
58 | public String getFederateName();
59 |
60 | /**
61 | * @return The type of the SEE Federate
62 | */
63 | public String getFederateType();
64 |
65 | /**
66 | * @return The directory that contains the FOMs module
67 | */
68 | public File getFomDirectory();
69 |
70 | /**
71 | * @return true: if the Asynchronous Delivery is enabled
72 | */
73 | public boolean isAsynchronousDelivery();
74 |
75 | /**
76 | * @return true: if the Realtime Clock is enabled
77 | */
78 | public boolean isRealtime();
79 |
80 | /**
81 | * @return true: if the Time Constrained is enabled
82 | */
83 | public boolean isTimeConstrained();
84 |
85 | /**
86 | * @return true: if the Time Regulating is enabled
87 | */
88 | public boolean isTimeRegulating();
89 |
90 | /**
91 | * Sets the CRC host to the specified value passed as parameter
92 | * @param crcHost the new value for the CRC host
93 | */
94 | public void setCrcHost(String crcHost);
95 |
96 | /**
97 | * Sets the CRC port to the specified value passed as parameter
98 | * @param crcHost the new value for the CRC port
99 | */
100 | public void setCrcPort(int crcHost);
101 |
102 | /**
103 | * Sets the Asynchronous delivery to the specified value passed as parameter
104 | * @param bool the new value for the Asynchronous delivery
105 | */
106 | public void setAsynchronousDelivery(boolean bool);
107 |
108 | /**
109 | * Sets the federation name to the specified value passed as parameter
110 | * @param federationName the new value for the federation name
111 | */
112 | public void setFederationName(String federationName);
113 |
114 | /**
115 | * Sets the name of the federate to the specified value passed as parameter
116 | * @param federateName the new name
117 | */
118 | public void setFederateName(String federateName);
119 |
120 | /**
121 | * Sets the type of the federate to the specified value passed as parameter
122 | * @param federateType the new type
123 | */
124 | public void setFederateType(String federateType);
125 |
126 | /**
127 | * Sets the FOMs directory to the specified value passed as parameter
128 | * @param dir the FOMs directory
129 | */
130 | public void setFomDirectory(File dir);
131 |
132 | /**
133 | * Sets the realtime clock to the specified value passed as parameter
134 | * @param bool the new value for the realtime clock
135 | */
136 | public void setRealtime(boolean bool);
137 |
138 | /**
139 | * Sets the time regulating to the specified value passed as parameter
140 | * @param bool the new value for the time regulating
141 | */
142 | public void setTimeRegulating(boolean bool);
143 |
144 | /**
145 | * Sets the time constrained to the specified value passed as parameter
146 | * @param bool the new value for the time constrained
147 | */
148 | public void setTimeConstrained(boolean bool);
149 |
150 | /**
151 | *
152 | * @return The simulation start ephoc
153 | */
154 | public DateTime getSimulationEphoc();
155 |
156 | /**
157 | * Sets the simulation start ephoc
158 | * @param simulationEphoc
159 | */
160 | public void setSimulationEphoc(DateTime simulationEphoc);
161 |
162 | }
163 |
--------------------------------------------------------------------------------
/src/main/java/dkf/core/DKFFederateInterface.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.core;
23 |
24 | import java.net.MalformedURLException;
25 | import java.util.Observer;
26 |
27 | import dkf.config.Configuration;
28 | import dkf.exception.PublishException;
29 | import dkf.exception.SubscribeException;
30 | import dkf.exception.UnsubscribeException;
31 | import dkf.exception.UpdateException;
32 | import hla.rti1516e.exceptions.AttributeNotDefined;
33 | import hla.rti1516e.exceptions.AttributeNotOwned;
34 | import hla.rti1516e.exceptions.CallNotAllowedFromWithinCallback;
35 | import hla.rti1516e.exceptions.ConnectionFailed;
36 | import hla.rti1516e.exceptions.CouldNotCreateLogicalTimeFactory;
37 | import hla.rti1516e.exceptions.CouldNotOpenFDD;
38 | import hla.rti1516e.exceptions.ErrorReadingFDD;
39 | import hla.rti1516e.exceptions.FederateIsExecutionMember;
40 | import hla.rti1516e.exceptions.FederateNotExecutionMember;
41 | import hla.rti1516e.exceptions.FederateOwnsAttributes;
42 | import hla.rti1516e.exceptions.FederateServiceInvocationsAreBeingReportedViaMOM;
43 | import hla.rti1516e.exceptions.IllegalName;
44 | import hla.rti1516e.exceptions.InconsistentFDD;
45 | import hla.rti1516e.exceptions.InteractionClassNotDefined;
46 | import hla.rti1516e.exceptions.InteractionClassNotPublished;
47 | import hla.rti1516e.exceptions.InteractionParameterNotDefined;
48 | import hla.rti1516e.exceptions.InvalidInteractionClassHandle;
49 | import hla.rti1516e.exceptions.InvalidLocalSettingsDesignator;
50 | import hla.rti1516e.exceptions.InvalidObjectClassHandle;
51 | import hla.rti1516e.exceptions.InvalidResignAction;
52 | import hla.rti1516e.exceptions.NameNotFound;
53 | import hla.rti1516e.exceptions.NotConnected;
54 | import hla.rti1516e.exceptions.ObjectClassNotDefined;
55 | import hla.rti1516e.exceptions.ObjectClassNotPublished;
56 | import hla.rti1516e.exceptions.ObjectInstanceNameInUse;
57 | import hla.rti1516e.exceptions.ObjectInstanceNameNotReserved;
58 | import hla.rti1516e.exceptions.ObjectInstanceNotKnown;
59 | import hla.rti1516e.exceptions.OwnershipAcquisitionPending;
60 | import hla.rti1516e.exceptions.RTIinternalError;
61 | import hla.rti1516e.exceptions.RestoreInProgress;
62 | import hla.rti1516e.exceptions.SaveInProgress;
63 | import hla.rti1516e.exceptions.UnsupportedCallbackModel;
64 |
65 | public interface DKFFederateInterface {
66 |
67 | /**
68 | * Configures the HLA federate on the HLA Federation
69 | * @param config
70 | */
71 | public void configure(Configuration config);
72 |
73 | /**
74 | * Connects the HLA Federate on the HLA Federation
75 | *
76 | * @param local_settings_designator represents the "local settings designator" string related to the specific
77 | * RTI vendor
78 | *
79 | * For PITCH RTI the local_settings_designator parameter MUST be "crcHost=" + {crc_host} + "\ncrcPort=" + {crc_port}
80 | * e.g. "crcHost=localhost\ncrcPort=8989"
81 | *
82 | * For MAK RTI the local_settings_designator parameter MUST be an empty string
83 | * e.g. ""
84 | * @throws RTIinternalError
85 | * @throws CallNotAllowedFromWithinCallback
86 | * @throws UnsupportedCallbackModel
87 | * @throws InvalidLocalSettingsDesignator
88 | * @throws ConnectionFailed
89 | * @throws NotConnected
90 | * @throws FederateNotExecutionMember
91 | */
92 | public void connectToRTI(String local_settings_designator) throws RTIinternalError, ConnectionFailed, InvalidLocalSettingsDesignator, UnsupportedCallbackModel, CallNotAllowedFromWithinCallback;
93 |
94 | /**
95 | * Joins the Federate to the specified Federation Execution.
96 | * @throws MalformedURLException
97 | * @throws RTIinternalError
98 | * @throws CallNotAllowedFromWithinCallback
99 | * @throws NotConnected
100 | * @throws RestoreInProgress
101 | * @throws SaveInProgress
102 | * @throws CouldNotOpenFDD
103 | * @throws ErrorReadingFDD
104 | * @throws InconsistentFDD
105 | * @throws CouldNotCreateLogicalTimeFactory
106 | * @throws FederateNotExecutionMember
107 | */
108 | public void joinFederationExecution() throws CouldNotCreateLogicalTimeFactory, InconsistentFDD, ErrorReadingFDD, CouldNotOpenFDD, SaveInProgress, RestoreInProgress, NotConnected, CallNotAllowedFromWithinCallback, RTIinternalError, MalformedURLException, FederateNotExecutionMember;
109 |
110 | /**
111 | * Disconnects the HLA Federate from the HLA Federation
112 | * @throws RTIinternalError
113 | * @throws CallNotAllowedFromWithinCallback
114 | * @throws NotConnected
115 | * @throws FederateNotExecutionMember
116 | * @throws FederateOwnsAttributes
117 | * @throws OwnershipAcquisitionPending
118 | * @throws InvalidResignAction
119 | * @throws FederateIsExecutionMember
120 | * @throws RestoreInProgress
121 | * @throws SaveInProgress
122 | */
123 | public void diconnectFromRTI() throws InvalidResignAction, OwnershipAcquisitionPending, FederateOwnsAttributes, FederateNotExecutionMember, NotConnected, CallNotAllowedFromWithinCallback, RTIinternalError, FederateIsExecutionMember, SaveInProgress, RestoreInProgress;
124 |
125 | /**
126 | * Starts Simulation Execution
127 | */
128 | public void startExecution();
129 |
130 | /**
131 | * Subscribes the HLA Federate to the Subject, in order to be notified about updates.
132 | * @param observer
133 | */
134 | public void subscribeSubject(Observer observer);
135 |
136 | /**
137 | * Unsubscribes the HLA Federate from the Subject.
138 | * @param observer
139 | */
140 | public void unsubscribeSubject(Observer observer);
141 |
142 | /**
143 | * Publishes the Element on HLA/RTI platform
144 | * @param element
145 | * @throws NameNotFound
146 | * @throws FederateNotExecutionMember
147 | * @throws NotConnected
148 | * @throws RTIinternalError
149 | * @throws InvalidObjectClassHandle
150 | * @throws AttributeNotDefined
151 | * @throws ObjectClassNotDefined
152 | * @throws SaveInProgress
153 | * @throws RestoreInProgress
154 | * @throws InstantiationException
155 | * @throws IllegalAccessException
156 | * @throws IllegalName
157 | * @throws ObjectInstanceNameInUse
158 | * @throws ObjectInstanceNameNotReserved
159 | * @throws ObjectClassNotPublished
160 | * @throws AttributeNotOwned
161 | * @throws ObjectInstanceNotKnown
162 | * @throws PublishException
163 | * @throws UpdateException
164 | */
165 | public void publishElement(Object element) throws NameNotFound, FederateNotExecutionMember, NotConnected, RTIinternalError, InvalidObjectClassHandle, AttributeNotDefined, ObjectClassNotDefined, SaveInProgress, RestoreInProgress, InstantiationException, IllegalAccessException, IllegalName, ObjectInstanceNameInUse, ObjectInstanceNameNotReserved, ObjectClassNotPublished, AttributeNotOwned, ObjectInstanceNotKnown, PublishException, UpdateException;
166 |
167 | /**
168 | * Publishes the Element on HLA/RTI platform with the specified name
169 | * @param element
170 | * @param name
171 | * @throws NameNotFound
172 | * @throws FederateNotExecutionMember
173 | * @throws NotConnected
174 | * @throws RTIinternalError
175 | * @throws InvalidObjectClassHandle
176 | * @throws AttributeNotDefined
177 | * @throws ObjectClassNotDefined
178 | * @throws SaveInProgress
179 | * @throws RestoreInProgress
180 | * @throws PublishException
181 | * @throws InstantiationException
182 | * @throws IllegalAccessException
183 | * @throws IllegalName
184 | * @throws ObjectInstanceNameInUse
185 | * @throws ObjectInstanceNameNotReserved
186 | * @throws ObjectClassNotPublished
187 | * @throws AttributeNotOwned
188 | * @throws ObjectInstanceNotKnown
189 | * @throws UpdateException
190 | */
191 | public void publishElement(Object element, String name) throws NameNotFound, FederateNotExecutionMember, NotConnected, RTIinternalError, InvalidObjectClassHandle, AttributeNotDefined, ObjectClassNotDefined, SaveInProgress, RestoreInProgress, PublishException, InstantiationException, IllegalAccessException, IllegalName, ObjectInstanceNameInUse, ObjectInstanceNameNotReserved, ObjectClassNotPublished, AttributeNotOwned, ObjectInstanceNotKnown, UpdateException;
192 |
193 | /**
194 | * Publishes the Interaction on HLA/RTI platform
195 | * @param element
196 | * @throws RTIinternalError
197 | * @throws NameNotFound
198 | * @throws FederateNotExecutionMember
199 | * @throws NotConnected
200 | * @throws InvalidInteractionClassHandle
201 | * @throws PublishException
202 | * @throws InteractionParameterNotDefined
203 | * @throws InteractionClassNotPublished
204 | * @throws RestoreInProgress
205 | * @throws SaveInProgress
206 | * @throws InteractionClassNotDefined
207 | */
208 | public void publishInteraction(Object element) throws RTIinternalError, NameNotFound, FederateNotExecutionMember, NotConnected, InvalidInteractionClassHandle, PublishException, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, InteractionClassNotPublished, InteractionParameterNotDefined;
209 |
210 |
211 | /**
212 | * Updates the Element on HLA/RTI platform
213 | * @param element
214 | * @throws FederateNotExecutionMember
215 | * @throws NotConnected
216 | * @throws AttributeNotOwned
217 | * @throws AttributeNotDefined
218 | * @throws ObjectInstanceNotKnown
219 | * @throws SaveInProgress
220 | * @throws RestoreInProgress
221 | * @throws RTIinternalError
222 | * @throws UpdateException
223 | * @throws ObjectClassNotDefined
224 | * @throws ObjectClassNotPublished
225 | * @throws ObjectInstanceNameNotReserved
226 | * @throws ObjectInstanceNameInUse
227 | * @throws IllegalName
228 | */
229 | public void updateElement(Object element) throws FederateNotExecutionMember, NotConnected, AttributeNotOwned, AttributeNotDefined, ObjectInstanceNotKnown, SaveInProgress, RestoreInProgress, RTIinternalError, UpdateException, IllegalName, ObjectInstanceNameInUse, ObjectInstanceNameNotReserved, ObjectClassNotPublished, ObjectClassNotDefined;
230 |
231 | /**
232 | * Updates the Interaction on HLA/RTI platform
233 | * @param interaction
234 | * @throws InteractionClassNotPublished
235 | * @throws InteractionParameterNotDefined
236 | * @throws InteractionClassNotDefined
237 | * @throws SaveInProgress
238 | * @throws RestoreInProgress
239 | * @throws FederateNotExecutionMember
240 | * @throws NotConnected
241 | * @throws RTIinternalError
242 | * @throws UpdateException
243 | */
244 | public void updateInteraction(Object interaction) throws InteractionClassNotPublished, InteractionParameterNotDefined, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError, UpdateException;
245 |
246 | /**
247 | * Subscribes an ElementObject
248 | * @param objectClass
249 | * @throws InstantiationException
250 | * @throws IllegalAccessException
251 | * @throws NameNotFound
252 | * @throws FederateNotExecutionMember
253 | * @throws NotConnected
254 | * @throws RTIinternalError
255 | * @throws InvalidObjectClassHandle
256 | * @throws AttributeNotDefined
257 | * @throws ObjectClassNotDefined
258 | * @throws SaveInProgress
259 | * @throws RestoreInProgress
260 | * @throws SubscribeException
261 | */
262 | @SuppressWarnings("rawtypes")
263 | public void subscribeElement(Class objectClass) throws InstantiationException, IllegalAccessException, NameNotFound, FederateNotExecutionMember, NotConnected, RTIinternalError, InvalidObjectClassHandle, AttributeNotDefined, ObjectClassNotDefined, SaveInProgress, RestoreInProgress, SubscribeException;
264 |
265 | /**
266 | * Subscribes an InteractionObject
267 | * @param interactionClass
268 | * @throws RTIinternalError
269 | * @throws InstantiationException
270 | * @throws IllegalAccessException
271 | * @throws NameNotFound
272 | * @throws FederateNotExecutionMember
273 | * @throws NotConnected
274 | * @throws InvalidInteractionClassHandle
275 | * @throws FederateServiceInvocationsAreBeingReportedViaMOM
276 | * @throws InteractionClassNotDefined
277 | * @throws SaveInProgress
278 | * @throws RestoreInProgress
279 | * @throws SubscribeException
280 | */
281 | @SuppressWarnings("rawtypes")
282 | public void subscribeInteraction(Class interactionClass) throws RTIinternalError, InstantiationException, IllegalAccessException, NameNotFound, FederateNotExecutionMember, NotConnected, InvalidInteractionClassHandle, FederateServiceInvocationsAreBeingReportedViaMOM, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, SubscribeException;
283 |
284 | /**
285 | * Unsubscribes an ElementObject
286 | * @param objectClass
287 | * @throws ObjectClassNotDefined
288 | * @throws SaveInProgress
289 | * @throws RestoreInProgress
290 | * @throws FederateNotExecutionMember
291 | * @throws NotConnected
292 | * @throws RTIinternalError
293 | * @throws UnsubscribeException
294 | */
295 | @SuppressWarnings("rawtypes")
296 | public void unsubscribeElement(Class objectClass) throws ObjectClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError, UnsubscribeException;
297 |
298 | /**
299 | * Unsubscribes an InteractionObject
300 | * @param objectClass
301 | * @throws InteractionClassNotDefined
302 | * @throws SaveInProgress
303 | * @throws RestoreInProgress
304 | * @throws FederateNotExecutionMember
305 | * @throws NotConnected
306 | * @throws RTIinternalError
307 | * @throws UnsubscribeException
308 | */
309 | @SuppressWarnings("rawtypes")
310 | public void unsubscribeInteraction(Class objectClass) throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError, UnsubscribeException;
311 |
312 | }
313 |
--------------------------------------------------------------------------------
/src/main/java/dkf/core/DKFRTIAmbassador.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.core;
23 |
24 | import org.apache.logging.log4j.LogManager;
25 | import org.apache.logging.log4j.Logger;
26 |
27 | import hla.rti1516e.RTIambassador;
28 | import hla.rti1516e.RtiFactory;
29 | import hla.rti1516e.RtiFactoryFactory;
30 | import hla.rti1516e.exceptions.RTIinternalError;
31 |
32 | public final class DKFRTIAmbassador {
33 |
34 | private static final Logger logger = LogManager.getLogger(DKFRTIAmbassador.class);
35 |
36 | private static RTIambassador rtiambassador = null;
37 | private static RtiFactory rtifactory = null;
38 |
39 | private DKFRTIAmbassador() throws RTIinternalError {
40 | rtifactory = RtiFactoryFactory.getRtiFactory();
41 | rtiambassador = rtifactory.getRtiAmbassador();
42 |
43 | // Get information on the HLA/RTI
44 | logger.info("Vendor HLA/RTI: name:"+rtifactory.rtiName()+", rtiVersion: "+rtifactory.rtiVersion()+
45 | ", hlaVersion: "+rtiambassador.getHLAversion());
46 |
47 | }
48 |
49 | public static synchronized RTIambassador getInstance() throws RTIinternalError {
50 | if(rtiambassador == null)
51 | new DKFRTIAmbassador();
52 | return rtiambassador;
53 | }
54 |
55 | public String rtiName() {
56 | return rtifactory.rtiName();
57 | }
58 |
59 | public String rtiVersion() {
60 | return rtifactory.rtiVersion();
61 | }
62 |
63 | public String hlaVersion() {
64 | return rtiambassador.getHLAversion();
65 | }
66 |
67 | @Override
68 | protected Object clone() throws CloneNotSupportedException {
69 | throw new CloneNotSupportedException("Clone not supported!");
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/dkf/core/ExecutionTask.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.core;
23 |
24 | import java.util.concurrent.atomic.AtomicBoolean;
25 |
26 | import dkf.time.TimeInterface;
27 | import hla.rti1516e.exceptions.RTIexception;
28 |
29 | public class ExecutionTask implements Runnable {
30 |
31 | private DKFAbstractFederate federate = null;
32 | private DKFAbstractFederateAmbassador fedamb = null;
33 | private DKFHLAModule hlamodule = null;
34 |
35 | private AtomicBoolean CONTINUE_EXECUTION = null;
36 |
37 | private long exec_loop_counter = 0;
38 |
39 | // Simulation time parameters.
40 | private TimeInterface time = null;
41 |
42 | protected ExecutionTask(DKFHLAModule hlamodule, TimeInterface time) {
43 | this.hlamodule = hlamodule;
44 | this.federate = hlamodule.getFederate();
45 | this.fedamb = hlamodule.getAmbassador();
46 | this.time = time;
47 | this.CONTINUE_EXECUTION = new AtomicBoolean(true);
48 | }
49 |
50 | @Override
51 | public void run() {
52 |
53 | while(CONTINUE_EXECUTION.get()){
54 | time.setFederateExecutionTimeCycle((exec_loop_counter * time.getTimeClycle()));
55 |
56 | // check realtime execution
57 | if (federate.getConfig().isRealtime()) {
58 | try {
59 | Thread.sleep(1000);
60 | } catch(Exception e) {
61 | e.printStackTrace();
62 | }
63 | }
64 | // Wait for the time advance grant.
65 | while(!fedamb.isAdvancing()){
66 | try {
67 | Thread.sleep(10);
68 | } catch( Exception e ) {
69 | e.printStackTrace();
70 | }
71 | }
72 |
73 | federate.doAction();
74 |
75 | // Request a time advance by the logical time interval.
76 | try {
77 | hlamodule.makeTARequest();
78 | } catch (RTIexception e) {
79 | e.printStackTrace();
80 | }
81 | exec_loop_counter++;
82 | }
83 |
84 | }
85 |
86 | protected void shutdown() {
87 | this.CONTINUE_EXECUTION.set(false);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/dkf/core/observer/Subject.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.core.observer;
23 |
24 | import java.util.Observable;
25 |
26 | public class Subject extends Observable {
27 |
28 | public Subject() {
29 |
30 | }
31 |
32 | public void notifyUpdate(Object obj){
33 | this.setChanged();
34 | this.notifyObservers(obj);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/ConfigurationSyntaxException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | /**
25 | *
26 | * @author SMASH-Lab University of Calabria
27 | * @version 0.1
28 | *
29 | */
30 | public class ConfigurationSyntaxException extends RuntimeException {
31 |
32 | private static final long serialVersionUID = 1L;
33 |
34 | public ConfigurationSyntaxException(String message){
35 | super(message);
36 | }
37 |
38 | public ConfigurationSyntaxException(String message, Throwable cause){
39 | super(message, cause);
40 | }
41 |
42 | public ConfigurationSyntaxException(Throwable cause){
43 | super(cause);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/FirewallExeption.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class FirewallExeption extends RuntimeException {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public FirewallExeption(String message) {
29 | super(message);
30 | }
31 |
32 | public FirewallExeption(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | public FirewallExeption(Throwable cause) {
37 | super(cause);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/PublishException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class PublishException extends Exception {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public PublishException(String message){
29 | super(message);
30 | }
31 |
32 | public PublishException(String message, Throwable cause){
33 | super(message, cause);
34 | }
35 |
36 | public PublishException(Throwable cause){
37 | super(cause);
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/RegisterElementNameException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class RegisterElementNameException extends Exception {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public RegisterElementNameException(String message){
29 | super(message);
30 | }
31 |
32 | public RegisterElementNameException(String message, Throwable cause){
33 | super(message, cause);
34 | }
35 |
36 | public RegisterElementNameException(Throwable cause){
37 | super(cause);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/SubscribeException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class SubscribeException extends Exception {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public SubscribeException(String message){
29 | super(message);
30 | }
31 |
32 | public SubscribeException(String message, Throwable cause){
33 | super(message, cause);
34 | }
35 |
36 | public SubscribeException(Throwable cause){
37 | super(cause);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/TimeRepresentationException.java:
--------------------------------------------------------------------------------
1 | package dkf.exception;
2 |
3 | public class TimeRepresentationException extends Exception {
4 |
5 | private static final long serialVersionUID = 1L;
6 |
7 | public TimeRepresentationException(String message){
8 | super(message);
9 | }
10 |
11 | public TimeRepresentationException(String message, Throwable cause){
12 | super(message, cause);
13 | }
14 |
15 | public TimeRepresentationException(Throwable cause){
16 | super(cause);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/UnsubscribeException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class UnsubscribeException extends Exception {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public UnsubscribeException(String message){
29 | super(message);
30 | }
31 |
32 | public UnsubscribeException(String message, Throwable cause){
33 | super(message, cause);
34 | }
35 |
36 | public UnsubscribeException(Throwable cause){
37 | super(cause);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/dkf/exception/UpdateException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.exception;
23 |
24 | public class UpdateException extends Exception {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | public UpdateException(String message){
29 | super(message);
30 | }
31 |
32 | public UpdateException(String message, Throwable cause){
33 | super(message, cause);
34 | }
35 |
36 | public UpdateException(Throwable cause){
37 | super(cause);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/Order.java:
--------------------------------------------------------------------------------
1 | package dkf.model;
2 |
3 | public enum Order {
4 |
5 | TIMESTAMP, RECEIVE, UNKNOWN
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/Sharing.java:
--------------------------------------------------------------------------------
1 | package dkf.model;
2 |
3 | public enum Sharing {
4 |
5 | PUBLISH, SUBSCRIBE, PUBLISH_SUBSCRIBE,UNKNOWN
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/Transportation.java:
--------------------------------------------------------------------------------
1 | package dkf.model;
2 |
3 | public enum Transportation {
4 |
5 | HLA_BEST_EFFORT, HLA_REILABLE, UNKNOWN
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/interaction/InteractionClassEntity.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.model.interaction;
23 |
24 | import dkf.model.object.AbstractClassEntity;
25 |
26 | public class InteractionClassEntity extends AbstractClassEntity {
27 |
28 | public InteractionClassEntity(String instanceName, Object element) {
29 | super(element);
30 | this.instanceName = instanceName;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/interaction/InteractionClassModel.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.model.interaction;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 | import java.util.Map.Entry;
27 |
28 | import hla.rti1516e.InteractionClassHandle;
29 | import hla.rti1516e.ParameterHandle;
30 | import hla.rti1516e.ParameterHandleValueMap;
31 | import hla.rti1516e.RTIambassador;
32 | import hla.rti1516e.exceptions.FederateNotExecutionMember;
33 | import hla.rti1516e.exceptions.FederateServiceInvocationsAreBeingReportedViaMOM;
34 | import hla.rti1516e.exceptions.InteractionClassNotDefined;
35 | import hla.rti1516e.exceptions.InteractionClassNotPublished;
36 | import hla.rti1516e.exceptions.InteractionParameterNotDefined;
37 | import hla.rti1516e.exceptions.InvalidInteractionClassHandle;
38 | import hla.rti1516e.exceptions.NameNotFound;
39 | import hla.rti1516e.exceptions.NotConnected;
40 | import hla.rti1516e.exceptions.RTIinternalError;
41 | import hla.rti1516e.exceptions.RestoreInProgress;
42 | import hla.rti1516e.exceptions.SaveInProgress;
43 |
44 | import org.apache.logging.log4j.LogManager;
45 | import org.apache.logging.log4j.Logger;
46 |
47 | import dkf.core.DKFRTIAmbassador;
48 | import dkf.model.object.ObjectModelStatus;
49 |
50 | public class InteractionClassModel {
51 |
52 | private static Logger logger = LogManager.getLogger(InteractionClassModel.class);
53 |
54 | private ObjectModelStatus status = ObjectModelStatus.UNKNOWN;
55 | private InteractionClassHandle interactionClassHandle = null;
56 |
57 | private Map mapFieldNameParameterHandle = null;
58 |
59 | private RTIambassador rti_ambassador = null;
60 |
61 | private InteractionClassEntity interactionEntity = null;
62 | private InteractionClassModelParser parser = null;
63 |
64 | private ParameterHandleValueMap parameter_values = null;
65 |
66 | @SuppressWarnings({ "rawtypes", "unchecked" })
67 | public InteractionClassModel(Class interactionClass) throws RTIinternalError, NameNotFound, FederateNotExecutionMember, NotConnected, InvalidInteractionClassHandle {
68 | this.rti_ambassador = DKFRTIAmbassador.getInstance();
69 | this.parser = new InteractionClassModelParser(interactionClass);
70 | initialize();
71 | }
72 |
73 | private void initialize() throws NameNotFound, FederateNotExecutionMember, NotConnected, RTIinternalError, InvalidInteractionClassHandle {
74 |
75 | if(status == ObjectModelStatus.UNKNOWN){
76 |
77 | // Get a handle to the class.
78 | this.interactionClassHandle = rti_ambassador.getInteractionClassHandle(parser.getClassHandleName());
79 | this.mapFieldNameParameterHandle = new HashMap();
80 |
81 | // Get handles to all the attributes.
82 | ParameterHandle tmp = null;
83 | for(String str : parser.getMapFieldCoder().keySet()){
84 | tmp = rti_ambassador.getParameterHandle(interactionClassHandle, str);
85 | mapFieldNameParameterHandle.put(str, tmp);
86 | }
87 |
88 | this.parameter_values = rti_ambassador.getParameterHandleValueMapFactory().create(mapFieldNameParameterHandle.size());
89 | status = ObjectModelStatus.INITIALIZED;
90 |
91 | }
92 | }
93 |
94 | public void subscribe() throws FederateServiceInvocationsAreBeingReportedViaMOM, InteractionClassNotDefined, SaveInProgress,
95 | RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
96 |
97 | if(status == ObjectModelStatus.INITIALIZED){
98 |
99 | rti_ambassador.subscribeInteractionClass(this.interactionClassHandle);
100 | status = ObjectModelStatus.SUBSCRIBED;
101 | }
102 | else{
103 | logger.error("You can't subscribe an uninitialized interaction!");
104 | throw new IllegalStateException("You can't subscribe an uninitialized interaction!");
105 | }
106 | }
107 |
108 | public void unsubscribe() throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
109 | if(status == ObjectModelStatus.SUBSCRIBED){
110 |
111 | rti_ambassador.unsubscribeInteractionClass(this.interactionClassHandle);
112 | status = ObjectModelStatus.UNKNOWN;
113 | }
114 | else{
115 | logger.error("You can't unsubscribe "+this.interactionClassHandle+" because it is not subscribed");
116 | throw new IllegalStateException("You can't unsubscribe "+this.interactionClassHandle+" because it is not subscribed");
117 | }
118 | }
119 |
120 | public void publish() throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
121 |
122 | if(status == ObjectModelStatus.INITIALIZED){
123 | rti_ambassador.publishInteractionClass(interactionClassHandle);
124 | status = ObjectModelStatus.PUBLISHED;
125 | }
126 | else{
127 | logger.error("You can't publish an uninitialized or an already published InteractionClassModel!");
128 | throw new IllegalStateException("You can't publish an uninitialized or an already published InteractionClassModel!");
129 | }
130 | }
131 |
132 | public void unpublish() throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
133 |
134 | if(status == ObjectModelStatus.PUBLISHED){
135 | rti_ambassador.unpublishInteractionClass(interactionClassHandle);
136 | status = ObjectModelStatus.UNKNOWN;
137 | }
138 | else{
139 | logger.error("You can't unpublish an uninitialized or an unpublished InteractionClassModel!");
140 | throw new IllegalStateException("You can't unpublish an uninitialized or an unpublished InteractionClassModel!");
141 | }
142 | }
143 |
144 | public void updatePublishedInteraction() throws InteractionClassNotPublished, InteractionParameterNotDefined, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
145 |
146 |
147 | if(status == ObjectModelStatus.PUBLISHED) {
148 | Map ris = parser.encode(interactionEntity.getElement());
149 | for(Entry entry : mapFieldNameParameterHandle.entrySet())
150 | parameter_values.put(entry.getValue(), ris.get(entry.getKey()));
151 |
152 | rti_ambassador.sendInteraction(interactionClassHandle, parameter_values, null);
153 | }
154 | else{
155 | logger.error("Can't update the ' "+interactionEntity+" ', because it is not published!");
156 | throw new IllegalStateException("Can't update the ' "+interactionEntity+" ', because it is not published!");
157 | }
158 |
159 | }
160 |
161 | public void updateSubscribedInteraction(ParameterHandleValueMap arg1) {
162 |
163 | if(status == ObjectModelStatus.SUBSCRIBED)
164 | parser.decode(interactionEntity.getElement(), mapFieldNameParameterHandle, arg1);
165 | else{
166 | logger.error("Can't update the ' "+interactionEntity+" ', because it is not subscribed !");
167 | throw new IllegalStateException("Can't update the ' "+interactionEntity+" ', because it is not subscribed !");
168 | }
169 | }
170 |
171 | public InteractionClassHandle getInteractionClassHandle() {
172 | return this.interactionClassHandle;
173 | }
174 |
175 | public void addEntity(Object interaction){
176 | this.interactionEntity = new InteractionClassEntity(interaction.getClass().getName()+interaction.hashCode(), interaction);
177 | }
178 |
179 | public InteractionClassEntity getEntity() {
180 | return this.interactionEntity;
181 | }
182 |
183 | }
184 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/interaction/InteractionClassModelManager.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 | package dkf.model.interaction;
23 |
24 | import hla.rti1516e.InteractionClassHandle;
25 | import hla.rti1516e.ParameterHandleValueMap;
26 | import hla.rti1516e.exceptions.FederateNotExecutionMember;
27 | import hla.rti1516e.exceptions.FederateServiceInvocationsAreBeingReportedViaMOM;
28 | import hla.rti1516e.exceptions.InteractionClassNotDefined;
29 | import hla.rti1516e.exceptions.InteractionClassNotPublished;
30 | import hla.rti1516e.exceptions.InteractionParameterNotDefined;
31 | import hla.rti1516e.exceptions.InvalidInteractionClassHandle;
32 | import hla.rti1516e.exceptions.NameNotFound;
33 | import hla.rti1516e.exceptions.NotConnected;
34 | import hla.rti1516e.exceptions.RTIinternalError;
35 | import hla.rti1516e.exceptions.RestoreInProgress;
36 | import hla.rti1516e.exceptions.SaveInProgress;
37 |
38 | import java.util.HashMap;
39 | import java.util.Map;
40 |
41 | import org.apache.commons.collections4.BidiMap;
42 | import org.apache.commons.collections4.bidimap.DualHashBidiMap;
43 |
44 | import dkf.model.interaction.annotations.InteractionClass;
45 |
46 | @SuppressWarnings("rawtypes")
47 | public class InteractionClassModelManager {
48 |
49 | //maps for published element
50 | private Map published = null;
51 | private Map mapInstanceNameInteractionClassEntity = null;
52 |
53 | //maps for subscribed element
54 | private Map subscribed = null;
55 | private BidiMap mapInteractionClassHandleClass = null;
56 |
57 |
58 | public InteractionClassModelManager() {
59 | this.published = new HashMap();
60 | this.mapInstanceNameInteractionClassEntity = new HashMap();
61 |
62 | this.subscribed = new HashMap();
63 | this.mapInteractionClassHandleClass = new DualHashBidiMap();
64 | }
65 |
66 | public Map getPublishedMap() {
67 | return this.published;
68 | }
69 |
70 | public Map getSubscribedMap() {
71 | return this.subscribed;
72 | }
73 |
74 | public void publish(Object interaction) throws RTIinternalError, NameNotFound, FederateNotExecutionMember, NotConnected, InvalidInteractionClassHandle, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, InteractionClassNotPublished, InteractionParameterNotDefined {
75 |
76 | InteractionClassModel icm = published.get(interaction.getClass().getAnnotation(InteractionClass.class).name());
77 |
78 | if(icm == null){
79 | icm = new InteractionClassModel(interaction.getClass());
80 | icm.addEntity(interaction);
81 | icm.publish();
82 | this.published.put(interaction.getClass().getAnnotation(InteractionClass.class).name(), icm);
83 | this.mapInstanceNameInteractionClassEntity.put(icm.getEntity().getInstanceName(), icm.getEntity());
84 | }
85 | }
86 |
87 | @SuppressWarnings("unchecked")
88 | public void subscribe(Class interactionClass) throws RTIinternalError, NameNotFound, FederateNotExecutionMember, NotConnected, InvalidInteractionClassHandle, FederateServiceInvocationsAreBeingReportedViaMOM, InteractionClassNotDefined, SaveInProgress, RestoreInProgress, InstantiationException, IllegalAccessException {
89 |
90 | InteractionClassModel icm = new InteractionClassModel(interactionClass);
91 | icm.addEntity(interactionClass.newInstance());
92 | icm.subscribe();
93 | this.subscribed.put(((Class extends InteractionClass>)interactionClass).getAnnotation(InteractionClass.class).name(), icm);
94 | this.mapInteractionClassHandleClass.put(icm.getInteractionClassHandle(), interactionClass);
95 | }
96 |
97 | @SuppressWarnings("unchecked")
98 | public void unsubscribe(Class interactionClass) throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, FederateNotExecutionMember, NotConnected, RTIinternalError {
99 | this.subscribed.remove(((Class extends InteractionClass>)interactionClass).getAnnotation(InteractionClass.class).name()).unsubscribe();
100 | this.mapInteractionClassHandleClass.inverseBidiMap().remove(interactionClass);
101 | }
102 |
103 | public boolean interactionInstanceHandleIsSubscribed(InteractionClassHandle arg0) {
104 | return this.mapInteractionClassHandleClass.get(arg0) != null;
105 | }
106 |
107 | @SuppressWarnings("unchecked")
108 | public Object receiveInteraction(InteractionClassHandle arg0, ParameterHandleValueMap arg1) {
109 |
110 | InteractionClassModel icm = subscribed.get(((Class)mapInteractionClassHandleClass.get(arg0)).getAnnotation(InteractionClass.class).name());
111 | if(icm != null){
112 | icm.updateSubscribedInteraction(arg1);
113 | return icm.getEntity().getElement();
114 | }
115 | return null;
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/main/java/dkf/model/interaction/InteractionClassModelParser.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | HLADevelopmentKit - A Java framework to develop HLA Federates.
3 | Copyright (c) 2015, SMASH Lab - University of Calabria (Italy),
4 | All rights reserved.
5 |
6 | GNU Lesser General Public License (GNU LGPL).
7 |
8 | This library is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 3.0 of the License, or (at your option) any later version.
12 |
13 | This library is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | Lesser General Public License for more details.
17 |
18 | You should have received a copy of the GNU Lesser General Public
19 | License along with this library.
20 | If not, see http://http://www.gnu.org/licenses/
21 | *****************************************************************/
22 |
23 | package dkf.model.interaction;
24 |
25 | import hla.rti1516e.ParameterHandle;
26 | import hla.rti1516e.ParameterHandleValueMap;
27 | import hla.rti1516e.encoding.DecoderException;
28 |
29 | import java.beans.IntrospectionException;
30 | import java.beans.PropertyDescriptor;
31 | import java.lang.reflect.Field;
32 | import java.lang.reflect.InvocationTargetException;
33 | import java.util.HashMap;
34 | import java.util.Map;
35 |
36 | import org.apache.logging.log4j.LogManager;
37 | import org.apache.logging.log4j.Logger;
38 |
39 | import dkf.coder.Coder;
40 | import dkf.model.interaction.annotations.InteractionClass;
41 | import dkf.model.interaction.annotations.Parameter;
42 | import dkf.model.parser.AbstractObjectModelParser;
43 |
44 |
45 |
46 | public class InteractionClassModelParser extends AbstractObjectModelParser {
47 |
48 | private static final Logger logger = LogManager.getLogger(InteractionClassModelParser.class);
49 |
50 | protected Class extends InteractionClass> interactionClassModel = null;
51 |
52 |
53 | public InteractionClassModelParser(Class extends InteractionClass> interactionClassModel) {
54 | super();
55 | this.interactionClassModel = interactionClassModel;
56 | retrieveClassModelStructure();
57 | }
58 |
59 | @SuppressWarnings({ "rawtypes" })
60 | protected void retrieveClassModelStructure() {
61 |
62 | this.classHandleName = interactionClassModel.getAnnotation(InteractionClass.class).name();
63 | fields = interactionClassModel.getDeclaredFields();
64 | Map tmpMapCoder = new HashMap();
65 | Coder coderTmp = null;
66 |
67 | try {
68 | for(Field f : fields){
69 | if(f.isAnnotationPresent(Parameter.class)){
70 | coderTmp = tmpMapCoder.get(f.getAnnotation(Parameter.class).coder());
71 | if(coderTmp == null){
72 | coderTmp = f.getAnnotation(Parameter.class).coder().newInstance();
73 | tmpMapCoder.put(f.getAnnotation(Parameter.class).coder(), coderTmp);
74 | }
75 | matchingObjectCoderIsValid(f, coderTmp);
76 | mapFieldCoder.put(f.getAnnotation(Parameter.class).name(), coderTmp);
77 | }
78 | }
79 | } catch (InstantiationException | IllegalAccessException e) {
80 | logger.error("Error in retreving the annotations of the fields");
81 | e.printStackTrace();
82 | } finally {
83 | tmpMapCoder = null;
84 | coderTmp = null;
85 | }
86 |
87 | }
88 |
89 | @SuppressWarnings("unchecked")
90 | public Map encode(Object interaction) {
91 |
92 | if(interaction == null){
93 | logger.error("The argument is null");
94 | throw new IllegalArgumentException("The parameter value cannot be null");
95 | }
96 |
97 | logger.debug("Encoding: "+interaction.toString());
98 |
99 | PropertyDescriptor pd = null;
100 | Object fieldValue = null;
101 | Coder