private static void SaveTimedTrafficLight(ushort i, Configuration configuration)
        {
            try {
                TrafficLightSimulation sim = TrafficLightSimulation.GetNodeSimulation(i);
                if (sim == null || !sim.IsTimedLight())
                {
                    return;
                }

                Log._Debug($"Going to save timed light at node {i}.");

                var timedNode = sim.TimedLight;
                timedNode.handleNewSegments();

                Configuration.TimedTrafficLights cnfTimedLights = new Configuration.TimedTrafficLights();
                configuration.TimedLights.Add(cnfTimedLights);

                cnfTimedLights.nodeId     = timedNode.NodeId;
                cnfTimedLights.nodeGroup  = timedNode.NodeGroup;
                cnfTimedLights.started    = timedNode.IsStarted();
                cnfTimedLights.timedSteps = new List <Configuration.TimedTrafficLightsStep>();

                for (var j = 0; j < timedNode.NumSteps(); j++)
                {
                    Log._Debug($"Saving timed light step {j} at node {i}.");
                    TimedTrafficLightsStep timedStep = timedNode.Steps[j];
                    Configuration.TimedTrafficLightsStep cnfTimedStep = new Configuration.TimedTrafficLightsStep();
                    cnfTimedLights.timedSteps.Add(cnfTimedStep);

                    cnfTimedStep.minTime         = timedStep.minTime;
                    cnfTimedStep.maxTime         = timedStep.maxTime;
                    cnfTimedStep.waitFlowBalance = timedStep.waitFlowBalance;
                    cnfTimedStep.segmentLights   = new Dictionary <ushort, Configuration.CustomSegmentLights>();
                    foreach (KeyValuePair <ushort, CustomSegmentLights> e in timedStep.segmentLights)
                    {
                        Log._Debug($"Saving timed light step {j}, segment {e.Key} at node {i}.");

                        CustomSegmentLights segLights = e.Value;
                        Configuration.CustomSegmentLights cnfSegLights = new Configuration.CustomSegmentLights();
                        cnfTimedStep.segmentLights.Add(e.Key, cnfSegLights);

                        cnfSegLights.nodeId               = segLights.NodeId;
                        cnfSegLights.segmentId            = segLights.SegmentId;
                        cnfSegLights.customLights         = new Dictionary <ExtVehicleType, Configuration.CustomSegmentLight>();
                        cnfSegLights.pedestrianLightState = segLights.PedestrianLightState;
                        cnfSegLights.manualPedestrianMode = segLights.ManualPedestrianMode;

                        Log._Debug($"Saving pedestrian light @ seg. {e.Key}, step {j}: {cnfSegLights.pedestrianLightState} {cnfSegLights.manualPedestrianMode}");

                        foreach (KeyValuePair <Traffic.ExtVehicleType, CustomSegmentLight> e2 in segLights.CustomLights)
                        {
                            Log._Debug($"Saving timed light step {j}, segment {e.Key}, vehicleType {e2.Key} at node {i}.");

                            CustomSegmentLight segLight = e2.Value;
                            Configuration.CustomSegmentLight cnfSegLight = new Configuration.CustomSegmentLight();
                            cnfSegLights.customLights.Add(e2.Key, cnfSegLight);

                            cnfSegLight.nodeId      = segLight.NodeId;
                            cnfSegLight.segmentId   = segLight.SegmentId;
                            cnfSegLight.currentMode = (int)segLight.CurrentMode;
                            cnfSegLight.leftLight   = segLight.LightLeft;
                            cnfSegLight.mainLight   = segLight.LightMain;
                            cnfSegLight.rightLight  = segLight.LightRight;
                        }
                    }
                }
            } catch (Exception e) {
                Log.Error($"Error adding TimedTrafficLights to save {e.Message}");
            }
        }
		private static void SaveTimedTrafficLight(ushort i, Configuration configuration) {
			try {
				TrafficLightSimulation sim = TrafficLightSimulation.GetNodeSimulation(i);
				if (sim == null || !sim.IsTimedLight())
					return;

				var timedNode = sim.TimedLight;
				timedNode.handleNewSegments();

				Configuration.TimedTrafficLights cnfTimedLights = new Configuration.TimedTrafficLights();
				configuration.TimedLights.Add(cnfTimedLights);

				cnfTimedLights.nodeId = timedNode.NodeId;
				cnfTimedLights.nodeGroup = timedNode.NodeGroup;
				cnfTimedLights.started = timedNode.IsStarted();
				cnfTimedLights.timedSteps = new List<Configuration.TimedTrafficLightsStep>();

				for (var j = 0; j < timedNode.NumSteps(); j++) {
					TimedTrafficLightsStep timedStep = timedNode.Steps[j];
					Configuration.TimedTrafficLightsStep cnfTimedStep = new Configuration.TimedTrafficLightsStep();
					cnfTimedLights.timedSteps.Add(cnfTimedStep);

					cnfTimedStep.minTime = timedStep.minTime;
					cnfTimedStep.maxTime = timedStep.maxTime;
					cnfTimedStep.waitFlowBalance = timedStep.waitFlowBalance;
					cnfTimedStep.segmentLights = new Dictionary<ushort, Configuration.CustomSegmentLights>();
					foreach (KeyValuePair<ushort, CustomSegmentLights> e in timedStep.segmentLights) {
						CustomSegmentLights segLights = e.Value;
						Configuration.CustomSegmentLights cnfSegLights = new Configuration.CustomSegmentLights();
						cnfTimedStep.segmentLights.Add(e.Key, cnfSegLights);

						cnfSegLights.nodeId = segLights.NodeId;
						cnfSegLights.segmentId = segLights.SegmentId;
						cnfSegLights.customLights = new Dictionary<ExtVehicleType, Configuration.CustomSegmentLight>();
						cnfSegLights.pedestrianLightState = segLights.PedestrianLightState;
						cnfSegLights.manualPedestrianMode = segLights.ManualPedestrianMode;

						Log._Debug($"Saving pedestrian light @ seg. {e.Key}, step {j}: {cnfSegLights.pedestrianLightState} {cnfSegLights.manualPedestrianMode}");

						foreach (KeyValuePair<Traffic.ExtVehicleType, CustomSegmentLight> e2 in segLights.CustomLights) {
							CustomSegmentLight segLight = e2.Value;
							Configuration.CustomSegmentLight cnfSegLight = new Configuration.CustomSegmentLight();
							cnfSegLights.customLights.Add(e2.Key, cnfSegLight);

							cnfSegLight.nodeId = segLight.NodeId;
							cnfSegLight.segmentId = segLight.SegmentId;
							cnfSegLight.currentMode = (int)segLight.CurrentMode;
							cnfSegLight.leftLight = segLight.LightLeft;
							cnfSegLight.mainLight = segLight.LightMain;
							cnfSegLight.rightLight = segLight.LightRight;
						}
					}
				}
			} catch (Exception e) {
				Log.Error($"Error adding TimedTrafficLights to save {e.Message}");
			}
		}