Skip to content
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

fix: driving mode, mock backend url, message header attributes #326

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions das_client/integration_test/test/fahrbild_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import '../app_test.dart';

void main() {
group('home screen test', () {
testWidgets('load fahrbild company=1088, train=9232', (tester) async {
testWidgets('load fahrbild company=1085, train=7839', (tester) async {
// Load app widget.
await prepareAndStartApp(tester);

await tester.pump(const Duration(seconds: 1));

// Verify we have trainnumber with 9232.
expect(find.text('9232'), findsOneWidget);
expect(find.text('7839'), findsOneWidget);

// Verify we have company with 1088.
expect(find.text('1088'), findsOneWidget);
expect(find.text('1085'), findsOneWidget);

// check that the primary button is enabled
var primaryButton = find.byWidgetPredicate((widget) => widget is SBBPrimaryButton).first;
Expand All @@ -28,7 +28,7 @@ void main() {
await tester.pumpAndSettle(const Duration(seconds: 1));

// check if station is present
expect(find.text('MEER-GRENS'), findsOneWidget);
expect(find.text('unkown'), findsExactly(6));
});
});
}
6 changes: 3 additions & 3 deletions das_client/lib/flavor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ enum Flavor {
dev(
displayName: 'Dev',
//backendUrl: 'http://localhost:8080',
backendUrl: 'https://das-backend-dev.app.sbb.ch',
backendUrl: 'https://sfera-mock.app.sbb.ch',
mqttUrl: 'wss://das-poc.messaging.solace.cloud',
authenticatorConfig: _authenticatorConfigDev,
),
inte(
displayName: 'Inte',
//backendUrl: 'http://localhost:8080',
backendUrl: 'https://das-backend-dev.app.sbb.ch',
backendUrl: 'https://sfera-mock.app.sbb.ch',
mqttUrl: 'wss://das-poc.messaging.solace.cloud',
authenticatorConfig: _authenticatorConfigInte,
),
prod(
displayName: 'Prod',
//backendUrl: 'http://localhost:8080',
backendUrl: 'https://das-backend-dev.app.sbb.ch',
backendUrl: 'https://sfera-mock.app.sbb.ch',
mqttUrl: 'wss://das-poc.messaging.solace.cloud',
authenticatorConfig: _authenticatorConfigProd,
);
Expand Down
6 changes: 2 additions & 4 deletions das_client/lib/model/sfera/message_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class MessageHeader extends SferaXmlElement {
messageHeader.attributes["timestamp"] = timestamp;
messageHeader.attributes["sourceDevice"] = sourceDevice;
messageHeader.attributes["destinationDevice"] = destinationDevice;
messageHeader.children.add(SferaXmlElement(type: "Sender", value: sender));
messageHeader.children.add(SferaXmlElement(type: "Recipient", value: recipient));

if (trainIdentification != null) {
messageHeader.children.add(trainIdentification);
}

messageHeader.children.add(SferaXmlElement(type: "Sender", value: sender));
messageHeader.children.add(SferaXmlElement(type: "Recipient", value: recipient));
return messageHeader;
}

Expand Down
4 changes: 2 additions & 2 deletions das_client/lib/pages/fahrt/widgets/train_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class _TrainSelectionState extends State<TrainSelection> {
@override
void initState() {
super.initState();
_trainNumberController = TextEditingController(text: "9232");
_companyController = TextEditingController(text: "1088");
_trainNumberController = TextEditingController(text: "7839");
_companyController = TextEditingController(text: "1085");

context.fahrbildCubit.updateTrainNumber(_trainNumberController.text);
context.fahrbildCubit.updateCompany(_companyController.text);
Expand Down
12 changes: 9 additions & 3 deletions das_client/lib/service/sfera/sfera_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ class SferaService {
_stateSubject.add(SferaServiceState.disconnected);
}

static Future<MessageHeader> messageHeader({TrainIdentification? trainIdentification}) async {
return MessageHeader.create(const Uuid().v4(), Format.sferaTimestamp(DateTime.now()),
await DeviceIdInfo.getDeviceId(), "TMS", await DeviceIdInfo.getDeviceId(), "TMS",
static Future<MessageHeader> messageHeader(
{TrainIdentification? trainIdentification}) async {
return MessageHeader.create(
const Uuid().v4(),
Format.sferaTimestamp(DateTime.now()),
await DeviceIdInfo.getDeviceId(),
"TMS",
"1085",
"0085",
trainIdentification: trainIdentification);
}

Expand Down
4 changes: 2 additions & 2 deletions das_client/lib/service/sfera/task/handshake_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class HandshakeTask extends SferaTask {
Fimber.i("Sending handshake request for company=${otnId.company} train=$sferaTrain");
var handshakeRequest = HandshakeRequest.create([
DasOperatingModesSupported.create(
DasDrivingMode.goa1, DasArchitecture.boardAdviceCalculation, DasConnectivity.connected),
], relatedTrainRequestType: RelatedTrainRequestType.ownTrainAndRelatedTrains, statusReportsEnabled: true);
DasDrivingMode.readOnly, DasArchitecture.boardAdviceCalculation, DasConnectivity.connected),
], relatedTrainRequestType: RelatedTrainRequestType.ownTrainAndRelatedTrains, statusReportsEnabled: false);

var sferaB2gRequestMessage =
SferaB2gRequestMessage.create(await SferaService.messageHeader(), handshakeRequest: handshakeRequest);
Expand Down
2 changes: 1 addition & 1 deletion das_client/lib/util/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Format {

static String sferaTimestamp(DateTime date) {
final localDate = date.toLocal();
final dateFormat = DateFormat("yyyy-MM-ddTHH:mm:ssZ");
final dateFormat = DateFormat("yyyy-MM-ddTHH:mm:ss'Z'");
return dateFormat.format(localDate);
}

Expand Down