-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.proto
160 lines (150 loc) · 3.36 KB
/
io.proto
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
syntax = "proto3";
package lebai.io;
import "google/protobuf/empty.proto";
// IO设备类型
enum IoDevice {
// 机箱IO
ROBOT = 0;
// 法兰IO
FLANGE = 1;
// 拓展IO
EXTRA = 2;
// 机箱按钮DI
ROBOT_BTN = 10;
// 肩部按钮DI
SHOULDER = 11;
// 法兰按钮DI
FLANGE_BTN = 12;
}
// IO引脚类型
enum IoPinKind {
DI = 0;
DO = 1;
AI = 2;
AO = 3;
}
// 数字IO类型
enum DigitalMode {
INPUT = 0;
OUTPUT = 1;
}
// 模拟IO类型
enum AnalogMode {
VOLTAGE = 0;
CURRENT = 1;
}
message SetDoPinRequest {
IoDevice device = 1;
uint32 pin = 2;
uint32 value = 11;
}
message SetDoPinsRequest {
IoDevice device = 1;
uint32 pin = 2;
repeated uint32 values = 11;
}
message GetDioPinRequest {
IoDevice device = 1;
uint32 pin = 2;
}
message GetDioPinResponse {
uint32 value = 11;
}
message GetDioPinsRequest {
IoDevice device = 1;
uint32 pin = 2;
uint32 count = 11;
}
message GetDioPinsResponse {
repeated uint32 values = 11;
}
message SetAoPinRequest {
IoDevice device = 1;
uint32 pin = 2;
double value = 11;
}
message SetAoPinsRequest {
IoDevice device = 1;
uint32 pin = 2;
repeated double values = 11;
}
message GetAioPinRequest {
IoDevice device = 1;
uint32 pin = 2;
}
message GetAioPinResponse {
double value = 11;
}
message GetAioPinsRequest {
IoDevice device = 1;
uint32 pin = 2;
uint32 count = 11;
}
message GetAioPinsResponse {
repeated double values = 11;
}
message ButtonIndex {
IoDevice device = 1;
// DI引脚号
uint32 pin = 2;
}
enum ButtonState {
// 无动作
EMPTY = 0;
// 松开长按
UP = 1;
// 长按
LONG_DOWN = 2;
// 点击
CLICK = 3;
}
message ButtonStatus {
ButtonState state = 1;
// 长按的毫秒数 或 连击的次数
uint32 time = 2;
}
message ButtonsStatus {
ButtonIndex button = 1;
ButtonStatus status = 2;
}
message SetDioModeRequest {
IoDevice device = 1;
uint32 pin = 2;
DigitalMode mode = 11;
}
message GetDioModeRequest {
IoDevice device = 1;
uint32 pin = 2;
}
message GetDioModeResponse {
DigitalMode mode = 11;
}
message GetDiosModeRequest {
IoDevice device = 1;
uint32 pin = 2;
uint32 count = 11;
}
message GetDiosModeResponse {
repeated DigitalMode modes = 11;
}
// IO相关服务
service IoService {
rpc GetDi(GetDioPinRequest) returns (GetDioPinResponse);
rpc GetDis(GetDioPinsRequest) returns (GetDioPinsResponse);
rpc GetDo(GetDioPinRequest) returns (GetDioPinResponse);
rpc GetDos(GetDioPinsRequest) returns (GetDioPinsResponse);
rpc SetDo(SetDoPinRequest) returns (google.protobuf.Empty);
rpc SetDos(SetDoPinsRequest) returns (google.protobuf.Empty);
rpc GetAi(GetAioPinRequest) returns (GetAioPinResponse);
rpc GetAis(GetAioPinsRequest) returns (GetAioPinsResponse);
rpc GetAo(GetAioPinRequest) returns (GetAioPinResponse);
rpc GetAos(GetAioPinsRequest) returns (GetAioPinsResponse);
rpc SetAo(SetAoPinRequest) returns (google.protobuf.Empty);
rpc SetAos(SetAoPinsRequest) returns (google.protobuf.Empty);
rpc EnableButton(ButtonIndex) returns (google.protobuf.Empty);
rpc DisableButton(ButtonIndex) returns (google.protobuf.Empty);
rpc SubButtonsStatus(google.protobuf.Empty) returns (stream ButtonsStatus);
rpc SetDioMode(SetDioModeRequest) returns (google.protobuf.Empty);
rpc GetDioMode(GetDioModeRequest) returns (GetDioModeResponse);
rpc GetDiosMode(GetDiosModeRequest) returns (GetDiosModeResponse);
}