public static string GetCustomNameForSimulatorPosition(SimulatorPositions position) { var result = simulatorAssignments.Where(a => a.Position == position); if (result.FirstOrDefault() != null) { return(result.FirstOrDefault().CustomAssignmentName.ToString()); } return("Kein Simulator zugewiesen"); }
/// <summary> /// Returns the corresponding simulator object for the specified assignment, position and mattress type. The last two parameters can be ommited. /// Special case: if the required assignment is "Simulation" and no object can be found, the assignment "Druckmessung_und_Simulation" is also checked. /// </summary> /// <returns>The correct simulator object or null if no simulator was specified for the assignment.</returns> public static CBaseSimulator GetSimulatorObject(SimulatorAssignments assignment, SimulatorPositions position = (SimulatorPositions)(-1), SimulationMattresses mattress = (SimulationMattresses)(-1)) //optional parameters { //get the id of the simulator that is assigned to the specified assignment string id = ""; SimulatorAssignment existingAssignment = null; QueryStart: var result = simulatorAssignments.Where(a => a.Assignment == assignment); if ((int)position > -1) { result = result.Where(r => r.Position == position); } if ((int)mattress > -1) { result = result.Where(r => r.Mattress == mattress); } existingAssignment = result.FirstOrDefault(); if (existingAssignment != null) { id = existingAssignment.SimulatorId; } else if (assignment == SimulatorAssignments.Simulation) { assignment = SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum; //re-attempt the query with a slightly different assignment that includes the "Simulation" assignment goto QueryStart; } else if (assignment == SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum) { assignment = SimulatorAssignments.Druckmessung_und_Simulation_NaturLatex; //re-attempt the query with a slightly different assignment that also includes the "Simulation" assignment goto QueryStart; } if (string.IsNullOrEmpty(id)) //no simulator available { return(null); } return(SimulatorController.MultiSimulatorMode.SimulatorControl.Instance.GetSimulatorById(id)); }