KItinerary

ssbv1ticket.h
1 /*
2  SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
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 <QDate>
13 #include <QMetaType>
14 
15 namespace KItinerary {
16 
17 /** ERA SSB ticket barcode (version 1).
18  * @see ERA TAP TSI Annex B.6 - Appendix C.1
19  */
20 class KITINERARY_EXPORT SSBv1Ticket : protected SSBTicketBase
21 {
22  Q_GADGET
23  SSB_NUM_PROPERTY(version, 0, 4)
24  SSB_NUM_PROPERTY(issuerCode, 4, 14)
25  SSB_NUM_PROPERTY(rct2TypeIndicator, 18, 1)
26  SSB_NUM_PROPERTY(numberOfTickets, 19, 6)
27  SSB_NUM_PROPERTY(numberOfAdultPassengers, 25, 7)
28  SSB_NUM_PROPERTY(numberOfChildPassengers, 32, 7)
29  /** Days since Jan 01. */
30  SSB_NUM_PROPERTY(firstDayOfValidityDay, 39, 9)
31  SSB_NUM_PROPERTY(lastDayOfValidityDay, 48, 9)
32  SSB_NUM_PROPERTY(customerNumberType, 57, 1)
33  SSB_LONG_PROPERTY(customerNumber, 58, 47)
34  SSB_NUM_PROPERTY(departureStationType, 105, 1)
35  SSB_NUM_PROPERTY(departureStationNum, 106, 30)
36  SSB_STR_PROPERTY(departureStationAlpha, 106, 5)
37  SSB_NUM_PROPERTY(arrivalStationType, 136, 1)
38  SSB_NUM_PROPERTY(arrivalStationNum, 137, 30)
39  SSB_STR_PROPERTY(arrivalStationAlpha, 137, 5)
40  /** departure time encoded as 48 30min time slots */
41  SSB_NUM_PROPERTY(departureTimeSlot, 167, 6)
42  SSB_NUM_PROPERTY(trainNumber, 173, 17)
43  SSB_LONG_PROPERTY(reservationReference, 190, 40)
44  /** ERA/TD/2009-14/INT: PASSENGER CODE LIST TO TAP TSI - §B.5.24 - Class
45  * Possible values are: 1 (1st), 2 (2nd), C (Club), P (Superior), T (Tourist)
46  */
47  SSB_NUM_PROPERTY(classOfTransport, 230, 6)
48  SSB_NUM_PROPERTY(coachNumber, 236, 10)
49  SSB_NUM_PROPERTY(seatNumber, 246, 7)
50  SSB_STR_PROPERTY(berthNumber, 253, 1)
51  SSB_NUM_PROPERTY(overbookingIndicator, 259, 1)
52  SSB_STR_PROPERTY(issuerPNRNumber, 260, 7)
53  SSB_NUM_PROPERTY(ticketType, 302, 4)
54  SSB_NUM_PROPERTY(specimen, 306, 1)
55  SSB_STR_PROPERTY(viaStations, 307, 5) // is that the correct encoding? page 131 of TAP TSI Annex B.6 could also be read as 6 times 5 bit content
56 
57  Q_PROPERTY(QByteArray rawData READ rawData STORED false)
58 
59 public:
60  SSBv1Ticket();
61  explicit SSBv1Ticket(const QByteArray &data);
62  ~SSBv1Ticket();
63 
64  /** Returns @c true if this is a valid SSB ticket. */
65  bool isValid() const;
66 
67  /** First day of validity. */
68  Q_INVOKABLE QDate firstDayOfValidity(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
69  /** Decoded departure time slot. */
70  Q_INVOKABLE QDateTime departureTime(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
71 
72  /** Raw barcode data. */
73  QByteArray rawData() const;
74 
75  /** Returns @c true if @p data might be an ERA SSB ticket. */
76  static bool maybeSSB(const QByteArray &data);
77 };
78 
79 }
80 
81 Q_DECLARE_METATYPE(KItinerary::SSBv1Ticket)
82 
Classes for reservation/travel data models, data extraction and data augmentation.
Internal base class for ERA SSB tickets.
Definition: ssbticketbase.h:19
ERA SSB ticket barcode (version 1).
Definition: ssbv1ticket.h:20
QDateTime currentDateTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jan 17 2022 23:06:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.