Example #1
0
        public static ArmStringLiteral AsArmString(this ArmType type)
        {
            switch (type)
            {
            case ArmType.String:
                return(s_string);

            case ArmType.SecureString:
                return(s_secureString);

            case ArmType.Int:
                return(s_int);

            case ArmType.Bool:
                return(s_bool);

            case ArmType.Object:
                return(s_object);

            case ArmType.SecureObject:
                return(s_secureObject);

            case ArmType.Array:
                return(s_array);

            default:
                throw new InvalidOperationException($"Cannot convert unsupported ARM type: '{type}'");
            }
        }
Example #2
0
        public static string AsString(this ArmType type)
        {
            switch (type)
            {
            case ArmType.String:
                return(ArmType_String);

            case ArmType.SecureString:
                return(ArmType_SecureString);

            case ArmType.Int:
                return(ArmType_Int);

            case ArmType.Bool:
                return(ArmType_Bool);

            case ArmType.Object:
                return(ArmType_Object);

            case ArmType.SecureObject:
                return(ArmType_SecureObject);

            case ArmType.Array:
                return(ArmType_Array);

            default:
                throw new InvalidOperationException($"Cannot convert unsupported ARM type: '{type}'");
            }
        }
Example #3
0
        public static Type AsType(this ArmType armType)
        {
            switch (armType)
            {
            case ArmType.String:
                return(typeof(string));

            case ArmType.SecureString:
                return(typeof(SecureString));

            case ArmType.Int:
                return(typeof(long));

            case ArmType.Bool:
                return(typeof(bool));

            case ArmType.Object:
                return(typeof(object));

            case ArmType.SecureObject:
                return(typeof(SecureObject));

            case ArmType.Array:
                return(typeof(Array));

            default:
                throw new InvalidOperationException($"Cannot convert unsupported ARM type: '{armType}'");
            }
        }
Example #4
0
        private void GetCurrentPositon()
        {
            //get current position
            ArmType armType = ArmType.Liha;

            if (romaTeachingForm != null && romaTeachingForm.IsVisible)
            {
                armType = ArmType.Roma;
            }
            var    position = TeachingControllerDelegate.Instance.Controller.GetPosition(armType);
            double degree, clipWidth;

            degree = clipWidth = 0;
            if (armType == ArmType.Roma)
            {
                TeachingControllerDelegate.Instance.Controller.GetClipperInfo(ref degree, ref clipWidth);
                if (onPositionChanged != null)
                {
                    onPositionChanged(this, new ROMAPosition("x", position.X, position.Y, position.Z, degree, clipWidth));
                }
                return;
            }


            Debug.WriteLine("Current Position is: xyz {0}{1}{2}", position.X, position.Y, position.Z);
            xyz.X = position.X;
            xyz.Y = position.Y;
            xyz.Z = position.Z;
        }
Example #5
0
        public void StartMove(ArmType armType, WorkstationController.Hardware.Direction dir, int speedMMPerSecond)
        {
            startPosition         = GetPosition(armType);
            this.dir              = dir;
            this.armType          = armType;
            this.speedMMPerSecond = speedMMPerSecond;
            if (armType == ArmType.Roma)
            {
                GetClipperInfo(ref degree, ref clipWidth);
            }

            var eArmType = enumMapper[armType];
            //var res = MoveController.Instance.StartMove(enumMapper[armType], (Direction)dir, speedMMPerSecond);
            e_RSPErrorCode res         = e_RSPErrorCode.RSP_ERROR_NONE;
            e_CanMotorID   motorID     = e_CanMotorID.CanMotorID_Max;
            double         absPosition = 0;

            switch (dir)
            {
            case Direction.Left:
            case Direction.Right:
                motorID     = armType == ArmType.Liha ? e_CanMotorID.CanMotorID_Left_x : e_CanMotorID.CanMotorID_Right_x;
                absPosition = dir == Direction.Left ? 0 : 700;
                res         = MoveController.Instance.StartMove(eArmType, Axis.X, speedMMPerSecond, absPosition, 0);
                Debug.WriteLine(string.Format("movex result:{0}", res.ToString()));
                break;

            case Direction.Up:
            case Direction.Down:
                motorID     = armType == ArmType.Liha ? e_CanMotorID.CanMotorID_Left_y : e_CanMotorID.CanMotorID_Right_y;
                absPosition = dir == Direction.Down ? 400 : 0;
                res         = MoveController.Instance.StartMove(eArmType, Axis.Y, speedMMPerSecond, absPosition, 0);
                break;

            case Direction.ZDown:
            case Direction.ZUp:
                motorID     = armType == ArmType.Liha ? e_CanMotorID.CanMotorID_Left_z : e_CanMotorID.CanMotorID_Right_z;
                absPosition = dir == Direction.ZUp ? 0 : 300;
                res         = MoveController.Instance.StartMove(eArmType, Axis.Z, speedMMPerSecond, absPosition, 0);
                break;

            case Direction.RotateCCW:
            case Direction.RotateCW:
                this.armType = ArmType.Roma;
                motorID      = e_CanMotorID.CanMotorID_Rotate;
                absPosition  = dir == Direction.RotateCCW ? 360 : 720;
                res          = MoveController.Instance.StartMove(_eARM.右臂, Axis.R, speedMMPerSecond, absPosition, 0);
                break;

            case Direction.ClampOff:
            case Direction.ClampOn:
                this.armType = ArmType.Roma;
                motorID      = e_CanMotorID.CanMotorID_Clipper;
                absPosition  = dir == Direction.ClampOff ? 0 : 20;
                res          = MoveController.Instance.StartMove(_eARM.右臂, Axis.Clipper, speedMMPerSecond, absPosition, 0);
                break;
            }
            ThrowIfErrorHappened(res);
        }
Example #6
0
        public XYZ GetPosition(ArmType armType)
        {
            double x, y, z;

            x = y = z = 0;
            MoveController.Instance.GetCurrentPosition(enumMapper[armType], ref x, ref y, ref z);
            return(new XYZ(x, y, z));
        }
 public void StartMove(ArmType armType, Direction dir, int speedMMPerSecond)
 {
     updatePositionTimer.Start();
     Debug.WriteLine(string.Format("start move at:{0}", dir.ToString()));
     stopWatch.Restart();
     this.speed_mmPerSecond = speedMMPerSecond;
     this.dir = dir;
 }
Example #8
0
    public Sprite GetSpriteForType(ArmType type)
    {
        if (isBroken)
        {
            return(BrokenArm);
        }

        switch (type)
        {
        case ArmType.machinegun:
            return(MachineGunArm);

        case ArmType.paintgun:
            return(PaintGunArm);

        case ArmType.hammer:
            return(HammerArm);

        case ArmType.shears:
            return(ShearsArm);

        case ArmType.mop:
            return(MopArm);

        case ArmType.blade:
            return(BladeArm);

        case ArmType.roller:
            return(RollerArm);

        case ArmType.cement:
            return(CementArm);

        case ArmType.chainsaw:
            return(ChainsawArm);

        case ArmType.vacuum:
            return(VacuumArm);

        case ArmType.laser:
            return(LaserArm);

        case ArmType.twine:
            return(TwineArm);

        case ArmType.nailgun:
            return(NailgunArm);

        case ArmType.flamethrower:
            return(FlamethrowerArm);

        case ArmType.paintbrush:
            return(PaintbrushArm);
        }
        return(null);
    }
Example #9
0
        public void Move2XYZ(ArmType armType, XYZ xyz)
        {
            //    //need consider ztravel

            var err = MoveController.Instance.MoveXYZ(enumMapper[armType], xyz.X, xyz.Y, xyz.Z, MoveController.defaultTimeOut);

            if (err != e_RSPErrorCode.RSP_ERROR_NONE)
            {
                throw new CriticalException(err.ToString());
            }
        }
Example #10
0
        void inputChecker_OnStartMove(object sender, Direction dir)
        {
            ArmType armType = ArmType.Liha;

            if (romaTeachingForm != null && romaTeachingForm.IsVisible)
            {
                armType = ArmType.Roma;
            }
            TeachingControllerDelegate.Instance.Controller.StartMove(armType, dir, speed);
            updatePositionTimer.Start();
        }
        public void Move2XYZ(ArmType armType, Core.Data.XYZ xyz)
        {
            Random rnd          = new Random((int)DateTime.Now.Ticks);
            double xDiff        = xyz.X - currentPosition.X;
            double yDiff        = xyz.Y - currentPosition.Y;
            double zDiff        = xyz.Z - currentPosition.Z;
            double maxDis       = Math.Max(Math.Max(xDiff, yDiff), zDiff);
            int    milliSeconds = (int)(maxDis / 0.8);

            Thread.Sleep(milliSeconds);
            currentPosition = xyz;
        }
