Skip to content

Commit 68b1ac9

Browse files
authored
Documentation/interface convention (#380)
* Changed numeric list for citation * Adding interface naming convention * Added section about the use of UNKNOWN in GT
1 parent a793e4a commit 68b1ac9

File tree

2 files changed

+119
-8
lines changed

2 files changed

+119
-8
lines changed

doc/commenting.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,22 @@ Every OSI message should be defined properly and should have a well cited refere
215215
- Find filled-out examples under `https://apastyle.apa.org <https://apastyle.apa.org/style-grammar-guidelines/references/examples>`_ and in existing entries.
216216
- The scheme of popular sources for the reference list is as follows (replace tags with corresponding values):
217217

218-
.. [#] <author1>, <author2>, <author3> & <author4>. (<year>). Contribution in a compilation title. <em><Compilation Title></em>. <edition>. <page(s)>. <publisher>. <location>. <doi>. <page(s)>.
219-
.. [#] <author1>, <author2> & <author3>. (<year>). <em><book (monograph) title></em>. <edition>. <publisher>. <doi>. <page(s)>.
220-
.. [#] <author1> & <author2>. (<year>). <book chapter title>. In <editor1> & <editor2> (Eds.), <em><book title></em> (<page(s)>). <publisher>. <doi>. <page(s)>.
221-
.. [#] <author1> & <author2>. (<year>). <journal article title>. <em><journal title></em>. <page(s)>. <location>. <doi>. <page(s)>.
222-
.. [#] <author>. (<year>). <em><Phd thesis title></em>. Phd. thesis. <location>. <university>. <doi or url>. <page(s)>.
223-
.. [#] <author>. (<year>, <month> <day>). <em><internet article title></em>. Retrieved <month> <day>, <year>, from <url>.
224-
.. [#] <standarding organisation>. (<year>). <em><title of the standard></em>. (<standard identifier>). <location>.
225-
.. [#] <author>. (<year>). <em><patent title and id></em>. <location>. <organisation>.
218+
1. <author1>, <author2>, <author3> & <author4>. (<year>). Contribution in a compilation title. <em><Compilation Title></em>. <edition>. <page(s)>. <publisher>. <location>. <doi>. <page(s)>.
219+
220+
2. <author1>, <author2> & <author3>. (<year>). <em><book (monograph) title></em>. <edition>. <publisher>. <doi>. <page(s)>.
221+
222+
3. <author1> & <author2>. (<year>). <book chapter title>. In <editor1> & <editor2> (Eds.), <em><book title></em> (<page(s)>). <publisher>. <doi>. <page(s)>.
223+
224+
4. <author1> & <author2>. (<year>). <journal article title>. <em><journal title></em>. <page(s)>. <location>. <doi>. <page(s)>.
225+
226+
5. <author>. (<year>). <em><Phd thesis title></em>. Phd. thesis. <location>. <university>. <doi or url>. <page(s)>.
227+
228+
6. <author>. (<year>, <month> <day>). <em><internet article title></em>. Retrieved <month> <day>, <year>, from <url>.
229+
230+
7. <standarding organisation>. (<year>). <em><title of the standard></em>. (<standard identifier>). <location>.
231+
232+
8. <author>. (<year>). <em><patent title and id></em>. <location>. <organisation>.
233+
226234

227235

228236
.. code-block:: protobuf

doc/interfaceconventions.rst

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
.. _iconventions:
2+
3+
Interface Conventions
4+
======================
5+
6+
When adding new messages, enums, field messages and field enums to OSI we enforce a few naming conventions for each type like in the `style guide <https://developers.google.com/protocol-buffers/docs/style>`_ from protobuf.
7+
8+
Message Naming
9+
---------------
10+
A message definition should always be in camel case. This means that the first letter of each word in a message should be upper case without any spaces. See example below:
11+
12+
.. code-block:: protobuf
13+
14+
message EnvironmentalConditions
15+
{
16+
}
17+
18+
Top-Level Messages
19+
-------------------
20+
All messages that are intended to be exchanged as a stand-alone message, i.e. not required to be embedded in another message, like e.g. ``SensorView`` or ``SensorViewConfiguration``, are required to carry an ``InterfaceVersion`` field as their first field, and a ``Timestamp`` field as their second field, e.g.:
21+
22+
.. code-block:: protobuf
23+
24+
message TopLevel
25+
{
26+
// The interface version used by the sender (simulation environment).
27+
//
28+
optional InterfaceVersion version = 1;
29+
30+
// The data timestamp of the simulation environment. Zero time is arbitrary
31+
// but must be identical for all messages. Zero time does not need to
32+
// coincide with the UNIX epoch. Recommended is the starting time point of
33+
// the simulation.
34+
//
35+
optional Timestamp timestamp = 2;
36+
}
37+
38+
Field Message Naming
39+
---------------------
40+
After defining a message fields can be added to it in snake case format. This means every letter is lower case and the words are connected through an underline character. See example below:
41+
42+
.. code-block:: protobuf
43+
44+
message EnvironmentalConditions
45+
{
46+
optional double atmospheric_pressure = 1;
47+
}
48+
49+
Field Numbering
50+
----------------
51+
52+
Fields should be numbered consecutively starting from 1 on first definition. During maintenance, the rules of backward/forward-compatibility require that fields are never renumbered, and field numbers never re-used unless a major release is performed.
53+
54+
All field numbers of 10000 and above are reserved for user-defined extensions and will thus never be used by OSI message fields.
55+
56+
Enum Naming
57+
------------
58+
The naming of an enum should be camel case. See example below:
59+
60+
.. code-block:: protobuf
61+
62+
message EnvironmentalConditions
63+
{
64+
optional double atmospheric_pressure = 1;
65+
66+
enum AmbientIllumination
67+
{
68+
}
69+
}
70+
71+
Enum Field Naming
72+
------------
73+
The naming of an enum field should be all in upper case. The start should be converted from the enum name camel case to upper case snake case. It is mandatory to add to the first enum field name the postfix ``_UNKNOWN`` and to the second the postfix ``_OTHER``. After that the naming can be decided by the user. It is often mentioned that the value ``_UNKNOWN`` should not be used in a ``GroundTruth`` message as there are now uncertanties by definition in ``the truth``. These values are mostly used in messages like ``SensorData`` where the content is subject to interpretation. See example below:
74+
75+
.. code-block:: protobuf
76+
77+
message EnvironmentalConditions
78+
{
79+
optional double atmospheric_pressure = 1;
80+
81+
enum AmbientIllumination
82+
{
83+
AMBIENT_ILLUMINATION_UNKNOWN = 0;
84+
85+
AMBIENT_ILLUMINATION_OTHER = 1;
86+
87+
AMBIENT_ILLUMINATION_LEVEL1 = 2;
88+
}
89+
}
90+
91+
Summary
92+
--------
93+
Here a small summary for the naming conventions:
94+
95+
Messages: camel case
96+
97+
Message Fields: snake case
98+
99+
Enum: camel case
100+
101+
Enum Fields: upper case, name of enum converted in upper case snake case and then following the specified name
102+
103+
After defining the messages do not forget to comment them. See also the `section for commenting <https://opensimulationinterface.github.io/osi-documentation/open-simulation-interface/doc/commenting.html>`_ of fields and messages.

0 commit comments

Comments
 (0)