private static string _returnArea = "";//缓存damagearea/area接口

        public DamageAnalysisService(IMongoService mongoService,
                                     ILogger <DamageAnalysisService> logger,
                                     IConfiguration configuration)
        {
            Configuration = configuration;

            _mongoService = mongoService ??
                            throw new ArgumentNullException(nameof(mongoService));


            this._logger = logger;

            _infos = _mongoService.GetInfos();
            //_configs = _mongoService.GetConfigs();


            _overlays = _mongoService.GetOverlays();
            foreach (var overlay in _overlays)
            {
                additionTable.Add(Damage2String(overlay.addend) + Damage2String(overlay.augend),
                                  Int32.Parse(Damage2String(overlay.result)));
            }

            //创建线程,并启动
            //Thread th = new Thread(new ThreadStart(ThreadMethod));
            //th.Start();

            task = new Task(Run, cts.Token, TaskCreationOptions.LongRunning);
            task.Start();
        }
 public int InfoChanged()
 {
     lock (_infoLocker)
     {
         _infos = _mongoService.GetInfos();
     }
     return(1);
 }
Exemplo n.º 3
0
        public List <TestResultVO> TestStart(ref double damageR)
        {
            List <TestResultVO> result = new List <TestResultVO>();
            DD dd = null;
            // 1. 访问DD接口,拿到数据
            var url = Configuration["ServiceUrls:MissileInfo"];//http://localhost:5000/nuclearthreatanalysis/missileinfo

            try
            {
                Task <string> s = MyCore.Utils.HttpCli.GetAsyncJson(url);
                s.Wait();

                //JObject jo = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(s.Result);
                dd = Newtonsoft.Json.JsonConvert.DeserializeObject <DD>(s.Result);
            }
            catch (Exception e)
            {
                _logger.LogInformation("DD访问接口出错" + e.ToString());
                //Console.WriteLine(e.Message);
            }
            finally
            {
            }
            // 2. 读取info表里的井和车
            // 3. 计算井和车距离爆点的距离

            var infos = _mongoService.GetInfos();

            foreach (var info in infos)
            {
                // 只要井和车
                if (info.platform != "发射井" && info.platform != "发射车")
                {
                    continue;
                }

                double dis = MyCore.Utils.Translate.GetDistance(dd.return_data[0].lat, dd.return_data[0].lon, info.lat, info.lon);
                result.Add(new TestResultVO(info.platform, info.lon, info.lat, dis));
            }


            double r1 = MyCore.NuclearAlgorithm.GetShockWaveRadius(dd.return_data[0].yield, dd.return_data[0].alt, 1);
            double r2 = MyCore.NuclearAlgorithm.GetNuclearRadiationRadius(dd.return_data[0].yield, dd.return_data[0].alt, 100);
            double r3 = MyCore.NuclearAlgorithm.GetThermalRadiationRadius(dd.return_data[0].yield, dd.return_data[0].alt, 1.9);
            double r4 = MyCore.NuclearAlgorithm.GetNuclearPulseRadius(dd.return_data[0].yield, dd.return_data[0].alt, 200);

            // 4. 返回距离和综合损伤半径
            damageR = r4;


            return(result);
        }