Skip to content

Commit d608b9b

Browse files
committed
add cumulative images
1 parent 360c49f commit d608b9b

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

cmd/obstructionMapVideo/grpc.go

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,7 @@ type StarlinkGetStatusResponse struct {
109109
PhyRxBeamSnrAvg float32
110110
}
111111

112-
func (e *Exporter) CollectDishObstructionMap() *StarlinkGetObstructionMapResponse {
113-
req := &device.Request{
114-
Request: &device.Request_DishGetObstructionMap{},
115-
}
116-
117-
ctx, cancel := context.WithTimeout(context.Background(), grpcTimeout)
118-
defer cancel()
119-
resp, err := e.Client.Handle(ctx, req)
120-
if err != nil {
121-
fmt.Printf("gRPC GetObstructionMap failed: %s", err.Error())
122-
return nil
123-
}
124-
125-
dishObstructionMap := resp.GetDishGetObstructionMap()
126-
rows := int(dishObstructionMap.NumRows)
127-
cols := int(dishObstructionMap.NumCols)
128-
referenceFrame := dishObstructionMap.GetMapReferenceFrame().String()
129-
data := dishObstructionMap.Snr
130-
112+
func createImageFromSNR(cols, rows int, data []float32) *image.RGBA {
131113
upLeft := image.Point{0, 0}
132114
lowRight := image.Point{cols * 2, rows * 2}
133115

@@ -161,6 +143,29 @@ func (e *Exporter) CollectDishObstructionMap() *StarlinkGetObstructionMapRespons
161143
}
162144
}
163145
}
146+
return img
147+
}
148+
149+
func (e *Exporter) CollectDishObstructionMap() *StarlinkGetObstructionMapResponse {
150+
req := &device.Request{
151+
Request: &device.Request_DishGetObstructionMap{},
152+
}
153+
154+
ctx, cancel := context.WithTimeout(context.Background(), grpcTimeout)
155+
defer cancel()
156+
resp, err := e.Client.Handle(ctx, req)
157+
if err != nil {
158+
fmt.Printf("gRPC GetObstructionMap failed: %s", err.Error())
159+
return nil
160+
}
161+
162+
dishObstructionMap := resp.GetDishGetObstructionMap()
163+
rows := int(dishObstructionMap.NumRows)
164+
cols := int(dishObstructionMap.NumCols)
165+
referenceFrame := dishObstructionMap.GetMapReferenceFrame().String()
166+
data := dishObstructionMap.Snr
167+
168+
img := createImageFromSNR(cols, rows, data)
164169

165170
timestamp := time.Now().Format(time.RFC3339Nano)
166171
parts := strings.Split(timestamp, "T")
@@ -178,7 +183,8 @@ func (e *Exporter) CollectDishObstructionMap() *StarlinkGetObstructionMapRespons
178183
MapReferenceFrame: referenceFrame,
179184
Rows: rows,
180185
Cols: cols,
181-
Data: buf.Bytes(),
186+
InstImage: buf.Bytes(),
187+
Raw: data,
182188
}
183189
return dishObstructionMapResp
184190
}
@@ -188,7 +194,10 @@ type StarlinkGetObstructionMapResponse struct {
188194
MapReferenceFrame string
189195
Rows int
190196
Cols int
191-
Data []byte
197+
InstImage []byte
198+
CumulativeImage []byte
199+
Raw []float32
200+
CumulativeRaw []float32
192201
}
193202

194203
func (e *Exporter) ResetDishObstructionMap() error {

cmd/obstructionMapVideo/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func main() {
122122
log.Println("Error creating obstruction map file: ", err)
123123
return
124124
}
125-
_, err = f.Write(obstructionMap.Data)
125+
_, err = f.Write(obstructionMap.InstImage)
126126
if err != nil {
127127
log.Println("Error writing obstruction map: ", err)
128128
}

0 commit comments

Comments
 (0)