KItinerary

ssbv3ticket.h
1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kitinerary_export.h"
10#include "ssbticketbase.h"
11
12#include <QDateTime>
13#include <QMetaType>
14
15namespace KItinerary {
16
17/** ERA SSB ticket barcode (version 3).
18 * @see ERA TAP TSI TD B.12 Digital Security Elements For Rail Passenger Ticketing - ยง7 SSB - Small Structured Barcode
19 */
20class KITINERARY_EXPORT SSBv3Ticket : protected SSBTicketBase {
21 Q_GADGET
22 // low-level raw value access
23 // header
24 SSB_NUM_PROPERTY(version, 0, 4)
25 SSB_NUM_PROPERTY(issuerCode, 4, 14)
26 SSB_NUM_PROPERTY(id, 18, 4)
27 SSB_NUM_PROPERTY(ticketTypeCode, 22, 5)
28
29 // open data common part for type 1-4
30 SSB_NUM_PROPERTY(numberOfAdultPassengers, 27, 7)
31 SSB_NUM_PROPERTY(numberOfChildPassengers, 34, 7)
32 SSB_NUM_PROPERTY(specimen, 41, 1)
33 SSB_NUM_PROPERTY(classOfTravel, 42, 6)
34 SSB_STR_PROPERTY(tcn, 48, 14)
35 SSB_NUM_PROPERTY(yearOfIssue, 132, 4) // last digit only
36 SSB_NUM_PROPERTY(issuingDay, 136, 9)
37
38 // open data type 1 (IRT, RES, BOA) variant
39 SSB_NUM_PROPERTY(type1SubTicketType, 145, 2)
40 SSB_NUM_PROPERTY(type1StationCodeNumericOrAlpha, 147, 1)
41 SSB_NUM_PROPERTY(type1StationCodeListType, 148, 4)
42 SSB_NUM_PROPERTY(type1DepartureStationNum, 152, 28)
43 SSB_STR_PROPERTY(type1DepartureStationAlpha, 148, 5)
44 SSB_NUM_PROPERTY(type1ArrivalStationNum, 180, 28)
45 SSB_STR_PROPERTY(type1ArrivalStationAlpha, 178, 5)
46 SSB_NUM_PROPERTY(type1DepartureDate, 208, 9)
47 SSB_NUM_PROPERTY(type1DepartureTime, 217, 11)
48 SSB_STR_PROPERTY(type1TrainNumber, 228, 5)
49 SSB_NUM_PROPERTY(type1CoachNumber, 258, 10)
50 SSB_STR_PROPERTY(type1SeatNumber, 268, 3)
51 SSB_NUM_PROPERTY(type1OverbookingIndicator, 286, 1)
52 SSB_NUM_PROPERTY(type1InformationMessages, 287, 14)
53 SSB_STR_PROPERTY(type1OpenText, 301, 27)
54
55 // open data type 2 (NRT) variant
56 SSB_NUM_PROPERTY(type2ReturnJourneyFlag, 145, 1)
57 SSB_NUM_PROPERTY(type2FirstDayOfValidity, 146, 9)
58 SSB_NUM_PROPERTY(type2LastDayOfValidity, 155, 9)
59 SSB_NUM_PROPERTY(type2StationCodeNumericOrAlpha, 164, 1)
60 SSB_NUM_PROPERTY(type2StationCodeListType, 165, 4)
61 SSB_NUM_PROPERTY(type2DepartureStationNum, 169, 28)
62 SSB_STR_PROPERTY(type2DepartureStationAlpha, 165, 5)
63 SSB_NUM_PROPERTY(type2ArrivalStationNum, 197, 28)
64 SSB_STR_PROPERTY(type2ArrivalStationAlpha, 195, 5)
65 SSB_NUM_PROPERTY(type2InformationMessages, 225, 14)
66 SSB_STR_PROPERTY(type2OpenText, 239, 37)
67
68 // open data type 3 (GRT) variant
69 SSB_NUM_PROPERTY(type3ReturnJourneyFlag, 145, 1)
70 SSB_NUM_PROPERTY(type3FirstDayOfValidity, 146, 9)
71 SSB_NUM_PROPERTY(type3LastDayOfValidity, 155, 9)
72 SSB_NUM_PROPERTY(type3StationCodeNumericOrAlpha, 164, 1)
73 SSB_NUM_PROPERTY(type3StationCodeListType, 165, 4)
74 SSB_NUM_PROPERTY(type3DepartureStationNum, 169, 28)
75 SSB_STR_PROPERTY(type3DepartureStationAlpha, 165, 5)
76 SSB_NUM_PROPERTY(type3ArrivalStationNum, 197, 28)
77 SSB_STR_PROPERTY(type3ArrivalStationAlpha, 195, 5)
78 SSB_STR_PROPERTY(type3NameOfGroupLeader, 225, 12)
79 SSB_NUM_PROPERTY(type3CountermarkNumber, 297, 8)
80 SSB_NUM_PROPERTY(type3InformationMessages, 305, 14)
81 SSB_STR_PROPERTY(type3OpenText, 305, 24)
82
83 // open data type 4 (RPT) variant
84 SSB_NUM_PROPERTY(type4RPTSubTicketType, 145, 2)
85 SSB_NUM_PROPERTY(type4FirstDayOfValidity, 147, 9)
86 SSB_NUM_PROPERTY(type4LastDayOfValidity, 156, 9)
87 SSB_NUM_PROPERTY(type4NumberOfDaysOfTravelAllowed, 165, 7)
88 SSB_NUM_PROPERTY(type4CountryCode1, 172, 7)
89 SSB_NUM_PROPERTY(type4CountryCode2, 179, 7)
90 SSB_NUM_PROPERTY(type4CountryCode3, 186, 7)
91 SSB_NUM_PROPERTY(type4CountryCode4, 193, 7)
92 SSB_NUM_PROPERTY(type4SecondPage, 200, 1)
93 SSB_NUM_PROPERTY(type4InformationMessages, 201, 14)
94 SSB_STR_PROPERTY(type4OpenText, 215, 40)
95
96 enum TicketType {
97 IRT_RES_BOA = 1,
98 NRT = 2,
99 GRT = 3,
100 RPT = 4
101 };
102 Q_ENUM(TicketType)
103
104 Q_PROPERTY(QByteArray rawData READ rawData STORED false)
105
106public:
107 SSBv3Ticket();
108 explicit SSBv3Ticket(const QByteArray &data);
109 ~SSBv3Ticket();
110
111 /** Returns @c true if this is a valid SSB ticket. */
112 bool isValid() const;
113
114 /** Date of issue. */
115 Q_INVOKABLE QDate issueDate(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
116 /** Departure day for type 1 (IRT/RES/BOA) tickets. */
117 Q_INVOKABLE QDate type1DepartureDay(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
118 /** First day of validity for type 2 (NRT) tickets. */
119 Q_INVOKABLE QDate type2ValidFrom(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
120 /** Last day of validity for type 2 (NRT) tickets. */
121 Q_INVOKABLE QDate type2ValidUntil(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
122
123 /** Raw barcode data. */
124 QByteArray rawData() const;
125
126 /** Returns @c true if @p data might be an ERA SSB ticket. */
127 static bool maybeSSB(const QByteArray &data);
128
129private:
130 QString readString(int start, int length) const;
131};
132
133}
134
135Q_DECLARE_METATYPE(KItinerary::SSBv3Ticket)
136
Internal base class for ERA SSB tickets.
ERA SSB ticket barcode (version 3).
Definition ssbv3ticket.h:20
Q_SCRIPTABLE Q_NOREPLY void start()
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
QDateTime currentDateTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.