Example #12
0
        public static BoneType ToBoneType(this ArmType _this)
        {
            switch (_this)
            {
            case ArmType.LeftHand:
                return(BoneType.LeftHand);

            case ArmType.RightHand:
                return(BoneType.RightHand);

            default:
                throw new ArgumentException(_this.ToString());
            }
        }
Example #13
0
        public dynamic SecuritySystem([FromBody] AlexaSkillRequestModel request)
        {
            var coxHomelifeService = new CoxHomelifeService();
            CoxServiceResponse coxServiceResponse = null;

            // Check if the requesting user id is allowed to use this skill
            var intent   = request.Request.Intent.Name;
            var fromUser = request.Session.User.UserId;

            if (fromUser != _allowedAmazonUserId)
            {
                return(null);
            }

            // Check which intent the user wants and act on it
            if (intent == "DisarmIntent")
            {
                coxServiceResponse = coxHomelifeService.Disarm();
            }
            else if (intent == "ArmStayIntent")
            {
                ArmType armType = ArmType.STAY;

                coxServiceResponse = coxHomelifeService.Arm(armType);
            }
            else if (intent == "ArmNightIntent")
            {
                ArmType armType = ArmType.NIGHT;

                coxServiceResponse = coxHomelifeService.Arm(armType);
            }
            else if (intent == "ArmAwayIntent")
            {
                ArmType armType = ArmType.AWAY;

                coxServiceResponse = coxHomelifeService.Arm(armType);
            }
            else if (intent == "ZoneIntent")
            {
                var zone    = request.Request.Intent.Slots["Zone"].Value;
                var onOrOff = request.Request.Intent.Slots["OnOff"].Value;

                coxServiceResponse = coxHomelifeService.ChangeZone(zone, onOrOff);
            }

            // Create the response and return to amazon
            var alexaResponse = CreateAlexaResponseFromCoxServiceResponse(coxServiceResponse);

            return(alexaResponse);
        }
Example #14
0
    public void Copy(BotArm arm)
    {
        if (renderer == null)
        {
            renderer = GetComponent <SpriteRenderer>();
        }

        this.armType = arm.armType;
        if (this.animator)
        {
            this.animator.SetInteger("Type", (int)this.armType);
        }
        this.isBroken        = arm.isBroken;
        this.renderer.sprite = GetSprite();
    }
        public int GetXMax(ArmType armType)
        {
            int maxValue = 700;

            switch (armType)
            {
            case ArmType.Liha:
                maxValue = 700;
                break;

            case ArmType.Roma:
                maxValue = 800;
                break;
            }
            return(maxValue);
        }
