/// <summary> /// Stores the "EcellObject" /// </summary> /// <param name="simulator">The "simulator"</param> /// <param name="dmm">The "DMDescriptorKeeper"</param> /// <param name="ecellObject">The stored "EcellObject"</param> /// <param name="initialCondition">The initial condition.</param> internal static void DataStored( WrappedSimulator simulator, DMDescriptorKeeper dmm, EcellObject ecellObject, Dictionary<string, double> initialCondition) { if (ecellObject.Type.Equals(Constants.xpathStepper)) { DataStored4Stepper(simulator, dmm, ecellObject); } else if (ecellObject.Type.Equals(Constants.xpathSystem)) { DataStored4System( simulator, ecellObject, initialCondition); } else if (ecellObject.Type.Equals(Constants.xpathProcess)) { DataStored4Process( simulator, dmm, ecellObject, initialCondition); } else if (ecellObject.Type.Equals(Constants.xpathVariable)) { DataStored4Variable( simulator, ecellObject, initialCondition); } // // 4 children // if (ecellObject.Children != null) { foreach (EcellObject childEcellObject in ecellObject.Children) DataStored(simulator, dmm, childEcellObject, initialCondition); } }
/// <summary> /// GetValueFromDMM /// </summary> /// <param name="dmm">DMDescriptorKeeper</param> /// <param name="type">DM type.</param> /// <param name="className">the class name,</param> /// <param name="name">the property name.</param> /// <returns></returns> private static EcellValue GetValueFromDMM(DMDescriptorKeeper dmm, string type, string className, string name) { EcellValue value = null; try { if (dmm.ContainsDescriptor(type, className)) { DMDescriptor desc = dmm.GetDMDescriptor(type, className); if (desc.ContainsProperty(name)) { PropertyDescriptor prop = desc[name]; value = new EcellValue(prop.DefaultValue); } else { value = new EcellValue(0.0); } } else { value = new EcellValue(""); } } catch(Exception e) { Trace.WriteLine(e.StackTrace); } return value; }
/// <summary> /// Stores the "EcellObject" 4 the "Stepper". /// </summary> /// <param name="simulator">The simulator</param> /// <param name="dmm">The "DynamicModuleManager"</param> /// <param name="ecellObject">The stored "Stepper"</param> internal static void DataStored4Stepper( WrappedSimulator simulator, DMDescriptorKeeper dmm, EcellObject ecellObject) { string key = Constants.xpathStepper + Constants.delimiterColon + Constants.delimiterColon + ecellObject.Key; List<EcellData> stepperEcellDataList = new List<EcellData>(); IList<string> wrappedPolymorph = null; // // Property List // try { wrappedPolymorph = simulator.GetStepperPropertyList(ecellObject.Key); } catch (Exception ex) { Trace.WriteLine(ex.StackTrace); return; } // // Sets the class name. // if (string.IsNullOrEmpty(ecellObject.Classname)) { ecellObject.Classname = simulator.GetStepperClassName(ecellObject.Key); } // // Checks the stored "EcellData" // Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>(); if (ecellObject.Value != null && ecellObject.Value.Count > 0) { foreach (EcellData storedEcellData in ecellObject.Value) { storedEcellDataDic[storedEcellData.Name] = storedEcellData; stepperEcellDataList.Add(storedEcellData); } } // // Stores the "EcellData" // foreach (string name in wrappedPolymorph) { string entityPath = key + Constants.delimiterColon + name; PropertyAttributes flag = simulator.GetStepperPropertyAttributes(ecellObject.Key, name); if (!flag.Gettable) { continue; } EcellValue value = null; try { object property = simulator.GetStepperProperty(ecellObject.Key, name); value = new EcellValue(property); } catch (Exception ex) { Trace.WriteLine(ex); value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name); } EcellData ecellData = CreateEcellData(name, value, entityPath, flag); if (storedEcellDataDic.ContainsKey(name)) { if (value.IsString && value.ToString().Equals("")) { continue; } else { stepperEcellDataList.Remove(storedEcellDataDic[name]); } } stepperEcellDataList.Add(ecellData); } ecellObject.SetEcellDatas(stepperEcellDataList); }
/// <summary> /// Stores the "EcellObject" 4 the "Process". /// </summary> /// <param name="simulator">The simulator</param> /// <param name="dmm">The "DMDescriptorKeeper"</param> /// <param name="ecellObject">The stored "Process"</param> /// <param name="initialCondition">The initial condition.</param> internal static void DataStored4Process( WrappedSimulator simulator, DMDescriptorKeeper dmm, EcellObject ecellObject, Dictionary<string, double> initialCondition) { string key = ecellObject.FullID; IList<string> wrappedPolymorph = null; try { wrappedPolymorph = simulator.GetEntityPropertyList(key); } catch (Exception ex) { Trace.WriteLine(ex); return; } // // Checks the stored "EcellData" // List<EcellData> processEcellDataList = new List<EcellData>(); Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>(); if (ecellObject.Value != null && ecellObject.Value.Count > 0) { foreach (EcellData storedEcellData in ecellObject.Value) { storedEcellDataDic[storedEcellData.Name] = storedEcellData; processEcellDataList.Add(storedEcellData); } } // // Stores the "EcellData" // foreach (string name in wrappedPolymorph) { string entityPath = Util.BuildFullPN(key, name); PropertyAttributes flag = simulator.GetEntityPropertyAttributes(entityPath); if (!flag.Gettable) { continue; } EcellValue value = null; if (name == Constants.xpathVRL) { // Won't restore the variable reference list from the simulator's corresponding // object. if (storedEcellDataDic.ContainsKey(name)) value = storedEcellDataDic[name].Value; else value = new EcellValue(new List<object>()); } else if (name == Constants.xpathActivity || name == Constants.xpathMolarActivity) { value = new EcellValue(0.0); } else { try { value = new EcellValue(simulator.GetEntityProperty(entityPath)); if (dmm.ContainsDescriptor(ecellObject.Type, ecellObject.Classname)) { DMDescriptor desc = dmm.GetDMDescriptor(ecellObject.Type, ecellObject.Classname); if (desc.ContainsProperty(name)) { PropertyDescriptor prop = desc[name]; if (prop.DefaultValue.Type == EcellValueType.List && !value.IsList) value = new EcellValue(new List<EcellValue>()); } } } catch (Exception ex) { Trace.WriteLine(ex); value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name); } } EcellData ecellData = CreateEcellData(name, value, entityPath, flag); if (ecellData.Value != null) { ecellData.Logable = ecellData.Value.IsDouble && (ecellData.Settable == false || ecellData.Saveable == false); } if (storedEcellDataDic.ContainsKey(name)) { ecellData.Logged = storedEcellDataDic[name].Logged; processEcellDataList.Remove(storedEcellDataDic[name]); } processEcellDataList.Add(ecellData); } ecellObject.SetEcellDatas(processEcellDataList); }
public void TearDown() { _unitUnderTest = null; }
public void SetUp() { string[] path = Util.GetDMDirs(); _unitUnderTest = new DMDescriptorKeeper(path); }
/// <summary> /// Constructors /// </summary> public ApplicationEnvironment() { m_dManager = new DataManager(this); m_lManager = new LogManager(this); m_gManager = new LoggerManager(this); m_pManager = new PluginManager(this); m_aManager = new ActionManager(this); m_jManager = new JobManager(this); m_rManager = new ReportManager(this); m_cManager = new CommandManager(this); m_console = new ConsoleManager(this); m_dmManager = new DMDescriptorKeeper(Util.GetDMDirs()); }