Skip to content

Commit 1ba8fda

Browse files
committed
payload encoding optimized to minimize size by replacing float by sint32 and int32 by uint32 were possible guided by experimental data
1 parent ce67bb5 commit 1ba8fda

1 file changed

Lines changed: 43 additions & 42 deletions

File tree

src/proto/artisan_roast.proto

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,46 @@ message Roast {
3636
//
3737
// - all indices of the given milestones are valid and strict monotonic
3838
// milestone_idicies = [
39-
// milestones.charge_idx,
40-
// milestones.dry_end_idx,
41-
// milestones.first_crack_start_idx,
42-
// milestones.first_crack_end_idx,
43-
// milestones.second_crack_start_idx,
44-
// milestones.second_crack_end_idx,
45-
// milestones.drop_idx
39+
// milestones.charge_idx,
40+
// milestones.dry_end_idx,
41+
// milestones.first_crack_start_idx,
42+
// milestones.first_crack_end_idx,
43+
// milestones.second_crack_start_idx,
44+
// milestones.second_crack_end_idx,
45+
// milestones.drop_idx
4646
// ]
4747
// for i, idx in enumerate(milestone_idicies):
48-
// if hasValue(idx):
49-
// 0 <= idx < len(times) and
50-
// for 0 <= j < i:
51-
// if hasValue(milestone_idicies[j]
52-
// milestone_idicies[j] < idx
48+
// if HasField(idx):
49+
// 0 <= idx < len(times) and
50+
// for 0 <= j < i:
51+
// if HasField(milestone_idicies[j]
52+
// milestone_idicies[j] < idx
5353
// - all annotations are well defined and valid
5454
// len(annotations.time_indices) == len(annotations.tags) and
5555
// for idx in annotations.time_indices: 0 <= idx < len(times)
5656
// - all events are well defined and valid
5757
// for events in {events1, events2, events3, events4}:
58-
// len(events.time_indices) == len(events.values) and
59-
// for idx in events.time_indices: 0 <= idx <= len(times)
60-
// - all readings are valid
58+
// len(events.time_indices) == len(events.values) and
59+
// for idx in events.time_indices: 0 <= idx <= len(times)
60+
// - all readings are valid (every reading has an associated time)
6161
// for readings in {
6262
// bt_values, et_values,
63-
// bt_ror_values, et_ror_values}:
64-
// len(readings) == len(time)
63+
// bt_ror_values, et_ror_values}
64+
// len(readings) <= len(times)
6565
// for curve in additional_curves:
66-
// len(curve.values) == len(times)
66+
// len(curve.values) <= len(times)
6767
// - time is monotonic
6868
// for i in range(0,len(times)):
69-
// for 0 <= j < i:
70-
// times[j] <= times[i]
69+
// for 0 <= j < i:
70+
// times[j] <= times[i]
7171
// - time of CHARGE (start of roast)
72-
// if hasValue(milestones) and hasValue(milestones.charge_idx):
73-
// times[milestones.charge_idx] = 0
72+
// if HasField(milestones) and HasField(milestones.charge_idx):
73+
// times[milestones.charge_idx] == 0
7474
// elif len(times)>0:
75-
// times[0] = 0
75+
// times[0] == 0
7676
// NOTE: time[x]=0 corresponds to timestamp 'start'
7777
// - time of DROP (end of roast)
78-
// if hasValue(milestones) and hasValue(milestones.drop_idx):
78+
// if HasField(milestones) and HasField(milestones.drop_idx):
7979
// times[milestones.drop_idx]
8080
// NOTE: times[milestones.drop_idx] corresponds
8181
// to timestamp 'drop'
@@ -85,45 +85,46 @@ message Roast {
8585
// to timestamp 'drop'
8686

8787
message Milestones {
88-
int32 charge_idx = 1;
89-
int32 dry_end_idx = 2;
90-
int32 first_crack_start_idx = 3;
91-
int32 first_crack_end_idx = 4;
92-
int32 second_crack_start_idx = 5;
93-
int32 second_crack_end_idx = 6;
94-
int32 drop_idx = 7;
88+
uint32 charge_idx = 1;
89+
uint32 dry_end_idx = 2;
90+
uint32 first_crack_start_idx = 3;
91+
uint32 first_crack_end_idx = 4;
92+
uint32 second_crack_start_idx = 5;
93+
uint32 second_crack_end_idx = 6;
94+
uint32 drop_idx = 7;
9595
}
9696

9797
message Annotations {
98-
repeated int32 time_indices = 1;
98+
repeated uint32 time_indices = 1;
9999
repeated string tags = 2;
100100
}
101101

102102
message Events {
103103
string name = 1;
104104
string unit = 2;
105-
repeated int32 time_indices = 3;
106-
repeated int32 values = 4;
105+
repeated uint32 time_indices = 3;
106+
repeated uint32 values = 4;
107107
}
108108

109109
message Curve {
110110
string name = 1;
111-
repeated float values = 2;
112-
bool temperatures = 3;
111+
repeated sint32 values = 2; // readings multiplied by 10
112+
bool temperatures = 3; // true if values are temperatures in C
113113
}
114114

115115
string org_id = 1; // id of organization
116116
string machine_id = 2; // id of machine
117117
string roast_id = 3; // roast UUID
118118
google.protobuf.Timestamp start = 4; // start of roast
119119
google.protobuf.Timestamp end = 5; // end of roast
120-
repeated float times = 6; // [s] roast time relative to CHARGE
120+
repeated sint32 times = 6; // [s] roast time relative to CHARGE
121121
Milestones milestones = 7; // main roasting events like CHARGE, FCs, ...
122122
Annotations annotations = 8; // text annotations
123123
repeated Events events = 9; // events like power changes
124-
repeated float bt_values = 10; // [Celsius] bean temperatures
125-
repeated float et_values = 11; // [Celsius] environmental temperatures
126-
repeated float bt_ror_values = 12; // [Celsius/min] BT RoR
127-
repeated float et_ror_values = 13; // [Celsius/min] ET RoR
128-
repeated Curve additional_curves = 14; // additional curves
124+
repeated sint32 bt_values = 10; // [C] bean temperatures multiplied by 10
125+
repeated sint32 et_values = 11; // [C] environmental temperatures mult. by 10
126+
repeated sint32 bt_ror_values = 12; // [C/min] BT RoR multiplied by 10
127+
repeated sint32 et_ror_values = 13; // [C/min] ET RoR multiplied by 10
128+
repeated Curve additional_curves = 14; // additional curves
129+
uint32 factor = 15; // multiplication factor of all values
129130
}

0 commit comments

Comments
 (0)