Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/pkg/logger/data/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ func (sublogger *Logger) getFile(valueName data.ValueName) (*file.CSV, error) {

func (sublogger *Logger) createFile(valueName data.ValueName) (*os.File, error) {
filename := path.Join(
"logger", "data",
"logger",
loggerHandler.Timestamp.Format(loggerHandler.TimestampFormat),
"data",
fmt.Sprintf("%s.csv", valueName),
)

Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/logger/order/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ func (sublogger *Logger) Start() error {

func (sublogger *Logger) createFile() (*os.File, error) {
filename := path.Join(
"logger", "order",
"logger",
logger.Timestamp.Format(logger.TimestampFormat),
"order",
"order.csv",
)

Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/logger/protection/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ func (sublogger *Logger) createFile(boardId abstraction.BoardId) (*os.File, erro
}

filename := path.Join(
"logger", "protections",
"logger",
logger.Timestamp.Format(logger.TimestampFormat),
"protections",
fmt.Sprintf("%s.csv", boardName),
)

Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/logger/state/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error {

func (sublogger *Logger) createFile(timestamp time.Time) (*file.CSV, error) {
filename := path.Join(
"logger", "state",
"logger",
logger.Timestamp.Format(logger.TimestampFormat),
"state",
fmt.Sprintf("%s.csv", timestamp.Format(logger.TimestampFormat)),
)

Expand Down
21 changes: 19 additions & 2 deletions backend/pkg/vehicle/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func (vehicle *Vehicle) Notification(notification abstraction.TransportNotificat
}

func (vehicle *Vehicle) handlePacketNotification(notification transport.PacketNotification) error {
var from string
var to string

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

from_ip := strings.Split(notification.From, ":")[0]
to_ip := strings.Split(notification.To, ":")[0]

if from_ip == "192.168.0.9" {
from = "backend"
} else {
from = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[from_ip])]
}

if to_ip == "192.168.0.9" {
to = "backend"
} else {
to = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[to_ip])]
}

err = vehicle.logger.PushRecord(&data_logger.Record{
Packet: p,
From: notification.From,
To: notification.To,
From: from,
To: to,
Timestamp: notification.Timestamp,
})

Expand Down
Loading