예제 #1
0
        public PostionVar GetCurrPosEx2(PosVarType ptype)
        {
            Send(string.Format("cmd={0};a1=0;a2={1};a3=0;a4=0;a5=0;", Commands.CMD_MpGetCarPosEx, ptype == PosVarType.Robot ? 1 : 0));
            var re = string.Empty;

            do
            {
                re = ReadSck();
            } while (string.IsNullOrEmpty(re) || re == "OK\r\n");

            var currPos = CurrPosFormat(re);

            var pv = new PostionVar(decimal.Parse(currPos["(X)"]),
                                    decimal.Parse(currPos["(Y)"]),
                                    decimal.Parse(currPos["(Z)"]),
                                    decimal.Parse(currPos["(Rx)"]),
                                    decimal.Parse(currPos["(Ry)"]),
                                    decimal.Parse(currPos["(Rz)"]), 0, false);

            return(pv);
        }
예제 #2
0
        public bool SetPostion(PosVarType ptype, PostionVar pv, int pvIndex, PosType pt, int toolNo, int userFrameNo)
        {
            int nConfig;

            nConfig  = (int)pt;
            nConfig |= (pv.NoFlip ? 1 : 0) << 8;
            nConfig |= (pv.LowArm ? 1 : 0) << 9;
            nConfig |= (pv.Back ? 1 : 0) << 10;
            nConfig |= (pv.RGt180 ? 1 : 0) << 11;
            nConfig |= (pv.TGt180 ? 1 : 0) << 12;
            nConfig |= toolNo << 16;
            nConfig |= userFrameNo << 22;

            var cmd = string.Format("cmd={0};usType={1};usIndex={2};nConfig={3};ulValue1={4};ulValue2={5};ulValue3={6};ulValue4={7};ulValue5={8};ulValue6={9};ulValue7={10};ulValue8={11};",
                                    Commands.CMD_MpPutPosVarData, (int)ptype, pvIndex, nConfig,
                                    pv.sOrX, pv.lOrY, pv.uOrZ, pv.bOrRx, pv.rOrRy, pv.tOrRz, 0, 0);

            Send(cmd);
            var s = ReadSck();

            return(s.Contains("OK"));
        }