From c5d8e6282ed9f7e8a4d6738c613d4d50c528babf Mon Sep 17 00:00:00 2001 From: linus Date: Sun, 21 Jun 2020 10:26:07 +0200 Subject: [PATCH] =?UTF-8?q?Ordner=20f=C3=BCr=20die=20installation=20des=20?= =?UTF-8?q?Prototypen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 18 - CarControlUnit/pom.xml | 27 -- CarControlUnit/src/Car/MessageHandler.java | 344 ------------------ CarControlUnit/src/Car/SoftwareManager.java | 50 --- CarControlUnit/src/CarControlUnitMain.java | 68 ---- .../MessageHandlerPresenter.java | 35 -- .../CCUMessageHandler/MessageHandlerView.java | 6 - .../GUI/CCUMessageHandler/messagehandler.css | 3 - .../GUI/CCUMessageHandler/messagehandler.fxml | 15 - .../src/GUI/Carla/CarlaPresenter.java | 303 --------------- CarControlUnit/src/GUI/Carla/CarlaView.java | 6 - CarControlUnit/src/GUI/Carla/carla.css | 3 - CarControlUnit/src/GUI/Carla/carla.fxml | 40 -- CarControlUnit/src/GUI/LogPrinter.java | 63 ---- .../src/GUI/Main/MainPresenter.java | 59 --- CarControlUnit/src/GUI/Main/MainView.java | 6 - CarControlUnit/src/GUI/Main/main.css | 3 - CarControlUnit/src/GUI/Main/main.fxml | 15 - CarControlUnit/src/META-INF/MANIFEST.MF | 3 - .../src/Network/CarlaClientConnection.java | 121 ------ .../src/Network/MMSClientConnection.java | 114 ------ CarControlUnit/src/Network/NetworkConfig.java | 15 - .../INettyClient.java | 38 -- .../NettyClientHandler.java | 88 ----- .../NettyClientInitializer.java | 42 --- .../NettyConnectionClient.java | 164 --------- Common/pom.xml | 19 - Common/src/Actions/GoAwayAction.java | 9 - Common/src/Actions/IAction.java | 6 - Common/src/Actions/MovementHintAction.java | 10 - Common/src/Actions/TargetAction.java | 9 - Common/src/EnvironmentObjects/Angebot.java | 26 -- .../src/EnvironmentObjects/Description.java | 77 ---- .../EnvironmentObjects/IConnectionClient.java | 37 -- Common/src/EnvironmentObjects/Provider.java | 39 -- .../Software/ISoftware.java | 13 - .../Software/ParkingServiceSoftware.java | 116 ------ .../EnvironmentObjects/Software/Software.java | 93 ----- Common/src/Messages/CarlaMessage.java | 17 - Common/src/Messages/FillShopMessage.java | 31 -- Common/src/Messages/IMessage.java | 14 - Common/src/Messages/Message.java | 18 - Common/src/Messages/ServiceActionCommand.java | 27 -- Common/src/Messages/ServiceActionMessage.java | 26 -- .../src/Messages/ServiceDecisionMessage.java | 36 -- Common/src/Messages/ServiceMessage.java | 32 -- .../Messages/ServiceRegistrationMessage.java | 49 --- .../src/Messages/SoftwareContentMessage.java | 55 --- .../src/Messages/SoftwareContentRequest.java | 37 -- .../src/Messages/SoftwareDecisionMessage.java | 32 -- .../src/Messages/SoftwareDeleteMessage.java | 27 -- .../src/Messages/SoftwareInstallRequest.java | 20 - .../Messages/SoftwareInstallationPackage.java | 31 -- Common/src/Messages/SoftwareMessage.java | 29 -- .../Messages/SoftwareRegistrationMessage.java | 35 -- .../src/Messages/SoftwareSearchRequest.java | 22 -- Installationsordner/CarControlUnit.jar | Bin 0 -> 7676856 bytes .../simulation_handler_automatic.py | 174 +++++++++ Installationsordner/Server.jar | Bin 0 -> 7642179 bytes .../OEMVerificationServer.iml | 28 -- OEMVerificationServer/Server.iml | 29 -- OEMVerificationServer/pom.xml | 27 -- .../src/META-INF/MANIFEST.MF | 3 - OEMVerificationServer/src/ServerMain.java | 7 - .../src/director_repository/Director.java | 122 ------- .../InventoryDatabase.java | 30 -- .../src/director_repository/SUPR.java | 23 -- .../src/network/INettyServer.java | 10 - .../src/network/NettyServer.java | 71 ---- .../src/network/NettyServerHandler.java | 60 --- .../src/network/NetworkConfig.java | 6 - .../src/repos/ImageRepository.java | 27 -- .../src/repos/ScenarioRepository.java | 24 -- pom.xml | 59 --- 74 files changed, 174 insertions(+), 3167 deletions(-) delete mode 100644 .gitignore delete mode 100644 CarControlUnit/pom.xml delete mode 100644 CarControlUnit/src/Car/MessageHandler.java delete mode 100644 CarControlUnit/src/Car/SoftwareManager.java delete mode 100644 CarControlUnit/src/CarControlUnitMain.java delete mode 100644 CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerPresenter.java delete mode 100644 CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerView.java delete mode 100644 CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.css delete mode 100644 CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.fxml delete mode 100644 CarControlUnit/src/GUI/Carla/CarlaPresenter.java delete mode 100644 CarControlUnit/src/GUI/Carla/CarlaView.java delete mode 100644 CarControlUnit/src/GUI/Carla/carla.css delete mode 100644 CarControlUnit/src/GUI/Carla/carla.fxml delete mode 100644 CarControlUnit/src/GUI/LogPrinter.java delete mode 100644 CarControlUnit/src/GUI/Main/MainPresenter.java delete mode 100644 CarControlUnit/src/GUI/Main/MainView.java delete mode 100644 CarControlUnit/src/GUI/Main/main.css delete mode 100644 CarControlUnit/src/GUI/Main/main.fxml delete mode 100644 CarControlUnit/src/META-INF/MANIFEST.MF delete mode 100644 CarControlUnit/src/Network/CarlaClientConnection.java delete mode 100644 CarControlUnit/src/Network/MMSClientConnection.java delete mode 100644 CarControlUnit/src/Network/NetworkConfig.java delete mode 100644 CarControlUnit/src/Network/OEMVerificationServerConnection/INettyClient.java delete mode 100644 CarControlUnit/src/Network/OEMVerificationServerConnection/NettyClientHandler.java delete mode 100644 CarControlUnit/src/Network/OEMVerificationServerConnection/NettyClientInitializer.java delete mode 100644 CarControlUnit/src/Network/OEMVerificationServerConnection/NettyConnectionClient.java delete mode 100644 Common/pom.xml delete mode 100644 Common/src/Actions/GoAwayAction.java delete mode 100644 Common/src/Actions/IAction.java delete mode 100644 Common/src/Actions/MovementHintAction.java delete mode 100644 Common/src/Actions/TargetAction.java delete mode 100644 Common/src/EnvironmentObjects/Angebot.java delete mode 100644 Common/src/EnvironmentObjects/Description.java delete mode 100644 Common/src/EnvironmentObjects/IConnectionClient.java delete mode 100644 Common/src/EnvironmentObjects/Provider.java delete mode 100644 Common/src/EnvironmentObjects/Software/ISoftware.java delete mode 100644 Common/src/EnvironmentObjects/Software/ParkingServiceSoftware.java delete mode 100644 Common/src/EnvironmentObjects/Software/Software.java delete mode 100644 Common/src/Messages/CarlaMessage.java delete mode 100644 Common/src/Messages/FillShopMessage.java delete mode 100644 Common/src/Messages/IMessage.java delete mode 100644 Common/src/Messages/Message.java delete mode 100644 Common/src/Messages/ServiceActionCommand.java delete mode 100644 Common/src/Messages/ServiceActionMessage.java delete mode 100644 Common/src/Messages/ServiceDecisionMessage.java delete mode 100644 Common/src/Messages/ServiceMessage.java delete mode 100644 Common/src/Messages/ServiceRegistrationMessage.java delete mode 100644 Common/src/Messages/SoftwareContentMessage.java delete mode 100644 Common/src/Messages/SoftwareContentRequest.java delete mode 100644 Common/src/Messages/SoftwareDecisionMessage.java delete mode 100644 Common/src/Messages/SoftwareDeleteMessage.java delete mode 100644 Common/src/Messages/SoftwareInstallRequest.java delete mode 100644 Common/src/Messages/SoftwareInstallationPackage.java delete mode 100644 Common/src/Messages/SoftwareMessage.java delete mode 100644 Common/src/Messages/SoftwareRegistrationMessage.java delete mode 100644 Common/src/Messages/SoftwareSearchRequest.java create mode 100644 Installationsordner/CarControlUnit.jar create mode 100644 Installationsordner/CarlaScriptThesis/simulation_handler_automatic.py create mode 100644 Installationsordner/Server.jar delete mode 100644 OEMVerificationServer/OEMVerificationServer.iml delete mode 100644 OEMVerificationServer/Server.iml delete mode 100644 OEMVerificationServer/pom.xml delete mode 100644 OEMVerificationServer/src/META-INF/MANIFEST.MF delete mode 100644 OEMVerificationServer/src/ServerMain.java delete mode 100644 OEMVerificationServer/src/director_repository/Director.java delete mode 100644 OEMVerificationServer/src/director_repository/InventoryDatabase.java delete mode 100644 OEMVerificationServer/src/director_repository/SUPR.java delete mode 100644 OEMVerificationServer/src/network/INettyServer.java delete mode 100644 OEMVerificationServer/src/network/NettyServer.java delete mode 100644 OEMVerificationServer/src/network/NettyServerHandler.java delete mode 100644 OEMVerificationServer/src/network/NetworkConfig.java delete mode 100644 OEMVerificationServer/src/repos/ImageRepository.java delete mode 100644 OEMVerificationServer/src/repos/ScenarioRepository.java delete mode 100644 pom.xml diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9908cb0..0000000 --- a/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Project exclude paths -/CarControlUnit/target/ -/Common/target/ -/Server/target/ -/CarControlUnit/CarControlUnit.iml -/Common/Common.iml -/Server/Server.iml -/bachelorthesis-java.iml -/.idea/vcs.xml -/.idea/.gitignore -/.idea/.name -/.idea/compiler.xml -/.idea/misc.xml -/.idea/modules.xml -/.idea/uiDesigner.xml -/.idea/* -/.idea -/OEMVerificationServer/target diff --git a/CarControlUnit/pom.xml b/CarControlUnit/pom.xml deleted file mode 100644 index 3d7e688..0000000 --- a/CarControlUnit/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - - linushestermeyer - bachelorthesis-java - 1.0-SNAPSHOT - - - linushestermeyer - CarControlUnit - 1.0-SNAPSHOT - - - - linushestermeyer - Common - 1.0-SNAPSHOT - - - - - - \ No newline at end of file diff --git a/CarControlUnit/src/Car/MessageHandler.java b/CarControlUnit/src/Car/MessageHandler.java deleted file mode 100644 index 81d8dd6..0000000 --- a/CarControlUnit/src/Car/MessageHandler.java +++ /dev/null @@ -1,344 +0,0 @@ -package Car; - -import Actions.GoAwayAction; -import Actions.TargetAction; -import EnvironmentObjects.IConnectionClient; -import EnvironmentObjects.Provider; -import EnvironmentObjects.Software.Software; -import GUI.CCUMessageHandler.MessageHandlerPresenter; -import GUI.Carla.CarlaPresenter; -import Network.CarlaClientConnection; -import Network.MMSClientConnection; -import Network.NetworkConfig; -import Network.OEMVerificationServerConnection.NettyClientInitializer; -import Network.OEMVerificationServerConnection.NettyConnectionClient; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -import Messages.*; - -import java.util.ArrayList; - -public class MessageHandler { - - - public static String MANIFEST = - "Software:\r\n" + - " DriveAutomaticBasic: 1.0\r\n" + - " DriveInMcDonalds: 1.2\r\n"; - - public static String MANIFEST_HACKED = - "Software:\r\n" + - " DriveAutomaticBasic: 1.0\r\n" + - " DriveInMcDonalds: 1.2\r\n"+ - "hacked muhahahaha"; - - public boolean hacked = false; - public boolean suggestionReady = true; - public boolean providerVerified = true; - - private IConnectionClient carlaConnection; - private IConnectionClient mmsConnection; - - private final NettyClientInitializer nettyClientInitializer; - private NettyConnectionClient swsConnection; - private EventBus bus; - private CarlaPresenter carlaPresenter; - private MessageHandlerPresenter messageHandlerPresenter; - private SoftwareManager mgr; - - private static MessageHandler handler; - - private MessageHandler() { - this.bus=new EventBus(); - bus.register(this); - this.carlaConnection = new CarlaClientConnection(bus); - this.mmsConnection = new MMSClientConnection(bus); - this.swsConnection= new NettyConnectionClient(bus); - nettyClientInitializer = new NettyClientInitializer(swsConnection); - this.swsConnection = (NettyConnectionClient)nettyClientInitializer.createNettyClientConnection(NetworkConfig.serverUrl,NetworkConfig.serverPort); - - this.carlaConnection.initBootstrap("127.0.0.1", 22898); - this.mmsConnection.initBootstrap("127.0.0.1",22620); - this.mgr =new SoftwareManager(); - } - - public static MessageHandler getInstance(){ - if(handler ==null){ - handler=new MessageHandler(); - } - return handler; - } - public void sendToCarla(IMessage out){ - if(((CarlaClientConnection)this.carlaConnection).isRunning()) { - this.carlaConnection.sendMessage(out); - } - - } - public void sendToMMS(IMessage out){ - if(((MMSClientConnection)this.mmsConnection).isRunning()){ - this.mmsConnection.sendMessage(out); - } else { - messageHandlerPresenter.printToLog("Tried to send "+out.toString()+ "but mms is not connected;"); - } - } - public void sendToSWS(IMessage out){ - this.swsConnection.sendMessage(out); - } - public void setMessageHandlerPresenter(MessageHandlerPresenter messageHandlerPresenter) { - this.messageHandlerPresenter=messageHandlerPresenter; - } - public void setCarlaPresenter(CarlaPresenter carlaPresenter) { - this.carlaPresenter=carlaPresenter; - } - - - private ArrayList registeringServices = new ArrayList<>(); - - /** - * Reads ServiceRegistrationMessages and passes them to the software being able to handle this Message. - * - * @param msg - */ - @Subscribe - public void registerService(ServiceRegistrationMessage msg){ - final String serviceSoftwareID= msg.getRequiredSWID(); - Software handlingSW = mgr.getSoftware(serviceSoftwareID); - if(handlingSW != null && handlingSW.isUpTpDate()){ - boolean found = false; - for(Provider provider : handlingSW.getVerifiedServiceProviders()){ - if(provider.getPublicProviderID() == msg.getProvider().getPublicProviderID()) - found= true; - } - if(!found && !providerVerified){//todo: verschönern, damit der boolean nicht weiter benötigt wird. - messageHandlerPresenter.printToLog( - "Service wird nicht vorgeschlagen, da der Service Provider nicht verifiziert ist:"+ msg.getDescription().getTitle()); - - carlaPresenter.currentStage = CarlaPresenter.STAGE.CAR_DECLINED_SERVICE_OR_SOFTWARE; - carlaPresenter.setUpButtons(); - return; - } - messageHandlerPresenter.printToLog( - "Service wird zur Nutzung vorgeschlagen! "+ msg.getDescription().getTitle()); - - mmsConnection.sendMessage(msg); - - carlaPresenter.currentStage = CarlaPresenter.STAGE.CAR_INSTALLING_SW; - carlaPresenter.setUpButtons(); - } else{ - messageHandlerPresenter.printToLog( - "Service möchte sich registrieren!" - +"\n Für den Service wird eine neue Software benötigt! Speichere Anfrage... InquiryID: "+ msg.getInquiryID() - +"\n Provider name: "+msg.getProvider().getProviderName() - +"\n Service: "+msg.getDescription().getTitle() - +"\n Beschreibung: "+msg.getDescription().getDescription() - +"\n Software ID: "+msg.getRequiredSWID() - ); - - msg.setInstallSW(true); - registeringServices.add(msg); - SoftwareContentRequest cmd = new SoftwareContentRequest(msg.getDescription(), msg.getProvider(),msg.getInquiryID(), msg.getRequiredSWID()); - swsConnection.sendMessage(cmd); - messageHandlerPresenter.printToLog("Software Beschreibung wird heruntergeladen."); - - carlaPresenter.currentStage = CarlaPresenter.STAGE.CAR_INSTALLING_SW; - carlaPresenter.setUpButtons(); - } - } - - @Subscribe - public void waitForVerification(SoftwareContentMessage softwareContentMessage){ - messageHandlerPresenter.printToLog("Software Beschreibung vom Server erhalten:" - +"\n Software ID: "+softwareContentMessage.getDesc().getTitle() - +"\n Entwickler: "+softwareContentMessage.getProvider().getProviderName() - ); - if(softwareContentMessage.isVerified()){ - for(ServiceRegistrationMessage msg : registeringServices){ - if(softwareContentMessage.getSoftwareID().equals(msg.getRequiredSWID())){ - SoftwareRegistrationMessage swRegistration = new SoftwareRegistrationMessage( - softwareContentMessage.getDesc(), - softwareContentMessage.getInquiryID(), - softwareContentMessage.getSoftwareID(), - softwareContentMessage.getProvider() - ); - new Thread(){ - @Override - public void run() { - while(true) { - System.err.println(suggestionReady); - if(suggestionReady) { - sendToMMS(swRegistration); - break; - } - } - - } - }.start(); - } - } - } else{ - System.err.println("Unverified SW got recommended!"); - } - } - - @Subscribe - public void handleActionCommand(ServiceActionCommand cmd){ - if(cmd.getAction() instanceof GoAwayAction){ - messageHandlerPresenter.printToLog("Fahranweisung vom Parkautomaten erhalten, ich entferne mich."); - }else if (cmd.getAction() instanceof TargetAction){ - messageHandlerPresenter.printToLog("Parkticket gebucht und Parkplatz zugewiesen bekommen, ich parke!"); - - } - if(cmd.getAction() instanceof GoAwayAction) - sendToCarla(new CarlaMessage(5)); - else - sendToCarla(new CarlaMessage(4)); - - final String serviceSWID =cmd.getRequiredSWID(); - Software handlingSW = mgr.getSoftware(serviceSWID); - if(handlingSW != null) - handlingSW.handleMessage(cmd); - - } - - @Subscribe - public void waitForDecisions(ServiceDecisionMessage serviceDecisionMessage){ - final String serviceSoftwareID= serviceDecisionMessage.getRequiredSWID(); - Software handlingSW = mgr.getSoftware(serviceSoftwareID); - if(handlingSW!=null) { - //Todo: in handleMessage der Softwares muss die id des genutzten Angebots ausgewertet werden. - //handleMessage wird nicht genutzt, da nicht notwendig für Prototypen - //handlingSW.handleMessage(serviceDecisionMessage); - }else{ - System.err.println("Die notwendige Software konnte nicht gestartet werden..."); - } - if(serviceDecisionMessage.isAccepted()) { - messageHandlerPresenter.printToLog( - "Fahrer hat den Service angenommen. Leite die Entscheidung an den Parkautomaten weiter." - ); - carlaPresenter.printToEnvironment( - "Anfrage "+ serviceDecisionMessage.getInquiryID() +" wurde angenommen, bereit einen Parkplatz zuzuweisen."); - - carlaPresenter.currentStage = CarlaPresenter.STAGE.CAR_ACCEPTED_SERVICE; - carlaPresenter.setUpButtons(); - }else{ - messageHandlerPresenter.printToLog( - "Fahrer hat den Service nicht angenommen. Leite die Entscheidung an den Parkautomaten weiter." - ); - carlaPresenter.printToEnvironment( - "Anfrage "+ serviceDecisionMessage.getInquiryID() +" wurde abgelehnt, Fahrzeug kann verabschiedet werden."); - carlaPresenter.currentStage = CarlaPresenter.STAGE.CAR_DECLINED_SERVICE_OR_SOFTWARE; - carlaPresenter.setUpButtons(); - } - } - - - /** - * Sends a SWInstallRequest to the OEMVerificationServer. Return expected form server: SoftwareInstallationMessage - * @param softwareDecisionMessage - */ - @Subscribe - public void waitForSoftwareDecisions(SoftwareDecisionMessage softwareDecisionMessage){ - if(softwareDecisionMessage.isAccepted()){ - SoftwareInstallRequest req = new SoftwareInstallRequest( - softwareDecisionMessage.getSoftwareID(), - softwareDecisionMessage.getProvider(), - getManifest()); - //todo: gewähltes Angebot berechnen - messageHandlerPresenter.printToLog("Fahrer möchte neue Software installieren. Fordere diese vom Server an..."); - sendToSWS(req); - } else{ - ServiceRegistrationMessage registrationMessage = null; - for(ServiceRegistrationMessage msg : registeringServices){ - if(msg.getRequiredSWID().equals(softwareDecisionMessage.getSoftwareID())){ - registrationMessage= msg; - } - } - registeringServices.remove(registrationMessage); - - messageHandlerPresenter.printToLog("Fahrer möchte keine Software installieren, ich entferne mich!"); - carlaPresenter.currentStage= CarlaPresenter.STAGE.CAR_DECLINED_SERVICE_OR_SOFTWARE; - carlaPresenter.setUpButtons(); - } - } - - - @Subscribe - public void waitForSoftwarePackage(SoftwareInstallationPackage installationPackage){ - if(installationPackage.getUpdatedManifest().equals(getManifest())){ - //Keine neue Software - messageHandlerPresenter.printToLog("Error 502: Bad Request. Ihr Fahrzeug wurde nicht verifiziert. Sicherheitslücke!"); - - ServiceRegistrationMessage registrationMessage = null; - for(ServiceRegistrationMessage msg : registeringServices){ - if(installationPackage.getSoftwareID().equals(msg.getRequiredSWID()) - && msg.isInstallSW()){ - registrationMessage =msg; - } - } - registeringServices.remove(registrationMessage); - bus.post(new SoftwareDecisionMessage(registrationMessage.getInquiryID(), - false, - installationPackage.getSoftwareID(), - installationPackage.getProvider())); - } else{ - //Neue Software - messageHandlerPresenter.printToLog("Neue Software installiert: "+installationPackage.getSoftware().getDescription().getTitle()); - Software toBeInstalled = installationPackage.getSoftware(); - - //Kommunikationskanäle setzen - toBeInstalled.setCarlaConnection(carlaConnection); - toBeInstalled.setMmsConnection(mmsConnection); - //toBeInstalled.setSwsConnection(swsConnection); - - //Software hinzufügen - mgr.installSoftware(toBeInstalled); - MANIFEST =installationPackage.getUpdatedManifest(); - carlaPresenter.setSwInstalled(); - - System.err.println(getManifest()); - //Now that Software is installed, if a Sevrice is waiting for this to be installed the Process must continue - ServiceRegistrationMessage registrationMessage = null; - for(ServiceRegistrationMessage msg : registeringServices){ - if(installationPackage.getSoftwareID().equals(msg.getRequiredSWID()) - && msg.isInstallSW()){ - registrationMessage =msg; - } - } - registeringServices.remove(registrationMessage); - bus.post(registrationMessage); - } - } - - public String getManifest() { - if(hacked) - return MANIFEST_HACKED; - else - return MANIFEST; - } - - public void post(IMessage msg){ - bus.post(msg); - } - - public void hack() { - if(hacked){ - hacked = false; - } else{ - hacked=true; - } - } - public void verifyProvider() { - if(providerVerified){ - providerVerified = false; - } else{ - providerVerified=true; - } - } - public void showSWSuggestions() { - if(suggestionReady){ - suggestionReady = false; - } else{ - suggestionReady=true; - } - } -} diff --git a/CarControlUnit/src/Car/SoftwareManager.java b/CarControlUnit/src/Car/SoftwareManager.java deleted file mode 100644 index 0299119..0000000 --- a/CarControlUnit/src/Car/SoftwareManager.java +++ /dev/null @@ -1,50 +0,0 @@ -package Car; - -import EnvironmentObjects.Software.Software; -import Messages.ServiceRegistrationMessage; - -import java.util.ArrayList; - -/** - * Every Car has a SoftwareManager. the Softwaremanager forwards incoming messages to the specific Software which is needed to handle these Messages. It also prepares the installation of new Software. - */ -public class SoftwareManager { - - private static ArrayList installedSW = new ArrayList<>(); - - /** - * Method to get a Software from the SoftwareManager by SoftwareID. - * - * @param serviceSoftwareID the id - * @return the software requested by ID - */ - public Software getSoftware(String serviceSoftwareID) { - for(Software sw : installedSW){ - if(sw.getSoftwareID().equals(serviceSoftwareID)){ - return sw; - } - } - return null; - } - - /** - * Called if a incoming Service requires a software which is not installed. This method passes Softwware-based - * information to the MMS. - * - * @param msg - */ - public void submitSoftware(ServiceRegistrationMessage msg) { - msg.setInstallSW(true); - MessageHandler.getInstance().sendToMMS(msg); - } - - - public void installSoftware(Software software) { - installedSW.add(software); - System.err.println("Installed new Software: " + software); - } - - public void uninstallSoftware(Software software){ - installedSW.remove(software); - } -} diff --git a/CarControlUnit/src/CarControlUnitMain.java b/CarControlUnit/src/CarControlUnitMain.java deleted file mode 100644 index 2764c0c..0000000 --- a/CarControlUnit/src/CarControlUnitMain.java +++ /dev/null @@ -1,68 +0,0 @@ -import GUI.Main.MainPresenter; -import GUI.Main.MainView; -import Car.MessageHandler; -import com.google.common.eventbus.EventBus; -import com.airhacks.afterburner.injection.Injector; -import javafx.application.Application; -import javafx.application.Platform; -import javafx.event.EventHandler; -import javafx.scene.Scene; -import javafx.stage.Stage; -import javafx.stage.WindowEvent; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Linus Hestermeyer - * - * View.Main Class. - */ -public class CarControlUnitMain extends Application { - - private MessageHandler handler; - - @Override - public void start(Stage primaryStage) throws Exception { - //Teile entnommen von: https://docs.oracle.com/javafx/2/get_started/hello_world.htm - MainView mainView = new MainView(); - - /** - * Darstellen der Scene - */ - Scene scene = new Scene(mainView.getView()); - primaryStage.setTitle("CarControlUnit GUI"); - primaryStage.setScene(scene); - - primaryStage.setOnCloseRequest(new EventHandler() { - @Override - public void handle(WindowEvent event) { - Platform.exit(); - System.exit(0); - } - }); - - /** - * übergibt dem mainpresenter die primarystage, damit dieser die windowsize anpassen kann. - */ - MainPresenter mainPresenter = (MainPresenter) mainView.getPresenter(); - mainPresenter.setStage(primaryStage); - - /** - * sizetoScene muss hier geschehen, da im MainPresenter initalizer noch keine primarystage übergeben ist - */ - primaryStage.sizeToScene(); - primaryStage.show(); - - handler=MessageHandler.getInstance(); - handler.setCarlaPresenter(mainPresenter.getCarlaPresenter()); - handler.setMessageHandlerPresenter(mainPresenter.getMessageHandlerPresenter()); - - mainPresenter.getCarlaPresenter().setCarLogRefference(mainPresenter.getMessageHandlerPresenter().logReceivedMessages); - } - - @Override - public void stop() throws Exception { - Injector.forgetAll(); - } -} diff --git a/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerPresenter.java b/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerPresenter.java deleted file mode 100644 index 0190f7d..0000000 --- a/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerPresenter.java +++ /dev/null @@ -1,35 +0,0 @@ -package GUI.CCUMessageHandler; - -import GUI.LogPrinter; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.BorderPane; - -import java.net.URL; -import java.util.ResourceBundle; - -/** - * Diese Klasse repräsentiert den MainPresenter der die Mainview steuert, - * und somit die einzelnen Views lädt. - * - * @version 1.0 - */ -public class MessageHandlerPresenter implements Initializable { - - @FXML - public BorderPane mainPane; - - @FXML - public ScrollPane logReceivedMessages; - - @Override - public void initialize(URL location, ResourceBundle resources) { - - } - - public void printToLog(String s) { - LogPrinter.displayInView(logReceivedMessages, s); - } - -} \ No newline at end of file diff --git a/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerView.java b/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerView.java deleted file mode 100644 index 19fd346..0000000 --- a/CarControlUnit/src/GUI/CCUMessageHandler/MessageHandlerView.java +++ /dev/null @@ -1,6 +0,0 @@ -package GUI.CCUMessageHandler; - -import com.airhacks.afterburner.views.FXMLView; -//entnommen von http://afterburner.adam-bien.com/ -public class MessageHandlerView extends FXMLView { -} diff --git a/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.css b/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.css deleted file mode 100644 index 5192fbc..0000000 --- a/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.css +++ /dev/null @@ -1,3 +0,0 @@ -#mainView{ - -} \ No newline at end of file diff --git a/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.fxml b/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.fxml deleted file mode 100644 index 2a5b595..0000000 --- a/CarControlUnit/src/GUI/CCUMessageHandler/messagehandler.fxml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/CarControlUnit/src/GUI/Carla/CarlaPresenter.java b/CarControlUnit/src/GUI/Carla/CarlaPresenter.java deleted file mode 100644 index 3657d39..0000000 --- a/CarControlUnit/src/GUI/Carla/CarlaPresenter.java +++ /dev/null @@ -1,303 +0,0 @@ -package GUI.Carla; - -import Actions.GoAwayAction; -import Actions.IAction; -import Actions.TargetAction; -import Car.MessageHandler; -import EnvironmentObjects.Angebot; -import EnvironmentObjects.Description; -import EnvironmentObjects.Provider; -import EnvironmentObjects.Software.ParkingServiceSoftware; -import GUI.LogPrinter; -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.paint.Color; -import Messages.CarlaMessage; -import Messages.ServiceActionCommand; -import Messages.ServiceRegistrationMessage; - -import java.net.URL; -import java.util.ArrayList; -import java.util.ResourceBundle; - -/** - * Diese Klasse repräsentiert den MainPresenter der die Mainview steuert, - * und somit die einzelnen Views lädt. - * - * @version 1.0 - */ -public class CarlaPresenter implements Initializable { - - - public static final String CAR_1_ID = "CAR-LA-1"; - public static final String CAR_1_MANIFEST = - "software:\r\n" + - " DriveAutomaticBasic: 1.0\r\n" + - " DriveInMcDonalds: 1.2\r\n"; - - //TODO: edit this according to your local Carla.exe/Carla.sh - private static final String PATH = - "D:\\Carla"; - - @FXML - public ScrollPane environmentlog; - - @FXML - public Button startScenario; //start the engine - - @FXML - public Button driveAround; - - @FXML - public Button driveIntoPerceptionAreaButton; - - @FXML - public Button sendServiceRegistrationMessage; - - @FXML - public Button sendServiceActionButton; - - @FXML - public Button sayGoodbye; - - @FXML - public Button hack; - - @FXML - public Label hackLabel; - - @FXML - public Button svProviderVerified; - - @FXML - public Label svProviderVerifiedLabel; - - @FXML - public Button suggestionReady; - - @FXML - public Label suggestionReadyLabel; - - @FXML - public Label swInstalled; - - private boolean messageSent =false; - - private ScrollPane carLog; - - public void setCarLogRefference(ScrollPane carLog) { - this.carLog=carLog; - } - - public enum STAGE { - NO_CAR_STARTED, - NO_RUNNING_SCENARIO, - NO_REGISTERED_CAR, - CAR_IN_PERCEPTION_AREA, - CAR_DECLINED_SERVICE_OR_SOFTWARE, - CAR_INSTALLING_SW, - CAR_ACCEPTED_SERVICE, - CAR_PARKED - } - private Provider provider; - - public STAGE currentStage = STAGE.NO_CAR_STARTED; - - - @Override - public void initialize(URL location, ResourceBundle resources) { - setUpButtons(); - startScenario.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - MessageHandler.getInstance().sendToCarla(new CarlaMessage(1)); - LogPrinter.displayInView(carLog, "Fahrzeug wurde in Carla gespawned."); - currentStage=STAGE.NO_RUNNING_SCENARIO; - setUpButtons(); - } - }); - driveAround.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - MessageHandler.getInstance().sendToCarla(new CarlaMessage(2)); - LogPrinter.displayInView(carLog, "Fahrzeug fährt zum Parkplatz."); - currentStage = STAGE.NO_REGISTERED_CAR; - setUpButtons(); - } - }); - driveIntoPerceptionAreaButton.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - MessageHandler.getInstance().sendToCarla(new CarlaMessage(3)); - currentStage = STAGE.CAR_IN_PERCEPTION_AREA; - LogPrinter.displayInView(carLog, "Fahrzeug fährt in Registrierungszone des Parkplatzes."); - LogPrinter.displayInView(environmentlog, "Fahrzeug in Registrierungszone erkannt. Registrierung möglich."); - setUpButtons(); - } - }); - sendServiceRegistrationMessage.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - ArrayList list = new ArrayList<>(); - list.add(new TargetAction()); - provider = new Provider( - "ger_park_328_nds", - "Parken in Oldenburg", - "parken.stadt-oldenburg.de" - ); - ArrayList angebotTitel = new ArrayList<>(); - angebotTitel.add("Preis pro Stunde"); - - ArrayList angebote = new ArrayList<>(); - angebote.add(new Angebot(0.70)); - Description desc = new Description( - "Parken in Oldenburg", - "Parken Sie in nächster Nähe zur Oldenburger Innenstadt!", - new ArrayList<>(), - angebote, - angebotTitel, - list - ); - - ServiceRegistrationMessage msg = new ServiceRegistrationMessage( - desc, 992120, provider, ParkingServiceSoftware.SOFTWARE_ID - ); - - MessageHandler.getInstance().post(msg); - - } - }); - sendServiceActionButton.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - if(currentStage== STAGE.CAR_ACCEPTED_SERVICE) { - ServiceActionCommand cmd = new ServiceActionCommand( - new TargetAction(), provider, "PARKING_SERVICE_GERMAN_CITIES" - ); - MessageHandler.getInstance().post(cmd); - }else if(currentStage== STAGE.CAR_DECLINED_SERVICE_OR_SOFTWARE){ - ServiceActionCommand cmd = new ServiceActionCommand( - new GoAwayAction(), provider, "PARKING_SERVICE_GERMAN_CITIES" - ); - MessageHandler.getInstance().post(cmd); - } - currentStage=STAGE.CAR_PARKED; - setUpButtons(); - } - }); - sayGoodbye.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - MessageHandler.getInstance().sendToCarla(new CarlaMessage(6)); - currentStage=STAGE.NO_CAR_STARTED; - setUpButtons(); - } - }); - hack.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - if(MessageHandler.getInstance().hacked){ - //nicht mehr gehackt - hackLabel.setText("Nicht gehackt"); - hackLabel.setTextFill(Color.web("#21a810")); - } else{ - hackLabel.setText("Gehackt"); - hackLabel.setTextFill(Color.web("#f50000")); - } - MessageHandler.getInstance().hack(); - } - }); - svProviderVerified.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - if(MessageHandler.getInstance().providerVerified){ - svProviderVerifiedLabel.setText("Nicht Verifiziert"); - svProviderVerifiedLabel.setTextFill(Color.web("#f50000")); - } else{ - svProviderVerifiedLabel.setText("Verifiziert"); - svProviderVerifiedLabel.setTextFill(Color.web("#21a810")); - } - MessageHandler.getInstance().verifyProvider(); - } - }); - suggestionReady.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - if(!MessageHandler.getInstance().suggestionReady){ - suggestionReadyLabel.setText("Werden angezeigt"); - suggestionReadyLabel.setTextFill(Color.web("#21a810")); - } else{ - suggestionReadyLabel.setText("Werden nicht angezeigt"); - suggestionReadyLabel.setTextFill(Color.web("#f50000")); - } - MessageHandler.getInstance().showSWSuggestions(); - } - }); - - } - - /** - * Enables and disables invalid Buttons. Sets what is to happen on Action. - */ - public void setUpButtons() { - switch (currentStage){ - case NO_CAR_STARTED: - setButtonVisibility(new boolean[]{true,false,false,false,false,false}); - break; - case NO_RUNNING_SCENARIO: - setButtonVisibility(new boolean[]{false,true,false,false,false,false}); - break; - case NO_REGISTERED_CAR: - setButtonVisibility(new boolean[]{false, false, true,false,false,false}); - break; - case CAR_IN_PERCEPTION_AREA: - setButtonVisibility(new boolean[]{false, false, false, true,false,false}); - break; - case CAR_INSTALLING_SW: - setButtonVisibility(new boolean[]{false,false,false,false,false,false}); - break; - case CAR_DECLINED_SERVICE_OR_SOFTWARE: - setButtonVisibility(new boolean[]{false,false,false, false,true,false}); - break; - case CAR_ACCEPTED_SERVICE: - setButtonVisibility(new boolean[]{false,false,false, false,true,false}); - break; - case CAR_PARKED: - setButtonVisibility(new boolean[]{false,false,false, false,false,true}); - break; - - default: - break; - } - } - - private void setButtonVisibility(boolean[] b) { - //System.err.println("Setting visibility..."); - startScenario.setDisable(!b[0]); - driveAround.setDisable(!b[1]); - driveIntoPerceptionAreaButton.setDisable(!b[2]); - sendServiceRegistrationMessage.setDisable(!b[3]); - sendServiceActionButton.setDisable(!b[4]); - sayGoodbye.setDisable(!b[5]); - } - - public void printToEnvironment(String s) { - LogPrinter.displayInView(environmentlog, s); - } - - public void setSwInstalled(){ - Platform.runLater(new Runnable() { - @Override - public void run() { - swInstalled.setText("Software Installiert"); - swInstalled.setTextFill(Color.web("#21a810")); - } - }); - } -} \ No newline at end of file diff --git a/CarControlUnit/src/GUI/Carla/CarlaView.java b/CarControlUnit/src/GUI/Carla/CarlaView.java deleted file mode 100644 index 640c929..0000000 --- a/CarControlUnit/src/GUI/Carla/CarlaView.java +++ /dev/null @@ -1,6 +0,0 @@ -package GUI.Carla; - -import com.airhacks.afterburner.views.FXMLView; -//entnommen von http://afterburner.adam-bien.com/ -public class CarlaView extends FXMLView { -} diff --git a/CarControlUnit/src/GUI/Carla/carla.css b/CarControlUnit/src/GUI/Carla/carla.css deleted file mode 100644 index 5192fbc..0000000 --- a/CarControlUnit/src/GUI/Carla/carla.css +++ /dev/null @@ -1,3 +0,0 @@ -#mainView{ - -} \ No newline at end of file diff --git a/CarControlUnit/src/GUI/Carla/carla.fxml b/CarControlUnit/src/GUI/Carla/carla.fxml deleted file mode 100644 index 101459c..0000000 --- a/CarControlUnit/src/GUI/Carla/carla.fxml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - -