Adjust actions actions
This commit is contained in:
parent
d557241107
commit
5cbc6aef9b
@ -1,6 +1,8 @@
|
||||
package vstp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.fjla.uk/owlboard/go-types/pkg/database"
|
||||
"git.fjla.uk/owlboard/mq-client/log"
|
||||
)
|
||||
@ -23,4 +25,5 @@ func createEntry(entry database.Service) {
|
||||
|
||||
func deleteEntry(entry database.Service) {
|
||||
log.Msg.Info("Entry DELETE requested for: " + entry.TrainUid + " - " + entry.Headcode)
|
||||
fmt.Printf("%+v\n", entry)
|
||||
}
|
||||
|
@ -25,10 +25,8 @@ func unmarshalData(jsonData string) database.Service {
|
||||
|
||||
if schedule.Data.CIFMsg.ScheduleSegment == nil {
|
||||
log.Msg.Warn("ScheduleSegment is nil")
|
||||
return database.Service{}
|
||||
} else if len(schedule.Data.CIFMsg.ScheduleSegment) == 0 {
|
||||
log.Msg.Warn("ScheduleSegment is empty")
|
||||
return database.Service{}
|
||||
}
|
||||
saveToFile(schedule, "unmarshalled") // For Debugging Only
|
||||
return formatData(&schedule.Data.CIFMsg)
|
||||
@ -38,19 +36,32 @@ func unmarshalData(jsonData string) database.Service {
|
||||
func formatData(dataInput *upstreamApi.Schedule) database.Service {
|
||||
log.Msg.Debug("ScheduleSegment length: " + fmt.Sprint(len(dataInput.ScheduleSegment)))
|
||||
log.Msg.Debug("Printing dataInput to console:")
|
||||
|
||||
var operator, headcode, powerType string
|
||||
var planSpeed int32
|
||||
var stops []database.Stop
|
||||
|
||||
// Check that the ScheduleSegment contains data, 'Delete' messages have no ScheduleSegment
|
||||
if len(dataInput.ScheduleSegment) > 0 {
|
||||
operator = dataInput.ScheduleSegment[0].ATOCCode
|
||||
headcode = dataInput.ScheduleSegment[0].SignallingID
|
||||
powerType = dataInput.ScheduleSegment[0].CIFPowerType
|
||||
planSpeed = parseSpeed(dataInput.ScheduleSegment[0].CIFSpeed)
|
||||
stops = parseStops(dataInput.ScheduleSegment[0].ScheduleLocation)
|
||||
}
|
||||
service := database.Service{
|
||||
TransactionType: dataInput.TransactionType,
|
||||
StpIndicator: dataInput.CIFSTPIndicator,
|
||||
Vstp: true,
|
||||
Operator: dataInput.ScheduleSegment[0].ATOCCode,
|
||||
Operator: operator,
|
||||
TrainUid: dataInput.CIFTrainUID,
|
||||
Headcode: dataInput.ScheduleSegment[0].SignallingID,
|
||||
PowerType: dataInput.ScheduleSegment[0].CIFPowerType,
|
||||
PlanSpeed: parseSpeed(dataInput.ScheduleSegment[0].CIFSpeed),
|
||||
Headcode: headcode,
|
||||
PowerType: powerType,
|
||||
PlanSpeed: planSpeed,
|
||||
ScheduleStartDate: parseDate(dataInput.ScheduleStartDate, false),
|
||||
ScheduleEndDate: parseDate(dataInput.ScheduleEndDate, true),
|
||||
DaysRun: parseDaysRun(dataInput.ScheduleDaysRun),
|
||||
Stops: parseStops(dataInput.ScheduleSegment[0].ScheduleLocation),
|
||||
Stops: stops,
|
||||
}
|
||||
return service
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user