コード例 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            g_frmMain   = new frmMain();
            data        = new Database();
            server      = new TcpIpServer();
            formRobot_1 = new formRobotCom_1();
            formRobot_2 = new formRobotCom_2();

            Application.Run(g_frmMain);
            //Application.Run(formRobot_1);
            //Application.Run(formRobot_2);
        }
コード例 #2
0
        //static void Woman_InOrder(NetworkStream stream)
        //{
        //    int length = 0;
        //    string data = "";
        //    byte[] bytes = new byte[256];
        //    //string cmd_in_order = "IN_ORDER";
        //    //string productNo = "";
        //    //string in_prod_pos = "";

        //    if (stream.DataAvailable != true)
        //        return;

        //    while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
        //    {
        //        data = Encoding.Default.GetString(bytes, 0, length);
        //        Program.g_frmMain.AddConsoleOutput(String.Format("수신 : {0}", data));
        //        //string[] sRcvMessage = data.Split(new string[] { "{{$", "=", "[!]", "$}}", "MSGID", "CMD", "NUMBER" }, StringSplitOptions.RemoveEmptyEntries);

        //        //productNo = sRcvMessage[2];

        //        //if (sRcvMessage[2] == WOMAN1001) in_prod_pos = WSTG01;
        //        //else if (sRcvMessage[2] == WOMAN1002) in_prod_pos = WSTG02;
        //        //else if (sRcvMessage[2] == WOMAN1003) in_prod_pos = WSTG03;

        //        //SendCmdToRobot(ref stream, cmd_in_order, in_prod_pos);
        //        //Woman_Order_Rev(ref stream);

        //        //Program.data.insertValue(productNo,in_prod_pos);
        //        //Program.g_frmMain.AddConsoleOutput("입고기록 삽입");

        //    }
        //}

        //public static void Woman_Order_Rev(ref NetworkStream stream, string product_code, string out_product_position)
        //{
        //    int length = 0;
        //    string data = "";
        //    byte[] bytes = new byte[256];

        //    try
        //    {
        //        while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
        //        {
        //            data = Encoding.Default.GetString(bytes, 0, length);
        //            // string[] sRcvMessage = data.Split(new string[] { "{{$", "=", "[!]", "$}}", "MSGID", "CMD", "POS", "STATE"}, StringSplitOptions.RemoveEmptyEntries);

        //            if (data.Contains("COMPLETE_OUTPUT"))
        //            {
        //                Program.g_frmMain.AddConsoleOutput("작업 완료/출고 완료");
        //                Program.data.RowDelete();
        //                Program.g_frmMain.AddConsoleOutput("주문 테이블 삭제");
        //                break;
        //            }
        //            //if (data.Contains("COMPLETE_INPUT"))
        //            //{
        //            //    Program.g_frmMain.AddConsoleOutput("작업 완료/입고 완료");
        //            //    break;
        //            //}

        //            //foreach (var k in dicWomanLog.Keys)
        //            //{
        //            //    if (data.Contains(k))
        //            //    {
        //            //        Program.g_frmMain.AddConsoleOutput(dicWomanLog[k]);
        //            //    }
        //            //}

        //            //foreach (var p in dicWomanPos)
        //            //{
        //            //	if (data.Contains(p))
        //            //	{
        //            //		sPosition = p;
        //            //	}
        //            //}

        //        }
        //    }
        //    catch( Exception ex )
        //    {

        //    }


        //}

        private static void RobotComProc_Woman()
        {
            TcpClient client = TcpIpServer.GetWomanClient();

            Program.g_frmMain.AddConsoleOutput(string.Format("Woman 로봇 :{0}", ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString()));
            NetworkStream stream = client.GetStream();


            while (true)
            {
                Thread.Sleep(1);

                Woman_OutOrder(stream);

                //Woman_InOrder(stream);
            }
            //stream.Close();
            //client.Close();
        }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     TcpIpServer.SendCmdToWoman("MOVE", "LEFT");
 }
コード例 #4
0
 private void Output_Click(object sender, EventArgs e)
 {
     TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
 }
