diff --git a/.gradle/7.1/executionHistory/executionHistory.bin b/.gradle/7.1/executionHistory/executionHistory.bin index c9a290a..b64d7e3 100644 Binary files a/.gradle/7.1/executionHistory/executionHistory.bin and b/.gradle/7.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.1/executionHistory/executionHistory.lock b/.gradle/7.1/executionHistory/executionHistory.lock index 9675f43..8933358 100644 Binary files a/.gradle/7.1/executionHistory/executionHistory.lock and b/.gradle/7.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.1/fileHashes/fileHashes.bin b/.gradle/7.1/fileHashes/fileHashes.bin index e5e9bf7..7bba79a 100644 Binary files a/.gradle/7.1/fileHashes/fileHashes.bin and b/.gradle/7.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.1/fileHashes/fileHashes.lock b/.gradle/7.1/fileHashes/fileHashes.lock index bbe791b..341b18b 100644 Binary files a/.gradle/7.1/fileHashes/fileHashes.lock and b/.gradle/7.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 642f185..9a1a849 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/classes/java/main/com/example/DeliveryCar$CheckStop.class b/build/classes/java/main/com/example/DeliveryCar$CheckStop.class index a104d3d..e2c4eac 100644 Binary files a/build/classes/java/main/com/example/DeliveryCar$CheckStop.class and b/build/classes/java/main/com/example/DeliveryCar$CheckStop.class differ diff --git a/build/classes/java/main/com/example/DeliveryCar$LoadMessage.class b/build/classes/java/main/com/example/DeliveryCar$LoadMessage.class index 3018329..1987861 100644 Binary files a/build/classes/java/main/com/example/DeliveryCar$LoadMessage.class and b/build/classes/java/main/com/example/DeliveryCar$LoadMessage.class differ diff --git a/build/classes/java/main/com/example/DeliveryCar$PickupResponse.class b/build/classes/java/main/com/example/DeliveryCar$PickupResponse.class index 0ee5351..6a5bf7c 100644 Binary files a/build/classes/java/main/com/example/DeliveryCar$PickupResponse.class and b/build/classes/java/main/com/example/DeliveryCar$PickupResponse.class differ diff --git a/build/classes/java/main/com/example/DeliveryCar$StartRoute.class b/build/classes/java/main/com/example/DeliveryCar$StartRoute.class index 65ef920..6fbaa1b 100644 Binary files a/build/classes/java/main/com/example/DeliveryCar$StartRoute.class and b/build/classes/java/main/com/example/DeliveryCar$StartRoute.class differ diff --git a/build/classes/java/main/com/example/DeliveryCar.class b/build/classes/java/main/com/example/DeliveryCar.class index 9f31e90..d5c0644 100644 Binary files a/build/classes/java/main/com/example/DeliveryCar.class and b/build/classes/java/main/com/example/DeliveryCar.class differ diff --git a/build/classes/java/main/com/example/DistributionCenter$ArriveMessage.class b/build/classes/java/main/com/example/DistributionCenter$ArriveMessage.class index 0083120..0743378 100644 Binary files a/build/classes/java/main/com/example/DistributionCenter$ArriveMessage.class and b/build/classes/java/main/com/example/DistributionCenter$ArriveMessage.class differ diff --git a/build/classes/java/main/com/example/DistributionCenter$GenerateRoutes.class b/build/classes/java/main/com/example/DistributionCenter$GenerateRoutes.class index 747d208..3b2d427 100644 Binary files a/build/classes/java/main/com/example/DistributionCenter$GenerateRoutes.class and b/build/classes/java/main/com/example/DistributionCenter$GenerateRoutes.class differ diff --git a/build/classes/java/main/com/example/DistributionCenter$StartAllRoutes.class b/build/classes/java/main/com/example/DistributionCenter$StartAllRoutes.class index 9bcf206..0aa7244 100644 Binary files a/build/classes/java/main/com/example/DistributionCenter$StartAllRoutes.class and b/build/classes/java/main/com/example/DistributionCenter$StartAllRoutes.class differ diff --git a/build/classes/java/main/com/example/DistributionCenter.class b/build/classes/java/main/com/example/DistributionCenter.class index 4511246..7553e54 100644 Binary files a/build/classes/java/main/com/example/DistributionCenter.class and b/build/classes/java/main/com/example/DistributionCenter.class differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 3b1c7ab..1304868 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/com/example/DeliveryCar.java b/src/main/java/com/example/DeliveryCar.java index 559ff53..c91e5ad 100644 --- a/src/main/java/com/example/DeliveryCar.java +++ b/src/main/java/com/example/DeliveryCar.java @@ -1,4 +1,3 @@ -// DeliveryCar.java package com.example; import akka.actor.typed.ActorRef; @@ -29,6 +28,8 @@ public class DeliveryCar extends AbstractBehavior { public record CheckStop() implements Message {} + public record Clear() implements Message {} // Clear all packages in the delivery car + private DeliveryCar(ActorContext context, TimerScheduler timers, ArrayList> route) { super(context); this.route = route; @@ -46,12 +47,13 @@ public class DeliveryCar extends AbstractBehavior { .onMessage(LoadMessage.class, this::onLoadMessage) .onMessage(StartRoute.class, this::onStartRoute) .onMessage(CheckStop.class, this::onCheckStop) + .onMessage(Clear.class, this::onClear) .build(); } private Behavior onLoadMessage(LoadMessage msg) { pakete.addAll(msg.pakete); - getContext().getLog().info("Geladen {} Pakete in den LKW.", msg.pakete.size()); + getContext().getLog().info("Laden: {} Pakete wurden in den LKW geladen.", msg.pakete.size()); scheduleNextStopCheck(Duration.ofSeconds(3)); // Start checking the first stop after 3 seconds return this; } @@ -59,7 +61,7 @@ public class DeliveryCar extends AbstractBehavior { private Behavior onPickupResponse(PickupResponse rsp) { if (rsp.paket != null && rsp.paket.inhalt != null && pakete.size() < maxCapacity) { pakete.add(rsp.paket); - getContext().getLog().info("Ein Paket abgeholt. Aktuelle Anzahl der Pakete im LKW: {}", pakete.size()); + getContext().getLog().info("Abholung: Ein Paket wurde aufgenommen. Aktuelle Anzahl der Pakete im LKW: {}", pakete.size()); } scheduleNextStopCheck(Duration.ofSeconds(1)); // Move to the next stop after 1 second return this; @@ -67,14 +69,13 @@ public class DeliveryCar extends AbstractBehavior { private Behavior onCheckStop(CheckStop stop) { if (globalIndex >= route.size()) { - getContext().getLog().info("Der LKW kehrt zum Verteilzentrum zurück."); + getContext().getLog().info("Rückkehr: Der LKW kehrt zum Verteilzentrum zurück mit {} Paketen.", pakete.size()); DistributionCenter.ArriveMessage antwort = new DistributionCenter.ArriveMessage(pakete, getContext().getSelf()); getDistributionCenter().tell(antwort); - pakete.clear(); globalIndex = 0; } else { ActorRef currentStop = route.get(globalIndex); - getContext().getLog().info("Ich bin bei {}", currentStop.path().name()); + getContext().getLog().info("Aktuelle Haltestelle: {}", currentStop.path().name()); deliverPackages(currentStop); if (pakete.size() < maxCapacity) { sendPickupMessage(currentStop); @@ -91,8 +92,13 @@ public class DeliveryCar extends AbstractBehavior { return this; } + private Behavior onClear(Clear clear) { + pakete.clear(); + return this; + } + private void sendPickupMessage(ActorRef customer) { - customer.tell(new Customer.PickUpMessage(getContext().getSelf(), "LKW kann Paket abholen")); + customer.tell(new Customer.PickUpMessage(getContext().getSelf(), "Der LKW kann das Paket abholen.")); } private void deliverPackages(ActorRef customer) { diff --git a/src/main/java/com/example/DistributionCenter.java b/src/main/java/com/example/DistributionCenter.java index 9fdf470..10a1992 100644 --- a/src/main/java/com/example/DistributionCenter.java +++ b/src/main/java/com/example/DistributionCenter.java @@ -1,4 +1,3 @@ -// DistributionCenter.java package com.example; import akka.actor.typed.ActorRef; @@ -91,6 +90,7 @@ public class DistributionCenter extends AbstractBehavior arrivedPackages = msg.getPakete(); lagerraum.addAll(arrivedPackages); getContext().getLog().info("Angekommene Pakete: {} Anz Packeten in Lager: {}", arrivedPackages.size(), lagerraum.size()); + msg.getTruck().tell(new DeliveryCar.Clear()); // Entferne zufällig 3 Pakete aus dem Lagerraum und sende sie dem angekommenen Wagen int numPackagesToSend = Math.min(3, lagerraum.size());