// Update is called once per frame
    void Update()
    {
        if (g == null)
        {
            alerted = false;
            return;
        }

        int speed = (int)g.GetComponentInParent <CarController>().GetSpeed();

        if (speed <= 0)
        {
            timeLeft -= Time.deltaTime;
        }
        else
        {
            timeLeft = waitTime;
        }

        if (timeLeft <= 0 && !alerted)
        {
            AlertContainer.NewAlert("No Parking - Php 1,500");
            alerted = true;
        }
    }
 private void Detect()
 {
     if (uTurnIdentifiers.Count == 3)
     {
         if (uTurnIdentifiers[0].index == 1 &&
             uTurnIdentifiers[1].index == 2 &&
             uTurnIdentifiers[2].index == 3)
         {
             AlertContainer.NewAlert("U-Turn - Php 1,500");
             uTurnIdentifiers.Clear();
         }
     }
 }
示例#3
0
    void CheckFlow()
    {
        Vector3 forward = transform.forward;
        Vector3 other   = g.transform.forward;

        if (Vector3.Dot(forward, other) < -0.8f)
        {
            if (!alerted)
            {
                AlertContainer.NewAlert("Counter Flow - Php 1,500");
                alerted = true;
            }
        }
    }
示例#4
0
    private void OnTriggerEnter(Collider collider)
    {
        Vector3 forward = transform.forward;
        Vector3 other   = collider.transform.forward;

        if (collider.GetComponentInParent <CustomCarUserControl>() == null)
        {
            return;
        }
        if (Vector3.Dot(forward, other) > 0 && trafficLight.status == TrafficLightStatus.Stop)
        {
            AlertContainer.NewAlert("Red Light Violation - Php 1,500");
        }
    }
 void Update()
 {
     if (speedLimit == 0)
     {
         return;
     }
     if (!isAlerted && m_Car.GetSpeed() > speedLimit)
     {
         AlertContainer.NewAlert("Overspeeding - Php 1500");
         isAlerted = true;
     }
     else if (m_Car.GetSpeed() < speedLimit - 2)
     {
         isAlerted = false;
     }
 }
示例#6
0
 void CheckIdentifier()
 {
     if (detectors[0].GetIndex() == 0 && detectors[1].GetIndex() == 3)
     {
         Debug.Log("Right Turn");
     }
     else if (detectors[0].GetIndex() == 3 && detectors[1].GetIndex() == 0)
     {
         AlertContainer.NewAlert("No Left Turn - Php 1,500");
     }
     else if (detectors[0].GetIndex() == detectors[1].GetIndex() + 1)
     {
         Debug.Log("Right Trurn");
     }
     else
     {
         AlertContainer.NewAlert("No Left Turn - Php 1,500");
     }
     detectors.Clear();
 }
        public static List<AlertContainer> GetAlerts()
        {
            List<AlertContainer> retVal = new List<AlertContainer>();
            lock (LastSamples)
            {
                List<long> warningsToRemove = new List<long>();
                foreach (long componentSensorId in FlaggedWarnings)
                {
                    SensorReadingContainer readingContainer;
                    if (LastSamples.TryGetValue(componentSensorId, out readingContainer))
                    {
                        if (readingContainer.WarnUntilTime < DateTime.UtcNow ||
                            readingContainer.Readings.Count == 0)
                        {
                            warningsToRemove.Add(componentSensorId);
                            continue;
                        }

                        AlertContainer container = new AlertContainer();
                        container.AverageOverLastMinute = readingContainer.Sum / readingContainer.Readings.Count;

                        const string c_selecttHistoricalData =
                            @"SELECT ct.Name,cs.SensorName, cs.SensorTypeId
                             FROM ComponentSensor cs
                             JOIN ComputerComponent cc
                             ON cs.ComputerComponentId = cc.ComputerComponentId
                             JOIN Component ct
                             ON ct.ComponentId = cc.ComponentId
                             WHERE cs.ComponentSensorId = @componentSensorId";

                        // If the row already exists, we need to add the data together
                        using (SQLiteCommand sqlSelectCommand = new SQLiteCommand(s_dataManager._sqliteConnection))
                        {
                            sqlSelectCommand.CommandText = c_selecttHistoricalData;
                            sqlSelectCommand.Parameters.Add(new SQLiteParameter("@componentSensorId", componentSensorId));

                            using (SQLiteDataReader reader = sqlSelectCommand.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    container.ComponentName = Convert.ToString(reader["Name"]);
                                    container.SensorName = Convert.ToString(reader["SensorName"]);
                                    long sensorTypeId = Convert.ToInt64(reader["SensorTypeID"]);
                                    container.SensorType = (SensorType)sensorTypeId;

                                    retVal.Add(container);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }

                        string smtpServer;
                        string emailAddress;
                        GetEmailSettings(out smtpServer, out emailAddress);

                        if (!readingContainer.EmailSent && !String.IsNullOrEmpty(smtpServer) && !String.IsNullOrEmpty(emailAddress))
                        {
                            try
                            {
                                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                                message.To.Add(emailAddress);
                                message.Subject = "Alert: Your computer is running hotter than normal!";
                                message.From = new System.Net.Mail.MailAddress(emailAddress);
                                message.Body = "Alert: Your computer is running hotter than normal!\r\nName: " + container.ComponentName + "\r\nSensorName: " + container.SensorName + "\r\nAverage over last minute: " + container.AverageOverLastMinute;
                                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtpServer);
                                smtp.Send(message);
                                readingContainer.EmailSent = true;
                            }
                            catch (Exception)
                            {
                                // We'll just eat these
                            }
                        }
                    }
                }

                foreach (long componentSensorId in warningsToRemove)
                {
                    FlaggedWarnings.Remove(componentSensorId);
                }
            }

            return retVal;
        }