internal ALPRScanResult(Vehicle pVehicle, EAlertType pResult)
 {
     mVehicle  = pVehicle;
     AlertType = pResult;
     mResult   = pResult.ToString();
     Created   = DateTime.Now;
 }
Beispiel #2
0
 public static MvcHtmlString Alert(this HtmlHelper html, EAlertType alertType, string message, string otherMessage = "")
 {
     return(html.Partial("_Alert", new AlertOptions
     {
         Message = message,
         OtherMessage = otherMessage,
         AlertType = alertType
     }));
 }
Beispiel #3
0
 public static MvcHtmlString PopupAlert(this HtmlHelper html, EAlertType alertType, string message, string otherMessage = "")
 {
     return(PopupAlert(html, new AlertOptions
     {
         Message = message,
         OtherMessage = otherMessage,
         AlertType = alertType
     }));
 }
Beispiel #4
0
        private API.ALPRScanResult CreateScanResult(Vehicle veh, EAlertType alert, ECamera cam)
        {
            API.ALPRScanResult r = null;

            switch (alert)
            {
            case EAlertType.Stolen_Vehicle:
                r = CreateStolenVehResult(veh);
                break;

            case EAlertType.Owner_Wanted:
                r = CreateWantedResult(veh);
                break;

            case EAlertType.Owner_License_Suspended:
                r = CreateLicSuspendedResult(veh);
                break;

            case EAlertType.Owner_License_Expired:
                r = CreateLicExpiredResult(veh);
                break;

            case EAlertType.Registration_Expired:
                r = CreateRegExpiredResult(veh);
                break;

            case EAlertType.Unregistered_Vehicle:
                r = CreateRegNotValidResult(veh);
                break;

            case EAlertType.No_Insurance:
                r = CreateInsNotValidResult(veh);
                break;

            case EAlertType.Insurance_Expired:
                r = CreateInsExpiredResult(veh);
                break;
            }

            API.Functions.RaiseALPRFlagGenerated(veh, new ALPREventArgs(r, cam));
            return(r);
        }
Beispiel #5
0
        private EAlertType GenerateFlag(Vehicle veh)
        {
            if (!veh.Exists() || (!veh.HasDriver || !veh.Driver.Exists()))
            {
                return(EAlertType.Null);
            }

            EAlertType mAlertToTrigger = EAlertType.Null;
            int        alertFactor     = mRand.Next(100);

            Dictionary <EAlertType, int> mAlertWeights = new Dictionary <EAlertType, int>()
            {
                { EAlertType.Stolen_Vehicle, Config.StolenVehicleWeight },
                { EAlertType.Owner_Wanted, Config.OwnerWantedWeight },
                { EAlertType.Owner_License_Suspended, Config.OwnerLicenseSuspendedWeight },
                { EAlertType.Owner_License_Expired, Config.OwnerLicenseExpiredWeight },
                { EAlertType.Unregistered_Vehicle, Config.UnregisteredVehicleWeight },
                { EAlertType.Registration_Expired, Config.RegisrationExpiredWeight },
                { EAlertType.No_Insurance, Config.NoInsuranceWeight },
                { EAlertType.Insurance_Expired, Config.InsuranceExpiredWeight }
            };

            List <EAlertType> keys = (from x in mAlertWeights select x.Key).ToList();

            int cumulative = 0;

            foreach (var x in keys)
            {
                int mItemWeight = mAlertWeights[x];
                cumulative += mItemWeight;

                if (alertFactor < cumulative)
                {
                    mAlertToTrigger = x;
                    break;
                }
            }

            return(mAlertToTrigger);
        }
Beispiel #6
0
 public static MvcHtmlString Alert(this HtmlHelper html, EAlertType alertType, MvcHtmlString message)
 {
     return(Alert(html, alertType, message.ToString(), String.Empty));
 }
Beispiel #7
0
 public static MvcHtmlString Alert(this HtmlHelper html, EAlertType alertType, string message, MvcHtmlString otherMessage)
 {
     return(Alert(html, alertType, message, otherMessage.ToString()));
 }
Beispiel #8
0
 private void updateTheMessageByType(EAlertType highestAlertType)
 {
     switch (highestAlertType)
     {
         case EAlertType.EyeDetectionAlert:
             _alertMessage = "Open Your Eyes!";
             break;
         case EAlertType.DistanceAlert:
             _alertMessage = "Keep Your Distance";
             break;
         case EAlertType.LaneCrossingAlert:
             _alertMessage = "Keep in Your Lane";
             break;
         default:
             _alertMessage = "Drive Safely";
             break;
     }
 }
