public static void Line1_Insert(ref DB_TBL_LINE1 Line1) // Model Insert 메소드 { conn.Open(); // Mysql Open string Line1_Insert_Sql = "INSERT INTO TBL_LINE (_id, aname, state, working_lot, line_temp, line_humidity) VALUES('" + Line1._Id + "','" + Line1.Name + "','" + Line1.State + "','" + Line1.Working_Lot + "','" + Line1.Line_Temp + "','" + Line1.Line_Humidity + "');"; // Insert 쿼리문 MySqlCommand Command_Line1_Insert = new MySqlCommand(Line1_Insert_Sql, conn); // Insert Command문 Command_Line1_Insert.ExecuteNonQuery(); // Insert 실행 conn.Close(); // mysql Close }
public static void Line_Update3(ref DB_TBL_LINE1 line) { conn.Open(); string Line1_State_Update_Sql0 = "update TBL_LINE set _id = null, oper_name = null, state = 'wating' where line_id = '" + line.Line_id + "';"; MySqlCommand Command_Line1_State_Update0 = new MySqlCommand(Line1_State_Update_Sql0, conn); Command_Line1_State_Update0.ExecuteNonQuery(); conn.Close(); }
public static void Line_Update2(ref DB_TBL_LINE1 line) { conn.Open(); string Line1_State_Update_Sql0 = "update TBL_LINE set line_temp = '" + line.Line_Temp + "', line_humidity = '" + line.Line_Humidity + "' " + "where line_id = '" + line.Line_id + "';"; MySqlCommand Command_Line1_State_Update0 = new MySqlCommand(Line1_State_Update_Sql0, conn); Command_Line1_State_Update0.ExecuteNonQuery(); conn.Close(); }
public static void Line_Update(ref DB_TBL_LINE1 line) // Line1 State 작업중 메소드 { conn.Open(); string Line1_State_Update_Sql0 = "update TBL_LINE set _id = '" + line._Id + "', oper_name = '" + line.Oper_name + "'," + "state = 'working' where line_id = '" + line.Line_id + "';"; MySqlCommand Command_Line1_State_Update0 = new MySqlCommand(Line1_State_Update_Sql0, conn); Command_Line1_State_Update0.ExecuteNonQuery(); conn.Close(); }
} // lot 삭제 public void Proc_req_line_update(string[] receive_data_division, ref NetworkStream stream) { DB_TBL_LINE1 Line = new DB_TBL_LINE1(receive_data_division[2], receive_data_division[3], receive_data_division[4], "", "", "", "", ""); DB_MGR.Line_Update(ref Line); string send_data = "line 변경"; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); } // 작업시작시 line 생성
} // Pi Server Open public void Server_Open() { server.Start(); StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); sb.Append("Aria Project Server Open" + "\n"); fm.richTextBox1.Text = sb.ToString(); while (true) { TcpClient client = server.AcceptTcpClient(); ((IPEndPoint)client.Client.RemoteEndPoint).ToString(); NetworkStream stream = client.GetStream(); int length; string receive_data = null; // 클라이언트로부터 수신되는 값이 저장 될 변수 string send_data = null; // 클라이언트에게 송신할 값이 저장 될 변수 byte[] bytes = new byte[1024]; length = stream.Read(bytes, 0, bytes.Length); // 데이터 수신 (byte 형식으로) receive_data = ""; // 수신 될 값이 저장 될 string 변수 try { receive_data = Encoding.UTF8.GetString(bytes, 0, length); // byte 형식으로 받은 데이터를 string으로 변환 sb.Append(receive_data + "///" + DateTime.Now.ToString("yyyy년 MM월 dd일 HH:mm:ss") + "///" + ((IPEndPoint)client.Client.RemoteEndPoint).ToString() + "\n"); fm.richTextBox1.Text = sb.ToString(); if (receive_data.Substring(0, 2) == "{{") { int nLen = receive_data.Length; // 받은 data의 길이 nLen 변수에 저장 string sMsgBody = receive_data.Substring(3, nLen - 6); // receive_data 자르기 string[] receive_data_division = sMsgBody.Split(new char[] { ',' }); // receive_data , 기준으로 자르기 if (receive_data_division[1] == "req_user_log_in") // user_login 프로토콜 { Proc_req_user_login(receive_data_division, ref stream); } //else if (receive_data_division[1] == "req_log_in") // 로그인 폼 //{ // Proc_req_log_in(receive_data_division, ref stream); //} else if (receive_data_division[1] == "req_user_select") // 유저 검색 { if (receive_data_division[2] == "0") // 유저 전체 검색 { Proc_req_user_all_select(receive_data_division, ref stream); } else if (receive_data_division[2] == "1") // 유저 부분 검색 { Proc_req_user_select(receive_data_division, ref stream); } } else if (receive_data_division[1] == "req_user_update") // 유저 생성 & 유저 변경 { if (receive_data_division[8] != "변경") // 유저 생성 { Proc_req_user_create(receive_data_division, ref stream); } else if (receive_data_division[8] == "변경") // 유저 변경 { Proc_req_user_update(receive_data_division, ref stream); } } else if (receive_data_division[1] == "req_user_delete") // 유저 삭제 { if (receive_data_division[2] == "전부 삭제") // 유저 전체 삭제 { Proc_req_user_all_delete(receive_data_division, ref stream); } else // 유저 부분 삭제 { Proc_req_user_delete(receive_data_division, ref stream); } } else if (receive_data_division[1] == "req_model_select") // 모델 검색 { if (receive_data_division[2] == "0") // 모델 전체 검색 { Proc_req_model_all_select(receive_data_division, ref stream); } else if (receive_data_division[2] == "1") // 모델 부분 검색 { Proc_req_model_select(receive_data_division, ref stream); } } else if (receive_data_division[1] == "req_model_create") // 모델 생성 & 수정 { Proc_req_model_create(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_model_update") { Proc_req_model_updata(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_model_delete") // 모델 삭제 { Proc_req_model_delete(receive_data_division, ref stream); } // lot 관리 else if (receive_data_division[1] == "req_lot_select") // lot 전체 검색 { Proc_req_lot_all_select(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_lot_select1") // lot start 시간 update { Proc_req_lot_all_select1(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_lot_update") // lot 생성 / 수정 { Proc_req_lot_create(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_lot_delete") // lot 삭제 { Proc_req_lot_delete(receive_data_division, ref stream); } // 라인 관리 else if (receive_data_division[1] == "req_line_select") // 라인 검색 { } else if (receive_data_division[1] == "req_line_update") // 라인 생성, 수정 { Proc_req_line_update(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_line_update2") { try { DB_TBL_LINE1 Line = new DB_TBL_LINE1(); Line.Line_id = receive_data_division[2]; Line.Line_Temp = receive_data_division[3]; Line.Line_Humidity = receive_data_division[4]; DB_MGR.Line_Update2(ref Line); send_data = receive_data_division[2].Length.ToString() + receive_data_division[3].Length.ToString() + receive_data_division[4].Length.ToString() + "\n" + receive_data_division[2] + "," + receive_data_division[3] + "," + receive_data_division[4]; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox1.Text = send_data; } catch (Exception ege) { byte[] Response_Data = Encoding.Default.GetBytes(ege.ToString()); stream.Write(Response_Data, 0, Response_Data.Length); } } else if (receive_data_division[1] == "req_line_update3") { DB_TBL_LINE1 Line = new DB_TBL_LINE1(); Line.Line_id = receive_data_division[2]; DB_MGR.Line_Update3(ref Line); send_data = "Line 종료 완료"; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); } else if (receive_data_division[1] == "req_line_delete") // 라인 삭제 { } else if (receive_data_division[1] == "req_products_update") // products 작업전 생성 { Proc_req_products_create(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_products_update2") { Proc_req_products_update2(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_products_update3") { Proc_req_products_update3(receive_data_division, ref stream); } else if (receive_data_division[1] == "S2F41") // pi에 보낼 정보 저장 { Proc_Pi_info(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_pi_ceid1") { Proc_req_pi_ceid1(receive_data_division, ref stream); } else if (receive_data_division[1] == "req_pi_ceid4") { if (Pi.Ceid4_index != 4) { send_data = "ceid4 안들어옴"; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); } else { send_data = "ceid4 들어옴"; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); Pi.Ceid4_index = 0; } } else { send_data = "이상한 값이 들어왔습니다."; byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); } fm.richTextBox2.Text = send_data; } else if (receive_data.Substring(0, 2) == "<S") // Pi 데이터가 들어왔을 시 { MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(receive_data)); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(ms); XmlNodeList HEAD_IN = xmldoc.GetElementsByTagName("HEAD"); XmlNodeList BODY_IN = xmldoc.GetElementsByTagName("BODY"); string Sys = ""; string CMd = ""; string Str = ""; string Fun = ""; string CEID = ""; string QRCode = ""; // Head foreach (XmlNode node in HEAD_IN) { Sys = node["SystemByte"].InnerText; // SystemBytem CMd = node["CMD"].InnerText; // CMD Str = node["Stream"].InnerText; // Stream Fun = node["Function"].InnerText; // Fucntion } if (Str == "6" && Fun == "11") { foreach (XmlNode node in BODY_IN) { CEID = node["CEID"].InnerText; // CEID } if (CEID == "1") { XmlNodeList VARIABLES = xmldoc.GetElementsByTagName("VARIABLES"); foreach (XmlNode node in VARIABLES) { Pi.Product_number = node["Product_number"].InnerText; Pi.Model_name = node["Model_name"].InnerText; Pi.Prod_Percent = node["Prod_Percent"].InnerText; //Model_humid = node["Model_humid"].InnerText; Pi.Result = node["Result"].InnerText; Pi.Fail_reason = node["Fail_reason"].InnerText; //QRCode = node["QRCode"].InnerText; Pi.CV_move_state = node["CV_move_state"].InnerText; Pi.Robot_gripper_state = node["Robot_gripper_state"].InnerText; send_data = Pi.Product_number + "," + Pi.Model_name + "," + Pi.Result + "," + Pi.Fail_reason + "," + Pi.CV_move_state + "," + Pi.Robot_gripper_state; //byte[] Response_Data = Encoding.UTF8.GetBytes(send_data); byte[] Response_Data = Encoding.Default.GetBytes(send_data); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox2.Text = Pi.Product_number + "," + Pi.Model_name + "," + Pi.Result + "," + Pi.Fail_reason + "," + Pi.CV_move_state + "," + Pi.Robot_gripper_state; } Pi.Ceid1_index = 1; } else if (CEID == "2") { byte[] Response_Data = Encoding.Default.GetBytes("2받음"); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox1.Text = "2받음"; } else if (CEID == "3") { byte[] Response_Data = Encoding.Default.GetBytes("3받음"); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox1.Text = "3받음"; } else if (CEID == "4") { Pi.Ceid4_index = 1; XmlNodeList VARIABLES = xmldoc.GetElementsByTagName("VARIABLES"); foreach (XmlNode node in VARIABLES) { Pi.temp = node["Temp"].InnerText; Pi.humid = node["Humid"].InnerText; byte[] Response_Data = Encoding.Default.GetBytes(Pi.temp + "," + Pi.humid); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox1.Text = Pi.temp + Pi.humid; } } } else { byte[] Response_Data = Encoding.Default.GetBytes("아무것도 안받음"); stream.Write(Response_Data, 0, Response_Data.Length); fm.textBox1.Text = "아무것도 안받음"; }/* * // Body * foreach (XmlNode node in BODY_IN) * { * ACKC6 = node["ACKC6"].InnerText; // ACKC6 * } * //fm.textBox3.Text = receive_data + Req_User_Log_In.level; * * string aa = "aa = " + xmldoc.DocumentElement.OuterXml;*/ //fm.textBox3.Text = aa + receive_data.Length; } else if (receive_data == "value = ?") // Pi에서 작업시작을 받는 부분 { if (Pi_on != 1) // 클라이언트에서 작업을 보낼경우 1 아닐경우 0 { Proc_S2F41_receive_false(ref stream); } else if (Pi_on == 1) { Proc_S2F41_receive_true(ref stream); } } } catch (Exception error) { byte[] Response_Data = Encoding.Default.GetBytes(error.Message); stream.Write(Response_Data, 0, Response_Data.Length); } } } // Client Server Open