コード例 #5
0
        private void tmr_man_seq_Tick(object sender, EventArgs e)
        {
            switch (man_seq_step)
            {
            case 0:
            {
                if (target_man.Route == null || target_man.Dest == null)
                {
                    tmr_man_seq.Enabled = false;
                    tmr_man_seq.Stop();
                }

                if (target_man.Route == "" || target_man.Dest == "")
                {
                    tmr_man_seq.Enabled = false;
                    tmr_man_seq.Stop();
                }

                man_seq_step = 5;
            }
            break;

            case 5:
            {
                if (man_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "UP");
                }
                else if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "DOWN");
                }

                man_tickcount_ms = Environment.TickCount;
                man_seq_step     = 6;
            }
            break;

            case 6:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > man_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                    man_seq_step = 20;
                }
            }
            break;

            case 20:
            {
                if (man_route_code == target_man.Route)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "STOP");
                    man_seq_step = 30;
                }
            }
            break;

            case 30:
            {
                TcpIpServer.SendCmdToMan("MOVE", "LEFT_TURN_90");
                man_seq_step = 35;
            }
            break;

            case 35:
            {
                TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                man_seq_step = 40;
            }
            break;

            case 40:
            {
                if (man_route_code == target_man.Dest)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "STOP");
                    man_seq_step = 50;
                }
            }
            break;

            case 50:
            {
                if (man_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "DOWN");
                }
                else if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "UP");
                }

                man_tickcount_ms = Environment.TickCount;
                man_seq_step     = 60;
            }
            break;

            case 60:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > man_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "LEFT_TURN_180");
                    man_seq_step = 65;
                }
            }
            break;

            case 65:
            {
                TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                man_seq_step = 70;
            }
            break;

            case 70:
            {
                if (man_route_code == target_man.Route)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "STOP");
                    man_seq_step = 75;
                }
            }
            break;

            case 75:
            {
                TcpIpServer.SendCmdToMan("MOVE", "LEFT_TURN_90");
                man_seq_step = 80;
            }
            break;

            case 80:
            {
                TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                man_seq_step = 90;
            }
            break;

            case 90:
            {
                if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    if (man_route_code == target_man.output)
                    {
                        TcpIpServer.SendCmdToMan("MOVE", "STOP");
                        man_seq_step = 100;
                    }
                }
                else if (man_INPUT_OUTPUT == "INPUT")
                {
                    if (man_route_code == target_man.output)
                    {
                        TcpIpServer.SendCmdToMan("MOVE", "STOP");
                        man_seq_step = 100;
                    }
                }
            }
            break;

            case 100:
            {
                if (man_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "LEFT_TURN_90");
                    man_seq_step = 110;
                }
                else if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "DOWN");
                    man_tickcount_ms = Environment.TickCount;
                    man_seq_step     = 105;
                }
            }
            break;

            case 105:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > man_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToMan("MOVE", "LEFT_TURN_90");
                    man_seq_step = 110;
                }
            }
            break;

            case 110:
            {
                if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                    man_seq_step = 120;
                }
                else if (man_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToMan("MOVE", "FORWARD");
                    man_seq_step = 120;
                }
            }
            break;

            case 120:
            {
                if (man_INPUT_OUTPUT == "INPUT")
                {
                    if (man_route_code == target_man.input)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                        man_seq_step = 121;
                    }
                }
                else if (man_INPUT_OUTPUT == "OUTPUT")
                {
                    if (man_route_code == target_man.input)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");

                        TcpIpServer.SendCmdToWoman("MOVE", "LEFT_TURN_90");

                        Program.g_frmMain.AddConsoleOutput("작업 완료/출고 완료");

                        tmr_man.Enabled = false;
                        tmr_man.Stop();

                        tmr_man_seq.Enabled = false;
                        tmr_man_seq.Stop();
                    }
                }
            }
            break;

            case 121:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "LEFT_TURN_90");
                Program.g_frmMain.AddConsoleOutput("작업 완료/입고 완료");
                tmr_man_seq.Enabled = false;
                tmr_man_seq.Stop();
            }
            break;
            }
        }
