コード例 #1
0
ファイル: PIRSensor.cs プロジェクト: Natorkawl/shima
    private int layerMask = 1 << 9;     // Layer : RFID

    // Use this for initialization
    void Start()
    {
        currentCooldown = cooldown;
        canDetect       = true;
        GameObject smartHomeServer = GameObject.Find("smarthomeserver");

        smartHomeServerScript = smartHomeServer.GetComponent <SmartHomeServer> ();
    }
コード例 #2
0
ファイル: DDContactSensor.cs プロジェクト: Natorkawl/shima
 public void Switch()
 {
     if (currentTime <= 0)
     {
         state       = !state;
         currentTime = delay;
         SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
     }
 }
コード例 #3
0
 void ISensorObserver.Notify()
 {
     if (currentTime <= 0)
     {
         state       = !state;
         currentTime = delay;
         SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
     }
 }
コード例 #4
0
ファイル: RFIDSensor.cs プロジェクト: Natorkawl/shima
    public void Trigger(GameObject collider)
    {
        float rssi = RSSI(collider);

        if (rssi <= thresoldMin && rssi >= thresoldMax)
        {
            SmartHomeServer.InsertRFIDData(name, rssi, collider.name);
        }
    }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: zihaoong/SmartHome
        public MainForm()
        {
            InitializeComponent();

            Server = new SmartHomeServer(IPAddress.Any, 3000);
            Server.Start((command) =>
            {
                MessageBox.Show(command);
            });
        }
コード例 #6
0
ファイル: ForceSignal.cs プロジェクト: Natorkawl/shima
    private void InitSmartHomeServerConnection()
    {
        GameObject smartHomeServerObject = GameObject.Find("smarthomeserver");

        if (smartHomeServer == null)
        {
            Debug.Log("SmartHomeServer Not Loaded");
        }
        smartHomeServer = smartHomeServerObject.GetComponent <SmartHomeServer>();
    }
コード例 #7
0
        static void Main(string[] args)
        {
            SmartHomeServer server = new SmartHomeServer(IPAddress.Any, 3000);

            server.Start((command) =>
            {
                Console.WriteLine(command);
                Console.WriteLine();
            });
        }
コード例 #8
0
 private void ConsoleForm_Load(object sender, EventArgs e)
 {
     Server = new SmartHomeServer(IPAddress.Any, 3000);
     Server.Start((command) =>
     {
         Invoke(new Action(() => {
             tbConsole.AppendText(command);
         }));
     });
 }
コード例 #9
0
    private void InitLogger()
    {
        GameObject smartHomeServer = GameObject.Find(smartHomeServerName);

        if (smartHomeServer == null)
        {
            Debug.Log("SmartHomeServer named " + smartHomeServerName + " Not Loaded");
        }

        logger   = smartHomeServer.GetComponent <ElectricityLogger> ();
        shServer = smartHomeServer.GetComponent <SmartHomeServer> ();
    }
コード例 #10
0
 void OnCollisionExit(Collision other)
 {
     if (isStarted)
     {
         Rigidbody rgbd = other.gameObject.GetComponent <Rigidbody> ();
         totalMassPressure -= rgbd.mass;
         if (totalMassPressure == 0f)
         {
             SmartHomeServer.InsertBinarySensorData(name, SensorType, false);
         }
     }
 }
コード例 #11
0
ファイル: IESensor.cs プロジェクト: Natorkawl/shima
    private void InitSmartHomeServerConnection()
    {
        GameObject smartHomeServerObject = GameObject.Find(smartHomeServerObjectName);

        if (smartHomeServerObject == null)
        {
            Debug.Log(smartHomeServerObjectName + " Not found");
        }
        else
        {
            smartHomeServer = smartHomeServerObject.GetComponent <SmartHomeServer> ();
        }
    }
コード例 #12
0
    protected override bool Init()
    {
        if (shServer == null)
        {
            GameObject smartHomeServer = GameObject.Find("smarthomeserver");
            if (smartHomeServer == null)
            {
                Debug.Log("SmartHomeServer Not Loaded");
            }

            shServer = smartHomeServer.GetComponent <SmartHomeServer> ();
            return(true);
        }
        return(false);
    }
コード例 #13
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);
             }
         }
     }
 }
