Skip to content

Commit 87f5efb

Browse files
authored
Merge branch 'develop' into backend/version-system
2 parents 6cd874f + 3aa7ca9 commit 87f5efb

22 files changed

Lines changed: 494 additions & 225 deletions

File tree

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ The main project file is inside `backend/cmd`. Ensure you have the proper `confi
1818

1919
See [CONTRIBUTING.md](./CONTRIBUTING.md) for ways to contribute to the Control Station.
2020

21-
### Authors
22-
23-
- [Juan Martinez Alonso](https://github.com/jmaralo)
24-
- [Marc Sanchis Llinares](https://github.com/msanlli)
25-
- [Sergio Moreno Suay](https://github.com/smorsua)
26-
- [Felipe Zaballa Martinez](https://github.com/lipezaballa)
27-
- [Andrés de la Torre Mora](https://github.com/andresdlt03)
28-
- [Alejandro Losa](https://github.com/Losina24)
29-
3021
### About
3122

3223
HyperloopUPV is a student team based at Universitat Politècnica de València (Spain), which works every year to develop the transport of the future, the hyperloop. Check out [our website](https://hyperloopupv.com/#/)

backend/cmd/adj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit fd87ad3fac5aa62e7b274b5ae00412caa544c0a0

backend/internal/adj/git.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package adj
22

33
import (
44
"os"
5+
"path/filepath"
56

67
"github.com/go-git/go-git/v5"
78
"github.com/go-git/go-git/v5/plumbing"
@@ -21,6 +22,27 @@ func updateRepo(AdjBranch string) error {
2122
SingleBranch: true,
2223
Depth: 1,
2324
}
25+
26+
// Try to clone the ADJ to a temp directory to check for accessibility to the repo (also checks internet connection)
27+
tempPath := filepath.Join(os.TempDir(), "temp_adj")
28+
29+
// Remove previous failed cloning attempts
30+
if err = os.RemoveAll(tempPath); err != nil {
31+
return err
32+
}
33+
34+
// Try to import the ADJ to the temp directory
35+
_, err = git.PlainClone(tempPath, false, cloneOptions)
36+
if err != nil {
37+
// If the clone fails, work with the local ADJ
38+
return nil
39+
}
40+
41+
// If the clone is succesful, delete the temp files
42+
if err = os.RemoveAll(tempPath); err != nil {
43+
return err
44+
}
45+
2446
if _, err = os.Stat(RepoPath); os.IsNotExist(err) {
2547
_, err = git.PlainClone(RepoPath, false, cloneOptions)
2648
if err != nil {

backend/pkg/adj/git.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package adj
22

33
import (
44
"os"
5+
"path/filepath"
56

67
"github.com/go-git/go-git/v5"
78
"github.com/go-git/go-git/v5/plumbing"
@@ -21,6 +22,27 @@ func updateRepo(AdjBranch string) error {
2122
SingleBranch: true,
2223
Depth: 1,
2324
}
25+
26+
// Try to clone the ADJ to a temp directory to check for accessibility to the repo (also checks internet connection)
27+
tempPath := filepath.Join(os.TempDir(), "temp_adj")
28+
29+
// Remove previous failed cloning attempts
30+
if err = os.RemoveAll(tempPath); err != nil {
31+
return err
32+
}
33+
34+
// Try to import the ADJ to the temp directory
35+
_, err = git.PlainClone(tempPath, false, cloneOptions)
36+
if err != nil {
37+
// If the clone fails, work with the local ADJ
38+
return nil
39+
}
40+
41+
// If the clone is succesful, delete the temp files
42+
if err = os.RemoveAll(tempPath); err != nil {
43+
return err
44+
}
45+
2446
if _, err = os.Stat(RepoPath); os.IsNotExist(err) {
2547
_, err = git.PlainClone(RepoPath, false, cloneOptions)
2648
if err != nil {

backend/pkg/logger/data/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ func (sublogger *Logger) getFile(valueName data.ValueName) (*file.CSV, error) {
137137

138138
func (sublogger *Logger) createFile(valueName data.ValueName) (*os.File, error) {
139139
filename := path.Join(
140-
"logger", "data",
140+
"logger",
141141
loggerHandler.Timestamp.Format(loggerHandler.TimestampFormat),
142+
"data",
142143
fmt.Sprintf("%s.csv", valueName),
143144
)
144145

backend/pkg/logger/order/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ func (sublogger *Logger) Start() error {
5959

6060
func (sublogger *Logger) createFile() (*os.File, error) {
6161
filename := path.Join(
62-
"logger", "order",
62+
"logger",
6363
logger.Timestamp.Format(logger.TimestampFormat),
64+
"order",
6465
"order.csv",
6566
)
6667

backend/pkg/logger/protection/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ func (sublogger *Logger) createFile(boardId abstraction.BoardId) (*os.File, erro
118118
}
119119

120120
filename := path.Join(
121-
"logger", "protections",
121+
"logger",
122122
logger.Timestamp.Format(logger.TimestampFormat),
123+
"protections",
123124
fmt.Sprintf("%s.csv", boardName),
124125
)
125126

backend/pkg/logger/state/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error {
9494

9595
func (sublogger *Logger) createFile(timestamp time.Time) (*file.CSV, error) {
9696
filename := path.Join(
97-
"logger", "state",
97+
"logger",
9898
logger.Timestamp.Format(logger.TimestampFormat),
99+
"state",
99100
fmt.Sprintf("%s.csv", timestamp.Format(logger.TimestampFormat)),
100101
)
101102

backend/pkg/vehicle/notification.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func (vehicle *Vehicle) Notification(notification abstraction.TransportNotificat
4343
}
4444

4545
func (vehicle *Vehicle) handlePacketNotification(notification transport.PacketNotification) error {
46+
var from string
47+
var to string
4648

4749
switch p := notification.Packet.(type) {
4850
case *data.Packet:
@@ -53,10 +55,25 @@ func (vehicle *Vehicle) handlePacketNotification(notification transport.PacketNo
5355
return errors.Join(fmt.Errorf("update data to frontend (data with id %d from %s to %s)", p.Id(), notification.From, notification.To), err)
5456
}
5557

58+
from_ip := strings.Split(notification.From, ":")[0]
59+
to_ip := strings.Split(notification.To, ":")[0]
60+
61+
if from_ip == "192.168.0.9" {
62+
from = "backend"
63+
} else {
64+
from = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[from_ip])]
65+
}
66+
67+
if to_ip == "192.168.0.9" {
68+
to = "backend"
69+
} else {
70+
to = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[to_ip])]
71+
}
72+
5673
err = vehicle.logger.PushRecord(&data_logger.Record{
5774
Packet: p,
58-
From: notification.From,
59-
To: notification.To,
75+
From: from,
76+
To: to,
6077
Timestamp: notification.Timestamp,
6178
})
6279

control-station/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const App = () => {
2121
items={[
2222
{ path: '/vehicle', icon: <Wheel /> },
2323
{ path: '/cameras', icon: <Cameras /> },
24+
{ path: '/guiBooster', icon: <Gui /> }
2425
]}
2526
/>
2627
<Outlet />

0 commit comments

Comments
 (0)