Exemplo n.º 1
0
        private void MediatorContext_OnEarthquake(object sender, EPSPQuakeEventArgs e)
        {
            if (e.InformationType == QuakeInformationType.Unknown)
            {
                return;
            }

            var earthquakeNotification = configuration.EarthquakeNotification;

            if (!earthquakeNotification.Enabled)
            {
                return;
            }

            var scale = e.InformationType == QuakeInformationType.Destination ? 30 : ScaleConverter.Str2Int(e.Scale);

            if (scale < earthquakeNotification.MinScale)
            {
                return;
            }

            if (!earthquakeNotification.Show)
            {
                Select("quake", e.ReceivedAt.ToString());
                return;
            }
            Activate("quake", e.ReceivedAt.ToString());
        }
Exemplo n.º 2
0
        private void MediatorContext_OnEarthquake(object sender, EPSPQuakeEventArgs e)
        {
            if (e.InformationType == QuakeInformationType.Unknown)
            {
                return;
            }

            var earthquakeNotification = configuration.EarthquakeNotification;

            if (!earthquakeNotification.Enabled)
            {
                return;
            }
            if (!earthquakeNotification.Sound)
            {
                return;
            }

            if (e.OccuredTime == lastEarthquakeOccuredTime)
            {
                return;
            }
            lastEarthquakeOccuredTime = e.OccuredTime;

            var scale = e.InformationType == QuakeInformationType.Destination ? 30 : ScaleConverter.Str2Int(e.Scale);

            if (scale < earthquakeNotification.MinScale)
            {
                return;
            }

            if (e.InformationType == QuakeInformationType.Destination)
            {
                PlaySound(SoundType.P2PQ_Snd0);
                return;
            }

            if (scale >= 55)
            {
                PlaySound(SoundType.P2PQ_Snd4);
            }
            else if (scale >= 45)
            {
                PlaySound(SoundType.P2PQ_Snd3);
            }
            else if (scale >= 30)
            {
                PlaySound(SoundType.P2PQ_Snd2);
            }
            else
            {
                PlaySound(SoundType.P2PQ_Snd1);
            }
        }
Exemplo n.º 3
0
 private static void Client_OnEarthquake(object sender, EPSPQuakeEventArgs e)
 {
     AddHistory(e);
 }
Exemplo n.º 4
0
 private void PeerManager_OnEarthquake(object sender, EPSPQuakeEventArgs e)
 {
     OnEarthquake(sender, e);
 }
Exemplo n.º 5
0
        private void RaiseEarthquakeEvent(Packet packet)
        {
            if (packet.Code != Code.EARTHQUAKE)
            {
                return;
            }

            if (packet.Data == null || packet.Data.Length < 4)
            {
                return;
            }

            EPSPQuakeEventArgs e = new EPSPQuakeEventArgs()
            {
                ReceivedAt = ProtocolTime()
            };

            Verifier.VerifyResult result = Verifier.VerifyServerData(packet.Data[2] + packet.Data[3], packet.Data[1], packet.Data[0], ProtocolTime());
            e.IsExpired          = result.isExpired;
            e.IsInvalidSignature = !result.isValidSignature;

            // 地震概要の解析
            string[] abstracts = packet.Data[2].Split(',');
            if (abstracts.Length != 11)
            {
                return;
            }

            e.OccuredTime     = abstracts[0];
            e.Scale           = abstracts[1];
            e.TsunamiType     = (DomesticTsunamiType)int.Parse(abstracts[2]);
            e.InformationType = (QuakeInformationType)int.Parse(abstracts[3]);
            e.Destination     = abstracts[4];
            e.Depth           = abstracts[5];
            e.Magnitude       = abstracts[6];
            e.IsCorrection    = abstracts[7] == "1";
            e.Latitude        = abstracts[8];
            e.Longitude       = abstracts[9];
            e.IssueFrom       = abstracts[10];

            // 震度観測点の解析
            e.PointList = new List <QuakeObservationPoint>();
            string[] details    = packet.Data[3].Split(',');
            string   prefecture = null;
            string   scale      = null;

            foreach (string detail in details)
            {
                if (detail.Length <= 0)
                {
                    continue;
                }

                if (detail[0] == '-')
                {
                    prefecture = detail.Substring(1);
                    continue;
                }
                if (detail[0] == '+')
                {
                    scale = detail.Substring(1);
                    continue;
                }
                if (detail[0] != '*')
                {
                    continue;
                }

                QuakeObservationPoint point = new QuakeObservationPoint();
                point.Prefecture = prefecture;
                point.Scale      = scale;
                point.Name       = detail.Substring(1);

                e.PointList.Add(point);
            }

            OnEarthquake(this, e);
        }