private void SetStatus() { Status = AnalysisStatusType.Success; foreach (var hashtable in AnalysisEvents) { if (hashtable.ContainsValue(AnalysisStatusType.Failed)) { Status = AnalysisStatusType.Failed; } // Error always overwrites test case fail if (hashtable.ContainsValue(AnalysisStatusType.Error)) { Status = AnalysisStatusType.Error; break; } } // cycle every status to convert to string for json foreach (var hashtable in AnalysisEvents) { if (hashtable.ContainsKey("Status")) { hashtable["Status"] = hashtable["Status"].ToString(); } } }
/* * private void Awake() * { * SerializerSettings = new JsonSerializerSettings * { * ReferenceLoopHandling = ReferenceLoopHandling.Ignore, * Formatting = Formatting.Indented * }; * * PersistantPath = Application.persistentDataPath; * AnalysisPath = Path.Combine(PersistantPath, "Analysis"); * if (!Directory.Exists(AnalysisPath)) * Directory.CreateDirectory(AnalysisPath); * } * * private void Start() * { * if (!SimulatorManager.Instance.IsAPI) * { * AnalysisInit(); * } * } * * private void OnDestroy() * { * AnalysisSave(); * } * * private void FixedUpdate() * { * if (SimConfig == null)// || SimConfig.CurrentTestId == null) * { * return; // Development mode or generate report false * } * * foreach (var sensor in Sensors) * { * sensor.OnAnalyze(); * } * } */ public void AnalysisInit() { Sensors.Clear(); AnalysisEvents.Clear(); CollisionTotals.Ego = 0; CollisionTotals.Npc = 0; CollisionTotals.Ped = 0; Status = AnalysisStatusType.InProgress; AnalysisStart = DateTime.Now; SimConfig = Loader.Instance?.SimConfig; if (SimConfig == null) // || SimConfig.CurrentTestId == null) { return; // Development mode or generate report false } if (SimulatorManager.Instance.IsAPI) { SimConfig.Agents = SimulatorManager.Instance.AgentManager.ActiveAgents.ToArray(); } foreach (var agent in SimConfig.Agents) { Array.ForEach(agent.AgentGO.GetComponentsInChildren <SensorBase>(), sensorBase => { Sensors.Add(sensorBase); }); } }
public void AnalysisInit() { if (Init) { return; } SimConfig = Loader.Instance?.SimConfig; Console.WriteLine("[ANMGR] Initializing with TestReportId:{0}", (SimConfig?.TestReportId is null) ? "<null>" : SimConfig.TestReportId); Sensors.Clear(); AnalysisEvents.Clear(); CollisionTotals.Ego = 0; CollisionTotals.Npc = 0; CollisionTotals.Ped = 0; ReceivedResponses = 0; ClientsSensorsData.Clear(); Status = AnalysisStatusType.InProgress; AnalysisStart = DateTime.Now; if (SimConfig == null) // || !SimConfig.CurrentTestId.HasValue) // This will need to taken from WISE or sent to simconfig, then read { return; // Development mode or generate report false } if (SimulatorManager.Instance.IsAPI) { SimConfig.Agents = SimulatorManager.Instance.AgentManager.ActiveAgents.ToArray(); } foreach (var agent in SimConfig.Agents) { if (agent.AgentGO == null) { continue; } Array.ForEach(agent.AgentGO.GetComponentsInChildren <SensorBase>(), sensorBase => { Sensors.Add(sensorBase); var sensorType = sensorBase.GetType().GetCustomAttribute <SensorType>(); if (sensorType.Name == "Video Recording") { sensorBase.GetType().GetMethod("StartRecording").Invoke(sensorBase, new object[] { null }); } }); } Init = true; }
private void CheckStatus() { Status = AnalysisStatusType.Success; foreach (var hashtable in AnalysisEvents) { if (hashtable.ContainsValue(AnalysisStatusType.Failed)) { Status = AnalysisStatusType.Failed; } if (hashtable.ContainsValue(AnalysisStatusType.Error)) { Status = AnalysisStatusType.Error; // Error always overwrites test case fail } if (hashtable.ContainsKey("Status")) { hashtable["Status"] = hashtable["Status"].ToString(); } } }