Esempio n. 1
0
        /// <summary>
        ///  Replace a value list with one that has been pre-populated with possible methonds.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e)
        {
            int       index = e.ParameterIndex;
            IGH_Param param = e.Parameter;

            //Only add value list to the first input
            if (param.Name != "*Method")
            {
                return;
            }

            //Only change value lists
            var extractedItems = param.Sources.Where(p => p.Name == "Value List");

            //Set up value list
            Dictionary <string, string> options = new Dictionary <string, string>();

            foreach (int entity in typeof(MotionType).GetEnumValues())
            {
                MotionType m = (MotionType)entity;

                options.Add(m.ToString(), entity.ToString());
            }
            Grasshopper.Kernel.Special.GH_ValueList gH_ValueList = Canvas.Component.CreateValueList("Mothods", options);

            //The magic
            Canvas.Component.ChangeObjects(extractedItems, gH_ValueList);
        }
Esempio n. 2
0
        public async Task <bool> readRRSensor(TestMeViewModel b, int sec)
        {
            Activity activity = Droid.MainActivity.instance;

            _contactSensor.StartReadings();
            while (_bandState == null)
            {
            }                              //get the band state
            if (_bandState != BandContactState.Worn)
            {
                _bandState = null;
                //TODO: notify the user by sending a notification
                return(false);
            }
            _distancerSensor.StartReadings();
            while (currentMotionTyp == null)
            {
            }
            if (currentMotionTyp == MotionType.Walking || currentMotionTyp == MotionType.Jogging || currentMotionTyp == MotionType.Running)
            {
                b.StressResult = "Error: can't measure during sports activity";
                Log.Error("motion", "user is " + currentMotionTyp.ToString());
                return(false);
            }
            _rrIntervalsReadings.Clear();
            //RequestConsent();
            _rrSensor.StartReadings();
            await Task.Delay(sec * 1000);

            _rrSensor.StopReadings();
            _contactSensor.StopReadings();
            return(true);
        }
Esempio n. 3
0
 public static void Play(this AnimatorComponent self, MotionType motionType, float motionSpeed = 1f)
 {
     if (!self.HasParameter(motionType.ToString()))
     {
         return;
     }
     self.MotionType   = motionType;
     self.MontionSpeed = motionSpeed;
 }
Esempio n. 4
0
 public void Play(MotionType motionType, float motionSpeed = 1f)
 {
     if (!this.HasParameter(motionType.ToString()))
     {
         return;
     }
     this.MotionType   = motionType;
     this.MontionSpeed = motionSpeed;
 }
Esempio n. 5
0
        public static float AnimationTime(this AnimatorComponent self, MotionType motionType)
        {
            AnimationClip animationClip;

            if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
            {
                throw new Exception($"找不到该动作: {motionType}");
            }
            return(animationClip.length);
        }
