From 3f631276a77b6ca45f5839d830f24d842c24a221 Mon Sep 17 00:00:00 2001 From: Jonas Zeunert Date: Mon, 6 May 2019 01:06:55 +0200 Subject: [PATCH] working on cli and added lamp json --- FlippR-Driver/CMakeLists.txt | 2 +- FlippR-Driver/cli/OutputInterpreter.cpp | 16 + FlippR-Driver/cli/OutputInterpreter.h | 24 ++ FlippR-Driver/cli/main.cpp | 9 +- .../json_example/output/Lamp_Config.json | 318 +++++++++++++++++- FlippR-Driver/include/DriverFactory.h | 12 +- 6 files changed, 364 insertions(+), 17 deletions(-) create mode 100644 FlippR-Driver/cli/OutputInterpreter.cpp create mode 100644 FlippR-Driver/cli/OutputInterpreter.h diff --git a/FlippR-Driver/CMakeLists.txt b/FlippR-Driver/CMakeLists.txt index aec62da..380c4db 100644 --- a/FlippR-Driver/CMakeLists.txt +++ b/FlippR-Driver/CMakeLists.txt @@ -90,7 +90,7 @@ file(GLOB_RECURSE SOURCES src/*.cpp) if(BUILD_SHARED_LIB) add_library(${PROJECT_NAME} SHARED ${SOURCES}) else() - add_library(${PROJECT_NAME} STATIC ${SOURCES}) + add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h) endif(BUILD_SHARED_LIB) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) diff --git a/FlippR-Driver/cli/OutputInterpreter.cpp b/FlippR-Driver/cli/OutputInterpreter.cpp new file mode 100644 index 0000000..46a0c4a --- /dev/null +++ b/FlippR-Driver/cli/OutputInterpreter.cpp @@ -0,0 +1,16 @@ +// +// Created by rhetenor on 5/5/19. +// + +#include "OutputInterpreter.h" + +#include + +using namespace std; + +OutputInterpreter::OutputInterpreter(std::string output_pin_config_file, std::string output_lamp_config_file, + std::string output_solenoid_config_file, std::string output_sound_config_file, + std::string output_display_config_file) + : output_driver(flippR_driver::get_OutputDriver(ifstream(output_pin_config_file), ifstream(output_lamp_config_file), + ifstream(output_solenoid_config_file), ifstream(output_sound_config_file), ifstream(output_display_config_file))) +{} diff --git a/FlippR-Driver/cli/OutputInterpreter.h b/FlippR-Driver/cli/OutputInterpreter.h new file mode 100644 index 0000000..9094a17 --- /dev/null +++ b/FlippR-Driver/cli/OutputInterpreter.h @@ -0,0 +1,24 @@ +// +// Created by rhetenor on 5/5/19. +// + +#ifndef FLIPPR_DRIVER_OUTPUTINTERPRETER_H +#define FLIPPR_DRIVER_OUTPUTINTERPRETER_H + +#include "DriverFactory.h" + +class OutputInterpreter +{ +public: + OutputInterpreter(std::string output_pin_config_file, std::string output_lamp_config_file, + std::string output_solenoid_config_file, std::string output_sound_config_file, + std::string output_display_config_file); + + void startInterpreter(); + +private: + std::shared_ptr output_driver; + +}; + +#endif //FLIPPR_DRIVER_OUTPUTINTERPRETER_H diff --git a/FlippR-Driver/cli/main.cpp b/FlippR-Driver/cli/main.cpp index 3cbc723..9792750 100644 --- a/FlippR-Driver/cli/main.cpp +++ b/FlippR-Driver/cli/main.cpp @@ -78,14 +78,9 @@ int main (int argc, char *argv[]) signal(SIGINT, __sigint_handler); po::options_description po_desc("Options"); - boost::optional input_pin_config_file; - std::string input_matrix_config_file; + boost::optional input_pin_config_file, output_pin_config_file; - boost::optional output_pin_config_file; - std::string output_display_config_file; - std::string output_lamp_config_file; - std::string output_solenoid_config_file; - std::string output_sound_config_file; + std::string input_matrix_config_file, output_display_config_file, output_lamp_config_file, output_solenoid_config_file, output_sound_config_file; register_program_options(po_desc, input_pin_config_file, input_matrix_config_file, output_pin_config_file, output_display_config_file, output_lamp_config_file, output_solenoid_config_file, output_sound_config_file); diff --git a/FlippR-Driver/contrib/json_example/output/Lamp_Config.json b/FlippR-Driver/contrib/json_example/output/Lamp_Config.json index 5cee167..dca6d9d 100644 --- a/FlippR-Driver/contrib/json_example/output/Lamp_Config.json +++ b/FlippR-Driver/contrib/json_example/output/Lamp_Config.json @@ -3,7 +3,319 @@ [ { "address" : 0, - "name" : "Special 100000 points" - } + "name" : "Special 100000 Points" + }, + { + "address" : 1, + "name" : "Special 200000 Points" + }, + { + "address" : 2, + "name" : "Woman Speech Lamp" + }, + { + "address" : 3, + "name" : "Highest Score" + }, + { + "address" : 4, + "name" : "Pop 2+4" + }, + { + "address" : 5, + "name" : "Special 300000 Points" + }, + { + "address" : 6, + "name" : "Pop 1+3" + }, + { + "address" : 7, + "name" : "Special Orange" + }, + { + "address" : 8, + "name" : "Down" + }, + { + "address" : 9, + "name" : "Lamp 30 Sec" + }, + { + "address" : 10, + "name" : "Lamp 20 Sec" + }, + { + "address" : 11, + "name" : "Lamp 10 Sec" + }, + { + "address" : 12, + "name" : "Lamp 5 Sec" + }, + { + "address" : 13, + "name" : "Can Play 4" + }, + { + "address" : 14, + "name" : "Can Play 3" + }, + { + "address" : 15, + "name" : "P Of Champ" + }, + { + "address" : 16, + "name" : "M Of Champ" + }, + { + "address" : 17, + "name" : "A Of Champ" + }, + { + "address" : 18, + "name" : "Can Play 2" + }, + { + "address" : 19, + "name" : "Big Bonus 20000" + }, + { + "address" : 20, + "name" : "Can Play 1" + }, + { + "address" : 21, + "name" : "H Of Champ" + }, + { + "address" : 22, + "name" : "C Of Champ" + }, + { + "address" : 23, + "name" : "Special Red" + }, + { + "address" : 24, + "name" : "Super Bonus" + }, + { + "address" : 25, + "name" : "Bonus 20000" + }, + { + "address" : 26, + "name" : "2nd Kicker Lamp" + }, + { + "address" : 27, + "name" : "Bonus 18000" + }, + { + "address" : 28, + "name" : "Bonus 17000" + }, + { + "address" : 29, + "name" : "Bonus 16000" + }, + { + "address" : 30, + "name" : "Man Speech Lamp" + }, + { + "address" : 31, + "name" : "Bonus 15000" + }, + { + "address" : 32, + "name" : "Bonus 14000" + }, + { + "address" : 33, + "name" : "Bonus 13000" + }, + { + "address" : 34, + "name" : "Bonus 12000" + }, + { + "address" : 35, + "name" : "Ball" + }, + { + "address" : 36, + "name" : "Bonus 11000" + }, + { + "address" : 37, + "name" : "Bonus 10000" + }, + { + "address" : 38, + "name" : "Bonus 9000" + }, + { + "address" : 39, + "name" : "Bonus 8000" + }, + { + "address" : 40, + "name" : "Bonus 7000" + }, + { + "address" : 41, + "name" : "Bonus 6000" + }, + { + "address" : 42, + "name" : "Bonus 5000" + }, + { + "address" : 43, + "name" : "Pop 5 Head Lamp" + }, + { + "address" : 44, + "name" : "Bonus 3000" + }, + { + "address" : 45, + "name" : "Bonus 2000" + }, + { + "address" : 46, + "name" : "Bonus 1000" + }, + { + "address" : 47, + "name" : "Bonus 4000" + }, + { + "address" : 48, + "name" : "Right Advance Time" + }, + { + "address" : 49, + "name" : "UP" + }, + { + "address" : 50, + "name" : "Bonux Multiplier x50" + }, + { + "address" : 51, + "name" : "Bonus Multiplier x20" + }, + { + "address" : 52, + "name" : "Bonus Multiplier x10" + }, + { + "address" : 53, + "name" : "Credit" + }, + { + "address" : 54, + "name" : "Bonus 19000" + }, + { + "address" : 55, + "name" : "5th Button" + }, + { + "address" : 56, + "name" : "4th Button" + }, + { + "address" : 57, + "name" : "3rd Button" + }, + { + "address" : 58, + "name" : "2nd Button" + }, + { + "address" : 59, + "name" : "1st Button" + }, + { // todo! + "address" : 60, + "name" : "Flipper Relay" + }, + { + "address" : 61, + "name" : "Lamp 5" + }, + { + "address" : 62, + "name" : "Lamp 4" + }, + { + "address" : 63, + "name" : "Ball To Play" + }, + { + "address" : 64, + "name" : "Tunnel Lamp 20000 Points" + }, + { + "address" : 65, + "name" : "Tunnel Lamp 30000 Points" + }, + { + "address" : 66, + "name" : "Tunnel Lamp 50000 Points" + }, + { + "address" : 67, + "name" : "Match" + }, + { + "address" : 68, + "name" : "Lamp 3" + }, + { + "address" : 69, + "name" : "Lamp 2" + }, + { + "address" : 70, + "name" : "1st Kicker Lamp" + }, + { + "address" : 71, + "name" : "Lamp 1" + }, + { + "address" : 72, + "name" : "Left Advance Time" + }, + { + "address" : 73, + "name" : "Tilt" + }, + { + "address" : 74, + "name" : "Game Over" + }, + { + "address" : 75, + "name" : "500000 Points" + }, + { + "address" : 76, + "name" : "200000 Points" + }, + { + "address" : 77, + "name" : "150000 Points" + }, + { + "address" : 78, + "name" : "100000 Points" + }, ] -} \ No newline at end of file +} diff --git a/FlippR-Driver/include/DriverFactory.h b/FlippR-Driver/include/DriverFactory.h index 92b31c1..1a898f5 100644 --- a/FlippR-Driver/include/DriverFactory.h +++ b/FlippR-Driver/include/DriverFactory.h @@ -13,12 +13,12 @@ namespace flippR_driver { - std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); - std::shared_ptr get_OutputDriver(std::istream &output_pin_config, - std::istream &lamp_config, - std::istream &solenoid_config, - std::istream &sound_config, - std::istream &display_config); + std::shared_ptr get_InputDriver(const std::istream& input_config_stream, const std::istream& matrix_config_stream); + std::shared_ptr get_OutputDriver(const std::istream &output_pin_config, + const std::istream &lamp_config, + const std::istream &solenoid_config, + const std::istream &sound_config, + const std::istream &display_config); } #endif //flippR_driver_DRIVERFACTORY_H