DCCL v5
Loading...
Searching...
No Matches
test.proto
1// Copyright 2013-2026:
2// GobySoft, LLC (2013-)
3// Massachusetts Institute of Technology (2007-2014)
4// Community contributors (see AUTHORS file)
5// File authors:
6// Cadmus To <cadmus.to+dev@gmail.com>
7//
8//
9// This file is part of the Dynamic Compact Control Language Library
10// ("DCCL").
11//
12// DCCL is free software: you can redistribute it and/or modify
13// it under the terms of the GNU Lesser General Public License as published by
14// the Free Software Foundation, either version 2.1 of the License, or
15// (at your option) any later version.
16//
17// DCCL is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with DCCL. If not, see <http://www.gnu.org/licenses/>.
24syntax = "proto2";
25import "dccl/option_extensions.proto";
26package dccl.test;
27
28message FloatMsg
29{
30 option (dccl.msg).id = 1501;
31 option (dccl.msg).max_bytes = 32;
32 option (dccl.msg).codec_version = 5;
33
34 optional float f = 1 [
35 (dccl.field).max = 10,
36 (dccl.field).min = -10,
37 (dccl.field).precision = 7
38 ];
39}
40
41message NegativePrecisionFloatMsg
42{
43 option (dccl.msg).id = 2101;
44 option (dccl.msg).max_bytes = 32;
45 option (dccl.msg).codec_version = 5;
46
47 optional float f = 1 [
48 (dccl.field).max = 20,
49 (dccl.field).min = -20,
50 (dccl.field).precision = -1
51 ];
52}
53
54message PrecisionRangeFloatMsg
55{
56 option (dccl.msg).id = 2201;
57 option (dccl.msg).max_bytes = 256;
58 option (dccl.msg).codec_version = 5;
59
60 optional float prec0 = 1 [
61 (dccl.field).max = 10000000,
62 (dccl.field).min = -10000000,
63 (dccl.field).precision = 0
64 ];
65 optional float prec1 = 2 [
66 (dccl.field).max = 1000000,
67 (dccl.field).min = -1000000,
68 (dccl.field).precision = 1
69 ];
70 optional float prec2 = 3 [
71 (dccl.field).max = 100000,
72 (dccl.field).min = -100000,
73 (dccl.field).precision = 2
74 ];
75 optional float prec3 = 4 [
76 (dccl.field).max = 10000,
77 (dccl.field).min = -10000,
78 (dccl.field).precision = 3
79 ];
80 optional float prec4 = 5 [
81 (dccl.field).max = 1000,
82 (dccl.field).min = -1000,
83 (dccl.field).precision = 4
84 ];
85 optional float prec5 = 6 [
86 (dccl.field).max = 100,
87 (dccl.field).min = -100,
88 (dccl.field).precision = 5
89 ];
90 optional float prec6 = 7 [
91 (dccl.field).max = 10,
92 (dccl.field).min = -10,
93 (dccl.field).precision = 6
94 ];
95}
96
97// Messages for issue #149: min/max limits of floating point fields are not always inclusive
98// https://github.com/GobySoft/dccl/issues/149
99
100// v4 codec: encoding a = max = 0.05 fails due to floating-point quantization (issue #149)
101message Issue149V4Msg
102{
103 option (dccl.msg).id = 149;
104 option (dccl.msg).max_bytes = 4;
105 option (dccl.msg).codec_version = 4;
106
107 optional float a = 1 [
108 (dccl.field).min = 0,
109 (dccl.field).max = 0.05,
110 (dccl.field).precision = 2
111 ];
112}
113
114// v5 codec: encoding a = max = 0.05 succeeds (fixed by PR #152 integer-domain arithmetic)
115message Issue149V5Msg
116{
117 option (dccl.msg).id = 150;
118 option (dccl.msg).max_bytes = 4;
119 option (dccl.msg).codec_version = 5;
120
121 optional float a = 1 [
122 (dccl.field).min = 0,
123 (dccl.field).max = 0.05,
124 (dccl.field).precision = 2
125 ];
126}