public bool UpdatePlate(RealtimeCameraInfo cam, List <System.Drawing.Point> region, List <DriveWayRegion> driveWayRegion,
                                List <System.Drawing.Rectangle> carPlateRegion,
                                bool noplat,
                                AccidentAlarmSubType accidentType,
                                uint carFast,
                                uint carStop,
                                uint carLow,
                                uint fluxTime)
        {
            bool ret = false;

            if (cam != null)
            {
                RealAnalyseInfo info = GetAllPlate().Find(item => item.realAnalyseParam.eAlgthmType == E_VIDEO_ANALYZE_TYPE.E_ANALYZE_CROSSROAD && item.realAnalyseParam.realCameraInfo.szCameraID == cam.CameraID);
                if (info != null)
                {
                    SaveEvent(cam.CameraID);
                    DelPlate(cam.CameraID);
                    uint id = AddPlate(cam, region, driveWayRegion, carPlateRegion, noplat, accidentType, carFast, carStop, carLow, fluxTime);
                    RecoverEvent(id);
                }
                else
                {
                    ret = false;
                }
            }
            else
            {
                ret = false;
            }


            return(ret);
        }
        private string BuildAnalyseParamByCheckCarCross(AccidentAlarmSubType AccidentAlarmSubType)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<CheckCarCross>" + ((AccidentAlarmSubType.CheckCarCross & AccidentAlarmSubType) > 0).ToString().ToUpper() + "</CheckCarCross>");

            return(sb.ToString());
        }
        private string BuildAnalyseParamByFlux(AccidentAlarmSubType AccidentAlarmSubType, uint FluxTimelyReportTimeInterval)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<Flux>");
            sb.AppendLine("<Enable>" + ((AccidentAlarmSubType.Flux & AccidentAlarmSubType) > 0).ToString().ToUpper() + "</Enable>");
            sb.AppendLine("<TimelyReportTimeInterval>" + FluxTimelyReportTimeInterval + "</TimelyReportTimeInterval>");
            sb.AppendLine("</Flux>");

            return(sb.ToString());
        }
        private string BuildAnalyseParamByCheckCarStop(AccidentAlarmSubType AccidentAlarmSubType, uint CarStop)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<CheckCarStop>");
            sb.AppendLine("<Enable>" + ((AccidentAlarmSubType.CheckCarStop & AccidentAlarmSubType) > 0).ToString().ToUpper() + "</Enable>");
            sb.AppendLine("<Limen>" + CarStop + "</Limen>");
            sb.AppendLine("</CheckCarStop>");

            return(sb.ToString());
        }
        public uint  AddPlate(RealtimeCameraInfo cam, List <System.Drawing.Point> region,
                              List <DriveWayRegion> driveWayRegion,
                              List <System.Drawing.Rectangle> carPlateRegion,
                              bool noplat,
                              AccidentAlarmSubType accidentType,
                              uint carFast,
                              uint carStop,
                              uint carLow,
                              uint fluxTime)
        {
            if (GetRealAnalyseCapableLeft() > 0)
            {
                AdpsServerUnitInfo unit       = GetOneProcessAdps();
                string             pChannelId = cam.CameraID;

                RealAnalyseParam param = new RealAnalyseParam()
                {
                    eAlgthmType    = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_CROSSROAD,
                    realCameraInfo = new RealCameraInfo()
                    {
                        dwDevicePort = (ushort)cam.PlatPort,
                        dwDeviceType = (uint)cam.ProtocolType,
                        szCameraID   = cam.CameraID,
                        szChannelID  = cam.CameraChannelID,
                        szDeviceIP   = cam.PlatIP,
                        szLoginPwd   = cam.Password,
                        szLoginUser  = cam.UserName,
                    },
                    dwAnalysisPlanID = Convert.ToUInt32(DateTime.Now.Subtract(new DateTime(DateTime.Today.Year, 1, 1, 0, 0, 0)).TotalMilliseconds / 10),
                    szAnalysisParam  = BuildAnalyseParamByAccidentAlarm(region, driveWayRegion, carPlateRegion, noplat, accidentType, carFast, carStop, carLow, fluxTime),
                    szArsIp          = unit.szServerIp,
                    wArsPort         = unit.wServerPort,
                };

                return(AddRealAnalyse(param));
            }
            else
            {
                return(0);
            }
        }
        private string BuildAnalyseParamByAccidentAlarm(
            List <System.Drawing.Point> AnalyseAreaExParam,
            List <DriveWayRegion> DriveWayRegionParam,
            List <System.Drawing.Rectangle> CarPlateAreaParam,
            bool VehicleNoplatInclude,
            AccidentAlarmSubType AccidentAlarmSubType,
            uint CarFast,
            uint CarStop,
            uint CarLow,
            uint FluxTimelyReportTimeInterval)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<root>");
            sb.AppendLine("<AlgorithmInitParam>");
            sb.AppendLine("<AlgorithmType>Crossroad</AlgorithmType>");
            if (AnalyseAreaExParam.Count > 0)
            {
                sb.AppendLine("<RoadRegion>");
                sb.AppendLine("<RoadNum>1</RoadNum>");
                sb.AppendLine("<RoadInfo>");
                sb.AppendLine("<PointNum>" + AnalyseAreaExParam.Count + "</PointNum>");
                sb.AppendLine("<PointSet>");
                foreach (var item in AnalyseAreaExParam)
                {
                    sb.AppendLine("<Point>");
                    sb.AppendLine("<X>" + item.X + "</X>");
                    sb.AppendLine("<Y>" + item.Y + "</Y>");
                    sb.AppendLine("</Point>");
                }
                sb.AppendLine("</PointSet>");
                sb.AppendLine("</RoadInfo>");
                sb.AppendLine("</RoadRegion>");
            }

            sb.AppendLine("<ChannelRegion>");
            sb.AppendLine("<ChannelNum>" + DriveWayRegionParam.Count + "</ChannelNum>");
            DriveWayRegionParam.ForEach(item => { sb.AppendLine(item.ToXMLString()); });
            sb.AppendLine("</ChannelRegion>");

            //if (CarPlateAreaParam.Count > 0)
            sb.AppendLine(BuildAnalyseParamByCarPlate(CarPlateAreaParam[0], VehicleNoplatInclude));
            //else
            //{
            //    Rectangle rect = new Rectangle(0, 2 * DrawImage.Height / 3, DrawImage.Width, DrawImage.Height - 2 * DrawImage.Height / 3);

            //    sb.AppendLine(BuildAnalyseParamByCarPlate(rect));
            //}

            sb.AppendLine("<Accident>");
            sb.AppendLine(BuildAnalyseParamByCheckNoReverse(AccidentAlarmSubType));
            sb.AppendLine(BuildAnalyseParamByCheckJam(AccidentAlarmSubType));
            sb.AppendLine(BuildAnalyseParamByCheckPassagerCross(AccidentAlarmSubType));
            sb.AppendLine(BuildAnalyseParamByCheckCarCross(AccidentAlarmSubType));
            sb.AppendLine(BuildAnalyseParamByCheckCarFast(AccidentAlarmSubType, CarFast));
            sb.AppendLine(BuildAnalyseParamByCheckCarLow(AccidentAlarmSubType, CarLow));
            sb.AppendLine(BuildAnalyseParamByCheckCarStop(AccidentAlarmSubType, CarStop));
            sb.AppendLine("</Accident>");

            sb.AppendLine(BuildAnalyseParamByFlux(AccidentAlarmSubType, FluxTimelyReportTimeInterval));

            sb.AppendLine("</AlgorithmInitParam>");
            sb.AppendLine("</root>");

            return(sb.ToString());
        }