Ejemplo n.º 1
0
 protected override State OnOn()
 {
     if (audio != null)
     {
         AudioSource.PlayClipAtPoint(audio, transform.position);
     }
     shServer.InsertBinarySensorData(name, "FlowMeasurement", true);
     return(State.Opening);
 }
Ejemplo n.º 2
0
 public void Switch()
 {
     if (currentTime <= 0)
     {
         state       = !state;
         currentTime = delay;
         SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
     }
 }
Ejemplo n.º 3
0
 void ISensorObserver.Notify()
 {
     if (currentTime <= 0)
     {
         state       = !state;
         currentTime = delay;
         SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
     }
 }
Ejemplo n.º 4
0
 void OnCollisionExit(Collision other)
 {
     if (isStarted)
     {
         Rigidbody rgbd = other.gameObject.GetComponent <Rigidbody> ();
         totalMassPressure -= rgbd.mass;
         if (totalMassPressure == 0f)
         {
             SmartHomeServer.InsertBinarySensorData(name, SensorType, false);
         }
     }
 }
Ejemplo n.º 5
0
    void Update()
    {
        if (canDetect)
        {
            Hashtable  detected     = new Hashtable();
            Collider[] hitColliders = Physics.OverlapSphere(capteurTransform.position, range);             //, layerMask);
            if (hitColliders.Length != 0)
            {
                for (int i = 0; i < hitColliders.Length; i++)
                {
//					Debug.Log ("Detected "+hitColliders [i].name);
                    if (detectedEntity != null)
                    {
                        if (canDetect && CheckMove(hitColliders [i]))
                        {
                            canDetect = false;
                            smartHomeServerScript.InsertBinarySensorData(name, "PIRSensor", true);
//							Debug.Log ("Detected "+hitColliders [i].name);
                        }
                        else
                        {
                        }
                    }
                    if (!detected.Contains(hitColliders [i].gameObject))
                    {
//						detected.Add (hitColliders [i].gameObject, new MovementDetection (hitColliders [i].gameObject));
                        Vector3 position = new Vector3(hitColliders [i].gameObject.transform.position.x,
                                                       hitColliders [i].gameObject.transform.position.y
                                                       , hitColliders [i].gameObject.transform.position.z);
                        detected.Add(hitColliders [i].gameObject, position);
                    }
                }
                if (detectedEntity != null)
                {
                    detectedEntity.Clear();
                }
                detectedEntity = detected;
            }
        }
        else
        {
            currentCooldown -= Time.deltaTime;
            if (currentCooldown <= 0)
            {
                currentCooldown = cooldown;
                canDetect       = true;
            }
        }
    }
Ejemplo n.º 6
0
 void OnCollisionEnter(Collision other)
 {
     if (isStarted)
     {
         if (other.gameObject.tag != "Floor")
         {
             Rigidbody rgbd = other.gameObject.GetComponent <Rigidbody> ();
             totalMassPressure += rgbd.mass;
             if (totalMassPressure >= minimumValue)
             {
                 SmartHomeServer.InsertBinarySensorData(name, SensorType, true);
             }
         }
     }
 }
Ejemplo n.º 7
0
 protected override void IESensorUpdate()
 {
     base.IESensorUpdate();
     if (canDetect)
     {
         Hashtable  detected     = new Hashtable();
         Collider[] hitColliders = Physics.OverlapSphere(capteurTransform.position, range);             //, layerMask);
         if (hitColliders.Length != 0)
         {
             for (int i = 0; i < hitColliders.Length; i++)
             {
                 if (detectedEntity != null)
                 {
                     if (canDetect && CheckMove(hitColliders [i]))
                     {
                         canDetect = false;
                         SmartHomeServer.InsertBinarySensorData(name, SensorType, true);
                     }
                     else
                     {
                     }
                 }
                 if (!detected.Contains(hitColliders [i].gameObject))
                 {
                     Vector3 position = new Vector3(hitColliders [i].gameObject.transform.position.x,
                                                    hitColliders [i].gameObject.transform.position.y
                                                    , hitColliders [i].gameObject.transform.position.z);
                     detected.Add(hitColliders [i].gameObject, position);
                 }
             }
             if (detectedEntity != null)
             {
                 detectedEntity.Clear();
             }
             detectedEntity = detected;
         }
     }
     else
     {
         currentCooldown -= Time.deltaTime;
         if (currentCooldown <= 0)
         {
             currentCooldown = cooldown;
             canDetect       = true;
         }
     }
 }
Ejemplo n.º 8
0
 void ISensorObserver.Notify()
 {
     state = !state;
     SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
 }