예제 #1
0
        public override bool Execute(ScriptObject scriptObject)
        {
            try
            {
                ServiceProvider.ScriptManager.OutPut("PHDGuiding started");
                Executing = true;
                TcpClient socket = new TcpClient("localhost", 4300);
                Thread.Sleep(200);
                switch (MoveType.ToLower())
                {
                case "move 1":
                    SendReceiveTest2(socket, 3);
                    break;

                case "move 2":
                    SendReceiveTest2(socket, 4);
                    break;

                case "move 3":
                    SendReceiveTest2(socket, 5);
                    break;

                case "move 4":
                    SendReceiveTest2(socket, 12);
                    break;

                case "move 5":
                    SendReceiveTest2(socket, 13);
                    break;
                }
                ServiceProvider.ScriptManager.OutPut("PHDGuiding waiting....");
                for (int i = 1; i <= WaitTime / 1000; i++)
                {
                    if (ServiceProvider.ScriptManager.ShouldStop)
                    {
                        break;
                    }
                    Thread.Sleep(i * 1000);
                }
                socket.Close();
            }
            catch (Exception exception)
            {
                StaticHelper.Instance.SystemMessage = "PHDGuiding error " + exception.Message;
                Log.Error("PHDGuiding error", exception);
            }
            ServiceProvider.ScriptManager.OutPut("PHDGuiding done");
            return(true);
        }