private void m_wndClearTimer_Tick(object sender, EventArgs e)
        {
            // 查找需要清除的目标
            DateTime   now        = DateTime.Now;
            TimeSpan   tenMinutes = new TimeSpan(0, 20, 0);
            List <int> removeKeys = new List <int>();

            foreach (AISTarget target in m_AISCollection.Values)
            {
                if ((now - target.UpdateTime) >= tenMinutes)
                {
                    removeKeys.Add(target.MMSI);
                }
            }

            // 开展清除工作
            foreach (int mmsi in removeKeys)
            {
                AISTarget target = null;
                if (m_AISCollection.TryGetValue(mmsi, out target) && (target != null))
                {
                    m_AISCollection.Remove(mmsi);
                    m_wndAISList.Items.Remove(target.ListItem);
                }
            }
        }
예제 #2
0
        //! 上报新的ARPA目标数据

        /*!
         *      \param		dwArpaID:ARPA目标ID
         *      \return		ARPA数据是否进入统计列表
         *      \remark     上报新的ARPA目标数据
         */
        bool ReportSensorArpa(long dwArpaID)
        {
            bool      bResult     = false;
            target    radarTarget = null;
            AISTarget aisTarget   = null;

            m_np.m_dicTargetCollection.TryGetValue(dwArpaID, out radarTarget);

            if (radarTarget == null)
            {
                return(false);
            }
            int nIndex = -1;

            nIndex = FindUnionAisTarget(dwArpaID, UNION_STATE_SENSOR, UNION_ASSCI | UNION_DISASSCI);
            if (nIndex != -1)
            {
                m_np.m_AISCollection.TryGetValue((int)dwArpaID, out aisTarget);
                if (aisTarget != null)
                {
                    bResult = TryUnionTarget(aisTarget, radarTarget, UNION_STATE_SENSOR, nIndex);
                }
            }
            else
            {
                float fMinRng    = 926 * 1.0f;
                long  dwMinRngID = -1;

                foreach (var item in m_np.m_AISCollection)
                {
                    if (FindUnionArpaTarget(item.Value.MMSI, UNION_STATE_SENSOR, UNION_ASSCI | UNION_DISASSCI) != -1)
                    {
                        continue;
                    }
                    tagTARGET_DIFF stTargetDiff = new tagTARGET_DIFF();
                    if (RetCurState(aisTarget, radarTarget, stTargetDiff) == UNION_ASSCI)
                    {
                        if (stTargetDiff.fRngDiff < fMinRng)
                        {
                            fMinRng    = stTargetDiff.fRngDiff;
                            dwMinRngID = item.Value.MMSI;
                        }
                    }
                    if (dwMinRngID != -1)
                    {
                        m_np.m_AISCollection.TryGetValue((int)dwMinRngID, out aisTarget);
                        bResult = TryUnionTarget(aisTarget, radarTarget, UNION_STATE_SENSOR, nIndex);
                    }
                }
            }
            return(true);
        }
