Exemplo n.º 1
0
        internal void UpdateRobotStatus()
        {
            if (bot == null)
            {
                ResetRobotStatus();
                return;
            }

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

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

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

                Machina.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, Machina.Geometry.STRING_ROUND_DECIMALS_MM) + " mm/s / " + Math.Round(acc, Machina.Geometry.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, Machina.Geometry.STRING_ROUND_DECIMALS_MM) + " mm";

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

                lbl_Status_Tool_Value.Content = bot.GetCurrentTool()?.name ?? "(no tool)";
            }, null);
        }
Exemplo n.º 2
0
        public static void OnMotionCursorUpdated(object sender, EventArgs e)
        {
            Robot r = sender as Robot;

            Machina.Vector   p   = r.GetCurrentPosition();
            Machina.Rotation rot = r.GetCurrentRotation();
            Joints           j   = r.GetCurrentAxes();

            if (p != null && rot != null)
            {
                wssv.WebSocketServices.Broadcast($"{{\"msg\":\"pose\",\"data\":[{p.X},{p.Y},{p.Z},{rot.Q.W},{rot.Q.X},{rot.Q.Y},{rot.Q.Z}]}}");
            }
            else if (j != null)
            {
                wssv.WebSocketServices.Broadcast($"{{\"msg\":\"joints\",\"data\":[{j.J1},{j.J2},{j.J3},{j.J4},{j.J5},{j.J6}]}}");
            }
        }