Exemple #1
0
        private bool MsgProcess(string ReceiveString)
        {
            char ProtocolC = '\n';

            char[] buffer    = new char[10];
            String StrBuffer = null;

            char[] RecvMsg = ReceiveString.ToCharArray();
            if (RecvMsg.Length == 0)
            {
                return(false);
            }
            for (int i = 0, counter = 0; i < RecvMsg.Length; i++)
            {
                if (ProtocolC != '\n' && RecvMsg[i] != '|')
                {
                    buffer[counter++] = RecvMsg[i];
                }
                else if (ProtocolC != '\n' && RecvMsg[i] == '|')
                {
                    StrBuffer = new string(buffer);
                    if (Sender.InsertProtocol(ProtocolC, StrBuffer))
                    {
                        MsgEngine.Enqueue("The input value from bluetooth exists.");
                    }
                    InsEngine.Enqueue(StrBuffer);
                    ProtocolC = '\n';
                    buffer    = new char[10];
                    counter   = 0;
                }

                /* Smart Home Protocol
                 * T-거실 온도
                 * t-침실 온도
                 * H-거실 습도
                 * h-침실 습도
                 * P-주차장 차량있음
                 * U-주차장 차량없음
                 */
                if (RecvMsg[i] == 'T' || RecvMsg[i] == 'H' || RecvMsg[i] == 't' || RecvMsg[i] == 'h')
                {
                    ProtocolC = RecvMsg[i];
                }
                else if (RecvMsg[i] == 'P' || RecvMsg[i] == 'U')
                {
                    Sender.InsertProtocol_P(RecvMsg[i]);
                    buffer[counter] = RecvMsg[i];
                    InsEngine.Enqueue(new string(buffer));
                    buffer = new char[10];
                }
            }
            while (InsEngine.PickUpFeasibility() != null)
            {
                Message.Items.Add(InsEngine.Dequeue());
            }
            return(true);
        }
Exemple #2
0
 public void PutQuery(String SQL)
 {
     command = new MySqlCommand(SQL, conn);
     try
     {
         command.ExecuteNonQuery();
     }catch (MySqlException e) {
         tmp1.Enqueue(e.Message);
     }
 }
Exemple #3
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;
            }
        }
Exemple #4
0
        public UserWeb(interfaceEngine ListOfChat)
        {
            String MysqlCon = "Server=localhost; Database=UserWeb; Uid=root; Pwd=IOT123;";

            conn = new MySqlConnection(MysqlCon);
            try
            {
                tmp1 = ListOfChat;
                ListOfChat.Enqueue("Connecting to Mysql..");
                conn.Open();
            } catch (Exception ex)
            {
                ListOfChat.Enqueue(ex.ToString());
            }
            ListOfChat.Enqueue("Done.");
        }