public static bool GetButtonReleased(AxisID button, ControllerID hand = ControllerID.unbound) { if (hand == ControllerID.unbound) { if (leftController == null) { hand = ControllerID.right; } else if (rightController == null) { hand = ControllerID.left; } } switch (hand) { case ControllerID.left: if (leftController == null) { return(false); } return(leftController.GetReleased(button)); case ControllerID.right: if (rightController == null) { return(false); } return(rightController.GetReleased(button)); default: return(rightController.GetReleased(button) || leftController.GetReleased(button)); } }
bool GetReleased(AxisID button) { if (!inputCheckedThisFrame) { CheckInput(); } return(GetAxis(button).released); }
bool GetHeld(AxisID button) { if (!inputCheckedThisFrame) { CheckInput(); } return(GetAxis(button).held); }
bool GetPressed(AxisID button) { if (!inputCheckedThisFrame) { CheckInput(); } return(GetAxis(button).pressed); }
public static byte[] AxisSelect_Command(AxisID id) { return(new byte[] { INSTRUCTION_CODE, 0x02, (byte)CommandID.AxisSelect, (byte)id }); }
public static byte[] Coefficient_Command(AxisID axisId, CoefficientID coefficientID) { return(new byte[] { INSTRUCTION_CODE, 0x03, (byte)CommandID.Coefficient, (byte)axisId, (byte)coefficientID, }); }
public static void ArcMoveUseVectorMode(AxisID axis1, AxisID axis2, PointF tartgetPointF, PointF centroPointF, ArcDirectory arcDirectory) { var aixsGroup = new ushort[2]; aixsGroup[0] = (ushort)axis1; aixsGroup[1] = (ushort)axis2; var targetPoint = new long[2]; targetPoint[0] = (long)tartgetPointF.X; targetPoint[1] = (long)tartgetPointF.Y; }
public static AxisID GetOrthogonalAxis(AxisID axis) { switch (axis) { case AxisID.X: return(AxisID.Z); case AxisID.Y: return(AxisID.Y); case AxisID.Z: default: return(AxisID.X); } }
/// <summary> /// コントローラが保持しているマトリクス 係数 をホストに転送するコマンド。 /// ※ 予め Bootload コマンドを実行しておいてください。 /// Axis IDと Coefficient ID を組み合わせて、読み出してください。 /// </summary> /// <param name="axisID"></param> /// <param name="coefficientID"></param> /// <returns></returns> public int Coefficient(AxisID axisID, CoefficientID coefficientID) { var ret = sendAndResponse(CommandBuilder.Coefficient_Command(axisID, coefficientID), 6); ResponseStatus status = (ResponseStatus)ret[0]; if (status != ResponseStatus.OK) { throw new Exception(status.ToString()); } if (ret[1] != 4) { throw new Exception($"data length error: {ret[1]}"); } var coeBytes = new byte[4]; Array.Copy(ret, 2, coeBytes, 0, 4); return(BitConverter.ToInt32(coeBytes)); }
public Axis(AxisID id, AxisPulseOutMode axisPulseOutMode, double pulseOfMilMeter, long maxRouteDistance, long logicOrgPosition, AxisINPSIG inpsig) { _axisId = Convert.ToUInt16(id); _pulseOfPerMilMeter = pulseOfMilMeter; _maxRouteDistance = (long)(maxRouteDistance * PulseOfPerMilMeter); _logicOrgPosition = (int)(logicOrgPosition * PulseOfPerMilMeter); _axisPulseOutMode = Convert.ToUInt16(axisPulseOutMode); //轴脉冲输出模式 Dmc2610.d2610_set_pulse_outmode(_axisId, Convert.ToUInt16(AxisPulseOutMode)); //ALM信号定义: 低电平有效,触发后立即停止 Dmc2610.d2610_config_ALM_PIN(_axisId, Convert.ToUInt16(AxisALMLogic.HighLevelVaild), Convert.ToUInt16(AxisALMAction.ImmediatelyStop)); //INP信号低电平有效, 发送完成指令脉冲后立即置check_done 完成,无需等待,否则需得到INP为低电平才置位check_done if (_axisPulseOutMode < 4) { Dmc2610.d2610_config_INP_PIN(_axisId, Convert.ToUInt16(AxisINPSIG.Enable), Convert.ToUInt16(AxisINPLogic.LowLevelVaild)); } else { Dmc2610.d2610_config_INP_PIN(_axisId, Convert.ToUInt16(AxisINPSIG.Enable), Convert.ToUInt16(AxisINPLogic.HighLevelVaild)); } //Emergy Stop 信号定义 0为1号卡 1允许,1 高电平有效 Dmc2610.d2610_config_EMG_PIN(0, 1, 0); //编码器计数方式为: AB相 EA单路信号4倍。(无卡时,初始化这一项会出现内存存储违规,故暂时取消掉) Dmc2610.d2610_counter_config(_axisId, Convert.ToUInt16(EnCoderCountMode.ABPhased4xEA)); //Dmc2610.d2610_set_encoder(_axisId, 0); //设置Home PIN的回原点以及滤波器开关。(无卡时,初始化这一项会出现内存存储违规,故暂时取消掉) Dmc2610.d2610_set_HOME_pin_logic(AxisId, Convert.ToUInt16(AxisHOMEOrgLogic.LowLevelVaild), Convert.ToUInt16(AxisHOMEUseFilter.Enable)); Dmc2610.d2610_config_home_mode(AxisId, Convert.ToUInt16(AxisHomeMode.HomeCountOnly), Convert.ToUInt16(0)); }
InputAxis GetAxis(AxisID id) { return(axes[(int)id]); }
/// <summary> /// 力覚センサの各軸に該当する AFE に個別にアクセスするために、アクセスする軸を選択するコマンド。 /// 力覚センサをIdle 状態にするためには、 各軸に該当する AFE を個別に Idle 状態にしなければなりません。 /// そのため、Idle コマンドを発行する前に、アクセスする軸を選択します。 /// 本コマンドでアクセスする軸を選択し、その後、Idle コマンドで選択した軸の AFE を Idle 状態にします。 /// </summary> /// <param name="id"></param> /// <returns></returns> public ResponseStatus AxisSelect(AxisID id) { var ret = sendAndResponse(CommandBuilder.AxisSelect_Command(id), 2); return((ResponseStatus)ret[0]); }