This commit is contained in:
Jonas Zeunert
2018-11-09 13:00:43 +01:00
parent c5867acd52
commit 8eb1f724ea
21 changed files with 206 additions and 63 deletions

View File

@@ -0,0 +1,45 @@
{
"displays" :
{
},
"driver_board" :
{
"i2c_address" : 32,
"pin_base" : 65,
"latch-select" :
{
"A" : 0,
"B" : 1,
"C" : 2
},
"data" : 3,
"CL" : 4,
"mux-select" :
{
"A" : 5,
"B" : 6,
"C" : 7,
"mux1" : 8,
"mux2" : 9
}
},
"sound_board" :
{
"i2c_address" : 33,
"pin_base" : 81,
"fire" : 7,
"sound_address" :
{
"A" : 0,
"B" : 1,
"C" : 2,
"D" : 3,
"E" : 4,
"F" : 5,
"G" : 6
}
}
}

View File

@@ -0,0 +1,14 @@
{
"sounds" :
{
},
"lamps" :
{
},
"solenoids" :
{
}
}

View File

@@ -0,0 +1,13 @@
//
// Created by rhetenor on 19.10.18.
//
#ifndef FLIPPR_DRIVER_ACTIVATEEVENT_H
#define FLIPPR_DRIVER_ACTIVATEEVENT_H
class ActivateEvent : public Event
{
};
#endif //FLIPPR_DRIVER_ACTIVATEEVENT_H

View File

@@ -0,0 +1,5 @@
//
// Created by rhetenor on 19.10.18.
//
#include "CabinetItem.h"

View File

@@ -1,42 +1,13 @@
/*
* CabinetItem.h
*
* Created on: Aug 2, 2018
* Author: rhetenor
*/
//
// Created by rhetenor on 19.10.18.
//
#ifndef _SRC_OUTPUT_CABINETITEM_H_
#define _SRC_OUTPUT_CABINETITEM_H_
#ifndef FLIPPR_DRIVER_CABINETITEM_H
#define FLIPPR_DRIVER_CABINETITEM_H
#include "ICabinetItem.h"
#include "utilities/IOutputGPIOInterface.h"
#include <memory>
#include <string>
namespace FlippR_Driver
{
namespace output
class CabinetItem : IOutputItem
{
class CabinetItem : public ICabinetItem
{
public:
CabinetItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~CabinetItem();
virtual bool isActivated();
virtual bool activate();
virtual bool deactivate();
protected:
int address;
std::string name;
bool activated;
};
} /* namespace output */
}
#endif
#endif //FLIPPR_DRIVER_CABINETITEM_H

View File

@@ -0,0 +1,13 @@
//
// Created by rhetenor on 19.10.18.
//
#ifndef FLIPPR_DRIVER_DEACTIVATEEVENT_H
#define FLIPPR_DRIVER_DEACTIVATEEVENT_H
class DeactivateEvent
{
};
#endif //FLIPPR_DRIVER_DEACTIVATEEVENT_H

View File

