Beispiel #1
0
    /// <summary>
    /// Returns true during the frame the axis is no longer "pressed", which is if the absolute value of this axis is greater than a certain threshold.
    /// </summary>
    /// <param name="axis"></param>
    /// <returns></returns>
    public bool Released(CAxis axis)
    {
        bool pressedNow       = Mathf.Abs(Axis[(int)axis]) > AxisPressedThreshold;
        bool pressedLastFrame = Mathf.Abs(LastAxis[(int)axis]) > AxisPressedThreshold;

        return(!pressedNow && pressedLastFrame);
    }
Beispiel #2
0
 private void PlayerColumn(PlayerIndex id, int x)
 {
     GUI.contentColor = Color.white;
     GUI.Label(new Rect(x, 20, 100, 20), "Player " + id);
     if (id != PlayerIndex.Any)
     {
         GUI.Label(new Rect(x, 40, 100, 20), GamePad.GetMapping(id).Controller.name);
     }
     for (CButton btn = CButton.A; btn <= CButton.RS; btn++)
     {
         if (GamePad.GetButton(btn, id))
         {
             GUI.contentColor = Color.green;
         }
         else
         {
             GUI.contentColor = Color.white;
         }
         GUI.Label(new Rect(x, 60 + 20 * (int)btn, 40, 20), btn.ToString());
     }
     for (CAxis axis = CAxis.LX; axis <= CAxis.DY; axis++)
     {
         float value = GamePad.GetAxis(axis, id);
         if (Mathf.Abs(value) > 0)
         {
             GUI.contentColor = Color.green;
         }
         else
         {
             GUI.contentColor = Color.white;
         }
         GUI.Label(new Rect(x + 40, 60 + 20 * (int)axis, 80, 20), axis.ToString() + " " + value.ToString("F"));
     }
 }
        /// <summary>
        /// Handles the DPad input. If a button was pressed, <see cref="AxisMapping.AxisType.ButtonWrapper2"/> will be used.
        /// </summary>
        /// <param name="axis"></param>
        private void HandleDPad(CAxis axis)
        {
            AxisMapping mapping = Mapping.Axes[(int)axis];
            int         index;

            // some gamepads only have buttons for the dpad
            if (GetButton(out index))
            {
                if (step == 0)
                {
                    mapping.Axis = index;
                }
                else
                {
                    mapping.Alternative = index;
                }
                mapping.Type = AxisMapping.AxisType.ButtonWrapper2;
                Next();
            }
            else if (GetAxis(out index))
            {
                mapping.Axis   = index;
                mapping.Invert = Snapshot[index] > 0;
                if (axis == CAxis.DY)
                {
                    mapping.Invert = !mapping.Invert;
                }
                Next();
            }
        }
Beispiel #4
0
        private void _appServiceConnection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            if (args.Request.Message.ContainsKey("STATUS"))
            {
                var msg = args.Request.Message["STATUS"];
                Debug.WriteLine("STATUS: " + msg);
            }

            if (args.Request.Message.ContainsKey("DONE"))
            {
                var axis = Convert.ToInt32(args.Request.Message["DONE"]);
                Debug.WriteLine($"FINISHED {axis}");
                switch (axis)
                {
                case 0: XAxis.Completed(); break;

                case 1: YAxis.Completed(); break;

                case 2: CAxis.Completed(); break;

                case 3: PlaceAxis.Completed(); break;

                case 4: SolderAxis.Completed(); break;
                }
            }
        }
Beispiel #5
0
        public void HandleCommand(GCodeCommand cmd)
        {
            _curent = cmd;
            var movement = cmd as GCodeLine;

            if (movement != null)
            {
                _motorPower.Enable();
                XAxis.Move(movement.End.X, Convert.ToDouble(movement.Feed));
                YAxis.Move(movement.End.Y, Convert.ToDouble(movement.Feed));
                switch (_currentTool)
                {
                case Tools.CAxis: CAxis.Move(movement.End.Z, Convert.ToDouble(movement.Feed)); break;

                case Tools.PasteHead: SolderAxis.Move(movement.End.Z, Convert.ToDouble(movement.Feed)); break;

                case Tools.PlaceHead: PlaceAxis.Move(movement.End.Z, Convert.ToDouble(movement.Feed)); break;
                }
            }

            var machine = cmd as MCode;

            if (machine != null)
            {
                switch (machine.Code)
                {
                case 60: if (machine.Power == 0)
                    {
                        _topLight.Off();
                    }
                    else
                    {
                        _topLight.On();
                    } break;

                case 61: if (machine.Power == 0)
                    {
                        _bottomLight.Off();
                    }
                    else
                    {
                        _bottomLight.On();
                    } break;

                case 62: if (machine.Power == 0)
                    {
                        _vacuum.Off();
                    }
                    else
                    {
                        _vacuum.On();
                    } break;
                }
            }
        }
        /// <summary>
        /// Helper method used to invert an axis, providing an undo action.
        /// </summary>
        /// <param name="axis"></param>
        private void AxisToggle(CAxis axis)
        {
            EditorGUI.BeginChangeCheck();
            bool value = EditorGUILayout.ToggleLeft(axis.ToString(), Settings[axis], GUILayout.Width(40));

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(Settings, "Inverted Axis " + axis.ToString());
                Settings[axis] = value;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Returns the <paramref name="axis"/> of player <paramref name="id"/>. The result is in range [-1, 1], except for the two triggers.
 /// They are in range [0, 1].
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static float GetAxis(CAxis axis, PlayerIndex id = PlayerIndex.Any)
 {
     if (!IsInitialized)
     {
         Initialize();
     }
     if (Settings[axis])
     {
         return(-GetAxisRaw(axis, id));
     }
     return(GetAxisRaw(axis, id));
 }
Beispiel #8
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Ternary other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Domain == other.Domain ||
                     Domain != null &&
                     Domain.Equals(other.Domain)
                     ) &&
                 (
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                 ) &&
                 (
                     Sum == other.Sum ||
                     Sum != null &&
                     Sum.Equals(other.Sum)
                 ) &&
                 (
                     AAxis == other.AAxis ||
                     AAxis != null &&
                     AAxis.Equals(other.AAxis)
                 ) &&
                 (
                     BAxis == other.BAxis ||
                     BAxis != null &&
                     BAxis.Equals(other.BAxis)
                 ) &&
                 (
                     CAxis == other.CAxis ||
                     CAxis != null &&
                     CAxis.Equals(other.CAxis)
                 ) &&
                 (
                     UiRevision == other.UiRevision ||
                     UiRevision != null &&
                     UiRevision.Equals(other.UiRevision)
                 ));
        }
Beispiel #9
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Domain != null)
                {
                    hashCode = hashCode * 59 + Domain.GetHashCode();
                }

                if (BgColor != null)
                {
                    hashCode = hashCode * 59 + BgColor.GetHashCode();
                }

                if (Sum != null)
                {
                    hashCode = hashCode * 59 + Sum.GetHashCode();
                }

                if (AAxis != null)
                {
                    hashCode = hashCode * 59 + AAxis.GetHashCode();
                }

                if (BAxis != null)
                {
                    hashCode = hashCode * 59 + BAxis.GetHashCode();
                }

                if (CAxis != null)
                {
                    hashCode = hashCode * 59 + CAxis.GetHashCode();
                }

                if (UiRevision != null)
                {
                    hashCode = hashCode * 59 + UiRevision.GetHashCode();
                }

                return(hashCode);
            }
        }
        /// <summary>
        /// Handles left/right trigger. If a button was pressed, <see cref="AxisMapping.AxisType.ButtonWrapper"/> will be used.
        /// </summary>
        /// <param name="axis"></param>
        private void HandleTrigger(CAxis axis)
        {
            AxisMapping mapping = Mapping.Axes[(int)axis];
            int         index;

            if (GetButton(out index))  // wrapper
            {
                mapping.Axis = index;
                mapping.Type = AxisMapping.AxisType.ButtonWrapper;
                mapping.Min  = 0;
                mapping.Max  = 1;
                Next();
            }
            else if (GetAxis(out index))
            {
                mapping.Axis = index;
                Next();
            }
        }
