Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
b04c7b10
Commit
b04c7b10
authored
May 10, 2021
by
Volker Krause
Browse files
Decode ERA SSB v1 date/time fields
parent
ce3c602a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/era/ssbv1ticket.cpp
View file @
b04c7b10
...
...
@@ -44,6 +44,25 @@ bool SSBv1Ticket::maybeSSB(const QByteArray& data)
return
(
data
.
at
(
0
)
>>
4
)
==
SSB_VERSION
;
}
QDate
SSBv1Ticket
::
firstDayOfValidity
(
const
QDate
&
contextDate
)
const
{
if
(
!
isValid
()
||
firstDayOfValidityDay
()
==
0
||
firstDayOfValidityDay
()
>
366
)
{
return
{};
}
QDate
d
(
contextDate
.
year
(),
1
,
1
);
return
d
.
addDays
(
firstDayOfValidityDay
()
-
1
);
}
QDateTime
SSBv1Ticket
::
departureTime
(
const
QDate
&
contextDate
)
const
{
if
(
!
isValid
()
||
departureTimeSlot
()
==
0
||
departureTimeSlot
()
>
48
)
{
return
{};
}
QDateTime
dt
(
firstDayOfValidity
(
contextDate
),
{
0
,
0
});
return
dt
.
addSecs
(
60
*
30
*
(
departureTimeSlot
()
-
1
));
}
QByteArray
SSBv1Ticket
::
rawData
()
const
{
return
m_data
;
...
...
src/lib/era/ssbv1ticket.h
View file @
b04c7b10
...
...
@@ -10,6 +10,7 @@
#include "kitinerary_export.h"
#include "ssbticketbase.h"
#include <QDate>
#include <QMetaType>
namespace
KItinerary
{
...
...
@@ -26,8 +27,9 @@ class KITINERARY_EXPORT SSBv1Ticket : protected SSBTicketBase
SSB_NUM_PROPERTY
(
numberOfTickets
,
19
,
6
)
SSB_NUM_PROPERTY
(
numberOfAdultPassengers
,
25
,
7
)
SSB_NUM_PROPERTY
(
numberOfChildPassengers
,
32
,
7
)
SSB_NUM_PROPERTY
(
firstDayOfValidity
,
39
,
9
)
SSB_NUM_PROPERTY
(
lastDayOfValidity
,
48
,
9
)
/** Days since Jan 01. */
SSB_NUM_PROPERTY
(
firstDayOfValidityDay
,
39
,
9
)
SSB_NUM_PROPERTY
(
lastDayOfValidityDay
,
48
,
9
)
SSB_NUM_PROPERTY
(
customerNumberType
,
57
,
1
)
SSB_LONG_PROPERTY
(
customerNumber
,
58
,
47
)
SSB_NUM_PROPERTY
(
departureStationType
,
105
,
1
)
...
...
@@ -36,9 +38,13 @@ class KITINERARY_EXPORT SSBv1Ticket : protected SSBTicketBase
SSB_NUM_PROPERTY
(
arrivalStationType
,
136
,
1
)
SSB_NUM_PROPERTY
(
arrivalStationNum
,
137
,
30
)
SSB_STR_PROPERTY
(
arrivalStationAlpha
,
137
,
5
)
SSB_NUM_PROPERTY
(
departureTime
,
167
,
6
)
/** departure time encoded as 48 30min time slots */
SSB_NUM_PROPERTY
(
departureTimeSlot
,
167
,
6
)
SSB_NUM_PROPERTY
(
trainNumber
,
173
,
17
)
SSB_LONG_PROPERTY
(
reservationReference
,
190
,
40
)
/** ERA/TD/2009-14/INT: PASSENGER CODE LIST TO TAP TSI - §B.5.24 - Class
* Possible values are: 1 (1st), 2 (2nd), C (Club), P (Superior), T (Tourist)
*/
SSB_NUM_PROPERTY
(
classOfTransport
,
230
,
6
)
SSB_NUM_PROPERTY
(
coachNumber
,
236
,
10
)
SSB_NUM_PROPERTY
(
seatNumber
,
246
,
7
)
...
...
@@ -59,6 +65,11 @@ public:
/** Returns @c true if this is a valid SSB ticket. */
bool
isValid
()
const
;
/** First day of validity. */
Q_INVOKABLE
QDate
firstDayOfValidity
(
const
QDate
&
contextDate
=
QDate
::
currentDate
())
const
;
/** Decoded departure time slot. */
Q_INVOKABLE
QDateTime
departureTime
(
const
QDate
&
contextDate
=
QDate
::
currentDate
())
const
;
/** Raw barcode data. */
QByteArray
rawData
()
const
;
...
...
src/tools/ticket-barcode-dump.cpp
View file @
b04c7b10
...
...
@@ -113,6 +113,10 @@ static void dumpSsbv1Ticket(const QByteArray &data)
break
;
}
}
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"First day of validitiy: "
<<
qPrintable
(
ticket
.
firstDayOfValidity
().
toString
(
Qt
::
ISODate
))
<<
std
::
endl
;
std
::
cout
<<
"Departure time: "
<<
qPrintable
(
ticket
.
departureTime
().
toString
(
Qt
::
ISODate
))
<<
std
::
endl
;
}
static
void
dumpRawData
(
const
char
*
data
,
std
::
size_t
size
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment