Example #1
0
        //解析远程指令
        public void ResolveCmds(string msg)
        {
            try
            {
                string   deviceType, cmd, pos, step, temp, ismoving, lt;
                string[] cmdList = msg.Split(',');
                string   reply   = "";
                deviceType = cmdList[0];
                if (cmdList.Length < 3)
                {
                    return;
                }
                if (deviceType != "F")
                {
                    return;
                }
                cmd = cmdList[1];
                lt  = cmdList.Last();

                if (cmd == "MOVE")
                {
                    pos = cmdList[2];
                    //control device
                    m_focUser.FocuserMoveToPos(Convert.ToDouble(pos));
                    //send reply message
                    reply  = "R" + string.Join(",", cmdList, 0, cmdList.Length - 1);
                    reply += "," + "0" + "," + lt;
                    SendMessage(reply);
                }
                else if (cmd == "STOP")
                {
                    //control device
                    m_focUser.FocuserStop();

                    //send reply message
                    reply  = "R" + string.Join(",", cmdList, 0, cmdList.Length - 1);
                    reply += "," + "0" + "," + lt;
                    SendMessage(reply);
                }
                else if (cmd == "STEP")
                {
                    step = cmdList[2];
                    //control device
                    m_focUser.FocuserStepMove(Convert.ToDouble(step));
                    //send reply message
                    reply  = "R" + string.Join(",", cmdList, 0, cmdList.Length - 1);
                    reply += "," + "0" + "," + lt;
                    SendMessage(reply);
                }
                else if (cmd == "STATUS")
                {
                    //control device
                    pos      = m_focUser.GetCurPos().ToString("f3");
                    temp     = m_focUser.GetCurTemp().ToString("f1");
                    ismoving = (m_focUser.GetMoveStatus() ? 1 : 0).ToString();
                    //send reply message
                    reply  = "R" + string.Join(",", cmdList, 0, cmdList.Length - 1);
                    reply += "," + pos;
                    reply += "," + temp;
                    reply += "," + ismoving;
                    reply += "," + lt;
                    SendMessage(reply);
                }
                Console.WriteLine("send: {0}", reply);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("cmds error: {0}", ex.Message);
            }
        }
Example #2
0
 private void buttonFocusMove_Click(object sender, EventArgs e)
 {
     focuserUser.FocuserMoveToPos(
         Convert.ToDouble(textBoxFocusSetPos.Text));
 }