예제 #3
0
        //! 计算AIS和ARPA数据,返回瞬时状态

        /*!
         *      \param		lpAisTarget:AIS目标指针
         *      \param		lpArpaTarget:Arpa目标指针
         *      \return		瞬时状态
         *      \remark     计算AIS和ARPA数据,返回瞬时状态
         */
        int RetCurState(AISTarget lpAisTarget, target lpArpaTarget, tagTARGET_DIFF lpTargetDiff)
        {
            int   nCurState   = UNION_DISASSCI;
            float fRangeDist  = 0.0f;
            float fBearDiff   = 0.0f;
            float fCourseDist = 0.0f;
            float fSpeedDist  = 0.0f;

            double dAisLat = 0.0, dAisLon = 0.0, dArpaLat = 0.0, dArpaLon = 0.0;
            float  fAisSpd = 0.0f, fAisCrs = 0.0f, fArpaSpd = 0.0f, fArpaCrs = 0.0f;


            // 比较ais与arpa目标的距离、速度的偏差
            double dDistance = 0;

            dDistance = CommonFunctions.GetDistance(lpAisTarget.Latitude, lpAisTarget.Longitude, lpArpaTarget.Latitude, lpArpaTarget.Longitude);

            dDistance *= NM;
            fRangeDist = (float)dDistance;

            fSpeedDist = (float)Math.Abs((lpAisTarget.Speed - lpArpaTarget.Speed));

            //if (fAisSpd < NM && fArpaSpd < NM)
            //{
            //    fCourseDist = 0.0f;
            //}

            //if (fCourseDist > 180)
            //{
            //    fCourseDist = 360 - fCourseDist;
            //}

            if (lpTargetDiff != null)
            {
                lpTargetDiff.fRngDiff = fRangeDist;
                lpTargetDiff.fSpdDiff = fSpeedDist;
            }
            if (fRangeDist < NM && fSpeedDist < 1000)
            {
                // 瞬时状态为强联合
                nCurState = UNION_ASSCI;
            }
            else
            {
                // 瞬时状态为分离
                nCurState = UNION_DISASSCI;
            }
            return(nCurState);
        }
        /// <summary>
        /// 更新位置
        /// </summary>
        private void UpdatePosition(int mmsi, double latitude, double longitude, double speed, double course, double heading)
        {
            if (this.InvokeRequired)
            {
                Delegate method = new UpdatePositionHandler(UpdatePosition);
                this.Invoke(method, new object[] { mmsi, latitude, longitude, speed, course, heading });
                return;
            }

            AISTarget target = null;

            if (m_AISCollection.TryGetValue(mmsi, out target))
            {
                // 更新现有数据项
                target.Latitude  = latitude;
                target.Longitude = longitude;
                target.Speed     = speed;
                target.Course    = course;
                target.Heading   = heading;
            }
            else
            {
                // 新增新数据项
                target           = new AISTarget();
                target.MMSI      = mmsi;
                target.Latitude  = latitude;
                target.Longitude = longitude;
                target.Speed     = speed;
                target.Course    = course;
                target.Heading   = heading;

                // 添加到集合中
                m_AISCollection.Add(mmsi, target);
                target.ListItem = new System.Windows.Forms.ListViewItem(mmsi.ToString());
                target.ListItem.SubItems.AddRange(new string[] { "***", "***", "***", "***", "***", "***", "***", "***" });
                m_wndAISList.Items.Add(target.ListItem);
            }

            if (target != null)
            {
                target.UpdateTime = DateTime.Now;
                // 更新显示
                target.UpdateContent();
            }
        }
        /// <summary>
        /// 更新静态信息
        /// </summary>
        private void UpdateData(int mmsi, string name, string callSign, string destination)
        {
            if (this.InvokeRequired)
            {
                Delegate method = new UpdateDataHandler(UpdateData);
                this.Invoke(method, new object[] { mmsi, name, callSign, destination });
                return;
            }

            AISTarget target = null;

            if (m_AISCollection.TryGetValue(mmsi, out target))
            {
                // 更新现有数据项
                target.Name        = name;
                target.CallSign    = callSign;
                target.Destination = destination;
            }
            else
            {
                // 新增新数据项
                target             = new AISTarget();
                target.MMSI        = mmsi;
                target.Name        = name;
                target.CallSign    = callSign;
                target.Destination = destination;

                // 添加到集合中
                m_AISCollection.Add(mmsi, target);
                target.ListItem = new System.Windows.Forms.ListViewItem(mmsi.ToString());
                target.ListItem.SubItems.AddRange(new string[] { "***", "***", "***", "***", "***", "***", "***", "***" });
                m_wndAISList.Items.Add(target.ListItem);
            }

            if (target != null)
            {
                target.UpdateTime = DateTime.Now;
                // 更新显示
                target.UpdateContent();
            }
        }