@@ -7,7 +7,7 @@
#include "DisplayController.h"
#include "utilities/config.h"
#include "utility/config.h"
namespace FlippR_Driver
{

View File

@@ -24,7 +24,7 @@ namespace output
class DisplayController : public IDisplayController
{
public:
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
~DisplayController();
private:

View File

@@ -0,0 +1,22 @@
//
// Created by rhetenor on 19.10.18.
//
#ifndef FLIPPR_DRIVER_EVENT_H
#define FLIPPR_DRIVER_EVENT_H
#include "OutputItem.h"
#include <memory>
namespace FlippR_Driver
{
namespace output
{
class Event
{
std::shared_ptr<OutputItem> item;
};
}
}
#endif //FLIPPR_DRIVER_EVENT_H

View File

@@ -8,12 +8,14 @@
#ifndef _SRC_OUTPUT_ILAMP_H_
#define _SRC_OUTPUT_ILAMP_H_
#include "IOutputItem.h"
namespace FlippR_Driver
{
namespace output
{
class ILamp
class ILamp : public IOutputItem
{
};

View File

@@ -1,5 +1,5 @@
/*
* ICabinetItem.h
* IOutputItem.h
*
* Created on: Aug 7, 2018
* Author: rhetenor
@@ -14,9 +14,9 @@ namespace FlippR_Driver
namespace output
{
class ICabinetItem
class IOutputItem
{
virtual ~ICabinetItem();
virtual ~IOutputItem();
virtual bool isActivated() = 0;
virtual bool activate() = 0;
virtual bool deactivate() = 0;

View File

@@ -8,12 +8,14 @@
#ifndef _SRC_OUTPUT_ISOLENOID_H_
#define _SRC_OUTPUT_ISOLENOID_H_
#include "IOutputItem.h"
namespace FlippR_Driver
{
namespace output
{
class ISolenoid
class ISolenoid : public IOutputItem
{
};

View File

@@ -8,12 +8,13 @@
#ifndef _SRC_OUTPUT_ISOUND_H_
#define _SRC_OUTPUT_ISOUND_H_
#include "IOutputItem.h"
namespace FlippR_Driver
{
namespace output
{
class ISound
class ISound : public IOutputItem
{
public:
ISound();

View File

@@ -8,14 +8,14 @@
#ifndef _SRC_OUTPUT_LAMP_H_
#define _SRC_OUTPUT_LAMP_H_
#include "CabinetItem.h"
#include "OutputItem.h"
namespace FlippR_Driver
{
namespace output
{
class Lamp : public CabinetItem
class Lamp : public OutputItem
{
public:
Lamp();

View File

@@ -15,13 +15,13 @@ namespace FlippR_Driver
namespace output
{
OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<IOutputItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
: cabinet_items(cabinet_items), displays(displays), sounds(sounds)
{}
std::vector<std::shared_ptr<ICabinetItem>> OutputDriver::get_cabinet_items()
std::vector<std::shared_ptr<IOutputItem>> OutputDriver::get_cabinet_items()
{
std::vector<std::shared_ptr<ICabinetItem>> cabinet_items;
std::vector<std::shared_ptr<IOutputItem>> cabinet_items;
boost::copy(this->cabinet_items | boost::adaptors::map_values, std::back_inserter(cabinet_items));
@@ -46,7 +46,7 @@ std::vector<std::shared_ptr<IDisplay>> OutputDriver::get_displays()
return displays;
}
std::shared_ptr<ICabinetItem> OutputDriver::get_cabinet_item(std::string name)
std::shared_ptr<IOutputItem> OutputDriver::get_cabinet_item(std::string name)
{
return this->cabinet_items.find(name)->second;
}

View File

@@ -13,7 +13,7 @@
#include <map>
#include <memory>
#include "ICabinetItem.h"
#include "IOutputItem.h"
#include "IDisplay.h"
#include "ISound.h"
@@ -25,20 +25,20 @@ namespace output
class OutputDriver : public IOutputDriver
{
public:
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
OutputDriver(std::map<std::string, std::shared_ptr<IOutputItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
virtual ~OutputDriver() = default;
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
std::vector<std::shared_ptr<IOutputItem>> get_cabinet_items();
std::vector<std::shared_ptr<ISound>> get_sounds();
std::vector<std::shared_ptr<IDisplay>> get_displays();
std::shared_ptr<ICabinetItem> get_cabinet_item(std::string name);
std::shared_ptr<IOutputItem> get_cabinet_item(std::string name);
std::shared_ptr<ISound> get_sound(std::string name);
std::shared_ptr<IDisplay> get_display(char number);
private:
std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items;
std::map<std::string, std::shared_ptr<IOutputItem>> cabinet_items;
std::map<char, std::shared_ptr<IDisplay>> displays;
std::map<std::string, std::shared_ptr<ISound>> sounds;
};

View File

@@ -0,0 +1,45 @@
/*
* OutputItem.h
*
* Created on: Aug 2, 2018
* Author: rhetenor
*/
#ifndef _SRC_OUTPUT_CABINETITEM_H_
#define _SRC_OUTPUT_CABINETITEM_H_
#include "IOutputItem.h"
#include "utility/IOutputGPIOInterface.h"
#include <memory>
#include <string>
namespace FlippR_Driver
{
namespace output
{
using namespace utility;
class OutputItem : public IOutputItem
{
public:
OutputItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~OutputItem();
bool isActivated();
public:
int address;
int priority;
std::string name;
protected:
bool activated;
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
};
} /* namespace output */
}
#endif

View File

@@ -8,14 +8,14 @@
#ifndef _SRC_OUTPUT_SOLENOID_H_
#define _SRC_OUTPUT_SOLENOID_H_
#include "CabinetItem.h"
#include "ISolenoid.h.h"
namespace FlippR_Driver
{
namespace output
{
class Solenoid : public CabinetItem
class Solenoid : public ISolenoid
{
public:
Solenoid();

View File

@@ -9,6 +9,9 @@
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
#include "GPIOInterface.h"
#include "output/Event.h"
#include <mcp23017.h>
namespace FlippR_Driver
@@ -19,13 +22,22 @@ class OutputGPIOInterface : GPIOInterface
{
public:
void activate_cabinet_item(CabinetItem &item);
OutputGPIOInterface();
~OutputGPIOInterface() = default;
void queue_output_item(shared_ptr<OutputItem> item);
void write_display(Display &display);
private:
void
void cycle_output_items();
void activate_sounds(OutputItem &item);
void activate_cabinet_item(OutputItem &item);
private:
IBlockingQueue <CabinetItem> event_queue;
IBlockingQueue <output::Event> event_queue;
};
}

View File

@@ -12,8 +12,6 @@
#define LOGGER_FILE "driver.log"
#define DRIVER_CONF_FILE "/var/log/flippr_driver.conf"
#define HIGHEST_LOG_VERBOSITY 10

View File

@@ -17,7 +17,7 @@
// testing purposes
#define private public
#include "output/CabinetItem.h"
#include "output/OutputItem.h"
using namespace output;
using namespace fakeit;