DCCL v4
test.proto
1 // Copyright 2013-2023:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 // Davide Fenucci <davfen@noc.ac.uk>
8 //
9 //
10 // This file is part of the Dynamic Compact Control Language Library
11 // ("DCCL").
12 //
13 // DCCL is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published by
15 // the Free Software Foundation, either version 2.1 of the License, or
16 // (at your option) any later version.
17 //
18 // DCCL is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
25 syntax = "proto2";
26 
27 import "dccl/option_extensions.proto";
28 package dccl.test;
29 
30 message NumericMsg
31 {
32  option (dccl.msg).id = 10;
33  option (dccl.msg).max_bytes = 32;
34  option (dccl.msg).codec_version = 4;
35 
36  optional double a = 1 [
37  (dccl.field).max = 180,
38  (dccl.field).min = -180,
39  (dccl.field).precision = 12,
40  (dccl.field).in_head = true
41  ];
42 
43  optional double b = 2 [
44  (dccl.field).max = 18,
45  (dccl.field).min = -18,
46  (dccl.field).resolution = 0.0001
47  ];
48 
49  // max is 2^64 rounded to 1e5
50  required uint64 u1 = 3 [
51  (dccl.field).max = 18446744073709500000,
52  (dccl.field).min = 0,
53  (dccl.field).precision = -5
54  ];
55 
56  // max is 2^64 rounded to 1e5
57  required uint64 u2 = 4 [
58  (dccl.field).max = 18446744073709500000,
59  (dccl.field).min = 0,
60  (dccl.field).resolution = 100000
61  ];
62 
63  // resolution != 10^N
64  required double u3 = 5 [
65  (dccl.field).max = 15.5,
66  (dccl.field).min = 5.5,
67  (dccl.field).resolution = 0.5
68  ];
69 
70  // resolution default
71  required double u4 = 6 [(dccl.field).max = 20.0, (dccl.field).min = 0.0];
72 
73  // weird resolution
74  required double u5 = 7 [
75  (dccl.field).max = 3.6,
76  (dccl.field).min = 1.44,
77  (dccl.field).resolution = 0.12
78  ];
79 
80  // old precision field did not require min and max to be a multiple of
81  // resolution
82  required int32 u6 = 8 [
83  (dccl.field).min = 0,
84  (dccl.field).max = 25599,
85  (dccl.field).precision = -2
86  ];
87 }
88 
89 message NegativeResolutionNumericMsg // Invalid resolution
90 {
91  option (dccl.msg).id = 10;
92  option (dccl.msg).max_bytes = 32;
93  option (dccl.msg).codec_version = 4;
94 
95  optional double a = 1 [
96  (dccl.field).min = -20,
97  (dccl.field).max = 20,
98  (dccl.field).resolution = -0.5
99  ];
100 
101  optional int32 b = 2 [
102  (dccl.field).min = -500000,
103  (dccl.field).max = 500000,
104  (dccl.field).precision = -3
105  ];
106 }
107 
108 message BothResolutionAndPrecisionSetNumericMsg
109 {
110  option (dccl.msg).id = 11;
111  option (dccl.msg).max_bytes = 32;
112  option (dccl.msg).codec_version = 4;
113 
114  optional double a = 1 [
115  (dccl.field).max = 180,
116  (dccl.field).min = -180,
117  (dccl.field).precision = 1,
118  (dccl.field).resolution = 0.1
119  ];
120 }
121 
122 message TooBigNumericMsg
123 {
124  option (dccl.msg).id = 11;
125  option (dccl.msg).max_bytes = 32;
126  option (dccl.msg).codec_version = 4;
127 
128  optional double a = 1 [
129  (dccl.field).max = 180,
130  (dccl.field).min = -180,
131  (dccl.field).resolution = 1e-15
132  ];
133 }
134 
135 message MinNotMultipleOfResolution
136 {
137  option (dccl.msg).id = 11;
138  option (dccl.msg).max_bytes = 32;
139  option (dccl.msg).codec_version = 4;
140 
141  required double a = 1 [
142  (dccl.field).max = 3.6,
143  (dccl.field).min = 1.5,
144  (dccl.field).resolution = 0.2
145  ];
146 }
147 
148 message MaxNotMultipleOfResolution
149 {
150  option (dccl.msg).id = 11;
151  option (dccl.msg).max_bytes = 32;
152  option (dccl.msg).codec_version = 4;
153 
154  required double a = 1 [
155  (dccl.field).max = 3.5,
156  (dccl.field).min = 1.4,
157  (dccl.field).resolution = 0.2
158  ];
159 }