diff options
author | stuebinm | 2022-07-02 00:16:02 +0200 |
---|---|---|
committer | stuebinm | 2022-07-02 00:35:34 +0200 |
commit | 6c25964c0165530e7db6650eea79cbac99031353 (patch) | |
tree | 2b821e5e07320c211a8af0e70974cbbe6defef9e /gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs | |
parent | 6b4e8ba88f35538d62bb78b9872bc298178cf96d (diff) |
gtfs realtime proof of concept
this adds a package for protobuf stuff, generated via hprotoc. Seems to
work kinda fine?
(the generated API is horrible though, will have to write some wrappers
for that)
Diffstat (limited to '')
-rw-r--r-- | gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs b/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs new file mode 100644 index 0000000..92d4064 --- /dev/null +++ b/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs @@ -0,0 +1,109 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.VehiclePosition.OccupancyStatus (OccupancyStatus(..)) where +import Prelude ((+), (/), (.)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data OccupancyStatus = EMPTY + | MANY_SEATS_AVAILABLE + | FEW_SEATS_AVAILABLE + | STANDING_ROOM_ONLY + | CRUSHED_STANDING_ROOM_ONLY + | FULL + | NOT_ACCEPTING_PASSENGERS + | NO_DATA_AVAILABLE + | NOT_BOARDABLE + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable OccupancyStatus + +instance Prelude'.Bounded OccupancyStatus where + minBound = EMPTY + maxBound = NOT_BOARDABLE + +instance P'.Default OccupancyStatus where + defaultValue = EMPTY + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe OccupancyStatus +toMaybe'Enum 0 = Prelude'.Just EMPTY +toMaybe'Enum 1 = Prelude'.Just MANY_SEATS_AVAILABLE +toMaybe'Enum 2 = Prelude'.Just FEW_SEATS_AVAILABLE +toMaybe'Enum 3 = Prelude'.Just STANDING_ROOM_ONLY +toMaybe'Enum 4 = Prelude'.Just CRUSHED_STANDING_ROOM_ONLY +toMaybe'Enum 5 = Prelude'.Just FULL +toMaybe'Enum 6 = Prelude'.Just NOT_ACCEPTING_PASSENGERS +toMaybe'Enum 7 = Prelude'.Just NO_DATA_AVAILABLE +toMaybe'Enum 8 = Prelude'.Just NOT_BOARDABLE +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum OccupancyStatus where + fromEnum EMPTY = 0 + fromEnum MANY_SEATS_AVAILABLE = 1 + fromEnum FEW_SEATS_AVAILABLE = 2 + fromEnum STANDING_ROOM_ONLY = 3 + fromEnum CRUSHED_STANDING_ROOM_ONLY = 4 + fromEnum FULL = 5 + fromEnum NOT_ACCEPTING_PASSENGERS = 6 + fromEnum NO_DATA_AVAILABLE = 7 + fromEnum NOT_BOARDABLE = 8 + toEnum + = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus") . + toMaybe'Enum + succ EMPTY = MANY_SEATS_AVAILABLE + succ MANY_SEATS_AVAILABLE = FEW_SEATS_AVAILABLE + succ FEW_SEATS_AVAILABLE = STANDING_ROOM_ONLY + succ STANDING_ROOM_ONLY = CRUSHED_STANDING_ROOM_ONLY + succ CRUSHED_STANDING_ROOM_ONLY = FULL + succ FULL = NOT_ACCEPTING_PASSENGERS + succ NOT_ACCEPTING_PASSENGERS = NO_DATA_AVAILABLE + succ NO_DATA_AVAILABLE = NOT_BOARDABLE + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus" + pred MANY_SEATS_AVAILABLE = EMPTY + pred FEW_SEATS_AVAILABLE = MANY_SEATS_AVAILABLE + pred STANDING_ROOM_ONLY = FEW_SEATS_AVAILABLE + pred CRUSHED_STANDING_ROOM_ONLY = STANDING_ROOM_ONLY + pred FULL = CRUSHED_STANDING_ROOM_ONLY + pred NOT_ACCEPTING_PASSENGERS = FULL + pred NO_DATA_AVAILABLE = NOT_ACCEPTING_PASSENGERS + pred NOT_BOARDABLE = NO_DATA_AVAILABLE + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus" + +instance P'.Wire OccupancyStatus where + wireSize ft' enum = P'.wireSize ft' (Prelude'.fromEnum enum) + wirePut ft' enum = P'.wirePut ft' (Prelude'.fromEnum enum) + wireGet 14 = P'.wireGetEnum toMaybe'Enum + wireGet ft' = P'.wireGetErr ft' + wireGetPacked 14 = P'.wireGetPackedEnum toMaybe'Enum + wireGetPacked ft' = P'.wireGetErr ft' + +instance P'.GPB OccupancyStatus + +instance P'.MessageAPI msg' (msg' -> OccupancyStatus) OccupancyStatus where + getVal m' f' = f' m' + +instance P'.ReflectEnum OccupancyStatus where + reflectEnum + = [(0, "EMPTY", EMPTY), (1, "MANY_SEATS_AVAILABLE", MANY_SEATS_AVAILABLE), (2, "FEW_SEATS_AVAILABLE", FEW_SEATS_AVAILABLE), + (3, "STANDING_ROOM_ONLY", STANDING_ROOM_ONLY), (4, "CRUSHED_STANDING_ROOM_ONLY", CRUSHED_STANDING_ROOM_ONLY), + (5, "FULL", FULL), (6, "NOT_ACCEPTING_PASSENGERS", NOT_ACCEPTING_PASSENGERS), (7, "NO_DATA_AVAILABLE", NO_DATA_AVAILABLE), + (8, "NOT_BOARDABLE", NOT_BOARDABLE)] + reflectEnumInfo _ + = P'.EnumInfo + (P'.makePNF (P'.pack ".transit_realtime.VehiclePosition.OccupancyStatus") [] ["GTFS", "Realtime", "VehiclePosition"] + "OccupancyStatus") + ["GTFS", "Realtime", "VehiclePosition", "OccupancyStatus.hs"] + [(0, "EMPTY"), (1, "MANY_SEATS_AVAILABLE"), (2, "FEW_SEATS_AVAILABLE"), (3, "STANDING_ROOM_ONLY"), + (4, "CRUSHED_STANDING_ROOM_ONLY"), (5, "FULL"), (6, "NOT_ACCEPTING_PASSENGERS"), (7, "NO_DATA_AVAILABLE"), + (8, "NOT_BOARDABLE")] + Prelude'.False + +instance P'.TextType OccupancyStatus where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file |