Beispiel #1
0
 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);
 }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
        private InputPowerCalculator getInputPowerCalc()
        {
            DesktopClient.CoolIt_Service.DataPoint[] specificPowerData = webService.GetSpecificPowerData();
            DataPoint[] data = new DataPoint[specificPowerData.Length];
            for (int i = 0; i < specificPowerData.Length; i++)
            {
                data[i] = new DataPoint(specificPowerData[i].temp, specificPowerData[i].data);
            }
            InputPowerCalculator calc = new InputPowerCalculator(data);

            return(calc);
        }