Fix parsing errors where 'CIF_speed' is not defined
This commit is contained in:
@@ -41,6 +41,7 @@ func formatData(dataInput *upstreamApi.Schedule) database.Service {
|
||||
service := database.Service{
|
||||
TransactionType: dataInput.TransactionType,
|
||||
StpIndicator: dataInput.CIFSTPIndicator,
|
||||
Vstp: true,
|
||||
Operator: dataInput.ScheduleSegment[0].ATOCCode,
|
||||
TrainUid: dataInput.CIFTrainUID,
|
||||
Headcode: dataInput.ScheduleSegment[0].SignallingID,
|
||||
@@ -56,7 +57,11 @@ func formatData(dataInput *upstreamApi.Schedule) database.Service {
|
||||
|
||||
// Uses the map provided in 'helpers' to translate incorrect CIF speeds to their correct equivalent
|
||||
func parseSpeed(CIFSpeed string) int32 {
|
||||
log.Msg.Debug("CIFSpeed Input: " + CIFSpeed)
|
||||
log.Msg.Debug("CIFSpeed Input: '" + CIFSpeed + "'")
|
||||
if CIFSpeed == "" {
|
||||
log.Msg.Debug("Speed data not provided")
|
||||
return int32(0)
|
||||
}
|
||||
actualSpeed, exists := helpers.SpeedMap[CIFSpeed]
|
||||
if !exists {
|
||||
actualSpeed = CIFSpeed
|
||||
@@ -65,7 +70,7 @@ func parseSpeed(CIFSpeed string) int32 {
|
||||
|
||||
speed, err := strconv.ParseInt(actualSpeed, 10, 32)
|
||||
if err != nil {
|
||||
log.Msg.Warn("Unable to parse speed: " + CIFSpeed + ", returning nil")
|
||||
log.Msg.Warn("Unable to parse speed: " + CIFSpeed + ", returning 0")
|
||||
return int32(0)
|
||||
}
|
||||
return int32(speed)
|
||||
|
||||
@@ -19,9 +19,9 @@ func Subscribe() {
|
||||
for {
|
||||
msg := <-sub.C
|
||||
if msg.Err != nil {
|
||||
log.Msg.Error("STOMP Message Error: " + msg.Err.Error())
|
||||
log.Msg.Error("\nSTOMP Message Error: " + msg.Err.Error())
|
||||
} else {
|
||||
log.Msg.Debug("STOMP Message Received")
|
||||
log.Msg.Debug("\nSTOMP Message Received")
|
||||
saveToFile(string(msg.Body), "msgBody")
|
||||
handle(msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user