コード例 #1
0
        public void ExecuteCalcJob([NotNull] MessageFromServerToClient job, [NotNull] CalcExecutor calcExecutor, [NotNull] RequestSocket client)
        {
            var cdp = new CalcDirectoryPreparer(_mySettings, _logger, _threadId);

            cdp.Run();
            HouseCreationAndCalculationJob hcj = null;

            if (!string.IsNullOrWhiteSpace(job.HouseJobStr))
            {
                hcj = JsonConvert.DeserializeObject <HouseCreationAndCalculationJob>(job.HouseJobStr);
                if (hcj.CalcSpec == null)
                {
                    hcj.CalcSpec = JsonCalcSpecification.MakeDefaultsForProduction();
                }

                hcj.CalcSpec.OutputDirectory = "Results";
                string jsonFileName = Path.Combine(_mySettings.ClientSettings.LPGCalcDirectory, "calcjob.json");
                string correctedJob = JsonConvert.SerializeObject(hcj, Formatting.Indented);
                File.WriteAllText(jsonFileName, correctedJob);
                calcExecutor.Run(hcj);
            }
            else
            {
                _logger.Info("Client #" + _threadId + ": Got a task with an exe, not real, waiting 5s", _threadId);
                Thread.Sleep(5000);
            }

            ReportFinishedCalcJob(job, client, hcj);
        }
コード例 #2
0
        private static void SetCalcSpec([NotNull] HouseCreationAndCalculationJob hj, [NotNull] Simulator sim)
        {
            hj.CalcSpec = JsonCalcSpecification.MakeDefaultsForProduction();
            hj.CalcSpec.OutputDirectory = "Results";
            hj.CalcSpec.CalcOptions     = new List <CalcOption>();
            hj.CalcSpec.CalcOptions.Add(CalcOption.SumProfileExternalIndividualHouseholdsAsJson);
            hj.CalcSpec.DefaultForOutputFiles  = OutputFileDefault.NoFiles;
            hj.CalcSpec.ExternalTimeResolution = "00:15:00";
            hj.CalcSpec.StartDate          = new DateTime(2019, 1, 1);
            hj.CalcSpec.EndDate            = new DateTime(2019, 12, 31);
            hj.CalcSpec.TemperatureProfile = sim.TemperatureProfiles[0].GetJsonReference();
            var geoloc = sim.GeographicLocations.FindFirstByName("Chemnitz", FindMode.Partial) ?? throw new LPGException("Chemnitz not found");

            hj.CalcSpec.GeographicLocation = geoloc.GetJsonReference();
        }