Example #16
0
    public Arm(JSONObject json)
        : base(json.GetField("name").str, json.GetField("basevalue").f,
               (int)json.GetField("level").f, (int)json.GetField("levelcap").f, (int)json.GetField("tier").f)
    {
        type = parseArmType(json.GetField("type").str);

        setGrowth(json.GetField("growth").f);

        List <JSONObject> stats = json.GetField("stats").list;

        setBase(stats[0].f, stats[1].f, stats[2].f, stats[3].f, stats[4].f);

        List <JSONObject> dist = json.GetField("distribution").list;

        setDistribution(dist);
    }
 public static string ToAttributeString(this HumanoidMuscleType _this)
 {
     if (_this < HumanoidMuscleType.Root)
     {
         int delta = _this - HumanoidMuscleType.Motion;
         return(nameof(HumanoidMuscleType.Motion) + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Limbs)
     {
         int delta = _this - HumanoidMuscleType.Root;
         return(nameof(HumanoidMuscleType.Root) + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Muscles)
     {
         int      delta = _this - HumanoidMuscleType.Limbs;
         LimbType limb  = (LimbType)(delta / 7);
         return(limb.ToBoneType().ToAttributeString() + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Fingers)
     {
         int        delta  = _this - HumanoidMuscleType.Muscles;
         MuscleType muscle = (MuscleType)delta;
         return(muscle.ToAttributeString());
     }
     if (_this < HumanoidMuscleType.TDoFBones)
     {
         const int armSize = (int)FingerType.Last * (int)FingerDoFType.Last;
         const int dofSize = (int)FingerDoFType.Last;
         int       delta   = _this - HumanoidMuscleType.Fingers;
         ArmType   arm     = (ArmType)(delta / armSize);
         delta = delta % armSize;
         FingerType finger = (FingerType)(delta / dofSize);
         delta = delta % dofSize;
         FingerDoFType dof = (FingerDoFType)delta;
         return($"{arm.ToBoneType().ToAttributeString()}.{finger.ToAttributeString()}.{dof.ToAttributeString()}");
     }
     if (_this < HumanoidMuscleType.Last)
     {
         const int    TDoFSize = (int)TDoFBoneType.Last;
         int          delta    = _this - HumanoidMuscleType.TDoFBones;
         TDoFBoneType tdof     = (TDoFBoneType)(delta / TDoFSize);
         return($"{tdof.ToBoneType().ToAttributeString()}{GetTDoFTransformPostfix(delta % TDoFSize)}");
     }
     throw new ArgumentException(_this.ToString());
 }
    private void MoveArm(ArmType arm, Vector2 axis)
    {
        var controller = arm == ArmType.LeftArm ? leftArmController : rightArmController;

        var forwardTransform = camera ? camera.transform : transform;
        var right            = forwardTransform.right;
        var forward          = forwardTransform.forward;

        right   *= axis.x;
        forward *= axis.y;

        var heading = right + forward;

        heading.y = 0;
        heading  *= moveSpeed;

        controller.position += heading * Time.deltaTime;
    }
Example #19
0
    public void Init()
    {
        animator = GetComponent <Animator>();
        renderer = GetComponent <SpriteRenderer>();

        int type = Random.Range(0, 15);

        armType = (ArmType)type;

        if (animator)
        {
            animator.SetInteger("Type", type);
        }
        if (renderer)
        {
            renderer.sprite = GetSprite();
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="ModdedArmsHelper.API.CraftableModdedArm"/> class, the basic class for any arm that can be crafted at a Vehicle Upgrade Console.
        /// </summary>
        /// <param name="techTypeName">The main internal identifier for this item. Your item's <see cref="TechType"/> will be created using this name.</param>
        /// <param name="friendlyName">The name displayed in-game for this item whether in the open world or in the inventory.</param>
        /// <param name="description">The description for this item; Typically seen in the PDA, inventory, or crafting screens.</param>
        /// <param name="armType">The <see cref="ModdedArmsHelper.API.ArmType"/> parameter (Exosuit or Seamoth).</param>
        /// <param name="armTemplate">The base <see cref="ModdedArmsHelper.API.ArmTemplate"/> for cloning.</param>
        /// <param name="requiredForUnlock">The required <see cref="TechType"/> that must first be scanned or picked up to unlock the blueprint for this item. If you use fragment set this one to TechType.None</param>
        /// <param name="fragment">The <see cref="ModdedArmsHelper.API.SpawnableArmFragment"/> parameter. If you not used fragment set this one to null.</param>
        protected CraftableModdedArm(
            string techTypeName,
            string friendlyName,
            string description,
            ArmType armType,
            ArmTemplate armTemplate,
            TechType requiredForUnlock,
            SpawnableArmFragment fragment
            )
            : base(techTypeName, $"{techTypeName}.Prefab")
        {
            TechTypeName      = techTypeName;
            FriendlyName      = friendlyName;
            Description       = description;
            ArmType           = armType;
            PrefabForClone    = ArmTypes[armTemplate];
            RequiredForUnlock = requiredForUnlock;
            _Fragment         = fragment;
            ArmTemplate       = armTemplate;

            IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent);
        }
Example #21
0
 protected ArmLiteral(object value, ArmType armType)
 {
     _value  = value;
     ArmType = armType;
 }
Example #22
0
 public Arm(string name, float baseValue, int level, int levelCap, int tier, ArmType type)
     : base(name, baseValue, level, levelCap, tier)
 {
     this.type = type;
 }
 public Core.Data.XYZ GetPosition(ArmType armType)
 {
     return(currentPosition);
 }