예제 #6
0
        //! 尝试将AIS和ARPA目标对放进入统计列表

        /*!
         *      \param		lpAisTarget:AIS目标指针
         *      \param		lpArpaTarget:ARPA目标指针
         *      \return		是否成功将AIS和ARPA目标对放入统计列表
         *      \remark
         */
        bool TryUnionTarget(AISTarget lpAisTarget, target lpArpaTarget, long dwUnionState, int nIndex)
        {
            bool bResult = false;

            if (lpAisTarget == null || lpArpaTarget == null)
            {
                return(bResult);
            }

            float          fCourse = 0.0f, fSpeed = 0.0f;
            tagCOMBINE_TGT stCmbTgt1   = new tagCOMBINE_TGT();
            tagCOMBINE_TGT stCmbTgt2   = new tagCOMBINE_TGT();
            tagCOMBINE_TGT stCmbTgtRet = new tagCOMBINE_TGT();

            int nCurState = RetCurState(lpAisTarget, lpArpaTarget, null);

            if (nIndex == -1)
            {
                // 只有同时满足瞬时状态为UNION_ASSCI,统计列表未到上限,AIS和ARPA任何一个都未被联合才能进入联合统计列表
                if ((nCurState == UNION_ASSCI) && (m_vectUnion.Count() < MAX_UNION_SIZE))
                {
                    tagTARGET_UNION stTargetUnion = new tagTARGET_UNION();
                    stTargetUnion.dwAisID     = lpAisTarget.MMSI;
                    stTargetUnion.dwArpaID    = lpArpaTarget.targetID;
                    stTargetUnion.dwUnionStat = dwUnionState;

                    //stTargetUnion.dUnionRng		= stCmbTgtRet.dRange;
                    //stTargetUnion.dUnionAzi		= stCmbTgtRet.dAzimuth;
                    //stTargetUnion.dUnionTSpd	= stCmbTgtRet.dTSpeed;
                    //stTargetUnion.dUnionTCrs	= stCmbTgtRet.dTCourse;



                    stTargetUnion.dUnionTSpd = lpAisTarget.Speed;
                    stTargetUnion.dUnionTCrs = lpAisTarget.Course;

                    {
                        double dCurLat = 0.0, dCurLon = 0.0;
                        //dCurLat	= g_EFPSDataManager.GetCurLat();
                        //dCurLon	= g_EFPSDataManager.GetCurLon();
                        //GeoFunc::RefPos2GeoPos(dCurLat, dCurLon, stTargetUnion.dUnionAzi, MToNM(stTargetUnion.dUnionRng), stTargetUnion.dUnionLat, stTargetUnion.dUnionLon);
                    }
                    stTargetUnion.ResetState(UNION_DISASSCI);
                    stTargetUnion.ReportOnce(nCurState);
                    m_vectUnion.Add(stTargetUnion);
                    bResult = true;
                }
            }
            else
            {
                int             nState        = m_vectUnion[nIndex].ReportOnce(nCurState);
                tagTARGET_UNION lpTargetUnion = m_vectUnion[nIndex];

                if (nCurState == UNION_ASSCI)
                {
                    lpTargetUnion.dUnionTSpd = lpAisTarget.Speed;
                    lpTargetUnion.dUnionTCrs = lpAisTarget.Course;
                }
                else
                {
                }

                switch (nState)
                {
                case UNION_ASSCI:
                    break;

                case UNION_DISASSCI:
                    break;

                case UNION_BREAK:
                    m_vectUnion.RemoveAt(nIndex);
                    break;
                }
                bResult = true;
            }
            return(bResult);
        }
예제 #7
0
        //! 设置需要统计的AIS和ARPA列表

        /*!
         *      \param		lpAisTgtList:指向AIS列表指针
         *      \param		lpArpaTgtList:指向ARPA列表指针
         *      \return		None
         *      \remark     设置需要统计的AIS和ARPA列表
         */
        void SetAisArpaTgtList(AISTarget lpAisTgtList, target lpArpaTgtList)
        {
        }