Exemplo n.º 1
0
        private void DBThread_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                string tmp = Sender.OutOfClass(Proto[i]);

                if (tmp != null && Mysql != null)
                {
                    Message.Items.Add("Sql Sending.. value is " + Proto[i] + tmp);
                    Mysql.PutQuery("update hardware set " + Proto[i] + "='" + tmp + "' where list=1");
                }
                else if (Mysql == null && isOnDB == true)
                {
                    Message.Items.Add("Mysql is closed. please turn it on!");
                    isOnDB = false;
                }
            }
            if (usingDB == false && isOnPort == true)
            {
                usingDB = true;
                if (usingDB = Sender.ManualControl(Mysql, Dongle))
                {
                    MsgEngine.Enqueue("Sending Manual code is completed.");
                }
                usingDB = false;
            }
        }
Exemplo n.º 2
0
        public bool ManualControl(UserWeb mysql, SerialPort Dongle)
        {
            reader = mysql.GetQuery("select * from manual");
            while (reader.Read())
            {
                control_unit = (string)reader[0];
            }
            reader.Close();
            if (control_unit.Equals(" "))
            {
                reader.Close();
                return(false);
            }
            if (control_unit.Equals("LmotorOn"))//on
            {
                Dongle.Write("A");
            }
            else if (control_unit.Equals("LmotorOff"))//off
            {
                Dongle.Write("B");
            }
            else if (control_unit.Equals("BmotorOn"))//on
            {
                Dongle.Write("C");
            }
            else if (control_unit.Equals("BmotorOff"))
            {
                Dongle.Write("D");
            }
            else if (control_unit.Equals("exWinOn"))//on
            {
                Dongle.Write("E");
            }
            else if (control_unit.Equals("exWinOff"))
            {
                Dongle.Write("F");
            }

            mysql.PutQuery("update manual set Mfield=' ' where list=1");
            return(true);
        }