-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added punctuality display (#122) #473
Draft
tobe-official
wants to merge
28
commits into
main
Choose a base branch
from
122-puenktlichkeit-anzeige
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1c6cc8d
feat: added CAB start and end signaling
rawi-coding f4dc23a
feat: handled track equipment segments that start or end outside of t…
rawi-coding 2cd599a
Merge branch 'main' into 82-streckenausruestung
rawi-coding 0f2d05b
chore: fixed some issues after merge.
rawi-coding 7babb87
chore: added UI integration test for CAB signaling.
rawi-coding 3313065
chore: changes from review and fixed ordering of CABSignaling.
rawi-coding d707eca
chore: fixed integration test.
rawi-coding d868b47
chore: added train journey to test non standard track equipment.
rawi-coding 6a6428a
Merge branch 'main' into 82-streckenausruestung
rawi-coding 638c975
chore: updated integration test for track equipment to T1 train journey
rawi-coding 2fe61ea
fix ui tests
Grodien 924ea83
fix tests for real
Grodien 8987de9
feat: added visualization of non standard track equipment (#82).
rawi-coding b9939e6
Merge branch 'main' into 82-streckenausruestung
rawi-coding 7698872
chore: add integration tests for track equipment
rawi-coding 351dd8e
fix rendering issue
Grodien 2046c2f
merge main
Grodien aef8aa8
quick fix for not throwing exception on event message
Grodien dbf1762
fix something I broke :)
Grodien fc76192
feat: implement basic sfera event handling
Grodien 5bb0c58
chore: fix test
Grodien 58c4347
merge main
Grodien 0d9a432
fix lint
Grodien b1ec409
remove unused file
Grodien 3bb680b
feat: Fixed the delay model and added all the needed Sfera models. Al…
tobe-official 6dd34d7
Merge branch 'main' into 122-puenktlichkeit-anzeige
tobe-official a999728
fix: fixed the mentioned points. Still need to do the tests. SBBLoadi…
tobe-official d33253b
fix: fixed the tests and fixed the mentioned points
tobe-official File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: d9dad56c0cd0b4fd8b4fe3034a53fd42a0b990f6 | ||
|
||
COCOAPODS: 1.16.1 | ||
COCOAPODS: 1.15.2 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,13 @@ import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; | |
import 'package:das_client/sfera/src/model/journey_profile.dart'; | ||
import 'package:das_client/sfera/src/model/multilingual_text.dart'; | ||
import 'package:das_client/sfera/src/model/network_specific_parameter.dart'; | ||
import 'package:das_client/sfera/src/model/related_train_information.dart'; | ||
import 'package:das_client/sfera/src/model/segment_profile.dart'; | ||
import 'package:das_client/sfera/src/model/speeds.dart'; | ||
import 'package:das_client/sfera/src/model/taf_tap_location.dart'; | ||
import 'package:das_client/sfera/src/model/train_characteristics.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
import 'package:iso_duration/iso_duration.dart'; | ||
|
||
class SferaModelMapper { | ||
SferaModelMapper._(); | ||
|
@@ -42,18 +44,21 @@ class SferaModelMapper { | |
static const String _protectionSectionNspFacultativeName = 'facultative'; | ||
static const String _protectionSectionNspLengthTypeName = 'lengthType'; | ||
|
||
static Journey mapToJourney(JourneyProfile journeyProfile, List<SegmentProfile> segmentProfiles, | ||
List<TrainCharacteristics> trainCharacteristics) { | ||
static Journey mapToJourney( | ||
{required JourneyProfile journeyProfile, | ||
List<SegmentProfile> segmentProfiles = const [], | ||
List<TrainCharacteristics> trainCharacteristics = const [], | ||
RelatedTrainInformation? relatedTrainInformation}) { | ||
try { | ||
return _mapToJourney(journeyProfile, segmentProfiles, trainCharacteristics); | ||
return _mapToJourney(journeyProfile, segmentProfiles, trainCharacteristics, relatedTrainInformation); | ||
} catch (e, s) { | ||
Fimber.e('Error mapping journey-/segment profiles to journey:', ex: e, stacktrace: s); | ||
return Journey.invalid(); | ||
} | ||
} | ||
|
||
static Journey _mapToJourney(JourneyProfile journeyProfile, List<SegmentProfile> segmentProfiles, | ||
List<TrainCharacteristics> trainCharacteristics) { | ||
List<TrainCharacteristics> trainCharacteristics, RelatedTrainInformation? relatedTrainInformation) { | ||
final journeyData = <BaseData>[]; | ||
|
||
final segmentProfilesLists = journeyProfile.segmentProfilesLists.toList(); | ||
|
@@ -130,13 +135,17 @@ class SferaModelMapper { | |
|
||
final trainCharacteristic = _resolveFirstTrainCharacteristics(journeyProfile, trainCharacteristics); | ||
final servicePoints = journeyData.where((it) => it.type == Datatype.servicePoint).toList(); | ||
|
||
return Journey( | ||
metadata: Metadata( | ||
nextStop: servicePoints.length > 1 ? servicePoints[1] as ServicePoint : null, | ||
currentPosition: journeyData.first, | ||
additionalSpeedRestrictions: additionalSpeedRestrictions, | ||
routeStart: journeyData.firstOrNull, | ||
routeEnd: journeyData.lastOrNull, | ||
delay: _stringToDuration(relatedTrainInformation == null | ||
? '+PT0M0S' //Base Value for when the information is Null | ||
tobe-official marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: relatedTrainInformation.ownTrain.trainLocationInformation.delay.delay), | ||
nonStandardTrackEquipmentSegments: trackEquipmentSegments, | ||
availableBreakSeries: _parseAvailableBreakSeries(journeyData), | ||
breakSeries: trainCharacteristic?.tcFeatures.trainCategoryCode != null && | ||
|
@@ -150,6 +159,20 @@ class SferaModelMapper { | |
); | ||
} | ||
|
||
static Duration _stringToDuration(String stringToChange) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ich würde diese Logik gleich im "Domain-Model" Delay führen, z.B. eine |
||
//'-PT41M30S' | ||
|
||
//TODO code in util auslagern und ganz ganz viele tests wie zb -5 stunden | ||
//TODO anschauen was mit über einer stunde geschehen sollte (mit UX) | ||
final Duration? delay = tryParseIso8601Duration(stringToChange); | ||
|
||
if (delay == null) { | ||
//Todo change the error-code | ||
throw FormatException('Invalid ISO 8601 duration format'); | ||
tobe-official marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return delay; | ||
} | ||
|
||
static List<AdditionalSpeedRestriction> _parseAdditionalSpeedRestrictions( | ||
JourneyProfile journeyProfile, List<SegmentProfile> segmentProfiles) { | ||
final List<AdditionalSpeedRestriction> result = []; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
|
||
class Delay extends SferaXmlElement { | ||
static const String elementType = 'Delay'; | ||
|
||
Delay({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
String get delay => attributes['Delay']!; | ||
|
||
@override | ||
bool validate() { | ||
return validateHasAttribute('Delay') && super.validate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:das_client/sfera/src/model/journey_profile.dart'; | ||
import 'package:das_client/sfera/src/model/related_train_information.dart'; | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
|
||
class G2bEventPayload extends SferaXmlElement { | ||
static const String elementType = 'G2B_EventPayload'; | ||
|
||
G2bEventPayload({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
RelatedTrainInformation? get relatedTrainInformation => children.whereType<RelatedTrainInformation>().firstOrNull; | ||
|
||
Iterable<JourneyProfile> get journeyProfiles => children.whereType<JourneyProfile>(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
import 'package:das_client/sfera/src/model/train_identification.dart'; | ||
import 'package:das_client/sfera/src/model/train_location_information.dart'; | ||
|
||
class OwnTrain extends SferaXmlElement { | ||
static const String elementType = 'OwnTrain'; | ||
|
||
OwnTrain({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
TrainIdentification get trainIdentification => children.whereType<TrainIdentification>().first; | ||
|
||
TrainLocationInformation get trainLocationInformation => children.whereType<TrainLocationInformation>().first; | ||
|
||
@override | ||
bool validate() { | ||
return validateHasChildOfType<TrainIdentification>() && | ||
validateHasChildOfType<TrainLocationInformation>() && | ||
super.validate(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
das_client/lib/sfera/src/model/related_train_information.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
|
||
import 'package:das_client/sfera/src/model/own_train.dart'; | ||
|
||
class RelatedTrainInformation extends SferaXmlElement { | ||
static const String elementType = 'RelatedTrainInformation'; | ||
|
||
RelatedTrainInformation({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
OwnTrain get ownTrain => children.whereType<OwnTrain>().first; | ||
|
||
@override | ||
bool validate() { | ||
return validateHasChildOfType<OwnTrain>() && super.validate(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
das_client/lib/sfera/src/model/sfera_g2b_event_message.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:das_client/sfera/src/model/g2b_event_payload.dart'; | ||
import 'package:das_client/sfera/src/model/message_header.dart'; | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
|
||
class SferaG2bEventMessage extends SferaXmlElement { | ||
static const String elementType = 'SFERA_G2B_EventMessage'; | ||
|
||
SferaG2bEventMessage({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
MessageHeader get messageHeader => children.whereType<MessageHeader>().first; | ||
|
||
G2bEventPayload? get payload => children.whereType<G2bEventPayload>().firstOrNull; | ||
|
||
@override | ||
bool validate() { | ||
return validateHasChildOfType<MessageHeader>() && validateHasChildOfType<G2bEventPayload>() && super.validate(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
das_client/lib/sfera/src/model/train_location_information.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:das_client/sfera/src/model/delay.dart'; | ||
import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; | ||
|
||
class TrainLocationInformation extends SferaXmlElement { | ||
static const String elementType = 'TrainLocationInformation'; | ||
|
||
tobe-official marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
TrainLocationInformation({super.type = elementType, super.attributes, super.children, super.value}); | ||
|
||
Delay get delay => children.whereType<Delay>().first; | ||
|
||
@override | ||
bool validate() { | ||
return validateHasChildOfType<Delay>() && super.validate(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
das_client/lib/sfera/src/service/event/journey_profile_event_handler.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:das_client/sfera/src/model/journey_profile.dart'; | ||
import 'package:das_client/sfera/src/model/sfera_g2b_event_message.dart'; | ||
import 'package:das_client/sfera/src/repo/sfera_repository.dart'; | ||
import 'package:das_client/sfera/src/service/event/sfera_event_message_handler.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
|
||
class JourneyProfileEventHandler extends SferaEventMessageHandler<JourneyProfile> { | ||
final SferaRepository _sferaRepository; | ||
|
||
JourneyProfileEventHandler(super.onMessageHandled, this._sferaRepository); | ||
|
||
@override | ||
Future<bool> handleMessage(SferaG2bEventMessage eventMessage) async { | ||
if (eventMessage.payload == null || eventMessage.payload!.journeyProfiles.isEmpty) { | ||
return false; | ||
} | ||
|
||
Fimber.i('Updating journey profiles...'); | ||
for (final journeyProfile in eventMessage.payload!.journeyProfiles) { | ||
await _sferaRepository.saveJourneyProfile(journeyProfile); | ||
} | ||
|
||
if (eventMessage.payload!.journeyProfiles.length > 1) { | ||
Fimber.w('Received more then 1 journey profile which is not supported, using first one provided'); | ||
} | ||
|
||
onMessageHandled(this, eventMessage.payload!.journeyProfiles.first); | ||
return true; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
das_client/lib/sfera/src/service/event/related_train_information_event_handler.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:das_client/sfera/src/model/related_train_information.dart'; | ||
import 'package:das_client/sfera/src/model/sfera_g2b_event_message.dart'; | ||
import 'package:das_client/sfera/src/service/event/sfera_event_message_handler.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
|
||
class RelatedTrainInformationEventHandler extends SferaEventMessageHandler<RelatedTrainInformation> { | ||
RelatedTrainInformationEventHandler(super.onMessageHandled); | ||
|
||
@override | ||
Future<bool> handleMessage(SferaG2bEventMessage eventMessage) async { | ||
if (eventMessage.payload == null || eventMessage.payload!.relatedTrainInformation == null) { | ||
return false; | ||
} | ||
|
||
Fimber.i('Received new related train information... ${eventMessage.payload!.relatedTrainInformation?.ownTrain.trainLocationInformation.delay.delay}'); | ||
onMessageHandled(this, eventMessage.payload!.relatedTrainInformation!); | ||
return true; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
das_client/lib/sfera/src/service/event/sfera_event_message_handler.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:das_client/sfera/src/model/sfera_g2b_event_message.dart'; | ||
|
||
typedef MessageHandled<T> = void Function(SferaEventMessageHandler handler, T data); | ||
|
||
abstract class SferaEventMessageHandler<T> { | ||
SferaEventMessageHandler(this.onMessageHandled); | ||
|
||
final MessageHandled<T> onMessageHandled; | ||
|
||
Future<bool> handleMessage(SferaG2bEventMessage eventMessage); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cocoapods bei dir noch updaten, dieser change reverten