コード例 #6
0
        private void tmr_woman_seq_Tick(object sender, EventArgs e)
        {
            switch (woman_seq_step)
            {
            case 0:
            {
                if (target_woman.Route == null || target_woman.Dest == null)
                {
                    tmr_woman_seq.Enabled = false;
                    tmr_woman_seq.Stop();
                }

                if (target_woman.Route == "" || target_woman.Dest == "")
                {
                    tmr_woman_seq.Enabled = false;
                    tmr_woman_seq.Stop();
                }

                woman_seq_step = 5;
            }
            break;

            case 5:
            {
                if (woman_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "UP");
                }
                else if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "DOWN");
                }

                woman_tickcount_ms = Environment.TickCount;
                woman_seq_step     = 6;
            }
            break;

            case 6:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > woman_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                    woman_seq_step = 20;
                }
            }
            break;

            case 20:
            {
                if (woman_route_code == target_woman.Route)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                    woman_seq_step = 30;
                }
            }
            break;

            case 30:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");
                woman_seq_step = 35;
            }
            break;

            case 35:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                woman_seq_step = 40;
            }
            break;

            case 40:
            {
                if (woman_route_code == target_woman.Dest)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                    woman_seq_step = 50;
                }
            }
            break;

            case 50:
            {
                if (woman_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "DOWN");
                }
                else if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "UP");
                }

                woman_tickcount_ms = Environment.TickCount;
                woman_seq_step     = 60;
            }
            break;

            case 60:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > woman_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "LEFT_TURN_180");
                    woman_seq_step = 65;
                }
            }
            break;

            case 65:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                woman_seq_step = 70;
            }
            break;

            case 70:
            {
                if (woman_route_code == target_woman.Route)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                    woman_seq_step = 75;
                }
            }
            break;

            case 75:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");
                woman_seq_step = 80;
            }
            break;

            case 80:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                woman_seq_step = 90;
            }
            break;

            case 90:
            {
                if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    if (woman_route_code == target_woman.output)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                        woman_seq_step = 100;
                    }
                }
                else if (woman_INPUT_OUTPUT == "INPUT")
                {
                    if (woman_route_code == target_woman.output)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                        woman_seq_step = 100;
                    }
                }
            }
            break;

            case 100:
            {
                if (woman_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");
                    woman_seq_step = 110;
                }
                else if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "DOWN");
                    woman_tickcount_ms = Environment.TickCount;
                    woman_seq_step     = 105;
                }
            }
            break;

            case 105:
            {
                int now_tickcount = Environment.TickCount;
                if (now_tickcount > woman_tickcount_ms + 3000)
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");
                    woman_seq_step = 110;
                }
            }
            break;

            case 110:
            {
                if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                    woman_seq_step = 120;
                }
                else if (woman_INPUT_OUTPUT == "INPUT")
                {
                    TcpIpServer.SendCmdToWoman("MOVE", "FORWARD");
                    woman_seq_step = 120;
                }
            }
            break;

            case 120:
            {
                if (woman_INPUT_OUTPUT == "INPUT")
                {
                    if (woman_route_code == target_woman.input)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                        woman_seq_step = 121;
                        Program.g_frmMain.AddConsoleOutput("작업 완료/입고 완료");

                        //Program.data.insertValue(woman_product_code, target_woman.Dest);
                        //Program.g_frmMain.AddConsoleOutput("입고기록 삽입");

                        //TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");

                        //tmr_woman_seq.Enabled = false;
                        //tmr_woman_seq.Stop();
                    }
                }
                else if (woman_INPUT_OUTPUT == "OUTPUT")
                {
                    if (woman_route_code == target_woman.input)
                    {
                        TcpIpServer.SendCmdToWoman("MOVE", "STOP");
                        TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");

                        tmr_woman_seq.Enabled = false;
                        tmr_woman_seq.Stop();

                        Program.g_frmMain.AddConsoleOutput("작업 완료/출고 완료");
                        Program.data.RowDelete();
                        Program.g_frmMain.AddConsoleOutput("주문 테이블 삭제");

                        Program.data.insertValue(Output_Log, woman_product_code, target_woman.Dest);
                        Program.g_frmMain.AddConsoleOutput("출고기록 삽입");

                        tmr_woman.Enabled = false;
                        tmr_woman.Stop();
                    }
                }
            }
            break;

            case 121:
            {
                TcpIpServer.SendCmdToWoman("MOVE", "RIGHT_TURN_90");

                Program.g_frmMain.AddConsoleOutput("작업 완료/입고 완료");

                Program.data.insertValue(Input_Log, woman_product_code, target_woman.Dest);
                Program.g_frmMain.AddConsoleOutput("입고기록 삽입");

                tmr_woman_seq.Enabled = false;
                tmr_woman_seq.Stop();
            }
            break;
            }
        }