Skip to content

Commit e60bf26

Browse files
committed
restore map-only logic
1 parent 8f61fef commit e60bf26

2 files changed

Lines changed: 5 additions & 26 deletions

File tree

backend/internal/adj/adj.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package adj
22

33
import (
44
"encoding/json"
5-
"errors"
6-
"github.com/HyperloopUPV-H8/h9-backend/internal/utils"
75
"github.com/go-git/go-git/v5"
86
"os"
97
)
@@ -19,17 +17,11 @@ func NewADJ() (*ADJ, error) {
1917
return nil, err
2018
}
2119

22-
var JsonInfo JsonInfo
2320
var info Info
24-
if err := json.Unmarshal(infoRaw, &JsonInfo); err != nil {
21+
if err := json.Unmarshal(infoRaw, &info); err != nil {
2522
return nil, err
2623
}
2724

28-
info.Ports = utils.ConvertToMap_Str_Uint16(JsonInfo.Ports)
29-
info.Addresses = utils.ConvertToMap_Str_Str(JsonInfo.Addresses)
30-
info.Units = utils.ConvertToMap_Str_Op(JsonInfo.Units)
31-
info.MessageIds = utils.ConvertToMap_Str_Uint16(JsonInfo.MessageIds)
32-
3325
var boardsList map[string]string
3426
if err := json.Unmarshal(boardsRaw, &boardsList); err != nil {
3527
return nil, err
@@ -96,12 +88,7 @@ func getBoards(info Info, boardsList map[string]string) (map[string]Board, error
9688
return nil, err
9789
}
9890

99-
if info.Addresses[boardName] != boardJSON.IP {
100-
return nil, errors.New("the IP of the board does not match the one in the general info")
101-
}
102-
10391
var board Board
104-
10592
board.Name = boardName
10693
board.IP = boardJSON.IP
10794

backend/internal/adj/models.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ type ADJ struct {
77
Boards map[string]Board
88
}
99

10-
type JsonInfo struct {
11-
Ports []map[string]uint16 `json:"ports"`
12-
Addresses []map[string]string `json:"addresses"`
13-
Units []map[string]utils.Operations `json:"units"`
14-
MessageIds []map[string]uint16 `json:"message_ids"`
15-
}
16-
1710
type Info struct {
18-
Ports map[string]uint16
19-
Addresses map[string]string
20-
Units map[string]utils.Operations
21-
MessageIds map[string]uint16
11+
Ports map[string]uint16 `json:"ports"`
12+
Addresses map[string]string `json:"addresses"`
13+
Units map[string]utils.Operations `json:"units"`
14+
MessageIds map[string]uint16 `json:"message_ids"`
2215
BoardIds map[string]uint16
2316
}
2417

@@ -35,7 +28,6 @@ type BoardJSON struct {
3528
IP string `json:"board_ip"`
3629
MeasurementsPaths []string `json:"measurements"`
3730
PacketsPaths []string `json:"packets"`
38-
// StructuresPaths []string `json:"structures"` // TODO: Issued in JSON_ADE #1
3931
}
4032

4133
type Packet struct {

0 commit comments

Comments
 (0)