text
stringlengths 30
1.67M
|
|---|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tAnalogTrigger extends tSystem { public tAnalogTrigger ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:8> ; public final int m_SystemIndex ; private static final int kSourceSelect_Channel_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_Channel_BitfieldOffset = <NUM_LIT:12> ; private static final int kSourceSelect_Module_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_Module_BitfieldOffset = <NUM_LIT:11> ; private static final int kSourceSelect_Averaged_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_Averaged_BitfieldOffset = <NUM_LIT:10> ; private static final int kSourceSelect_Filter_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_Filter_BitfieldOffset = <NUM_LIT:9> ; private static final int kSourceSelect_FloatingRollover_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_FloatingRollover_BitfieldOffset = <NUM_LIT:8> ; private static final int kSourceSelect_RolloverLimit_BitfieldMask = <NUM_LIT> ; private static final int kSourceSelect_RolloverLimit_BitfieldOffset = <NUM_LIT:0> ; private static final int kSourceSelect_RolloverLimit_FixedPointIntegerShift = <NUM_LIT:4> ; private static final int kAnalogTrigger0_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger1_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger2_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger3_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger4_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger5_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger6_SourceSelect_Address = <NUM_LIT> ; private static final int kAnalogTrigger7_SourceSelect_Address = <NUM_LIT> ; private static final int kSourceSelect_Addresses [ ] = { kAnalogTrigger0_SourceSelect_Address , kAnalogTrigger1_SourceSelect_Address , kAnalogTrigger2_SourceSelect_Address , kAnalogTrigger3_SourceSelect_Address , kAnalogTrigger4_SourceSelect_Address , kAnalogTrigger5_SourceSelect_Address , kAnalogTrigger6_SourceSelect_Address , kAnalogTrigger7_SourceSelect_Address , } ; public void writeSourceSelect ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeSourceSelect_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_Channel_BitfieldMask ; regValue |= ( ( value ) << kSourceSelect_Channel_BitfieldOffset ) & kSourceSelect_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSourceSelect_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_Module_BitfieldMask ; regValue |= ( ( value ) << kSourceSelect_Module_BitfieldOffset ) & kSourceSelect_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSourceSelect_Averaged ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_Averaged_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kSourceSelect_Averaged_BitfieldOffset ) & kSourceSelect_Averaged_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSourceSelect_Filter ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_Filter_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kSourceSelect_Filter_BitfieldOffset ) & kSourceSelect_Filter_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSourceSelect_FloatingRollover ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_FloatingRollover_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kSourceSelect_FloatingRollover_BitfieldOffset ) & kSourceSelect_FloatingRollover_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSourceSelect_RolloverLimit ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSourceSelect_RolloverLimit_BitfieldMask ; regValue |= ( ( value > > > kSourceSelect_RolloverLimit_FixedPointIntegerShift ) << kSourceSelect_RolloverLimit_BitfieldOffset ) & kSourceSelect_RolloverLimit_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readSourceSelect ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readSourceSelect_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_Channel_BitfieldMask ) > > > kSourceSelect_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readSourceSelect_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_Module_BitfieldMask ) > > > kSourceSelect_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readSourceSelect_Averaged ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_Averaged_BitfieldMask ) > > > kSourceSelect_Averaged_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readSourceSelect_Filter ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_Filter_BitfieldMask ) > > > kSourceSelect_Filter_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readSourceSelect_FloatingRollover ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_FloatingRollover_BitfieldMask ) > > > kSourceSelect_FloatingRollover_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public short readSourceSelect_RolloverLimit ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSourceSelect_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSourceSelect_RolloverLimit_BitfieldMask ) > > > kSourceSelect_RolloverLimit_BitfieldOffset ) << kSourceSelect_RolloverLimit_FixedPointIntegerShift ; bitfieldValue <<= <NUM_LIT:20> ; bitfieldValue >>= <NUM_LIT:20> ; return ( short ) ( bitfieldValue ) ; } private static final int kAnalogTrigger0_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger1_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger2_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger3_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger4_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger5_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger6_UpperLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger7_UpperLimit_Address = <NUM_LIT> ; private static final int kUpperLimit_Addresses [ ] = { kAnalogTrigger0_UpperLimit_Address , kAnalogTrigger1_UpperLimit_Address , kAnalogTrigger2_UpperLimit_Address , kAnalogTrigger3_UpperLimit_Address , kAnalogTrigger4_UpperLimit_Address , kAnalogTrigger5_UpperLimit_Address , kAnalogTrigger6_UpperLimit_Address , kAnalogTrigger7_UpperLimit_Address , } ; public void writeUpperLimit ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kUpperLimit_Addresses [ m_SystemIndex ] , value , status ) ; } public int readUpperLimit ( ) { return ( int ) ( NiRioSrv . peek32 ( m_DeviceHandle , kUpperLimit_Addresses [ m_SystemIndex ] , status ) ) ; } private static final int kAnalogTrigger0_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger1_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger2_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger3_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger4_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger5_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger6_LowerLimit_Address = <NUM_LIT> ; private static final int kAnalogTrigger7_LowerLimit_Address = <NUM_LIT> ; private static final int kLowerLimit_Addresses [ ] = { kAnalogTrigger0_LowerLimit_Address , kAnalogTrigger1_LowerLimit_Address , kAnalogTrigger2_LowerLimit_Address , kAnalogTrigger3_LowerLimit_Address , kAnalogTrigger4_LowerLimit_Address , kAnalogTrigger5_LowerLimit_Address , kAnalogTrigger6_LowerLimit_Address , kAnalogTrigger7_LowerLimit_Address , } ; public void writeLowerLimit ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kLowerLimit_Addresses [ m_SystemIndex ] , value , status ) ; } public int readLowerLimit ( ) { return ( int ) ( NiRioSrv . peek32 ( m_DeviceHandle , kLowerLimit_Addresses [ m_SystemIndex ] , status ) ) ; } public static final int kOutput_NumElements = <NUM_LIT:8> ; public static final int kOutput_ElementSize = <NUM_LIT:4> ; public static final int kOutput_ElementMask = <NUM_LIT> ; private static final int kOutput_InHysteresis_BitfieldMask = <NUM_LIT> ; private static final int kOutput_InHysteresis_BitfieldOffset = <NUM_LIT:3> ; private static final int kOutput_OverLimit_BitfieldMask = <NUM_LIT> ; private static final int kOutput_OverLimit_BitfieldOffset = <NUM_LIT:2> ; private static final int kOutput_Rising_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Rising_BitfieldOffset = <NUM_LIT:1> ; private static final int kOutput_Falling_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Falling_BitfieldOffset = <NUM_LIT:0> ; private static final int kAnalogTrigger_Output_Address = <NUM_LIT> ; public static int readOutput ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOutput_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAnalogTrigger_Output_Address , status ) > > > ( ( kOutput_NumElements - <NUM_LIT:1> - bitfield_index ) * kOutput_ElementSize ) ; return ( int ) ( regValue ) ; } public static boolean readOutput_InHysteresis ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOutput_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAnalogTrigger_Output_Address , status ) > > > ( ( kOutput_NumElements - <NUM_LIT:1> - bitfield_index ) * kOutput_ElementSize ) ; int bitfieldValue = ( ( regValue & kOutput_InHysteresis_BitfieldMask ) > > > kOutput_InHysteresis_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readOutput_OverLimit ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOutput_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAnalogTrigger_Output_Address , status ) > > > ( ( kOutput_NumElements - <NUM_LIT:1> - bitfield_index ) * kOutput_ElementSize ) ; int bitfieldValue = ( ( regValue & kOutput_OverLimit_BitfieldMask ) > > > kOutput_OverLimit_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readOutput_Rising ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOutput_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAnalogTrigger_Output_Address , status ) > > > ( ( kOutput_NumElements - <NUM_LIT:1> - bitfield_index ) * kOutput_ElementSize ) ; int bitfieldValue = ( ( regValue & kOutput_Rising_BitfieldMask ) > > > kOutput_Rising_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readOutput_Falling ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOutput_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAnalogTrigger_Output_Address , status ) > > > ( ( kOutput_NumElements - <NUM_LIT:1> - bitfield_index ) * kOutput_ElementSize ) ; int bitfieldValue = ( ( regValue & kOutput_Falling_BitfieldMask ) > > > kOutput_Falling_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; import edu . wpi . first . wpilibj . communication . BumARioHandle ; public abstract class tSystem implements ExpectedFPGASignature , DMAChannelDescriptors { protected static int m_DeviceHandle = <NUM_LIT:0> ; private static int m_ReferenceCount = <NUM_LIT:0> ; public static NiRioStatus status = new NiRioStatus ( ) ; private static final String kRIO_DEVICE_NAME = "<STR_LIT>" ; private static final int kFPGA_RESET_REGISTER = <NUM_LIT> ; private static final int kFPGA_COMMAND_REGISTER = <NUM_LIT> ; private static final int kFPGA_COMMAND_ENABLE_CLEAR = <NUM_LIT:4> ; private static final int kFPGA_COMMAND_ENABLE_IN = <NUM_LIT:2> ; private static final int kFPGA_INTERRUPT_BASE_ADDRESS = <NUM_LIT> ; private static final int kFPGA_SIGNATURE_REGISTER = <NUM_LIT> ; private static final int kMITE_IOPCR_REGISTER = <NUM_LIT> ; private static final int kMITE_IOPCR_32BIT = <NUM_LIT> ; protected tSystem ( ) { NiRioStatus versionStatus = new NiRioStatus ( ) ; if ( m_DeviceHandle == <NUM_LIT:0> ) { m_DeviceHandle = BumARioHandle . bum ( status . getPointer ( ) ) ; int hwGUID [ ] = new int [ <NUM_LIT:4> ] ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { NiRioStatus cleanStatus = new NiRioStatus ( ) ; hwGUID [ i ] = NiRioSrv . peek32 ( m_DeviceHandle , kFPGA_SIGNATURE_REGISTER , cleanStatus ) ; status . setStatus ( cleanStatus ) ; if ( hwGUID [ i ] != kExpectedFPGASignature [ i ] ) { versionStatus . setStatus ( NiRioStatus . kRIOStatusVersionMismatch ) ; } } System . out . print ( "<STR_LIT>" ) ; printGUID ( hwGUID ) ; System . out . println ( "<STR_LIT>" ) ; System . out . print ( "<STR_LIT>" ) ; printGUID ( kExpectedFPGASignature ) ; System . out . println ( "<STR_LIT>" ) ; } status . setStatus ( versionStatus ) ; } private static void printGUID ( int guid [ ] ) { System . out . print ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { long longVar = guid [ i ] ; String word = Long . toString ( longVar & <NUM_LIT> , <NUM_LIT:16> ) ; while ( word . length ( ) < <NUM_LIT:8> ) { word = "<STR_LIT:0>" + word ; } System . out . print ( word ) ; } } protected void finalize ( ) { } public int [ ] getFpgaGuid ( NiRioStatus status ) { int [ ] guid = { <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> } ; if ( m_DeviceHandle == <NUM_LIT:0> ) { status . setStatus ( NiRioStatus . kRIOStatusInvalidHandle ) ; return guid ; } for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { guid [ i ] = NiRioSrv . peek32 ( m_DeviceHandle , kFPGA_SIGNATURE_REGISTER , status ) ; } return guid ; } public void Release ( ) { } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tAlarm extends tSystem { public tAlarm ( ) { super ( ) ; } protected void finalize ( ) { super . finalize ( ) ; } public static final int kNumSystems = <NUM_LIT:1> ; private static final int kAlarm_TriggerTime_Address = <NUM_LIT> ; public static void writeTriggerTime ( final long value ) { NiRioSrv . poke32 ( m_DeviceHandle , kAlarm_TriggerTime_Address , ( int ) ( value ) , status ) ; } public static long readTriggerTime ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kAlarm_TriggerTime_Address , status ) ) & <NUM_LIT> ) ; } private static final int kAlarm_Enable_Address = <NUM_LIT> ; public static void writeEnable ( final boolean value ) { NiRioSrv . poke32 ( m_DeviceHandle , kAlarm_Enable_Address , ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) , status ) ; } public static boolean readEnable ( ) { return ( ( NiRioSrv . peek32 ( m_DeviceHandle , kAlarm_Enable_Address , status ) ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; public interface DMAChannelDescriptors { public static final int kDMA_VERSION = <NUM_LIT:1> ; public static final int kNUM_DMA_CHANNELS = <NUM_LIT:1> ; static class tDMAChannelDescriptor { public tDMAChannelDescriptor ( int c , int ba , int d , int w ) { channel = c ; baseAddress = ba ; depth = d ; write = w ; } public final int channel ; public final int baseAddress ; public final int depth ; public final int write ; } static final tDMAChannelDescriptor kDMAChannelDescriptors [ ] = { new tDMAChannelDescriptor ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ) , } ; } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; public interface ExpectedFPGASignature { public static final int kExpectedFPGAVersion = <NUM_LIT> ; public static final int kExpectedFPGARevision = <NUM_LIT> ; public static final int kExpectedFPGASignature [ ] = { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , } ; } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tAI extends tSystem { public tAI ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:2> ; public final int m_SystemIndex ; private static final int kConfig_ScanSize_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ScanSize_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_ConvertRate_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ConvertRate_BitfieldOffset = <NUM_LIT:0> ; private static final int kAI0_Config_Address = <NUM_LIT> ; private static final int kAI1_Config_Address = <NUM_LIT> ; private static final int kConfig_Addresses [ ] = { kAI0_Config_Address , kAI1_Config_Address , } ; public void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeConfig_ScanSize ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_ScanSize_BitfieldMask ; regValue |= ( ( value ) << kConfig_ScanSize_BitfieldOffset ) & kConfig_ScanSize_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_ConvertRate ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_ConvertRate_BitfieldMask ; regValue |= ( ( value ) << kConfig_ConvertRate_BitfieldOffset ) & kConfig_ConvertRate_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readConfig_ScanSize ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_ScanSize_BitfieldMask ) > > > kConfig_ScanSize_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public int readConfig_ConvertRate ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_ConvertRate_BitfieldMask ) > > > kConfig_ConvertRate_BitfieldOffset ) ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static final int kScanList_NumElements = <NUM_LIT:8> ; public static final int kScanList_ElementSize = <NUM_LIT:3> ; public static final int kScanList_ElementMask = <NUM_LIT> ; private static final int kAI0_ScanList_Address = <NUM_LIT> ; private static final int kAI1_ScanList_Address = <NUM_LIT> ; private static final int kScanList_Addresses [ ] = { kAI0_ScanList_Address , kAI1_ScanList_Address , } ; public void writeScanList ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kScanList_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kScanList_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kScanList_ElementMask << ( ( kScanList_NumElements - <NUM_LIT:1> - bitfield_index ) * kScanList_ElementSize ) ) ; regValue |= ( ( value & kScanList_ElementMask ) << ( ( kScanList_NumElements - <NUM_LIT:1> - bitfield_index ) * kScanList_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kScanList_Addresses [ m_SystemIndex ] , regValue , status ) ; } public byte readScanList ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kScanList_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kScanList_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kScanList_NumElements - <NUM_LIT:1> - bitfield_index ) * kScanList_ElementSize ) ) & kScanList_ElementMask ; return ( byte ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } public static final int kAverageBits_NumElements = <NUM_LIT:8> ; public static final int kAverageBits_ElementSize = <NUM_LIT:4> ; public static final int kAverageBits_ElementMask = <NUM_LIT> ; private static final int kAI0_AverageBits_Address = <NUM_LIT> ; private static final int kAI1_AverageBits_Address = <NUM_LIT> ; private static final int kAverageBits_Addresses [ ] = { kAI0_AverageBits_Address , kAI1_AverageBits_Address , } ; public void writeAverageBits ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kAverageBits_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAverageBits_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kAverageBits_ElementMask << ( ( kAverageBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kAverageBits_ElementSize ) ) ; regValue |= ( ( value & kAverageBits_ElementMask ) << ( ( kAverageBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kAverageBits_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kAverageBits_Addresses [ m_SystemIndex ] , regValue , status ) ; } public byte readAverageBits ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kAverageBits_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kAverageBits_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kAverageBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kAverageBits_ElementSize ) ) & kAverageBits_ElementMask ; return ( byte ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } private static final int kAI0_LoopTiming_Address = <NUM_LIT> ; private static final int kAI1_LoopTiming_Address = <NUM_LIT> ; private static final int kLoopTiming_Addresses [ ] = { kAI0_LoopTiming_Address , kAI1_LoopTiming_Address , } ; public long readLoopTiming ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kLoopTiming_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } public static final int kOversampleBits_NumElements = <NUM_LIT:8> ; public static final int kOversampleBits_ElementSize = <NUM_LIT:4> ; public static final int kOversampleBits_ElementMask = <NUM_LIT> ; private static final int kAI0_OversampleBits_Address = <NUM_LIT> ; private static final int kAI1_OversampleBits_Address = <NUM_LIT> ; private static final int kOversampleBits_Addresses [ ] = { kAI0_OversampleBits_Address , kAI1_OversampleBits_Address , } ; public void writeOversampleBits ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kOversampleBits_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOversampleBits_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kOversampleBits_ElementMask << ( ( kOversampleBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kOversampleBits_ElementSize ) ) ; regValue |= ( ( value & kOversampleBits_ElementMask ) << ( ( kOversampleBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kOversampleBits_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kOversampleBits_Addresses [ m_SystemIndex ] , regValue , status ) ; } public byte readOversampleBits ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kOversampleBits_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kOversampleBits_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kOversampleBits_NumElements - <NUM_LIT:1> - bitfield_index ) * kOversampleBits_ElementSize ) ) & kOversampleBits_ElementMask ; return ( byte ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } private static final int kAI_Output_Address = <NUM_LIT> ; public static int readOutput ( ) { return ( int ) ( NiRioSrv . peek32 ( m_DeviceHandle , kAI_Output_Address , status ) ) ; } private static final int kReadSelect_Channel_BitfieldMask = <NUM_LIT> ; private static final int kReadSelect_Channel_BitfieldOffset = <NUM_LIT:2> ; private static final int kReadSelect_Module_BitfieldMask = <NUM_LIT> ; private static final int kReadSelect_Module_BitfieldOffset = <NUM_LIT:1> ; private static final int kReadSelect_Averaged_BitfieldMask = <NUM_LIT> ; private static final int kReadSelect_Averaged_BitfieldOffset = <NUM_LIT:0> ; private static final int kAI_ReadSelect_Address = <NUM_LIT> ; public static void writeReadSelect ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kAI_ReadSelect_Address , value , status ) ; } public static void writeReadSelect_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; regValue &= ~ kReadSelect_Channel_BitfieldMask ; regValue |= ( ( value ) << kReadSelect_Channel_BitfieldOffset ) & kReadSelect_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kAI_ReadSelect_Address , regValue , status ) ; } public static void writeReadSelect_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; regValue &= ~ kReadSelect_Module_BitfieldMask ; regValue |= ( ( value ) << kReadSelect_Module_BitfieldOffset ) & kReadSelect_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kAI_ReadSelect_Address , regValue , status ) ; } public static void writeReadSelect_Averaged ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; regValue &= ~ kReadSelect_Averaged_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kReadSelect_Averaged_BitfieldOffset ) & kReadSelect_Averaged_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kAI_ReadSelect_Address , regValue , status ) ; } public static int readReadSelect ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; return ( int ) ( regValue ) ; } public static byte readReadSelect_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; int bitfieldValue = ( ( regValue & kReadSelect_Channel_BitfieldMask ) > > > kReadSelect_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readReadSelect_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; int bitfieldValue = ( ( regValue & kReadSelect_Module_BitfieldMask ) > > > kReadSelect_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static boolean readReadSelect_Averaged ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kAI_ReadSelect_Address , status ) ; int bitfieldValue = ( ( regValue & kReadSelect_Averaged_BitfieldMask ) > > > kReadSelect_Averaged_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kAI_LatchOutput_Address = <NUM_LIT> ; public static void strobeLatchOutput ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kAI_LatchOutput_Address , <NUM_LIT:1> , status ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tDIO extends tSystem { public tDIO ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:2> ; public final int m_SystemIndex ; private static final int kDIO0_DO_Address = <NUM_LIT> ; private static final int kDIO1_DO_Address = <NUM_LIT> ; private static final int kDO_Addresses [ ] = { kDIO0_DO_Address , kDIO1_DO_Address , } ; public void writeDO ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDO_Addresses [ m_SystemIndex ] , value , status ) ; } public int readDO ( ) { return ( int ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kDO_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kDIO0_I2CDataToSend_Address = <NUM_LIT> ; private static final int kDIO1_I2CDataToSend_Address = <NUM_LIT> ; private static final int kI2CDataToSend_Addresses [ ] = { kDIO0_I2CDataToSend_Address , kDIO1_I2CDataToSend_Address , } ; public void writeI2CDataToSend ( final long value ) { NiRioSrv . poke32 ( m_DeviceHandle , kI2CDataToSend_Addresses [ m_SystemIndex ] , ( int ) ( value ) , status ) ; } public long readI2CDataToSend ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kI2CDataToSend_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } public static final int kFilterSelect_NumElements = <NUM_LIT:16> ; public static final int kFilterSelect_ElementSize = <NUM_LIT:2> ; public static final int kFilterSelect_ElementMask = <NUM_LIT> ; private static final int kDIO0_FilterSelect_Address = <NUM_LIT> ; private static final int kDIO1_FilterSelect_Address = <NUM_LIT> ; private static final int kFilterSelect_Addresses [ ] = { kDIO0_FilterSelect_Address , kDIO1_FilterSelect_Address , } ; public void writeFilterSelect ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kFilterSelect_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kFilterSelect_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kFilterSelect_ElementMask << ( ( kFilterSelect_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterSelect_ElementSize ) ) ; regValue |= ( ( value & kFilterSelect_ElementMask ) << ( ( kFilterSelect_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterSelect_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kFilterSelect_Addresses [ m_SystemIndex ] , regValue , status ) ; } public byte readFilterSelect ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kFilterSelect_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kFilterSelect_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kFilterSelect_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterSelect_ElementSize ) ) & kFilterSelect_ElementMask ; return ( byte ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } public static final int kFilterPeriod_NumElements = <NUM_LIT:3> ; public static final int kFilterPeriod_ElementSize = <NUM_LIT:8> ; public static final int kFilterPeriod_ElementMask = <NUM_LIT> ; private static final int kDIO0_FilterPeriod_Address = <NUM_LIT> ; private static final int kDIO1_FilterPeriod_Address = <NUM_LIT> ; private static final int kFilterPeriod_Addresses [ ] = { kDIO0_FilterPeriod_Address , kDIO1_FilterPeriod_Address , } ; public void writeFilterPeriod ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kFilterPeriod_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kFilterPeriod_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kFilterPeriod_ElementMask << ( ( kFilterPeriod_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterPeriod_ElementSize ) ) ; regValue |= ( ( value & kFilterPeriod_ElementMask ) << ( ( kFilterPeriod_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterPeriod_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kFilterPeriod_Addresses [ m_SystemIndex ] , regValue , status ) ; } public short readFilterPeriod ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kFilterPeriod_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kFilterPeriod_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kFilterPeriod_NumElements - <NUM_LIT:1> - bitfield_index ) * kFilterPeriod_ElementSize ) ) & kFilterPeriod_ElementMask ; return ( short ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } private static final int kDIO0_OutputEnable_Address = <NUM_LIT> ; private static final int kDIO1_OutputEnable_Address = <NUM_LIT> ; private static final int kOutputEnable_Addresses [ ] = { kDIO0_OutputEnable_Address , kDIO1_OutputEnable_Address , } ; public void writeOutputEnable ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kOutputEnable_Addresses [ m_SystemIndex ] , value , status ) ; } public int readOutputEnable ( ) { return ( int ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kOutputEnable_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kDIO0_DI_Address = <NUM_LIT> ; private static final int kDIO1_DI_Address = <NUM_LIT> ; private static final int kDI_Addresses [ ] = { kDIO0_DI_Address , kDIO1_DI_Address , } ; public int readDI ( ) { return ( int ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kDI_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kDIO0_I2CDataReceived_Address = <NUM_LIT> ; private static final int kDIO1_I2CDataReceived_Address = <NUM_LIT> ; private static final int kI2CDataReceived_Addresses [ ] = { kDIO0_I2CDataReceived_Address , kDIO1_I2CDataReceived_Address , } ; public long readI2CDataReceived ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kI2CDataReceived_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kI2CStatus_Transaction_BitfieldMask = <NUM_LIT> ; private static final int kI2CStatus_Transaction_BitfieldOffset = <NUM_LIT> ; private static final int kI2CStatus_Done_BitfieldMask = <NUM_LIT> ; private static final int kI2CStatus_Done_BitfieldOffset = <NUM_LIT> ; private static final int kI2CStatus_Aborted_BitfieldMask = <NUM_LIT> ; private static final int kI2CStatus_Aborted_BitfieldOffset = <NUM_LIT:24> ; private static final int kI2CStatus_DataReceivedHigh_BitfieldMask = <NUM_LIT> ; private static final int kI2CStatus_DataReceivedHigh_BitfieldOffset = <NUM_LIT:0> ; private static final int kDIO0_I2CStatus_Address = <NUM_LIT> ; private static final int kDIO1_I2CStatus_Address = <NUM_LIT> ; private static final int kI2CStatus_Addresses [ ] = { kDIO0_I2CStatus_Address , kDIO1_I2CStatus_Address , } ; public int readI2CStatus ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CStatus_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readI2CStatus_Transaction ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CStatus_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CStatus_Transaction_BitfieldMask ) > > > kI2CStatus_Transaction_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readI2CStatus_Done ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CStatus_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CStatus_Done_BitfieldMask ) > > > kI2CStatus_Done_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readI2CStatus_Aborted ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CStatus_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CStatus_Aborted_BitfieldMask ) > > > kI2CStatus_Aborted_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public int readI2CStatus_DataReceivedHigh ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CStatus_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CStatus_DataReceivedHigh_BitfieldMask ) > > > kI2CStatus_DataReceivedHigh_BitfieldOffset ) ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } private static final int kSlowValue_RelayFwd_BitfieldMask = <NUM_LIT> ; private static final int kSlowValue_RelayFwd_BitfieldOffset = <NUM_LIT:12> ; private static final int kSlowValue_RelayRev_BitfieldMask = <NUM_LIT> ; private static final int kSlowValue_RelayRev_BitfieldOffset = <NUM_LIT:4> ; private static final int kSlowValue_I2CHeader_BitfieldMask = <NUM_LIT> ; private static final int kSlowValue_I2CHeader_BitfieldOffset = <NUM_LIT:0> ; private static final int kDIO0_SlowValue_Address = <NUM_LIT> ; private static final int kDIO1_SlowValue_Address = <NUM_LIT> ; private static final int kSlowValue_Addresses [ ] = { kDIO0_SlowValue_Address , kDIO1_SlowValue_Address , } ; public void writeSlowValue ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeSlowValue_RelayFwd ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSlowValue_RelayFwd_BitfieldMask ; regValue |= ( ( value ) << kSlowValue_RelayFwd_BitfieldOffset ) & kSlowValue_RelayFwd_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSlowValue_RelayRev ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSlowValue_RelayRev_BitfieldMask ; regValue |= ( ( value ) << kSlowValue_RelayRev_BitfieldOffset ) & kSlowValue_RelayRev_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeSlowValue_I2CHeader ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kSlowValue_I2CHeader_BitfieldMask ; regValue |= ( ( value ) << kSlowValue_I2CHeader_BitfieldOffset ) & kSlowValue_I2CHeader_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readSlowValue ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public short readSlowValue_RelayFwd ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSlowValue_RelayFwd_BitfieldMask ) > > > kSlowValue_RelayFwd_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public short readSlowValue_RelayRev ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSlowValue_RelayRev_BitfieldMask ) > > > kSlowValue_RelayRev_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readSlowValue_I2CHeader ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSlowValue_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kSlowValue_I2CHeader_BitfieldMask ) > > > kSlowValue_I2CHeader_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static final int kPWMPeriodScale_NumElements = <NUM_LIT:10> ; public static final int kPWMPeriodScale_ElementSize = <NUM_LIT:2> ; public static final int kPWMPeriodScale_ElementMask = <NUM_LIT> ; private static final int kDIO0_PWMPeriodScale_Address = <NUM_LIT> ; private static final int kDIO1_PWMPeriodScale_Address = <NUM_LIT> ; private static final int kPWMPeriodScale_Addresses [ ] = { kDIO0_PWMPeriodScale_Address , kDIO1_PWMPeriodScale_Address , } ; public void writePWMPeriodScale ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kPWMPeriodScale_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kPWMPeriodScale_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kPWMPeriodScale_ElementMask << ( ( kPWMPeriodScale_NumElements - <NUM_LIT:1> - bitfield_index ) * kPWMPeriodScale_ElementSize ) ) ; regValue |= ( ( value & kPWMPeriodScale_ElementMask ) << ( ( kPWMPeriodScale_NumElements - <NUM_LIT:1> - bitfield_index ) * kPWMPeriodScale_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kPWMPeriodScale_Addresses [ m_SystemIndex ] , regValue , status ) ; } public byte readPWMPeriodScale ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kPWMPeriodScale_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kPWMPeriodScale_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kPWMPeriodScale_NumElements - <NUM_LIT:1> - bitfield_index ) * kPWMPeriodScale_ElementSize ) ) & kPWMPeriodScale_ElementMask ; return ( byte ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } private static final int kDIO0_Pulse_Address = <NUM_LIT> ; private static final int kDIO1_Pulse_Address = <NUM_LIT> ; private static final int kPulse_Addresses [ ] = { kDIO0_Pulse_Address , kDIO1_Pulse_Address , } ; public void writePulse ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kPulse_Addresses [ m_SystemIndex ] , value , status ) ; } public int readPulse ( ) { return ( int ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kPulse_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kDIO0_I2CStart_Address = <NUM_LIT> ; private static final int kDIO1_I2CStart_Address = <NUM_LIT> ; private static final int kI2CStart_Addresses [ ] = { kDIO0_I2CStart_Address , kDIO1_I2CStart_Address , } ; public void strobeI2CStart ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kI2CStart_Addresses [ m_SystemIndex ] , <NUM_LIT:1> , status ) ; } private static final int kDIO0_BFL_Address = <NUM_LIT> ; private static final int kDIO1_BFL_Address = <NUM_LIT> ; private static final int kBFL_Addresses [ ] = { kDIO0_BFL_Address , kDIO1_BFL_Address , } ; public void writeBFL ( final boolean value ) { NiRioSrv . poke32 ( m_DeviceHandle , kBFL_Addresses [ m_SystemIndex ] , ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) , status ) ; } public boolean readBFL ( ) { return ( ( NiRioSrv . peek32 ( m_DeviceHandle , kBFL_Addresses [ m_SystemIndex ] , status ) ) != <NUM_LIT:0> ? true : false ) ; } public static final int kDO_PWMDutyCycle_NumElements = <NUM_LIT:4> ; public static final int kDO_PWMDutyCycle_ElementSize = <NUM_LIT:8> ; public static final int kDO_PWMDutyCycle_ElementMask = <NUM_LIT> ; private static final int kDIO0_DO_PWMDutyCycle_Address = <NUM_LIT> ; private static final int kDIO1_DO_PWMDutyCycle_Address = <NUM_LIT> ; private static final int kDO_PWMDutyCycle_Addresses [ ] = { kDIO0_DO_PWMDutyCycle_Address , kDIO1_DO_PWMDutyCycle_Address , } ; public void writeDO_PWMDutyCycle ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kDO_PWMDutyCycle_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMDutyCycle_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ ( kDO_PWMDutyCycle_ElementMask << ( ( kDO_PWMDutyCycle_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO_PWMDutyCycle_ElementSize ) ) ; regValue |= ( ( value & kDO_PWMDutyCycle_ElementMask ) << ( ( kDO_PWMDutyCycle_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO_PWMDutyCycle_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMDutyCycle_Addresses [ m_SystemIndex ] , regValue , status ) ; } public short readDO_PWMDutyCycle ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kDO_PWMDutyCycle_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMDutyCycle_Addresses [ m_SystemIndex ] , status ) ) > > > ( ( kDO_PWMDutyCycle_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO_PWMDutyCycle_ElementSize ) ) & kDO_PWMDutyCycle_ElementMask ; return ( short ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } private static final int kDIO0_PulseLength_Address = <NUM_LIT> ; private static final int kDIO1_PulseLength_Address = <NUM_LIT> ; private static final int kPulseLength_Addresses [ ] = { kDIO0_PulseLength_Address , kDIO1_PulseLength_Address , } ; public void writePulseLength ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kPulseLength_Addresses [ m_SystemIndex ] , value , status ) ; } public short readPulseLength ( ) { return ( short ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kPulseLength_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kDO_PWMConfig_PeriodPower_BitfieldMask = <NUM_LIT> ; private static final int kDO_PWMConfig_PeriodPower_BitfieldOffset = <NUM_LIT:16> ; private static final int kDO_PWMConfig_OutputSelect_0_BitfieldMask = <NUM_LIT> ; private static final int kDO_PWMConfig_OutputSelect_0_BitfieldOffset = <NUM_LIT:12> ; private static final int kDO_PWMConfig_OutputSelect_1_BitfieldMask = <NUM_LIT> ; private static final int kDO_PWMConfig_OutputSelect_1_BitfieldOffset = <NUM_LIT:8> ; private static final int kDO_PWMConfig_OutputSelect_2_BitfieldMask = <NUM_LIT> ; private static final int kDO_PWMConfig_OutputSelect_2_BitfieldOffset = <NUM_LIT:4> ; private static final int kDO_PWMConfig_OutputSelect_3_BitfieldMask = <NUM_LIT> ; private static final int kDO_PWMConfig_OutputSelect_3_BitfieldOffset = <NUM_LIT:0> ; private static final int kDIO0_DO_PWMConfig_Address = <NUM_LIT> ; private static final int kDIO1_DO_PWMConfig_Address = <NUM_LIT> ; private static final int kDO_PWMConfig_Addresses [ ] = { kDIO0_DO_PWMConfig_Address , kDIO1_DO_PWMConfig_Address , } ; public void writeDO_PWMConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeDO_PWMConfig_PeriodPower ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kDO_PWMConfig_PeriodPower_BitfieldMask ; regValue |= ( ( value ) << kDO_PWMConfig_PeriodPower_BitfieldOffset ) & kDO_PWMConfig_PeriodPower_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeDO_PWMConfig_OutputSelect_0 ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kDO_PWMConfig_OutputSelect_0_BitfieldMask ; regValue |= ( ( value ) << kDO_PWMConfig_OutputSelect_0_BitfieldOffset ) & kDO_PWMConfig_OutputSelect_0_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeDO_PWMConfig_OutputSelect_1 ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kDO_PWMConfig_OutputSelect_1_BitfieldMask ; regValue |= ( ( value ) << kDO_PWMConfig_OutputSelect_1_BitfieldOffset ) & kDO_PWMConfig_OutputSelect_1_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeDO_PWMConfig_OutputSelect_2 ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kDO_PWMConfig_OutputSelect_2_BitfieldMask ; regValue |= ( ( value ) << kDO_PWMConfig_OutputSelect_2_BitfieldOffset ) & kDO_PWMConfig_OutputSelect_2_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeDO_PWMConfig_OutputSelect_3 ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kDO_PWMConfig_OutputSelect_3_BitfieldMask ; regValue |= ( ( value ) << kDO_PWMConfig_OutputSelect_3_BitfieldOffset ) & kDO_PWMConfig_OutputSelect_3_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readDO_PWMConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readDO_PWMConfig_PeriodPower ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kDO_PWMConfig_PeriodPower_BitfieldMask ) > > > kDO_PWMConfig_PeriodPower_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readDO_PWMConfig_OutputSelect_0 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kDO_PWMConfig_OutputSelect_0_BitfieldMask ) > > > kDO_PWMConfig_OutputSelect_0_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readDO_PWMConfig_OutputSelect_1 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kDO_PWMConfig_OutputSelect_1_BitfieldMask ) > > > kDO_PWMConfig_OutputSelect_1_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readDO_PWMConfig_OutputSelect_2 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kDO_PWMConfig_OutputSelect_2_BitfieldMask ) > > > kDO_PWMConfig_OutputSelect_2_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readDO_PWMConfig_OutputSelect_3 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDO_PWMConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kDO_PWMConfig_OutputSelect_3_BitfieldMask ) > > > kDO_PWMConfig_OutputSelect_3_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } private static final int kI2CConfig_Address_BitfieldMask = <NUM_LIT> ; private static final int kI2CConfig_Address_BitfieldOffset = <NUM_LIT> ; private static final int kI2CConfig_BytesToRead_BitfieldMask = <NUM_LIT> ; private static final int kI2CConfig_BytesToRead_BitfieldOffset = <NUM_LIT:20> ; private static final int kI2CConfig_BytesToWrite_BitfieldMask = <NUM_LIT> ; private static final int kI2CConfig_BytesToWrite_BitfieldOffset = <NUM_LIT> ; private static final int kI2CConfig_DataToSendHigh_BitfieldMask = <NUM_LIT> ; private static final int kI2CConfig_DataToSendHigh_BitfieldOffset = <NUM_LIT:1> ; private static final int kI2CConfig_BitwiseHandshake_BitfieldMask = <NUM_LIT> ; private static final int kI2CConfig_BitwiseHandshake_BitfieldOffset = <NUM_LIT:0> ; private static final int kDIO0_I2CConfig_Address = <NUM_LIT> ; private static final int kDIO1_I2CConfig_Address = <NUM_LIT> ; private static final int kI2CConfig_Addresses [ ] = { kDIO0_I2CConfig_Address , kDIO1_I2CConfig_Address , } ; public void writeI2CConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeI2CConfig_Address ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kI2CConfig_Address_BitfieldMask ; regValue |= ( ( value ) << kI2CConfig_Address_BitfieldOffset ) & kI2CConfig_Address_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeI2CConfig_BytesToRead ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kI2CConfig_BytesToRead_BitfieldMask ; regValue |= ( ( value ) << kI2CConfig_BytesToRead_BitfieldOffset ) & kI2CConfig_BytesToRead_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeI2CConfig_BytesToWrite ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kI2CConfig_BytesToWrite_BitfieldMask ; regValue |= ( ( value ) << kI2CConfig_BytesToWrite_BitfieldOffset ) & kI2CConfig_BytesToWrite_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeI2CConfig_DataToSendHigh ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kI2CConfig_DataToSendHigh_BitfieldMask ; regValue |= ( ( value ) << kI2CConfig_DataToSendHigh_BitfieldOffset ) & kI2CConfig_DataToSendHigh_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeI2CConfig_BitwiseHandshake ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kI2CConfig_BitwiseHandshake_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kI2CConfig_BitwiseHandshake_BitfieldOffset ) & kI2CConfig_BitwiseHandshake_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readI2CConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public short readI2CConfig_Address ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CConfig_Address_BitfieldMask ) > > > kI2CConfig_Address_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readI2CConfig_BytesToRead ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CConfig_BytesToRead_BitfieldMask ) > > > kI2CConfig_BytesToRead_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readI2CConfig_BytesToWrite ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CConfig_BytesToWrite_BitfieldMask ) > > > kI2CConfig_BytesToWrite_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public int readI2CConfig_DataToSendHigh ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CConfig_DataToSendHigh_BitfieldMask ) > > > kI2CConfig_DataToSendHigh_BitfieldOffset ) ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readI2CConfig_BitwiseHandshake ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kI2CConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kI2CConfig_BitwiseHandshake_BitfieldMask ) > > > kI2CConfig_BitwiseHandshake_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kDIO_LoopTiming_Address = <NUM_LIT> ; public static int readLoopTiming ( ) { return ( int ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kDIO_LoopTiming_Address , status ) ) & <NUM_LIT> ) ; } private static final int kPWMConfig_Period_BitfieldMask = <NUM_LIT> ; private static final int kPWMConfig_Period_BitfieldOffset = <NUM_LIT:16> ; private static final int kPWMConfig_MinHigh_BitfieldMask = <NUM_LIT> ; private static final int kPWMConfig_MinHigh_BitfieldOffset = <NUM_LIT:0> ; private static final int kDIO_PWMConfig_Address = <NUM_LIT> ; public static void writePWMConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDIO_PWMConfig_Address , value , status ) ; } public static void writePWMConfig_Period ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDIO_PWMConfig_Address , status ) ; regValue &= ~ kPWMConfig_Period_BitfieldMask ; regValue |= ( ( value ) << kPWMConfig_Period_BitfieldOffset ) & kPWMConfig_Period_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDIO_PWMConfig_Address , regValue , status ) ; } public static void writePWMConfig_MinHigh ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDIO_PWMConfig_Address , status ) ; regValue &= ~ kPWMConfig_MinHigh_BitfieldMask ; regValue |= ( ( value ) << kPWMConfig_MinHigh_BitfieldOffset ) & kPWMConfig_MinHigh_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDIO_PWMConfig_Address , regValue , status ) ; } public static int readPWMConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDIO_PWMConfig_Address , status ) ; return ( int ) ( regValue ) ; } public static int readPWMConfig_Period ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDIO_PWMConfig_Address , status ) ; int bitfieldValue = ( ( regValue & kPWMConfig_Period_BitfieldMask ) > > > kPWMConfig_Period_BitfieldOffset ) ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static int readPWMConfig_MinHigh ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDIO_PWMConfig_Address , status ) ; int bitfieldValue = ( ( regValue & kPWMConfig_MinHigh_BitfieldMask ) > > > kPWMConfig_MinHigh_BitfieldOffset ) ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static final int kPWMValue_NumRegisters = <NUM_LIT:10> ; private static final int kDIO0_PWMValue0_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue1_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue2_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue3_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue4_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue5_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue6_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue7_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue8_Address = <NUM_LIT> ; private static final int kDIO0_PWMValue9_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue0_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue1_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue2_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue3_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue4_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue5_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue6_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue7_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue8_Address = <NUM_LIT> ; private static final int kDIO1_PWMValue9_Address = <NUM_LIT> ; private static final int kPWMValue_Addresses [ ] = { kDIO0_PWMValue0_Address , kDIO0_PWMValue1_Address , kDIO0_PWMValue2_Address , kDIO0_PWMValue3_Address , kDIO0_PWMValue4_Address , kDIO0_PWMValue5_Address , kDIO0_PWMValue6_Address , kDIO0_PWMValue7_Address , kDIO0_PWMValue8_Address , kDIO0_PWMValue9_Address , kDIO1_PWMValue0_Address , kDIO1_PWMValue1_Address , kDIO1_PWMValue2_Address , kDIO1_PWMValue3_Address , kDIO1_PWMValue4_Address , kDIO1_PWMValue5_Address , kDIO1_PWMValue6_Address , kDIO1_PWMValue7_Address , kDIO1_PWMValue8_Address , kDIO1_PWMValue9_Address , } ; public void writePWMValue ( final int reg_index , final int value ) { if ( status . isNotFatal ( ) && reg_index >= kPWMValue_NumRegisters ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } NiRioSrv . poke32 ( m_DeviceHandle , kPWMValue_Addresses [ m_SystemIndex * kPWMValue_NumRegisters + reg_index ] , value , status ) ; } public short readPWMValue ( final int reg_index ) { if ( status . isNotFatal ( ) && reg_index >= kPWMValue_NumRegisters ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } return ( short ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kPWMValue_Addresses [ m_SystemIndex * kPWMValue_NumRegisters + reg_index ] , status ) ) & <NUM_LIT> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tWatchdog extends tSystem { public tWatchdog ( ) { super ( ) ; } protected void finalize ( ) { super . finalize ( ) ; } public static final int kNumSystems = <NUM_LIT:1> ; private static final int kStatus_SystemActive_BitfieldMask = <NUM_LIT> ; private static final int kStatus_SystemActive_BitfieldOffset = <NUM_LIT:31> ; private static final int kStatus_Alive_BitfieldMask = <NUM_LIT> ; private static final int kStatus_Alive_BitfieldOffset = <NUM_LIT:30> ; private static final int kStatus_SysDisableCount_BitfieldMask = <NUM_LIT> ; private static final int kStatus_SysDisableCount_BitfieldOffset = <NUM_LIT:15> ; private static final int kStatus_DisableCount_BitfieldMask = <NUM_LIT> ; private static final int kStatus_DisableCount_BitfieldOffset = <NUM_LIT:0> ; private static final int kWatchdog_Status_Address = <NUM_LIT> ; public static int readStatus ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Status_Address , status ) ; return ( int ) ( regValue ) ; } public static boolean readStatus_SystemActive ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_SystemActive_BitfieldMask ) > > > kStatus_SystemActive_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readStatus_Alive ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_Alive_BitfieldMask ) > > > kStatus_Alive_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static short readStatus_SysDisableCount ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_SysDisableCount_BitfieldMask ) > > > kStatus_SysDisableCount_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static short readStatus_DisableCount ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_DisableCount_BitfieldMask ) > > > kStatus_DisableCount_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } private static final int kWatchdog_Feed_Address = <NUM_LIT> ; public static void strobeFeed ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kWatchdog_Feed_Address , <NUM_LIT:1> , status ) ; } private static final int kWatchdog_Kill_Address = <NUM_LIT> ; public static void strobeKill ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kWatchdog_Kill_Address , <NUM_LIT:1> , status ) ; } private static final int kWatchdog_Immortal_Address = <NUM_LIT> ; public static void writeImmortal ( final boolean value ) { NiRioSrv . poke32 ( m_DeviceHandle , kWatchdog_Immortal_Address , ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) , status ) ; } public static boolean readImmortal ( ) { return ( ( NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Immortal_Address , status ) ) != <NUM_LIT:0> ? true : false ) ; } private static final int kWatchdog_Expiration_Address = <NUM_LIT> ; public static void writeExpiration ( final long value ) { NiRioSrv . poke32 ( m_DeviceHandle , kWatchdog_Expiration_Address , ( int ) ( value ) , status ) ; } public static long readExpiration ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Expiration_Address , status ) ) & <NUM_LIT> ) ; } private static final int kWatchdog_Timer_Address = <NUM_LIT> ; public static long readTimer ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kWatchdog_Timer_Address , status ) ) & <NUM_LIT> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tAccumulator extends tSystem { public tAccumulator ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:2> ; public final int m_SystemIndex ; public static class tOutput { public tOutput ( int regValue1 , int regValue2 , int regValue3 ) { Value = ( ( ( long ) regValue1 ) << <NUM_LIT:32> ) | regValue2 ; Count = regValue3 ; } public final long Value ; public final int Count ; } private static final int kOutput_Value_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Value_BitfieldOffset = <NUM_LIT:32> ; private static final int kOutput_Count_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Count_BitfieldOffset = <NUM_LIT:0> ; private static final int kAccumulator0_Output_Address = <NUM_LIT> ; private static final int kAccumulator1_Output_Address = <NUM_LIT> ; private static final int kOutput_Addresses [ ] = { kAccumulator0_Output_Address , kAccumulator1_Output_Address , } ; public tOutput readOutput ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue2 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue3 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; return new tOutput ( regValue , regValue2 , regValue3 ) ; } public long readOutput_Value ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue2 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue3 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; tOutput val = new tOutput ( regValue , regValue2 , regValue3 ) ; return val . Value ; } public long readOutput_Count ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue2 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int regValue3 = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; tOutput val = new tOutput ( regValue , regValue2 , regValue3 ) ; return val . Count ; } private static final int kAccumulator0_Center_Address = <NUM_LIT> ; private static final int kAccumulator1_Center_Address = <NUM_LIT> ; private static final int kCenter_Addresses [ ] = { kAccumulator0_Center_Address , kAccumulator1_Center_Address , } ; public void writeCenter ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kCenter_Addresses [ m_SystemIndex ] , value , status ) ; } public int readCenter ( ) { return ( int ) ( NiRioSrv . peek32 ( m_DeviceHandle , kCenter_Addresses [ m_SystemIndex ] , status ) ) ; } private static final int kAccumulator0_Reset_Address = <NUM_LIT> ; private static final int kAccumulator1_Reset_Address = <NUM_LIT> ; private static final int kReset_Addresses [ ] = { kAccumulator0_Reset_Address , kAccumulator1_Reset_Address , } ; public void strobeReset ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kReset_Addresses [ m_SystemIndex ] , <NUM_LIT:1> , status ) ; } private static final int kAccumulator0_Deadband_Address = <NUM_LIT> ; private static final int kAccumulator1_Deadband_Address = <NUM_LIT> ; private static final int kDeadband_Addresses [ ] = { kAccumulator0_Deadband_Address , kAccumulator1_Deadband_Address , } ; public void writeDeadband ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDeadband_Addresses [ m_SystemIndex ] , value , status ) ; } public int readDeadband ( ) { return ( int ) ( NiRioSrv . peek32 ( m_DeviceHandle , kDeadband_Addresses [ m_SystemIndex ] , status ) ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tEncoder extends tSystem { public tEncoder ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:4> ; public final int m_SystemIndex ; private static final int kOutput_Direction_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Direction_BitfieldOffset = <NUM_LIT:31> ; private static final int kOutput_Value_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Value_BitfieldOffset = <NUM_LIT:0> ; private static final int kEncoder0_Output_Address = <NUM_LIT> ; private static final int kEncoder1_Output_Address = <NUM_LIT> ; private static final int kEncoder2_Output_Address = <NUM_LIT> ; private static final int kEncoder3_Output_Address = <NUM_LIT> ; private static final int kOutput_Addresses [ ] = { kEncoder0_Output_Address , kEncoder1_Output_Address , kEncoder2_Output_Address , kEncoder3_Output_Address , } ; public int readOutput ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public boolean readOutput_Direction ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kOutput_Direction_BitfieldMask ) > > > kOutput_Direction_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public int readOutput_Value ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kOutput_Value_BitfieldMask ) > > > kOutput_Value_BitfieldOffset ) ; bitfieldValue <<= <NUM_LIT:1> ; bitfieldValue >>= <NUM_LIT:1> ; return ( int ) ( bitfieldValue ) ; } private static final int kConfig_ASource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ASource_Channel_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_ASource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ASource_Module_BitfieldOffset = <NUM_LIT:16> ; private static final int kConfig_ASource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ASource_AnalogTrigger_BitfieldOffset = <NUM_LIT:15> ; private static final int kConfig_BSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_BSource_Channel_BitfieldOffset = <NUM_LIT:11> ; private static final int kConfig_BSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_BSource_Module_BitfieldOffset = <NUM_LIT:10> ; private static final int kConfig_BSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_BSource_AnalogTrigger_BitfieldOffset = <NUM_LIT:9> ; private static final int kConfig_IndexSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_Channel_BitfieldOffset = <NUM_LIT:5> ; private static final int kConfig_IndexSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_Module_BitfieldOffset = <NUM_LIT:4> ; private static final int kConfig_IndexSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_AnalogTrigger_BitfieldOffset = <NUM_LIT:3> ; private static final int kConfig_IndexActiveHigh_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexActiveHigh_BitfieldOffset = <NUM_LIT:2> ; private static final int kConfig_Reverse_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Reverse_BitfieldOffset = <NUM_LIT:1> ; private static final int kConfig_Enable_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_BitfieldOffset = <NUM_LIT:0> ; private static final int kEncoder0_Config_Address = <NUM_LIT> ; private static final int kEncoder1_Config_Address = <NUM_LIT> ; private static final int kEncoder2_Config_Address = <NUM_LIT> ; private static final int kEncoder3_Config_Address = <NUM_LIT> ; private static final int kConfig_Addresses [ ] = { kEncoder0_Config_Address , kEncoder1_Config_Address , kEncoder2_Config_Address , kEncoder3_Config_Address , } ; public void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeConfig_ASource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_ASource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_ASource_Channel_BitfieldOffset ) & kConfig_ASource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_ASource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_ASource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_ASource_Module_BitfieldOffset ) & kConfig_ASource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_ASource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_ASource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_ASource_AnalogTrigger_BitfieldOffset ) & kConfig_ASource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_BSource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_BSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_BSource_Channel_BitfieldOffset ) & kConfig_BSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_BSource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_BSource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_BSource_Module_BitfieldOffset ) & kConfig_BSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_BSource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_BSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_BSource_AnalogTrigger_BitfieldOffset ) & kConfig_BSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_IndexSource_Channel_BitfieldOffset ) & kConfig_IndexSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_IndexSource_Module_BitfieldOffset ) & kConfig_IndexSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_IndexSource_AnalogTrigger_BitfieldOffset ) & kConfig_IndexSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexActiveHigh ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexActiveHigh_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_IndexActiveHigh_BitfieldOffset ) & kConfig_IndexActiveHigh_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Reverse ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Reverse_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Reverse_BitfieldOffset ) & kConfig_Reverse_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Enable ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Enable_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_BitfieldOffset ) & kConfig_Enable_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readConfig_ASource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_ASource_Channel_BitfieldMask ) > > > kConfig_ASource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_ASource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_ASource_Module_BitfieldMask ) > > > kConfig_ASource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_ASource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_ASource_AnalogTrigger_BitfieldMask ) > > > kConfig_ASource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public byte readConfig_BSource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_BSource_Channel_BitfieldMask ) > > > kConfig_BSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_BSource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_BSource_Module_BitfieldMask ) > > > kConfig_BSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_BSource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_BSource_AnalogTrigger_BitfieldMask ) > > > kConfig_BSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public byte readConfig_IndexSource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_Channel_BitfieldMask ) > > > kConfig_IndexSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_IndexSource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_Module_BitfieldMask ) > > > kConfig_IndexSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_IndexSource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_AnalogTrigger_BitfieldMask ) > > > kConfig_IndexSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_IndexActiveHigh ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexActiveHigh_BitfieldMask ) > > > kConfig_IndexActiveHigh_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_Reverse ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Reverse_BitfieldMask ) > > > kConfig_Reverse_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_Enable ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_BitfieldMask ) > > > kConfig_Enable_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kEncoder0_Reset_Address = <NUM_LIT> ; private static final int kEncoder1_Reset_Address = <NUM_LIT> ; private static final int kEncoder2_Reset_Address = <NUM_LIT> ; private static final int kEncoder3_Reset_Address = <NUM_LIT> ; private static final int kReset_Addresses [ ] = { kEncoder0_Reset_Address , kEncoder1_Reset_Address , kEncoder2_Reset_Address , kEncoder3_Reset_Address , } ; public void strobeReset ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kReset_Addresses [ m_SystemIndex ] , <NUM_LIT:1> , status ) ; } private static final int kTimerOutput_Period_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Period_BitfieldOffset = <NUM_LIT:9> ; private static final int kTimerOutput_Period_FixedPointIntegerShift = <NUM_LIT:1> ; private static final int kTimerOutput_Count_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Count_BitfieldOffset = <NUM_LIT:1> ; private static final int kTimerOutput_Stalled_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Stalled_BitfieldOffset = <NUM_LIT:0> ; private static final int kEncoder0_TimerOutput_Address = <NUM_LIT> ; private static final int kEncoder1_TimerOutput_Address = <NUM_LIT> ; private static final int kEncoder2_TimerOutput_Address = <NUM_LIT> ; private static final int kEncoder3_TimerOutput_Address = <NUM_LIT> ; private static final int kTimerOutput_Addresses [ ] = { kEncoder0_TimerOutput_Address , kEncoder1_TimerOutput_Address , kEncoder2_TimerOutput_Address , kEncoder3_TimerOutput_Address , } ; public int readTimerOutput ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public int readTimerOutput_Period ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Period_BitfieldMask ) > > > kTimerOutput_Period_BitfieldOffset ) << kTimerOutput_Period_FixedPointIntegerShift ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readTimerOutput_Count ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Count_BitfieldMask ) > > > kTimerOutput_Count_BitfieldOffset ) ; bitfieldValue <<= <NUM_LIT:24> ; bitfieldValue >>= <NUM_LIT:24> ; return ( byte ) ( bitfieldValue ) ; } public boolean readTimerOutput_Stalled ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Stalled_BitfieldMask ) > > > kTimerOutput_Stalled_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kTimerConfig_StallPeriod_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_StallPeriod_BitfieldOffset = <NUM_LIT:8> ; private static final int kTimerConfig_StallPeriod_FixedPointIntegerShift = <NUM_LIT:1> ; private static final int kTimerConfig_AverageSize_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_AverageSize_BitfieldOffset = <NUM_LIT:1> ; private static final int kTimerConfig_UpdateWhenEmpty_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_UpdateWhenEmpty_BitfieldOffset = <NUM_LIT:0> ; private static final int kEncoder0_TimerConfig_Address = <NUM_LIT> ; private static final int kEncoder1_TimerConfig_Address = <NUM_LIT> ; private static final int kEncoder2_TimerConfig_Address = <NUM_LIT> ; private static final int kEncoder3_TimerConfig_Address = <NUM_LIT> ; private static final int kTimerConfig_Addresses [ ] = { kEncoder0_TimerConfig_Address , kEncoder1_TimerConfig_Address , kEncoder2_TimerConfig_Address , kEncoder3_TimerConfig_Address , } ; public void writeTimerConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeTimerConfig_StallPeriod ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_StallPeriod_BitfieldMask ; regValue |= ( ( value > > > kTimerConfig_StallPeriod_FixedPointIntegerShift ) << kTimerConfig_StallPeriod_BitfieldOffset ) & kTimerConfig_StallPeriod_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeTimerConfig_AverageSize ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_AverageSize_BitfieldMask ; regValue |= ( ( value ) << kTimerConfig_AverageSize_BitfieldOffset ) & kTimerConfig_AverageSize_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeTimerConfig_UpdateWhenEmpty ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_UpdateWhenEmpty_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kTimerConfig_UpdateWhenEmpty_BitfieldOffset ) & kTimerConfig_UpdateWhenEmpty_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readTimerConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public int readTimerConfig_StallPeriod ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_StallPeriod_BitfieldMask ) > > > kTimerConfig_StallPeriod_BitfieldOffset ) << kTimerConfig_StallPeriod_FixedPointIntegerShift ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readTimerConfig_AverageSize ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_AverageSize_BitfieldMask ) > > > kTimerConfig_AverageSize_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readTimerConfig_UpdateWhenEmpty ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_UpdateWhenEmpty_BitfieldMask ) > > > kTimerConfig_UpdateWhenEmpty_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tSPI extends tSystem { public tSPI ( ) { super ( ) ; } protected void finalize ( ) { super . finalize ( ) ; } public static final int kNumSystems = <NUM_LIT:1> ; private static final int kStatus_ReceivedDataOverflow_BitfieldMask = <NUM_LIT> ; private static final int kStatus_ReceivedDataOverflow_BitfieldOffset = <NUM_LIT:1> ; private static final int kStatus_Idle_BitfieldMask = <NUM_LIT> ; private static final int kStatus_Idle_BitfieldOffset = <NUM_LIT:0> ; private static final int kSPI_Status_Address = <NUM_LIT> ; public static int readStatus ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Status_Address , status ) ; return ( int ) ( regValue ) ; } public static boolean readStatus_ReceivedDataOverflow ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_ReceivedDataOverflow_BitfieldMask ) > > > kStatus_ReceivedDataOverflow_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readStatus_Idle ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Status_Address , status ) ; int bitfieldValue = ( ( regValue & kStatus_Idle_BitfieldMask ) > > > kStatus_Idle_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kSPI_ReadReceivedData_Address = <NUM_LIT> ; public static void strobeReadReceivedData ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_ReadReceivedData_Address , <NUM_LIT:1> , status ) ; } private static final int kConfig_BusBitWidth_BitfieldMask = <NUM_LIT> ; private static final int kConfig_BusBitWidth_BitfieldOffset = <NUM_LIT:15> ; private static final int kConfig_ClockHalfPeriodDelay_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ClockHalfPeriodDelay_BitfieldOffset = <NUM_LIT:7> ; private static final int kConfig_MSBfirst_BitfieldMask = <NUM_LIT> ; private static final int kConfig_MSBfirst_BitfieldOffset = <NUM_LIT:6> ; private static final int kConfig_DataOnFalling_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DataOnFalling_BitfieldOffset = <NUM_LIT:5> ; private static final int kConfig_LatchFirst_BitfieldMask = <NUM_LIT> ; private static final int kConfig_LatchFirst_BitfieldOffset = <NUM_LIT:4> ; private static final int kConfig_LatchLast_BitfieldMask = <NUM_LIT> ; private static final int kConfig_LatchLast_BitfieldOffset = <NUM_LIT:3> ; private static final int kConfig_FramePolarity_BitfieldMask = <NUM_LIT> ; private static final int kConfig_FramePolarity_BitfieldOffset = <NUM_LIT:2> ; private static final int kConfig_WriteOnly_BitfieldMask = <NUM_LIT> ; private static final int kConfig_WriteOnly_BitfieldOffset = <NUM_LIT:1> ; private static final int kConfig_ClockPolarity_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ClockPolarity_BitfieldOffset = <NUM_LIT:0> ; private static final int kSPI_Config_Address = <NUM_LIT> ; public static void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , value , status ) ; } public static void writeConfig_BusBitWidth ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_BusBitWidth_BitfieldMask ; regValue |= ( ( value ) << kConfig_BusBitWidth_BitfieldOffset ) & kConfig_BusBitWidth_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_ClockHalfPeriodDelay ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_ClockHalfPeriodDelay_BitfieldMask ; regValue |= ( ( value ) << kConfig_ClockHalfPeriodDelay_BitfieldOffset ) & kConfig_ClockHalfPeriodDelay_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_MSBfirst ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_MSBfirst_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_MSBfirst_BitfieldOffset ) & kConfig_MSBfirst_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_DataOnFalling ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_DataOnFalling_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_DataOnFalling_BitfieldOffset ) & kConfig_DataOnFalling_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_LatchFirst ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_LatchFirst_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_LatchFirst_BitfieldOffset ) & kConfig_LatchFirst_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_LatchLast ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_LatchLast_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_LatchLast_BitfieldOffset ) & kConfig_LatchLast_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_FramePolarity ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_FramePolarity_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_FramePolarity_BitfieldOffset ) & kConfig_FramePolarity_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_WriteOnly ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_WriteOnly_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_WriteOnly_BitfieldOffset ) & kConfig_WriteOnly_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static void writeConfig_ClockPolarity ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; regValue &= ~ kConfig_ClockPolarity_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_ClockPolarity_BitfieldOffset ) & kConfig_ClockPolarity_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Config_Address , regValue , status ) ; } public static int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; return ( int ) ( regValue ) ; } public static short readConfig_BusBitWidth ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_BusBitWidth_BitfieldMask ) > > > kConfig_BusBitWidth_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static short readConfig_ClockHalfPeriodDelay ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_ClockHalfPeriodDelay_BitfieldMask ) > > > kConfig_ClockHalfPeriodDelay_BitfieldOffset ) ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static boolean readConfig_MSBfirst ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_MSBfirst_BitfieldMask ) > > > kConfig_MSBfirst_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_DataOnFalling ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_DataOnFalling_BitfieldMask ) > > > kConfig_DataOnFalling_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_LatchFirst ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_LatchFirst_BitfieldMask ) > > > kConfig_LatchFirst_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_LatchLast ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_LatchLast_BitfieldMask ) > > > kConfig_LatchLast_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_FramePolarity ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_FramePolarity_BitfieldMask ) > > > kConfig_FramePolarity_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_WriteOnly ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_WriteOnly_BitfieldMask ) > > > kConfig_WriteOnly_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_ClockPolarity ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_ClockPolarity_BitfieldMask ) > > > kConfig_ClockPolarity_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kSPI_Reset_Address = <NUM_LIT> ; public static void strobeReset ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Reset_Address , <NUM_LIT:1> , status ) ; } private static final int kSPI_DataToLoad_Address = <NUM_LIT> ; public static void writeDataToLoad ( final long value ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_DataToLoad_Address , ( int ) ( value ) , status ) ; } public static long readDataToLoad ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kSPI_DataToLoad_Address , status ) ) & <NUM_LIT> ) ; } private static final int kSPI_ReceivedData_Address = <NUM_LIT> ; public static long readReceivedData ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kSPI_ReceivedData_Address , status ) ) & <NUM_LIT> ) ; } private static final int kChannels_SCLK_Channel_BitfieldMask = <NUM_LIT> ; private static final int kChannels_SCLK_Channel_BitfieldOffset = <NUM_LIT:16> ; private static final int kChannels_SCLK_Module_BitfieldMask = <NUM_LIT> ; private static final int kChannels_SCLK_Module_BitfieldOffset = <NUM_LIT:15> ; private static final int kChannels_MOSI_Channel_BitfieldMask = <NUM_LIT> ; private static final int kChannels_MOSI_Channel_BitfieldOffset = <NUM_LIT:11> ; private static final int kChannels_MOSI_Module_BitfieldMask = <NUM_LIT> ; private static final int kChannels_MOSI_Module_BitfieldOffset = <NUM_LIT:10> ; private static final int kChannels_MISO_Channel_BitfieldMask = <NUM_LIT> ; private static final int kChannels_MISO_Channel_BitfieldOffset = <NUM_LIT:6> ; private static final int kChannels_MISO_Module_BitfieldMask = <NUM_LIT> ; private static final int kChannels_MISO_Module_BitfieldOffset = <NUM_LIT:5> ; private static final int kChannels_SS_Channel_BitfieldMask = <NUM_LIT> ; private static final int kChannels_SS_Channel_BitfieldOffset = <NUM_LIT:1> ; private static final int kChannels_SS_Module_BitfieldMask = <NUM_LIT> ; private static final int kChannels_SS_Module_BitfieldOffset = <NUM_LIT:0> ; private static final int kSPI_Channels_Address = <NUM_LIT> ; public static void writeChannels ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , value , status ) ; } public static void writeChannels_SCLK_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_SCLK_Channel_BitfieldMask ; regValue |= ( ( value ) << kChannels_SCLK_Channel_BitfieldOffset ) & kChannels_SCLK_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_SCLK_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_SCLK_Module_BitfieldMask ; regValue |= ( ( value ) << kChannels_SCLK_Module_BitfieldOffset ) & kChannels_SCLK_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_MOSI_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_MOSI_Channel_BitfieldMask ; regValue |= ( ( value ) << kChannels_MOSI_Channel_BitfieldOffset ) & kChannels_MOSI_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_MOSI_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_MOSI_Module_BitfieldMask ; regValue |= ( ( value ) << kChannels_MOSI_Module_BitfieldOffset ) & kChannels_MOSI_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_MISO_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_MISO_Channel_BitfieldMask ; regValue |= ( ( value ) << kChannels_MISO_Channel_BitfieldOffset ) & kChannels_MISO_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_MISO_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_MISO_Module_BitfieldMask ; regValue |= ( ( value ) << kChannels_MISO_Module_BitfieldOffset ) & kChannels_MISO_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_SS_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_SS_Channel_BitfieldMask ; regValue |= ( ( value ) << kChannels_SS_Channel_BitfieldOffset ) & kChannels_SS_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static void writeChannels_SS_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; regValue &= ~ kChannels_SS_Module_BitfieldMask ; regValue |= ( ( value ) << kChannels_SS_Module_BitfieldOffset ) & kChannels_SS_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Channels_Address , regValue , status ) ; } public static int readChannels ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; return ( int ) ( regValue ) ; } public static byte readChannels_SCLK_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_SCLK_Channel_BitfieldMask ) > > > kChannels_SCLK_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_SCLK_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_SCLK_Module_BitfieldMask ) > > > kChannels_SCLK_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_MOSI_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_MOSI_Channel_BitfieldMask ) > > > kChannels_MOSI_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_MOSI_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_MOSI_Module_BitfieldMask ) > > > kChannels_MOSI_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_MISO_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_MISO_Channel_BitfieldMask ) > > > kChannels_MISO_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_MISO_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_MISO_Module_BitfieldMask ) > > > kChannels_MISO_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_SS_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_SS_Channel_BitfieldMask ) > > > kChannels_SS_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readChannels_SS_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSPI_Channels_Address , status ) ; int bitfieldValue = ( ( regValue & kChannels_SS_Module_BitfieldMask ) > > > kChannels_SS_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } private static final int kSPI_Load_Address = <NUM_LIT> ; public static void strobeLoad ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_Load_Address , <NUM_LIT:1> , status ) ; } private static final int kSPI_ReceivedElements_Address = <NUM_LIT> ; public static short readReceivedElements ( ) { return ( short ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kSPI_ReceivedElements_Address , status ) ) & <NUM_LIT> ) ; } private static final int kSPI_ClearReceivedData_Address = <NUM_LIT> ; public static void strobeClearReceivedData ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kSPI_ClearReceivedData_Address , <NUM_LIT:1> , status ) ; } private static final int kSPI_AvailableToLoad_Address = <NUM_LIT> ; public static short readAvailableToLoad ( ) { return ( short ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kSPI_AvailableToLoad_Address , status ) ) & <NUM_LIT> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; import com . sun . cldc . jna . * ; import com . sun . cldc . jna . ptr . IntByReference ; public class tDMAManager extends tSystem { boolean m_started ; int m_dmaChannel ; int m_hostBufferSize ; DMAChannelDescriptors . tDMAChannelDescriptor m_dmaChannelDescriptor ; public tDMAManager ( int dmaChannel , int hostBufferSize ) { super ( ) ; if ( status . isFatal ( ) ) return ; m_started = false ; m_dmaChannel = dmaChannel ; m_hostBufferSize = hostBufferSize ; boolean found = false ; for ( int i = <NUM_LIT:0> ; i < kNUM_DMA_CHANNELS ; i ++ ) { if ( kDMAChannelDescriptors [ i ] . channel == m_dmaChannel ) { m_dmaChannelDescriptor = kDMAChannelDescriptors [ i ] ; found = true ; break ; } } if ( ! found ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; return ; } NiRioSrv . fifoConfig ( m_DeviceHandle , m_dmaChannel , m_hostBufferSize , status ) ; } protected void finalize ( ) { stop ( ) ; super . finalize ( ) ; } public void start ( ) { NiRioSrv . fifoStart ( m_DeviceHandle , m_dmaChannel , status ) ; m_started = true ; } public void stop ( ) { NiRioSrv . fifoStop ( m_DeviceHandle , m_dmaChannel , status ) ; m_started = false ; } public int [ ] read ( int num , int timeout ) { if ( m_dmaChannelDescriptor . write != <NUM_LIT:1> ) { status . setStatus ( NiRioStatus . kRIOStatusInvalidFunction ) ; return new int [ <NUM_LIT:0> ] ; } Pointer pBuffer = new Pointer ( num * <NUM_LIT:4> ) ; IntByReference read = new IntByReference ( <NUM_LIT:0> ) ; IntByReference remaining = new IntByReference ( <NUM_LIT:0> ) ; NiRioSrv . fifoRead ( m_DeviceHandle , m_dmaChannel , pBuffer , num , timeout , read , remaining , status ) ; int [ ] data = new int [ num ] ; pBuffer . getInts ( <NUM_LIT:0> , data , <NUM_LIT:0> , num ) ; pBuffer . free ( ) ; m_started = true ; return data ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tDMA extends tSystem { public tDMA ( ) { super ( ) ; } protected void finalize ( ) { super . finalize ( ) ; } public static final int kNumSystems = <NUM_LIT:1> ; private static final int kDMA_Rate_Address = <NUM_LIT> ; public static void writeRate ( final long value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Rate_Address , ( int ) ( value ) , status ) ; } public static long readRate ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Rate_Address , status ) ) & <NUM_LIT> ) ; } private static final int kConfig_Pause_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Pause_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_Enable_AI0_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AI0_Low_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_Enable_AI0_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AI0_High_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged0_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged0_Low_BitfieldOffset = <NUM_LIT:16> ; private static final int kConfig_Enable_AIAveraged0_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged0_High_BitfieldOffset = <NUM_LIT:15> ; private static final int kConfig_Enable_AI1_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AI1_Low_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_Enable_AI1_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AI1_High_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged1_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged1_Low_BitfieldOffset = <NUM_LIT:12> ; private static final int kConfig_Enable_AIAveraged1_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AIAveraged1_High_BitfieldOffset = <NUM_LIT:11> ; private static final int kConfig_Enable_Accumulator0_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_Accumulator0_BitfieldOffset = <NUM_LIT:10> ; private static final int kConfig_Enable_Accumulator1_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_Accumulator1_BitfieldOffset = <NUM_LIT:9> ; private static final int kConfig_Enable_DI_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_DI_BitfieldOffset = <NUM_LIT:8> ; private static final int kConfig_Enable_AnalogTriggers_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_AnalogTriggers_BitfieldOffset = <NUM_LIT:7> ; private static final int kConfig_Enable_Counters_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_Counters_Low_BitfieldOffset = <NUM_LIT:6> ; private static final int kConfig_Enable_Counters_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_Counters_High_BitfieldOffset = <NUM_LIT:5> ; private static final int kConfig_Enable_CounterTimers_Low_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_CounterTimers_Low_BitfieldOffset = <NUM_LIT:4> ; private static final int kConfig_Enable_CounterTimers_High_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_CounterTimers_High_BitfieldOffset = <NUM_LIT:3> ; private static final int kConfig_Enable_Encoders_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_Encoders_BitfieldOffset = <NUM_LIT:2> ; private static final int kConfig_Enable_EncoderTimers_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_EncoderTimers_BitfieldOffset = <NUM_LIT:1> ; private static final int kConfig_ExternalClock_BitfieldMask = <NUM_LIT> ; private static final int kConfig_ExternalClock_BitfieldOffset = <NUM_LIT:0> ; private static final int kDMA_Config_Address = <NUM_LIT> ; public static void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , value , status ) ; } public static void writeConfig_Pause ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Pause_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Pause_BitfieldOffset ) & kConfig_Pause_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AI0_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AI0_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AI0_Low_BitfieldOffset ) & kConfig_Enable_AI0_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AI0_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AI0_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AI0_High_BitfieldOffset ) & kConfig_Enable_AI0_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AIAveraged0_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AIAveraged0_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AIAveraged0_Low_BitfieldOffset ) & kConfig_Enable_AIAveraged0_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AIAveraged0_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AIAveraged0_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AIAveraged0_High_BitfieldOffset ) & kConfig_Enable_AIAveraged0_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AI1_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AI1_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AI1_Low_BitfieldOffset ) & kConfig_Enable_AI1_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AI1_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AI1_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AI1_High_BitfieldOffset ) & kConfig_Enable_AI1_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AIAveraged1_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AIAveraged1_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AIAveraged1_Low_BitfieldOffset ) & kConfig_Enable_AIAveraged1_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AIAveraged1_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AIAveraged1_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AIAveraged1_High_BitfieldOffset ) & kConfig_Enable_AIAveraged1_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_Accumulator0 ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_Accumulator0_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_Accumulator0_BitfieldOffset ) & kConfig_Enable_Accumulator0_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_Accumulator1 ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_Accumulator1_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_Accumulator1_BitfieldOffset ) & kConfig_Enable_Accumulator1_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_DI ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_DI_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_DI_BitfieldOffset ) & kConfig_Enable_DI_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_AnalogTriggers ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_AnalogTriggers_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_AnalogTriggers_BitfieldOffset ) & kConfig_Enable_AnalogTriggers_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_Counters_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_Counters_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_Counters_Low_BitfieldOffset ) & kConfig_Enable_Counters_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_Counters_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_Counters_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_Counters_High_BitfieldOffset ) & kConfig_Enable_Counters_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_CounterTimers_Low ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_CounterTimers_Low_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_CounterTimers_Low_BitfieldOffset ) & kConfig_Enable_CounterTimers_Low_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_CounterTimers_High ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_CounterTimers_High_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_CounterTimers_High_BitfieldOffset ) & kConfig_Enable_CounterTimers_High_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_Encoders ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_Encoders_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_Encoders_BitfieldOffset ) & kConfig_Enable_Encoders_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_Enable_EncoderTimers ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_Enable_EncoderTimers_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_EncoderTimers_BitfieldOffset ) & kConfig_Enable_EncoderTimers_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static void writeConfig_ExternalClock ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; regValue &= ~ kConfig_ExternalClock_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_ExternalClock_BitfieldOffset ) & kConfig_ExternalClock_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_Config_Address , regValue , status ) ; } public static int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; return ( int ) ( regValue ) ; } public static boolean readConfig_Pause ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Pause_BitfieldMask ) > > > kConfig_Pause_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AI0_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AI0_Low_BitfieldMask ) > > > kConfig_Enable_AI0_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AI0_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AI0_High_BitfieldMask ) > > > kConfig_Enable_AI0_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AIAveraged0_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AIAveraged0_Low_BitfieldMask ) > > > kConfig_Enable_AIAveraged0_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AIAveraged0_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AIAveraged0_High_BitfieldMask ) > > > kConfig_Enable_AIAveraged0_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AI1_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AI1_Low_BitfieldMask ) > > > kConfig_Enable_AI1_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AI1_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AI1_High_BitfieldMask ) > > > kConfig_Enable_AI1_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AIAveraged1_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AIAveraged1_Low_BitfieldMask ) > > > kConfig_Enable_AIAveraged1_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AIAveraged1_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AIAveraged1_High_BitfieldMask ) > > > kConfig_Enable_AIAveraged1_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_Accumulator0 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_Accumulator0_BitfieldMask ) > > > kConfig_Enable_Accumulator0_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_Accumulator1 ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_Accumulator1_BitfieldMask ) > > > kConfig_Enable_Accumulator1_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_DI ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_DI_BitfieldMask ) > > > kConfig_Enable_DI_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_AnalogTriggers ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_AnalogTriggers_BitfieldMask ) > > > kConfig_Enable_AnalogTriggers_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_Counters_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_Counters_Low_BitfieldMask ) > > > kConfig_Enable_Counters_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_Counters_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_Counters_High_BitfieldMask ) > > > kConfig_Enable_Counters_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_CounterTimers_Low ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_CounterTimers_Low_BitfieldMask ) > > > kConfig_Enable_CounterTimers_Low_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_CounterTimers_High ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_CounterTimers_High_BitfieldMask ) > > > kConfig_Enable_CounterTimers_High_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_Encoders ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_Encoders_BitfieldMask ) > > > kConfig_Enable_Encoders_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_Enable_EncoderTimers ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_EncoderTimers_BitfieldMask ) > > > kConfig_Enable_EncoderTimers_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readConfig_ExternalClock ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_Config_Address , status ) ; int bitfieldValue = ( ( regValue & kConfig_ExternalClock_BitfieldMask ) > > > kConfig_ExternalClock_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static final int kExternalTriggers_NumElements = <NUM_LIT:4> ; public static final int kExternalTriggers_ElementSize = <NUM_LIT:8> ; public static final int kExternalTriggers_ElementMask = <NUM_LIT> ; private static final int kExternalTriggers_ExternalClockSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kExternalTriggers_ExternalClockSource_Channel_BitfieldOffset = <NUM_LIT:4> ; private static final int kExternalTriggers_ExternalClockSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kExternalTriggers_ExternalClockSource_Module_BitfieldOffset = <NUM_LIT:3> ; private static final int kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldOffset = <NUM_LIT:2> ; private static final int kExternalTriggers_RisingEdge_BitfieldMask = <NUM_LIT> ; private static final int kExternalTriggers_RisingEdge_BitfieldOffset = <NUM_LIT:1> ; private static final int kExternalTriggers_FallingEdge_BitfieldMask = <NUM_LIT> ; private static final int kExternalTriggers_FallingEdge_BitfieldOffset = <NUM_LIT:0> ; private static final int kDMA_ExternalTriggers_Address = <NUM_LIT> ; public static void writeExternalTriggers ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , value , status ) ; } public static void writeExternalTriggers_ExternalClockSource_Channel ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) ; regValue &= ~ kExternalTriggers_ExternalClockSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kExternalTriggers_ExternalClockSource_Channel_BitfieldOffset ) & kExternalTriggers_ExternalClockSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , regValue , status ) ; } public static void writeExternalTriggers_ExternalClockSource_Module ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) ; regValue &= ~ kExternalTriggers_ExternalClockSource_Module_BitfieldMask ; regValue |= ( ( value ) << kExternalTriggers_ExternalClockSource_Module_BitfieldOffset ) & kExternalTriggers_ExternalClockSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , regValue , status ) ; } public static void writeExternalTriggers_ExternalClockSource_AnalogTrigger ( final int bitfield_index , final boolean value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) ; regValue &= ~ kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldOffset ) & kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , regValue , status ) ; } public static void writeExternalTriggers_RisingEdge ( final int bitfield_index , final boolean value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) ; regValue &= ~ kExternalTriggers_RisingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kExternalTriggers_RisingEdge_BitfieldOffset ) & kExternalTriggers_RisingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , regValue , status ) ; } public static void writeExternalTriggers_FallingEdge ( final int bitfield_index , final boolean value ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) ; regValue &= ~ kExternalTriggers_FallingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kExternalTriggers_FallingEdge_BitfieldOffset ) & kExternalTriggers_FallingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , regValue , status ) ; } public static int readExternalTriggers ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; return ( int ) ( regValue ) ; } public static byte readExternalTriggers_ExternalClockSource_Channel ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; int bitfieldValue = ( ( regValue & kExternalTriggers_ExternalClockSource_Channel_BitfieldMask ) > > > kExternalTriggers_ExternalClockSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static byte readExternalTriggers_ExternalClockSource_Module ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; int bitfieldValue = ( ( regValue & kExternalTriggers_ExternalClockSource_Module_BitfieldMask ) > > > kExternalTriggers_ExternalClockSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public static boolean readExternalTriggers_ExternalClockSource_AnalogTrigger ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; int bitfieldValue = ( ( regValue & kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldMask ) > > > kExternalTriggers_ExternalClockSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readExternalTriggers_RisingEdge ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; int bitfieldValue = ( ( regValue & kExternalTriggers_RisingEdge_BitfieldMask ) > > > kExternalTriggers_RisingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public static boolean readExternalTriggers_FallingEdge ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kExternalTriggers_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kDMA_ExternalTriggers_Address , status ) > > > ( ( kExternalTriggers_NumElements - <NUM_LIT:1> - bitfield_index ) * kExternalTriggers_ElementSize ) ; int bitfieldValue = ( ( regValue & kExternalTriggers_FallingEdge_BitfieldMask ) > > > kExternalTriggers_FallingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tInterrupt extends tSystem { public tInterrupt ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:8> ; public final int m_SystemIndex ; private static final int kInterrupt0_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt1_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt2_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt3_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt4_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt5_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt6_TimeStamp_Address = <NUM_LIT> ; private static final int kInterrupt7_TimeStamp_Address = <NUM_LIT> ; private static final int kTimeStamp_Addresses [ ] = { kInterrupt0_TimeStamp_Address , kInterrupt1_TimeStamp_Address , kInterrupt2_TimeStamp_Address , kInterrupt3_TimeStamp_Address , kInterrupt4_TimeStamp_Address , kInterrupt5_TimeStamp_Address , kInterrupt6_TimeStamp_Address , kInterrupt7_TimeStamp_Address , } ; public long readTimeStamp ( ) { return ( long ) ( ( NiRioSrv . peek32 ( m_DeviceHandle , kTimeStamp_Addresses [ m_SystemIndex ] , status ) ) & <NUM_LIT> ) ; } private static final int kConfig_Source_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Source_Channel_BitfieldOffset = <NUM_LIT:5> ; private static final int kConfig_Source_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Source_Module_BitfieldOffset = <NUM_LIT:4> ; private static final int kConfig_Source_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Source_AnalogTrigger_BitfieldOffset = <NUM_LIT:3> ; private static final int kConfig_RisingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_RisingEdge_BitfieldOffset = <NUM_LIT:2> ; private static final int kConfig_FallingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_FallingEdge_BitfieldOffset = <NUM_LIT:1> ; private static final int kConfig_WaitForAck_BitfieldMask = <NUM_LIT> ; private static final int kConfig_WaitForAck_BitfieldOffset = <NUM_LIT:0> ; private static final int kInterrupt0_Config_Address = <NUM_LIT> ; private static final int kInterrupt1_Config_Address = <NUM_LIT> ; private static final int kInterrupt2_Config_Address = <NUM_LIT> ; private static final int kInterrupt3_Config_Address = <NUM_LIT> ; private static final int kInterrupt4_Config_Address = <NUM_LIT> ; private static final int kInterrupt5_Config_Address = <NUM_LIT> ; private static final int kInterrupt6_Config_Address = <NUM_LIT> ; private static final int kInterrupt7_Config_Address = <NUM_LIT> ; private static final int kConfig_Addresses [ ] = { kInterrupt0_Config_Address , kInterrupt1_Config_Address , kInterrupt2_Config_Address , kInterrupt3_Config_Address , kInterrupt4_Config_Address , kInterrupt5_Config_Address , kInterrupt6_Config_Address , kInterrupt7_Config_Address , } ; public void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeConfig_Source_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Source_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_Source_Channel_BitfieldOffset ) & kConfig_Source_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Source_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Source_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_Source_Module_BitfieldOffset ) & kConfig_Source_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Source_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Source_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Source_AnalogTrigger_BitfieldOffset ) & kConfig_Source_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_RisingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_RisingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_RisingEdge_BitfieldOffset ) & kConfig_RisingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_FallingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_FallingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_FallingEdge_BitfieldOffset ) & kConfig_FallingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_WaitForAck ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_WaitForAck_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_WaitForAck_BitfieldOffset ) & kConfig_WaitForAck_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readConfig_Source_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Source_Channel_BitfieldMask ) > > > kConfig_Source_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_Source_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Source_Module_BitfieldMask ) > > > kConfig_Source_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_Source_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Source_AnalogTrigger_BitfieldMask ) > > > kConfig_Source_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_RisingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_RisingEdge_BitfieldMask ) > > > kConfig_RisingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_FallingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_FallingEdge_BitfieldMask ) > > > kConfig_FallingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_WaitForAck ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_WaitForAck_BitfieldMask ) > > > kConfig_WaitForAck_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; import com . sun . cldc . jna . ptr . IntByReference ; public class tInterruptManager extends tSystem { private static final int kFPGA_INTERRUPT_BASE_ADDRESS = <NUM_LIT> ; private static final int kFPGA_INTERRUPT_ACKNOWLEDGE_ADDRESS = ( kFPGA_INTERRUPT_BASE_ADDRESS + <NUM_LIT> ) ; private int m_interruptMask ; private IntByReference m_rioContext ; private boolean m_watcher ; private boolean m_enabled ; private static int m_globalInterruptMask = <NUM_LIT:0> ; public tInterruptManager ( int interruptMask , boolean watcher ) { super ( ) ; if ( status . isFatal ( ) ) return ; m_interruptMask = interruptMask ; m_rioContext = new IntByReference ( <NUM_LIT:0> ) ; m_watcher = watcher ; m_enabled = false ; NiRioSrv . irqReserve ( m_DeviceHandle , m_rioContext , status ) ; } protected void finalize ( ) { NiRioStatus tempStatus = new NiRioStatus ( ) ; NiRioSrv . irqUnreserve ( m_DeviceHandle , m_rioContext , tempStatus ) ; super . finalize ( ) ; } public int watch ( int timeoutInMs ) { if ( ! m_watcher ) { status . setStatus ( NiRioStatus . kRIOStatusIrrelevantAttribute ) ; return <NUM_LIT:0> ; } reserve ( ) ; if ( status . isFatal ( ) ) return <NUM_LIT:0> ; acknowledge ( ) ; int intsAsserted = NiRioSrv . irqWait ( m_DeviceHandle , m_rioContext , m_interruptMask , timeoutInMs , status ) ; acknowledge ( ) ; unreserve ( ) ; return intsAsserted ; } protected void acknowledge ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kFPGA_INTERRUPT_ACKNOWLEDGE_ADDRESS , m_interruptMask , status ) ; } protected void reserve ( ) { if ( ( m_globalInterruptMask & m_interruptMask ) != <NUM_LIT:0> || m_enabled ) { status . setStatus ( NiRioStatus . kRIOStatusEventEnabled ) ; } else { m_globalInterruptMask |= m_interruptMask ; m_enabled = true ; } } protected void unreserve ( ) { if ( ! m_enabled ) { status . setStatus ( NiRioStatus . kRIOStatusEventNotEnabled ) ; } else { m_enabled = false ; m_globalInterruptMask &= ~ m_interruptMask ; } } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tSolenoid extends tSystem { public tSolenoid ( ) { super ( ) ; } protected void finalize ( ) { super . finalize ( ) ; } public static final int kNumSystems = <NUM_LIT:1> ; public static final int kDO7_0_NumElements = <NUM_LIT:2> ; public static final int kDO7_0_ElementSize = <NUM_LIT:8> ; public static final int kDO7_0_ElementMask = <NUM_LIT> ; private static final int kSolenoid_DO7_0_Address = <NUM_LIT> ; public static void writeDO7_0 ( final int bitfield_index , final int value ) { if ( status . isNotFatal ( ) && bitfield_index >= kDO7_0_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kSolenoid_DO7_0_Address , status ) ; regValue &= ~ ( kDO7_0_ElementMask << ( ( kDO7_0_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO7_0_ElementSize ) ) ; regValue |= ( ( value & kDO7_0_ElementMask ) << ( ( kDO7_0_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO7_0_ElementSize ) ) ; NiRioSrv . poke32 ( m_DeviceHandle , kSolenoid_DO7_0_Address , regValue , status ) ; } public static short readDO7_0 ( final int bitfield_index ) { if ( status . isNotFatal ( ) && bitfield_index >= kDO7_0_NumElements ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } int arrayElementValue = ( ( NiRioSrv . peek32 ( m_DeviceHandle , kSolenoid_DO7_0_Address , status ) ) > > > ( ( kDO7_0_NumElements - <NUM_LIT:1> - bitfield_index ) * kDO7_0_ElementSize ) ) & kDO7_0_ElementMask ; return ( short ) ( ( arrayElementValue ) & <NUM_LIT> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . fpga ; import com . ni . rio . * ; public class tCounter extends tSystem { public tCounter ( final int sys_index ) { super ( ) ; m_SystemIndex = sys_index ; if ( status . isNotFatal ( ) && m_SystemIndex >= kNumSystems ) { status . setStatus ( NiRioStatus . kRIOStatusBadSelector ) ; } } protected void finalize ( ) { super . finalize ( ) ; } public int getSystemIndex ( ) { return m_SystemIndex ; } public static final int kNumSystems = <NUM_LIT:8> ; public final int m_SystemIndex ; private static final int kOutput_Direction_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Direction_BitfieldOffset = <NUM_LIT:31> ; private static final int kOutput_Value_BitfieldMask = <NUM_LIT> ; private static final int kOutput_Value_BitfieldOffset = <NUM_LIT:0> ; private static final int kCounter0_Output_Address = <NUM_LIT> ; private static final int kCounter1_Output_Address = <NUM_LIT> ; private static final int kCounter2_Output_Address = <NUM_LIT> ; private static final int kCounter3_Output_Address = <NUM_LIT> ; private static final int kCounter4_Output_Address = <NUM_LIT> ; private static final int kCounter5_Output_Address = <NUM_LIT> ; private static final int kCounter6_Output_Address = <NUM_LIT> ; private static final int kCounter7_Output_Address = <NUM_LIT> ; private static final int kOutput_Addresses [ ] = { kCounter0_Output_Address , kCounter1_Output_Address , kCounter2_Output_Address , kCounter3_Output_Address , kCounter4_Output_Address , kCounter5_Output_Address , kCounter6_Output_Address , kCounter7_Output_Address , } ; public int readOutput ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public boolean readOutput_Direction ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kOutput_Direction_BitfieldMask ) > > > kOutput_Direction_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public int readOutput_Value ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kOutput_Value_BitfieldMask ) > > > kOutput_Value_BitfieldOffset ) ; bitfieldValue <<= <NUM_LIT:1> ; bitfieldValue >>= <NUM_LIT:1> ; return ( int ) ( bitfieldValue ) ; } private static final int kConfig_UpSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_UpSource_Channel_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_UpSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_UpSource_Module_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_UpSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_UpSource_AnalogTrigger_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_DownSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DownSource_Channel_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_DownSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DownSource_Module_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_DownSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DownSource_AnalogTrigger_BitfieldOffset = <NUM_LIT:20> ; private static final int kConfig_IndexSource_Channel_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_Channel_BitfieldOffset = <NUM_LIT:16> ; private static final int kConfig_IndexSource_Module_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_Module_BitfieldOffset = <NUM_LIT:15> ; private static final int kConfig_IndexSource_AnalogTrigger_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexSource_AnalogTrigger_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_IndexActiveHigh_BitfieldMask = <NUM_LIT> ; private static final int kConfig_IndexActiveHigh_BitfieldOffset = <NUM_LIT> ; private static final int kConfig_UpRisingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_UpRisingEdge_BitfieldOffset = <NUM_LIT:12> ; private static final int kConfig_UpFallingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_UpFallingEdge_BitfieldOffset = <NUM_LIT:11> ; private static final int kConfig_DownRisingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DownRisingEdge_BitfieldOffset = <NUM_LIT:10> ; private static final int kConfig_DownFallingEdge_BitfieldMask = <NUM_LIT> ; private static final int kConfig_DownFallingEdge_BitfieldOffset = <NUM_LIT:9> ; private static final int kConfig_Mode_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Mode_BitfieldOffset = <NUM_LIT:7> ; private static final int kConfig_PulseLengthThreshold_BitfieldMask = <NUM_LIT> ; private static final int kConfig_PulseLengthThreshold_BitfieldOffset = <NUM_LIT:1> ; private static final int kConfig_PulseLengthThreshold_FixedPointIntegerShift = <NUM_LIT:8> ; private static final int kConfig_Enable_BitfieldMask = <NUM_LIT> ; private static final int kConfig_Enable_BitfieldOffset = <NUM_LIT:0> ; private static final int kCounter0_Config_Address = <NUM_LIT> ; private static final int kCounter1_Config_Address = <NUM_LIT> ; private static final int kCounter2_Config_Address = <NUM_LIT> ; private static final int kCounter3_Config_Address = <NUM_LIT> ; private static final int kCounter4_Config_Address = <NUM_LIT> ; private static final int kCounter5_Config_Address = <NUM_LIT> ; private static final int kCounter6_Config_Address = <NUM_LIT> ; private static final int kCounter7_Config_Address = <NUM_LIT> ; private static final int kConfig_Addresses [ ] = { kCounter0_Config_Address , kCounter1_Config_Address , kCounter2_Config_Address , kCounter3_Config_Address , kCounter4_Config_Address , kCounter5_Config_Address , kCounter6_Config_Address , kCounter7_Config_Address , } ; public void writeConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeConfig_UpSource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_UpSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_UpSource_Channel_BitfieldOffset ) & kConfig_UpSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_UpSource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_UpSource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_UpSource_Module_BitfieldOffset ) & kConfig_UpSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_UpSource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_UpSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_UpSource_AnalogTrigger_BitfieldOffset ) & kConfig_UpSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_DownSource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_DownSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_DownSource_Channel_BitfieldOffset ) & kConfig_DownSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_DownSource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_DownSource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_DownSource_Module_BitfieldOffset ) & kConfig_DownSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_DownSource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_DownSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_DownSource_AnalogTrigger_BitfieldOffset ) & kConfig_DownSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_Channel ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_Channel_BitfieldMask ; regValue |= ( ( value ) << kConfig_IndexSource_Channel_BitfieldOffset ) & kConfig_IndexSource_Channel_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_Module ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_Module_BitfieldMask ; regValue |= ( ( value ) << kConfig_IndexSource_Module_BitfieldOffset ) & kConfig_IndexSource_Module_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexSource_AnalogTrigger ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexSource_AnalogTrigger_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_IndexSource_AnalogTrigger_BitfieldOffset ) & kConfig_IndexSource_AnalogTrigger_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_IndexActiveHigh ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_IndexActiveHigh_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_IndexActiveHigh_BitfieldOffset ) & kConfig_IndexActiveHigh_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_UpRisingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_UpRisingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_UpRisingEdge_BitfieldOffset ) & kConfig_UpRisingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_UpFallingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_UpFallingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_UpFallingEdge_BitfieldOffset ) & kConfig_UpFallingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_DownRisingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_DownRisingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_DownRisingEdge_BitfieldOffset ) & kConfig_DownRisingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_DownFallingEdge ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_DownFallingEdge_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_DownFallingEdge_BitfieldOffset ) & kConfig_DownFallingEdge_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Mode ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Mode_BitfieldMask ; regValue |= ( ( value ) << kConfig_Mode_BitfieldOffset ) & kConfig_Mode_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_PulseLengthThreshold ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_PulseLengthThreshold_BitfieldMask ; regValue |= ( ( value > > > kConfig_PulseLengthThreshold_FixedPointIntegerShift ) << kConfig_PulseLengthThreshold_BitfieldOffset ) & kConfig_PulseLengthThreshold_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeConfig_Enable ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kConfig_Enable_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kConfig_Enable_BitfieldOffset ) & kConfig_Enable_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public byte readConfig_UpSource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_UpSource_Channel_BitfieldMask ) > > > kConfig_UpSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_UpSource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_UpSource_Module_BitfieldMask ) > > > kConfig_UpSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_UpSource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_UpSource_AnalogTrigger_BitfieldMask ) > > > kConfig_UpSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public byte readConfig_DownSource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_DownSource_Channel_BitfieldMask ) > > > kConfig_DownSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_DownSource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_DownSource_Module_BitfieldMask ) > > > kConfig_DownSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_DownSource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_DownSource_AnalogTrigger_BitfieldMask ) > > > kConfig_DownSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public byte readConfig_IndexSource_Channel ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_Channel_BitfieldMask ) > > > kConfig_IndexSource_Channel_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readConfig_IndexSource_Module ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_Module_BitfieldMask ) > > > kConfig_IndexSource_Module_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_IndexSource_AnalogTrigger ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexSource_AnalogTrigger_BitfieldMask ) > > > kConfig_IndexSource_AnalogTrigger_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_IndexActiveHigh ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_IndexActiveHigh_BitfieldMask ) > > > kConfig_IndexActiveHigh_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_UpRisingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_UpRisingEdge_BitfieldMask ) > > > kConfig_UpRisingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_UpFallingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_UpFallingEdge_BitfieldMask ) > > > kConfig_UpFallingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_DownRisingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_DownRisingEdge_BitfieldMask ) > > > kConfig_DownRisingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public boolean readConfig_DownFallingEdge ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_DownFallingEdge_BitfieldMask ) > > > kConfig_DownFallingEdge_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } public byte readConfig_Mode ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Mode_BitfieldMask ) > > > kConfig_Mode_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public short readConfig_PulseLengthThreshold ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_PulseLengthThreshold_BitfieldMask ) > > > kConfig_PulseLengthThreshold_BitfieldOffset ) << kConfig_PulseLengthThreshold_FixedPointIntegerShift ; return ( short ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readConfig_Enable ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kConfig_Enable_BitfieldMask ) > > > kConfig_Enable_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kCounter0_Reset_Address = <NUM_LIT> ; private static final int kCounter1_Reset_Address = <NUM_LIT> ; private static final int kCounter2_Reset_Address = <NUM_LIT> ; private static final int kCounter3_Reset_Address = <NUM_LIT> ; private static final int kCounter4_Reset_Address = <NUM_LIT> ; private static final int kCounter5_Reset_Address = <NUM_LIT> ; private static final int kCounter6_Reset_Address = <NUM_LIT> ; private static final int kCounter7_Reset_Address = <NUM_LIT> ; private static final int kReset_Addresses [ ] = { kCounter0_Reset_Address , kCounter1_Reset_Address , kCounter2_Reset_Address , kCounter3_Reset_Address , kCounter4_Reset_Address , kCounter5_Reset_Address , kCounter6_Reset_Address , kCounter7_Reset_Address , } ; public void strobeReset ( ) { NiRioSrv . poke32 ( m_DeviceHandle , kReset_Addresses [ m_SystemIndex ] , <NUM_LIT:1> , status ) ; } private static final int kTimerOutput_Period_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Period_BitfieldOffset = <NUM_LIT:9> ; private static final int kTimerOutput_Period_FixedPointIntegerShift = <NUM_LIT:1> ; private static final int kTimerOutput_Count_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Count_BitfieldOffset = <NUM_LIT:1> ; private static final int kTimerOutput_Stalled_BitfieldMask = <NUM_LIT> ; private static final int kTimerOutput_Stalled_BitfieldOffset = <NUM_LIT:0> ; private static final int kCounter0_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter1_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter2_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter3_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter4_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter5_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter6_TimerOutput_Address = <NUM_LIT> ; private static final int kCounter7_TimerOutput_Address = <NUM_LIT> ; private static final int kTimerOutput_Addresses [ ] = { kCounter0_TimerOutput_Address , kCounter1_TimerOutput_Address , kCounter2_TimerOutput_Address , kCounter3_TimerOutput_Address , kCounter4_TimerOutput_Address , kCounter5_TimerOutput_Address , kCounter6_TimerOutput_Address , kCounter7_TimerOutput_Address , } ; public int readTimerOutput ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public int readTimerOutput_Period ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Period_BitfieldMask ) > > > kTimerOutput_Period_BitfieldOffset ) << kTimerOutput_Period_FixedPointIntegerShift ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readTimerOutput_Count ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Count_BitfieldMask ) > > > kTimerOutput_Count_BitfieldOffset ) ; bitfieldValue <<= <NUM_LIT:24> ; bitfieldValue >>= <NUM_LIT:24> ; return ( byte ) ( bitfieldValue ) ; } public boolean readTimerOutput_Stalled ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerOutput_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerOutput_Stalled_BitfieldMask ) > > > kTimerOutput_Stalled_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } private static final int kTimerConfig_StallPeriod_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_StallPeriod_BitfieldOffset = <NUM_LIT:8> ; private static final int kTimerConfig_StallPeriod_FixedPointIntegerShift = <NUM_LIT:1> ; private static final int kTimerConfig_AverageSize_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_AverageSize_BitfieldOffset = <NUM_LIT:1> ; private static final int kTimerConfig_UpdateWhenEmpty_BitfieldMask = <NUM_LIT> ; private static final int kTimerConfig_UpdateWhenEmpty_BitfieldOffset = <NUM_LIT:0> ; private static final int kCounter0_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter1_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter2_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter3_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter4_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter5_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter6_TimerConfig_Address = <NUM_LIT> ; private static final int kCounter7_TimerConfig_Address = <NUM_LIT> ; private static final int kTimerConfig_Addresses [ ] = { kCounter0_TimerConfig_Address , kCounter1_TimerConfig_Address , kCounter2_TimerConfig_Address , kCounter3_TimerConfig_Address , kCounter4_TimerConfig_Address , kCounter5_TimerConfig_Address , kCounter6_TimerConfig_Address , kCounter7_TimerConfig_Address , } ; public void writeTimerConfig ( final int value ) { NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , value , status ) ; } public void writeTimerConfig_StallPeriod ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_StallPeriod_BitfieldMask ; regValue |= ( ( value > > > kTimerConfig_StallPeriod_FixedPointIntegerShift ) << kTimerConfig_StallPeriod_BitfieldOffset ) & kTimerConfig_StallPeriod_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeTimerConfig_AverageSize ( final int value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_AverageSize_BitfieldMask ; regValue |= ( ( value ) << kTimerConfig_AverageSize_BitfieldOffset ) & kTimerConfig_AverageSize_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public void writeTimerConfig_UpdateWhenEmpty ( final boolean value ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; regValue &= ~ kTimerConfig_UpdateWhenEmpty_BitfieldMask ; regValue |= ( ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) << kTimerConfig_UpdateWhenEmpty_BitfieldOffset ) & kTimerConfig_UpdateWhenEmpty_BitfieldMask ; NiRioSrv . poke32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , regValue , status ) ; } public int readTimerConfig ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; return ( int ) ( regValue ) ; } public int readTimerConfig_StallPeriod ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_StallPeriod_BitfieldMask ) > > > kTimerConfig_StallPeriod_BitfieldOffset ) << kTimerConfig_StallPeriod_FixedPointIntegerShift ; return ( int ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public byte readTimerConfig_AverageSize ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_AverageSize_BitfieldMask ) > > > kTimerConfig_AverageSize_BitfieldOffset ) ; return ( byte ) ( ( bitfieldValue ) & <NUM_LIT> ) ; } public boolean readTimerConfig_UpdateWhenEmpty ( ) { int regValue = NiRioSrv . peek32 ( m_DeviceHandle , kTimerConfig_Addresses [ m_SystemIndex ] , status ) ; int bitfieldValue = ( ( regValue & kTimerConfig_UpdateWhenEmpty_BitfieldMask ) > > > kTimerConfig_UpdateWhenEmpty_BitfieldOffset ) ; return ( ( bitfieldValue ) != <NUM_LIT:0> ? true : false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import com . sun . squawk . Isolate ; import com . sun . squawk . VM ; import edu . wpi . first . wpilibj . fpga . tGlobal ; import edu . wpi . first . wpilibj . parsing . IUtility ; public class Utility implements IUtility { static { new tGlobal ( ) ; } private Utility ( ) { } int getFPGAVersion ( ) { return tGlobal . readVersion ( ) ; } long getFPGARevision ( ) { return tGlobal . readRevision ( ) ; } public static long getFPGATime ( ) { return tGlobal . readLocalTime ( ) ; } public static void sendErrorStreamToDriverStation ( boolean enabled ) { final String url = "<STR_LIT>" ; Isolate isolate = VM . getCurrentIsolate ( ) ; if ( enabled ) { isolate . addErr ( url ) ; } else { isolate . removeErr ( url ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class ADXL345_I2C extends SensorBase { private static final byte kAddress = <NUM_LIT> ; private static final byte kPowerCtlRegister = <NUM_LIT> ; private static final byte kDataFormatRegister = <NUM_LIT> ; private static final byte kDataRegister = <NUM_LIT> ; private static final double kGsPerLSB = <NUM_LIT> ; private static final byte kPowerCtl_Link = <NUM_LIT> , kPowerCtl_AutoSleep = <NUM_LIT> , kPowerCtl_Measure = <NUM_LIT> , kPowerCtl_Sleep = <NUM_LIT> ; private static final byte kDataFormat_SelfTest = ( byte ) <NUM_LIT> , kDataFormat_SPI = <NUM_LIT> , kDataFormat_IntInvert = <NUM_LIT> , kDataFormat_FullRes = <NUM_LIT> , kDataFormat_Justify = <NUM_LIT> ; public static class DataFormat_Range { public final byte value ; static final byte k2G_val = <NUM_LIT:0x00> ; static final byte k4G_val = <NUM_LIT> ; static final byte k8G_val = <NUM_LIT> ; static final byte k16G_val = <NUM_LIT> ; public static final DataFormat_Range k2G = new DataFormat_Range ( k2G_val ) ; public static final DataFormat_Range k4G = new DataFormat_Range ( k4G_val ) ; public static final DataFormat_Range k8G = new DataFormat_Range ( k8G_val ) ; public static final DataFormat_Range k16G = new DataFormat_Range ( k16G_val ) ; private DataFormat_Range ( byte value ) { this . value = value ; } } public static class Axes { public final byte value ; static final byte kX_val = <NUM_LIT:0x00> ; static final byte kY_val = <NUM_LIT> ; static final byte kZ_val = <NUM_LIT> ; public static final Axes kX = new Axes ( kX_val ) ; public static final Axes kY = new Axes ( kY_val ) ; public static final Axes kZ = new Axes ( kZ_val ) ; private Axes ( byte value ) { this . value = value ; } } public static class AllAxes { public double XAxis ; public double YAxis ; public double ZAxis ; } private I2C m_i2c ; public ADXL345_I2C ( int slot , DataFormat_Range range ) { DigitalModule module = DigitalModule . getInstance ( slot ) ; m_i2c = module . getI2C ( kAddress ) ; m_i2c . write ( kPowerCtlRegister , kPowerCtl_Measure ) ; m_i2c . write ( kDataFormatRegister , kDataFormat_FullRes | range . value ) ; } public double getAcceleration ( Axes axis ) { byte [ ] rawAccel = new byte [ <NUM_LIT:2> ] ; m_i2c . read ( kDataRegister + axis . value , rawAccel . length , rawAccel ) ; return accelFromBytes ( rawAccel [ <NUM_LIT:0> ] , rawAccel [ <NUM_LIT:1> ] ) ; } private double accelFromBytes ( byte first , byte second ) { short tempLow = ( short ) ( first & <NUM_LIT> ) ; short tempHigh = ( short ) ( ( second << <NUM_LIT:8> ) & <NUM_LIT> ) ; return ( tempLow | tempHigh ) * kGsPerLSB ; } public AllAxes getAccelerations ( ) { AllAxes data = new AllAxes ( ) ; byte [ ] rawData = new byte [ <NUM_LIT:6> ] ; m_i2c . read ( kDataRegister , rawData . length , rawData ) ; data . XAxis = accelFromBytes ( rawData [ <NUM_LIT:0> ] , rawData [ <NUM_LIT:1> ] ) ; data . YAxis = accelFromBytes ( rawData [ <NUM_LIT:2> ] , rawData [ <NUM_LIT:3> ] ) ; data . ZAxis = accelFromBytes ( rawData [ <NUM_LIT:4> ] , rawData [ <NUM_LIT:5> ] ) ; return data ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class MotorSafetyHelper { double m_expiration ; boolean m_enabled ; double m_stopTime ; MotorSafety m_safeObject ; MotorSafetyHelper m_nextHelper ; static MotorSafetyHelper m_headHelper = null ; public MotorSafetyHelper ( MotorSafety safeObject ) { m_safeObject = safeObject ; m_enabled = false ; m_expiration = MotorSafety . DEFAULT_SAFETY_EXPIRATION ; m_stopTime = Timer . getFPGATimestamp ( ) ; m_nextHelper = m_headHelper ; m_headHelper = this ; } public void feed ( ) { m_stopTime = Timer . getFPGATimestamp ( ) + m_expiration ; } public void setExpiration ( double expirationTime ) { m_expiration = expirationTime ; } public double getExpiration ( ) { return m_expiration ; } public boolean isAlive ( ) { return ! m_enabled || m_stopTime > Timer . getFPGATimestamp ( ) ; } public void check ( ) { if ( ! m_enabled ) { return ; } if ( m_stopTime < Timer . getFPGATimestamp ( ) ) { m_safeObject . stopMotor ( ) ; } } public void setSafetyEnabled ( boolean enabled ) { m_enabled = enabled ; } public boolean isSafetyEnabled ( ) { return m_enabled ; } public static void checkMotors ( ) { for ( MotorSafetyHelper msh = m_headHelper ; msh != null ; msh = msh . m_nextHelper ) { msh . check ( ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tWatchdog ; import edu . wpi . first . wpilibj . parsing . IUtility ; public class Watchdog extends SensorBase implements IUtility { private static Watchdog m_instance ; private tWatchdog m_fpgaWatchdog ; public static final double kDefaultWatchdogExpiration = <NUM_LIT> ; protected Watchdog ( ) { m_fpgaWatchdog = new tWatchdog ( ) ; setExpiration ( Watchdog . kDefaultWatchdogExpiration ) ; setEnabled ( true ) ; } public static synchronized Watchdog getInstance ( ) { if ( m_instance == null ) { m_instance = new Watchdog ( ) ; } return m_instance ; } public void feed ( ) { tWatchdog . strobeFeed ( ) ; } public void kill ( ) { tWatchdog . strobeKill ( ) ; } public double getTimer ( ) { long timer = tWatchdog . readTimer ( ) ; return timer / ( kSystemClockTicksPerMicrosecond * <NUM_LIT> ) ; } public double getExpiration ( ) { long expiration = tWatchdog . readExpiration ( ) ; return ( double ) expiration / ( kSystemClockTicksPerMicrosecond * <NUM_LIT> ) ; } public void setExpiration ( double expiration ) { tWatchdog . writeExpiration ( ( int ) ( expiration * ( kSystemClockTicksPerMicrosecond * <NUM_LIT> ) ) ) ; } public boolean getEnabled ( ) { return ! tWatchdog . readImmortal ( ) ; } public void setEnabled ( final boolean enabled ) { tWatchdog . writeImmortal ( ! enabled ) ; } public boolean isAlive ( ) { return tWatchdog . readStatus_Alive ( ) ; } public boolean isSystemActive ( ) { return tWatchdog . readStatus_SystemActive ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tAI ; import edu . wpi . first . wpilibj . communication . AICalibration ; public class AnalogModule extends Module { public static final int kTimebase = <NUM_LIT> ; public static final int kDefaultOversampleBits = <NUM_LIT:0> ; public static final int kDefaultAverageBits = <NUM_LIT:7> ; public static final double kDefaultSampleRate = <NUM_LIT> ; private tAI m_module ; private boolean m_sampleRateSet ; private long m_accumulatorOffset ; private int m_numChannelsToActivate ; private final Object syncRoot = new Object ( ) ; public static synchronized AnalogModule getInstance ( final int slot ) { checkAnalogModule ( slot ) ; if ( Module . m_modules [ slot ] == null ) { Module . m_modules [ slot ] = new AnalogModule ( slot ) ; } return ( AnalogModule ) Module . m_modules [ slot ] ; } public static int slotToIndex ( final int slot ) { return slot - <NUM_LIT:1> ; } protected AnalogModule ( final int slot ) { super ( slot ) ; m_module = new tAI ( slotToIndex ( slot ) ) ; setNumChannelsToActivate ( SensorBase . kAnalogChannels ) ; setSampleRate ( AnalogModule . kDefaultSampleRate ) ; for ( int i = <NUM_LIT:0> ; i < SensorBase . kAnalogChannels ; i ++ ) { m_module . writeScanList ( i , i ) ; setAverageBits ( i + <NUM_LIT:1> , kDefaultAverageBits ) ; setOversampleBits ( i + <NUM_LIT:1> , kDefaultOversampleBits ) ; } } public void setSampleRate ( final double samplesPerSecond ) { m_sampleRateSet = true ; final int ticksPerSample = ( int ) ( ( double ) AnalogModule . kTimebase / samplesPerSecond ) ; int ticksPerConversion = ticksPerSample / getNumChannelsToActivate ( ) ; if ( ticksPerConversion < <NUM_LIT> ) { ticksPerConversion = <NUM_LIT> ; } m_module . writeConfig_ScanSize ( getNumChannelsToActivate ( ) ) ; m_module . writeConfig_ConvertRate ( ticksPerConversion ) ; setNumChannelsToActivate ( <NUM_LIT:0> ) ; } public double getSampleRate ( ) { final long ticksPerConversion = m_module . readLoopTiming ( ) ; final long ticksPerSample = ticksPerConversion * getNumActiveChannels ( ) ; return ( double ) AnalogModule . kTimebase / ( double ) ticksPerSample ; } private int getNumActiveChannels ( ) { final int scanSize = m_module . readConfig_ScanSize ( ) ; return scanSize == <NUM_LIT:0> ? <NUM_LIT:8> : scanSize ; } private int getNumChannelsToActivate ( ) { if ( m_numChannelsToActivate == <NUM_LIT:0> ) { return getNumActiveChannels ( ) ; } return m_numChannelsToActivate ; } private void setNumChannelsToActivate ( final int channels ) { m_numChannelsToActivate = channels ; } public void setAverageBits ( final int channel , final int bits ) { m_module . writeAverageBits ( channel - <NUM_LIT:1> , bits ) ; } public int getAverageBits ( final int channel ) { return m_module . readAverageBits ( channel - <NUM_LIT:1> ) ; } public void setOversampleBits ( final int channel , final int bits ) { m_module . writeOversampleBits ( channel - <NUM_LIT:1> , bits ) ; } public int getOversampleBits ( final int channel ) { return m_module . readOversampleBits ( channel - <NUM_LIT:1> ) ; } public int getValue ( final int channel ) { int value ; SensorBase . checkAnalogChannel ( channel ) ; synchronized ( syncRoot ) { tAI . writeReadSelect_Channel ( channel - <NUM_LIT:1> ) ; tAI . writeReadSelect_Module ( slotToIndex ( m_slot ) ) ; tAI . writeReadSelect_Averaged ( false ) ; tAI . strobeLatchOutput ( ) ; value = tAI . readOutput ( ) ; } return ( short ) value ; } public int getAverageValue ( final int channel ) { int value ; SensorBase . checkAnalogChannel ( channel ) ; synchronized ( syncRoot ) { tAI . writeReadSelect_Channel ( channel - <NUM_LIT:1> ) ; tAI . writeReadSelect_Module ( slotToIndex ( m_slot ) ) ; tAI . writeReadSelect_Averaged ( true ) ; tAI . strobeLatchOutput ( ) ; value = tAI . readOutput ( ) ; } return value ; } public int voltsToValue ( final int channel , final double voltage ) { final long LSBWeight = getLSBWeight ( channel ) ; final int offset = getOffset ( channel ) ; final int value = ( int ) ( ( voltage + offset * <NUM_LIT> ) / ( LSBWeight * <NUM_LIT> ) ) ; return value ; } public double getVoltage ( final int channel ) { final int value = getValue ( channel ) ; final long LSBWeight = getLSBWeight ( channel ) ; final int offset = getOffset ( channel ) ; final double voltage = ( LSBWeight * <NUM_LIT> * value ) - ( offset * <NUM_LIT> ) ; return voltage ; } public double getAverageVoltage ( final int channel ) { final int value = getAverageValue ( channel ) ; final long LSBWeight = getLSBWeight ( channel ) ; final int offset = getOffset ( channel ) ; final int oversampleBits = getOversampleBits ( channel ) ; final double voltage = ( ( LSBWeight * <NUM_LIT> * value ) / ( double ) ( <NUM_LIT:1> << oversampleBits ) ) - ( offset * <NUM_LIT> ) ; return voltage ; } public long getLSBWeight ( final int channel ) { return AICalibration . getLSBWeight ( m_module . getSystemIndex ( ) , channel - <NUM_LIT:1> ) ; } public int getOffset ( final int channel ) { return AICalibration . getOffset ( m_module . getSystemIndex ( ) , channel - <NUM_LIT:1> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import com . sun . squawk . * ; public class IterativeRobot extends RobotBase { private final static boolean TRACE_LOOP_ALLOCATIONS = false ; private final static boolean TRACE_LOOP_ALLOCATIONS_AFTER_INIT = true ; private boolean m_disabledInitialized ; private boolean m_autonomousInitialized ; private boolean m_teleopInitialized ; public IterativeRobot ( ) { m_disabledInitialized = false ; m_autonomousInitialized = false ; m_teleopInitialized = false ; } public void startCompetition ( ) { robotInit ( ) ; final int TRACE_LOOP_MAX = <NUM_LIT:100> ; int loopCount = TRACE_LOOP_MAX ; Object marker = null ; boolean didDisabledPeriodic = false ; boolean didAutonomousPeriodic = false ; boolean didTeleopPeriodic = false ; if ( TRACE_LOOP_ALLOCATIONS ) { GC . initHeapStats ( ) ; if ( ! TRACE_LOOP_ALLOCATIONS_AFTER_INIT ) { System . out . println ( "<STR_LIT>" ) ; marker = new Object ( ) ; } } while ( true ) { if ( TRACE_LOOP_ALLOCATIONS && didDisabledPeriodic && didAutonomousPeriodic && didTeleopPeriodic && -- loopCount <= <NUM_LIT:0> ) { System . out . println ( "<STR_LIT>" ) ; break ; } if ( isDisabled ( ) ) { if ( ! m_disabledInitialized ) { disabledInit ( ) ; m_disabledInitialized = true ; m_autonomousInitialized = false ; m_teleopInitialized = false ; } if ( nextPeriodReady ( ) ) { disabledPeriodic ( ) ; didDisabledPeriodic = true ; } disabledContinuous ( ) ; } else if ( isAutonomous ( ) ) { if ( ! m_autonomousInitialized ) { autonomousInit ( ) ; m_autonomousInitialized = true ; m_teleopInitialized = false ; m_disabledInitialized = false ; } if ( nextPeriodReady ( ) ) { getWatchdog ( ) . feed ( ) ; autonomousPeriodic ( ) ; didAutonomousPeriodic = true ; } autonomousContinuous ( ) ; } else { if ( ! m_teleopInitialized ) { teleopInit ( ) ; m_teleopInitialized = true ; m_autonomousInitialized = false ; m_disabledInitialized = false ; } if ( nextPeriodReady ( ) ) { getWatchdog ( ) . feed ( ) ; teleopPeriodic ( ) ; didTeleopPeriodic = true ; } teleopContinuous ( ) ; } if ( TRACE_LOOP_ALLOCATIONS && TRACE_LOOP_ALLOCATIONS_AFTER_INIT && didDisabledPeriodic && didAutonomousPeriodic && didTeleopPeriodic && loopCount == TRACE_LOOP_MAX ) { System . out . println ( "<STR_LIT>" ) ; marker = new Object ( ) ; } } if ( TRACE_LOOP_ALLOCATIONS ) { GC . printHeapStats ( marker , false ) ; } } private boolean nextPeriodReady ( ) { return m_ds . isNewControlData ( ) ; } public void robotInit ( ) { System . out . println ( "<STR_LIT>" ) ; } public void disabledInit ( ) { System . out . println ( "<STR_LIT>" ) ; } public void autonomousInit ( ) { System . out . println ( "<STR_LIT>" ) ; } public void teleopInit ( ) { System . out . println ( "<STR_LIT>" ) ; } private boolean dpFirstRun = true ; public void disabledPeriodic ( ) { if ( dpFirstRun ) { System . out . println ( "<STR_LIT>" ) ; dpFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } private boolean apFirstRun = true ; public void autonomousPeriodic ( ) { if ( apFirstRun ) { System . out . println ( "<STR_LIT>" ) ; apFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } private boolean tpFirstRun = true ; public void teleopPeriodic ( ) { if ( tpFirstRun ) { System . out . println ( "<STR_LIT>" ) ; tpFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } private boolean dcFirstRun = true ; public void disabledContinuous ( ) { if ( dcFirstRun ) { System . out . println ( "<STR_LIT>" ) ; dcFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } private boolean acFirstRun = true ; public void autonomousContinuous ( ) { if ( acFirstRun ) { System . out . println ( "<STR_LIT>" ) ; acFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } private boolean tcFirstRun = true ; public void teleopContinuous ( ) { if ( tcFirstRun ) { System . out . println ( "<STR_LIT>" ) ; tcFirstRun = false ; } Timer . delay ( <NUM_LIT> ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class AccumulatorResult { public long value ; public long count ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tEncoder ; import edu . wpi . first . wpilibj . parsing . ISensor ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class Encoder extends SensorBase implements CounterBase , ISensor { static Resource quadEncoders = new Resource ( tEncoder . kNumSystems ) ; protected DigitalSource m_aSource ; protected DigitalSource m_bSource ; protected DigitalSource m_indexSource = null ; private tEncoder m_encoder ; private int m_index ; private double m_distancePerPulse ; private Counter m_counter ; private EncodingType m_encodingType = EncodingType . k4X ; private boolean m_allocatedA ; private boolean m_allocatedB ; private boolean m_allocatedI ; private void initEncoder ( boolean reverseDirection ) { switch ( m_encodingType . value ) { case EncodingType . k4X_val : try { m_index = quadEncoders . allocate ( ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" ) ; } m_encoder = new tEncoder ( m_index ) ; m_encoder . writeConfig_ASource_Module ( m_aSource . getModuleForRouting ( ) ) ; m_encoder . writeConfig_ASource_Channel ( m_aSource . getChannelForRouting ( ) ) ; m_encoder . writeConfig_ASource_AnalogTrigger ( m_aSource . getAnalogTriggerForRouting ( ) ) ; m_encoder . writeConfig_BSource_Module ( m_bSource . getModuleForRouting ( ) ) ; m_encoder . writeConfig_BSource_Channel ( m_bSource . getChannelForRouting ( ) ) ; m_encoder . writeConfig_BSource_AnalogTrigger ( m_bSource . getAnalogTriggerForRouting ( ) ) ; m_encoder . strobeReset ( ) ; m_encoder . writeConfig_Reverse ( reverseDirection ) ; m_encoder . writeTimerConfig_AverageSize ( <NUM_LIT:1> ) ; if ( m_indexSource != null ) { m_encoder . writeConfig_IndexSource_Module ( m_indexSource . getModuleForRouting ( ) ) ; m_encoder . writeConfig_IndexSource_Channel ( m_indexSource . getChannelForRouting ( ) ) ; m_encoder . writeConfig_IndexSource_AnalogTrigger ( m_indexSource . getAnalogTriggerForRouting ( ) ) ; m_encoder . writeConfig_IndexActiveHigh ( true ) ; } m_counter = null ; break ; case EncodingType . k2X_val : case EncodingType . k1X_val : m_counter = new Counter ( m_encodingType , m_aSource , m_bSource , reverseDirection ) ; break ; } m_distancePerPulse = <NUM_LIT:1.0> ; } public Encoder ( final int aSlot , final int aChannel , final int bSlot , final int bChannel , boolean reverseDirection ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = false ; m_aSource = new DigitalInput ( aSlot , aChannel ) ; m_bSource = new DigitalInput ( bSlot , bChannel ) ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aSlot , final int aChannel , final int bSlot , final int bChannel ) { this ( aSlot , aChannel , bSlot , bChannel , false ) ; } public Encoder ( final int aSlot , final int aChannel , final int bSlot , final int bChannel , boolean reverseDirection , final EncodingType encodingType ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = false ; m_aSource = new DigitalInput ( aSlot , aChannel ) ; m_bSource = new DigitalInput ( bSlot , bChannel ) ; if ( encodingType == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_encodingType = encodingType ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aSlot , final int aChannel , final int bSlot , final int bChannel , final int indexSlot , final int indexChannel , boolean reverseDirection ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = true ; m_aSource = new DigitalInput ( aSlot , aChannel ) ; m_bSource = new DigitalInput ( bSlot , bChannel ) ; m_indexSource = new DigitalInput ( indexSlot , indexChannel ) ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aSlot , final int aChannel , final int bSlot , final int bChannel , final int indexSlot , final int indexChannel ) { this ( aSlot , aChannel , bSlot , bChannel , indexSlot , indexChannel , false ) ; } public Encoder ( final int aChannel , final int bChannel , boolean reverseDirection ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = false ; m_aSource = new DigitalInput ( aChannel ) ; m_bSource = new DigitalInput ( bChannel ) ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aChannel , final int bChannel ) { this ( aChannel , bChannel , false ) ; } public Encoder ( final int aChannel , final int bChannel , boolean reverseDirection , final EncodingType encodingType ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = false ; if ( encodingType == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_encodingType = encodingType ; m_aSource = new DigitalInput ( aChannel ) ; m_bSource = new DigitalInput ( bChannel ) ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aChannel , final int bChannel , final int indexChannel , boolean reverseDirection ) { m_allocatedA = true ; m_allocatedB = true ; m_allocatedI = true ; m_aSource = new DigitalInput ( aChannel ) ; m_bSource = new DigitalInput ( bChannel ) ; m_indexSource = new DigitalInput ( indexChannel ) ; initEncoder ( reverseDirection ) ; } public Encoder ( final int aChannel , final int bChannel , final int indexChannel ) { this ( aChannel , bChannel , indexChannel , false ) ; } public Encoder ( DigitalSource aSource , DigitalSource bSource , boolean reverseDirection ) { m_allocatedA = false ; m_allocatedB = false ; m_allocatedI = false ; if ( aSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_aSource = aSource ; if ( bSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_bSource = bSource ; initEncoder ( reverseDirection ) ; } public Encoder ( DigitalSource aSource , DigitalSource bSource ) { this ( aSource , bSource , false ) ; } public Encoder ( DigitalSource aSource , DigitalSource bSource , boolean reverseDirection , final EncodingType encodingType ) { m_allocatedA = false ; m_allocatedB = false ; m_allocatedI = false ; if ( encodingType == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_encodingType = encodingType ; if ( aSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_aSource = aSource ; if ( bSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_aSource = aSource ; m_bSource = bSource ; initEncoder ( reverseDirection ) ; } public Encoder ( DigitalSource aSource , DigitalSource bSource , DigitalSource indexSource , boolean reverseDirection ) { m_allocatedA = false ; m_allocatedB = false ; m_allocatedI = false ; if ( aSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_aSource = aSource ; if ( bSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_aSource = aSource ; m_bSource = bSource ; m_indexSource = indexSource ; initEncoder ( reverseDirection ) ; } public Encoder ( DigitalSource aSource , DigitalSource bSource , DigitalSource indexSource ) { this ( aSource , bSource , indexSource , false ) ; } protected void free ( ) { if ( m_aSource != null && m_allocatedA ) { m_aSource . free ( ) ; m_allocatedA = false ; } if ( m_bSource != null && m_allocatedB ) { m_bSource . free ( ) ; m_allocatedB = false ; } if ( m_indexSource != null && m_allocatedI ) { m_indexSource . free ( ) ; m_allocatedI = false ; } m_aSource = null ; m_bSource = null ; m_indexSource = null ; if ( m_counter != null ) { m_counter . free ( ) ; m_counter = null ; } else { m_encoder . Release ( ) ; quadEncoders . free ( m_index ) ; m_encoder = null ; } } public void start ( ) { if ( m_counter != null ) { m_counter . start ( ) ; } else { m_encoder . writeConfig_Enable ( true ) ; } } public void stop ( ) { if ( m_counter != null ) { m_counter . stop ( ) ; } else { m_encoder . writeConfig_Enable ( false ) ; } } public int getRaw ( ) { int value ; if ( m_counter != null ) { value = m_counter . get ( ) ; } else { value = m_encoder . readOutput_Value ( ) ; } return value ; } public int get ( ) { return ( int ) ( getRaw ( ) * decodingScaleFactor ( ) ) ; } public void reset ( ) { if ( m_counter != null ) { m_counter . reset ( ) ; } else { m_encoder . strobeReset ( ) ; } } public double getPeriod ( ) { double measuredPeriod ; if ( m_counter != null ) { measuredPeriod = m_counter . getPeriod ( ) ; } else { double value ; if ( m_encoder . readTimerOutput_Stalled ( ) ) { return Double . POSITIVE_INFINITY ; } else { value = ( double ) m_encoder . readTimerOutput_Period ( ) / ( double ) m_encoder . readTimerOutput_Count ( ) ; } measuredPeriod = value * <NUM_LIT> ; } return measuredPeriod / decodingScaleFactor ( ) ; } public void setMaxPeriod ( double maxPeriod ) { if ( m_counter != null ) { m_counter . setMaxPeriod ( maxPeriod * decodingScaleFactor ( ) ) ; } else { m_encoder . writeTimerConfig_StallPeriod ( ( int ) ( maxPeriod * <NUM_LIT> * decodingScaleFactor ( ) ) ) ; } } public boolean getStopped ( ) { if ( m_counter != null ) { return m_counter . getStopped ( ) ; } else { boolean value = m_encoder . readTimerOutput_Stalled ( ) != false ; return value ; } } public boolean getDirection ( ) { if ( m_counter != null ) { return m_counter . getDirection ( ) ; } else { boolean value = m_encoder . readOutput_Direction ( ) ; return value ; } } private double decodingScaleFactor ( ) { switch ( m_encodingType . value ) { case EncodingType . k1X_val : return <NUM_LIT:1.0> ; case EncodingType . k2X_val : return <NUM_LIT> ; case EncodingType . k4X_val : return <NUM_LIT> ; default : return <NUM_LIT:0.0> ; } } public double getDistance ( ) { return getRaw ( ) * decodingScaleFactor ( ) * m_distancePerPulse ; } public double getRate ( ) { return m_distancePerPulse / getPeriod ( ) ; } public void setMinRate ( double minRate ) { setMaxPeriod ( m_distancePerPulse / minRate ) ; } public void setDistancePerPulse ( double distancePerPulse ) { m_distancePerPulse = distancePerPulse ; } public void setReverseDirection ( boolean reverseDirection ) { if ( m_counter != null ) { m_counter . setReverseDirection ( reverseDirection ) ; } else { m_encoder . writeConfig_Reverse ( reverseDirection ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . visa . Visa ; import edu . wpi . first . wpilibj . visa . VisaException ; public class SerialPort { private int m_resourceManagerHandle ; private int m_portHandle ; public static class Parity { public final int value ; static final int kNone_val = <NUM_LIT:0> ; static final int kOdd_val = <NUM_LIT:1> ; static final int kEven_val = <NUM_LIT:2> ; static final int kMark_val = <NUM_LIT:3> ; static final int kSpace_val = <NUM_LIT:4> ; public static final Parity kNone = new Parity ( kNone_val ) ; public static final Parity kOdd = new Parity ( kOdd_val ) ; public static final Parity kEven = new Parity ( kEven_val ) ; public static final Parity kMark = new Parity ( kMark_val ) ; public static final Parity kSpace = new Parity ( ( kSpace_val ) ) ; private Parity ( int value ) { this . value = value ; } } public static class StopBits { public final int value ; static final int kOne_val = <NUM_LIT:10> ; static final int kOnePointFive_val = <NUM_LIT:15> ; static final int kTwo_val = <NUM_LIT:20> ; public static final StopBits kOne = new StopBits ( kOne_val ) ; public static final StopBits kOnePointFive = new StopBits ( kOnePointFive_val ) ; public static final StopBits kTwo = new StopBits ( kTwo_val ) ; private StopBits ( int value ) { this . value = value ; } } public static class FlowControl { public final int value ; static final int kNone_val = <NUM_LIT:0> ; static final int kXonXoff_val = <NUM_LIT:1> ; static final int kRtsCts_val = <NUM_LIT:2> ; static final int kDtrDsr_val = <NUM_LIT:4> ; public static final FlowControl kNone = new FlowControl ( kNone_val ) ; public static final FlowControl kXonXoff = new FlowControl ( kXonXoff_val ) ; public static final FlowControl kRtsCts = new FlowControl ( kRtsCts_val ) ; public static final FlowControl kDtrDsr = new FlowControl ( kDtrDsr_val ) ; private FlowControl ( int value ) { this . value = value ; } } public static class WriteBufferMode { public final int value ; static final int kFlushOnAccess_val = <NUM_LIT:1> ; static final int kFlushWhenFull_val = <NUM_LIT:2> ; public static final WriteBufferMode kFlushOnAccess = new WriteBufferMode ( kFlushOnAccess_val ) ; public static final WriteBufferMode kFlushWhenFull = new WriteBufferMode ( kFlushWhenFull_val ) ; private WriteBufferMode ( int value ) { this . value = value ; } } public SerialPort ( final int baudRate , final int dataBits , Parity parity , StopBits stopBits ) throws VisaException { m_resourceManagerHandle = <NUM_LIT:0> ; m_portHandle = <NUM_LIT:0> ; m_resourceManagerHandle = Visa . viOpenDefaultRM ( ) ; m_portHandle = Visa . viOpen ( m_resourceManagerHandle , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:0> ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_BAUD , baudRate ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_DATA_BITS , dataBits ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_PARITY , parity . value ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_STOP_BITS , stopBits . value ) ; setTimeout ( <NUM_LIT> ) ; setWriteBufferMode ( WriteBufferMode . kFlushOnAccess ) ; disableTermination ( ) ; } public SerialPort ( final int baudRate , final int dataBits , Parity parity ) throws VisaException { this ( baudRate , dataBits , parity , StopBits . kOne ) ; } public SerialPort ( final int baudRate , final int dataBits ) throws VisaException { this ( baudRate , dataBits , Parity . kNone , StopBits . kOne ) ; } public SerialPort ( final int baudRate ) throws VisaException { this ( baudRate , <NUM_LIT:8> , Parity . kNone , StopBits . kOne ) ; } protected void free ( ) { Visa . viClose ( m_portHandle ) ; Visa . viClose ( m_resourceManagerHandle ) ; } public void setFlowControl ( FlowControl flowControl ) throws VisaException { Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_FLOW_CNTRL , flowControl . value ) ; } public void enableTermination ( char terminator ) throws VisaException { Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_TERMCHAR_EN , true ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_TERMCHAR , terminator ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_END_IN , Visa . VI_ASRL_END_TERMCHAR ) ; } public void enableTermination ( ) throws VisaException { this . enableTermination ( '<STR_LIT:\n>' ) ; } public void disableTermination ( ) throws VisaException { Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_TERMCHAR_EN , false ) ; Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_END_IN , Visa . VI_ASRL_END_NONE ) ; } public int getBytesReceived ( ) throws VisaException { return Visa . viGetAttribute ( m_portHandle , Visa . VI_ATTR_ASRL_AVAIL_NUM ) ; } public void print ( String write ) throws VisaException { Visa . viVPrintf ( m_portHandle , write ) ; } public String readString ( ) throws VisaException { return readString ( getBytesReceived ( ) ) ; } public String readString ( int count ) throws VisaException { byte [ ] out = Visa . viBufRead ( m_portHandle , count ) ; StringBuffer s = new StringBuffer ( count + <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { s . append ( out [ i ] ) ; } return s . toString ( ) ; } public byte [ ] read ( final int count ) throws VisaException { return Visa . viBufRead ( m_portHandle , count ) ; } public int write ( byte [ ] buffer , int count ) throws VisaException { return Visa . viBufWrite ( m_portHandle , buffer , count ) ; } public void setTimeout ( double timeout ) throws VisaException { Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_TMO_VALUE , ( int ) ( timeout * <NUM_LIT> ) ) ; } public void setWriteBufferMode ( WriteBufferMode mode ) throws VisaException { Visa . viSetAttribute ( m_portHandle , Visa . VI_ATTR_WR_BUF_OPER_MODE , mode . value ) ; } public void flush ( ) throws VisaException { Visa . viFlush ( m_portHandle , Visa . VI_WRITE_BUF ) ; } public void reset ( ) throws VisaException { Visa . viClear ( m_portHandle ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public abstract class DigitalSource extends InterruptableSensorBase { public abstract int getChannelForRouting ( ) ; public abstract int getModuleForRouting ( ) ; public abstract boolean getAnalogTriggerForRouting ( ) ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IDevice ; public class Compressor extends SensorBase implements IDevice { private DigitalInput m_pressureSwitch ; private Relay m_relay ; private boolean m_enabled ; private Thread m_task ; private boolean m_run = true ; private class CompressorThread extends Thread { Compressor m_compressor ; CompressorThread ( Compressor comp ) { m_compressor = comp ; } public void run ( ) { while ( m_run ) { if ( m_compressor . enabled ( ) ) { m_compressor . setRelayValue ( ! m_compressor . getPressureSwitchValue ( ) ? Relay . Value . kOn : Relay . Value . kOff ) ; } else { m_compressor . setRelayValue ( Relay . Value . kOff ) ; } try { Thread . sleep ( <NUM_LIT> ) ; } catch ( InterruptedException e ) { } } } } private void initCompressor ( final int pressureSwitchSlot , final int pressureSwitchChannel , final int compresssorRelaySlot , final int compressorRelayChannel ) { checkDigitalModule ( pressureSwitchSlot ) ; checkRelayModule ( compresssorRelaySlot ) ; checkDigitalChannel ( pressureSwitchChannel ) ; checkRelayChannel ( compressorRelayChannel ) ; m_enabled = false ; m_pressureSwitch = new DigitalInput ( pressureSwitchSlot , pressureSwitchChannel ) ; m_relay = new Relay ( compresssorRelaySlot , compressorRelayChannel , Relay . Direction . kForward ) ; m_task = new CompressorThread ( this ) ; m_task . start ( ) ; } public Compressor ( final int pressureSwitchSlot , final int pressureSwitchChannel , final int compresssorRelaySlot , final int compressorRelayChannel ) { initCompressor ( pressureSwitchSlot , pressureSwitchChannel , compresssorRelaySlot , compressorRelayChannel ) ; } public Compressor ( final int pressureSwitchChannel , final int compressorRelayChannel ) { initCompressor ( getDefaultDigitalModule ( ) , pressureSwitchChannel , getDefaultDigitalModule ( ) , compressorRelayChannel ) ; } protected void free ( ) { m_run = false ; try { m_task . join ( ) ; } catch ( InterruptedException e ) { } m_pressureSwitch . free ( ) ; m_relay . free ( ) ; m_pressureSwitch = null ; m_relay = null ; } public void setRelayValue ( Relay . Value relayValue ) { m_relay . set ( relayValue ) ; } public boolean getPressureSwitchValue ( ) { return m_pressureSwitch . get ( ) ; } public void start ( ) { m_enabled = true ; } public void stop ( ) { m_enabled = false ; } public boolean enabled ( ) { return m_enabled ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class SensorBase { private static final int [ ] modulePopulation = new int [ ] { <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; public static final int kSystemClockTicksPerMicrosecond = <NUM_LIT> ; public static final int kDigitalChannels = <NUM_LIT> ; public static final int kAnalogChannels = <NUM_LIT:8> ; public static final int kAnalogModules = <NUM_LIT:2> ; public static final int kSolenoidChannels = <NUM_LIT:8> ; public static final int kSolenoidModules = <NUM_LIT:2> ; public static final int kPwmChannels = <NUM_LIT:10> ; public static final int kRelayChannels = <NUM_LIT:8> ; public static final int kChassisSlots = <NUM_LIT:8> ; private static int m_defaultAnalogModule = <NUM_LIT:1> ; private static int m_defaultDigitalModule = <NUM_LIT:4> ; private static int m_defaultSolenoidModule = <NUM_LIT:8> ; public SensorBase ( ) { } public static void setDefaultDigitalModule ( final int slot ) { checkDigitalModule ( slot ) ; SensorBase . m_defaultDigitalModule = slot ; } public static void setDefaultAnalogModule ( final int slot ) { checkAnalogModule ( slot ) ; SensorBase . m_defaultAnalogModule = slot ; } public static void setDefaultSolenoidModule ( final int slot ) { checkSolenoidModule ( slot ) ; SensorBase . m_defaultSolenoidModule = slot ; } protected static void checkDigitalModule ( final int slot ) { if ( slot > kChassisSlots || modulePopulation [ slot ] != <NUM_LIT> ) { System . err . print ( "<STR_LIT>" ) ; System . err . print ( slot ) ; System . err . println ( "<STR_LIT>" ) ; throw new IndexOutOfBoundsException ( "<STR_LIT>" + slot + "<STR_LIT>" ) ; } } protected static void checkRelayModule ( final int slot ) { checkDigitalModule ( slot ) ; } protected static void checkPWMModule ( final int slot ) { SensorBase . checkDigitalModule ( slot ) ; } protected static void checkAnalogModule ( final int slot ) { if ( slot > kChassisSlots || modulePopulation [ slot ] != <NUM_LIT> ) { System . err . print ( "<STR_LIT>" ) ; System . err . print ( slot ) ; System . err . println ( "<STR_LIT>" ) ; } } protected static void checkSolenoidModule ( final int slot ) { if ( slot > kChassisSlots || modulePopulation [ slot ] != <NUM_LIT> ) { System . err . print ( "<STR_LIT>" ) ; System . err . print ( slot ) ; System . err . println ( "<STR_LIT>" ) ; } } protected static void checkDigitalChannel ( final int channel ) { if ( channel <= <NUM_LIT:0> || channel > kDigitalChannels ) { System . err . println ( "<STR_LIT>" ) ; } } protected static void checkRelayChannel ( final int channel ) { if ( channel <= <NUM_LIT:0> || channel > kRelayChannels ) { System . err . println ( "<STR_LIT>" ) ; throw new IndexOutOfBoundsException ( "<STR_LIT>" ) ; } } protected static void checkPWMChannel ( final int channel ) { if ( channel <= <NUM_LIT:0> || channel > kPwmChannels ) { System . err . println ( "<STR_LIT>" ) ; throw new IndexOutOfBoundsException ( "<STR_LIT>" ) ; } } protected static void checkAnalogChannel ( final int channel ) { if ( channel <= <NUM_LIT:0> || channel > kAnalogChannels ) { System . err . println ( "<STR_LIT>" ) ; } } protected static void checkSolenoidChannel ( final int channel ) { if ( channel <= <NUM_LIT:0> || channel > kSolenoidChannels ) { System . err . println ( "<STR_LIT>" ) ; } } public static int getDefaultAnalogModule ( ) { return SensorBase . m_defaultAnalogModule ; } public static int getDefaultDigitalModule ( ) { return SensorBase . m_defaultDigitalModule ; } public static int getDefaultSolenoidModule ( ) { return SensorBase . m_defaultSolenoidModule ; } protected void free ( ) { } } </s>
|
<s> package edu . wpi . first . wpilibj ; public interface PIDOutput { public void pidWrite ( double output ) ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IDeviceController ; public class Victor extends SafePWM implements SpeedController , IDeviceController { private void initVictor ( ) { setBounds ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ; setPeriodMultiplier ( PeriodMultiplier . k2X ) ; setRaw ( m_centerPwm ) ; } public Victor ( final int channel ) { super ( channel ) ; initVictor ( ) ; } public Victor ( final int slot , final int channel ) { super ( slot , channel ) ; initVictor ( ) ; } public void set ( double speed , byte syncGroup ) { setSpeed ( speed ) ; } public void set ( double speed ) { setSpeed ( speed ) ; } public double get ( ) { return getSpeed ( ) ; } public void pidWrite ( double output ) { set ( output ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public interface SpeedController extends PIDOutput { double get ( ) ; void set ( double speed , byte syncGroup ) ; void set ( double speed ) ; void disable ( ) ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import com . sun . squawk . util . MathUtils ; import edu . wpi . first . wpilibj . fpga . tDIO ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class DigitalModule extends Module { public static final int kExpectedLoopTiming = <NUM_LIT> ; private static final int mapping [ ] = { <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> } ; private static final Resource DIOChannels = new Resource ( tDIO . kNumSystems * SensorBase . kDigitalChannels ) ; private static final Resource DO_PWMGenerators [ ] = new Resource [ tDIO . kNumSystems ] ; tDIO m_fpgaDIO ; private final Object syncRoot = new Object ( ) ; public static synchronized DigitalModule getInstance ( final int slot ) { SensorBase . checkDigitalModule ( slot ) ; if ( Module . m_modules [ slot ] == null ) { Module . m_modules [ slot ] = new DigitalModule ( slot ) ; } return ( DigitalModule ) Module . m_modules [ slot ] ; } public static int slotToIndex ( final int slot ) { return DigitalModule . mapping [ slot - <NUM_LIT:1> ] ; } public static int remapDigitalChannel ( final int channel ) { return <NUM_LIT:15> - channel ; } public static int unmapDigitalChannel ( final int channel ) { return <NUM_LIT:15> - channel ; } protected DigitalModule ( final int slot ) { super ( slot ) ; DO_PWMGenerators [ slotToIndex ( m_slot ) ] = new Resource ( tDIO . kDO_PWMDutyCycle_NumElements ) ; m_fpgaDIO = new tDIO ( slotToIndex ( m_slot ) ) ; while ( tDIO . readLoopTiming ( ) == <NUM_LIT:0> ) { Timer . delay ( <NUM_LIT> ) ; } if ( tDIO . readLoopTiming ( ) != kExpectedLoopTiming ) { System . out . print ( "<STR_LIT>" ) ; System . out . print ( tDIO . readLoopTiming ( ) ) ; System . out . print ( "<STR_LIT>" ) ; System . out . println ( kExpectedLoopTiming ) ; } tDIO . writePWMConfig_Period ( ( short ) PWM . kDefaultPwmPeriod ) ; tDIO . writePWMConfig_MinHigh ( ( short ) PWM . kDefaultMinPwmHigh ) ; for ( int pwm_index = <NUM_LIT:1> ; pwm_index <= kPwmChannels ; pwm_index ++ ) { setPWM ( pwm_index , PWM . kPwmDisabled ) ; setPWMPeriodScale ( pwm_index , PWM . PeriodMultiplier . k4X_val ) ; } m_fpgaDIO . writeSlowValue_RelayFwd ( <NUM_LIT:0> ) ; m_fpgaDIO . writeSlowValue_RelayRev ( <NUM_LIT:0> ) ; } public void setPWM ( final int channel , final int value ) { checkPWMChannel ( channel ) ; m_fpgaDIO . writePWMValue ( channel - <NUM_LIT:1> , value ) ; } public int getPWM ( final int channel ) { checkPWMChannel ( channel ) ; return m_fpgaDIO . readPWMValue ( channel - <NUM_LIT:1> ) ; } public void setPWMPeriodScale ( final int channel , final int squelchMask ) { checkPWMChannel ( channel ) ; m_fpgaDIO . writePWMPeriodScale ( ( byte ) ( channel - <NUM_LIT:1> ) , squelchMask ) ; } public void setRelayForward ( final int channel , final boolean on ) { checkRelayChannel ( channel ) ; synchronized ( syncRoot ) { int forwardRelays = m_fpgaDIO . readSlowValue_RelayFwd ( ) ; if ( on ) { forwardRelays |= <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ; } else { forwardRelays &= ~ ( <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ) ; } m_fpgaDIO . writeSlowValue_RelayFwd ( forwardRelays ) ; } } public void setRelayReverse ( final int channel , final boolean on ) { SensorBase . checkRelayChannel ( channel ) ; synchronized ( syncRoot ) { int reverseRelays = m_fpgaDIO . readSlowValue_RelayRev ( ) ; if ( on ) { reverseRelays |= <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ; } else { reverseRelays &= ~ ( <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ) ; } m_fpgaDIO . writeSlowValue_RelayRev ( reverseRelays ) ; } } public boolean getRelayForward ( int channel ) { int forwardRelays = m_fpgaDIO . readSlowValue_RelayFwd ( ) ; return ( forwardRelays & ( <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ) ) != <NUM_LIT:0> ; } public byte getRelayForward ( ) { return ( byte ) m_fpgaDIO . readSlowValue_RelayFwd ( ) ; } public boolean getRelayReverse ( int channel ) { int reverseRelays = m_fpgaDIO . readSlowValue_RelayRev ( ) ; return ( reverseRelays & ( <NUM_LIT:1> << ( channel - <NUM_LIT:1> ) ) ) != <NUM_LIT:0> ; } public byte getRelayReverse ( ) { return ( byte ) m_fpgaDIO . readSlowValue_RelayRev ( ) ; } public boolean allocateDIO ( final int channel , final boolean input ) { try { DIOChannels . allocate ( ( kDigitalChannels * slotToIndex ( m_slot ) + channel - <NUM_LIT:1> ) ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + channel + "<STR_LIT>" + m_slot + "<STR_LIT>" ) ; } final int outputEnable = m_fpgaDIO . readOutputEnable ( ) ; final int bitToSet = <NUM_LIT:1> << ( DigitalModule . remapDigitalChannel ( ( channel - <NUM_LIT:1> ) ) ) ; short outputEnableValue ; if ( input ) { outputEnableValue = ( short ) ( outputEnable & ( ~ bitToSet ) ) ; } else { outputEnableValue = ( short ) ( outputEnable | bitToSet ) ; } m_fpgaDIO . writeOutputEnable ( outputEnableValue ) ; return true ; } public void freeDIO ( final int channel ) { DIOChannels . free ( ( kDigitalChannels * slotToIndex ( m_slot ) + channel - <NUM_LIT:1> ) ) ; } public void setDIO ( final int channel , final boolean value ) { int currentDIO = m_fpgaDIO . readDO ( ) ; if ( value ) { currentDIO = ( currentDIO & ~ ( <NUM_LIT:1> << DigitalModule . remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ) ; } else { currentDIO = ( currentDIO | ( <NUM_LIT:1> << DigitalModule . remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ) ; } m_fpgaDIO . writeDO ( currentDIO ) ; } public boolean getDIO ( final int channel ) { final int currentDIO = m_fpgaDIO . readDI ( ) ; return ( ( currentDIO > > remapDigitalChannel ( channel - <NUM_LIT:1> ) ) & <NUM_LIT:1> ) == <NUM_LIT:1> ; } public short getAllDIO ( ) { return ( short ) m_fpgaDIO . readDI ( ) ; } public boolean getDIODirection ( int channel ) { int currentOutputEnable = m_fpgaDIO . readOutputEnable ( ) ; return ( ( currentOutputEnable > > remapDigitalChannel ( channel - <NUM_LIT:1> ) ) & <NUM_LIT:1> ) != <NUM_LIT:0> ; } public short getDIODirection ( ) { return ( short ) m_fpgaDIO . readOutputEnable ( ) ; } public void pulse ( final int channel , final int pulseLength ) { final short mask = ( short ) ( <NUM_LIT:1> << remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ; m_fpgaDIO . writePulseLength ( pulseLength ) ; m_fpgaDIO . writePulse ( mask ) ; } public boolean isPulsing ( final int channel ) { final int mask = <NUM_LIT:1> << remapDigitalChannel ( channel - <NUM_LIT:1> ) ; final int pulseRegister = m_fpgaDIO . readPulse ( ) ; return ( pulseRegister & mask ) != <NUM_LIT:0> ; } public boolean isPulsing ( ) { final int pulseRegister = m_fpgaDIO . readPulse ( ) ; return pulseRegister != <NUM_LIT:0> ; } public int allocateDO_PWM ( ) { try { return DO_PWMGenerators [ slotToIndex ( m_slot ) ] . allocate ( ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + m_slot + "<STR_LIT>" ) ; } } public void freeDO_PWM ( int pwmGenerator ) { if ( pwmGenerator == ~ <NUM_LIT:0> ) return ; DO_PWMGenerators [ slotToIndex ( m_slot ) ] . free ( pwmGenerator ) ; } public void setDO_PWMRate ( double rate ) { byte pwmPeriodPower = ( byte ) ( MathUtils . log ( <NUM_LIT:1.0> / ( m_fpgaDIO . readLoopTiming ( ) * <NUM_LIT> * rate ) ) / MathUtils . log ( <NUM_LIT> ) + <NUM_LIT> ) ; m_fpgaDIO . writeDO_PWMConfig_PeriodPower ( pwmPeriodPower ) ; } public void setDO_PWMOutputChannel ( int pwmGenerator , int channel ) { if ( pwmGenerator == ~ <NUM_LIT:0> ) return ; switch ( pwmGenerator ) { case <NUM_LIT:0> : m_fpgaDIO . writeDO_PWMConfig_OutputSelect_0 ( remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ; break ; case <NUM_LIT:1> : m_fpgaDIO . writeDO_PWMConfig_OutputSelect_1 ( remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ; break ; case <NUM_LIT:2> : m_fpgaDIO . writeDO_PWMConfig_OutputSelect_2 ( remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ; break ; case <NUM_LIT:3> : m_fpgaDIO . writeDO_PWMConfig_OutputSelect_3 ( remapDigitalChannel ( channel - <NUM_LIT:1> ) ) ; break ; } } public void setDO_PWMDutyCycle ( int pwmGenerator , double dutyCycle ) { if ( pwmGenerator == ~ <NUM_LIT:0> ) return ; if ( dutyCycle > <NUM_LIT:1.0> ) { dutyCycle = <NUM_LIT:1.0> ; } if ( dutyCycle < <NUM_LIT:0.0> ) { dutyCycle = <NUM_LIT:0.0> ; } double rawDutyCycle = <NUM_LIT> * dutyCycle ; if ( rawDutyCycle > <NUM_LIT> ) { rawDutyCycle = <NUM_LIT> ; } byte pwmPeriodPower = m_fpgaDIO . readDO_PWMConfig_PeriodPower ( ) ; if ( pwmPeriodPower < <NUM_LIT:4> ) { rawDutyCycle = rawDutyCycle / MathUtils . pow ( <NUM_LIT> , <NUM_LIT:4> - pwmPeriodPower ) ; } m_fpgaDIO . writeDO_PWMDutyCycle ( pwmGenerator , ( byte ) rawDutyCycle ) ; } public I2C getI2C ( final int address ) { return new I2C ( this , address ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public interface PIDSource { public double pidGet ( ) ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tInterrupt ; import edu . wpi . first . wpilibj . fpga . tInterruptManager ; public abstract class InterruptableSensorBase extends SensorBase { protected tInterrupt m_interrupt ; protected tInterruptManager m_manager ; protected int m_interruptIndex ; protected static Resource interrupts = new Resource ( <NUM_LIT:8> ) ; public InterruptableSensorBase ( ) { m_manager = null ; m_interrupt = null ; } public void allocateInterrupts ( boolean watcher ) { if ( ! watcher ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } m_interrupt = new tInterrupt ( ( byte ) m_interruptIndex ) ; m_interrupt . writeConfig_WaitForAck ( false ) ; m_manager = new tInterruptManager ( <NUM_LIT:1> << m_interruptIndex , watcher ) ; } public void cancelInterrupts ( ) { if ( m_interrupt == null || m_manager == null ) { throw new IllegalStateException ( ) ; } m_interrupt . Release ( ) ; m_interrupt = null ; m_manager . Release ( ) ; m_manager = null ; } public void waitForInterrupt ( double timeout ) { m_manager . watch ( ( int ) ( timeout * <NUM_LIT> ) ) ; } public void enableInterrupts ( ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } public void disableInterrupts ( ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } public double readInterruptTimestamp ( ) { return m_interrupt . readTimeStamp ( ) * <NUM_LIT> ; } } </s>
|
<s> package edu . wpi . first . wpilibj . util ; import java . util . Vector ; public class SortedVector extends Vector { public static interface Comparator { public int compare ( Object object1 , Object object2 ) ; } Comparator comparator ; public SortedVector ( Comparator comparator ) { this . comparator = comparator ; } public void addElement ( Object element ) { int highBound = size ( ) ; int lowBound = <NUM_LIT:0> ; while ( highBound - lowBound > <NUM_LIT:0> ) { int index = ( highBound + lowBound ) / <NUM_LIT:2> ; int result = comparator . compare ( element , elementAt ( index ) ) ; if ( result < <NUM_LIT:0> ) { lowBound = index + <NUM_LIT:1> ; } else if ( result > <NUM_LIT:0> ) { highBound = index ; } else { lowBound = index ; highBound = index ; } } insertElementAt ( element , lowBound ) ; } public void sort ( ) { Object [ ] array = new Object [ size ( ) ] ; copyInto ( array ) ; removeAllElements ( ) ; for ( int i = <NUM_LIT:0> ; i < array . length ; i ++ ) { addElement ( array [ i ] ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj . util ; public class AllocationException extends RuntimeException { public AllocationException ( String msg ) { super ( msg ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . util ; public class CheckedAllocationException extends Exception { public CheckedAllocationException ( String msg ) { super ( msg ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . util ; public class BoundaryException extends RuntimeException { public BoundaryException ( String message ) { super ( message ) ; } public static void assertWithinBounds ( double value , double lower , double upper ) { if ( value < lower || value > upper ) throw new BoundaryException ( "<STR_LIT>" + lower + "<STR_LIT:U+0020andU+0020>" + upper + "<STR_LIT:U+002CU+0020>" + value + "<STR_LIT>" ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . util ; public final class UncleanStatusException extends IllegalStateException { private final int statusCode ; public UncleanStatusException ( int status , String message ) { super ( message ) ; statusCode = status ; } public UncleanStatusException ( int status ) { this ( status , "<STR_LIT>" ) ; } public UncleanStatusException ( String message ) { this ( - <NUM_LIT:1> , message ) ; } public UncleanStatusException ( ) { this ( - <NUM_LIT:1> , "<STR_LIT>" ) ; } public int getStatus ( ) { return statusCode ; } } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface IInputOutput extends IDevice { } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface ISensor extends IDevice { } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface IDevice { } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface IMechanism { } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface IDeviceController extends IDevice { } </s>
|
<s> package edu . wpi . first . wpilibj . parsing ; public interface IUtility extends IDevice { } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; import java . util . Stack ; public class Dashboard implements IDashboard , IInputOutput { protected class MemAccess { byte [ ] m_bytes ; protected MemAccess ( byte [ ] bytes ) { m_bytes = bytes ; } protected MemAccess ( int length ) { m_bytes = new byte [ length ] ; } public void setByte ( int index , byte value ) { m_bytes [ index ] = value ; } public void setShort ( int index , short value ) { setByte ( index ++ , ( byte ) ( value > > > <NUM_LIT:8> ) ) ; setByte ( index ++ , ( byte ) ( value ) ) ; } public void setInt ( int index , int value ) { setByte ( index ++ , ( byte ) ( value > > > <NUM_LIT:24> ) ) ; setByte ( index ++ , ( byte ) ( value > > > <NUM_LIT:16> ) ) ; setByte ( index ++ , ( byte ) ( value > > > <NUM_LIT:8> ) ) ; setByte ( index ++ , ( byte ) ( value ) ) ; } public void setFloat ( int index , float value ) { setInt ( index , Float . floatToIntBits ( value ) ) ; } public void setDouble ( int index , double value ) { setInt ( index , ( int ) ( Double . doubleToLongBits ( value ) > > > <NUM_LIT:32> ) ) ; setInt ( index + <NUM_LIT:4> , ( int ) Double . doubleToLongBits ( value ) ) ; } public void setString ( int index , String value ) { setBytes ( index , value . getBytes ( ) , <NUM_LIT:0> , value . length ( ) ) ; } public void setBytes ( int index , byte [ ] value , int offset , int number ) { for ( int i = <NUM_LIT:0> ; i < number ; i ++ ) { m_bytes [ i + index ] = value [ i + offset ] ; } } } private static final String kArray = "<STR_LIT>" ; private static final String kCluster = "<STR_LIT>" ; private static final Integer kByte = new Integer ( <NUM_LIT:0> ) ; private static final Integer kShort = new Integer ( <NUM_LIT:1> ) ; private static final Integer kInt = new Integer ( <NUM_LIT:2> ) ; private static final Integer kFloat = new Integer ( <NUM_LIT:3> ) ; private static final Integer kDouble = new Integer ( <NUM_LIT:4> ) ; private static final Integer kString = new Integer ( <NUM_LIT:5> ) ; private static final Integer kOther = new Integer ( <NUM_LIT:6> ) ; private static final Integer kBoolean = new Integer ( <NUM_LIT:7> ) ; private static final int kMaxDashboardDataSize = DriverStation . USER_STATUS_DATA_SIZE - <NUM_LIT:4> * <NUM_LIT:3> - <NUM_LIT:1> ; protected MemAccess m_userStatus ; protected int m_userStatusSize = <NUM_LIT:0> ; private MemAccess m_localBuffer ; private int m_packPtr ; private Stack m_expectedArrayElementType = new Stack ( ) ; private Stack m_arrayElementCount = new Stack ( ) ; private Stack m_arraySizePtr = new Stack ( ) ; private Stack m_complexTypeStack = new Stack ( ) ; private final Object m_statusDataSemaphore ; protected Dashboard ( Object statusDataSemaphore ) { m_userStatus = new MemAccess ( kMaxDashboardDataSize ) ; m_localBuffer = new MemAccess ( kMaxDashboardDataSize ) ; m_packPtr = <NUM_LIT:0> ; m_statusDataSemaphore = statusDataSemaphore ; } public boolean addByte ( byte value ) { if ( ! validateAdd ( <NUM_LIT:1> ) ) { return false ; } m_localBuffer . setByte ( m_packPtr , value ) ; m_packPtr += <NUM_LIT:1> ; return addedElement ( kByte ) ; } public boolean addShort ( short value ) { if ( ! validateAdd ( <NUM_LIT:2> ) ) { return false ; } m_localBuffer . setShort ( m_packPtr , value ) ; m_packPtr += <NUM_LIT:2> ; return addedElement ( kShort ) ; } public boolean addInt ( int value ) { if ( ! validateAdd ( <NUM_LIT:4> ) ) { return false ; } m_localBuffer . setInt ( m_packPtr , value ) ; m_packPtr += <NUM_LIT:4> ; return addedElement ( kInt ) ; } public boolean addFloat ( float value ) { if ( ! validateAdd ( <NUM_LIT:4> ) ) { return false ; } m_localBuffer . setFloat ( m_packPtr , value ) ; m_packPtr += <NUM_LIT:4> ; return addedElement ( kFloat ) ; } public boolean addDouble ( double value ) { if ( ! validateAdd ( <NUM_LIT:8> ) ) { return false ; } m_localBuffer . setDouble ( m_packPtr , value ) ; m_packPtr += <NUM_LIT:8> ; return addedElement ( kDouble ) ; } public boolean addBoolean ( boolean value ) { if ( ! validateAdd ( <NUM_LIT:1> ) ) { return false ; } m_localBuffer . setByte ( m_packPtr , ( byte ) ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) ) ; m_packPtr += <NUM_LIT:1> ; return addedElement ( kBoolean ) ; } public boolean addString ( String value ) { if ( ! validateAdd ( value . length ( ) + <NUM_LIT:4> ) ) { return false ; } m_localBuffer . setInt ( m_packPtr , value . length ( ) ) ; m_packPtr += <NUM_LIT:4> ; m_localBuffer . setString ( m_packPtr , value ) ; m_packPtr += value . length ( ) ; return addedElement ( kString ) ; } public boolean addString ( String value , int length ) { return addString ( value . substring ( <NUM_LIT:0> , length ) ) ; } public boolean addArray ( ) { if ( ! validateAdd ( <NUM_LIT:4> ) ) { return false ; } m_complexTypeStack . push ( kArray ) ; m_arrayElementCount . push ( new Integer ( <NUM_LIT:0> ) ) ; m_arraySizePtr . push ( new Integer ( m_packPtr ) ) ; m_packPtr += <NUM_LIT:4> ; return true ; } public boolean finalizeArray ( ) { if ( m_complexTypeStack . peek ( ) != kArray ) { System . err . println ( "<STR_LIT>" ) ; return false ; } m_complexTypeStack . pop ( ) ; m_localBuffer . setInt ( ( ( Integer ) m_arraySizePtr . pop ( ) ) . intValue ( ) , ( ( Integer ) m_arrayElementCount . peek ( ) ) . intValue ( ) ) ; if ( ( ( Integer ) m_arrayElementCount . peek ( ) ) . intValue ( ) != <NUM_LIT:0> ) { m_expectedArrayElementType . pop ( ) ; } m_arrayElementCount . pop ( ) ; return addedElement ( kOther ) ; } public boolean addCluster ( ) { m_complexTypeStack . push ( kCluster ) ; return true ; } public boolean finalizeCluster ( ) { if ( m_complexTypeStack . peek ( ) != kCluster ) { System . err . println ( "<STR_LIT>" ) ; return false ; } m_complexTypeStack . pop ( ) ; return addedElement ( kOther ) ; } public synchronized int commit ( ) { if ( ! m_complexTypeStack . empty ( ) ) { System . err . println ( "<STR_LIT>" ) ; m_packPtr = <NUM_LIT:0> ; System . err . println ( "<STR_LIT>" ) ; return <NUM_LIT:0> ; } synchronized ( m_statusDataSemaphore ) { DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; m_userStatusSize = m_packPtr ; m_userStatus . setBytes ( <NUM_LIT:0> , m_localBuffer . m_bytes , <NUM_LIT:0> , m_userStatusSize ) ; m_packPtr = <NUM_LIT:0> ; } return m_userStatusSize ; } private boolean validateAdd ( int size ) { if ( m_packPtr + size > kMaxDashboardDataSize ) { m_packPtr = <NUM_LIT:0> ; System . err . println ( "<STR_LIT>" ) ; return false ; } return true ; } private boolean addedElement ( Integer type ) { if ( isArrayRoot ( ) ) { if ( ( ( Integer ) m_arrayElementCount . peek ( ) ) . intValue ( ) == <NUM_LIT:0> ) { m_expectedArrayElementType . push ( type ) ; } else { if ( type != m_expectedArrayElementType . peek ( ) ) { System . err . println ( "<STR_LIT>" ) ; return false ; } } m_arrayElementCount . push ( new Integer ( ( ( Integer ) m_arrayElementCount . pop ( ) ) . intValue ( ) + <NUM_LIT:1> ) ) ; } return true ; } private boolean isArrayRoot ( ) { return ! m_complexTypeStack . empty ( ) && m_complexTypeStack . peek ( ) == kArray ; } public byte [ ] getBytes ( ) { return m_userStatus . m_bytes ; } public int getBytesLength ( ) { return m_userStatusSize ; } public void flush ( ) { } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class SimpleRobot extends RobotBase { private boolean m_robotMainOverridden ; public SimpleRobot ( ) { super ( ) ; m_robotMainOverridden = true ; } protected void robotInit ( ) { System . out . println ( "<STR_LIT>" ) ; } protected void disabled ( ) { System . out . println ( "<STR_LIT>" ) ; } public void autonomous ( ) { System . out . println ( "<STR_LIT>" ) ; } public void operatorControl ( ) { System . out . println ( "<STR_LIT>" ) ; } public void robotMain ( ) { m_robotMainOverridden = false ; } public void startCompetition ( ) { robotMain ( ) ; if ( ! m_robotMainOverridden ) { robotInit ( ) ; while ( true ) { if ( isDisabled ( ) ) { disabled ( ) ; while ( isDisabled ( ) ) { Timer . delay ( <NUM_LIT> ) ; } } else if ( isAutonomous ( ) ) { autonomous ( ) ; while ( isAutonomous ( ) && ! isDisabled ( ) ) { Timer . delay ( <NUM_LIT> ) ; } } else { operatorControl ( ) ; while ( isOperatorControl ( ) && ! isDisabled ( ) ) { Timer . delay ( <NUM_LIT> ) ; } } } } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . ISensor ; public class HiTechnicCompass extends SensorBase implements ISensor { public class CompassException extends RuntimeException { public CompassException ( String message ) { super ( message ) ; } } private static final byte kAddress = <NUM_LIT> ; private static final byte kManufacturerBaseRegister = <NUM_LIT> ; private static final byte kManufacturerSize = <NUM_LIT> ; private static final byte kSensorTypeBaseRegister = <NUM_LIT> ; private static final byte kSensorTypeSize = <NUM_LIT> ; private static final byte kHeadingRegister = <NUM_LIT> ; private I2C m_i2c ; public HiTechnicCompass ( int slot ) { DigitalModule module = DigitalModule . getInstance ( slot ) ; m_i2c = module . getI2C ( kAddress ) ; final byte [ ] kExpectedManufacturer = "<STR_LIT>" . getBytes ( ) ; final byte [ ] kExpectedSensorType = "<STR_LIT>" . getBytes ( ) ; if ( ! m_i2c . verifySensor ( kManufacturerBaseRegister , kManufacturerSize , kExpectedManufacturer ) ) { throw new CompassException ( "<STR_LIT>" ) ; } if ( ! m_i2c . verifySensor ( kSensorTypeBaseRegister , kSensorTypeSize , kExpectedSensorType ) ) { throw new CompassException ( "<STR_LIT>" ) ; } } protected void free ( ) { if ( m_i2c != null ) { m_i2c . free ( ) ; } m_i2c = null ; } public double getAngle ( ) { byte [ ] heading = new byte [ <NUM_LIT:2> ] ; m_i2c . read ( kHeadingRegister , ( byte ) heading . length , heading ) ; return ( ( int ) heading [ <NUM_LIT:1> ] + ( int ) heading [ <NUM_LIT:2> ] * ( int ) ( <NUM_LIT:1> << <NUM_LIT:8> ) ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tAnalogTrigger ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; public class AnalogTriggerOutput extends DigitalSource implements IInputOutput { public class AnalogTriggerOutputException extends RuntimeException { public AnalogTriggerOutputException ( String message ) { super ( message ) ; } } public static class Type { public final int value ; static final int kInWindow_val = <NUM_LIT:0> ; static final int kTypeState_val = <NUM_LIT:1> ; static final int kRisingPulse_val = <NUM_LIT:2> ; static final int kFallingPulse_val = <NUM_LIT:3> ; public static final Type kInWindow = new Type ( kInWindow_val ) ; public static final Type kTypeState = new Type ( kTypeState_val ) ; public static final Type kRisingPulse = new Type ( kRisingPulse_val ) ; public static final Type kFallingPulse = new Type ( kFallingPulse_val ) ; private Type ( int value ) { this . value = value ; } } private AnalogTrigger m_trigger ; private Type m_outputType ; public AnalogTriggerOutput ( AnalogTrigger trigger , final Type outputType ) { if ( trigger == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_trigger = trigger ; m_outputType = outputType ; } protected void free ( ) { } public boolean get ( ) { switch ( m_outputType . value ) { case Type . kInWindow_val : return tAnalogTrigger . readOutput_InHysteresis ( ( byte ) m_trigger . m_index ) ; case Type . kTypeState_val : return tAnalogTrigger . readOutput_OverLimit ( ( byte ) m_trigger . m_index ) ; case Type . kRisingPulse_val : case Type . kFallingPulse_val : throw new AnalogTriggerOutputException ( "<STR_LIT>" ) ; } return false ; } public int getChannelForRouting ( ) { return ( m_trigger . m_index << <NUM_LIT:2> ) + m_outputType . value ; } public int getModuleForRouting ( ) { return m_trigger . m_index > > <NUM_LIT:2> ; } public boolean getAnalogTriggerForRouting ( ) { return true ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tAnalogTrigger ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . BoundaryException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class AnalogTrigger implements IInputOutput { public class AnalogTriggerException extends RuntimeException { public AnalogTriggerException ( String message ) { super ( message ) ; } } private static Resource triggers = new Resource ( tAnalogTrigger . kNumSystems ) ; protected int m_index ; private tAnalogTrigger m_trigger ; private AnalogModule m_analogModule ; private int m_channel ; protected void initTrigger ( final int slot , final int channel ) { m_channel = channel ; m_analogModule = AnalogModule . getInstance ( slot ) ; try { m_index = triggers . allocate ( ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" ) ; } m_trigger = new tAnalogTrigger ( ( byte ) m_index ) ; m_trigger . writeSourceSelect_Channel ( ( byte ) ( m_channel - <NUM_LIT:1> ) ) ; m_trigger . writeSourceSelect_Module ( ( byte ) AnalogModule . slotToIndex ( ( byte ) slot ) ) ; } public AnalogTrigger ( final int channel ) { initTrigger ( AnalogModule . getDefaultAnalogModule ( ) , channel ) ; } public AnalogTrigger ( final int slot , final int channel ) { initTrigger ( slot , channel ) ; } public AnalogTrigger ( AnalogChannel channel ) { initTrigger ( channel . getSlot ( ) , channel . getChannel ( ) ) ; } protected void free ( ) { triggers . free ( m_index ) ; m_trigger . Release ( ) ; m_trigger = null ; } public void setLimitsRaw ( final int lower , final int upper ) { if ( lower > upper ) { throw new BoundaryException ( "<STR_LIT>" ) ; } m_trigger . writeLowerLimit ( lower ) ; m_trigger . writeUpperLimit ( upper ) ; } public void setLimitsVoltage ( double lower , double upper ) { if ( lower > upper ) { throw new BoundaryException ( "<STR_LIT>" ) ; } m_trigger . writeLowerLimit ( m_analogModule . voltsToValue ( m_channel , lower ) ) ; m_trigger . writeUpperLimit ( m_analogModule . voltsToValue ( m_channel , upper ) ) ; } public void setAveraged ( boolean useAveragedValue ) { if ( m_trigger . readSourceSelect_Filter ( ) && useAveragedValue ) { throw new AnalogTriggerException ( "<STR_LIT>" ) ; } m_trigger . writeSourceSelect_Averaged ( useAveragedValue ) ; } public void setFiltered ( boolean useFilteredValue ) { if ( m_trigger . readSourceSelect_Averaged ( ) && useFilteredValue ) { throw new AnalogTriggerException ( "<STR_LIT>" ) ; } m_trigger . writeSourceSelect_Filter ( useFilteredValue ) ; } public int getIndex ( ) { return m_index ; } public boolean getInWindow ( ) { return tAnalogTrigger . readOutput_InHysteresis ( ( byte ) m_index ) ; } public boolean getTriggerState ( ) { return tAnalogTrigger . readOutput_OverLimit ( ( byte ) m_index ) ; } AnalogTriggerOutput createOutput ( AnalogTriggerOutput . Type type ) { return new AnalogTriggerOutput ( this , type ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IUtility ; public class Timer implements IUtility { private long m_startTime ; private double m_accumulatedTime ; private boolean m_running ; public static void delay ( final double seconds ) { try { Thread . sleep ( ( long ) ( seconds * <NUM_LIT> ) ) ; } catch ( final InterruptedException e ) { } } public static long getUsClock ( ) { return Utility . getFPGATime ( ) ; } static long getMsClock ( ) { return getUsClock ( ) / <NUM_LIT:1000> ; } public static double getFPGATimestamp ( ) { return Utility . getFPGATime ( ) / <NUM_LIT> ; } public Timer ( ) { reset ( ) ; } public synchronized double get ( ) { if ( m_running ) { return ( ( double ) ( ( getMsClock ( ) - m_startTime ) + m_accumulatedTime ) ) / <NUM_LIT> ; } else { return m_accumulatedTime ; } } public synchronized void reset ( ) { m_accumulatedTime = <NUM_LIT:0> ; m_startTime = getMsClock ( ) ; } public synchronized void start ( ) { m_startTime = getMsClock ( ) ; m_running = true ; } public synchronized void stop ( ) { final double temp = get ( ) ; m_accumulatedTime += temp ; m_running = false ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . ISensor ; public class Accelerometer extends SensorBase implements PIDSource , ISensor { private AnalogChannel m_analogChannel ; private double m_voltsPerG = <NUM_LIT:1.0> ; private double m_zeroGVoltage = <NUM_LIT> ; private boolean m_allocatedChannel ; public Accelerometer ( final int channel ) { m_allocatedChannel = true ; m_analogChannel = new AnalogChannel ( channel ) ; } public Accelerometer ( final int slot , final int channel ) { m_allocatedChannel = true ; m_analogChannel = new AnalogChannel ( slot , channel ) ; } public Accelerometer ( AnalogChannel channel ) { m_allocatedChannel = false ; if ( channel == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_analogChannel = channel ; } protected void free ( ) { if ( m_analogChannel != null && m_allocatedChannel ) { m_analogChannel . free ( ) ; } m_analogChannel = null ; } public double getAcceleration ( ) { return ( m_analogChannel . getAverageVoltage ( ) - m_zeroGVoltage ) / m_voltsPerG ; } public void setSensitivity ( double sensitivity ) { m_voltsPerG = sensitivity ; } public void setZero ( double zero ) { m_zeroGVoltage = zero ; } public double pidGet ( ) { return getAcceleration ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import java . io . ByteArrayOutputStream ; import java . io . DataOutputStream ; import java . io . IOException ; import java . util . Enumeration ; import java . util . Hashtable ; public class SmartDashboard implements IDashboard { public static final int MAX_FIELDS = <NUM_LIT> ; public static final int BUFFER_SIZE = <NUM_LIT> ; public static final int SUCCESS = <NUM_LIT:0> ; public static final int ERROR_BUFFER_FULL = - <NUM_LIT:1> ; public static final int ERROR_TYPE_MISMATCH = - <NUM_LIT:2> ; public static final int ERROR_TOO_MANY_FIELDS = - <NUM_LIT:3> ; public static final int ERROR_STRING_TOO_LONG = - <NUM_LIT:4> ; protected static final byte BYTE_TYPE = <NUM_LIT:0> ; protected static final byte CHAR_TYPE = <NUM_LIT:1> ; protected static final byte INT_TYPE = <NUM_LIT:2> ; protected static final byte LONG_TYPE = <NUM_LIT:3> ; protected static final byte SHORT_TYPE = <NUM_LIT:4> ; protected static final byte FLOAT_TYPE = <NUM_LIT:5> ; protected static final byte DOUBLE_TYPE = <NUM_LIT:6> ; protected static final byte STRING_UTF16_TYPE = <NUM_LIT:7> ; protected static final byte BOOL_TYPE = <NUM_LIT:8> ; protected static final byte STRING_UTF8_TYPE = <NUM_LIT:9> ; protected static final int REANNOUNCEMENT_INTERVAL_MS = <NUM_LIT> ; protected final static Hashtable field_types = new Hashtable ( ) ; protected final static Hashtable field_ids = new Hashtable ( ) ; private static SmartDashboard instance = null ; private static boolean initialized = false ; protected final Object m_monitor ; private ByteArrayOutputStream m_byteBuffer ; private DataOutputStream m_dataOutput ; private long m_nextReannouncementTime ; private boolean m_blockingIO = false ; private SmartDashboard ( Object monitor ) { m_monitor = monitor ; m_byteBuffer = new ByteArrayOutputStream ( BUFFER_SIZE ) ; m_dataOutput = new DataOutputStream ( m_byteBuffer ) ; m_nextReannouncementTime = Timer . getMsClock ( ) + REANNOUNCEMENT_INTERVAL_MS ; } public static void init ( ) { field_types . clear ( ) ; field_ids . clear ( ) ; instance = new SmartDashboard ( DriverStation . getInstance ( ) . getStatusDataMonitor ( ) ) ; DriverStation . getInstance ( ) . setDashboardPackerToUseHigh ( getInstance ( ) ) ; initialized = true ; } public static int log ( byte value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( BYTE_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:1> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeByte ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( char value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( CHAR_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:2> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeChar ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( int value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( INT_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:4> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeInt ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( long value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( LONG_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:8> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeLong ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( short value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( SHORT_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:2> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeShort ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( float value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( dash . announceIfNewField ( FLOAT_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:4> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeFloat ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( double value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( DOUBLE_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:8> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeDouble ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } static int utfLength ( String s ) { int sLength = s . length ( ) ; int utfLength = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < sLength ; ++ i ) { char c = s . charAt ( i ) ; if ( c == <NUM_LIT:0> || c >= <NUM_LIT> ) ++ utfLength ; ++ utfLength ; } return utfLength ; } public static int log ( String value , String name ) { int dataLen = utfLength ( value ) + <NUM_LIT:2> ; if ( dataLen > <NUM_LIT> ) return ERROR_STRING_TOO_LONG ; if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( STRING_UTF8_TYPE , name ) ) != SUCCESS ) return retcode ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( ( byte ) dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , ( byte ) dataLen ) ; dash . m_dataOutput . writeUTF ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int log ( boolean value , String name ) { if ( ! initialized ) init ( ) ; int retcode = SUCCESS ; SmartDashboard dash = getInstance ( ) ; synchronized ( dash . m_monitor ) { try { if ( ( retcode = dash . announceIfNewField ( BOOL_TYPE , name ) ) != SUCCESS ) return retcode ; byte dataLen = <NUM_LIT:1> ; if ( dash . checkBufferFull ( SmartDashboardPacketFactory . getUpdateLength ( dataLen ) ) ) return ERROR_BUFFER_FULL ; dash . fieldUpdatePrefix ( name , dataLen ) ; dash . m_dataOutput . writeBoolean ( value ) ; dash . periodicallyReannounce ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } DriverStation . getInstance ( ) . incrementUpdateNumber ( ) ; } return retcode ; } public static int useProfile ( String name ) { if ( ! initialized ) init ( ) ; synchronized ( getInstance ( ) . m_monitor ) { try { if ( getInstance ( ) . checkBufferFull ( SmartDashboardPacketFactory . getAnnounceProfileLength ( name ) ) ) return ERROR_BUFFER_FULL ; SmartDashboardPacketFactory . announceProfile ( getInstance ( ) . m_dataOutput , name ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return ERROR_BUFFER_FULL ; } } return SUCCESS ; } public static String diagnoseErrorCode ( int code ) { switch ( code ) { case SUCCESS : return "<STR_LIT>" ; case ERROR_BUFFER_FULL : return "<STR_LIT>" + "<STR_LIT>" ; case ERROR_TOO_MANY_FIELDS : return "<STR_LIT>" + "<STR_LIT>" + MAX_FIELDS + "<STR_LIT:.>" ; case ERROR_TYPE_MISMATCH : return "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; default : return "<STR_LIT>" + code ; } } public static void useBlockingIO ( boolean value ) { getInstance ( ) . m_blockingIO = value ; } private int announceIfNewField ( byte type , String name ) throws IOException { if ( checkBufferFull ( SmartDashboardPacketFactory . getAnnounceLength ( name ) ) ) return ERROR_BUFFER_FULL ; if ( ! field_ids . containsKey ( name ) ) { if ( field_ids . size ( ) >= MAX_FIELDS ) return ERROR_TOO_MANY_FIELDS ; field_ids . put ( name , new Byte ( ( byte ) field_ids . size ( ) ) ) ; field_types . put ( name , new Byte ( type ) ) ; SmartDashboardPacketFactory . announce ( m_dataOutput , name , type , ( ( Byte ) field_ids . get ( name ) ) . byteValue ( ) ) ; } else { if ( ( ( Byte ) field_types . get ( name ) ) . byteValue ( ) != type ) { return ERROR_TYPE_MISMATCH ; } } return SUCCESS ; } private void periodicallyReannounce ( ) throws IOException { if ( Timer . getMsClock ( ) >= m_nextReannouncementTime ) { Enumeration e = field_ids . keys ( ) ; while ( e . hasMoreElements ( ) ) { String name = ( String ) e . nextElement ( ) ; byte id = ( ( Byte ) field_ids . get ( name ) ) . byteValue ( ) ; byte type = ( ( Byte ) field_types . get ( name ) ) . byteValue ( ) ; if ( ! checkBufferFull ( SmartDashboardPacketFactory . getAnnounceLength ( name ) ) ) SmartDashboardPacketFactory . announce ( m_dataOutput , name , type , id ) ; } m_nextReannouncementTime += REANNOUNCEMENT_INTERVAL_MS ; } } private void fieldUpdatePrefix ( String name , byte len ) throws IOException { SmartDashboardPacketFactory . updatePrefix ( m_dataOutput , ( ( Byte ) field_ids . get ( name ) ) . byteValue ( ) , len ) ; } private boolean checkBufferFull ( int requestedBytes ) { synchronized ( m_monitor ) { while ( ( m_byteBuffer . size ( ) + requestedBytes ) > BUFFER_SIZE ) { if ( ! m_blockingIO ) return true ; try { m_monitor . wait ( ) ; } catch ( InterruptedException ex ) { } } } return false ; } private static SmartDashboard getInstance ( ) { return instance ; } public byte [ ] getBytes ( ) { synchronized ( m_monitor ) { return m_byteBuffer . toByteArray ( ) ; } } public int getBytesLength ( ) { synchronized ( m_monitor ) { return m_byteBuffer . size ( ) ; } } public void flush ( ) { synchronized ( m_monitor ) { m_byteBuffer . reset ( ) ; m_monitor . notifyAll ( ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import java . io . DataOutputStream ; import java . io . IOException ; import java . io . OutputStream ; public class SmartDashboardPacketFactory { private static final byte ANNOUNCE_TYPE = <NUM_LIT:0> ; private static final byte UPDATE_TYPE = <NUM_LIT:1> ; private static final byte ANNOUNCE_PROFILE_TYPE = <NUM_LIT:2> ; public static void announce ( DataOutputStream s , String name , byte type , byte id ) throws IOException { s . writeByte ( ANNOUNCE_TYPE ) ; s . writeByte ( id ) ; s . writeByte ( type ) ; s . writeUTF ( name ) ; } public static int getAnnounceLength ( String name ) { return <NUM_LIT:5> + SmartDashboard . utfLength ( name ) ; } public static void updatePrefix ( DataOutputStream s , byte id , byte length ) throws IOException { s . writeByte ( UPDATE_TYPE ) ; s . writeByte ( id ) ; s . writeByte ( length ) ; } public static int getUpdateLength ( int dataLen ) { return <NUM_LIT:3> + dataLen ; } public static void announceProfile ( DataOutputStream s , String name ) throws IOException { s . writeByte ( ANNOUNCE_PROFILE_TYPE ) ; s . writeUTF ( name ) ; } public static int getAnnounceProfileLength ( String name ) { return <NUM_LIT:3> + SmartDashboard . utfLength ( name ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tCounter ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class Counter extends SensorBase implements CounterBase { public static class Mode { public final int value ; static final int kTwoPulse_val = <NUM_LIT:0> ; static final int kSemiperiod_val = <NUM_LIT:1> ; static final int kPulseLength_val = <NUM_LIT:2> ; static final int kExternalDirection_val = <NUM_LIT:3> ; public static final Mode kTwoPulse = new Mode ( kTwoPulse_val ) ; public static final Mode kSemiperiod = new Mode ( kSemiperiod_val ) ; public static final Mode kPulseLength = new Mode ( kPulseLength_val ) ; public static final Mode kExternalDirection = new Mode ( kExternalDirection_val ) ; private Mode ( int value ) { this . value = value ; } } private DigitalSource m_upSource ; private DigitalSource m_downSource ; private boolean m_allocatedUpSource ; private boolean m_allocatedDownSource ; private tCounter m_counter ; private int m_index ; private static Resource counters = new Resource ( tCounter . kNumSystems ) ; private void initCounter ( final Mode mode ) { m_allocatedUpSource = false ; m_allocatedDownSource = false ; try { m_index = counters . allocate ( ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" ) ; } m_counter = new tCounter ( m_index ) ; m_counter . writeConfig_Mode ( mode . value ) ; m_upSource = null ; m_downSource = null ; m_counter . writeTimerConfig_AverageSize ( <NUM_LIT:1> ) ; } public Counter ( ) { initCounter ( Mode . kTwoPulse ) ; } public Counter ( DigitalSource source ) { if ( source == null ) throw new NullPointerException ( "<STR_LIT>" ) ; initCounter ( Mode . kTwoPulse ) ; setUpSource ( source ) ; } public Counter ( int channel ) { initCounter ( Mode . kTwoPulse ) ; setUpSource ( channel ) ; } public Counter ( int slot , int channel ) { initCounter ( Mode . kTwoPulse ) ; setUpSource ( slot , channel ) ; } public Counter ( EncodingType encodingType , DigitalSource upSource , DigitalSource downSource , boolean inverted ) { initCounter ( Mode . kExternalDirection ) ; if ( upSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; setUpSource ( upSource ) ; if ( downSource == null ) throw new NullPointerException ( "<STR_LIT>" ) ; setDownSource ( downSource ) ; if ( encodingType == null ) throw new NullPointerException ( "<STR_LIT>" ) ; if ( encodingType == EncodingType . k1X ) { setUpSourceEdge ( true , false ) ; } else { setUpSourceEdge ( true , true ) ; } setDownSourceEdge ( inverted , true ) ; } public Counter ( AnalogTrigger trigger ) { initCounter ( Mode . kTwoPulse ) ; setUpSource ( trigger . createOutput ( AnalogTriggerOutput . Type . kTypeState ) ) ; } protected void free ( ) { setUpdateWhenEmpty ( true ) ; clearUpSource ( ) ; clearDownSource ( ) ; m_counter . Release ( ) ; m_upSource = null ; m_downSource = null ; m_counter = null ; counters . free ( m_index ) ; } public void setUpSource ( int slot , int channel ) { m_allocatedUpSource = true ; setUpSource ( new DigitalInput ( slot , channel ) ) ; } public void setUpSource ( int channel ) { m_allocatedUpSource = true ; setUpSource ( new DigitalInput ( channel ) ) ; } public void setUpSource ( DigitalSource source ) { m_upSource = source ; m_counter . writeConfig_UpSource_Module ( source . getModuleForRouting ( ) ) ; m_counter . writeConfig_UpSource_Channel ( source . getChannelForRouting ( ) ) ; m_counter . writeConfig_UpSource_AnalogTrigger ( source . getAnalogTriggerForRouting ( ) ) ; if ( m_counter . readConfig_Mode ( ) == Mode . kTwoPulse . value || m_counter . readConfig_Mode ( ) == Mode . kExternalDirection . value ) { setUpSourceEdge ( true , false ) ; } m_counter . strobeReset ( ) ; } public void setUpSource ( AnalogTrigger analogTrigger , AnalogTriggerOutput . Type triggerType ) { m_allocatedUpSource = true ; setUpSource ( analogTrigger . createOutput ( triggerType ) ) ; } public void setUpSourceEdge ( boolean risingEdge , boolean fallingEdge ) { m_counter . writeConfig_UpRisingEdge ( risingEdge ) ; m_counter . writeConfig_UpFallingEdge ( fallingEdge ) ; } public void clearUpSource ( ) { if ( m_upSource != null && m_allocatedUpSource ) { m_upSource . free ( ) ; } m_upSource = null ; boolean state = m_counter . readConfig_Enable ( ) ; m_counter . writeConfig_Enable ( false ) ; m_counter . writeConfig_UpFallingEdge ( false ) ; m_counter . writeConfig_UpRisingEdge ( false ) ; m_counter . writeConfig_UpSource_Channel ( <NUM_LIT:0> ) ; m_counter . writeConfig_UpSource_AnalogTrigger ( false ) ; m_counter . writeConfig_Enable ( state ) ; } public void setDownSource ( int channel ) { m_allocatedDownSource = true ; setDownSource ( new DigitalInput ( channel ) ) ; } public void setDownSource ( int slot , int channel ) { m_allocatedDownSource = true ; setDownSource ( new DigitalInput ( slot , channel ) ) ; } public void setDownSource ( DigitalSource source ) { int mode = m_counter . readConfig_Mode ( ) ; m_downSource = source ; m_counter . writeConfig_DownSource_Module ( source . getModuleForRouting ( ) ) ; m_counter . writeConfig_DownSource_Channel ( source . getChannelForRouting ( ) ) ; m_counter . writeConfig_DownSource_AnalogTrigger ( source . getAnalogTriggerForRouting ( ) ) ; setDownSourceEdge ( true , false ) ; m_counter . strobeReset ( ) ; } public void setDownSource ( AnalogTrigger analogTrigger , AnalogTriggerOutput . Type triggerType ) { m_allocatedDownSource = true ; setDownSource ( analogTrigger . createOutput ( triggerType ) ) ; } public void setDownSourceEdge ( boolean risingEdge , boolean fallingEdge ) { m_counter . writeConfig_DownRisingEdge ( risingEdge ) ; m_counter . writeConfig_DownFallingEdge ( fallingEdge ) ; } public void clearDownSource ( ) { if ( m_downSource != null && m_allocatedDownSource ) { m_downSource . free ( ) ; } m_downSource = null ; boolean state = m_counter . readConfig_Enable ( ) ; m_counter . writeConfig_Enable ( false ) ; m_counter . writeConfig_DownFallingEdge ( false ) ; m_counter . writeConfig_DownRisingEdge ( false ) ; m_counter . writeConfig_DownSource_Channel ( <NUM_LIT:0> ) ; m_counter . writeConfig_DownSource_AnalogTrigger ( false ) ; m_counter . writeConfig_Enable ( state ) ; } public void setUpDownCounterMode ( ) { m_counter . writeConfig_Mode ( Mode . kTwoPulse . value ) ; } public void setExternalDirectionMode ( ) { m_counter . writeConfig_Mode ( Mode . kExternalDirection . value ) ; } public void setSemiPeriodMode ( boolean highSemiPeriod ) { m_counter . writeConfig_Mode ( Mode . kSemiperiod . value ) ; m_counter . writeConfig_UpRisingEdge ( highSemiPeriod ) ; setUpdateWhenEmpty ( false ) ; } public void setPulseLengthMode ( double threshold ) { m_counter . writeConfig_Mode ( Mode . kPulseLength . value ) ; m_counter . writeConfig_PulseLengthThreshold ( ( short ) ( ( threshold * <NUM_LIT> ) * kSystemClockTicksPerMicrosecond ) ) ; } public void start ( ) { m_counter . writeConfig_Enable ( true ) ; } public int get ( ) { return m_counter . readOutput_Value ( ) ; } public void reset ( ) { m_counter . strobeReset ( ) ; } public void stop ( ) { m_counter . writeConfig_Enable ( false ) ; } public void setMaxPeriod ( double maxPeriod ) { m_counter . writeTimerConfig_StallPeriod ( ( int ) ( maxPeriod * <NUM_LIT> ) ) ; } public void setUpdateWhenEmpty ( boolean enabled ) { m_counter . writeTimerConfig_UpdateWhenEmpty ( enabled ) ; } public boolean getStopped ( ) { return m_counter . readTimerOutput_Stalled ( ) ; } public boolean getDirection ( ) { boolean value = m_counter . readOutput_Direction ( ) ; return value ; } public void setReverseDirection ( boolean reverseDirection ) { if ( m_counter . readConfig_Mode ( ) == Mode . kExternalDirection . value ) { if ( reverseDirection ) { setDownSourceEdge ( true , true ) ; } else { setDownSourceEdge ( false , true ) ; } } } public double getPeriod ( ) { double period ; if ( m_counter . readTimerOutput_Stalled ( ) ) { return Double . POSITIVE_INFINITY ; } else { period = ( double ) m_counter . readTimerOutput_Period ( ) / ( double ) m_counter . readTimerOutput_Count ( ) ; } return period / <NUM_LIT> ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . util . BoundaryException ; public class I2C extends SensorBase { private DigitalModule m_module ; private int m_deviceAddress ; private boolean m_compatibilityMode ; public I2C ( DigitalModule module , int deviceAddress ) { if ( module == null ) { throw new NullPointerException ( "<STR_LIT>" ) ; } m_module = module ; m_deviceAddress = deviceAddress ; m_compatibilityMode = false ; } protected void free ( ) { } public synchronized boolean transaction ( byte [ ] dataToSend , int sendSize , byte [ ] dataReceived , int receiveSize ) { BoundaryException . assertWithinBounds ( sendSize , <NUM_LIT:0> , <NUM_LIT:6> ) ; BoundaryException . assertWithinBounds ( receiveSize , <NUM_LIT:0> , <NUM_LIT:7> ) ; long data = <NUM_LIT:0> ; long dataHigh = <NUM_LIT:0> ; int i ; for ( i = <NUM_LIT:0> ; i < sendSize && i < <NUM_LIT:4> ; i ++ ) { data |= ( long ) dataToSend [ i ] << ( <NUM_LIT:8> * i ) ; } for ( ; i < sendSize ; i ++ ) { dataHigh |= ( long ) dataToSend [ i ] << ( <NUM_LIT:8> * ( i - <NUM_LIT:4> ) ) ; } boolean aborted = true ; m_module . m_fpgaDIO . writeI2CConfig_Address ( m_deviceAddress ) ; m_module . m_fpgaDIO . writeI2CConfig_BytesToWrite ( sendSize ) ; m_module . m_fpgaDIO . writeI2CConfig_BytesToRead ( receiveSize ) ; if ( sendSize > <NUM_LIT:0> ) { m_module . m_fpgaDIO . writeI2CDataToSend ( data ) ; } if ( sendSize > <NUM_LIT:4> ) { m_module . m_fpgaDIO . writeI2CConfig_DataToSendHigh ( ( int ) dataHigh ) ; } m_module . m_fpgaDIO . writeI2CConfig_BitwiseHandshake ( m_compatibilityMode ) ; byte transaction = m_module . m_fpgaDIO . readI2CStatus_Transaction ( ) ; m_module . m_fpgaDIO . strobeI2CStart ( ) ; while ( transaction == m_module . m_fpgaDIO . readI2CStatus_Transaction ( ) ) { Timer . delay ( <NUM_LIT> ) ; } while ( ! m_module . m_fpgaDIO . readI2CStatus_Done ( ) ) { Timer . delay ( <NUM_LIT> ) ; } aborted = m_module . m_fpgaDIO . readI2CStatus_Aborted ( ) ; if ( receiveSize > <NUM_LIT:0> ) { data = m_module . m_fpgaDIO . readI2CDataReceived ( ) ; } if ( receiveSize > <NUM_LIT:4> ) { dataHigh = m_module . m_fpgaDIO . readI2CStatus_DataReceivedHigh ( ) ; } for ( i = <NUM_LIT:0> ; i < receiveSize && i < <NUM_LIT:4> ; i ++ ) { dataReceived [ i ] = ( byte ) ( ( data > > ( <NUM_LIT:8> * i ) ) & <NUM_LIT> ) ; } for ( ; i < receiveSize ; i ++ ) { dataReceived [ i ] = ( byte ) ( ( dataHigh > > ( <NUM_LIT:8> * ( i - <NUM_LIT:4> ) ) ) & <NUM_LIT> ) ; } return aborted ; } public boolean addressOnly ( ) { return transaction ( null , ( byte ) <NUM_LIT:0> , null , ( byte ) <NUM_LIT:0> ) ; } public synchronized boolean write ( int registerAddress , int data ) { byte [ ] buffer = new byte [ <NUM_LIT:2> ] ; buffer [ <NUM_LIT:0> ] = ( byte ) registerAddress ; buffer [ <NUM_LIT:1> ] = ( byte ) data ; return transaction ( buffer , buffer . length , null , <NUM_LIT:0> ) ; } public boolean read ( int registerAddress , int count , byte [ ] buffer ) { BoundaryException . assertWithinBounds ( count , <NUM_LIT:1> , <NUM_LIT:7> ) ; if ( buffer == null ) { throw new NullPointerException ( "<STR_LIT>" ) ; } byte [ ] registerAddressArray = new byte [ <NUM_LIT:1> ] ; registerAddressArray [ <NUM_LIT:0> ] = ( byte ) registerAddress ; return transaction ( registerAddressArray , registerAddressArray . length , buffer , count ) ; } public void broadcast ( int registerAddress , int data ) { } public void setCompatabilityMode ( boolean enable ) { m_compatibilityMode = enable ; } public boolean verifySensor ( int registerAddress , int count , byte [ ] expected ) { byte [ ] deviceData = new byte [ <NUM_LIT:4> ] ; for ( int i = <NUM_LIT:0> , curRegisterAddress = registerAddress ; i < count ; i += <NUM_LIT:4> , curRegisterAddress += <NUM_LIT:4> ) { int toRead = count - i < <NUM_LIT:4> ? count - i : <NUM_LIT:4> ; if ( read ( curRegisterAddress , toRead , deviceData ) ) { return false ; } for ( byte j = <NUM_LIT:0> ; j < toRead ; j ++ ) { if ( deviceData [ j ] != expected [ i + j ] ) { return false ; } } } return true ; } } </s>
|
<s> package edu . wpi . first . wpilibj . camera ; import com . sun . cldc . jna . BlockingFunction ; import com . sun . cldc . jna . Function ; import com . sun . cldc . jna . NativeLibrary ; import com . sun . cldc . jna . TaskExecutor ; import com . sun . squawk . VM ; import edu . wpi . first . wpilibj . image . ColorImage ; import edu . wpi . first . wpilibj . image . HSLImage ; import edu . wpi . first . wpilibj . image . NIVisionException ; import edu . wpi . first . wpilibj . parsing . ISensor ; import edu . wpi . first . wpilibj . util . BoundaryException ; public class AxisCamera implements ISensor { private static AxisCamera m_instance = null ; public static class ExposureT { public final int value ; static final ExposureT [ ] allValues = new ExposureT [ <NUM_LIT:4> ] ; public static final ExposureT automatic = new ExposureT ( <NUM_LIT:0> ) ; public static final ExposureT hold = new ExposureT ( <NUM_LIT:1> ) ; public static final ExposureT flickerfree50 = new ExposureT ( <NUM_LIT:2> ) ; public static final ExposureT flickerfree60 = new ExposureT ( <NUM_LIT:3> ) ; private ExposureT ( int value ) { this . value = value ; allValues [ value ] = this ; } private static ExposureT get ( int val ) { return allValues [ val ] ; } } public static class WhiteBalanceT { public final int value ; static final WhiteBalanceT [ ] allValues = new WhiteBalanceT [ <NUM_LIT:7> ] ; public static final WhiteBalanceT automatic = new WhiteBalanceT ( <NUM_LIT:0> ) ; public static final WhiteBalanceT hold = new WhiteBalanceT ( <NUM_LIT:1> ) ; public static final WhiteBalanceT fixedOutdoor1 = new WhiteBalanceT ( <NUM_LIT:2> ) ; public static final WhiteBalanceT fixedOutdoor2 = new WhiteBalanceT ( <NUM_LIT:3> ) ; public static final WhiteBalanceT fixedIndoor = new WhiteBalanceT ( <NUM_LIT:4> ) ; public static final WhiteBalanceT fixedFlour1 = new WhiteBalanceT ( <NUM_LIT:5> ) ; public static final WhiteBalanceT fixedFlour2 = new WhiteBalanceT ( <NUM_LIT:6> ) ; private WhiteBalanceT ( int value ) { this . value = value ; allValues [ value ] = this ; } private static WhiteBalanceT get ( int value ) { return allValues [ value ] ; } } public static class ResolutionT { public final int value ; public final int width ; public final int height ; static final ResolutionT [ ] allValues = new ResolutionT [ <NUM_LIT:4> ] ; public static final ResolutionT k640x480 = new ResolutionT ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ) ; public static final ResolutionT k640x360 = new ResolutionT ( <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) ; public static final ResolutionT k320x240 = new ResolutionT ( <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT> ) ; public static final ResolutionT k160x120 = new ResolutionT ( <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) ; private ResolutionT ( int value , int horizontal , int vertical ) { this . value = value ; this . width = horizontal ; this . height = vertical ; allValues [ value ] = this ; } private static ResolutionT get ( int value ) { return allValues [ value ] ; } } public static class RotationT { public final int value ; static final RotationT [ ] allValues = new RotationT [ <NUM_LIT:2> ] ; public static final RotationT k0 = new RotationT ( <NUM_LIT:0> ) ; public static final RotationT k180 = new RotationT ( <NUM_LIT:1> ) ; private RotationT ( int value ) { this . value = value ; allValues [ value ] = this ; } private static RotationT get ( int value ) { return allValues [ value ] ; } } public static class ExposurePriorityT { public final int value ; static final ExposurePriorityT [ ] allValues = new ExposurePriorityT [ <NUM_LIT:3> ] ; public static final ExposurePriorityT imageQuality = new ExposurePriorityT ( <NUM_LIT:0> ) ; public static final ExposurePriorityT none = new ExposurePriorityT ( <NUM_LIT> ) ; public static final ExposurePriorityT frameRate = new ExposurePriorityT ( <NUM_LIT:100> ) ; private ExposurePriorityT ( int value ) { this . value = value ; allValues [ value / <NUM_LIT> ] = this ; } private static ExposurePriorityT get ( int value ) { return allValues [ value / <NUM_LIT> ] ; } } public static synchronized AxisCamera getInstance ( ) { if ( m_instance == null ) { m_instance = new AxisCamera ( ) ; } return m_instance ; } private static final Function cameraStartFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; AxisCamera ( ) { cameraStartFn . call0 ( ) ; } private static final TaskExecutor cameraTaskExecutor = new TaskExecutor ( "<STR_LIT>" ) ; private static final BlockingFunction getImageFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { getImageFn . setTaskExecutor ( cameraTaskExecutor ) ; } public ColorImage getImage ( ) throws AxisCameraException , NIVisionException { ColorImage image = new HSLImage ( ) ; if ( getImageFn . call1 ( image . image ) == <NUM_LIT:0> ) { image . free ( ) ; throw new AxisCameraException ( "<STR_LIT>" ) ; } return image ; } private static final Function writeBrightnessFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeBrightness ( int brightness ) { BoundaryException . assertWithinBounds ( brightness , <NUM_LIT:0> , <NUM_LIT:100> ) ; writeBrightnessFn . call1 ( brightness ) ; } private static final Function getBrightnessFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public int getBrightness ( ) { return getBrightnessFn . call0 ( ) ; } private static final Function writeWhiteBalenceFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeWhiteBalance ( WhiteBalanceT whiteBalance ) { writeWhiteBalenceFn . call1 ( whiteBalance . value ) ; } private static final Function getWhiteBalanceFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public WhiteBalanceT getWhiteBalance ( ) { return WhiteBalanceT . get ( getWhiteBalanceFn . call0 ( ) ) ; } private static final Function writeColorLevelFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeColorLevel ( int value ) { BoundaryException . assertWithinBounds ( value , <NUM_LIT:0> , <NUM_LIT:100> ) ; writeColorLevelFn . call1 ( value ) ; } private static final Function getColorLevelFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public int getColorLevel ( ) { return getColorLevelFn . call0 ( ) ; } private static final Function writeExposureControlFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeExposureControl ( ExposureT value ) { writeExposureControlFn . call1 ( value . value ) ; } private static final Function getExposureControlFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public ExposureT getExposureControl ( ) { return ExposureT . get ( getExposureControlFn . call0 ( ) ) ; } private static final Function writeExposurePriorityFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeExposurePriority ( ExposurePriorityT value ) { writeExposurePriorityFn . call1 ( value . value ) ; } private static final Function getExposurePriorityFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public ExposurePriorityT getExposurePriority ( ) { return ExposurePriorityT . get ( getExposurePriorityFn . call0 ( ) ) ; } private static final Function writeResolutionFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeResolution ( ResolutionT value ) { writeResolutionFn . call1 ( value . value ) ; } private static final Function getResolutionFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public ResolutionT getResolution ( ) { return ResolutionT . get ( getResolutionFn . call0 ( ) ) ; } private static final Function writeCompressionFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeCompression ( int value ) { BoundaryException . assertWithinBounds ( value , <NUM_LIT:0> , <NUM_LIT:100> ) ; writeCompressionFn . call1 ( value ) ; } private static final Function getCompressionFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public int getCompression ( ) { return getCompressionFn . call0 ( ) ; } private static final Function writeRotationFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeRotation ( RotationT value ) { writeRotationFn . call1 ( value . value ) ; } private static final Function getRotationFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public RotationT getRotation ( ) { return RotationT . get ( getRotationFn . call0 ( ) ) ; } private static final Function freshImageFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public boolean freshImage ( ) { return freshImageFn . call0 ( ) == <NUM_LIT:0> ? false : true ; } private static final Function getMaxFPSFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public int getMaxFPS ( ) { return getMaxFPSFn . call0 ( ) ; } private static final Function writeMaxFPSFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public void writeMaxFPS ( int value ) { writeMaxFPSFn . call1 ( value ) ; } private static final Function deleteInstanceFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; static { VM . addShutdownHook ( new Thread ( ) { public void run ( ) { deleteInstanceFn . call0 ( ) ; } } ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . camera ; public class AxisCameraException extends Exception { public AxisCameraException ( String msg ) { super ( msg ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public interface IDashboard { public byte [ ] getBytes ( ) ; public int getBytesLength ( ) ; public void flush ( ) ; } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tDIO ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; public class DigitalOutput extends DigitalSource implements IInputOutput { private int m_channel ; private int m_pwmGenerator ; private DigitalModule m_module ; private void initDigitalOutput ( int slot , int channel ) { m_channel = channel ; m_pwmGenerator = ~ <NUM_LIT:0> ; m_module = DigitalModule . getInstance ( slot ) ; m_module . allocateDIO ( m_channel , false ) ; } public DigitalOutput ( int slot , int channel ) { initDigitalOutput ( slot , channel ) ; } public DigitalOutput ( int channel ) { initDigitalOutput ( getDefaultDigitalModule ( ) , channel ) ; } protected void free ( ) { disablePWM ( ) ; m_module . freeDIO ( m_channel ) ; } public void set ( boolean value ) { m_module . setDIO ( m_channel , value ) ; } public int getChannel ( ) { return m_channel ; } public void pulse ( double length ) { m_module . pulse ( m_channel , ( char ) ( <NUM_LIT> * length / ( tDIO . readLoopTiming ( ) * <NUM_LIT> ) ) ) ; } public boolean isPulsing ( ) { return m_module . isPulsing ( m_channel ) ; } public void setPWMRate ( double rate ) { m_module . setDO_PWMRate ( rate ) ; } public void enablePWM ( double initialDutyCycle ) { if ( m_pwmGenerator != ~ <NUM_LIT:0> ) return ; m_pwmGenerator = m_module . allocateDO_PWM ( ) ; m_module . setDO_PWMDutyCycle ( m_pwmGenerator , initialDutyCycle ) ; m_module . setDO_PWMOutputChannel ( m_pwmGenerator , m_channel ) ; } public void disablePWM ( ) { m_module . setDO_PWMOutputChannel ( m_pwmGenerator , kDigitalChannels ) ; m_module . freeDO_PWM ( m_pwmGenerator ) ; m_pwmGenerator = ~ <NUM_LIT:0> ; } public void updateDutyCycle ( double dutyCycle ) { m_module . setDO_PWMDutyCycle ( m_pwmGenerator , dutyCycle ) ; } public int getChannelForRouting ( ) { return DigitalModule . remapDigitalChannel ( getChannel ( ) - <NUM_LIT:1> ) ; } public int getModuleForRouting ( ) { return DigitalModule . slotToIndex ( m_module . getSlot ( ) ) ; } public boolean getAnalogTriggerForRouting ( ) { return false ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tDIO ; import edu . wpi . first . wpilibj . parsing . IDeviceController ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class Relay extends SensorBase implements IDeviceController { public class InvalidValueException extends RuntimeException { public InvalidValueException ( String message ) { super ( message ) ; } } public static class Value { public final int value ; static final int kOff_val = <NUM_LIT:0> ; static final int kOn_val = <NUM_LIT:1> ; static final int kForward_val = <NUM_LIT:2> ; static final int kReverse_val = <NUM_LIT:3> ; public static final Value kOff = new Value ( kOff_val ) ; public static final Value kOn = new Value ( kOn_val ) ; public static final Value kForward = new Value ( kForward_val ) ; public static final Value kReverse = new Value ( kReverse_val ) ; private Value ( int value ) { this . value = value ; } } public static class Direction { public final int value ; static final int kBoth_val = <NUM_LIT:0> ; static final int kForward_val = <NUM_LIT:1> ; static final int kReverse_val = <NUM_LIT:2> ; public static final Direction kBoth = new Direction ( kBoth_val ) ; public static final Direction kForward = new Direction ( kForward_val ) ; public static final Direction kReverse = new Direction ( kReverse_val ) ; private Direction ( int value ) { this . value = value ; } } private int m_channel ; private Direction m_direction ; private DigitalModule m_module ; private static Resource relayChannels = new Resource ( tDIO . kNumSystems * kRelayChannels ) ; private void initRelay ( final int slot ) { SensorBase . checkRelayModule ( slot ) ; SensorBase . checkRelayChannel ( m_channel ) ; try { if ( m_direction == Direction . kBoth || m_direction == Direction . kForward ) { relayChannels . allocate ( ( DigitalModule . slotToIndex ( slot ) * kRelayChannels + m_channel - <NUM_LIT:1> ) * <NUM_LIT:2> ) ; } if ( m_direction == Direction . kBoth || m_direction == Direction . kReverse ) { relayChannels . allocate ( ( DigitalModule . slotToIndex ( slot ) * kRelayChannels + m_channel - <NUM_LIT:1> ) * <NUM_LIT:2> + <NUM_LIT:1> ) ; } } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + m_channel + "<STR_LIT>" + slot + "<STR_LIT>" ) ; } m_module = DigitalModule . getInstance ( slot ) ; m_module . setRelayForward ( m_channel , false ) ; m_module . setRelayReverse ( m_channel , false ) ; } public Relay ( final int slot , final int channel , Direction direction ) { if ( direction == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_channel = channel ; m_direction = direction ; initRelay ( slot ) ; } public Relay ( final int channel , Direction direction ) { if ( direction == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_channel = channel ; m_direction = direction ; initRelay ( getDefaultDigitalModule ( ) ) ; } public Relay ( final int slot , final int channel ) { m_channel = channel ; m_direction = Direction . kBoth ; initRelay ( slot ) ; } public Relay ( final int channel ) { m_channel = channel ; m_direction = Direction . kBoth ; initRelay ( getDefaultDigitalModule ( ) ) ; } protected void free ( ) { m_module . setRelayForward ( m_channel , false ) ; m_module . setRelayReverse ( m_channel , false ) ; if ( m_direction == Direction . kBoth || m_direction == Direction . kForward ) { relayChannels . free ( ( DigitalModule . slotToIndex ( m_module . getSlot ( ) ) * kRelayChannels + m_channel - <NUM_LIT:1> ) * <NUM_LIT:2> ) ; } if ( m_direction == Direction . kBoth || m_direction == Direction . kReverse ) { relayChannels . free ( ( DigitalModule . slotToIndex ( m_module . getSlot ( ) ) * kRelayChannels + m_channel - <NUM_LIT:1> ) * <NUM_LIT:2> + <NUM_LIT:1> ) ; } } public void set ( Value value ) { switch ( value . value ) { case Value . kOff_val : if ( m_direction == Direction . kBoth || m_direction == Direction . kForward ) { m_module . setRelayForward ( m_channel , false ) ; } if ( m_direction == Direction . kBoth || m_direction == Direction . kReverse ) { m_module . setRelayReverse ( m_channel , false ) ; } break ; case Value . kOn_val : if ( m_direction == Direction . kBoth ) throw new InvalidValueException ( "<STR_LIT>" ) ; if ( m_direction == Direction . kForward ) { m_module . setRelayForward ( m_channel , true ) ; } else if ( m_direction == Direction . kReverse ) { m_module . setRelayReverse ( m_channel , true ) ; } break ; case Value . kForward_val : if ( m_direction == Direction . kReverse ) throw new InvalidValueException ( "<STR_LIT>" ) ; if ( m_direction == Direction . kBoth || m_direction == Direction . kForward ) { m_module . setRelayForward ( m_channel , true ) ; } if ( m_direction == Direction . kBoth ) { m_module . setRelayReverse ( m_channel , false ) ; } break ; case Value . kReverse_val : if ( m_direction == Direction . kForward ) throw new InvalidValueException ( "<STR_LIT>" ) ; if ( m_direction == Direction . kBoth ) { m_module . setRelayForward ( m_channel , false ) ; } if ( m_direction == Direction . kBoth || m_direction == Direction . kReverse ) { m_module . setRelayReverse ( m_channel , true ) ; } break ; default : } } public void setDirection ( Direction direction ) { if ( direction == null ) throw new NullPointerException ( "<STR_LIT>" ) ; if ( m_direction == direction ) { return ; } free ( ) ; m_direction = direction ; initRelay ( m_module . getSlot ( ) ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . can . * ; import edu . wpi . first . wpilibj . communication . Semaphore ; public class CANJaguar implements MotorSafety , PIDOutput , SpeedController { public static final int kControllerRate = <NUM_LIT:1000> ; public static final double kApproxBusVoltage = <NUM_LIT> ; public static class ControlMode { public final int value ; static final int kPercentVbus_val = <NUM_LIT:0> ; static final int kCurrent_val = <NUM_LIT:1> ; static final int kSpeed_val = <NUM_LIT:2> ; static final int kPosition_val = <NUM_LIT:3> ; static final int kVoltage_val = <NUM_LIT:4> ; public static final ControlMode kPercentVbus = new ControlMode ( kPercentVbus_val ) ; public static final ControlMode kCurrent = new ControlMode ( kCurrent_val ) ; public static final ControlMode kSpeed = new ControlMode ( kSpeed_val ) ; public static final ControlMode kPosition = new ControlMode ( kPosition_val ) ; public static final ControlMode kVoltage = new ControlMode ( kVoltage_val ) ; private ControlMode ( int value ) { this . value = value ; } } public static class Faults { public final int value ; static final int kCurrentFault_val = <NUM_LIT:1> ; static final int kTemperatureFault_val = <NUM_LIT:2> ; static final int kBusVoltageFault_val = <NUM_LIT:4> ; static final int kGateDriverFault_val = <NUM_LIT:8> ; public static final Faults kCurrentFault = new Faults ( kCurrentFault_val ) ; public static final Faults kTemperatureFault = new Faults ( kTemperatureFault_val ) ; public static final Faults kBusVoltageFault = new Faults ( kBusVoltageFault_val ) ; public static final Faults kGateDriverFault = new Faults ( kGateDriverFault_val ) ; private Faults ( int value ) { this . value = value ; } } public static class Limits { public final int value ; static final int kForwardLimit_val = <NUM_LIT:1> ; static final int kReverseLimit_val = <NUM_LIT:2> ; public static final Limits kForwardLimit = new Limits ( kForwardLimit_val ) ; public static final Limits kReverseLimit = new Limits ( kReverseLimit_val ) ; private Limits ( int value ) { this . value = value ; } } public static class PositionReference { public final byte value ; static final byte kQuadEncoder_val = <NUM_LIT:0> ; static final byte kPotentiometer_val = <NUM_LIT:1> ; static final byte kNone_val = ( byte ) <NUM_LIT> ; public static final PositionReference kQuadEncoder = new PositionReference ( kQuadEncoder_val ) ; public static final PositionReference kPotentiometer = new PositionReference ( kPotentiometer_val ) ; public static final PositionReference kNone = new PositionReference ( kNone_val ) ; private PositionReference ( byte value ) { this . value = value ; } } public static class SpeedReference { public final byte value ; static final byte kEncoder_val = <NUM_LIT:0> ; static final byte kInvEncoder_val = <NUM_LIT:2> ; static final byte kQuadEncoder_val = <NUM_LIT:3> ; static final byte kNone_val = ( byte ) <NUM_LIT> ; public static final SpeedReference kEncoder = new SpeedReference ( kEncoder_val ) ; public static final SpeedReference kInvEncoder = new SpeedReference ( kInvEncoder_val ) ; public static final SpeedReference kQuadEncoder = new SpeedReference ( kQuadEncoder_val ) ; public static final SpeedReference kNone = new SpeedReference ( kNone_val ) ; private SpeedReference ( byte value ) { this . value = value ; } } public static class NeutralMode { public final byte value ; static final byte kJumper_val = <NUM_LIT:0> ; static final byte kBrake_val = <NUM_LIT:1> ; static final byte kCoast_val = <NUM_LIT:2> ; public static final NeutralMode kJumper = new NeutralMode ( kJumper_val ) ; public static final NeutralMode kBrake = new NeutralMode ( kBrake_val ) ; public static final NeutralMode kCoast = new NeutralMode ( kCoast_val ) ; private NeutralMode ( byte value ) { this . value = value ; } } public static class LimitMode { public final byte value ; static final byte kSwitchInputsOnly_val = <NUM_LIT:0> ; static final byte kSoftPositionLimit_val = <NUM_LIT:1> ; public static final LimitMode kSwitchInputsOnly = new LimitMode ( kSwitchInputsOnly_val ) ; public static final LimitMode kSoftPostionLimits = new LimitMode ( kSoftPositionLimit_val ) ; private LimitMode ( byte value ) { this . value = value ; } } private final Object m_transactionMutex = new Object ( ) ; private byte m_deviceNumber ; private ControlMode m_controlMode ; private double m_maxOutputVoltage ; private MotorSafetyHelper m_safetyHelper ; private static final byte [ ] kNoData = new byte [ <NUM_LIT:0> ] ; private final static int swap16 ( int x ) { return ( ( ( ( x ) > > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:8> ) & <NUM_LIT> ) ) ; } private final static long swap32 ( long x ) { return ( ( ( ( x ) > > <NUM_LIT:24> ) & <NUM_LIT> ) | ( ( ( x ) > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:24> ) & <NUM_LIT> ) ) ; } private final static int swap16 ( int x , byte [ ] buffer ) { buffer [ <NUM_LIT:0> ] = ( byte ) x ; buffer [ <NUM_LIT:1> ] = ( byte ) ( ( x > > > <NUM_LIT:8> ) & <NUM_LIT> ) ; return ( ( ( ( x ) > > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:8> ) & <NUM_LIT> ) ) ; } private final static long swap32 ( long x , byte [ ] buffer ) { buffer [ <NUM_LIT:0> ] = ( byte ) x ; buffer [ <NUM_LIT:1> ] = ( byte ) ( ( x > > > <NUM_LIT:8> ) & <NUM_LIT> ) ; buffer [ <NUM_LIT:2> ] = ( byte ) ( ( x > > > <NUM_LIT:16> ) & <NUM_LIT> ) ; buffer [ <NUM_LIT:3> ] = ( byte ) ( ( x > > > <NUM_LIT:24> ) & <NUM_LIT> ) ; return ( ( ( ( x ) > > <NUM_LIT:24> ) & <NUM_LIT> ) | ( ( ( x ) > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( x ) << <NUM_LIT:24> ) & <NUM_LIT> ) ) ; } private final static int swap16 ( byte [ ] buffer ) { return ( ( ( ( buffer [ <NUM_LIT:1> ] ) > > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( buffer [ <NUM_LIT:0> ] ) << <NUM_LIT:8> ) & <NUM_LIT> ) ) ; } private final static long swap32 ( byte [ ] buffer ) { return ( ( ( ( buffer [ <NUM_LIT:3> ] ) > > <NUM_LIT:24> ) & <NUM_LIT> ) | ( ( ( buffer [ <NUM_LIT:2> ] ) > > <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( buffer [ <NUM_LIT:1> ] ) << <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( ( buffer [ <NUM_LIT:0> ] ) << <NUM_LIT:24> ) & <NUM_LIT> ) ) ; } private static final void pack16 ( short data , byte [ ] buffer , int offset ) { buffer [ offset ] = ( byte ) ( data & <NUM_LIT> ) ; buffer [ offset + <NUM_LIT:1> ] = ( byte ) ( ( data > > > <NUM_LIT:8> ) & <NUM_LIT> ) ; } private static final void pack32 ( int data , byte [ ] buffer , int offset ) { buffer [ offset ] = ( byte ) ( data & <NUM_LIT> ) ; buffer [ offset + <NUM_LIT:1> ] = ( byte ) ( ( data > > > <NUM_LIT:8> ) & <NUM_LIT> ) ; buffer [ offset + <NUM_LIT:2> ] = ( byte ) ( ( data > > > <NUM_LIT:16> ) & <NUM_LIT> ) ; buffer [ offset + <NUM_LIT:3> ] = ( byte ) ( ( data > > > <NUM_LIT:24> ) & <NUM_LIT> ) ; } private static final short unpack16 ( byte [ ] buffer , int offset ) { return ( short ) ( ( ( int ) buffer [ offset ] & <NUM_LIT> ) | ( short ) ( ( buffer [ offset + <NUM_LIT:1> ] << <NUM_LIT:8> ) ) & <NUM_LIT> ) ; } private static final int unpack32 ( byte [ ] buffer , int offset ) { return ( ( int ) buffer [ offset ] & <NUM_LIT> ) | ( ( buffer [ offset + <NUM_LIT:1> ] << <NUM_LIT:8> ) & <NUM_LIT> ) | ( ( buffer [ offset + <NUM_LIT:2> ] << <NUM_LIT:16> ) & <NUM_LIT> ) | ( ( buffer [ offset + <NUM_LIT:3> ] << <NUM_LIT:24> ) & <NUM_LIT> ) ; } private static final int kFullMessageIDMask = <NUM_LIT> ; private void initCANJaguar ( ) throws CANTimeoutException { if ( m_deviceNumber < <NUM_LIT:1> || m_deviceNumber > <NUM_LIT> ) { throw new RuntimeException ( "<STR_LIT>" + m_deviceNumber + "<STR_LIT>" ) ; } int fwVer = getFirmwareVersion ( ) ; if ( fwVer >= CANJaguarVersionException . kMinRDKFirmwareVersion || fwVer < CANJaguarVersionException . kMinLegalFIRSTFirmwareVersion ) { throw new CANJaguarVersionException ( m_deviceNumber , fwVer ) ; } switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : case ControlMode . kVoltage_val : enableControl ( ) ; break ; default : break ; } m_safetyHelper = new MotorSafetyHelper ( this ) ; } public CANJaguar ( int deviceNumber ) throws CANTimeoutException { m_deviceNumber = ( byte ) deviceNumber ; m_controlMode = ControlMode . kPercentVbus ; m_maxOutputVoltage = kApproxBusVoltage ; initCANJaguar ( ) ; } public CANJaguar ( int deviceNumber , ControlMode controlMode ) throws CANTimeoutException { m_deviceNumber = ( byte ) deviceNumber ; m_controlMode = controlMode ; m_maxOutputVoltage = kApproxBusVoltage ; initCANJaguar ( ) ; } public void setX ( double outputValue ) throws CANTimeoutException { setX ( outputValue , ( byte ) <NUM_LIT:0> ) ; } public void set ( double outputValue ) { set ( outputValue , ( byte ) <NUM_LIT:0> ) ; } public void setX ( double outputValue , byte syncGroup ) throws CANTimeoutException { int messageID = <NUM_LIT:0> ; byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; if ( ! m_safetyHelper . isAlive ( ) ) { enableControl ( ) ; } switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : messageID = JaguarCANProtocol . LM_API_VOLT_T_SET ; if ( outputValue > <NUM_LIT:1.0> ) outputValue = <NUM_LIT:1.0> ; if ( outputValue < - <NUM_LIT:1.0> ) outputValue = - <NUM_LIT:1.0> ; packPercentage ( dataBuffer , outputValue ) ; dataSize = <NUM_LIT:2> ; break ; case ControlMode . kSpeed_val : { messageID = JaguarCANProtocol . LM_API_SPD_T_SET ; dataSize = packFXP16_16 ( dataBuffer , outputValue ) ; } break ; case ControlMode . kPosition_val : { messageID = JaguarCANProtocol . LM_API_POS_T_SET ; dataSize = packFXP16_16 ( dataBuffer , outputValue ) ; } break ; case ControlMode . kCurrent_val : { messageID = JaguarCANProtocol . LM_API_ICTRL_T_SET ; dataSize = packFXP8_8 ( dataBuffer , outputValue ) ; } break ; case ControlMode . kVoltage_val : { messageID = JaguarCANProtocol . LM_API_VCOMP_T_SET ; dataSize = packFXP8_8 ( dataBuffer , outputValue ) ; } break ; default : return ; } if ( syncGroup != <NUM_LIT:0> ) { dataBuffer [ dataSize ] = syncGroup ; dataSize ++ ; } setTransaction ( messageID , dataBuffer , dataSize ) ; m_safetyHelper . feed ( ) ; } public void set ( double outputValue , byte syncGroup ) { try { setX ( outputValue , syncGroup ) ; } catch ( CANTimeoutException e ) { } } public double getX ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_VOLT_SET , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackPercentage ( dataBuffer ) ; } break ; case ControlMode . kSpeed_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_SPD_SET , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kPosition_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_POS_SET , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kCurrent_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_ICTRL_SET , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } break ; case ControlMode . kVoltage_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_VCOMP_SET , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } break ; } return <NUM_LIT:0.0> ; } public double get ( ) { try { return getX ( ) ; } catch ( CANTimeoutException e ) { return <NUM_LIT:0.0> ; } } public void disable ( ) { try { disableControl ( ) ; } catch ( CANTimeoutException e ) { } } public void pidWrite ( double output ) { if ( m_controlMode == ControlMode . kPercentVbus ) { set ( output ) ; } else { } } byte packPercentage ( byte [ ] buffer , double value ) { short intValue = ( short ) ( value * <NUM_LIT> ) ; swap16 ( intValue , buffer ) ; return <NUM_LIT:2> ; } byte packFXP8_8 ( byte [ ] buffer , double value ) { short intValue = ( short ) ( value * <NUM_LIT> ) ; swap16 ( intValue , buffer ) ; return <NUM_LIT:2> ; } byte packFXP16_16 ( byte [ ] buffer , double value ) { int intValue = ( int ) ( value * <NUM_LIT> ) ; swap32 ( intValue , buffer ) ; return <NUM_LIT:4> ; } byte packINT16 ( byte [ ] buffer , short value ) { swap16 ( value , buffer ) ; return <NUM_LIT:2> ; } byte packINT32 ( byte [ ] buffer , int value ) { swap32 ( value , buffer ) ; return <NUM_LIT:4> ; } double unpackPercentage ( byte [ ] buffer ) { return unpack16 ( buffer , <NUM_LIT:0> ) / <NUM_LIT> ; } double unpackFXP8_8 ( byte [ ] buffer ) { return unpack16 ( buffer , <NUM_LIT:0> ) / <NUM_LIT> ; } double unpackFXP16_16 ( byte [ ] buffer ) { return unpack32 ( buffer , <NUM_LIT:0> ) / <NUM_LIT> ; } int unpackINT16 ( byte [ ] buffer ) { return unpack16 ( buffer , <NUM_LIT:0> ) ; } long unpackINT32 ( byte [ ] buffer ) { return unpack32 ( buffer , <NUM_LIT:0> ) ; } private static final byte [ ] sendTrustedDataBuffer = new byte [ JaguarCANDriver . kMaxMessageDataSize ] ; protected static void sendMessage ( int messageID , byte [ ] data , int dataSize ) throws CANTimeoutException { final int [ ] kTrustedMessages = { JaguarCANProtocol . LM_API_VOLT_T_EN , JaguarCANProtocol . LM_API_VOLT_T_SET , JaguarCANProtocol . LM_API_SPD_T_EN , JaguarCANProtocol . LM_API_SPD_T_SET , JaguarCANProtocol . LM_API_VCOMP_T_EN , JaguarCANProtocol . LM_API_VCOMP_T_SET , JaguarCANProtocol . LM_API_POS_T_EN , JaguarCANProtocol . LM_API_POS_T_SET , JaguarCANProtocol . LM_API_ICTRL_T_EN , JaguarCANProtocol . LM_API_ICTRL_T_SET } ; byte i ; for ( i = <NUM_LIT:0> ; i < kTrustedMessages . length ; i ++ ) { if ( ( kFullMessageIDMask & messageID ) == kTrustedMessages [ i ] ) { sendTrustedDataBuffer [ <NUM_LIT:0> ] = <NUM_LIT:0> ; sendTrustedDataBuffer [ <NUM_LIT:1> ] = <NUM_LIT:0> ; if ( dataSize > JaguarCANDriver . kMaxMessageDataSize - <NUM_LIT:2> ) { throw new RuntimeException ( "<STR_LIT>" ) ; } byte j ; for ( j = <NUM_LIT:0> ; j < dataSize ; j ++ ) { sendTrustedDataBuffer [ j + <NUM_LIT:2> ] = data [ j ] ; } JaguarCANDriver . sendMessage ( messageID , sendTrustedDataBuffer , dataSize + <NUM_LIT:2> ) ; return ; } } JaguarCANDriver . sendMessage ( messageID , data , dataSize ) ; } protected static byte receiveMessage ( int messageID , byte [ ] data , double timeout ) throws CANTimeoutException { JaguarCANDriver canDriver = new JaguarCANDriver ( ) ; byte dataSize = canDriver . receiveMessage ( messageID , data , timeout ) ; return dataSize ; } protected static byte receiveMessage ( int messageID , byte [ ] data ) throws CANTimeoutException { return receiveMessage ( messageID , data , <NUM_LIT> ) ; } protected byte setTransaction ( int messageID , byte [ ] data , byte dataSize ) throws CANTimeoutException { int ackMessageID = JaguarCANProtocol . LM_API_ACK | m_deviceNumber ; synchronized ( m_transactionMutex ) { try { receiveMessage ( ackMessageID , kNoData , <NUM_LIT:0.0> ) ; } catch ( CANTimeoutException e ) { } sendMessage ( messageID | m_deviceNumber , data , dataSize ) ; dataSize = receiveMessage ( ackMessageID , kNoData ) ; } return dataSize ; } protected byte getTransaction ( int messageID , byte [ ] data ) throws CANTimeoutException { int targetedMessageID = messageID | m_deviceNumber ; byte dataSize = <NUM_LIT:0> ; synchronized ( m_transactionMutex ) { sendMessage ( targetedMessageID , kNoData , <NUM_LIT:0> ) ; targetedMessageID &= <NUM_LIT> ; dataSize = receiveMessage ( targetedMessageID , data ) ; } return dataSize ; } public void setSpeedReference ( SpeedReference reference ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; dataBuffer [ <NUM_LIT:0> ] = reference . value ; setTransaction ( JaguarCANProtocol . LM_API_SPD_REF , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } public SpeedReference getSpeedReference ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_SPD_REF , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { switch ( dataBuffer [ <NUM_LIT:0> ] ) { case SpeedReference . kEncoder_val : return SpeedReference . kEncoder ; case SpeedReference . kInvEncoder_val : return SpeedReference . kInvEncoder ; case SpeedReference . kQuadEncoder_val : return SpeedReference . kQuadEncoder ; case SpeedReference . kNone_val : return SpeedReference . kNone ; } } return SpeedReference . kNone ; } public void setPositionReference ( PositionReference reference ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; dataBuffer [ <NUM_LIT:0> ] = reference . value ; setTransaction ( JaguarCANProtocol . LM_API_POS_REF , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } public PositionReference getPositionReference ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_POS_REF , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { switch ( dataBuffer [ <NUM_LIT:0> ] ) { case PositionReference . kPotentiometer_val : return PositionReference . kPotentiometer ; case PositionReference . kQuadEncoder_val : return PositionReference . kQuadEncoder ; case PositionReference . kNone_val : return PositionReference . kNone ; } } return PositionReference . kNone ; } public void setPID ( double p , double i , double d ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : case ControlMode . kVoltage_val : break ; case ControlMode . kSpeed_val : dataSize = packFXP16_16 ( dataBuffer , p ) ; setTransaction ( JaguarCANProtocol . LM_API_SPD_PC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , i ) ; setTransaction ( JaguarCANProtocol . LM_API_SPD_IC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , d ) ; setTransaction ( JaguarCANProtocol . LM_API_SPD_DC , dataBuffer , dataSize ) ; break ; case ControlMode . kPosition_val : dataSize = packFXP16_16 ( dataBuffer , p ) ; setTransaction ( JaguarCANProtocol . LM_API_POS_PC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , i ) ; setTransaction ( JaguarCANProtocol . LM_API_POS_IC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , d ) ; setTransaction ( JaguarCANProtocol . LM_API_POS_DC , dataBuffer , dataSize ) ; break ; case ControlMode . kCurrent_val : dataSize = packFXP16_16 ( dataBuffer , p ) ; setTransaction ( JaguarCANProtocol . LM_API_ICTRL_PC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , i ) ; setTransaction ( JaguarCANProtocol . LM_API_ICTRL_IC , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , d ) ; setTransaction ( JaguarCANProtocol . LM_API_ICTRL_DC , dataBuffer , dataSize ) ; break ; } } public double getP ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : case ControlMode . kVoltage_val : break ; case ControlMode . kSpeed_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_SPD_PC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kPosition_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_POS_PC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kCurrent_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_ICTRL_PC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; } return <NUM_LIT:0.0> ; } public double getI ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : case ControlMode . kVoltage_val : break ; case ControlMode . kSpeed_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_SPD_IC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kPosition_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_POS_IC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kCurrent_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_ICTRL_IC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; } return <NUM_LIT:0.0> ; } public double getD ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : case ControlMode . kVoltage_val : break ; case ControlMode . kSpeed_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_SPD_DC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kPosition_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_POS_DC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; case ControlMode . kCurrent_val : dataSize = getTransaction ( JaguarCANProtocol . LM_API_ICTRL_DC , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } break ; } return <NUM_LIT:0.0> ; } public void enableControl ( ) throws CANTimeoutException { enableControl ( <NUM_LIT:0.0> ) ; } public void enableControl ( double encoderInitialPosition ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : setTransaction ( JaguarCANProtocol . LM_API_VOLT_T_EN , dataBuffer , dataSize ) ; break ; case ControlMode . kSpeed_val : setTransaction ( JaguarCANProtocol . LM_API_SPD_T_EN , dataBuffer , dataSize ) ; break ; case ControlMode . kPosition_val : dataSize = packFXP16_16 ( dataBuffer , encoderInitialPosition ) ; setTransaction ( JaguarCANProtocol . LM_API_POS_T_EN , dataBuffer , dataSize ) ; break ; case ControlMode . kCurrent_val : setTransaction ( JaguarCANProtocol . LM_API_ICTRL_T_EN , dataBuffer , dataSize ) ; break ; case ControlMode . kVoltage_val : setTransaction ( JaguarCANProtocol . LM_API_VCOMP_T_EN , dataBuffer , dataSize ) ; break ; } } public void disableControl ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : setTransaction ( JaguarCANProtocol . LM_API_VOLT_DIS , dataBuffer , dataSize ) ; break ; case ControlMode . kSpeed_val : setTransaction ( JaguarCANProtocol . LM_API_SPD_DIS , dataBuffer , dataSize ) ; break ; case ControlMode . kPosition_val : setTransaction ( JaguarCANProtocol . LM_API_POS_DIS , dataBuffer , dataSize ) ; break ; case ControlMode . kCurrent_val : setTransaction ( JaguarCANProtocol . LM_API_ICTRL_DIS , dataBuffer , dataSize ) ; break ; case ControlMode . kVoltage_val : setTransaction ( JaguarCANProtocol . LM_API_VCOMP_DIS , dataBuffer , dataSize ) ; break ; } } public void changeControlMode ( ControlMode controlMode ) throws CANTimeoutException { disableControl ( ) ; m_controlMode = controlMode ; } public ControlMode getControlMode ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_CMODE , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { switch ( dataBuffer [ <NUM_LIT:0> ] ) { case ControlMode . kPercentVbus_val : return ControlMode . kPercentVbus ; case ControlMode . kCurrent_val : return ControlMode . kCurrent ; case ControlMode . kSpeed_val : return ControlMode . kSpeed ; case ControlMode . kPosition_val : return ControlMode . kPosition ; case ControlMode . kVoltage_val : return ControlMode . kVoltage ; } } return ControlMode . kPercentVbus ; } public double getBusVoltage ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_VOLTBUS , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public double getOutputVoltage ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize = <NUM_LIT:0> ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_VOUT , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public double getOutputCurrent ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_CURRENT , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public double getTemperature ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_TEMP , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return unpackFXP8_8 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public double getPosition ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_POS , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public double getSpeed ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_SPD , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return unpackFXP16_16 ( dataBuffer ) ; } return <NUM_LIT:0.0> ; } public boolean getForwardLimitOK ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_LIMIT , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { return ( dataBuffer [ <NUM_LIT:0> ] & Limits . kForwardLimit_val ) != <NUM_LIT:0> ; } return false ; } public boolean getReverseLimitOK ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_LIMIT , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { return ( dataBuffer [ <NUM_LIT:0> ] & Limits . kReverseLimit_val ) != <NUM_LIT:0> ; } return false ; } public short getFaults ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_FAULT , dataBuffer ) ; if ( dataSize == <NUM_LIT:2> ) { return ( short ) unpackINT16 ( dataBuffer ) ; } return <NUM_LIT:0> ; } public boolean getPowerCycled ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_STATUS_POWER , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> ) { boolean powerCycled = dataBuffer [ <NUM_LIT:0> ] != <NUM_LIT:0> ; if ( powerCycled ) { dataBuffer [ <NUM_LIT:0> ] = <NUM_LIT:1> ; setTransaction ( JaguarCANProtocol . LM_API_STATUS_POWER , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } return powerCycled ; } return false ; } public void setVoltageRampRate ( double rampRate ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; switch ( m_controlMode . value ) { case ControlMode . kPercentVbus_val : dataSize = packPercentage ( dataBuffer , rampRate / ( m_maxOutputVoltage * kControllerRate ) ) ; setTransaction ( JaguarCANProtocol . LM_API_VOLT_SET_RAMP , dataBuffer , dataSize ) ; break ; case ControlMode . kVoltage_val : dataSize = packFXP8_8 ( dataBuffer , rampRate / kControllerRate ) ; setTransaction ( JaguarCANProtocol . LM_API_VCOMP_IN_RAMP , dataBuffer , dataSize ) ; break ; default : return ; } } public int getFirmwareVersion ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( <NUM_LIT> | JaguarCANProtocol . CAN_MSGID_API_FIRMVER , dataBuffer ) ; if ( dataSize == <NUM_LIT:4> ) { return ( int ) unpackINT32 ( dataBuffer ) ; } return <NUM_LIT:0> ; } public byte getHardwareVersion ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = getTransaction ( JaguarCANProtocol . LM_API_HWVER , dataBuffer ) ; if ( dataSize == <NUM_LIT:1> + <NUM_LIT:1> ) { if ( dataBuffer [ <NUM_LIT:0> ] == m_deviceNumber ) { return dataBuffer [ <NUM_LIT:1> ] ; } } return JaguarCANProtocol . LM_HWVER_JAG_1_0 ; } public void configNeutralMode ( NeutralMode mode ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; dataBuffer [ <NUM_LIT:0> ] = mode . value ; setTransaction ( JaguarCANProtocol . LM_API_CFG_BRAKE_COAST , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } public void configEncoderCodesPerRev ( int codesPerRev ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = packINT16 ( dataBuffer , ( short ) codesPerRev ) ; setTransaction ( JaguarCANProtocol . LM_API_CFG_ENC_LINES , dataBuffer , dataSize ) ; } public void configPotentiometerTurns ( int turns ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = packINT16 ( dataBuffer , ( short ) turns ) ; setTransaction ( JaguarCANProtocol . LM_API_CFG_POT_TURNS , dataBuffer , dataSize ) ; } public void configSoftPositionLimits ( double forwardLimitPosition , double reverseLimitPosition ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = packFXP16_16 ( dataBuffer , forwardLimitPosition ) ; dataBuffer [ dataSize ++ ] = ( forwardLimitPosition > reverseLimitPosition ) ? ( byte ) <NUM_LIT:1> : ( byte ) <NUM_LIT:0> ; setTransaction ( JaguarCANProtocol . LM_API_CFG_LIMIT_FWD , dataBuffer , dataSize ) ; dataSize = packFXP16_16 ( dataBuffer , reverseLimitPosition ) ; dataBuffer [ dataSize ++ ] = forwardLimitPosition <= reverseLimitPosition ? ( byte ) <NUM_LIT:1> : ( byte ) <NUM_LIT:0> ; setTransaction ( JaguarCANProtocol . LM_API_CFG_LIMIT_REV , dataBuffer , dataSize ) ; dataBuffer [ <NUM_LIT:0> ] = LimitMode . kSoftPositionLimit_val ; setTransaction ( JaguarCANProtocol . LM_API_CFG_LIMIT_MODE , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } public void disableSoftPositionLimits ( ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; dataBuffer [ <NUM_LIT:0> ] = LimitMode . kSwitchInputsOnly_val ; setTransaction ( JaguarCANProtocol . LM_API_CFG_LIMIT_MODE , dataBuffer , ( byte ) <NUM_LIT:1> ) ; } public void configMaxOutputVoltage ( double voltage ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; m_maxOutputVoltage = voltage ; dataSize = packFXP8_8 ( dataBuffer , voltage ) ; setTransaction ( JaguarCANProtocol . LM_API_CFG_MAX_VOUT , dataBuffer , dataSize ) ; } public void configFaultTime ( double faultTime ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; byte dataSize ; dataSize = packINT16 ( dataBuffer , ( short ) ( faultTime * <NUM_LIT> ) ) ; setTransaction ( JaguarCANProtocol . LM_API_CFG_FAULT_TIME , dataBuffer , dataSize ) ; } public static void updateSyncGroup ( byte syncGroup ) throws CANTimeoutException { byte [ ] dataBuffer = new byte [ <NUM_LIT:8> ] ; dataBuffer [ <NUM_LIT:0> ] = syncGroup ; sendMessage ( JaguarCANProtocol . CAN_MSGID_API_SYNC , dataBuffer , <NUM_LIT:1> ) ; } public void setExpiration ( double timeout ) { m_safetyHelper . setExpiration ( timeout ) ; } public double getExpiration ( ) { return m_safetyHelper . getExpiration ( ) ; } public boolean isAlive ( ) { return m_safetyHelper . isAlive ( ) ; } public boolean isSafetyEnabled ( ) { return m_safetyHelper . isSafetyEnabled ( ) ; } public void setSafetyEnabled ( boolean enabled ) { m_safetyHelper . setSafetyEnabled ( enabled ) ; } public void stopMotor ( ) { try { disableControl ( ) ; } catch ( CANTimeoutException e ) { } } } </s>
|
<s> package edu . wpi . first . wpilibj ; public class Module extends SensorBase { protected static Module [ ] m_modules = new Module [ SensorBase . kChassisSlots ] ; protected int m_slot ; protected Module ( final int slot ) { m_slot = slot ; } public int getSlot ( ) { return m_slot ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . communication . FRCControl ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; public class DriverStationLCD extends SensorBase implements IInputOutput { private static DriverStationLCD m_instance ; public static final int kSyncTimeout_ms = <NUM_LIT:20> ; public static final int kFullDisplayTextCommand = <NUM_LIT> ; public static final int kLineLength = <NUM_LIT> ; public static class Line { public final int value ; static final int kMain6_val = <NUM_LIT:0> ; static final int kUser2_val = <NUM_LIT:1> ; static final int kUser3_val = <NUM_LIT:2> ; static final int kUser4_val = <NUM_LIT:3> ; static final int kUser5_val = <NUM_LIT:4> ; static final int kUser6_val = <NUM_LIT:5> ; public static final Line kMain6 = new Line ( kMain6_val ) ; public static final Line kUser2 = new Line ( kUser2_val ) ; public static final Line kUser3 = new Line ( kUser3_val ) ; public static final Line kUser4 = new Line ( kUser4_val ) ; public static final Line kUser5 = new Line ( kUser5_val ) ; public static final Line kUser6 = new Line ( kUser6_val ) ; private Line ( int value ) { this . value = value ; } } byte [ ] m_textBuffer ; public static synchronized DriverStationLCD getInstance ( ) { if ( m_instance == null ) m_instance = new DriverStationLCD ( ) ; return m_instance ; } private DriverStationLCD ( ) { m_textBuffer = new byte [ FRCControl . USER_DS_LCD_DATA_SIZE ] ; for ( int i = <NUM_LIT:0> ; i < FRCControl . USER_DS_LCD_DATA_SIZE ; i ++ ) { m_textBuffer [ i ] = '<CHAR_LIT:U+0020>' ; } m_textBuffer [ <NUM_LIT:0> ] = ( byte ) ( kFullDisplayTextCommand > > <NUM_LIT:8> ) ; m_textBuffer [ <NUM_LIT:1> ] = ( byte ) kFullDisplayTextCommand ; } public synchronized void updateLCD ( ) { FRCControl . setUserDsLcdData ( m_textBuffer , FRCControl . USER_DS_LCD_DATA_SIZE , kSyncTimeout_ms ) ; } public void println ( Line line , int startingColumn , String text ) { int start = startingColumn - <NUM_LIT:1> ; int maxLength = kLineLength - start ; if ( startingColumn < <NUM_LIT:1> || startingColumn > kLineLength ) { throw new IndexOutOfBoundsException ( "<STR_LIT>" + kLineLength + "<STR_LIT>" ) ; } int length = text . length ( ) ; int finalLength = ( length < maxLength ? length : maxLength ) ; synchronized ( this ) { for ( int i = <NUM_LIT:0> ; i < finalLength ; i ++ ) { m_textBuffer [ i + start + line . value * kLineLength + <NUM_LIT:2> ] = ( byte ) text . charAt ( i ) ; } } } public void println ( Line line , int startingColumn , StringBuffer text ) { int start = startingColumn - <NUM_LIT:1> ; int maxLength = kLineLength - start ; if ( startingColumn < <NUM_LIT:1> || startingColumn > kLineLength ) { throw new IndexOutOfBoundsException ( "<STR_LIT>" + kLineLength + "<STR_LIT>" ) ; } int length = text . length ( ) ; int finalLength = ( length < maxLength ? length : maxLength ) ; synchronized ( this ) { for ( int i = <NUM_LIT:0> ; i < finalLength ; i ++ ) { m_textBuffer [ i + start + line . value * kLineLength + <NUM_LIT:2> ] = ( byte ) text . charAt ( i ) ; } } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . ISensor ; public class Gyro extends SensorBase implements PIDSource , ISensor { static final int kOversampleBits = <NUM_LIT:10> ; static final int kAverageBits = <NUM_LIT:0> ; static final double kSamplesPerSecond = <NUM_LIT> ; static final double kCalibrationSampleTime = <NUM_LIT> ; static final double kDefaultVoltsPerDegreePerSecond = <NUM_LIT> ; AnalogChannel m_analog ; double m_voltsPerDegreePerSecond ; double m_offset ; boolean m_channelAllocated ; AccumulatorResult result ; private void initGyro ( ) { result = new AccumulatorResult ( ) ; if ( m_analog == null ) { System . out . println ( "<STR_LIT>" ) ; } m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond ; m_analog . setAverageBits ( kAverageBits ) ; m_analog . setOversampleBits ( kOversampleBits ) ; double sampleRate = kSamplesPerSecond * ( <NUM_LIT:1> << ( kAverageBits + kOversampleBits ) ) ; m_analog . getModule ( ) . setSampleRate ( sampleRate ) ; Timer . delay ( <NUM_LIT:1.0> ) ; m_analog . initAccumulator ( ) ; Timer . delay ( kCalibrationSampleTime ) ; m_analog . getAccumulatorOutput ( result ) ; int center = ( int ) ( ( double ) result . value / ( double ) result . count + <NUM_LIT> ) ; m_offset = ( ( double ) result . value / ( double ) result . count ) - ( double ) center ; m_analog . setAccumulatorCenter ( center ) ; m_analog . setAccumulatorDeadband ( <NUM_LIT:0> ) ; m_analog . resetAccumulator ( ) ; } public Gyro ( int slot , int channel ) { m_analog = new AnalogChannel ( slot , channel ) ; m_channelAllocated = true ; initGyro ( ) ; } public Gyro ( int channel ) { m_analog = new AnalogChannel ( channel ) ; m_channelAllocated = true ; initGyro ( ) ; } public Gyro ( AnalogChannel channel ) { m_analog = channel ; if ( m_analog == null ) { System . err . println ( "<STR_LIT>" ) ; } else { m_channelAllocated = false ; initGyro ( ) ; } } public void reset ( ) { if ( m_analog != null ) { m_analog . resetAccumulator ( ) ; } } protected void free ( ) { if ( m_analog != null && m_channelAllocated ) { m_analog . free ( ) ; } m_analog = null ; } public double getAngle ( ) { if ( m_analog == null ) { return <NUM_LIT:0.0> ; } else { m_analog . getAccumulatorOutput ( result ) ; long value = result . value - ( long ) ( result . count * m_offset ) ; double scaledValue = value * <NUM_LIT> * m_analog . getLSBWeight ( ) * ( <NUM_LIT:1> << m_analog . getAverageBits ( ) ) / ( m_analog . getModule ( ) . getSampleRate ( ) * m_voltsPerDegreePerSecond ) ; return scaledValue ; } } public void setSensitivity ( double voltsPerDegreePerSecond ) { m_voltsPerDegreePerSecond = voltsPerDegreePerSecond ; } public double pidGet ( ) { return getAngle ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; public interface CounterBase { public static class EncodingType { public final int value ; static final int k1X_val = <NUM_LIT:0> ; static final int k2X_val = <NUM_LIT:1> ; static final int k4X_val = <NUM_LIT:2> ; public static final EncodingType k1X = new EncodingType ( k1X_val ) ; public static final EncodingType k2X = new EncodingType ( k2X_val ) ; public static final EncodingType k4X = new EncodingType ( k4X_val ) ; private EncodingType ( int value ) { this . value = value ; } } public void start ( ) ; int get ( ) ; void reset ( ) ; void stop ( ) ; double getPeriod ( ) ; void setMaxPeriod ( double maxPeriod ) ; boolean getStopped ( ) ; boolean getDirection ( ) ; } </s>
|
<s> package edu . wpi . first . wpilibj . visa ; import com . sun . cldc . jna . Function ; import com . sun . cldc . jna . NativeLibrary ; import com . sun . cldc . jna . Pointer ; import com . sun . cldc . jna . ptr . IntByReference ; public class Visa { private static int status ; private static final IntByReference pValue = new IntByReference ( <NUM_LIT:0> ) ; public static final int VI_ATTR_ASRL_BAUD = ( <NUM_LIT> ) ; public static final int VI_ATTR_ASRL_DATA_BITS = ( <NUM_LIT> ) ; public static final int VI_ATTR_ASRL_PARITY = ( <NUM_LIT> ) ; public static final int VI_ATTR_ASRL_STOP_BITS = ( <NUM_LIT> ) ; public static final int VI_ATTR_ASRL_FLOW_CNTRL = ( <NUM_LIT> ) ; public static final int VI_ATTR_TERMCHAR_EN = ( <NUM_LIT> ) ; public static final int VI_ATTR_TERMCHAR = ( <NUM_LIT> ) ; public static final int VI_ATTR_ASRL_END_IN = ( <NUM_LIT> ) ; public static final int VI_ASRL_END_TERMCHAR = <NUM_LIT:2> ; public static final int VI_ASRL_END_NONE = <NUM_LIT:0> ; public static final int VI_ATTR_ASRL_AVAIL_NUM = ( <NUM_LIT> ) ; public static final int VI_SUCCESS_TERM_CHAR = ( <NUM_LIT> ) ; public static final int VI_SUCCESS_MAX_CNT = ( <NUM_LIT> ) ; public static final int VI_ATTR_TMO_VALUE = ( <NUM_LIT> ) ; public static final int VI_ATTR_WR_BUF_OPER_MODE = ( <NUM_LIT> ) ; public static final int VI_WRITE_BUF = <NUM_LIT:2> ; private static final Function viOpenDefaultRMFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public synchronized static int viOpenDefaultRM ( ) throws VisaException { status = viOpenDefaultRMFn . call1 ( pValue . getPointer ( ) ) ; assertCleanStatus ( "<STR_LIT>" ) ; return pValue . getValue ( ) ; } private static final Function viOpenFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public synchronized static int viOpen ( int sesn , String name , int mode , int timeout ) throws VisaException { Pointer pName = new Pointer ( name . length ( ) ) ; pName . setBytes ( <NUM_LIT:0> , name . getBytes ( ) , <NUM_LIT:0> , name . length ( ) ) ; status = viOpenFn . call5 ( sesn , pName , mode , timeout , pValue . getPointer ( ) ) ; assertCleanStatus ( "<STR_LIT>" ) ; pName . free ( ) ; return pValue . getValue ( ) ; } private static final Function viSetAttributeFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void viSetAttribute ( int vi , int attrName , int attrValue ) throws VisaException { status = viSetAttributeFn . call3 ( vi , attrName , attrValue ) ; assertCleanStatus ( "<STR_LIT>" ) ; } public static void viSetAttribute ( int vi , int attrName , boolean attrValue ) throws VisaException { status = viSetAttributeFn . call3 ( vi , attrName , attrValue ? <NUM_LIT:1> : <NUM_LIT:0> ) ; assertCleanStatus ( "<STR_LIT>" ) ; } private static final Function viCloseFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void viClose ( int vi ) { viCloseFn . call1 ( vi ) ; } private static final Function viGetAttributeFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public synchronized static int viGetAttribute ( int vi , int attrName ) throws VisaException { status = viGetAttributeFn . call3 ( vi , attrName , pValue . getPointer ( ) ) ; assertCleanStatus ( "<STR_LIT>" ) ; return pValue . getValue ( ) ; } private static final Function viVPrintfFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void viVPrintf ( int vi , String write ) throws VisaException { Pointer string = new Pointer ( write . length ( ) ) ; string . setBytes ( <NUM_LIT:0> , write . getBytes ( ) , <NUM_LIT:0> , write . length ( ) ) ; status = viVPrintfFn . call2 ( vi , string ) ; string . free ( ) ; assertCleanStatus ( "<STR_LIT>" ) ; } private static final Function viBufReadFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static byte [ ] viBufRead ( int vi , int cnt ) throws VisaException { Pointer bytes = new Pointer ( cnt ) ; status = viBufReadFn . call2 ( vi , bytes ) ; switch ( status ) { case VI_SUCCESS_TERM_CHAR : case VI_SUCCESS_MAX_CNT : status = <NUM_LIT:0> ; break ; default : assertCleanStatus ( "<STR_LIT>" ) ; } byte [ ] toReturn = new byte [ cnt ] ; bytes . getBytes ( <NUM_LIT:0> , toReturn , <NUM_LIT:0> , cnt ) ; bytes . free ( ) ; return toReturn ; } private static final Function viBufWriteFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public synchronized static int viBufWrite ( int vi , byte [ ] buf , int cnt ) throws VisaException { Pointer string = new Pointer ( buf . length ) ; string . setBytes ( <NUM_LIT:0> , buf , <NUM_LIT:0> , buf . length ) ; status = viBufWriteFn . call4 ( vi , string , cnt , pValue . getPointer ( ) ) ; assertCleanStatus ( "<STR_LIT>" ) ; string . free ( ) ; return pValue . getValue ( ) ; } private static final Function viFlushFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void viFlush ( int vi , int mask ) throws VisaException { status = viFlushFn . call2 ( vi , mask ) ; assertCleanStatus ( "<STR_LIT>" ) ; } private static final Function viClearFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void viClear ( int vi ) throws VisaException { viClearFn . call1 ( vi ) ; assertCleanStatus ( "<STR_LIT>" ) ; } protected static final void assertCleanStatus ( String function ) throws VisaException { if ( status < <NUM_LIT:0> ) { throw new VisaException ( function , status ) ; } else if ( status != <NUM_LIT:0> ) { System . out . println ( VisaException . makeMessage ( function , status ) ) ; status = <NUM_LIT:0> ; } } private Visa ( ) { } } </s>
|
<s> package edu . wpi . first . wpilibj . visa ; public class VisaException extends Exception { public VisaException ( String function , int errorCode ) { super ( makeMessage ( function , errorCode ) ) ; } public static String makeMessage ( String function , int errorCode ) { return lookUpCode ( errorCode ) + "<STR_LIT>" + function ; } public static String lookUpCode ( int errorCode ) { switch ( errorCode ) { case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; default : return "<STR_LIT>" ; } } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tSolenoid ; import edu . wpi . first . wpilibj . parsing . IDeviceController ; public abstract class SolenoidBase extends SensorBase implements IDeviceController { protected int m_chassisSlot ; protected static Resource m_allocated = new Resource ( tSolenoid . kDO7_0_NumElements * kSolenoidChannels ) ; private static tSolenoid m_fpgaSolenoidModule ; private static int m_refCount ; public SolenoidBase ( final int slot ) { m_chassisSlot = slot ; checkSolenoidModule ( m_chassisSlot ) ; m_refCount ++ ; if ( m_refCount == <NUM_LIT:1> ) { m_fpgaSolenoidModule = new tSolenoid ( ) ; } } protected synchronized void free ( ) { if ( m_refCount == <NUM_LIT:1> ) { m_fpgaSolenoidModule . Release ( ) ; m_fpgaSolenoidModule = null ; } m_refCount -- ; } protected int slotToIndex ( final int slot ) { return <NUM_LIT:8> - slot ; } protected synchronized void set ( int value , int mask ) { byte currentValue = ( byte ) tSolenoid . readDO7_0 ( slotToIndex ( m_chassisSlot ) ) ; currentValue = ( byte ) ( currentValue & ~ mask ) ; currentValue = ( byte ) ( currentValue | ( value & mask ) ) ; tSolenoid . writeDO7_0 ( slotToIndex ( m_chassisSlot ) , currentValue ) ; } public byte getAll ( ) { return ( byte ) tSolenoid . readDO7_0 ( slotToIndex ( m_chassisSlot ) ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IDeviceController ; public class Jaguar extends SafePWM implements SpeedController , IDeviceController { private void initJaguar ( ) { setBounds ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) ; setPeriodMultiplier ( PeriodMultiplier . k1X ) ; setRaw ( m_centerPwm ) ; } public Jaguar ( final int channel ) { super ( channel ) ; initJaguar ( ) ; } public Jaguar ( final int slot , final int channel ) { super ( slot , channel ) ; initJaguar ( ) ; } public void set ( double speed , byte syncGroup ) { setSpeed ( speed ) ; } public void set ( double speed ) { setSpeed ( speed ) ; } public double get ( ) { return getSpeed ( ) ; } public void pidWrite ( double output ) { set ( output ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IDevice ; public class Servo extends PWM implements IDevice { private static final double kMaxServoAngle = <NUM_LIT> ; private static final double kMinServoAngle = <NUM_LIT:0.0> ; private void initServo ( ) { setBounds ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:11> ) ; setPeriodMultiplier ( PeriodMultiplier . k4X ) ; } public Servo ( final int channel ) { super ( channel ) ; initServo ( ) ; } public Servo ( final int slot , final int channel ) { super ( slot , channel ) ; initServo ( ) ; } public void set ( double value ) { setPosition ( value ) ; } public double get ( ) { return getPosition ( ) ; } public void setAngle ( double degrees ) { if ( degrees < kMinServoAngle ) { degrees = kMinServoAngle ; } else if ( degrees > kMaxServoAngle ) { degrees = kMaxServoAngle ; } setPosition ( ( ( degrees - kMinServoAngle ) ) / getServoAngleRange ( ) ) ; } public double getAngle ( ) { return getPosition ( ) * getServoAngleRange ( ) + kMinServoAngle ; } private double getServoAngleRange ( ) { return kMaxServoAngle - kMinServoAngle ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Structure ; public class RegionOfInterest extends Structure { public void read ( ) { } public void write ( ) { } public int size ( ) { return <NUM_LIT:0> ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public class RGBImage extends ColorImage { public RGBImage ( ) throws NIVisionException { super ( NIVision . ImageType . imaqImageRGB ) ; } RGBImage ( RGBImage sourceImage ) { super ( sourceImage ) ; } public RGBImage ( String fileName ) throws NIVisionException { super ( NIVision . ImageType . imaqImageRGB ) ; NIVision . readFile ( image , fileName ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Pointer ; public abstract class Image { public final Pointer image ; static final int DEFAULT_BORDER_SIZE = <NUM_LIT:3> ; Image ( NIVision . ImageType type ) throws NIVisionException { image = NIVision . imaqCreateImage ( type , DEFAULT_BORDER_SIZE ) ; } Image ( Image sourceImage ) { image = sourceImage . image ; } public void write ( String fileName ) throws NIVisionException { NIVision . writeFile ( image , fileName ) ; } public void free ( ) throws NIVisionException { NIVision . dispose ( image ) ; } public int getHeight ( ) throws NIVisionException { return NIVision . getHeight ( image ) ; } public int getWidth ( ) throws NIVisionException { return NIVision . getWidth ( image ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Structure ; public class CurveOptions extends Structure { int m_extractionMode ; int m_threshold ; int m_filterSize ; int m_minLength ; int m_rowStepSize ; int m_columnStepSize ; int m_maxEndPointGap ; int m_onlyClosed ; int m_subPixelAccuracy ; public CurveOptions ( int m_extractionMode , int m_threshold , int m_filterSize , int m_minLength , int m_rowStepSize , int m_columnStepSize , int m_maxEndPointGap , int m_onlyClosed , int m_subPixelAccuracy ) { this . m_extractionMode = m_extractionMode ; this . m_threshold = m_threshold ; this . m_filterSize = m_filterSize ; this . m_minLength = m_minLength ; this . m_rowStepSize = m_rowStepSize ; this . m_columnStepSize = m_columnStepSize ; this . m_maxEndPointGap = m_maxEndPointGap ; this . m_onlyClosed = m_onlyClosed ; this . m_subPixelAccuracy = m_subPixelAccuracy ; allocateMemory ( ) ; write ( ) ; } public void read ( ) { } public void write ( ) { backingNativeMemory . setInt ( <NUM_LIT:0> , m_extractionMode ) ; backingNativeMemory . setInt ( <NUM_LIT:4> , m_threshold ) ; backingNativeMemory . setInt ( <NUM_LIT:8> , m_filterSize ) ; backingNativeMemory . setInt ( <NUM_LIT:12> , m_minLength ) ; backingNativeMemory . setInt ( <NUM_LIT:16> , m_rowStepSize ) ; backingNativeMemory . setInt ( <NUM_LIT:20> , m_columnStepSize ) ; backingNativeMemory . setInt ( <NUM_LIT:24> , m_maxEndPointGap ) ; backingNativeMemory . setInt ( <NUM_LIT> , m_onlyClosed ) ; backingNativeMemory . setInt ( <NUM_LIT:32> , m_subPixelAccuracy ) ; } public int size ( ) { return <NUM_LIT> ; } public void free ( ) { release ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public abstract class ColorImage extends Image { ColorImage ( NIVision . ImageType type ) throws NIVisionException { super ( type ) ; } ColorImage ( ColorImage sourceImage ) { super ( sourceImage ) ; } private BinaryImage threshold ( NIVision . ColorMode colorMode , int low1 , int high1 , int low2 , int high2 , int low3 , int high3 ) throws NIVisionException { BinaryImage res = new BinaryImage ( ) ; NIVision . Range range1 = new NIVision . Range ( low1 , high1 ) ; NIVision . Range range2 = new NIVision . Range ( low2 , high2 ) ; NIVision . Range range3 = new NIVision . Range ( low3 , high3 ) ; try { NIVision . colorThreshold ( res . image , image , colorMode , range1 . getPointer ( ) , range2 . getPointer ( ) , range3 . getPointer ( ) ) ; } catch ( NIVisionException e ) { res . free ( ) ; throw e ; } finally { range1 . free ( ) ; range2 . free ( ) ; range3 . free ( ) ; } return res ; } public BinaryImage thresholdRGB ( int redLow , int redHigh , int greenLow , int greenHigh , int blueLow , int blueHigh ) throws NIVisionException { return threshold ( NIVision . ColorMode . IMAQ_RGB , redLow , redHigh , greenLow , greenHigh , blueLow , blueHigh ) ; } public BinaryImage thresholdHSL ( int hueLow , int hueHigh , int saturationLow , int saturationHigh , int luminenceLow , int luminenceHigh ) throws NIVisionException { return threshold ( NIVision . ColorMode . IMAQ_HSL , hueLow , hueHigh , saturationLow , saturationHigh , luminenceLow , luminenceHigh ) ; } public BinaryImage thresholdHSV ( int hueLow , int hueHigh , int saturationLow , int saturationHigh , int valueLow , int valueHigh ) throws NIVisionException { return threshold ( NIVision . ColorMode . IMAQ_HSV , hueLow , hueHigh , saturationLow , saturationHigh , valueLow , valueHigh ) ; } public BinaryImage thresholdHSI ( int hueLow , int hueHigh , int saturationLow , int saturationHigh , int intansityLow , int intensityHigh ) throws NIVisionException { return threshold ( NIVision . ColorMode . IMAQ_HSI , hueLow , hueHigh , saturationLow , saturationHigh , intansityLow , intensityHigh ) ; } MonoImage extractFirstColorPlane ( NIVision . ColorMode mode ) throws NIVisionException { MonoImage result = new MonoImage ( ) ; try { NIVision . extractColorPlanes ( image , mode , result . image , null , null ) ; } catch ( NIVisionException e ) { result . free ( ) ; throw e ; } return result ; } MonoImage extractSecondColorPlane ( NIVision . ColorMode mode ) throws NIVisionException { MonoImage result = new MonoImage ( ) ; try { NIVision . extractColorPlanes ( image , mode , null , result . image , null ) ; } catch ( NIVisionException e ) { result . free ( ) ; throw e ; } return result ; } MonoImage extractThirdColorPlane ( NIVision . ColorMode mode ) throws NIVisionException { MonoImage result = new MonoImage ( ) ; try { NIVision . extractColorPlanes ( image , mode , null , null , result . image ) ; } catch ( NIVisionException e ) { result . free ( ) ; throw e ; } return result ; } public MonoImage getRedPlane ( ) throws NIVisionException { return extractFirstColorPlane ( NIVision . ColorMode . IMAQ_RGB ) ; } public MonoImage getGreenPlane ( ) throws NIVisionException { return extractSecondColorPlane ( NIVision . ColorMode . IMAQ_RGB ) ; } public MonoImage getBluePlane ( ) throws NIVisionException { return extractThirdColorPlane ( NIVision . ColorMode . IMAQ_RGB ) ; } public MonoImage getHSLHuePlane ( ) throws NIVisionException { return extractFirstColorPlane ( NIVision . ColorMode . IMAQ_HSL ) ; } public MonoImage getHSVHuePlane ( ) throws NIVisionException { return extractFirstColorPlane ( NIVision . ColorMode . IMAQ_HSV ) ; } public MonoImage getHSIHuePlane ( ) throws NIVisionException { return extractFirstColorPlane ( NIVision . ColorMode . IMAQ_HSI ) ; } public MonoImage getHSLSaturationPlane ( ) throws NIVisionException { return extractSecondColorPlane ( NIVision . ColorMode . IMAQ_HSL ) ; } public MonoImage getHSVSaturationPlane ( ) throws NIVisionException { return extractSecondColorPlane ( NIVision . ColorMode . IMAQ_HSV ) ; } public MonoImage getHSISaturationPlane ( ) throws NIVisionException { return extractSecondColorPlane ( NIVision . ColorMode . IMAQ_HSI ) ; } public MonoImage getLuminancePlane ( ) throws NIVisionException { return extractThirdColorPlane ( NIVision . ColorMode . IMAQ_HSL ) ; } public MonoImage getValuePlane ( ) throws NIVisionException { return extractThirdColorPlane ( NIVision . ColorMode . IMAQ_HSV ) ; } public MonoImage getIntensityPlane ( ) throws NIVisionException { return extractThirdColorPlane ( NIVision . ColorMode . IMAQ_HSI ) ; } ColorImage replaceFirstColorPlane ( NIVision . ColorMode mode , MonoImage plane ) throws NIVisionException { NIVision . replaceColorPlanes ( image , image , mode , plane . image , null , null ) ; return this ; } ColorImage replaceSecondColorPlane ( NIVision . ColorMode mode , MonoImage plane ) throws NIVisionException { NIVision . replaceColorPlanes ( image , image , mode , null , plane . image , null ) ; return this ; } ColorImage replaceThirdColorPlane ( NIVision . ColorMode mode , MonoImage plane ) throws NIVisionException { NIVision . replaceColorPlanes ( image , image , mode , null , null , plane . image ) ; return this ; } public ColorImage replaceRedPlane ( MonoImage plane ) throws NIVisionException { return replaceFirstColorPlane ( NIVision . ColorMode . IMAQ_RGB , plane ) ; } public ColorImage replaceGreenPlane ( MonoImage plane ) throws NIVisionException { return replaceSecondColorPlane ( NIVision . ColorMode . IMAQ_RGB , plane ) ; } public ColorImage replaceBluePlane ( MonoImage plane ) throws NIVisionException { return replaceThirdColorPlane ( NIVision . ColorMode . IMAQ_RGB , plane ) ; } public ColorImage replaceHSLHuePlane ( MonoImage plane ) throws NIVisionException { return replaceFirstColorPlane ( NIVision . ColorMode . IMAQ_HSL , plane ) ; } public ColorImage replaceHSVHuePlane ( MonoImage plane ) throws NIVisionException { return replaceFirstColorPlane ( NIVision . ColorMode . IMAQ_HSV , plane ) ; } public ColorImage replaceHSIHuePlane ( MonoImage plane ) throws NIVisionException { return replaceFirstColorPlane ( NIVision . ColorMode . IMAQ_HSI , plane ) ; } public ColorImage replaceHSLSaturationPlane ( MonoImage plane ) throws NIVisionException { return replaceSecondColorPlane ( NIVision . ColorMode . IMAQ_HSL , plane ) ; } public ColorImage replaceHSVSaturationPlane ( MonoImage plane ) throws NIVisionException { return replaceSecondColorPlane ( NIVision . ColorMode . IMAQ_HSV , plane ) ; } public ColorImage replaceHSISaturationPlane ( MonoImage plane ) throws NIVisionException { return replaceSecondColorPlane ( NIVision . ColorMode . IMAQ_HSI , plane ) ; } public ColorImage replaceLuminancePlane ( MonoImage plane ) throws NIVisionException { return replaceThirdColorPlane ( NIVision . ColorMode . IMAQ_HSL , plane ) ; } public ColorImage replaceValuePlane ( MonoImage plane ) throws NIVisionException { return replaceThirdColorPlane ( NIVision . ColorMode . IMAQ_HSV , plane ) ; } public ColorImage replaceIntensityPlane ( MonoImage plane ) throws NIVisionException { return replaceThirdColorPlane ( NIVision . ColorMode . IMAQ_HSI , plane ) ; } public ColorImage colorEqualize ( ) throws NIVisionException { NIVision . colorEqualize ( image , image , true ) ; return this ; } public ColorImage luminanceEqualize ( ) throws NIVisionException { NIVision . colorEqualize ( image , image , false ) ; return this ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Pointer ; import com . sun . cldc . jna . Structure ; public class EllipseMatch { static final int ellipseMatchSize = <NUM_LIT> ; public double m_xPos ; public double m_yPos ; public double m_rotation ; public double m_majorRadius ; public double m_minorRadius ; public double m_score ; private class EllipseMatchStructure extends Structure { public EllipseMatchStructure ( int address ) { useMemory ( new Pointer ( address , ellipseMatchSize ) ) ; read ( ) ; } public void read ( ) { m_xPos = backingNativeMemory . getFloat ( <NUM_LIT:0> ) ; m_yPos = backingNativeMemory . getFloat ( <NUM_LIT:4> ) ; m_rotation = backingNativeMemory . getDouble ( <NUM_LIT:8> ) ; m_majorRadius = backingNativeMemory . getDouble ( <NUM_LIT:16> ) ; m_minorRadius = backingNativeMemory . getDouble ( <NUM_LIT:24> ) ; m_score = backingNativeMemory . getDouble ( <NUM_LIT:32> ) ; } public void write ( ) { } public int size ( ) { return ellipseMatchSize ; } } EllipseMatch ( int address ) { new EllipseMatchStructure ( address ) ; } public String toString ( ) { return "<STR_LIT>" + "<STR_LIT>" + m_xPos + "<STR_LIT>" + m_yPos + "<STR_LIT:n>" + "<STR_LIT>" + m_majorRadius + "<STR_LIT>" + m_minorRadius + "<STR_LIT:n>" + "<STR_LIT>" + m_rotation + "<STR_LIT>" + m_score + "<STR_LIT:n>" ; } protected static EllipseMatch [ ] getMatchesFromMemory ( int address , int number ) { if ( address == <NUM_LIT:0> ) { return new EllipseMatch [ <NUM_LIT:0> ] ; } EllipseMatch [ ] toReturn = new EllipseMatch [ number ] ; for ( int i = <NUM_LIT:0> ; i < number ; i ++ ) { toReturn [ i ] = new EllipseMatch ( address + i * ellipseMatchSize ) ; } return toReturn ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public class MonoImage extends Image { public MonoImage ( ) throws NIVisionException { super ( NIVision . ImageType . imaqImageU8 ) ; } MonoImage ( MonoImage sourceImage ) { super ( sourceImage ) ; } public EllipseMatch [ ] detectEllipses ( EllipseDescriptor ellipseDescriptor , CurveOptions curveOptions , ShapeDetectionOptions shapeDetectionOptions , RegionOfInterest roi ) throws NIVisionException { return NIVision . detectEllipses ( this , ellipseDescriptor , curveOptions , shapeDetectionOptions , roi ) ; } public EllipseMatch [ ] detectEllipses ( EllipseDescriptor ellipseDescriptor ) throws NIVisionException { return NIVision . detectEllipses ( this , ellipseDescriptor , null , null , null ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Structure ; public class ShapeDetectionOptions extends Structure { int mode ; int angleRanges ; int numAngleRanges ; float scaleRangeMin ; float scaleRangeMax ; double minMatchScore ; public static final int IMAQ_GEOMETRIC_MATCH_SHIFT_INVARIANT = <NUM_LIT:0> ; public static final int IMAQ_GEOMETRIC_MATCH_ROTATION_INVARIANT = <NUM_LIT:1> ; public static final int IMAQ_GEOMETRIC_MATCH_SCALE_INVARIANT = <NUM_LIT:2> ; public static final int IMAQ_GEOMETRIC_MATCH_OCCLUSION_INVARIANT = <NUM_LIT:4> ; public ShapeDetectionOptions ( int mode , int angleRanges , int numAngleRanges , float scaleRangeMin , float scaleRangeMax , double minMatchScore ) { this . mode = mode ; this . angleRanges = angleRanges ; this . numAngleRanges = numAngleRanges ; this . scaleRangeMin = scaleRangeMin ; this . scaleRangeMax = scaleRangeMax ; this . minMatchScore = minMatchScore ; allocateMemory ( ) ; write ( ) ; } public void read ( ) { mode = backingNativeMemory . getInt ( <NUM_LIT:0> ) ; angleRanges = backingNativeMemory . getInt ( <NUM_LIT:4> ) ; numAngleRanges = backingNativeMemory . getInt ( <NUM_LIT:8> ) ; scaleRangeMin = backingNativeMemory . getFloat ( <NUM_LIT:12> ) ; scaleRangeMax = backingNativeMemory . getFloat ( <NUM_LIT:16> ) ; minMatchScore = backingNativeMemory . getDouble ( <NUM_LIT:20> ) ; } public void write ( ) { backingNativeMemory . setInt ( <NUM_LIT:0> , mode ) ; backingNativeMemory . setInt ( <NUM_LIT:4> , angleRanges ) ; backingNativeMemory . setInt ( <NUM_LIT:8> , numAngleRanges ) ; backingNativeMemory . setFloat ( <NUM_LIT:12> , scaleRangeMin ) ; backingNativeMemory . setFloat ( <NUM_LIT:16> , scaleRangeMax ) ; backingNativeMemory . setDouble ( <NUM_LIT:20> , minMatchScore ) ; } public int size ( ) { return <NUM_LIT> ; } public void free ( ) { release ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Structure ; public class EllipseDescriptor extends Structure { double m_minMajorRadius ; double m_maxMajorRadius ; double m_minMinorRadius ; double m_maxMinorRadius ; public EllipseDescriptor ( double m_minMajorRadius , double m_maxMajorRadius , double m_minMinorRadius , double m_maxMinorRadius ) { this . m_minMajorRadius = m_minMajorRadius ; this . m_maxMajorRadius = m_maxMajorRadius ; this . m_minMinorRadius = m_minMinorRadius ; this . m_maxMinorRadius = m_maxMinorRadius ; allocateMemory ( ) ; write ( ) ; } public void free ( ) { release ( ) ; } public void read ( ) { m_minMajorRadius = backingNativeMemory . getDouble ( <NUM_LIT:0> ) ; m_maxMajorRadius = backingNativeMemory . getDouble ( <NUM_LIT:8> ) ; m_minMinorRadius = backingNativeMemory . getDouble ( <NUM_LIT:16> ) ; m_maxMinorRadius = backingNativeMemory . getDouble ( <NUM_LIT:24> ) ; } public void write ( ) { backingNativeMemory . setDouble ( <NUM_LIT:0> , m_minMajorRadius ) ; backingNativeMemory . setDouble ( <NUM_LIT:8> , m_maxMajorRadius ) ; backingNativeMemory . setDouble ( <NUM_LIT:16> , m_minMinorRadius ) ; backingNativeMemory . setDouble ( <NUM_LIT:24> , m_maxMinorRadius ) ; } public int size ( ) { return <NUM_LIT:32> ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . Pointer ; import edu . wpi . first . wpilibj . util . SortedVector ; public class BinaryImage extends MonoImage { private int numParticles = - <NUM_LIT:1> ; BinaryImage ( ) throws NIVisionException { } BinaryImage ( BinaryImage sourceImage ) { super ( sourceImage ) ; } public int getNumberParticles ( ) throws NIVisionException { if ( numParticles < <NUM_LIT:0> ) numParticles = NIVision . countParticles ( image ) ; return numParticles ; } private class ParticleSizeReport { final int index ; final double size ; public ParticleSizeReport ( int index ) throws NIVisionException { if ( ( ! ( index < BinaryImage . this . getNumberParticles ( ) ) ) || index < <NUM_LIT:0> ) throw new IndexOutOfBoundsException ( ) ; this . index = index ; size = ParticleAnalysisReport . getParticleToImagePercent ( BinaryImage . this , index ) ; } public ParticleAnalysisReport getParticleAnalysisReport ( ) throws NIVisionException { return new ParticleAnalysisReport ( BinaryImage . this , index ) ; } } public ParticleAnalysisReport getParticleAnalysisReport ( int index ) throws NIVisionException { if ( ! ( index < getNumberParticles ( ) ) ) throw new IndexOutOfBoundsException ( ) ; return new ParticleAnalysisReport ( this , index ) ; } public ParticleAnalysisReport [ ] getOrderedParticleAnalysisReports ( int size ) throws NIVisionException { if ( size > getNumberParticles ( ) ) size = getNumberParticles ( ) ; ParticleSizeReport [ ] reports = new ParticleSizeReport [ size ] ; SortedVector sorter = new SortedVector ( new SortedVector . Comparator ( ) { public int compare ( Object object1 , Object object2 ) { ParticleSizeReport p1 = ( ParticleSizeReport ) object1 ; ParticleSizeReport p2 = ( ParticleSizeReport ) object2 ; if ( p1 . size < p2 . size ) return - <NUM_LIT:1> ; else if ( p1 . size > p2 . size ) return <NUM_LIT:1> ; return <NUM_LIT:0> ; } } ) ; for ( int i = <NUM_LIT:0> ; i < getNumberParticles ( ) ; i ++ ) sorter . addElement ( new ParticleSizeReport ( i ) ) ; sorter . setSize ( size ) ; sorter . copyInto ( reports ) ; ParticleAnalysisReport [ ] finalReports = new ParticleAnalysisReport [ reports . length ] ; for ( int i = <NUM_LIT:0> ; i < finalReports . length ; i ++ ) finalReports [ i ] = reports [ i ] . getParticleAnalysisReport ( ) ; return finalReports ; } public ParticleAnalysisReport [ ] getOrderedParticleAnalysisReports ( ) throws NIVisionException { return getOrderedParticleAnalysisReports ( getNumberParticles ( ) ) ; } public void write ( String fileName ) throws NIVisionException { Pointer colorTable = new Pointer ( <NUM_LIT> ) ; colorTable . setByte ( <NUM_LIT:0> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:1> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:2> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:3> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:4> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:5> , ( byte ) <NUM_LIT:0> ) ; colorTable . setByte ( <NUM_LIT:6> , ( byte ) <NUM_LIT:255> ) ; colorTable . setByte ( <NUM_LIT:7> , ( byte ) <NUM_LIT:0> ) ; try { NIVision . writeFile ( image , fileName , colorTable ) ; } finally { colorTable . free ( ) ; } } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public class HSLImage extends ColorImage { public HSLImage ( ) throws NIVisionException { super ( NIVision . ImageType . imaqImageHSL ) ; } HSLImage ( HSLImage sourceImage ) { super ( sourceImage ) ; } public HSLImage ( String fileName ) throws NIVisionException { super ( NIVision . ImageType . imaqImageHSL ) ; NIVision . readFile ( image , fileName ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public class ParticleAnalysisReport { public final int imageHeight ; public final int imageWidth ; public final int center_mass_x ; public final int center_mass_y ; public final double center_mass_x_normalized ; public final double center_mass_y_normalized ; public final double particleArea ; public final int boundingRectLeft ; public final int boundingRectTop ; public final int boundingRectWidth ; public final int boundingRectHeight ; public final double particleToImagePercent ; public final double particleQuality ; ParticleAnalysisReport ( BinaryImage image , int index ) throws NIVisionException { imageHeight = image . getHeight ( ) ; imageWidth = image . getWidth ( ) ; center_mass_x = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_CENTER_OF_MASS_X ) ; center_mass_y = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_CENTER_OF_MASS_Y ) ; center_mass_x_normalized = ( <NUM_LIT> * center_mass_x / imageWidth ) - <NUM_LIT:1.0> ; center_mass_y_normalized = ( <NUM_LIT> * center_mass_y / imageHeight ) - <NUM_LIT:1.0> ; particleArea = NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_AREA ) ; boundingRectLeft = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_BOUNDING_RECT_LEFT ) ; boundingRectTop = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_BOUNDING_RECT_TOP ) ; boundingRectWidth = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_BOUNDING_RECT_WIDTH ) ; boundingRectHeight = ( int ) NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_BOUNDING_RECT_HEIGHT ) ; particleToImagePercent = NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_AREA_BY_IMAGE_AREA ) ; particleQuality = NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA ) ; } static double getParticleToImagePercent ( BinaryImage image , int index ) throws NIVisionException { return NIVision . MeasureParticle ( image . image , index , false , NIVision . MeasurementType . IMAQ_MT_AREA_BY_IMAGE_AREA ) ; } public String toString ( ) { return "<STR_LIT>" + "<STR_LIT>" + imageHeight + "<STR_LIT:n>" + "<STR_LIT>" + imageWidth + "<STR_LIT:n>" + "<STR_LIT>" + center_mass_x + "<STR_LIT>" + center_mass_y + "<STR_LIT>" + "<STR_LIT>" + center_mass_x_normalized + "<STR_LIT>" + center_mass_y_normalized + "<STR_LIT>" + "<STR_LIT>" + particleArea + "<STR_LIT:n>" + "<STR_LIT>" + particleToImagePercent + "<STR_LIT:n>" + "<STR_LIT>" + boundingRectLeft + "<STR_LIT>" + boundingRectTop + "<STR_LIT>" + boundingRectWidth + "<STR_LIT:*>" + boundingRectHeight + "<STR_LIT:n>" + "<STR_LIT>" + particleQuality + "<STR_LIT:n>" ; } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; public class NIVisionException extends Exception { public NIVisionException ( String msg ) { super ( msg ) ; } public NIVisionException ( int errorCode ) { super ( lookUpCode ( errorCode ) ) ; } private static String lookUpCode ( int errorCode ) { switch ( errorCode ) { case <NUM_LIT:0> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; case - <NUM_LIT> : return "<STR_LIT>" ; default : return "<STR_LIT>" ; } } } </s>
|
<s> package edu . wpi . first . wpilibj . image ; import com . sun . cldc . jna . BlockingFunction ; import com . sun . cldc . jna . Function ; import com . sun . cldc . jna . NativeLibrary ; import com . sun . cldc . jna . Pointer ; import com . sun . cldc . jna . Structure ; import com . sun . cldc . jna . TaskExecutor ; import com . sun . cldc . jna . ptr . IntByReference ; import edu . wpi . first . wpilibj . util . BoundaryException ; class NIVision { static final TaskExecutor taskExecutor = new TaskExecutor ( "<STR_LIT>" ) ; private static final BlockingFunction imaqGetLastErrorFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqGetLastErrorFn . setTaskExecutor ( taskExecutor ) ; } protected static void assertCleanStatus ( int code ) throws NIVisionException { if ( code == <NUM_LIT:0> ) { throw new NIVisionException ( imaqGetLastErrorFn . call0 ( ) ) ; } } private static final BlockingFunction Priv_ReadJPEGString_CFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { Priv_ReadJPEGString_CFn . setTaskExecutor ( taskExecutor ) ; } public static void readJpegString ( Pointer image , Pointer p ) { Priv_ReadJPEGString_CFn . call3 ( image , p , p . getSize ( ) ) ; } private static final BlockingFunction Priv_SetWriteFileAllowedFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { Priv_SetWriteFileAllowedFn . setTaskExecutor ( taskExecutor ) ; } public static void setWriteFileAllowed ( boolean val ) { Priv_SetWriteFileAllowedFn . call1 ( val ? <NUM_LIT:1> : <NUM_LIT:0> ) ; } public static class ImageType { public final int value ; public static final ImageType imaqImageU8 = new ImageType ( <NUM_LIT:0> ) ; public static final ImageType imaqImageU16 = new ImageType ( <NUM_LIT:7> ) ; public static final ImageType imaqImageI16 = new ImageType ( <NUM_LIT:1> ) ; public static final ImageType imaqImageSGL = new ImageType ( <NUM_LIT:2> ) ; public static final ImageType imaqImageComplex = new ImageType ( <NUM_LIT:3> ) ; public static final ImageType imaqImageRGB = new ImageType ( <NUM_LIT:4> ) ; public static final ImageType imaqImageHSL = new ImageType ( <NUM_LIT:5> ) ; public static final ImageType imaqImageRGBU64 = new ImageType ( <NUM_LIT:6> ) ; public static final ImageType imaqImageTypeSizeGuard = new ImageType ( <NUM_LIT> ) ; private ImageType ( int value ) { this . value = value ; } } public static class ColorMode { public final int value ; public static final ColorMode IMAQ_RGB = new ColorMode ( <NUM_LIT:0> ) ; public static final ColorMode IMAQ_HSL = new ColorMode ( <NUM_LIT:1> ) ; public static final ColorMode IMAQ_HSV = new ColorMode ( <NUM_LIT:2> ) ; public static final ColorMode IMAQ_HSI = new ColorMode ( <NUM_LIT:3> ) ; public static final ColorMode IMAQ_CIE = new ColorMode ( <NUM_LIT:4> ) ; public static final ColorMode IMAQ_CIEXYZ = new ColorMode ( <NUM_LIT:5> ) ; public static final ColorMode IMAQ_COLOR_MODE_SIZE_GUARD = new ColorMode ( <NUM_LIT> ) ; private ColorMode ( int value ) { this . value = value ; } } public static class MeasurementType { public final int value ; public static final MeasurementType IMAQ_MT_CENTER_OF_MASS_X = new MeasurementType ( <NUM_LIT:0> ) ; public static final MeasurementType IMAQ_MT_CENTER_OF_MASS_Y = new MeasurementType ( <NUM_LIT:1> ) ; public static final MeasurementType IMAQ_MT_FIRST_PIXEL_X = new MeasurementType ( <NUM_LIT:2> ) ; public static final MeasurementType IMAQ_MT_FIRST_PIXEL_Y = new MeasurementType ( <NUM_LIT:3> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_LEFT = new MeasurementType ( <NUM_LIT:4> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_TOP = new MeasurementType ( <NUM_LIT:5> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_RIGHT = new MeasurementType ( <NUM_LIT:6> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_BOTTOM = new MeasurementType ( <NUM_LIT:7> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER_START_X = new MeasurementType ( <NUM_LIT:8> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER_START_Y = new MeasurementType ( <NUM_LIT:9> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER_END_X = new MeasurementType ( <NUM_LIT:10> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER_END_Y = new MeasurementType ( <NUM_LIT:11> ) ; public static final MeasurementType IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_LEFT = new MeasurementType ( <NUM_LIT:12> ) ; public static final MeasurementType IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_RIGHT = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_ROW = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_WIDTH = new MeasurementType ( <NUM_LIT:16> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_HEIGHT = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_BOUNDING_RECT_DIAGONAL = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_PERIMETER = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_CONVEX_HULL_PERIMETER = new MeasurementType ( <NUM_LIT:20> ) ; public static final MeasurementType IMAQ_MT_HOLES_PERIMETER = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_ELLIPSE_MAJOR_AXIS = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_ELLIPSE_MINOR_AXIS = new MeasurementType ( <NUM_LIT:24> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_ELLIPSE_MINOR_AXIS_FERET = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_RECT_DIAGONAL = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE_FERET = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_AVERAGE_HORIZ_SEGMENT_LENGTH = new MeasurementType ( <NUM_LIT:30> ) ; public static final MeasurementType IMAQ_MT_AVERAGE_VERT_SEGMENT_LENGTH = new MeasurementType ( <NUM_LIT:31> ) ; public static final MeasurementType IMAQ_MT_HYDRAULIC_RADIUS = new MeasurementType ( <NUM_LIT:32> ) ; public static final MeasurementType IMAQ_MT_WADDEL_DISK_DIAMETER = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HOLES_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_PARTICLE_AND_HOLES_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_CONVEX_HULL_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_IMAGE_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NUMBER_OF_HOLES = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NUMBER_OF_HORIZ_SEGMENTS = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NUMBER_OF_VERT_SEGMENTS = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_ORIENTATION = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MAX_FERET_DIAMETER_ORIENTATION = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_AREA_BY_IMAGE_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_RATIO_OF_EQUIVALENT_ELLIPSE_AXES = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_RATIO_OF_EQUIVALENT_RECT_SIDES = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_ELONGATION_FACTOR = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_COMPACTNESS_FACTOR = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HEYWOOD_CIRCULARITY_FACTOR = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_TYPE_FACTOR = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_X = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_Y = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_XX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_XY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_YY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_XXX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_XXY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_XYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_SUM_YYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_XX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_XY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_YY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_XXX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_XXY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_XYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_MOMENT_OF_INERTIA_YYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_XX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_XY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_YY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_XXX = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_XXY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_XYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_NORM_MOMENT_OF_INERTIA_YYY = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_1 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_2 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_3 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_4 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_5 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_6 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MT_HU_MOMENT_7 = new MeasurementType ( <NUM_LIT> ) ; public static final MeasurementType IMAQ_MEASUREMENT_TYPE_SIZE_GUARD = new MeasurementType ( <NUM_LIT> ) ; private MeasurementType ( int value ) { this . value = value ; } } public static class Range extends Structure { int lower ; int upper ; public void read ( ) { lower = backingNativeMemory . getInt ( <NUM_LIT:0> ) ; upper = backingNativeMemory . getInt ( <NUM_LIT:4> ) ; } public void write ( ) { backingNativeMemory . setInt ( <NUM_LIT:0> , lower ) ; backingNativeMemory . setInt ( <NUM_LIT:4> , upper ) ; } public int size ( ) { return <NUM_LIT:8> ; } public void free ( ) { release ( ) ; } public Range ( final int lower , final int upper ) { allocateMemory ( ) ; set ( lower , upper ) ; } public void set ( final int lower , final int upper ) { if ( lower > upper ) { throw new BoundaryException ( "<STR_LIT>" ) ; } this . lower = lower ; this . upper = upper ; write ( ) ; } public int getLower ( ) { read ( ) ; return lower ; } public int getUpper ( ) { read ( ) ; return upper ; } } protected static final BlockingFunction imaqCreateImageFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqCreateImageFn . setTaskExecutor ( taskExecutor ) ; } public static Pointer imaqCreateImage ( ImageType type , int borderSize ) throws NIVisionException { int toReturn = imaqCreateImageFn . call2 ( type . value , borderSize ) ; assertCleanStatus ( toReturn ) ; return new Pointer ( toReturn , <NUM_LIT:0> ) ; } private static final Function imaqWriteFileFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void writeFile ( Pointer image , String fileName ) throws NIVisionException { Pointer p = new Pointer ( fileName . length ( ) + <NUM_LIT:1> ) ; p . setString ( <NUM_LIT:0> , fileName ) ; setWriteFileAllowed ( true ) ; try { assertCleanStatus ( imaqWriteFileFn . call3 ( image , p , <NUM_LIT:0> ) ) ; } finally { p . free ( ) ; } } public static void writeFile ( Pointer image , String fileName , Pointer colorTable ) throws NIVisionException { Pointer p = new Pointer ( fileName . length ( ) + <NUM_LIT:1> ) ; p . setString ( <NUM_LIT:0> , fileName ) ; setWriteFileAllowed ( true ) ; try { assertCleanStatus ( imaqWriteFileFn . call3 ( image , p , colorTable ) ) ; } finally { p . free ( ) ; } } private static final BlockingFunction imaqReadFileFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqReadFileFn . setTaskExecutor ( taskExecutor ) ; } public static void readFile ( Pointer image , String fileName ) throws NIVisionException { Pointer p = new Pointer ( fileName . length ( ) + <NUM_LIT:1> ) ; p . setString ( <NUM_LIT:0> , fileName ) ; try { assertCleanStatus ( imaqReadFileFn . call4 ( image , p , <NUM_LIT:0> , <NUM_LIT:0> ) ) ; } finally { p . free ( ) ; } } private static final BlockingFunction imaqColorThresholdFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqColorThresholdFn . setTaskExecutor ( taskExecutor ) ; } public static void colorThreshold ( Pointer dest , Pointer source , ColorMode mode , Pointer plane1Range , Pointer plane2Range , Pointer plane3Range ) throws NIVisionException { int replaceValue = <NUM_LIT:1> ; assertCleanStatus ( imaqColorThresholdFn . call7 ( dest . address ( ) . toUWord ( ) . toPrimitive ( ) , source . address ( ) . toUWord ( ) . toPrimitive ( ) , replaceValue , mode . value , plane1Range . address ( ) . toUWord ( ) . toPrimitive ( ) , plane2Range . address ( ) . toUWord ( ) . toPrimitive ( ) , plane3Range . address ( ) . toUWord ( ) . toPrimitive ( ) ) ) ; } private static final BlockingFunction imaqCountParticlesFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqCountParticlesFn . setTaskExecutor ( taskExecutor ) ; } public static int countParticles ( Pointer image ) throws NIVisionException { IntByReference i = new IntByReference ( <NUM_LIT:0> ) ; int val ; try { assertCleanStatus ( imaqCountParticlesFn . call3 ( image , <NUM_LIT:1> , i . getPointer ( ) ) ) ; } finally { val = i . getValue ( ) ; i . free ( ) ; } return val ; } private static final BlockingFunction imaqMeasureParticleFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqMeasureParticleFn . setTaskExecutor ( taskExecutor ) ; } public static double MeasureParticle ( Pointer image , int particleNum , boolean calibrated , MeasurementType type ) throws NIVisionException { Pointer l = new Pointer ( <NUM_LIT:8> ) ; double val ; try { assertCleanStatus ( imaqMeasureParticleFn . call5 ( image , particleNum , calibrated ? <NUM_LIT:1> : <NUM_LIT:0> , type . value , l ) ) ; } finally { val = l . getDouble ( <NUM_LIT:0> ) ; l . free ( ) ; } return val ; } private static final BlockingFunction imaqDisposeFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqDisposeFn . setTaskExecutor ( taskExecutor ) ; } public static void dispose ( Pointer item ) throws NIVisionException { assertCleanStatus ( imaqDisposeFn . call1 ( item ) ) ; } private static final BlockingFunction imaqGetImageSizeFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqGetImageSizeFn . setTaskExecutor ( taskExecutor ) ; } public static int getHeight ( Pointer image ) throws NIVisionException { Pointer i = new Pointer ( <NUM_LIT:4> ) ; int val ; try { assertCleanStatus ( imaqGetImageSizeFn . call3 ( image , <NUM_LIT:0> , i ) ) ; } finally { val = i . getInt ( <NUM_LIT:0> ) ; i . free ( ) ; } return val ; } public static int getWidth ( Pointer image ) throws NIVisionException { Pointer i = new Pointer ( <NUM_LIT:4> ) ; int val ; try { assertCleanStatus ( imaqGetImageSizeFn . call3 ( image , i , <NUM_LIT:0> ) ) ; } finally { val = i . getInt ( <NUM_LIT:0> ) ; i . free ( ) ; } return val ; } private static final BlockingFunction imaqExtractColorPlanesFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqExtractColorPlanesFn . setTaskExecutor ( taskExecutor ) ; } public static void extractColorPlanes ( Pointer source , ColorMode mode , Pointer plane1 , Pointer plane2 , Pointer plane3 ) throws NIVisionException { int plane_1 = <NUM_LIT:0> ; int plane_2 = <NUM_LIT:0> ; int plane_3 = <NUM_LIT:0> ; if ( plane1 != null ) plane_1 = plane1 . address ( ) . toUWord ( ) . toPrimitive ( ) ; if ( plane2 != null ) plane_2 = plane2 . address ( ) . toUWord ( ) . toPrimitive ( ) ; if ( plane3 != null ) plane_3 = plane3 . address ( ) . toUWord ( ) . toPrimitive ( ) ; assertCleanStatus ( imaqExtractColorPlanesFn . call5 ( source , mode . value , plane_1 , plane_2 , plane_3 ) ) ; } private static final BlockingFunction imaqReplaceColorPlanesFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqReplaceColorPlanesFn . setTaskExecutor ( taskExecutor ) ; } public static void replaceColorPlanes ( Pointer dest , Pointer source , ColorMode mode , Pointer plane1 , Pointer plane2 , Pointer plane3 ) throws NIVisionException { int plane_1 = <NUM_LIT:0> ; int plane_2 = <NUM_LIT:0> ; int plane_3 = <NUM_LIT:0> ; if ( plane1 != null ) plane_1 = plane1 . address ( ) . toUWord ( ) . toPrimitive ( ) ; if ( plane2 != null ) plane_2 = plane2 . address ( ) . toUWord ( ) . toPrimitive ( ) ; if ( plane3 != null ) plane_3 = plane3 . address ( ) . toUWord ( ) . toPrimitive ( ) ; assertCleanStatus ( imaqReplaceColorPlanesFn . call6 ( dest . address ( ) . toUWord ( ) . toPrimitive ( ) , source . address ( ) . toUWord ( ) . toPrimitive ( ) , mode . value , plane_1 , plane_2 , plane_3 ) ) ; } private static final BlockingFunction imaqColorEqualizeFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqColorEqualizeFn . setTaskExecutor ( taskExecutor ) ; } public static void colorEqualize ( Pointer destination , Pointer source , boolean all ) throws NIVisionException { assertCleanStatus ( imaqColorEqualizeFn . call3 ( destination , source , all ? <NUM_LIT:1> : <NUM_LIT:0> ) ) ; } private static final BlockingFunction imaqDetectEllipsesFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; static { imaqDetectEllipsesFn . setTaskExecutor ( NIVision . taskExecutor ) ; } private static Pointer numberOfEllipsesDetected = new Pointer ( <NUM_LIT:4> ) ; public static EllipseMatch [ ] detectEllipses ( MonoImage image , EllipseDescriptor ellipseDescriptor , CurveOptions curveOptions , ShapeDetectionOptions shapeDetectionOptions , RegionOfInterest roi ) throws NIVisionException { int curveOptionsPointer = <NUM_LIT:0> ; if ( curveOptions != null ) curveOptionsPointer = curveOptions . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ; int shapeDetectionOptionsPointer = <NUM_LIT:0> ; if ( shapeDetectionOptions != null ) shapeDetectionOptionsPointer = shapeDetectionOptions . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ; int roiPointer = <NUM_LIT:0> ; if ( roi != null ) roiPointer = roi . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ; int returnedAddress = imaqDetectEllipsesFn . call6 ( image . image . address ( ) . toUWord ( ) . toPrimitive ( ) , ellipseDescriptor . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) , curveOptionsPointer , shapeDetectionOptionsPointer , roiPointer , numberOfEllipsesDetected . address ( ) . toUWord ( ) . toPrimitive ( ) ) ; try { NIVision . assertCleanStatus ( returnedAddress ) ; } catch ( NIVisionException ex ) { if ( ! ex . getMessage ( ) . equals ( "<STR_LIT>" ) ) throw ex ; } EllipseMatch [ ] matches = EllipseMatch . getMatchesFromMemory ( returnedAddress , numberOfEllipsesDetected . getInt ( <NUM_LIT:0> ) ) ; NIVision . dispose ( new Pointer ( returnedAddress , <NUM_LIT:0> ) ) ; return matches ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . communication . * ; import edu . wpi . first . wpilibj . parsing . IInputOutput ; public class DriverStation implements IInputOutput { public static final int USER_CONTROL_DATA_SIZE = FRCControl . USER_CONTROL_DATA_SIZE ; public static final int USER_STATUS_DATA_SIZE = FRCControl . USER_STATUS_DATA_SIZE ; public static final int kBatterySlot = <NUM_LIT:1> ; public static final int kBatteryChannel = <NUM_LIT:8> ; public static final int kJoystickPorts = <NUM_LIT:4> ; public static final int kJoystickAxes = <NUM_LIT:6> ; public static final double kDSAnalogInScaling = <NUM_LIT> / <NUM_LIT> ; public static class Alliance { public final int value ; public final String name ; public static final int kRed_val = <NUM_LIT:0> ; public static final int kBlue_val = <NUM_LIT:1> ; public static final int kInvalid_val = <NUM_LIT:2> ; public static final Alliance kRed = new Alliance ( kRed_val , "<STR_LIT>" ) ; public static final Alliance kBlue = new Alliance ( kBlue_val , "<STR_LIT>" ) ; public static final Alliance kInvalid = new Alliance ( kInvalid_val , "<STR_LIT>" ) ; private Alliance ( int value , String name ) { this . value = value ; this . name = name ; } } private static class DriverStationTask implements Runnable { private DriverStation m_ds ; DriverStationTask ( DriverStation ds ) { m_ds = ds ; } public void run ( ) { m_ds . task ( ) ; } } private static DriverStation instance = new DriverStation ( ) ; private FRCCommonControlData m_controlData ; private AnalogChannel m_batteryChannel ; private Thread m_thread ; private final Object m_semaphore ; private int m_digitalOut ; private volatile boolean m_thread_keepalive = true ; private final Dashboard m_dashboardDefaultHigh ; private final Dashboard m_dashboardDefaultLow ; private IDashboard m_dashboardInUseHigh ; private IDashboard m_dashboardInUseLow ; private int m_updateNumber = <NUM_LIT:0> ; private boolean m_newControlData ; private final Semaphore m_packetDataAvailableSem ; private DriverStationEnhancedIO m_enhancedIO = new DriverStationEnhancedIO ( ) ; public static DriverStation getInstance ( ) { return DriverStation . instance ; } protected DriverStation ( ) { m_controlData = new FRCCommonControlData ( ) ; m_semaphore = new Object ( ) ; m_dashboardInUseHigh = m_dashboardDefaultHigh = new Dashboard ( m_semaphore ) ; m_dashboardInUseLow = m_dashboardDefaultLow = new Dashboard ( m_semaphore ) ; m_batteryChannel = new AnalogChannel ( kBatterySlot , kBatteryChannel ) ; Semaphore . Options options = new Semaphore . Options ( ) ; options . setPrioritySorted ( true ) ; m_packetDataAvailableSem = new Semaphore ( options , false ) ; FRCControl . setNewDataSem ( m_packetDataAvailableSem ) ; m_thread = new Thread ( new DriverStationTask ( this ) , "<STR_LIT>" ) ; m_thread . setPriority ( ( Thread . NORM_PRIORITY + Thread . MAX_PRIORITY ) / <NUM_LIT:2> ) ; m_thread . start ( ) ; } public void release ( ) { m_thread_keepalive = false ; } private void task ( ) { int safetyCounter = <NUM_LIT:0> ; while ( m_thread_keepalive ) { try { m_packetDataAvailableSem . takeForever ( ) ; synchronized ( this ) { getData ( ) ; m_enhancedIO . updateData ( ) ; setData ( ) ; } if ( ++ safetyCounter >= <NUM_LIT:5> ) { MotorSafetyHelper . checkMotors ( ) ; safetyCounter = <NUM_LIT:0> ; } } catch ( SemaphoreException ex ) { } } } protected synchronized void getData ( ) { FRCControl . getCommonControlData ( m_controlData , Semaphore . WAIT_FOREVER ) ; m_newControlData = true ; } protected void setData ( ) { synchronized ( m_semaphore ) { FRCControl . setStatusData ( getBatteryVoltage ( ) , m_digitalOut , m_updateNumber , m_dashboardInUseHigh . getBytes ( ) , m_dashboardInUseHigh . getBytesLength ( ) , m_dashboardInUseLow . getBytes ( ) , m_dashboardInUseLow . getBytesLength ( ) , Semaphore . WAIT_FOREVER ) ; m_dashboardInUseHigh . flush ( ) ; m_dashboardInUseLow . flush ( ) ; } } public double getBatteryVoltage ( ) { return m_batteryChannel . getAverageVoltage ( ) * ( <NUM_LIT> / <NUM_LIT> ) ; } public double getStickAxis ( int stick , int axis ) { if ( axis < <NUM_LIT:1> || axis > kJoystickAxes ) { return <NUM_LIT:0.0> ; } int value ; switch ( stick ) { case <NUM_LIT:1> : value = m_controlData . stick0Axes [ axis - <NUM_LIT:1> ] ; break ; case <NUM_LIT:2> : value = m_controlData . stick1Axes [ axis - <NUM_LIT:1> ] ; break ; case <NUM_LIT:3> : value = m_controlData . stick2Axes [ axis - <NUM_LIT:1> ] ; break ; case <NUM_LIT:4> : value = m_controlData . stick3Axes [ axis - <NUM_LIT:1> ] ; break ; default : return <NUM_LIT:0.0> ; } double result ; if ( value < <NUM_LIT:0> ) { result = ( ( double ) value ) / <NUM_LIT> ; } else { result = ( ( double ) value ) / <NUM_LIT> ; } if ( result > <NUM_LIT:1.0> ) { result = <NUM_LIT:1.0> ; } else if ( result < - <NUM_LIT:1.0> ) { result = - <NUM_LIT:1.0> ; } return result ; } public int getStickButtons ( final int stick ) { switch ( stick ) { case <NUM_LIT:1> : return m_controlData . stick0Buttons ; case <NUM_LIT:2> : return m_controlData . stick1Buttons ; case <NUM_LIT:3> : return m_controlData . stick2Buttons ; case <NUM_LIT:4> : return m_controlData . stick3Buttons ; default : return <NUM_LIT:0> ; } } public double getAnalogIn ( final int channel ) { switch ( channel ) { case <NUM_LIT:1> : return kDSAnalogInScaling * m_controlData . analog1 ; case <NUM_LIT:2> : return kDSAnalogInScaling * m_controlData . analog2 ; case <NUM_LIT:3> : return kDSAnalogInScaling * m_controlData . analog3 ; case <NUM_LIT:4> : return kDSAnalogInScaling * m_controlData . analog4 ; default : return <NUM_LIT:0.0> ; } } public boolean getDigitalIn ( final int channel ) { return ( ( m_controlData . dsDigitalIn > > ( channel - <NUM_LIT:1> ) ) & <NUM_LIT> ) == <NUM_LIT> ; } public void setDigitalOut ( final int channel , final boolean value ) { m_digitalOut &= ~ ( <NUM_LIT> << ( channel - <NUM_LIT:1> ) ) ; m_digitalOut |= ( ( value ? <NUM_LIT:1> : <NUM_LIT:0> ) << ( channel - <NUM_LIT:1> ) ) ; } public boolean getDigitalOut ( final int channel ) { return ( ( m_digitalOut > > ( channel - <NUM_LIT:1> ) ) & <NUM_LIT> ) == <NUM_LIT> ; } public boolean isEnabled ( ) { return m_controlData . enabled ( ) ; } public boolean isDisabled ( ) { return ! m_controlData . enabled ( ) ; } public boolean isAutonomous ( ) { return m_controlData . autonomous ( ) ; } public boolean isOperatorControl ( ) { return ! m_controlData . autonomous ( ) ; } public synchronized boolean isNewControlData ( ) { boolean result = m_newControlData ; m_newControlData = false ; return result ; } public int getPacketNumber ( ) { return m_controlData . packetIndex ; } public Alliance getAlliance ( ) { switch ( m_controlData . dsID_Alliance ) { case '<CHAR_LIT>' : return Alliance . kRed ; case '<CHAR_LIT>' : return Alliance . kBlue ; default : return Alliance . kInvalid ; } } public int getLocation ( ) { return m_controlData . dsID_Position - '<CHAR_LIT:0>' ; } public void setDashboardPackerToUseHigh ( IDashboard dashboard ) { m_dashboardInUseHigh = dashboard ; } public Dashboard getDashboardPackerHigh ( ) { return m_dashboardDefaultHigh ; } public IDashboard getDashboardPackerInUseHigh ( ) { return m_dashboardInUseHigh ; } public void setDashboardPackerToUseLow ( IDashboard dashboard ) { m_dashboardInUseLow = dashboard ; } public Dashboard getDashboardPackerLow ( ) { return m_dashboardDefaultLow ; } public IDashboard getDashboardPackerInUseLow ( ) { return m_dashboardInUseLow ; } public Object getStatusDataMonitor ( ) { return m_semaphore ; } void incrementUpdateNumber ( ) { synchronized ( m_semaphore ) { m_updateNumber ++ ; } } public boolean isFMSAttached ( ) { return ( m_controlData . control & FRCCommonControlData . FMS_ATTATCHED ) > <NUM_LIT:0> ; } public DriverStationEnhancedIO getEnhancedIO ( ) { return m_enhancedIO ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . IUtility ; import edu . wpi . first . wpilibj . util . BoundaryException ; import java . util . TimerTask ; public class PIDController implements IUtility { public static final double kDefaultPeriod = <NUM_LIT> ; private double m_P ; private double m_I ; private double m_D ; private double m_maximumOutput = <NUM_LIT:1.0> ; private double m_minimumOutput = - <NUM_LIT:1.0> ; private double m_maximumInput = <NUM_LIT:0.0> ; private double m_minimumInput = <NUM_LIT:0.0> ; private boolean m_continuous = false ; private boolean m_enabled = false ; private double m_prevError = <NUM_LIT:0.0> ; private double m_totalError = <NUM_LIT:0.0> ; private double m_tolerance = <NUM_LIT> ; private double m_setpoint = <NUM_LIT:0.0> ; private double m_error = <NUM_LIT:0.0> ; private double m_result = <NUM_LIT:0.0> ; private double m_period = kDefaultPeriod ; PIDSource m_pidInput ; PIDOutput m_pidOutput ; java . util . Timer m_controlLoop ; private class PIDTask extends TimerTask { private PIDController m_controller ; public PIDTask ( PIDController controller ) { if ( controller == null ) { throw new NullPointerException ( "<STR_LIT>" ) ; } m_controller = controller ; } public void run ( ) { m_controller . calculate ( ) ; } } public PIDController ( double Kp , double Ki , double Kd , PIDSource source , PIDOutput output , double period ) { if ( source == null ) throw new NullPointerException ( "<STR_LIT>" ) ; if ( output == null ) throw new NullPointerException ( "<STR_LIT>" ) ; m_controlLoop = new java . util . Timer ( ) ; m_P = Kp ; m_I = Ki ; m_D = Kd ; m_pidInput = source ; m_pidOutput = output ; m_period = period ; m_controlLoop . schedule ( new PIDTask ( this ) , <NUM_LIT> , ( long ) ( m_period * <NUM_LIT:1000> ) ) ; } public PIDController ( double Kp , double Ki , double Kd , PIDSource source , PIDOutput output ) { this ( Kp , Ki , Kd , source , output , kDefaultPeriod ) ; } protected void free ( ) { m_controlLoop . cancel ( ) ; m_controlLoop = null ; } private void calculate ( ) { boolean enabled ; PIDSource pidInput ; synchronized ( this ) { if ( m_pidInput == null ) { return ; } if ( m_pidOutput == null ) { return ; } enabled = m_enabled ; pidInput = m_pidInput ; } if ( enabled ) { double input = pidInput . pidGet ( ) ; double result ; PIDOutput pidOutput = null ; synchronized ( this ) { m_error = m_setpoint - input ; if ( m_continuous ) { if ( Math . abs ( m_error ) > ( m_maximumInput - m_minimumInput ) / <NUM_LIT:2> ) { if ( m_error > <NUM_LIT:0> ) { m_error = m_error - m_maximumInput + m_minimumInput ; } else { m_error = m_error + m_maximumInput - m_minimumInput ; } } } if ( ( ( m_totalError + m_error ) * m_I < m_maximumOutput ) && ( ( m_totalError + m_error ) * m_I > m_minimumOutput ) ) { m_totalError += m_error ; } m_result = ( m_P * m_error + m_I * m_totalError + m_D * ( m_error - m_prevError ) ) ; m_prevError = m_error ; if ( m_result > m_maximumOutput ) { m_result = m_maximumOutput ; } else if ( m_result < m_minimumOutput ) { m_result = m_minimumOutput ; } pidOutput = m_pidOutput ; result = m_result ; } pidOutput . pidWrite ( result ) ; } } public synchronized void setPID ( double p , double i , double d ) { m_P = p ; m_I = i ; m_D = d ; } public double getP ( ) { return m_P ; } public double getI ( ) { return m_I ; } public synchronized double getD ( ) { return m_D ; } public synchronized double get ( ) { return m_result ; } public synchronized void setContinuous ( boolean continuous ) { m_continuous = continuous ; } public synchronized void setContinuous ( ) { this . setContinuous ( true ) ; } public synchronized void setInputRange ( double minimumInput , double maximumInput ) { if ( minimumInput > maximumInput ) { throw new BoundaryException ( "<STR_LIT>" ) ; } m_minimumInput = minimumInput ; m_maximumInput = maximumInput ; setSetpoint ( m_setpoint ) ; } public synchronized void setOutputRange ( double minimumOutput , double maximumOutput ) { if ( minimumOutput > maximumOutput ) { throw new BoundaryException ( "<STR_LIT>" ) ; } m_minimumOutput = minimumOutput ; m_maximumOutput = maximumOutput ; } public synchronized void setSetpoint ( double setpoint ) { if ( m_maximumInput > m_minimumInput ) { if ( setpoint > m_maximumInput ) { m_setpoint = m_maximumInput ; } else if ( setpoint < m_minimumInput ) { m_setpoint = m_minimumInput ; } else { m_setpoint = setpoint ; } } else { m_setpoint = setpoint ; } } public synchronized double getSetpoint ( ) { return m_setpoint ; } public synchronized double getError ( ) { return m_error ; } public synchronized void setTolerance ( double percent ) { m_tolerance = percent ; } public synchronized boolean onTarget ( ) { return ( Math . abs ( m_error ) < m_tolerance / <NUM_LIT:100> * ( m_maximumInput - m_minimumInput ) ) ; } public synchronized void enable ( ) { m_enabled = true ; } public synchronized void disable ( ) { m_pidOutput . pidWrite ( <NUM_LIT:0> ) ; m_enabled = false ; } public synchronized boolean isEnable ( ) { return m_enabled ; } public synchronized void reset ( ) { disable ( ) ; m_prevError = <NUM_LIT:0> ; m_totalError = <NUM_LIT:0> ; m_result = <NUM_LIT:0> ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class DoubleSolenoid extends SolenoidBase { public static class Value { public final int value ; public static final int kOff_val = <NUM_LIT:0> ; public static final int kForward_val = <NUM_LIT:1> ; public static final int kReverse_val = <NUM_LIT:2> ; public static final Value kOff = new Value ( kOff_val ) ; public static final Value kForward = new Value ( kForward_val ) ; public static final Value kReverse = new Value ( kReverse_val ) ; private Value ( int value ) { this . value = value ; } } private int m_forwardChannel ; private int m_reverseChannel ; private byte m_forwardMask ; private byte m_reverseMask ; private synchronized void initSolenoid ( ) { checkSolenoidModule ( m_chassisSlot ) ; checkSolenoidChannel ( m_forwardChannel ) ; checkSolenoidChannel ( m_reverseChannel ) ; try { m_allocated . allocate ( slotToIndex ( m_chassisSlot ) * kSolenoidChannels + m_forwardChannel - <NUM_LIT:1> ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + m_forwardChannel + "<STR_LIT>" + m_chassisSlot + "<STR_LIT>" ) ; } try { m_allocated . allocate ( slotToIndex ( m_chassisSlot ) * kSolenoidChannels + m_reverseChannel - <NUM_LIT:1> ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + m_reverseChannel + "<STR_LIT>" + m_chassisSlot + "<STR_LIT>" ) ; } m_forwardMask = ( byte ) ( <NUM_LIT:1> << ( m_forwardChannel - <NUM_LIT:1> ) ) ; m_reverseMask = ( byte ) ( <NUM_LIT:1> << ( m_reverseChannel - <NUM_LIT:1> ) ) ; } public DoubleSolenoid ( final int forwardChannel , final int reverseChannel ) { super ( getDefaultSolenoidModule ( ) ) ; m_forwardChannel = forwardChannel ; m_reverseChannel = reverseChannel ; initSolenoid ( ) ; } public DoubleSolenoid ( final int slot , final int forwardChannel , final int reverseChannel ) { super ( slot ) ; m_forwardChannel = forwardChannel ; m_reverseChannel = reverseChannel ; initSolenoid ( ) ; } protected synchronized void free ( ) { m_allocated . free ( slotToIndex ( m_chassisSlot ) * kSolenoidChannels + m_forwardChannel - <NUM_LIT:1> ) ; m_allocated . free ( slotToIndex ( m_chassisSlot ) * kSolenoidChannels + m_reverseChannel - <NUM_LIT:1> ) ; } public void set ( final Value value ) { byte rawValue = <NUM_LIT:0> ; switch ( value . value ) { case Value . kOff_val : rawValue = <NUM_LIT:0x00> ; break ; case Value . kForward_val : rawValue = m_forwardMask ; break ; case Value . kReverse_val : rawValue = m_reverseMask ; break ; } set ( rawValue , m_forwardMask | m_reverseMask ) ; } public Value get ( ) { byte value = getAll ( ) ; if ( ( value & m_forwardMask ) != <NUM_LIT:0> ) return Value . kForward ; if ( ( value & m_reverseMask ) != <NUM_LIT:0> ) return Value . kReverse ; return Value . kOff ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . communication . FRCControl ; import javax . microedition . midlet . MIDlet ; import javax . microedition . midlet . MIDletStateChangeException ; public abstract class RobotBase extends MIDlet { public static final int ROBOT_TASK_PRIORITY = <NUM_LIT> ; public final static String ERRORS_TO_DRIVERSTATION_PROP = "<STR_LIT>" ; protected final DriverStation m_ds ; private final Watchdog m_watchdog = Watchdog . getInstance ( ) ; protected RobotBase ( ) { m_ds = DriverStation . getInstance ( ) ; m_watchdog . setEnabled ( false ) ; } protected void free ( ) { } public boolean isSystemActive ( ) { return m_watchdog . isSystemActive ( ) ; } public Watchdog getWatchdog ( ) { return m_watchdog ; } public boolean isDisabled ( ) { return m_ds . isDisabled ( ) ; } public boolean isEnabled ( ) { return m_ds . isEnabled ( ) ; } public boolean isAutonomous ( ) { return m_ds . isAutonomous ( ) ; } public boolean isOperatorControl ( ) { return m_ds . isOperatorControl ( ) ; } public boolean isNewDataAvailable ( ) { return m_ds . isNewControlData ( ) ; } public abstract void startCompetition ( ) ; public static boolean getBooleanProperty ( String name , boolean defaultValue ) { String propVal = System . getProperty ( name ) ; if ( propVal == null ) { return defaultValue ; } if ( propVal . equalsIgnoreCase ( "<STR_LIT:false>" ) ) { return false ; } else if ( propVal . equalsIgnoreCase ( "<STR_LIT:true>" ) ) { return true ; } else { throw new IllegalStateException ( propVal ) ; } } protected final void startApp ( ) throws MIDletStateChangeException { boolean errorOnExit = false ; Watchdog . getInstance ( ) . setExpiration ( <NUM_LIT> ) ; Watchdog . getInstance ( ) . setEnabled ( false ) ; FRCControl . observeUserProgramStarting ( ) ; try { this . startCompetition ( ) ; } catch ( Throwable t ) { t . printStackTrace ( ) ; errorOnExit = true ; } finally { System . err . println ( "<STR_LIT>" ) ; if ( errorOnExit ) { System . err . println ( "<STR_LIT>" ) ; } else { System . err . println ( "<STR_LIT>" ) ; } } } protected final void pauseApp ( ) { } protected final void destroyApp ( boolean unconditional ) throws MIDletStateChangeException { } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . parsing . ISensor ; public class GearTooth extends Counter implements ISensor { private static final double kGearToothThreshold = <NUM_LIT> ; public void enableDirectionSensing ( boolean directionSensitive ) { if ( directionSensitive ) { setPulseLengthMode ( kGearToothThreshold ) ; } } public GearTooth ( final int channel , boolean directionSensitive ) { super ( channel ) ; enableDirectionSensing ( directionSensitive ) ; } public GearTooth ( final int channel ) { this ( channel , false ) ; } public GearTooth ( final int slot , final int channel , boolean directionSensitive ) { super ( slot , channel ) ; enableDirectionSensing ( directionSensitive ) ; } public GearTooth ( final int slot , final int channel ) { this ( slot , channel , false ) ; } public GearTooth ( DigitalSource source , boolean directionSensitive ) { super ( source ) ; enableDirectionSensing ( directionSensitive ) ; } public GearTooth ( DigitalSource source ) { this ( source , false ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj ; import edu . wpi . first . wpilibj . fpga . tDIO ; import edu . wpi . first . wpilibj . util . AllocationException ; import edu . wpi . first . wpilibj . util . CheckedAllocationException ; public class PWM extends SensorBase { private static Resource allocated = new Resource ( ( tDIO . kNumSystems * kPwmChannels ) ) ; public static class PeriodMultiplier { public final int value ; static final int k1X_val = <NUM_LIT:1> ; static final int k2X_val = <NUM_LIT:2> ; static final int k4X_val = <NUM_LIT:4> ; public static final PeriodMultiplier k1X = new PeriodMultiplier ( k1X_val ) ; public static final PeriodMultiplier k2X = new PeriodMultiplier ( k2X_val ) ; public static final PeriodMultiplier k4X = new PeriodMultiplier ( k4X_val ) ; private PeriodMultiplier ( int value ) { this . value = value ; } } private int m_channel ; private DigitalModule m_module ; protected static final int kDefaultPwmPeriod = <NUM_LIT> ; protected static final int kDefaultMinPwmHigh = <NUM_LIT> ; public static final int kPwmDisabled = <NUM_LIT:0> ; boolean m_eliminateDeadband ; int m_maxPwm ; int m_deadbandMaxPwm ; int m_centerPwm ; int m_deadbandMinPwm ; int m_minPwm ; private void initPWM ( final int slot , final int channel ) { checkPWMModule ( slot ) ; checkPWMChannel ( channel ) ; try { allocated . allocate ( DigitalModule . slotToIndex ( slot ) * kPwmChannels + channel - <NUM_LIT:1> ) ; } catch ( CheckedAllocationException e ) { throw new AllocationException ( "<STR_LIT>" + channel + "<STR_LIT>" + slot + "<STR_LIT>" ) ; } m_channel = channel ; m_module = DigitalModule . getInstance ( slot ) ; m_module . setPWM ( m_channel , kPwmDisabled ) ; m_eliminateDeadband = false ; } public PWM ( final int slot , final int channel ) { initPWM ( slot , channel ) ; } public PWM ( final int channel ) { initPWM ( getDefaultDigitalModule ( ) , channel ) ; } protected void free ( ) { m_module . setPWM ( m_channel , kPwmDisabled ) ; allocated . free ( DigitalModule . slotToIndex ( m_module . getSlot ( ) ) * kPwmChannels + m_channel - <NUM_LIT:1> ) ; } public void enableDeadbandElimination ( boolean eliminateDeadband ) { m_eliminateDeadband = eliminateDeadband ; } public void setBounds ( final int max , final int deadbandMax , final int center , final int deadbandMin , final int min ) { m_maxPwm = max ; m_deadbandMaxPwm = deadbandMax ; m_centerPwm = center ; m_deadbandMinPwm = deadbandMin ; m_minPwm = min ; } public void setPosition ( double pos ) { if ( pos < <NUM_LIT:0.0> ) { pos = <NUM_LIT:0.0> ; } else if ( pos > <NUM_LIT:1.0> ) { pos = <NUM_LIT:1.0> ; } int rawValue ; rawValue = ( int ) ( ( pos * ( double ) getFullRangeScaleFactor ( ) ) + getMinNegativePwm ( ) ) ; setRaw ( rawValue ) ; } public double getPosition ( ) { int value = getRaw ( ) ; if ( value < getMinNegativePwm ( ) ) { return <NUM_LIT:0.0> ; } else if ( value > getMaxPositivePwm ( ) ) { return <NUM_LIT:1.0> ; } else { return ( double ) ( value - getMinNegativePwm ( ) ) / ( double ) getFullRangeScaleFactor ( ) ; } } final void setSpeed ( double speed ) { if ( speed < - <NUM_LIT:1.0> ) { speed = - <NUM_LIT:1.0> ; } else if ( speed > <NUM_LIT:1.0> ) { speed = <NUM_LIT:1.0> ; } int rawValue ; if ( speed == <NUM_LIT:0.0> ) { rawValue = getCenterPwm ( ) ; } else if ( speed > <NUM_LIT:0.0> ) { rawValue = ( int ) ( speed * ( ( double ) getPositiveScaleFactor ( ) ) + ( ( double ) getMinPositivePwm ( ) ) + <NUM_LIT> ) ; } else { rawValue = ( int ) ( speed * ( ( double ) getNegativeScaleFactor ( ) ) + ( ( double ) getMaxNegativePwm ( ) ) + <NUM_LIT> ) ; } setRaw ( rawValue ) ; } public double getSpeed ( ) { int value = getRaw ( ) ; if ( value > getMaxPositivePwm ( ) ) { return <NUM_LIT:1.0> ; } else if ( value < getMinNegativePwm ( ) ) { return - <NUM_LIT:1.0> ; } else if ( value > getMinPositivePwm ( ) ) { return ( double ) ( value - getMinPositivePwm ( ) ) / ( double ) getPositiveScaleFactor ( ) ; } else if ( value < getMaxNegativePwm ( ) ) { return ( double ) ( value - getMaxNegativePwm ( ) ) / ( double ) getNegativeScaleFactor ( ) ; } else { return <NUM_LIT:0.0> ; } } public void setRaw ( int value ) { m_module . setPWM ( m_channel , value ) ; } public int getRaw ( ) { return m_module . getPWM ( m_channel ) ; } public void setPeriodMultiplier ( PeriodMultiplier mult ) { switch ( mult . value ) { case PeriodMultiplier . k4X_val : m_module . setPWMPeriodScale ( m_channel , <NUM_LIT:3> ) ; break ; case PeriodMultiplier . k2X_val : m_module . setPWMPeriodScale ( m_channel , <NUM_LIT:1> ) ; break ; case PeriodMultiplier . k1X_val : m_module . setPWMPeriodScale ( m_channel , <NUM_LIT:0> ) ; break ; default : } } private int getMaxPositivePwm ( ) { return m_maxPwm ; } ; private int getMinPositivePwm ( ) { return m_eliminateDeadband ? m_deadbandMaxPwm : m_centerPwm + <NUM_LIT:1> ; } ; private int getCenterPwm ( ) { return m_centerPwm ; } ; private int getMaxNegativePwm ( ) { return m_eliminateDeadband ? m_deadbandMinPwm : m_centerPwm - <NUM_LIT:1> ; } ; private int getMinNegativePwm ( ) { return m_minPwm ; } ; private int getPositiveScaleFactor ( ) { return getMaxPositivePwm ( ) - getMinPositivePwm ( ) ; } private int getNegativeScaleFactor ( ) { return getMaxNegativePwm ( ) - getMinNegativePwm ( ) ; } private int getFullRangeScaleFactor ( ) { return getMaxPositivePwm ( ) - getMinNegativePwm ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; public class CANInvalidBufferException extends RuntimeException { public CANInvalidBufferException ( ) { super ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; import com . sun . cldc . jna . * ; import com . sun . cldc . jna . ptr . IntByReference ; import edu . wpi . first . wpilibj . communication . Semaphore ; public class JaguarCANDriver { public static final int kMaxMessageDataSize = <NUM_LIT:8> ; private static final TaskExecutor taskExecutor = new TaskExecutor ( "<STR_LIT>" ) ; private static final Function sendMessageFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public static void sendMessage ( int messageID , byte [ ] data , int dataSize ) throws CANTimeoutException { Pointer sendDataBufferPointer = new Pointer ( kMaxMessageDataSize ) ; sendDataBufferPointer . setBytes ( <NUM_LIT:0> , data , <NUM_LIT:0> , dataSize ) ; IntByReference sendStatus = new IntByReference ( <NUM_LIT:0> ) ; sendStatus . setValue ( <NUM_LIT:0> ) ; sendMessageFn . call4 ( messageID , sendDataBufferPointer , dataSize , sendStatus . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ) ; int statusValue = sendStatus . getValue ( ) ; sendStatus . free ( ) ; sendDataBufferPointer . free ( ) ; CANExceptionFactory . checkStatus ( statusValue , messageID ) ; } private static final BlockingFunction receiveMessageFn = NativeLibrary . getDefaultInstance ( ) . getBlockingFunction ( "<STR_LIT>" ) ; public int receivedMessageId ; static { receiveMessageFn . setTaskExecutor ( taskExecutor ) ; } public byte receiveMessage ( int messageID , byte [ ] data , double timeout ) throws CANTimeoutException { byte dataSize = <NUM_LIT:0> ; IntByReference recvStatus = new IntByReference ( <NUM_LIT:0> ) ; recvStatus . setValue ( <NUM_LIT:0> ) ; Pointer messageIdPtr = new Pointer ( <NUM_LIT:4> ) ; messageIdPtr . setInt ( <NUM_LIT:0> , messageID ) ; Pointer dataSizePtr = new Pointer ( <NUM_LIT:1> ) ; dataSizePtr . setByte ( <NUM_LIT:0> , ( byte ) <NUM_LIT:0> ) ; Pointer recvDataBufferPointer = new Pointer ( kMaxMessageDataSize ) ; receiveMessageFn . call5 ( messageIdPtr , recvDataBufferPointer , dataSizePtr , ( int ) ( timeout * <NUM_LIT> ) , recvStatus . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ) ; int statusValue = recvStatus . getValue ( ) ; if ( statusValue >= <NUM_LIT:0> ) { dataSize = dataSizePtr . getByte ( <NUM_LIT:0> ) ; receivedMessageId = messageIdPtr . getInt ( <NUM_LIT:0> ) ; recvDataBufferPointer . getBytes ( <NUM_LIT:0> , data , <NUM_LIT:0> , data . length < dataSize ? data . length : dataSize ) ; } recvDataBufferPointer . free ( ) ; dataSizePtr . free ( ) ; messageIdPtr . free ( ) ; recvStatus . free ( ) ; CANExceptionFactory . checkStatus ( statusValue , messageID ) ; return dataSize ; } public byte receiveMessage ( int messageID , byte [ ] data ) throws CANTimeoutException { return receiveMessage ( messageID , data , <NUM_LIT> ) ; } private static final Function receiveMessageStart_semFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public boolean receiveMessageStart ( int messageID , Semaphore sem , double timeout ) throws CANTimeoutException { int retVal = <NUM_LIT:0> ; IntByReference recvStatus = new IntByReference ( <NUM_LIT:0> ) ; recvStatus . setValue ( <NUM_LIT:0> ) ; retVal = receiveMessageStart_semFn . call4 ( messageID , sem . getPointer ( ) , ( int ) ( timeout * <NUM_LIT> ) , recvStatus . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ) ; int statusValue = recvStatus . getValue ( ) ; recvStatus . free ( ) ; CANExceptionFactory . checkStatus ( statusValue , messageID ) ; return retVal != <NUM_LIT:0> ; } private static final Function receiveMessageCompleteFn = NativeLibrary . getDefaultInstance ( ) . getFunction ( "<STR_LIT>" ) ; public byte receiveMessageComplete ( int messageID , byte [ ] data ) throws CANTimeoutException { byte dataSize = <NUM_LIT:0> ; IntByReference recvStatus = new IntByReference ( <NUM_LIT:0> ) ; recvStatus . setValue ( <NUM_LIT:0> ) ; Pointer messageIdPtr = new Pointer ( <NUM_LIT:4> ) ; messageIdPtr . setInt ( <NUM_LIT:0> , messageID ) ; Pointer dataSizePtr = new Pointer ( <NUM_LIT:1> ) ; dataSizePtr . setByte ( <NUM_LIT:0> , ( byte ) <NUM_LIT:0> ) ; Pointer recvDataBufferPointer = new Pointer ( kMaxMessageDataSize ) ; receiveMessageCompleteFn . call4 ( messageIdPtr , recvDataBufferPointer , dataSizePtr , recvStatus . getPointer ( ) . address ( ) . toUWord ( ) . toPrimitive ( ) ) ; int statusValue = recvStatus . getValue ( ) ; if ( statusValue >= <NUM_LIT:0> ) { dataSize = dataSizePtr . getByte ( <NUM_LIT:0> ) ; receivedMessageId = messageIdPtr . getInt ( <NUM_LIT:0> ) ; recvDataBufferPointer . getBytes ( <NUM_LIT:0> , data , <NUM_LIT:0> , data . length < dataSize ? data . length : dataSize ) ; } recvDataBufferPointer . free ( ) ; dataSizePtr . free ( ) ; messageIdPtr . free ( ) ; recvStatus . free ( ) ; CANExceptionFactory . checkStatus ( statusValue , messageID ) ; return dataSize ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; public class CANJaguarVersionException extends RuntimeException { public static final int kMinLegalFIRSTFirmwareVersion = <NUM_LIT> ; public static final int kMinRDKFirmwareVersion = <NUM_LIT> ; public CANJaguarVersionException ( int deviceNumber , int fwVersion ) { super ( getString ( deviceNumber , fwVersion ) ) ; System . out . println ( "<STR_LIT>" + deviceNumber + "<STR_LIT>" + fwVersion ) ; } static String getString ( int deviceNumber , int fwVersion ) { String msg ; if ( fwVersion < kMinRDKFirmwareVersion ) { msg = "<STR_LIT>" + deviceNumber + "<STR_LIT>" + Integer . toString ( kMinLegalFIRSTFirmwareVersion ) + "<STR_LIT>" ; } else { msg = "<STR_LIT>" + deviceNumber + "<STR_LIT>" + Integer . toString ( kMinLegalFIRSTFirmwareVersion ) + "<STR_LIT>" ; } return msg ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; public class CANNotInitializedException extends RuntimeException { public CANNotInitializedException ( ) { super ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; public class JaguarCANProtocol { public static final int CAN_MSGID_FULL_M = <NUM_LIT> ; public static final int CAN_MSGID_DEVNO_M = <NUM_LIT> ; public static final int CAN_MSGID_API_M = <NUM_LIT> ; public static final int CAN_MSGID_MFR_M = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_M = <NUM_LIT> ; public static final int CAN_MSGID_DEVNO_S = <NUM_LIT:0> ; public static final int CAN_MSGID_API_S = <NUM_LIT:6> ; public static final int CAN_MSGID_MFR_S = <NUM_LIT:16> ; public static final int CAN_MSGID_DTYPE_S = <NUM_LIT:24> ; public static final int CAN_MSGID_DEVNO_BCAST = <NUM_LIT> ; public static final int CAN_MSGID_API_SYSHALT = <NUM_LIT> ; public static final int CAN_MSGID_API_SYSRST = <NUM_LIT> ; public static final int CAN_MSGID_API_DEVASSIGN = <NUM_LIT> ; public static final int CAN_MSGID_API_DEVQUERY = <NUM_LIT> ; public static final int CAN_MSGID_API_HEARTBEAT = <NUM_LIT> ; public static final int CAN_MSGID_API_SYNC = <NUM_LIT> ; public static final int CAN_MSGID_API_UPDATE = <NUM_LIT> ; public static final int CAN_MSGID_API_FIRMVER = <NUM_LIT> ; public static final int CAN_MSGID_API_ENUMERATE = <NUM_LIT> ; public static final int CAN_MSGID_API_SYSRESUME = <NUM_LIT> ; public static final int CAN_STATUS_CODE_M = <NUM_LIT> ; public static final int CAN_STATUS_MFG_M = <NUM_LIT> ; public static final int CAN_STATUS_DTYPE_M = <NUM_LIT> ; public static final int CAN_STATUS_CODE_S = <NUM_LIT:0> ; public static final int CAN_STATUS_MFG_S = <NUM_LIT:16> ; public static final int CAN_STATUS_DTYPE_S = <NUM_LIT:24> ; public static final int CAN_MSGID_MFR_NI = <NUM_LIT> ; public static final int CAN_MSGID_MFR_LM = <NUM_LIT> ; public static final int CAN_MSGID_MFR_DEKA = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_BCAST = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_ROBOT = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_MOTOR = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_RELAY = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_GYRO = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_ACCEL = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_USONIC = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_GEART = <NUM_LIT> ; public static final int CAN_MSGID_DTYPE_UPDATE = <NUM_LIT> ; public static final int CAN_MSGID_API_CLASS_M = <NUM_LIT> ; public static final int CAN_MSGID_API_ID_M = <NUM_LIT> ; public static final int CAN_API_MC_VOLTAGE = <NUM_LIT> ; public static final int CAN_API_MC_SPD = <NUM_LIT> ; public static final int CAN_API_MC_VCOMP = <NUM_LIT> ; public static final int CAN_API_MC_POS = <NUM_LIT> ; public static final int CAN_API_MC_ICTRL = <NUM_LIT> ; public static final int CAN_API_MC_STATUS = <NUM_LIT> ; public static final int CAN_API_MC_CFG = <NUM_LIT> ; public static final int CAN_API_MC_ACK = <NUM_LIT> ; public static final int LM_API_VOLT = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_VOLTAGE ) ; public static final int LM_API_VOLT_EN = ( LM_API_VOLT | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_DIS = ( LM_API_VOLT | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_SET = ( LM_API_VOLT | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_SET_RAMP = ( LM_API_VOLT | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_T_EN = ( LM_API_VOLT | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_T_SET = ( LM_API_VOLT | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VOLT_RAMP_DIS = <NUM_LIT:0> ; public static final int LM_API_SYNC_PEND_NOW = <NUM_LIT:0> ; public static final int LM_API_SPD = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_SPD ) ; public static final int LM_API_SPD_EN = ( LM_API_SPD | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_DIS = ( LM_API_SPD | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_SET = ( LM_API_SPD | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_PC = ( LM_API_SPD | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_IC = ( LM_API_SPD | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_DC = ( LM_API_SPD | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_REF = ( LM_API_SPD | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_T_EN = ( LM_API_SPD | ( <NUM_LIT:7> << CAN_MSGID_API_S ) ) ; public static final int LM_API_SPD_T_SET = ( LM_API_SPD | ( <NUM_LIT:8> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_VCOMP ) ; public static final int LM_API_VCOMP_EN = ( LM_API_VCOMP | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_DIS = ( LM_API_VCOMP | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_SET = ( LM_API_VCOMP | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_IN_RAMP = ( LM_API_VCOMP | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_COMP_RAMP = ( LM_API_VCOMP | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_T_EN = ( LM_API_VCOMP | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_VCOMP_T_SET = ( LM_API_VCOMP | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_POS ) ; public static final int LM_API_POS_EN = ( LM_API_POS | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_DIS = ( LM_API_POS | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_SET = ( LM_API_POS | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_PC = ( LM_API_POS | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_IC = ( LM_API_POS | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_DC = ( LM_API_POS | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_REF = ( LM_API_POS | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_T_EN = ( LM_API_POS | ( <NUM_LIT:7> << CAN_MSGID_API_S ) ) ; public static final int LM_API_POS_T_SET = ( LM_API_POS | ( <NUM_LIT:8> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_ICTRL ) ; public static final int LM_API_ICTRL_EN = ( LM_API_ICTRL | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_DIS = ( LM_API_ICTRL | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_SET = ( LM_API_ICTRL | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_PC = ( LM_API_ICTRL | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_IC = ( LM_API_ICTRL | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_DC = ( LM_API_ICTRL | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_T_EN = ( LM_API_ICTRL | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ICTRL_T_SET = ( LM_API_ICTRL | ( <NUM_LIT:7> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_UPDATE ) ; public static final int LM_API_UPD_PING = ( LM_API_UPD | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD_DOWNLOAD = ( LM_API_UPD | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD_SEND_DATA = ( LM_API_UPD | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD_RESET = ( LM_API_UPD | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD_ACK = ( LM_API_UPD | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_HWVER = ( LM_API_UPD | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UPD_REQUEST = ( LM_API_UPD | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_UNTRUST_EN = ( LM_API_UPD | ( <NUM_LIT:11> << CAN_MSGID_API_S ) ) ; public static final int LM_API_TRUST_EN = ( LM_API_UPD | ( <NUM_LIT:12> << CAN_MSGID_API_S ) ) ; public static final int LM_API_TRUST_HEARTBEAT = ( LM_API_UPD | ( <NUM_LIT> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_STATUS ) ; public static final int LM_API_STATUS_VOLTOUT = ( LM_API_STATUS | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_VOLTBUS = ( LM_API_STATUS | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_CURRENT = ( LM_API_STATUS | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_TEMP = ( LM_API_STATUS | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_POS = ( LM_API_STATUS | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_SPD = ( LM_API_STATUS | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_LIMIT = ( LM_API_STATUS | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_FAULT = ( LM_API_STATUS | ( <NUM_LIT:7> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_POWER = ( LM_API_STATUS | ( <NUM_LIT:8> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_CMODE = ( LM_API_STATUS | ( <NUM_LIT:9> << CAN_MSGID_API_S ) ) ; public static final int LM_API_STATUS_VOUT = ( LM_API_STATUS | ( <NUM_LIT:10> << CAN_MSGID_API_S ) ) ; public static final int LM_STATUS_LIMIT_FWD = <NUM_LIT> ; public static final int LM_STATUS_LIMIT_REV = <NUM_LIT> ; public static final int LM_STATUS_FAULT_ILIMIT = <NUM_LIT> ; public static final int LM_STATUS_FAULT_TLIMIT = <NUM_LIT> ; public static final int LM_STATUS_FAULT_VLIMIT = <NUM_LIT> ; public static final int LM_API_CFG = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_CFG ) ; public static final int LM_API_CFG_NUM_BRUSHES = ( LM_API_CFG | ( <NUM_LIT:0> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_ENC_LINES = ( LM_API_CFG | ( <NUM_LIT:1> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_POT_TURNS = ( LM_API_CFG | ( <NUM_LIT:2> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_BRAKE_COAST = ( LM_API_CFG | ( <NUM_LIT:3> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_LIMIT_MODE = ( LM_API_CFG | ( <NUM_LIT:4> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_LIMIT_FWD = ( LM_API_CFG | ( <NUM_LIT:5> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_LIMIT_REV = ( LM_API_CFG | ( <NUM_LIT:6> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_MAX_VOUT = ( LM_API_CFG | ( <NUM_LIT:7> << CAN_MSGID_API_S ) ) ; public static final int LM_API_CFG_FAULT_TIME = ( LM_API_CFG | ( <NUM_LIT:8> << CAN_MSGID_API_S ) ) ; public static final int LM_API_ACK = ( CAN_MSGID_MFR_LM | CAN_MSGID_DTYPE_MOTOR | CAN_API_MC_ACK ) ; public static final int LM_HWVER_UNKNOWN = <NUM_LIT:0x00> ; public static final int LM_HWVER_JAG_1_0 = <NUM_LIT> ; public static final int LM_HWVER_JAG_2_0 = <NUM_LIT> ; public static final int LM_STATUS_CMODE_VOLT = <NUM_LIT:0x00> ; public static final int LM_STATUS_CMODE_CURRENT = <NUM_LIT> ; public static final int LM_STATUS_CMODE_SPEED = <NUM_LIT> ; public static final int LM_STATUS_CMODE_POS = <NUM_LIT> ; public static final int LM_STATUS_CMODE_VCOMP = <NUM_LIT> ; public static final int LM_REF_ENCODER = <NUM_LIT:0x00> ; public static final int LM_REF_POT = <NUM_LIT> ; public static final int LM_REF_INV_ENCODER = <NUM_LIT> ; public static final int LM_REF_QUAD_ENCODER = <NUM_LIT> ; public static final int LM_REF_NONE = <NUM_LIT> ; public static final int LM_FAULT_CURRENT = <NUM_LIT> ; public static final int LM_FAULT_TEMP = <NUM_LIT> ; public static final int LM_FAULT_VBUS = <NUM_LIT> ; public static final int LM_FAULT_GATE_DRIVE = <NUM_LIT> ; } </s>
|
<s> package edu . wpi . first . wpilibj . can ; public class CANMessageNotAllowedException extends RuntimeException { public CANMessageNotAllowedException ( String msg ) { super ( msg ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; import java . io . IOException ; public class CANTimeoutException extends IOException { public CANTimeoutException ( ) { super ( ) ; } } </s>
|
<s> package edu . wpi . first . wpilibj . can ; import com . ni . rio . NiRioStatus ; import edu . wpi . first . wpilibj . util . UncleanStatusException ; public class CANExceptionFactory { static final int ERR_JaguarCANDriver_InvalidBuffer = - <NUM_LIT> ; static final int ERR_JaguarCANDriver_TimedOut = - <NUM_LIT> ; static final int ERR_JaguarCANDriver_NotAllowed = - <NUM_LIT> ; static final int ERR_JaguarCANDriver_NotInitialized = - <NUM_LIT> ; public static void checkStatus ( int status , int messageID ) throws CANInvalidBufferException , CANTimeoutException , CANMessageNotAllowedException , CANNotInitializedException , UncleanStatusException { switch ( status ) { case NiRioStatus . kRioStatusSuccess : return ; case ERR_JaguarCANDriver_InvalidBuffer : case NiRioStatus . kRIOStatusBufferInvalidSize : throw new CANInvalidBufferException ( ) ; case ERR_JaguarCANDriver_TimedOut : case NiRioStatus . kRIOStatusOperationTimedOut : throw new CANTimeoutException ( ) ; case ERR_JaguarCANDriver_NotAllowed : case NiRioStatus . kRIOStatusFeatureNotSupported : throw new CANMessageNotAllowedException ( "<STR_LIT>" + Integer . toString ( messageID ) ) ; case ERR_JaguarCANDriver_NotInitialized : case NiRioStatus . kRIOStatusResourceNotInitialized : throw new CANNotInitializedException ( ) ; default : throw new UncleanStatusException ( "<STR_LIT>" + Integer . toString ( status ) ) ; } } } </s>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.