diff --git a/pkg/database/timetable.go b/pkg/database/timetable.go index e977921..fdf17b4 100644 --- a/pkg/database/timetable.go +++ b/pkg/database/timetable.go @@ -13,7 +13,7 @@ type Stop struct { Tiploc string `json:"tiploc,omitempty"` } -type Service struct { +type Service struct { // Consider including catering, train class etc. here too. TransactionType string `json:"transactionType,omitempty"` StpIndicator string `json:"stpIndicator,omitempty"` Vstp bool `json:"vstp"` diff --git a/pkg/upstreamApi/cif.go b/pkg/upstreamApi/cif.go new file mode 100644 index 0000000..a6955bf --- /dev/null +++ b/pkg/upstreamApi/cif.go @@ -0,0 +1,101 @@ +package upstreamApi + +import "time" + +// Defines the first JSON line of a CIF file, containing metadata +type JsonTimetableV1 struct { + Classification string `json:"classification"` + Timestamp int64 `json:"timestamp"` + Owner string `json:"owner"` + Sender TimetableSender `json:"Sender"` + Metadata TimetableMetadata `json:"Metadata"` +} + +// Part of the JsonTimetableV1 type +type TimetableSender struct { + Organisation string `json:"organisation"` + Application string `json:"application"` + Component string `json:"component"` +} + +// Part of the JsonTimetableV1 type +type TimetableMetadata struct { + Type string `json:"type"` + Sequence int64 `json:"sequence"` +} + +// Defines the JsonAssociation lines of a CIF File +type JsonAssociationV1 struct { + TransactionType string `json:"transaction_type"` + MainTrainUid string `json:"main_train_uid"` + AssocTrainUid string `json:"assoc_train_uid"` + AssocStartDate time.Time `json:"assoc_start_date"` + AssocEndDate time.Time `json:"assoc_end_date"` + Location string `json:"location"` + BaseLocationSuffix string `json:"base_location_suffix"` + DiagramType string `json:"diagram_type"` + AssocDays string `json:"assoc_days"` + Category string `json:"category"` + CIFSTPIndicator string `json:"CIF_stp_indicator"` + DateIndicator string `json:"date_indicator"` +} + +// Defined a schedule entry from a CIF File +type JsonScheduleV1 struct { + CifBankHolidayRunning string `json:"CIF_bank_holiday_running"` + CifStpIndicator string `json:"CIF_stp_indicator"` + CifTrainUid string `json:"CIF_train_uid"` + ApplicableTimetable string `json:"applicable_timetable"` + AtocCode string `json:"atoc_code"` + NewScheduleSegment ScheduleNewScheduleSegment `json:"new_schedule_segment"` + ScheduleDaysRun string `json:"schedule_days_run"` + ScheduleStartDate string `json:"schedule_start_date"` + ScheduleEndDate string `json:"schedule_end_date"` + ScheduleSegment CifScheduleSegment `json:"schedule_segment"` +} + +// Part of the JsonScheduleV1 type +type ScheduleNewScheduleSegment struct { + TractionClass string `json:"traction_class"` + UidCode string `json:"uid_code"` +} + +// Part of the JsonScheduleV1 type +type CifScheduleSegment struct { + SignallingId string `json:"signalling_id"` + CifTrainCategory string `json:"CIF_train_category"` + CifHeadcode string `json:"CIF_headcode"` + CifCourseIndicator string `json:"CIF_course_indicator"` + CifTrainServiceCode string `json:"CIF_train_service_code"` + CifBusinessSector string `json:"CIF_business_sector"` + CifPowerType string `json:"CIF_power_type"` + CifTimingLoad string `json:"CIF_timing_load"` + CifSpeed string `json:"CIF_speed"` + CifOperatingCharacteristics string `json:"CIF_operating_characteristics"` + CifTrainClass string `json:"CIF_train_class"` + CifSleepers string `json:"CIF_sleepers"` + CifReservations string `json:"CIF_reservations"` + CifConnectionIndicator string `json:"CIF_connection_indicator"` + CifCateringCode string `json:"CIF_catering_code"` + CifServiceBranding string `json:"CIF_service_branding"` + ScheduleLocation []CifScheduleLocation `json:"schedule_location"` +} + +// Part of the CifScheduleSegment type +type CifScheduleLocation struct { + LocationType string `json:"location_type"` + RecordIdentity string `json:"record_identity"` + TiplocCode string `json:"tiploc_code"` + TiplocInstance string `json:"tiploc_instance"` + Arrival string `json:"arrival"` + PublicArrival string `json:"public_arrival"` + Departure string `json:"departure"` + PublicDeparture string `json:"public_departure"` + Pass string `json:"pass"` + Path string `json:"path"` + Platform string `json:"platform"` + Line string `json:"line"` + EngineeringAllowance string `json:"engineering_allowance"` + PathingAllowance string `json:"pathing_allowance"` + PerformanceAllowance string `json:"performance_allowance"` +}