Beispiel #11
0
    private static float GetAxisRaw(CAxis axis, PlayerIndex id)
    {
        if (id == PlayerIndex.Any)
        {
            switch (settings.Behaviour)
            {
            case AnyBehaviour.UseControllerOne: return(PlayerMappings[1].GetAxis(axis));

            case AnyBehaviour.CheckAll:
                for (int i = 1; i < CarbonController.PlayerIndices; i++)
                {
                    float value = PlayerMappings[i].GetAxis(axis);
                    if (Mathf.Abs(value) > 0.02f)
                    {
                        return(value);
                    }
                }
                return(0f);
            }
        }
        return(PlayerMappings[(int)id].GetAxis(axis));
    }
Beispiel #12
0
 /// <summary>
 /// Returns the value of the given axis.
 /// </summary>
 /// <param name="axis"></param>
 /// <returns></returns>
 public float GetAxis(CAxis axis)
 {
     return(Axis[(int)axis]);
 }
Beispiel #13
0
        private void btnLoadAxisPara_Click(object sender, EventArgs e)
        {
            // DMC2610卡的函数调用

            nCard = Dmc2610.d2610_board_init(); //'为控制卡分配系统资源,并初始化控制卡。
            if (nCard <= 0)                     //DMC1000控制卡初始化
            {
                MessageBox.Show("未找到DMC2610控制卡!", "警告");
                return;//退出当前程序
            }

            string connectionString = @"Data Source=.\AOI;Initial Catalog=aoi5sys;Integrated Security=True";

            SqlConnection connection = new SqlConnection(connectionString);
            //string sql=@"SELECT * FROM AXIS_PARAM WHERE NAME='#1HOST'";
            string sql = @"SELECT [NAME]
      ,[AXIS]
      ,[AXIS_ID]
      ,[PULSE_MODE]
      ,[MAX_DIST]
      ,[ORG_POSITION]
      ,[RESET_SPEED]
      ,[START_SPEED]
      ,[MAX_SPEED]
      ,[ADD_SPEED]
      ,[ADD_MODE]
      ,[PULSE_PER_MM]
  FROM [aoi5sys].[dbo].[AXIS_PARAM]
  WHERE	NAME='#1HOST'";

            try
            {
                connection.Open();

                SqlCommand cmd = new SqlCommand(sql, connection);

                SqlDataReader dataReader = cmd.ExecuteReader();


                AxisGroup = new List <Axis>();

                while (dataReader.Read())
                {
                    string           tempstr  = dataReader.GetValue(1).ToString();
                    AxisPulseOutMode PoutMode = dataReader.GetInt32(3) == 0
                              ? AxisPulseOutMode.PM_PLDL
                              : AxisPulseOutMode.PM_PHDHPHDH;
                    double     pulseOfMilMeter   = Convert.ToDouble(dataReader.GetValue(11).ToString());
                    long       maxRouterDistance = Convert.ToInt64(dataReader.GetValue(4));
                    long       logicOrgPosition  = Convert.ToInt64(dataReader.GetValue(5));
                    AxisINPSIG axisInpsig        = AxisINPSIG.Enable;

                    double ResetVelocity = Convert.ToDouble(dataReader.GetValue(6));
                    double startVelocity = Convert.ToDouble(dataReader.GetValue(7));
                    double maxVelocity   = Convert.ToDouble(dataReader.GetValue(8));
                    double accVelocity   = Convert.ToDouble(dataReader.GetValue(9));
                    double decVelocity   = Convert.ToDouble(dataReader.GetValue(9));
                    float  scale         = (float)0.75;

                    if (tempstr.Contains("X_"))
                    {
                        this.XAxis = new Axis(AxisID.XAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        XAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        XAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        XAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        XAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // XAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(XAxis);
                    }
                    if (tempstr.Contains("Y_"))
                    {
                        this.YAxis = new Axis(AxisID.YAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        YAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        YAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        YAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        YAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // YAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(YAxis);
                    }
                    if (tempstr.Contains("C_"))
                    {
                        this.CAxis = new Axis(AxisID.ZAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        CAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        CAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        CAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        CAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        //CAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(CAxis);
                    }
                    if (tempstr.Contains("L_"))
                    {
                        this.LAxis = new Axis(AxisID.UAxis, PoutMode, pulseOfMilMeter, maxRouterDistance, logicOrgPosition, axisInpsig);
                        LAxis.AxisSetResetMoveParameters(ResetVelocity / 2, ResetVelocity, ResetVelocity / 2, ResetVelocity / 2);
                        LAxis.AxisSetTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity);
                        LAxis.AxisSetSPMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        LAxis.AxisSetSTMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, scale);
                        // LAxis.AxisSetVectorMoveParameters(startVelocity, maxVelocity, accVelocity, decVelocity, (float)0.6);
                        AxisGroup.Add(LAxis);
                    }
                }
                timer1.Enabled = true;
            }
            catch (DataException dataException)
            {
                MessageBox.Show(dataException.ToString());
            }
            finally
            {
                connection.Close();
                this.btnLoadAxisPara.Enabled = false;
            }

            for (int i = 0; i < 2; i++)
            {
                InputinitStatus[i] = Motion2610Control.ReadInputKey((ushort)(i + 1));
                InputiskeyDown[i]  = InputinitStatus[i];
            }
        }
Beispiel #14
0
 /// <summary>
 /// Returns true while the axis is "pressed", which is if the absolute value of this axis is greater than a certain threshold.
 /// </summary>
 /// <param name="axis"></param>
 /// <returns></returns>
 public bool Button(CAxis axis)
 {
     return(Mathf.Abs(Axis[(int)axis]) > AxisPressedThreshold);
 }
Beispiel #15
0
 /// <summary>
 /// Gets or sets the value of the given axis.
 /// </summary>
 /// <param name="axis"></param>
 /// <returns></returns>
 public float this[CAxis axis] {
     get { return(axisMap[(int)axis]); }
     set { axisMap[(int)axis] = value; }
 }
 /// <summary>
 /// Gets or sets the given axis to be inverted or not.
 /// </summary>
 /// <param name="axis"></param>
 /// <returns></returns>
 public bool this[CAxis axis] {
     get { return(InvertedAxis[(int)axis]); }
     set { InvertedAxis[(int)axis] = value; }
 }
Beispiel #17
0
        /// <summary>
        /// Returns the value of the virtual axis of player <paramref name="id"/> identified by the <paramref name="axis"/> parameter;
        /// </summary>
        /// <param name="axis"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual float GetAxis(CAxis axis, int id)
        {
            AxisMapping mapping = Axes[(int)axis];
            float       result  = 0;

            switch (mapping.Type)
            {
            case AxisMapping.AxisType.Default:
                result = Input.GetAxis(AxisNames[id, mapping.Axis]);
                break;

            case AxisMapping.AxisType.ButtonWrapper:
                result = Input.GetKey(KeyCode.JoystickButton0 + id * JoystickButtonCount + mapping.Axis) ? mapping.Max : mapping.Min;
                break;

            case AxisMapping.AxisType.KeyWrapper:
                bool key1 = Input.GetKey(mapping.Key1);
                bool key2 = Input.GetKey(mapping.Key2);
                if (key1 && !key2)
                {
                    result = -1;
                }
                else if (!key1 && key2)
                {
                    result = 1;
                }
                else
                {
                    result = 0;
                }
                break;

            case AxisMapping.AxisType.Clamped:
                result = Mathf.Clamp(Input.GetAxis(AxisNames[id, mapping.Axis]), mapping.Min, mapping.Max);
                break;

            case AxisMapping.AxisType.ButtonWrapper2:
                key1 = Input.GetKey(KeyCode.JoystickButton0 + id * JoystickButtonCount + mapping.Axis);
                key2 = Input.GetKey(KeyCode.JoystickButton0 + id * JoystickButtonCount + mapping.Alternative);
                if (key1 && !key2)
                {
                    result = -1;
                }
                else if (!key1 && key2)
                {
                    result = 1;
                }
                else
                {
                    result = 0;
                }
                break;

            case AxisMapping.AxisType.TriggerLimiter:
                result = (Input.GetAxis(AxisNames[id, mapping.Axis]) + 1f) / 2f;
                break;
            }
            if (mapping.Invert)
            {
                return(-result);
            }
            return(result);
        }
Beispiel #18
0
 public override float GetAxis(CAxis axis, int id)
 {
     return(this[axis]);
 }
Beispiel #19
0
 public float GetAxis(CAxis axis)
 {
     return(Controller.GetAxis(axis, Index));
 }