some changes at events

This commit is contained in:
Neeflix
2018-09-27 23:08:56 +02:00
parent f1315cec88
commit cf466ba3d6
3 changed files with 53 additions and 79 deletions

View File

@@ -1,227 +1,192 @@
{ {
"global_bounce_time" : 10,
"input_matrix" : "input_matrix" :
[ [
{ {
"name" : "Out hole", "name" : "Out hole",
"address" : 16, "address" : 16,
"priority" : 1, "priority" : 1,
"deactivation_time" : 50 "bounce_time" : 10
}, },
{ {
"name" : "Left outer exit canal", "name" : "Left outer exit canal",
"address" : 17, "address" : 17,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Inner left canal", "name" : "Inner left canal",
"address" : 18, "address" : 18,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Left flap contacts", "name" : "Left flap contacts",
"address" : 19, "address" : 19,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Right flap contacts", "name" : "Right flap contacts",
"address" : 20, "address" : 20,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Right inner canal", "name" : "Right inner canal",
"address" : 21, "address" : 21,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Right central exit canal", "name" : "Right central exit canal",
"address" : 22, "address" : 22,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Right kicker contact", "name" : "Right kicker contact",
"address" : 23, "address" : 23,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Contacts", "name" : "Contacts",
"address" : 24, "address" : 24,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "1st moving target bottom left bank", "name" : "1st moving target bottom left bank",
"address" : 25, "address" : 25,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "2nd moving target bottom left bank", "name" : "2nd moving target bottom left bank",
"address" : 26, "address" : 26,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "3rd moving target bottom left bank", "name" : "3rd moving target bottom left bank",
"address" : 27, "address" : 27,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "4th moving target bottom left bank", "name" : "4th moving target bottom left bank",
"address" : 28, "address" : 28,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Fixed special red target", "name" : "Fixed special red target",
"address" : 29, "address" : 29,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Fixed special orange target", "name" : "Fixed special orange target",
"address" : 30, "address" : 30,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "1st moving target bottom right bank", "name" : "1st moving target bottom right bank",
"address" : 31, "address" : 31,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "2nd moving target bottom right bank", "name" : "2nd moving target bottom right bank",
"address" : 32, "address" : 32,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "3rd moving target bottom right bank", "name" : "3rd moving target bottom right bank",
"address" : 33, "address" : 33,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Spinning target", "name" : "Spinning target",
"address" : 34, "address" : 34,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "1st button", "name" : "1st button",
"address" : 35, "address" : 35,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "2nd button", "name" : "2nd button",
"address" : 36, "address" : 36,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "3rd button", "name" : "3rd button",
"address" : 37, "address" : 37,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "4th button", "name" : "4th button",
"address" : 38, "address" : 38,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "5th button", "name" : "5th button",
"address" : 39, "address" : 39,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "1st moving target top central bank", "name" : "1st moving target top central bank",
"address" : 40, "address" : 40,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "2nd moving target top central bank", "name" : "2nd moving target top central bank",
"address" : 41, "address" : 41,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "3rd moving target top central bank", "name" : "3rd moving target top central bank",
"address" : 42, "address" : 42,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "4th moving target top central bank", "name" : "4th moving target top central bank",
"address" : 43, "address" : 43,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "5th moving target top central bank", "name" : "5th moving target top central bank",
"address" : 44, "address" : 44,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "1st fixed target", "name" : "1st fixed target",
"address" : 45, "address" : 45,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "2nd fixed target", "name" : "2nd fixed target",
"address" : 46, "address" : 46,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Top left pop contact", "name" : "Top left pop contact",
"address" : 47, "address" : 47,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Bottom right pop contact", "name" : "Bottom right pop contact",
"address" : 48, "address" : 48,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "5th fixed target", "name" : "5th fixed target",
"address" : 49, "address" : 49,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "4th fixed target", "name" : "4th fixed target",
"address" : 50, "address" : 50,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "3rd fixed target", "name" : "3rd fixed target",
"address" : 51, "address" : 51,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
}, },
{ {
"name" : "Rising ball contact", "name" : "Rising ball contact",
"address" : 52, "address" : 52,
"priority" : 2, "priority" : 2
"deactivation_time" : 50
} }
] ]
} }

View File

@@ -5,8 +5,11 @@
#include "DistributingEvent.h" #include "DistributingEvent.h"
FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name, FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name,
std::chrono::milliseconds bounce_time, std::shared_ptr<IEventNotifier> event_notifier) std::chrono::milliseconds bounce_time, std::shared_ptr<IEventNotifier> event_notifier):
: Event(address, priority, name), bounce_time(bounce_time), event_notifier(event_notifier) Event(address, priority, name),
bounce_time(bounce_time),
event_notifier(event_notifier),
activation_state(NOT_ACTIVATED)
{} {}
void FlippR_Driver::Input::DistributingEvent::distribute() void FlippR_Driver::Input::DistributingEvent::distribute()

View File

@@ -50,19 +50,25 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
std::map<std::string, std::shared_ptr<Event>>& name_event_map, std::map<std::string, std::shared_ptr<Event>>& name_event_map,
std::shared_ptr<IEventNotifier> event_notifier) std::shared_ptr<IEventNotifier> event_notifier)
{ {
int global_bounce_time = matrix_config.at("global_bounce_time").get<json::number_integer_t>();
auto& event_array = matrix_config.at("input_matrix"); auto& event_array = matrix_config.at("input_matrix");
for (auto &json_event : event_array) for (auto &json_event : event_array)
{ {
try try
{ {
std::string name = json_event.at("name"); std::string name = json_event.at("name");
char address = json_event.at("address").get<json::number_integer_t>(); char address = json_event.at("address").get<json::number_integer_t>();
int priority = json_event.at("priority").get<json::number_integer_t>(); int priority = json_event.at("priority").get<json::number_integer_t>();
int deactivation_time = json_event.at("deactivation_time").get<json::number_integer_t>(); int bounce_time = global_bounce_time;
auto it_bounce_time = json_event.find("bounce_time");
if (it_bounce_time != json_event.end())
{
bounce_time = it_bounce_time->get<json::number_integer_t>();
}
std::shared_ptr<DistributingEvent> event_ptr(new DistributingEvent(address, priority, name, std::shared_ptr<DistributingEvent> event_ptr(new DistributingEvent(address, priority, name,
std::chrono::milliseconds(deactivation_time), event_notifier)); std::chrono::milliseconds(bounce_time), event_notifier));
events.push_back(event_ptr); events.push_back(event_ptr);
name_event_map.emplace(name, event_ptr); name_event_map.emplace(name, event_ptr);
@@ -76,4 +82,4 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
} }
} }
} }