Beispiel #9
0
        private bool RunVehiclePlates(Vehicle veh, ECamera cam)
        {
            if (veh.Exists() && !IsVehicleBlacklisted(veh))
            {
                if (!mRecentlyScanned.ContainsKey(veh))
                {
                    mRecentlyScanned.Add(veh, Game.GameTime);

                    if (Config.PlayScanSound)
                    {
                        Audio.PlaySound(Audio.ESounds.PinButton);
                        //GameFiber.Sleep(500);
                    }

                    if (Globals.ScanResults.Keys.Contains(veh))
                    {
                        TimeSpan ts = DateTime.Now - Globals.ScanResults[veh].LastDisplayed;
                        if (ts.TotalSeconds < Config.VehicleRescanBuffer)
                        {
                            return(false);
                        }

                        EAlertType mPrevAlert = Globals.ScanResults[veh].AlertType;

                        if (mPrevAlert != EAlertType.Null)
                        {
                            DisplayAlert(veh, cam, Globals.ScanResults[veh]);
                            return(true);
                        }
                        else
                        {
                            if (Globals.ScanResults[veh].IsCustomFlag == true && Globals.ScanResults[veh].Result != "")
                            {
                                DisplayAlert(veh, cam, Globals.ScanResults[veh]);
                                return(true);
                            }
                        }

                        return(false);
                    }
                    else
                    {
                        int mAlertFactor = mRand.Next(0, 100);

                        if (mAlertFactor < Config.ProbabilityOfAlerts)
                        {
                            EAlertType mGeneratedFlag = GenerateFlag(veh);

                            if (mGeneratedFlag != EAlertType.Null)
                            {
                                API.ALPRScanResult r = CreateScanResult(veh, mGeneratedFlag, cam);
                                DisplayAlert(veh, cam, r);
                                return(true);
                            }
                            else
                            {
                                if (!Globals.ScanResults.ContainsKey(veh))
                                {
                                    API.ALPRScanResult r = new API.ALPRScanResult(veh, EAlertType.Null);
                                    Globals.ScanResults.Add(veh, r);
                                    return(false);
                                }
                            }
                        }
                        else
                        {
                            if (!Globals.ScanResults.ContainsKey(veh))
                            {
                                API.ALPRScanResult r = new API.ALPRScanResult(veh, EAlertType.Null);
                                Globals.ScanResults.Add(veh, r);
                                return(false);
                            }
                        }

                        return(false);
                    }
                }
            }

            return(false);
        }
Beispiel #10
0
 public static string GetIcon(this EAlertType type) => type switch
 {
Beispiel #11
0
        /// <summary>
        /// Sets the ALPR flag/result for a specific vehicle. This function uses the pre-defined alert types used by ALPR+.
        /// NOTE: This function will NOT set corresponding Persona or Vehicle details to match the flag you set; that part is YOUR responsibility!!
        /// </summary>
        /// <param name="veh">The Vehicle to set the flag for.</param>
        /// <param name="flag">The pre-defined flag to be set. If this parameter is EAlertType.Null, ALPR+ will not trigger any events for the vehicle (i.e. the vehicle has a 'clear record').
        /// However, again, YOU are responsible for setting the vehicle's owner and the driver's Persona accordingly!</param>
        /// <returns>True if the operation succeeded, or false if it failed. Errors will be logged.</returns>
        public static bool SetVehiclePredefinedALPRFlag(Vehicle veh, EAlertType flag)
        {
            try
            {
                if (veh.Exists())
                {
                    if (Globals.ScanResults.ContainsKey(veh))
                    {
                        Globals.ScanResults[veh].AlertType = flag;
                    }
                    else
                    {
                        ALPRScanResult r = new ALPRScanResult(veh, flag);
                        r.IsCustomFlag = false;
                        Globals.ScanResults.Add(veh, r);
                    }

                    if (Globals.ScanResults[veh] != null)
                    {
                        if (flag == EAlertType.Null)
                        {
                            Globals.ScanResults[veh].IsCustomFlag = false;
                            Globals.ScanResults[veh].SetResult("");
                            Globals.ScanResults[veh].Persona         = null;
                            Globals.ScanResults[veh].RegisteredOwner = "";
                        }
                    }

                    if (Funcs.IsTrafficPolicerRunning())
                    {
                        TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.Valid);
                        TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.Valid);
                    }

                    if (flag == EAlertType.Registration_Expired)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.Expired);
                        }
                    }

                    if (flag == EAlertType.Unregistered_Vehicle)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.None);
                        }
                    }

                    if (flag == EAlertType.No_Insurance)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.None);
                        }
                    }

                    if (flag == EAlertType.Insurance_Expired)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.Expired);
                        }
                    }

                    return(true);
                }
                else
                {
                    Logger.LogVerbose("Cannot set vehicle ALPR flag -- Vehicle is null.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogVerbose(String.Format("Exception occurred in API.SetVehiclePredefinedALPRFlag(Vehicle veh, string flag) -- {0}", ex.ToString()));
                return(false);
            }
        }