Exemple #1
0
        private static void DrawTrack()
        {
            int width  = Input.IndexOf('\n');
            int height = Input.Count(c => c == '\n');

            if (width > 80 || height > 80)
            {
                return;
            }
            for (int y = 0; y <= height; y++)
            {
                Console.Write("   ");
                for (int x = 0; x <= width; x++)
                {
                    char c = ' ';
                    if (Tracks.ContainsKey(new Point(x, y)))
                    {
                        c = Tracks[new Point(x, y)];
                    }

                    if (Minecarts.Any(m => m.Vector.Position.Equals(new Point(x, y))))
                    {
                        c = '*';
                    }
                    Console.Write(c);
                }
                Console.WriteLine();
            }
        }
Exemple #2
0
        /// <summary>
        ///     Loads an AudioTrack and caches it for later use
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static AudioTrack LoadTrack(string name)
        {
            if (Tracks.ContainsKey(name))
            {
                return(Tracks[name]);
            }

            var track = new AudioTrack(GameBase.Game.Resources.Get(name));

            Tracks.Add(name, track);

            return(track);
        }
        public void Update(ShipInfo ship, bool isFirstData)
        {
            if (GateIds == null || GateIds.Length == 0)//区域未绑定任何闸机,直接跳过。
            {
                return;
            }
            string shipID = ship.MMSI == 0 ? ship.ID : ship.MMSI.ToString();

            if (IsInner && ship.MMSI == 0)//不考虑雷达目标在内部区域
            {
                return;
            }
            lock (_obj)
            {
                ShipTrackConfig lastTrack = null;
                if (Tracks.ContainsKey(shipID))//找到该船之前的跟踪记录
                {
                    lastTrack = Tracks[shipID];
                }

                bool inRegion = Calculator.PtInPolygon(ship.Longitude, ship.Latitude, Regions);
                if (inRegion)
                {
                    bool isAlarm = !isFirstData && IsInner && (lastTrack == null || lastTrack.IsMoved); //不考虑首次刷新的内部区域的船舶(此时认为该船不是刚进入区域,已离港或者首次进入的船舶进行进港报警
                    if (lastTrack == null)                                                              //无历史跟踪数据
                    {
                        if (!IsInner && ship.SOG < 1)                                                   //外围区域速度过慢的船舶不启用跟踪
                        {
                            return;
                        }
                        Tracks[shipID] = new ShipTrackConfig(ship, isAlarm);
                    }
                    else
                    {
                        lastTrack.Update(ship, isAlarm, false);
                    }
                    trace($"-----------船舶 {ship.ID}:{ship.Name} 进入区域 {RegionId} {Name} - {IsInner}.报警:{isAlarm} - 跟踪总数 {Tracks.Count}");
                    TrackEventMgr.Instance.Enqueue(shipID);
                }
                else if (lastTrack != null)                                 //当前船舶不在区域内,且该船历史在区域内跟踪
                {
                    if (!ValidPoly.Contains(ship.Longitude, ship.Latitude)) //信号严重偏移且上一次在区域内,此时认为信号错误。2.4海里
                    {
                        Common.Log.Logger.Default.Error($"明显异常的船舶 {ship.MMSI},{ship.Name} : {lastTrack.Ship.Longitude},{lastTrack.Ship.Latitude} -> {ship.Longitude},{ship.Latitude}");
                        return;
                    }
                    else if (!_strictValidPoly.Contains(ship.Longitude, ship.Latitude))//信号有一定的偏移且上一次在区域内,此时认为可能会信号错误。0.6海里
                    {
                        Common.Log.Logger.Default.Error($"可能异常的船舶 {ship.MMSI},{ship.Name} : {lastTrack.Ship.Longitude},{lastTrack.Ship.Latitude} -> {ship.Longitude},{ship.Latitude}");
                    }
                    bool isalarm = false;
                    if (IsInner)
                    {
                        if (!lastTrack.IsMoved)//未离港的船舶刚离港发送离港报警
                        {
                            isalarm = true;
                        }
                        else if (!lastTrack.IsOutstanding)//已经超时的报警信息需要先清除,否则外部检测会出问题。
                        {
                            Common.Log.Logger.Default.Trace($"船舶离开内部区域报警结束,准备清除该记录...{shipID}:{ship.Name} -离开内部区域 {RegionId} {Name} ");
                            removeShip(shipID, lastTrack.Ship.Name);
                            return;
                        }
                    }
                    else if (!lastTrack.IsMoved)//外围区域仅考虑首次离开的船舶刷新
                    {
                        return;
                    }
                    lastTrack.Update(ship, isalarm, true);
                    TrackEventMgr.Instance.Enqueue(shipID);
                    trace($"+++++++++++++船舶 {shipID} :{ship.Name} 离开区域心跳 {RegionId} {Name} - {IsInner} - Alarm:{isalarm}");
                }
            }
        }