/* * SoundFactory.cpp * * Created on: December 28, 2019 * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert */ #include #include "SoundFactory.h" namespace flippR_driver { namespace output { SoundFactory::SoundFactory(nlohmann::json &object, std::shared_ptr pin_controller) : Factory{object, pin_controller}, deactivation_time{0} { if (object.find(config_path::deactivation_time) != object.end()) { this->deactivation_time = object.at(config_path::deactivation_time).get(); } } std::map> SoundFactory::getItemMap() { auto sounds = this->object.at(config_path::sound_path); std::map> sound_map; for (auto sound : sounds) { auto name = sound.at(config_path::item_name).get(); auto address = sound.at(config_path::item_address).get(); auto extender = sound.at(config_path::item_extender).get(); auto pin_base = this->get_extender_pin_base(extender); auto id = sound.at(config_path::item_identifier).get(); std::chrono::milliseconds deactivation_time_chrono{this->deactivation_time}; if (object.find(config_path::deactivation_time) != object.end()) { deactivation_time_chrono = std::chrono::milliseconds{object.at(config_path::deactivation_time).get()}; } auto sound_item = std::make_shared(std::static_pointer_cast(this->pin_controller), address, pin_base, name, deactivation_time_chrono, id); sound_map.emplace(name, sound_item); } return sound_map; } } }