Esempio n. 6
0
        public float AnimationTime(MotionType motionType)
        {
            AnimationClip animationClip;

            if (!this.animationClips.TryGetValue(motionType.ToString(), out animationClip))
            {
                throw new Exception($"找不到该动作: {motionType}");
            }
            return(animationClip.length);
        }
        internal void UpdateRobotStatus()
        {
            if (bot == null)
            {
                ResetRobotStatus();
                return;
            }

            uiContext.Post(x =>
            {
                MVector pos   = bot.GetCurrentPosition();
                string posStr = pos?.ToString(true) ?? "-";
                lbl_Status_TCP_Position_Value.Content = posStr;

                MOrientation ori = bot.GetCurrentRotation();
                string oriStr    = ori?.ToString(true) ?? "-";
                lbl_Status_TCP_Orientation_Value.Content = oriStr;

                Joints axes    = bot.GetCurrentAxes();
                string axesStr = axes?.ToString(true) ?? "-";
                lbl_Status_Axes_Value.Content = axesStr;

                ExternalAxes extax = bot.GetCurrentExternalAxes();
                bool nullext       = true;
                if (extax != null)
                {
                    for (int i = 0; i < 6; i++)
                    {
                        if (extax[i] != null)
                        {
                            nullext = false;
                            break;
                        }
                    }
                }
                lbl_Status_Ext_Axes_Value.Content = nullext ? "-" : extax.ToString(true);

                double speed    = bot.GetCurrentSpeed();
                double acc      = bot.GetCurrentAcceleration();
                string speedacc = Math.Round(speed, MMath.STRING_ROUND_DECIMALS_MM) + " mm/s / " + Math.Round(acc, MMath.STRING_ROUND_DECIMALS_MM) + " mm/s^2";
                lbl_Status_SpeedAcceleration_Value.Content = speedacc;

                double precision = bot.GetCurrentPrecision();
                lbl_Status_Precision_Value.Content =
                    Math.Round(precision, MMath.STRING_ROUND_DECIMALS_MM) + " mm";

                MotionType mtype = bot.GetCurrentMotionMode();
                lbl_Status_MotionMode_Value.Content = mtype.ToString();

                lbl_Status_Tool_Value.Content = bot.GetCurrentTool()?.name ?? "(no tool)";
            }, null);
        }
 protected virtual void SpeakMotion(MotionType value)
 {
     if (value != MotionType)
     {
         if (IsAutomove)
         {
             _notifyService.Notify("You start moving on the car");
         }
         else
         {
             _notifyService.Notify(value.ToString());
         }
     }
 }
        /// <summary>
        ///  Replace a value list with one that has been pre-populated with possible methonds.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e)
        {
            int       index = e.ParameterIndex;
            IGH_Param param = e.Parameter;

            switch (param.Name)
            {
            case "*Method":

                #region Change Value List

                //Only change value lists
                var extractedItems = param.Sources.Where(p => p.Name == "Value List");

                //Set up value list
                Dictionary <string, string> options = new Dictionary <string, string>();
                foreach (int entity in typeof(MotionType).GetEnumValues())
                {
                    MotionType m = (MotionType)entity;

                    options.Add(m.ToString(), entity.ToString());
                }
                Grasshopper.Kernel.Special.GH_ValueList gH_ValueList = Canvas.Component.CreateValueList("Mothods", options);

                //The magic
                Canvas.Component.ChangeObjects(extractedItems, gH_ValueList);
                break;

                #endregion Change Value List

            case "Plane":
                if (param.Sources.Count == 0)
                {
                    return;
                }

                foreach (var p in param.Sources)
                {
                    if (p.Name == "Panel")
                    {
                        this.c_motionType = MotionType.AbsoluteJoint;
                        return;
                    }
                }
                break;

            default:
                break;
            }
        }
Esempio n. 10
0
    public void SendDataToServer(MotionType type)
    {
        isFinished = false;
        _dataList.ForEach(p => p.Type = type.ToString());
        var o = JsonConvert.SerializeObject(_dataList);
        // Debug.Log(o);
        var request = new HTTPRequest(new Uri(SystemLogic.Instance.Config.ServerPath + "uploadData"), HTTPMethods.Post, OnRequestFinished)
        {
            RawData = Encoding.UTF8.GetBytes(o)
        };

        if (!request.HasHeader("Content-Type"))
        {
            request.SetHeader("Content-Type", "application/json");
        }
        request.Send();
        _dataList.Clear();
    }
Esempio n. 11
0
        public static void PlayInTime(this AnimatorComponent self, MotionType motionType, float time)
        {
            AnimationClip animationClip;

            if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
            {
                throw new Exception($"找不到该动作: {motionType}");
            }

            float motionSpeed = animationClip.length / time;

            if (motionSpeed < 0.01f || motionSpeed > 1000f)
            {
                Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
                return;
            }
            self.MotionType   = motionType;
            self.MontionSpeed = motionSpeed;
        }