44 std::vector<Light> result;
48 if((type == LightGroup::None) || (group == type)) {
49 auto it_light =
_lights.find(lights_state.first);
50 result.push_back(it_light->second);
58 for(
Light& light : lights) {
64 for(
Light& light : lights) {
70 size_t lights_to_update = (lights.size() < active.size()) ? lights.size() : active.size();
71 for(
size_t i = 0; i < lights_to_update; i++) {
77 std::vector<bool> result;
78 for(
Light& light : lights) {
79 result.push_back(
IsActive(light._id) );
85 std::vector<Light> result;
90 if( (type == LightGroup::None || group == type) && state.
_active ) {
91 auto it_light =
_lights.find(lights_state.first);
92 result.push_back(it_light->second);
100 std::vector<Light> result;
105 if( (type == LightGroup::None || group == type) && !state.
_active ) {
106 auto it_light =
_lights.find(lights_state.first);
107 result.push_back(it_light->second);
115 for(
Light& light : lights) {
121 size_t lights_to_update = (lights.size() < colors.size()) ? lights.size() : colors.size();
122 for(
size_t i = 0; i < lights_to_update; i++) {
128 std::vector<Color> result;
129 for(
Light& light : lights) {
130 result.push_back(
GetColor(light._id) );
136 for(
Light& light : lights) {
142 size_t lights_to_update = (lights.size() < intensities.size()) ? lights.size() : intensities.size();
143 for(
size_t i = 0; i < lights_to_update; i++) {
149 std::vector<float> result;
150 for(
Light& light : lights) {
157 for(
Light& light : lights) {
163 size_t lights_to_update = (lights.size() < groups.size()) ? lights.size() : groups.size();
164 for(
size_t i = 0; i < lights_to_update; i++) {
170 std::vector<LightGroup> result;
171 for(
Light& light : lights) {
178 for(
Light& light : lights) {
184 size_t lights_to_update = (lights.size() < states.size()) ? lights.size() : states.size();
185 for(
size_t i = 0; i < lights_to_update; i++) {
191 std::vector<LightState> result;
192 for(
Light& light : lights) {
219 std::lock_guard<std::mutex> lock(
_mutex);
227 std::lock_guard<std::mutex> lock(
_mutex);
235 std::lock_guard<std::mutex> lock(
_mutex);
243 std::lock_guard<std::mutex> lock(
_mutex);
257 std::lock_guard<std::mutex> lock(
_mutex);
274 std::lock_guard<std::mutex> lock(
_mutex);
276 std::vector<rpc::LightState> lights_snapshot =
_episode.Lock()->QueryLightsStateToServer();
281 for(
const auto& it : lights_snapshot) {
284 Color(it._color.r, it._color.g, it._color.b),
297 std::lock_guard<std::mutex> lock(
_mutex);
300 std::vector<rpc::LightState> message;
302 auto it_light =
_lights.find(it.first);
303 if(it_light !=
_lights.end()) {
305 it_light->second.GetLocation(),
306 it.second._intensity,
308 rpc::Color(it.second._color.r, it.second._color.g, it.second._color.b),
311 state.
_id = it.first;
313 message.push_back(state);
316 _episode.Lock()->UpdateServerLightsState(message, discard_client);
324 std::lock_guard<std::mutex> lock(
_mutex);
331 _episode.Lock()->UpdateDayNightCycle(active);
std::vector< Light > GetTurnedOffLights(LightGroup type=LightGroup::None) const
size_t _on_tick_register_id
size_t _on_light_update_register_id
std::vector< Light > GetTurnedOnLights(LightGroup type=LightGroup::None) const
std::vector< LightGroup > GetLightGroup(std::vector< Light > &lights) const
void SetIntensity(std::vector< Light > &lights, float intensity)
std::vector< bool > IsActive(std::vector< Light > &lights) const
std::vector< Color > GetColor(std::vector< Light > &lights) const
const LightState & RetrieveLightState(LightId id) const
void SetLightState(std::vector< Light > &lights, LightState state)
std::unordered_map< LightId, LightState > _lights_changes
void TurnOff(std::vector< Light > &lights)
void SetLightStateNoLock(LightId id, const LightState &new_state)
detail::WeakEpisodeProxy _episode
void SetColor(std::vector< Light > &lights, Color color)
void QueryLightsStateToServer()
void TurnOn(std::vector< Light > &lights)
std::vector< float > GetIntensity(std::vector< Light > &lights) const
void SetDayNightCycle(const bool active)
std::unordered_map< LightId, LightState > _lights_state
void SetLightGroup(std::vector< Light > &lights, LightGroup group)
void SetEpisode(detail::WeakEpisodeProxy episode)
void SetActive(std::vector< Light > &lights, std::vector< bool > &active)
std::unordered_map< LightId, Light > _lights
void UpdateServerLightsState(bool discard_client=false)
std::vector< LightState > GetLightState(std::vector< Light > &lights) const
std::vector< Light > GetAllLights(LightGroup type=LightGroup::None) const
EpisodeProxyImpl< EpisodeProxyPointerType::Weak > WeakEpisodeProxy
This file contains definitions of common data structures used in traffic manager.
static void log_warning(Args &&... args)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...