/
tracking_server.go
238 lines (176 loc) · 5.79 KB
/
tracking_server.go
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package tracking_server
import (
"context"
"fmt"
"io"
)
type ServiceImpl struct{
Client TrackingServerServiceClient
}
/*
Set/update the current point tracking status.
Parameters
----------
trackedPoint *TrackPoint
*/
func(s *ServiceImpl)SetTrackingPointStatus(ctx context.Context, trackedPoint *TrackPoint )(*SetTrackingPointStatusResponse, error){
request := &SetTrackingPointStatusRequest{}
request.TrackedPoint = trackedPoint
response, err := s.Client.SetTrackingPointStatus(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}
/*
Set/update the current rectangle tracking status.
Parameters
----------
trackedRectangle *TrackRectangle
*/
func(s *ServiceImpl)SetTrackingRectangleStatus(ctx context.Context, trackedRectangle *TrackRectangle )(*SetTrackingRectangleStatusResponse, error){
request := &SetTrackingRectangleStatusRequest{}
request.TrackedRectangle = trackedRectangle
response, err := s.Client.SetTrackingRectangleStatus(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}
/*
Set the current tracking status to off.
*/
func(s *ServiceImpl)SetTrackingOffStatus(ctx context.Context, )(*SetTrackingOffStatusResponse, error){
request := &SetTrackingOffStatusRequest{}
response, err := s.Client.SetTrackingOffStatus(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}
/*
Subscribe to incoming tracking point command.
*/
func (a *ServiceImpl) TrackingPointCommand(ctx context.Context, ) (<-chan *TrackPoint , error){
ch := make(chan *TrackPoint )
request := &SubscribeTrackingPointCommandRequest{}
stream, err := a.Client.SubscribeTrackingPointCommand(ctx, request)
if err != nil {
return nil, err
}
go func() {
defer close(ch)
for {
m := &TrackingPointCommandResponse{}
err := stream.RecvMsg(m)
if err == io.EOF {
break
}
if err != nil {
fmt.Printf("Unable to receive message %v", err)
break
}
ch <- m.GetTrackPoint()
}
}()
return ch, nil
}
/*
Subscribe to incoming tracking rectangle command.
*/
func (a *ServiceImpl) TrackingRectangleCommand(ctx context.Context, ) (<-chan *TrackRectangle , error){
ch := make(chan *TrackRectangle )
request := &SubscribeTrackingRectangleCommandRequest{}
stream, err := a.Client.SubscribeTrackingRectangleCommand(ctx, request)
if err != nil {
return nil, err
}
go func() {
defer close(ch)
for {
m := &TrackingRectangleCommandResponse{}
err := stream.RecvMsg(m)
if err == io.EOF {
break
}
if err != nil {
fmt.Printf("Unable to receive message %v", err)
break
}
ch <- m.GetTrackRectangle()
}
}()
return ch, nil
}
/*
Subscribe to incoming tracking off command.
*/
func (a *ServiceImpl) TrackingOffCommand(ctx context.Context, ) (<-chan int32 , error){
ch := make(chan int32 )
request := &SubscribeTrackingOffCommandRequest{}
stream, err := a.Client.SubscribeTrackingOffCommand(ctx, request)
if err != nil {
return nil, err
}
go func() {
defer close(ch)
for {
m := &TrackingOffCommandResponse{}
err := stream.RecvMsg(m)
if err == io.EOF {
break
}
if err != nil {
fmt.Printf("Unable to receive message %v", err)
break
}
ch <- m.GetDummy()
}
}()
return ch, nil
}
/*
Respond to an incoming tracking point command.
Parameters
----------
commandAnswer *CommandAnswer
*/
func(s *ServiceImpl)RespondTrackingPointCommand(ctx context.Context, commandAnswer *CommandAnswer )(*RespondTrackingPointCommandResponse, error){
request := &RespondTrackingPointCommandRequest{}
request.CommandAnswer = *commandAnswer
response, err := s.Client.RespondTrackingPointCommand(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}
/*
Respond to an incoming tracking rectangle command.
Parameters
----------
commandAnswer *CommandAnswer
*/
func(s *ServiceImpl)RespondTrackingRectangleCommand(ctx context.Context, commandAnswer *CommandAnswer )(*RespondTrackingRectangleCommandResponse, error){
request := &RespondTrackingRectangleCommandRequest{}
request.CommandAnswer = *commandAnswer
response, err := s.Client.RespondTrackingRectangleCommand(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}
/*
Respond to an incoming tracking off command.
Parameters
----------
commandAnswer *CommandAnswer
*/
func(s *ServiceImpl)RespondTrackingOffCommand(ctx context.Context, commandAnswer *CommandAnswer )(*RespondTrackingOffCommandResponse, error){
request := &RespondTrackingOffCommandRequest{}
request.CommandAnswer = *commandAnswer
response, err := s.Client.RespondTrackingOffCommand(ctx, request)
if err != nil {
return nil, err
}
return response, nil
}