public MainForm() { InitializeComponent(); // Read in data on the materials string materialFileName = Path.Combine(Resources.DataDir, "Materials.xml"); string materialSchema = Path.Combine(Resources.SchemaDir, "Materials.xsd"); MaterialsCollection materials = new MaterialsCollection(materialFileName, materialSchema); for (int i = 0; i < materials.Count; i++) { materialsListBox.Items.Add(materials[i]); } materialsListBox.SelectedIndex = 0; // Read in data on the coolers string coolerFileName = Path.Combine(Resources.DataDir, "Coolers.xml"); string coolerSchema = Path.Combine(Resources.SchemaDir, "Coolers.xsd"); CoolerCollection coolers = new CoolerCollection(coolerFileName, coolerSchema); for (int i = 0; i < coolers.Count; i++) { coolersListBox.Items.Add(coolers[i]); } coolersListBox.SelectedIndex = 0; // Ready to go - enable user to pull the trigger simulateButton.Enabled = true; }
private void initCoolers() { // Get the list of existing coolers from our XML data file string coolersDataFile = Path.Combine(dataDir, "Coolers.xml"); string coolersSchemaFile = Path.Combine(schemaDir, "Coolers.xsd"); CoolerCollection coolers = new CoolerCollection(coolersDataFile, coolersSchemaFile); // Persist the list in the database ISession session = null; ITransaction transaction = null; try { session = factory.OpenSession(); transaction = session.BeginTransaction(); foreach (Cooler c in coolers) { P_Cooler p_cool = new P_Cooler(); p_cool.Name = c.Name; session.Save(p_cool); } transaction.Commit(); } catch { if (transaction != null) { transaction.Rollback(); } throw; } finally { if (session != null) { session.Close(); } } }
private Cooler[] findCoolers() { Cooler[] answer; if (direct) { string coolerFile = Path.Combine(dataDir, "Coolers.xml"); string coolerSchema = Path.Combine(schemaDir, "Coolers.xsd"); CoolerCollection coolers = new CoolerCollection(coolerFile, coolerSchema); answer = new Cooler[coolers.Count]; for (int i = 0; i < coolers.Count; i++) { answer[i] = (Cooler)coolers[i]; } } else { DesktopClient.CoolIt_Service.Cooler[] rawCoolers = webService.GetCoolers(); answer = new Cooler[rawCoolers.Length]; InputPowerCalculator calc = getInputPowerCalc(); for (int i = 0; i < rawCoolers.Length; i++) { DesktopClient.CoolIt_Service.Cooler raw = rawCoolers[i]; List <DataPoint> data = new List <DataPoint>(); for (int j = 0; j < raw.CPM.Length; j++) { DesktopClient.CoolIt_Service.DataPoint rawPoint = raw.CPM[j]; DataPoint point = new DataPoint(rawPoint.temp, rawPoint.data); data.Add(point); } answer[i] = new Cooler(raw.Name, raw.id, data, raw.price, raw.priceUnit, raw.currencyUnit); answer[i].InputPowerCalculator = calc; } } return(answer); }
/// <summary> /// Read the data files and set up the MATLAB component. /// Would like to do this in a static constructor, but we don't have access to a /// HttpRequest object at that time, so it's not clear how to map the paths. /// </summary> private void init() { HttpRequest request = this.Context.Request; string dataDir = request.MapPath("Data"); string schemaDir = request.MapPath("Schema"); _logger.Debug("Loading SpecificPower.xml"); string specificPowerDataFile = Path.Combine(dataDir, "SpecificPower.xml"); string specificPowerSchemaFile = Path.Combine(schemaDir, "SpecificPower.xsd"); specificPowerData = new SpecificPowerDataManager(specificPowerDataFile, specificPowerSchemaFile); inputPowerCalc = new InputPowerCalculator(specificPowerData.Data); _logger.Debug("Loading Coolers.xml"); string coolerDataFile = Path.Combine(dataDir, "Coolers.xml"); string coolerSchemaFile = Path.Combine(schemaDir, "Coolers.xsd"); coolers = new CoolerCollection(coolerDataFile, coolerSchemaFile); foreach (Cooler c in coolers) { c.InputPowerCalculator = inputPowerCalc; } _logger.DebugFormat("{0} coolers loaded", coolers.Count); _logger.Debug("Loading Materials.xml"); string materialsDataFile = Path.Combine(dataDir, "Materials.xml"); string materialsSchemaFile = Path.Combine(schemaDir, "Materials.xsd"); materials = new MaterialsCollection(materialsDataFile, materialsSchemaFile); _logger.DebugFormat("{0} materials loaded", materials.Count); _logger.Debug("Loading Problems.xml"); string problemsDataFile = Path.Combine(dataDir, "Problems.xml"); string problemsSchemaFile = Path.Combine(schemaDir, "Problems.xsd"); problems = new ProblemCollection(problemsDataFile, problemsSchemaFile); _logger.DebugFormat("{0} problems loaded", problems.Count); _logger.Debug("Loading MathGates.xml"); string mathGateDataFile = Path.Combine(dataDir, "MathGates.xml"); string mathGateSchemaFile = Path.Combine(schemaDir, "MathGates.xsd"); mathGates = new MathGateCollection(mathGateDataFile, mathGateSchemaFile); _logger.DebugFormat("{0} math gates loaded", mathGates.Count); _logger.Debug("Initializing Optimizer"); optimizer = new Optimizer(coolers, materials); _logger.Debug("Initializaing SolutionChecker"); solutionChecker = new SolutionChecker(problems); _logger.Debug("Initializaing SteadyStateSimulator"); sim = new SteadyStateSimulator(); _logger.Debug("Initializing API"); api = new API(); }
public Cooler[] GetCoolers() { CoolerCollection coolers = findCoolers(); Cooler[] answer = new Cooler[coolers.Count]; for (int i = 0; i < coolers.Count; i++) { answer[i] = (Cooler)coolers[i]; } return(answer); }
public double SimulatePF(double length, double crossSection, string materialName, string coolerName, double powerFactor) { try { CoolerCollection coolers = findCoolers(); Cooler cooler = (Cooler)coolers[coolerName]; MaterialsCollection materials = findMaterials(); Material material = (Material)materials[materialName]; SteadyStateSimulator ssSim = new SteadyStateSimulator(); return(ssSim.simulate(length, crossSection, material, cooler, powerFactor)); } catch (Exception ex) { throw new SoapException(ex.ToString(), new System.Xml.XmlQualifiedName("")); } }