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

View File

@@ -5,8 +5,11 @@
#include "DistributingEvent.h"
FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name,
std::chrono::milliseconds bounce_time, std::shared_ptr<IEventNotifier> event_notifier)
: Event(address, priority, name), bounce_time(bounce_time), event_notifier(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),
activation_state(NOT_ACTIVATED)
{}
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::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");
for (auto &json_event : event_array)
{
try
{
std::string name = json_event.at("name");
char address = json_event.at("address").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::chrono::milliseconds(deactivation_time), event_notifier));
std::chrono::milliseconds(bounce_time), event_notifier));
events.push_back(event_ptr);
name_event_map.emplace(name, event_ptr);
@@ -76,4 +82,4 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
}
}
}
}