示例#1
0
 public string Position_Set_Pos(Position_Set_Pos vEn)
 {
     if (vEn.v00.cmdName == eDev485obj.Free)
     {
         vEn.v00.cmdName = (eDev485obj)Enum.Parse(
             typeof(eDev485obj),
             vEn.GetType().Name);
     }
     return(doObjectToString(vEn));
 }
示例#2
0
        /*
         * 把需要的参数,顺序放到设备域的 bt_out数组中
         * 此函数 取 数组中的数据放到 对象中,组合为字符串
         * --- 用法比较麻烦 ---
         * int _ref = vDevNo * _faim3.sect_iDev;  // 偏移
         * _faim3.Comm_Data._bt_out[0][_ref + 1] = 12;
         * _faim3.Comm_Data._bt_out[0][_ref + 2] = X;
         * _faim3.Comm_Data._bt_out[0][_ref + 3] = Y;
         * call doProtocol_01(-1, "home_set_pos", 2)
         * ------
         */
        string doProtocol_01(int vAxisNum = -1, string vCmdName = "", int vDevNo = 0)
        {
            string _res = "";

            if (string.IsNullOrEmpty(vCmdName))
            {
                return(_res);                                 // 命令名为空
            }
            //if (vAxisNum < 0) return _res;
            int _ref = vDevNo * _faim3.sect_iDev;  // 偏移

            if (vAxisNum < 0)
            {
                vAxisNum = _faim3.Comm_Data._bt_out[0][_ref + 1]; // 无轴号,则自动取轴号
            }
            int i = 0;

            switch (vCmdName.ToLower())
            {
                #region //..
            case "home_set_pos":
                _res = home_Set_Pos(vAxisNum);
                break;

            case "home_set_posa":
                _res = home_Set_PosA(vAxisNum);
                break;

            case "motoron":
                _res = MotorOn(vAxisNum);
                break;

            case "motoroff":
                _res = MotorOff(vAxisNum);
                break;

            case "motoralarmreset":
                _res = MotorAlarmReset(vAxisNum);
                break;

            case "readstatus":
                _res = ReadStatus(vAxisNum);
                break;

            case "readpos":
                _res = ReadPOS(vAxisNum);
                break;

            case "stopmove":
                _res = StopMove(vAxisNum);
                break;

            case "position_a_move":
                _res = Position_A_Move(vAxisNum);
                break;

            case "position_r_move":
                _res = Position_R_Move(vAxisNum);
                break;

            case "setregistersub":
                SetRegisterSub _en1 = new SetRegisterSub();
                _en1.v00.cmdName = eDev485obj.SetRegisterSub;
                _en1.v01.AxisNum = vAxisNum;
                i             = _ref + 2;
                _en1.v02.Addr = _faim3.Comm_Data._bt_out[0][i++];
                _en1.v03.Acc  = _faim3.Comm_Data._bt_out[0][i++];
                _res          = SetRegisterSub(_en1);
                break;

            case "outputline":
                OutputLine _OutputLine = new OutputLine();
                _OutputLine.v00.cmdName = eDev485obj.OutputLine;
                _OutputLine.v01.AxisNum = vAxisNum;
                i = _ref + 2;
                _OutputLine.v02.InputNum  = _faim3.Comm_Data._bt_out[0][i++];
                _OutputLine.v03.Condition = _faim3.Comm_Data._bt_out[0][i++];
                _res = OutputLine(_OutputLine);
                break;

            case "seekhome":
                SeekHome _SeekHome = new SeekHome();
                _SeekHome.v00.cmdName = eDev485obj.SeekHome;
                _SeekHome.v01.AxisNum = vAxisNum;
                i = _ref + 2;
                _SeekHome.v02.OutputNum = _faim3.Comm_Data._bt_out[0][i++];
                _SeekHome.v03.Condition = _faim3.Comm_Data._bt_out[0][i++];
                _res = SeekHome(_SeekHome);
                break;

            case "home_dir":
                Home_Dir _Home_Dir = new Home_Dir();
                _Home_Dir.v00.cmdName = eDev485obj.Home_Dir;
                _Home_Dir.v01.AxisNum = vAxisNum;
                i = _ref + 2;
                _Home_Dir.v02.Acc      = _faim3.Comm_Data._bt_out[0][i++];
                _Home_Dir.v03.Dec      = _faim3.Comm_Data._bt_out[0][i++];
                _Home_Dir.v04.Vel      = _faim3.Comm_Data._bt_out[0][i++];
                _Home_Dir.v05.Location = _faim3.Comm_Data._bt_out[0][i++];
                _Home_Dir.v06.Location = _faim3.Comm_Data._bt_out[0][i++];
                _res = Home_Dir(_Home_Dir);        // 一般使用



                break;

            case "position_set_pos":
                Position_Set_Pos _Position_Set_Pos = new Position_Set_Pos();
                _Position_Set_Pos.v00.cmdName = eDev485obj.Position_Set_Pos;
                _Position_Set_Pos.v01.AxisNum = vAxisNum;
                i = _ref + 2;
                _Position_Set_Pos.v02.Acc      = _faim3.Comm_Data._bt_out[0][i++];
                _Position_Set_Pos.v03.Dec      = _faim3.Comm_Data._bt_out[0][i++];
                _Position_Set_Pos.v04.Vel      = _faim3.Comm_Data._bt_out[0][i++];
                _Position_Set_Pos.v05.Location = _faim3.Comm_Data._bt_out[0][i++];
                _Position_Set_Pos.v06.Location = _faim3.Comm_Data._bt_out[0][i++];
                _res = Position_Set_Pos(_Position_Set_Pos);
                break;
                #endregion
            }
            return(_res);
        }