protected override void AfterStop(MultipleTalker talker) { m_prevBinTime = string.Empty; m_tide = 1000; m_nextSyncTime = DateTime.MinValue; m_prevPhase = 0; m_prevAlarmId = string.Empty; m_gridEqkId = null; m_gridMap?.Dispose(); m_gridMap = null; foreach (var brush in m_mmiBrushes) { brush.Dispose(); } m_mmiBrushes = null; lock (m_syncGridPath) { m_gridFilePath = null; } m_stationUpdate = true; m_stations.Clear(); m_maxStnMmi = StnMmiTrigger - 1; m_stationDb = null; }
//######################################################################################################### protected override void BeforeStart(MultipleTalker talker) { this.JobDelay = TimeSpan.FromSeconds(6.0); AuthorizeContext(); }
protected override void AfterStop(MultipleTalker talker) { StopProcess(); base.AfterStop(talker); }
//########################################################################################################### protected override void BeforeStart(MultipleTalker talker) { base.BeforeStart(talker); StartProcess(); }
protected override void AfterStop(MultipleTalker talker) { TriggerValue = DangerValue; m_samples.Clear(); m_sampleCountList.Clear(); m_prevRawData = null; m_prevProcData = 0; }
//############################################################################################# protected override void BeforeStart(MultipleTalker talker) { // 하루 API 호출 제한 횟수로 인한 제약. this.JobDelay = TimeSpan.FromSeconds(9.0); using (var sr = new StreamReader(new FileStream("EqkInfoService.txt", FileMode.Open))) { m_apiKey = sr.ReadLine().Trim(); } m_latestNotiTime = null; }
//########################################################################################################### protected override void BeforeStart(MultipleTalker talker) { this.JobDelay = TimeSpan.FromMilliseconds(200.0); TriggerValue = DangerValue; if (IsAccel) { NormalValue = 0.03; MinNormalValue = 0.03; MaxNormalValue = 0.1; } else { NormalValue = 0.01; MinNormalValue = 0.01; MaxNormalValue = 0.038; } }
//############################################################################################# protected override void BeforeStart(MultipleTalker talker) { this.JobDelay = TimeSpan.FromSeconds(0.2); m_gridMap = Image.FromFile("map.png"); m_stationUpdate = true; m_stations.Clear(); m_maxStnMmi = StnMmiTrigger - 1; SyncTime(); m_stationDb = new PewsStnDatabase(); m_stationDb.LoadDatabase("stations.csv"); #if DEBUG //StartSimulation("2017000407", "20171115142931"); // 포항 5.4 //StartSimulation("2020005363", "20200511194506"); // 북한 3.8 //StartSimulation("2021000517", "20210203121756"); // 인천 2.2 #endif }
//############################################################################################ public void Start(MultipleTalker talker, Logger logger) { if (talker == null) { throw new ArgumentException("talker는 null이 아니어야 합니다."); } if (logger == null) { throw new ArgumentException("logger는 null이 아니어야 합니다."); } Stop(); m_talker = talker; m_logger = logger; BeforeStart(talker); m_onRunning = true; m_task = Task.Factory.StartNew(Work); }
protected abstract void AfterStop(MultipleTalker talker);
//############################################################################################ protected abstract void BeforeStart(MultipleTalker talker);
static void Work() { string winstonIp = string.Empty; int winstonPort = -1; // Winston 지진계 정보 불러오기 try { using (var sr = new StreamReader(new FileStream("winston.txt", FileMode.Open))) { winstonIp = sr.ReadLine(); string temp = sr.ReadLine(); int.TryParse(temp, out winstonPort); } } catch (Exception) { Console.WriteLine("winston.txt 파일을 찾을 수 없습니다."); return; } int msgServerPort = -1; // 메세지 서버 정보 불러오기 try { using (var sr = new StreamReader(new FileStream("server.txt", FileMode.Open))) { string temp = sr.ReadLine(); int.TryParse(temp, out msgServerPort); } } catch (Exception) { Console.WriteLine("server.txt 파일을 찾을 수 없습니다."); return; } /// GUI 표준 입력 동기화 객체 object lockControllerInput = new object(); #if DEBUG bool needController = File.Exists("../../../EarthquakeTalkerController/bin/Debug/EarthquakeTalkerController.exe"); #else bool needController = File.Exists("EarthquakeTalkerController.exe"); #endif /// GUI Process controller = null; if (needController) { controller = new Process(); controller.StartInfo = new ProcessStartInfo() { #if DEBUG FileName = "../../../EarthquakeTalkerController/bin/Debug/EarthquakeTalkerController.exe", #else FileName = "EarthquakeTalkerController.exe", #endif RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false, }; controller.Start(); } /// 로거 Logger logger = new Logger(); /// 메세지 처리자 MultipleTalker talker = new MultipleTalker(); #if DEBUG talker.AddTalker(new TelegramBot("@neurowhai_test_bot")); #else talker.AddTalker(new TelegramBot("@neurowhai_earthquake_channel")); #endif talker.AddTalker(new MessageServer(msgServerPort, "messages.dat")); /// FCM 서버 var fcmServer = new FCMServer("neurowhai-pews", "fcm.json"); fcmServer.Start(); /// 지진계 List <Seismograph> seismographList = new List <Seismograph>(); seismographList.Add(new SLinkSeismograph("slinktool.exe", "00BH1", "IU", "INCN", 3.352080e+09 / 100, "인천") { DangerValue = 0.01, DangerWaveTime = 0.01, MinDangerWaveTime = 0.005, IsAccel = false }); seismographList.Add(new SLinkSeismograph("slinktool.exe", "BHZ", "JP", "JTU", 1.000000e+09 / 100, "대마도") { DangerValue = 0.07, DangerWaveTime = 0.5, MinDangerWaveTime = 0.2, IsAccel = false }); seismographList.Add(new SLinkSeismograph("slinktool.exe", "BHZ", "KG", "TJN", 6.327240e+08 / 100, "대전") { DangerValue = 0.01, DangerWaveTime = 0.01, MinDangerWaveTime = 0.05, IsAccel = false }); seismographList.Add(new WinstonSeismograph(winstonIp, winstonPort, "00", "EHZ", "AM", "R3E8F", 3.36e+08 / 100, "포항") { DangerValue = 0.03, DangerWaveTime = 0.5, MinDangerWaveTime = 0.2, IsAccel = false, Endian = true }); /// 지진계를 포함한 메세지 생성자 List <Worker> workerList = new List <Worker>(); workerList.AddRange(seismographList); workerList.Add(new UserWatcher("KMA_earthquake", new KMAEarthquakeFormatter())); workerList.Add(new KmaHome()); workerList.Add(new KmaMicro()); workerList.Add(new IssueWatcher("지진", "지진+-동공+-일본+-원전+-http+-카메라+-ㅋㅋㅋ+-캠", triggerTime: TimeSpan.FromSeconds(30), maxStatusCount: 20, maxTextLength: 32)); workerList.Add(new KmaNews()); workerList.Add(new KmaPews(fcmServer)); workerList.Add(new KmaTsunami()); int sensorIndex = 0; foreach (var sensor in seismographList) { // 지진계 인덱스 설정 sensor.Index = sensorIndex; // GUI에 지진계 정보 전달 if (controller != null) { controller.StandardInput.WriteLine(sensor.Name + "|" + sensor.Gain + "|" + sensor.DangerValue); sensor.WhenDataReceived += new Seismograph.SeismographDataReceivedEventHandler((index, waveform) => { lock (lockControllerInput) { foreach (int data in waveform) { if (controller.HasExited == false) { controller.StandardInput.WriteLine(index + "|" + data); } } } }); } ++sensorIndex; } // 메세지 생성자 시작 foreach (var worker in workerList) { worker.Start(talker, logger); } bool onRunning = true; var inputTask = Task.Factory.StartNew(new Action(() => { while (true) { var key = Console.ReadKey(true); if (key.KeyChar == 'q' || key.KeyChar == 'Q') { onRunning = false; break; } Thread.Sleep(1000); } })); while (onRunning) { talker.TalkAll(); logger.LogAll(); Thread.Sleep(100); } inputTask.Wait(); if (controller != null && controller.HasExited == false) { controller.WaitForExit(); } foreach (var worker in workerList) { worker.Stop(); } fcmServer.Stop(); }
protected override void AfterStop(MultipleTalker talker) { base.AfterStop(talker); }
protected override void AfterStop(MultipleTalker talker) { m_twitterCtx = null; }
protected override void AfterStop(MultipleTalker talker) { m_latestCount = -1; m_client = null; }
protected override void AfterStop(MultipleTalker talker) { m_client?.Dispose(); m_client = null; }
//############################################################################################# protected override void BeforeStart(MultipleTalker talker) { this.JobDelay = TimeSpan.FromSeconds(10.0); }
protected override void AfterStop(MultipleTalker talker) { m_latestNoti = string.Empty; m_client = null; }
//############################################################################################# protected override void BeforeStart(MultipleTalker talker) { this.JobDelay = TimeSpan.FromSeconds(3.0); m_latestTitle = null; }