FRC.WPILib.CTRE by RobotDotNet

<PackageReference Include="FRC.WPILib.CTRE" Version="2017.0.2" />

.NET API 131,584 bytes

 HALCanTalonSRX

public class HALCanTalonSRX
using HAL.Base; using NativeLibraryUtilities; using System; using System.IO; using System.Runtime.InteropServices; namespace CTRE { public class HALCanTalonSRX { public class Constants { public const int kDefaultControlPeriodMs = 10; public const int kMode_DutyCycle = 0; public const int kMode_PositionCloseLoop = 1; public const int kMode_VelocityCloseLoop = 2; public const int kMode_CurrentCloseLoop = 3; public const int kMode_VoltCompen = 4; public const int kMode_SlaveFollower = 5; public const int kMode_NoDrive = 15; public const int kLimitSwitchOverride_UseDefaultsFromFlash = 1; public const int kLimitSwitchOverride_DisableFwd_DisableRev = 4; public const int kLimitSwitchOverride_DisableFwd_EnableRev = 5; public const int kLimitSwitchOverride_EnableFwd_DisableRev = 6; public const int kLimitSwitchOverride_EnableFwd_EnableRev = 7; public const int kBrakeOverride_UseDefaultsFromFlash = 0; public const int kBrakeOverride_OverrideCoast = 1; public const int kBrakeOverride_OverrideBrake = 2; public const int kFeedbackDev_DigitalQuadEnc = 0; public const int kFeedbackDev_AnalogPot = 2; public const int kFeedbackDev_AnalogEncoder = 3; public const int kFeedbackDev_CountEveryRisingEdge = 4; public const int kFeedbackDev_CountEveryFallingEdge = 5; public const int kFeedbackDev_PosIsPulseWidth = 8; public const int kProfileSlotSelect_Slot0 = 0; public const int kProfileSlotSelect_Slot1 = 1; public const int kMotionProfileFlag_ActTraj_IsValid = 1; public const int kMotionProfileFlag_HasUnderrun = 2; public const int kMotionProfileFlag_IsUnderrun = 4; public const int kMotionProfileFlag_ActTraj_IsLast = 8; public const int kMotionProfileFlag_ActTraj_VelOnly = 16; public const int kStatusFrame_General = 0; public const int kStatusFrame_Feedback = 1; public const int kStatusFrame_Encoder = 2; public const int kStatusFrame_AnalogTempVbat = 3; } public enum ParamID { eProfileParamSlot0_P = 1, eProfileParamSlot0_I = 2, eProfileParamSlot0_D = 3, eProfileParamSlot0_F = 4, eProfileParamSlot0_IZone = 5, eProfileParamSlot0_CloseLoopRampRate = 6, eProfileParamSlot1_P = 11, eProfileParamSlot1_I = 12, eProfileParamSlot1_D = 13, eProfileParamSlot1_F = 14, eProfileParamSlot1_IZone = 15, eProfileParamSlot1_CloseLoopRampRate = 16, eProfileParamSoftLimitForThreshold = 21, eProfileParamSoftLimitRevThreshold = 22, eProfileParamSoftLimitForEnable = 23, eProfileParamSoftLimitRevEnable = 24, eOnBoot_BrakeMode = 31, eOnBoot_LimitSwitch_Forward_NormallyClosed = 32, eOnBoot_LimitSwitch_Reverse_NormallyClosed = 33, eOnBoot_LimitSwitch_Forward_Disable = 34, eOnBoot_LimitSwitch_Reverse_Disable = 35, eFault_OverTemp = 41, eFault_UnderVoltage = 42, eFault_ForLim = 43, eFault_RevLim = 44, eFault_HardwareFailure = 45, eFault_ForSoftLim = 46, eFault_RevSoftLim = 47, eStckyFault_OverTemp = 48, eStckyFault_UnderVoltage = 49, eStckyFault_ForLim = 50, eStckyFault_RevLim = 51, eStckyFault_ForSoftLim = 52, eStckyFault_RevSoftLim = 53, eAppliedThrottle = 61, eCloseLoopErr = 62, eFeedbackDeviceSelect = 63, eRevMotDuringCloseLoopEn = 64, eModeSelect = 65, eProfileSlotSelect = 66, eRampThrottle = 67, eRevFeedbackSensor = 68, eLimitSwitchEn = 69, eLimitSwitchClosedFor = 70, eLimitSwitchClosedRev = 71, eSensorPosition = 73, eSensorVelocity = 74, eCurrent = 75, eBrakeIsEnabled = 76, eEncPosition = 77, eEncVel = 78, eEncIndexRiseEvents = 79, eQuadApin = 80, eQuadBpin = 81, eQuadIdxpin = 82, eAnalogInWithOv = 83, eAnalogInVel = 84, eTemp = 85, eBatteryV = 86, eResetCount = 87, eResetFlags = 88, eFirmVers = 89, eSettingsChanged = 90, eQuadFilterEn = 91, ePidIaccum = 93, eStatus1FrameRate = 94, eStatus2FrameRate = 95, eStatus3FrameRate = 96, eStatus4FrameRate = 97, eStatus6FrameRate = 98, eStatus7FrameRate = 99, eClearPositionOnIdx = 100, ePeakPosOutput = 104, eNominalPosOutput = 105, ePeakNegOutput = 106, eNominalNegOutput = 107, eQuadIdxPolarity = 108, eStatus8FrameRate = 109, eAllowPosOverflow = 110, eProfileParamSlot0_AllowableClosedLoopErr = 111, eNumberPotTurns = 112, eNumberEncoderCPR = 113, ePwdPosition = 114, eAinPosition = 115, eProfileParamVcompRate = 116, eProfileParamSlot1_AllowableClosedLoopErr = 117, eStatus9FrameRate = 118, eMotionProfileHasUnderrunErr = 119, eReserved120 = 120, eLegac = 121 } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate IntPtr ctre_TalonSRX_Create3Delegate (int deviceNumber, int controlPeriodMs, int enablePeriodMs); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void ctre_TalonSRX_DestroyDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void ctre_TalonSRX_SetDelegate (IntPtr handle, double value); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetParamDelegate (IntPtr handle, int paramEnum, double value); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_RequestParamDelegate (IntPtr handle, int paramEnum); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetParamResponseDelegate (IntPtr handle, int paramEnum, ref double value); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetParamResponseInt32Delegate (IntPtr handle, int paramEnum, ref int value); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetPgainDelegate (IntPtr handle, int slotIdx, double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetIgainDelegate (IntPtr handle, int slotIdx, double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetDgainDelegate (IntPtr handle, int slotIdx, double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetFgainDelegate (IntPtr handle, int slotIdx, double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetIzoneDelegate (IntPtr handle, int slotIdx, int zone); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetCloseLoopRampRateDelegate (IntPtr handle, int slotIdx, int closeLoopRampRate); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetVoltageCompensationRateDelegate (IntPtr handle, double voltagePerMs); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetSensorPositionDelegate (IntPtr handle, int pos); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetForwardSoftLimitDelegate (IntPtr handle, int forwardLimit); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetReverseSoftLimitDelegate (IntPtr handle, int reverseLimit); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetForwardSoftEnableDelegate (IntPtr handle, int enable); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetReverseSoftEnableDelegate (IntPtr handle, int enable); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetPgainDelegate (IntPtr handle, int slotIdx, ref double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetIgainDelegate (IntPtr handle, int slotIdx, ref double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetDgainDelegate (IntPtr handle, int slotIdx, ref double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFgainDelegate (IntPtr handle, int slotIdx, ref double gain); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetIzoneDelegate (IntPtr handle, int slotIdx, ref int zone); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetCloseLoopRampRateDelegate (IntPtr handle, int slotIdx, ref int closeLoopRampRate); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetVoltageCompensationRateDelegate (IntPtr handle, ref double voltagePerMs); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetForwardSoftLimitDelegate (IntPtr handle, ref int forwardLimit); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetReverseSoftLimitDelegate (IntPtr handle, ref int reverseLimit); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetForwardSoftEnableDelegate (IntPtr handle, ref int enable); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetReverseSoftEnableDelegate (IntPtr handle, ref int enable); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetPulseWidthRiseToFallUsDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_IsPulseWidthSensorPresentDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetModeSelect2Delegate (IntPtr handle, int modeSelect, int demand); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetStatusFrameRateDelegate (IntPtr handle, int frameEnum, int periodMs); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_ClearStickyFaultsDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void ctre_TalonSRX_ChangeMotionControlFramePeriodDelegate (IntPtr handle, int periodMs); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void ctre_TalonSRX_ClearMotionProfileTrajectoriesDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate int ctre_TalonSRX_GetMotionProfileTopLevelBufferCountDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate int ctre_TalonSRX_IsMotionProfileTopLevelBufferFullDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_PushMotionProfileTrajectoryDelegate (IntPtr handle, int targPos, int targVel, int profileSlotSelect, int timeDurMs, int velOnly, int isLastPoint, int zeroPos); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void ctre_TalonSRX_ProcessMotionProfileBufferDelegate (IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetMotionProfileStatusDelegate (IntPtr handle, ref int flags, ref int profileSlotSelect, ref int targPos, ref int targVel, ref int topBufferRemaining, ref int topBufferCnt, ref int btmBufferCnt, ref int outputEnable); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_OverTempDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_UnderVoltageDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_ForLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_RevLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_HardwareFailureDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_ForSoftLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFault_RevSoftLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_OverTempDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_UnderVoltageDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_ForLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_RevLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_ForSoftLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetStckyFault_RevSoftLimDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetAppliedThrottleDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetCloseLoopErrDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFeedbackDeviceSelectDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetModeSelectDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetLimitSwitchEnDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetLimitSwitchClosedForDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetLimitSwitchClosedRevDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetSensorPositionDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetSensorVelocityDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetCurrentDelegate (IntPtr handle, ref double param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetBrakeIsEnabledDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetEncPositionDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetEncVelDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetEncIndexRiseEventsDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetQuadApinDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetQuadBpinDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetQuadIdxpinDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetAnalogInWithOvDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetAnalogInVelDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetTempDelegate (IntPtr handle, ref double param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetBatteryVDelegate (IntPtr handle, ref double param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetResetCountDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetResetFlagsDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetFirmVersDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetPulseWidthPositionDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetPulseWidthVelocityDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetPulseWidthRiseToRiseUsDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_IsValidDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_ProfileSlotSelectDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_VelOnlyDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_IsLastDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetOutputTypeDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetHasUnderrunDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetIsUnderrunDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetNextIDDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetBufferIsFullDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetCountDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_VelocityDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_GetActTraj_PositionDelegate (IntPtr handle, ref int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetDemandDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetOverrideLimitSwitchEnDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetFeedbackDeviceSelectDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetRevMotDuringCloseLoopEnDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetOverrideBrakeTypeDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetModeSelectDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetProfileSlotSelectDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetRampThrottleDelegate (IntPtr handle, int param); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate CTR_Code ctre_TalonSRX_SetRevFeedbackSensorDelegate (IntPtr handle, int param); private static readonly bool s_libraryLoaded; private static readonly string s_libraryLocation; private static readonly bool s_useCommandLineFile; private static readonly bool s_runFinalizer; private static readonly HALCanTalonSRX finalizeInterop; [NativeDelegate] internal static ctre_TalonSRX_Create3Delegate ctre_TalonSRX_Create3; [NativeDelegate] internal static ctre_TalonSRX_DestroyDelegate ctre_TalonSRX_Destroy; [NativeDelegate] internal static ctre_TalonSRX_SetDelegate ctre_TalonSRX_Set; [NativeDelegate] internal static ctre_TalonSRX_SetParamDelegate ctre_TalonSRX_SetParam; [NativeDelegate] internal static ctre_TalonSRX_RequestParamDelegate ctre_TalonSRX_RequestParam; [NativeDelegate] internal static ctre_TalonSRX_GetParamResponseDelegate ctre_TalonSRX_GetParamResponse; [NativeDelegate] internal static ctre_TalonSRX_GetParamResponseInt32Delegate ctre_TalonSRX_GetParamResponseInt32; [NativeDelegate] internal static ctre_TalonSRX_SetPgainDelegate ctre_TalonSRX_SetPgain; [NativeDelegate] internal static ctre_TalonSRX_SetIgainDelegate ctre_TalonSRX_SetIgain; [NativeDelegate] internal static ctre_TalonSRX_SetDgainDelegate ctre_TalonSRX_SetDgain; [NativeDelegate] internal static ctre_TalonSRX_SetFgainDelegate ctre_TalonSRX_SetFgain; [NativeDelegate] internal static ctre_TalonSRX_SetIzoneDelegate ctre_TalonSRX_SetIzone; [NativeDelegate] internal static ctre_TalonSRX_SetCloseLoopRampRateDelegate ctre_TalonSRX_SetCloseLoopRampRate; [NativeDelegate] internal static ctre_TalonSRX_SetVoltageCompensationRateDelegate ctre_TalonSRX_SetVoltageCompensationRate; [NativeDelegate] internal static ctre_TalonSRX_SetSensorPositionDelegate ctre_TalonSRX_SetSensorPosition; [NativeDelegate] internal static ctre_TalonSRX_SetForwardSoftLimitDelegate ctre_TalonSRX_SetForwardSoftLimit; [NativeDelegate] internal static ctre_TalonSRX_SetReverseSoftLimitDelegate ctre_TalonSRX_SetReverseSoftLimit; [NativeDelegate] internal static ctre_TalonSRX_SetForwardSoftEnableDelegate ctre_TalonSRX_SetForwardSoftEnable; [NativeDelegate] internal static ctre_TalonSRX_SetReverseSoftEnableDelegate ctre_TalonSRX_SetReverseSoftEnable; [NativeDelegate] internal static ctre_TalonSRX_GetPgainDelegate ctre_TalonSRX_GetPgain; [NativeDelegate] internal static ctre_TalonSRX_GetIgainDelegate ctre_TalonSRX_GetIgain; [NativeDelegate] internal static ctre_TalonSRX_GetDgainDelegate ctre_TalonSRX_GetDgain; [NativeDelegate] internal static ctre_TalonSRX_GetFgainDelegate ctre_TalonSRX_GetFgain; [NativeDelegate] internal static ctre_TalonSRX_GetIzoneDelegate ctre_TalonSRX_GetIzone; [NativeDelegate] internal static ctre_TalonSRX_GetCloseLoopRampRateDelegate ctre_TalonSRX_GetCloseLoopRampRate; [NativeDelegate] internal static ctre_TalonSRX_GetVoltageCompensationRateDelegate ctre_TalonSRX_GetVoltageCompensationRate; [NativeDelegate] internal static ctre_TalonSRX_GetForwardSoftLimitDelegate ctre_TalonSRX_GetForwardSoftLimit; [NativeDelegate] internal static ctre_TalonSRX_GetReverseSoftLimitDelegate ctre_TalonSRX_GetReverseSoftLimit; [NativeDelegate] internal static ctre_TalonSRX_GetForwardSoftEnableDelegate ctre_TalonSRX_GetForwardSoftEnable; [NativeDelegate] internal static ctre_TalonSRX_GetReverseSoftEnableDelegate ctre_TalonSRX_GetReverseSoftEnable; [NativeDelegate] internal static ctre_TalonSRX_GetPulseWidthRiseToFallUsDelegate ctre_TalonSRX_GetPulseWidthRiseToFallUs; [NativeDelegate] internal static ctre_TalonSRX_IsPulseWidthSensorPresentDelegate ctre_TalonSRX_IsPulseWidthSensorPresent; [NativeDelegate] internal static ctre_TalonSRX_SetModeSelect2Delegate ctre_TalonSRX_SetModeSelect2; [NativeDelegate] internal static ctre_TalonSRX_SetStatusFrameRateDelegate ctre_TalonSRX_SetStatusFrameRate; [NativeDelegate] internal static ctre_TalonSRX_ClearStickyFaultsDelegate ctre_TalonSRX_ClearStickyFaults; [NativeDelegate] internal static ctre_TalonSRX_ChangeMotionControlFramePeriodDelegate ctre_TalonSRX_ChangeMotionControlFramePeriod; [NativeDelegate] internal static ctre_TalonSRX_ClearMotionProfileTrajectoriesDelegate ctre_TalonSRX_ClearMotionProfileTrajectories; [NativeDelegate] internal static ctre_TalonSRX_GetMotionProfileTopLevelBufferCountDelegate ctre_TalonSRX_GetMotionProfileTopLevelBufferCount; [NativeDelegate] internal static ctre_TalonSRX_IsMotionProfileTopLevelBufferFullDelegate ctre_TalonSRX_IsMotionProfileTopLevelBufferFull; [NativeDelegate] internal static ctre_TalonSRX_PushMotionProfileTrajectoryDelegate ctre_TalonSRX_PushMotionProfileTrajectory; [NativeDelegate] internal static ctre_TalonSRX_ProcessMotionProfileBufferDelegate ctre_TalonSRX_ProcessMotionProfileBuffer; [NativeDelegate] internal static ctre_TalonSRX_GetMotionProfileStatusDelegate ctre_TalonSRX_GetMotionProfileStatus; [NativeDelegate] internal static ctre_TalonSRX_GetFault_OverTempDelegate ctre_TalonSRX_GetFault_OverTemp; [NativeDelegate] internal static ctre_TalonSRX_GetFault_UnderVoltageDelegate ctre_TalonSRX_GetFault_UnderVoltage; [NativeDelegate] internal static ctre_TalonSRX_GetFault_ForLimDelegate ctre_TalonSRX_GetFault_ForLim; [NativeDelegate] internal static ctre_TalonSRX_GetFault_RevLimDelegate ctre_TalonSRX_GetFault_RevLim; [NativeDelegate] internal static ctre_TalonSRX_GetFault_HardwareFailureDelegate ctre_TalonSRX_GetFault_HardwareFailure; [NativeDelegate] internal static ctre_TalonSRX_GetFault_ForSoftLimDelegate ctre_TalonSRX_GetFault_ForSoftLim; [NativeDelegate] internal static ctre_TalonSRX_GetFault_RevSoftLimDelegate ctre_TalonSRX_GetFault_RevSoftLim; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_OverTempDelegate ctre_TalonSRX_GetStckyFault_OverTemp; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_UnderVoltageDelegate ctre_TalonSRX_GetStckyFault_UnderVoltage; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_ForLimDelegate ctre_TalonSRX_GetStckyFault_ForLim; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_RevLimDelegate ctre_TalonSRX_GetStckyFault_RevLim; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_ForSoftLimDelegate ctre_TalonSRX_GetStckyFault_ForSoftLim; [NativeDelegate] internal static ctre_TalonSRX_GetStckyFault_RevSoftLimDelegate ctre_TalonSRX_GetStckyFault_RevSoftLim; [NativeDelegate] internal static ctre_TalonSRX_GetAppliedThrottleDelegate ctre_TalonSRX_GetAppliedThrottle; [NativeDelegate] internal static ctre_TalonSRX_GetCloseLoopErrDelegate ctre_TalonSRX_GetCloseLoopErr; [NativeDelegate] internal static ctre_TalonSRX_GetFeedbackDeviceSelectDelegate ctre_TalonSRX_GetFeedbackDeviceSelect; [NativeDelegate] internal static ctre_TalonSRX_GetModeSelectDelegate ctre_TalonSRX_GetModeSelect; [NativeDelegate] internal static ctre_TalonSRX_GetLimitSwitchEnDelegate ctre_TalonSRX_GetLimitSwitchEn; [NativeDelegate] internal static ctre_TalonSRX_GetLimitSwitchClosedForDelegate ctre_TalonSRX_GetLimitSwitchClosedFor; [NativeDelegate] internal static ctre_TalonSRX_GetLimitSwitchClosedRevDelegate ctre_TalonSRX_GetLimitSwitchClosedRev; [NativeDelegate] internal static ctre_TalonSRX_GetSensorPositionDelegate ctre_TalonSRX_GetSensorPosition; [NativeDelegate] internal static ctre_TalonSRX_GetSensorVelocityDelegate ctre_TalonSRX_GetSensorVelocity; [NativeDelegate] internal static ctre_TalonSRX_GetCurrentDelegate ctre_TalonSRX_GetCurrent; [NativeDelegate] internal static ctre_TalonSRX_GetBrakeIsEnabledDelegate ctre_TalonSRX_GetBrakeIsEnabled; [NativeDelegate] internal static ctre_TalonSRX_GetEncPositionDelegate ctre_TalonSRX_GetEncPosition; [NativeDelegate] internal static ctre_TalonSRX_GetEncVelDelegate ctre_TalonSRX_GetEncVel; [NativeDelegate] internal static ctre_TalonSRX_GetEncIndexRiseEventsDelegate ctre_TalonSRX_GetEncIndexRiseEvents; [NativeDelegate] internal static ctre_TalonSRX_GetQuadApinDelegate ctre_TalonSRX_GetQuadApin; [NativeDelegate] internal static ctre_TalonSRX_GetQuadBpinDelegate ctre_TalonSRX_GetQuadBpin; [NativeDelegate] internal static ctre_TalonSRX_GetQuadIdxpinDelegate ctre_TalonSRX_GetQuadIdxpin; [NativeDelegate] internal static ctre_TalonSRX_GetAnalogInWithOvDelegate ctre_TalonSRX_GetAnalogInWithOv; [NativeDelegate] internal static ctre_TalonSRX_GetAnalogInVelDelegate ctre_TalonSRX_GetAnalogInVel; [NativeDelegate] internal static ctre_TalonSRX_GetTempDelegate ctre_TalonSRX_GetTemp; [NativeDelegate] internal static ctre_TalonSRX_GetBatteryVDelegate ctre_TalonSRX_GetBatteryV; [NativeDelegate] internal static ctre_TalonSRX_GetResetCountDelegate ctre_TalonSRX_GetResetCount; [NativeDelegate] internal static ctre_TalonSRX_GetResetFlagsDelegate ctre_TalonSRX_GetResetFlags; [NativeDelegate] internal static ctre_TalonSRX_GetFirmVersDelegate ctre_TalonSRX_GetFirmVers; [NativeDelegate] internal static ctre_TalonSRX_GetPulseWidthPositionDelegate ctre_TalonSRX_GetPulseWidthPosition; [NativeDelegate] internal static ctre_TalonSRX_GetPulseWidthVelocityDelegate ctre_TalonSRX_GetPulseWidthVelocity; [NativeDelegate] internal static ctre_TalonSRX_GetPulseWidthRiseToRiseUsDelegate ctre_TalonSRX_GetPulseWidthRiseToRiseUs; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_IsValidDelegate ctre_TalonSRX_GetActTraj_IsValid; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_ProfileSlotSelectDelegate ctre_TalonSRX_GetActTraj_ProfileSlotSelect; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_VelOnlyDelegate ctre_TalonSRX_GetActTraj_VelOnly; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_IsLastDelegate ctre_TalonSRX_GetActTraj_IsLast; [NativeDelegate] internal static ctre_TalonSRX_GetOutputTypeDelegate ctre_TalonSRX_GetOutputType; [NativeDelegate] internal static ctre_TalonSRX_GetHasUnderrunDelegate ctre_TalonSRX_GetHasUnderrun; [NativeDelegate] internal static ctre_TalonSRX_GetIsUnderrunDelegate ctre_TalonSRX_GetIsUnderrun; [NativeDelegate] internal static ctre_TalonSRX_GetNextIDDelegate ctre_TalonSRX_GetNextID; [NativeDelegate] internal static ctre_TalonSRX_GetBufferIsFullDelegate ctre_TalonSRX_GetBufferIsFull; [NativeDelegate] internal static ctre_TalonSRX_GetCountDelegate ctre_TalonSRX_GetCount; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_VelocityDelegate ctre_TalonSRX_GetActTraj_Velocity; [NativeDelegate] internal static ctre_TalonSRX_GetActTraj_PositionDelegate ctre_TalonSRX_GetActTraj_Position; [NativeDelegate] internal static ctre_TalonSRX_SetDemandDelegate ctre_TalonSRX_SetDemand; [NativeDelegate] internal static ctre_TalonSRX_SetOverrideLimitSwitchEnDelegate ctre_TalonSRX_SetOverrideLimitSwitchEn; [NativeDelegate] internal static ctre_TalonSRX_SetFeedbackDeviceSelectDelegate ctre_TalonSRX_SetFeedbackDeviceSelect; [NativeDelegate] internal static ctre_TalonSRX_SetRevMotDuringCloseLoopEnDelegate ctre_TalonSRX_SetRevMotDuringCloseLoopEn; [NativeDelegate] internal static ctre_TalonSRX_SetOverrideBrakeTypeDelegate ctre_TalonSRX_SetOverrideBrakeType; [NativeDelegate] internal static ctre_TalonSRX_SetModeSelectDelegate ctre_TalonSRX_SetModeSelect; [NativeDelegate] internal static ctre_TalonSRX_SetProfileSlotSelectDelegate ctre_TalonSRX_SetProfileSlotSelect; [NativeDelegate] internal static ctre_TalonSRX_SetRampThrottleDelegate ctre_TalonSRX_SetRampThrottle; [NativeDelegate] internal static ctre_TalonSRX_SetRevFeedbackSensorDelegate ctre_TalonSRX_SetRevFeedbackSensor; public static NativeLibraryLoader NativeLoader { get; } private HALCanTalonSRX() { } private void Ping() { } ~HALCanTalonSRX() { if (s_runFinalizer) { NativeLoader.get_LibraryLoader().UnloadLibrary(); try { if (!s_useCommandLineFile && File.Exists(s_libraryLocation)) File.Delete(s_libraryLocation); } catch { } } } static HALCanTalonSRX() { finalizeInterop = new HALCanTalonSRX(); if (!s_libraryLoaded) { try { string[] commandLineArgs = Environment.GetCommandLineArgs(); string[] array = commandLineArgs; foreach (string text in array) { if (text.ToLower().Contains("-ctre:")) { int num = text.IndexOf(':'); string path = text.Substring(num + 1); if (File.Exists(path)) { s_libraryLocation = path; s_useCommandLineFile = true; } } } if (!File.Exists("/usr/local/frc/bin/frcRunRobot.sh")) throw new NotSupportedException("Desktop is not supported with CAN Talon SRX"); NativeLoader = new NativeLibraryLoader(); NativeLoader.AddLibraryLocation(7, "FRC.WPILib.CTRE.Libraries.libctreextern.so"); if (s_useCommandLineFile) NativeLoader.LoadNativeLibrary<HALCanTalonSRX>(s_libraryLocation, true, (string)null); else { NativeLoader.LoadNativeLibrary<HALCanTalonSRX>(false, (string)null); s_libraryLocation = NativeLoader.get_LibraryLocation(); } NativeDelegateInitializer.SetupNativeDelegates<HALCanTalonSRX>(NativeLoader); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Environment.Exit(1); } s_runFinalizer = true; s_libraryLoaded = true; } } } }