예제 #1
0
 public void RotationAssist(int forceOrSpeed, int target, int leftAngle, int rightAngle)
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     //paramPackage.RotationaForce = force;
     //paramPackage.RotationSpeed = speed;
     paramPackage.RotationaForceOrSpeed = forceOrSpeed;
     paramPackage.RotationTarget = target;
     paramPackage.LeftRotationAngleLimit = leftAngle;
     paramPackage.RightRotationAngleLimit = rightAngle;
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.Rotationa));
     Thread.Sleep(10);
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Assist;
     package.CommandParam = CommandParam.Rotation;
     WriteData(CreateCommandBuffer(package));
 }
예제 #2
0
 public void PushRodStop()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.PushRodStop;
     WriteData(CreateCommandBuffer(package));
 }
예제 #3
0
 public void RotationIsotonicA()
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.Rotationa));
     Thread.Sleep(10);
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.IsotonicA2;
     package.CommandParam = CommandParam.Rotation;
     WriteData(CreateCommandBuffer(package));
 }
예제 #4
0
 public void RotationIsotonicB(int forceOrSpeed, int target, int bendAngle, int stretchAngle,bool isControl)
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     paramPackage.RotationaForceOrSpeed = forceOrSpeed;
     paramPackage.RotationTarget = target * -1;
     paramPackage.LeftRotationAngleLimit = bendAngle;
     paramPackage.RightRotationAngleLimit = stretchAngle;
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.Rotationa));
     if (isControl)
     {
         Thread.Sleep(10);
         ControlCommandPackage package = new ControlCommandPackage();
         package.CommandType = CommandType.IsotonicB;
         package.CommandParam = CommandParam.Rotation;
         WriteData(CreateCommandBuffer(package));
     }
 }
예제 #5
0
 public void BendStretchIsotonicA()
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.BendStretch));
     Thread.Sleep(10);
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.IsotonicA2;
     package.CommandParam = CommandParam.BendStretch;
     WriteData(CreateCommandBuffer(package));
 }
예제 #6
0
 public void BendStretchIsotonicB(int forceOrSpeed, int target, int bendAngle, int stretchAngle,bool isControl)
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     paramPackage.BendStretchForceOrSpeed = forceOrSpeed;
     paramPackage.BendStretchTarget = target * -1;
     //paramPackage.BendStretchForce = force;
     //paramPackage.BendStretchSpeed = speed;
     paramPackage.BendAngleLimit = bendAngle;
     paramPackage.StretchAngleLimit = stretchAngle;
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.BendStretch));
     if (isControl)
     {
         Thread.Sleep(10);
         ControlCommandPackage package = new ControlCommandPackage();
         package.CommandType = CommandType.IsotonicB;
         package.CommandParam = CommandParam.BendStretch;
         WriteData(CreateCommandBuffer(package));
     }
 }
예제 #7
0
 public void GetVersion()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Version;
     WriteData(CreateCommandBuffer(package));
 }
예제 #8
0
 public void BendStretchAssist(int forceOrSpeed, int target, int bendAngle, int stretchAngle)
 {
     ControlParamPackage paramPackage = new ControlParamPackage();
     paramPackage.BendStretchForceOrSpeed = forceOrSpeed;
     paramPackage.BendStretchTarget = target;
     //paramPackage.BendStretchForce = force;
     //paramPackage.BendStretchSpeed = speed;
     paramPackage.BendAngleLimit = bendAngle;
     paramPackage.StretchAngleLimit = stretchAngle;
     WriteData(CreateParamBuffer(paramPackage, ControlParamType.BendStretch));
     Thread.Sleep(10);
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Assist;
     package.CommandParam = CommandParam.BendStretch;
     WriteData(CreateCommandBuffer(package));
 }
예제 #9
0
 public void Reset()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Reset;
     WriteData(CreateCommandBuffer(package));
 }
예제 #10
0
 public void Homing()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.SetZero;
     WriteData(CreateCommandBuffer(package));
 }
예제 #11
0
 public void SensorInit()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.SensorInit;
     WriteData(CreateCommandBuffer(package));
 }
예제 #12
0
 public void QuickStopCmd()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.QuickStop;
     WriteData(CreateCommandBuffer(package));
 }
예제 #13
0
 public void PauseCmd()
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Pause;
     WriteData(CreateCommandBuffer(package));
 }
예제 #14
0
 public void Free2(CommandParam param)
 {
     ControlCommandPackage package = new ControlCommandPackage();
     package.CommandType = CommandType.Free2;
     package.CommandParam = param;
     WriteData(CreateCommandBuffer(package));
 }
예제 #15
0
        /// <summary>
        /// 发送字节***2015.11.17
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        private byte[] CreateCommandBuffer(ControlCommandPackage package)
        {
            byte[] result = new byte[8];
            if (package.CommandType == CommandType.Version)
            {
                result[0] = 0x81;
                result[1] = BitConverter.GetBytes(Math.Abs((int)package.CommandType))[0];
            }
            else if (package.CommandType == CommandType.PushRodUp || package.CommandType == CommandType.PushRodDown || package.CommandType == CommandType.PushRodStop)
            {
                result[0] = 0x62;
                result[1] = BitConverter.GetBytes((int)package.CommandType)[0];
            }
            else
            {
                result[0] = 0x61;
                result[1] = BitConverter.GetBytes((int)package.CommandType)[0];
                switch (package.CommandType)
                {
                    case CommandType.Assist:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.ErrorReset:
                        break;
                    case CommandType.Free:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.Free2:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.FreeConstantResistance:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.FreeCounterWeight:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.Guided:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.IsotonicA:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.IsotonicB:
                        result[2] = BitConverter.GetBytes((int)package.CommandParam)[0];
                        break;
                    case CommandType.Reset:
                        break;
                    case CommandType.SensorInit:
                        break;
                    case CommandType.Pause:
                        break;
                }
            }

            return result;
        }