コード例 #14
0
ファイル: InfraredSensor.cs プロジェクト: Natorkawl/shima
    void Raycasting()
    {
        RaycastHit hit;

        Physics.Raycast(transform.position, transform.up, out hit, range);
        Debug.DrawRay(transform.position, transform.up * range, Color.red);
        if (hit.collider != null)
        {
            if (hit.collider.tag == "Player")
            {
                float distance = hit.distance;
                isDetectionEnable = false;
                SmartHomeServer.InsertUltrasoundData(name, distance);
            }
        }
    }
コード例 #15
0
ファイル: SmartElectricMeter.cs プロジェクト: Natorkawl/shima
 protected override void IESensorUpdate()
 {
     base.IESensorUpdate();
     lastUpdate -= Time.deltaTime;
     if (lastUpdate <= 0)
     {
         string        timestamp = System.DateTime.UtcNow.ToLongTimeString() + ":" + System.DateTime.UtcNow.Millisecond;
         ElectricPhase _electricPhase;
         for (int i = 0; i < phasesNumber; i++)
         {
             _electricPhase = electricPhases [i] as ElectricPhase;
             SmartHomeServer.InsertElectricityData(timestamp, "" + i, _electricPhase.ActivePower, _electricPhase.ReactivePower);
         }
         lastUpdate = updateFrequence;
     }
 }
コード例 #16
0
ファイル: PIRMotion.cs プロジェクト: Natorkawl/shima
 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;
         }
     }
 }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: devsifi/SmartHome
        public MainForm()
        {
            InitializeComponent();

            Server = new SmartHomeServer(IPAddress.Any, 3000);
            Server.Start((connected, disconnected) =>
            {
                using (SQLiteConnection conn = new SQLiteConnection("data source=SmartHomeDB.db3"))
                {
                    conn.Open();

                    foreach (Host host in connected)
                    {
                        SQLiteCommand cmd = new SQLiteCommand(conn);
                        cmd.CommandText   = "SELECT Modules.Path as Path, Modules.Args as Args FROM Devices INNER JOIN Actions ON Devices.DeviceName = Actions.DeviceName INNER JOIN Modules ON Actions.Command = Modules.Command WHERE Devices.MacAddress = @mac AND Action = @action";
                        cmd.Parameters.AddWithValue("@mac", host.MAC);
                        cmd.Parameters.AddWithValue("@action", "Enter");

                        var reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            reader.Read();
                            process(reader.GetString(reader.GetOrdinal("Path")), reader.GetString(reader.GetOrdinal("Args")));
                        }
                    }

                    foreach (Host host in disconnected)
                    {
                        SQLiteCommand cmd = new SQLiteCommand(conn);
                        cmd.CommandText   = "SELECT Modules.Path as Path, Modules.Args as Args FROM Devices INNER JOIN Actions ON Devices.DeviceName = Actions.DeviceName INNER JOIN Modules ON Actions.Command = Modules.Command WHERE Devices.MacAddress = @mac AND Action = @action";
                        cmd.Parameters.AddWithValue("@mac", host.MAC);
                        cmd.Parameters.AddWithValue("@action", "Exit");
                        var reader = cmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            reader.Read();
                            process(reader.GetString(reader.GetOrdinal("Path")), reader.GetString(reader.GetOrdinal("Args")));
                        }
                    }
                }
            });
        }
コード例 #18
0
//    public float GetTemps()
//    {
//        return temps;
//    }
//
//    public void SetTemps(float a)
//    {
//        temps = a;
//    }

//    public float GetDistance()
//    {
//        return distance;
//    }
//
//   public void SetDistance(float a)
//    {
//        distance = a;
//    }

    void Start()
    {
        detection            = true;
        cooldown             = cooldownTime;
        smartHomeServeScript = smartHomeServer.GetComponent <SmartHomeServer> ();
    }
コード例 #19
0
ファイル: BinaryFlowMeter.cs プロジェクト: Natorkawl/shima
 void ISensorObserver.Notify()
 {
     state = !state;
     SmartHomeServer.InsertBinarySensorData(name, SensorType, state);
 }
コード例 #20
0
ファイル: ConsoleForm.cs プロジェクト: devsifi/SmartHome
 private void ConsoleForm_Load(object sender, EventArgs e)
 {
     Server = new SmartHomeServer(IPAddress.Any, 3000);
     //Server.Start();
 }