Ejemplo n.º 1
0
        /// <summary>
        /// 넥스파 가동
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartNexpa_Click(object sender, EventArgs e)
        {
            bool status = false;

            if (isRunNexpa) //가동중
            {
                isRunNexpa         = false;
                status             = pipe.StopAdapter(AdapterType.nexpa);
                btnStartNexpa.Text = "넥스파 가동";
            }
            else //정지중
            {
                isRunNexpa         = true;
                status             = pipe.StartAdapter(AdapterType.nexpa);
                btnStartNexpa.Text = "넥스파 정지";
            }

            if (status)
            {
                if (isRunNexpa) //가동중
                {
                    btnStartNexpa.Text    = "넥스파 정지";
                    lblSttNexpa.BackColor = Color.Lime;
                    lblSttNexpa.Text      = "성공";
                    lblSttNexpa.ForeColor = Color.FromArgb(64, 64, 64);
                }
                else //정지중
                {
                    btnStartNexpa.Text    = "넥스파 가동";
                    lblSttNexpa.BackColor = Color.FromArgb(224, 224, 224);
                    lblSttNexpa.ForeColor = Color.FromArgb(64, 64, 64);
                    lblSttNexpa.Text      = "대기";
                }
            }
            else
            {
                if (isRunNexpa)
                {
                    isRunHomeNet          = false;
                    btnStartNexpa.Text    = "넥스파 가동";
                    lblSttNexpa.BackColor = Color.Red;
                    lblSttNexpa.ForeColor = Color.WhiteSmoke;
                    lblSttNexpa.Text      = "실패";
                }
            }
        }
Ejemplo n.º 2
0
        public static void MainService()
        {
            //AdapterFactory adapterFactory = new AdapterFactory();
            //var test = adapterFactory.MakeServerAdapter(AdapterFactory.Adapters.HttpServer, "8080");
            //test.Run();

            //TcpHNClient client = new TcpHNClient(;
            //cli를 통해...command 와 인자를 line 으로 받는다....
            //server, client 가동.....
            //exit <==== 닫기
            //run <=== 실행
            //disc <=== 닫기
            //conn <== 열기

            NexPipe pipe = new NexPipe();


            bool bForever = true;

            while (bForever)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write("cmd : ");
                Console.ResetColor();
                string readLine = Console.ReadLine();

                if (string.IsNullOrEmpty(readLine))
                {
                    Console.WriteLine("도움말은 -help 명령어로 확인 가능합니다.");
                }
                else
                {
                    string[] cmd = readLine.Split(" ");


                    switch (cmd[0].Trim().ToLower())
                    {
                    case "init":
                        pipe.GeneratePipe();
                        break;

                    case "start":     // nexpa or homenet
                        if (cmd.Length > 1)
                        {
                            var type = (AdapterType)Enum.Parse(typeof(AdapterType), cmd[1]);
                            Console.WriteLine(pipe.StartAdapter(type));
                        }
                        else
                        {
                            Console.WriteLine("Usable command : nexpa or homenet");
                        }
                        break;

                    case "stop":
                        if (cmd.Length > 1)
                        {
                            var type = (AdapterType)Enum.Parse(typeof(AdapterType), cmd[1]);
                            Console.WriteLine(pipe.StopAdapter(type));
                        }
                        else
                        {
                            Console.WriteLine("Usable command : nexpa or homenet");
                        }
                        break;

                    case "help":     //도움말
                        DisplayHelpMessage();
                        break;

                    case "exit":     //종료
                        bForever = false;
                        break;
                    }
                }
            }
        }