public void MultiTargetMove(
     int[] targetXList,
     int[] targetYList,
     int[] targetAngleList,
     Cube.TargetRotationType[] multiRotationTypeList,
     int configID,
     int timeOut,
     Cube.TargetMoveType targetMoveType,
     int maxSpd,
     Cube.TargetSpeedType targetSpeedType,
     Cube.MultiWriteType multiWriteType
     )
 {
     DelayCommand(() => impl.MultiTargetMove(targetXList, targetYList, targetAngleList, multiRotationTypeList, configID, timeOut, targetMoveType, maxSpd, targetSpeedType, multiWriteType));
 }
Exemplo n.º 2
0
        // COMMAND API
        public override void MultiTargetMove(
            int[] targetXList,
            int[] targetYList,
            int[] targetAngleList,
            Cube.TargetRotationType[] multiRotationTypeList,
            int configID,
            int timeOut,
            Cube.TargetMoveType targetMoveType,
            int maxSpd,
            Cube.TargetSpeedType targetSpeedType,
            Cube.MultiWriteType multiWriteType
            )
        {
#if !RELEASE
            if (targetXList.Length == 0 || targetYList.Length == 0 || targetAngleList.Length == 0 ||
                !(targetXList.Length == targetYList.Length && targetYList.Length == targetAngleList.Length))
            {
                Debug.LogErrorFormat("[Cube.TargetMove]座標・角度リストのサイズが不一致または0. targetXList.Length={0}, targetYList.Length={1}, targetAngleList.Length={2}", targetXList.Length, targetYList.Length, targetAngleList.Length);
            }
            if (255 < configID)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]制御識別値範囲を超えました. configID={0}", configID);
            }
            if (255 < timeOut)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]制御時間範囲を超えました. timeOut={0}", timeOut);
            }
            if (this.maxMotor < maxSpd)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]速度範囲を超えました. maxSpd={0}", maxSpd);
            }
#endif
            MotorMultiTargetCmd cmd = new MotorMultiTargetCmd();
            cmd.xs = Array.ConvertAll(targetXList, new Converter <int, ushort>(x => (ushort)(x == -1?65535:Mathf.Clamp(x, 0, 65534))));
            if (cmd.xs.Length == 0)
            {
                return;
            }
            cmd.xs = cmd.xs.Take(29).ToArray();
            cmd.ys = Array.ConvertAll(targetYList, new Converter <int, ushort>(x => (ushort)(x == -1?65535:Mathf.Clamp(x, 0, 65534))));
            if (cmd.ys.Length == 0)
            {
                return;
            }
            cmd.ys   = cmd.ys.Take(29).ToArray();
            cmd.degs = Array.ConvertAll(targetAngleList, new Converter <int, ushort>(x => (ushort)x));
            if (cmd.degs.Length == 0)
            {
                return;
            }
            cmd.degs            = cmd.degs.Take(29).ToArray();
            cmd.rotTypes        = multiRotationTypeList != null? multiRotationTypeList : new Cube.TargetRotationType[cmd.xs.Length];
            cmd.configID        = (byte)Mathf.Clamp(configID, 0, 255);
            cmd.timeOut         = (byte)Mathf.Clamp(timeOut, 0, 255);
            cmd.maxSpd          = (byte)Mathf.Clamp(maxSpd, 0, this.maxMotor);
            cmd.targetMoveType  = targetMoveType;
            cmd.targetSpeedType = targetSpeedType;
            cmd.multiWriteType  = multiWriteType;
            cmd.tRecv           = Time.time;

            MotorSetCmd(MotorCmdType.MotorMultiTargetCmd, cmd);
        }