Adds JNI Simulator interface and updated Sim API (#1002)

The simulator was generated by https://github.com/ThadHouse/SimulatorGenerator
This commit is contained in:
Thad House
2018-05-11 12:38:23 -07:00
committed by Peter Johnson
parent 1046371349
commit 337e89cf6e
96 changed files with 8204 additions and 26 deletions

View File

@@ -86,10 +86,9 @@ void SimOnUnload(JavaVM * vm, void* reserved) {
}
}
//TODO: Add this back in
//static void ThrowSimException(JNIEnv* env) {
static void ThrowSimException(JNIEnv* env) {
//}
}
'''
out.println 'extern "C" {'
symbolList.each {

View File

@@ -0,0 +1,40 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class AccelerometerDataJNI extends JNIWrapper {
public static native int registerActiveCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelActiveCallback(int index, int uid);
public static native boolean getActive(int index);
public static native void setActive(int index, boolean active);
public static native int registerRangeCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelRangeCallback(int index, int uid);
public static native int getRange(int index);
public static native void setRange(int index, int range);
public static native int registerXCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelXCallback(int index, int uid);
public static native double getX(int index);
public static native void setX(int index, double x);
public static native int registerYCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelYCallback(int index, int uid);
public static native double getY(int index);
public static native void setY(int index, double y);
public static native int registerZCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelZCallback(int index, int uid);
public static native double getZ(int index);
public static native void setZ(int index, double z);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,30 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class AnalogGyroDataJNI extends JNIWrapper {
public static native int registerAngleCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAngleCallback(int index, int uid);
public static native double getAngle(int index);
public static native void setAngle(int index, double angle);
public static native int registerRateCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelRateCallback(int index, int uid);
public static native double getRate(int index);
public static native void setRate(int index, double rate);
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,60 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class AnalogInDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerAverageBitsCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAverageBitsCallback(int index, int uid);
public static native int getAverageBits(int index);
public static native void setAverageBits(int index, int averageBits);
public static native int registerOversampleBitsCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelOversampleBitsCallback(int index, int uid);
public static native int getOversampleBits(int index);
public static native void setOversampleBits(int index, int oversampleBits);
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelVoltageCallback(int index, int uid);
public static native double getVoltage(int index);
public static native void setVoltage(int index, double voltage);
public static native int registerAccumulatorInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAccumulatorInitializedCallback(int index, int uid);
public static native boolean getAccumulatorInitialized(int index);
public static native void setAccumulatorInitialized(int index, boolean accumulatorInitialized);
public static native int registerAccumulatorValueCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAccumulatorValueCallback(int index, int uid);
public static native long getAccumulatorValue(int index);
public static native void setAccumulatorValue(int index, long accumulatorValue);
public static native int registerAccumulatorCountCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAccumulatorCountCallback(int index, int uid);
public static native long getAccumulatorCount(int index);
public static native void setAccumulatorCount(int index, long accumulatorCount);
public static native int registerAccumulatorCenterCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAccumulatorCenterCallback(int index, int uid);
public static native int getAccumulatorCenter(int index);
public static native void setAccumulatorCenter(int index, int AccumulatorCenter);
public static native int registerAccumulatorDeadbandCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelAccumulatorDeadbandCallback(int index, int uid);
public static native int getAccumulatorDeadband(int index);
public static native void setAccumulatorDeadband(int index, int AccumulatorDeadband);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,25 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class AnalogOutDataJNI extends JNIWrapper {
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelVoltageCallback(int index, int uid);
public static native double getVoltage(int index);
public static native void setVoltage(int index, double voltage);
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,30 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class AnalogTriggerDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerTriggerLowerBoundCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelTriggerLowerBoundCallback(int index, int uid);
public static native double getTriggerLowerBound(int index);
public static native void setTriggerLowerBound(int index, double triggerLowerBound);
public static native int registerTriggerUpperBoundCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelTriggerUpperBoundCallback(int index, int uid);
public static native double getTriggerUpperBound(int index);
public static native void setTriggerUpperBound(int index, double triggerUpperBound);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,40 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class DIODataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerValueCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelValueCallback(int index, int uid);
public static native boolean getValue(int index);
public static native void setValue(int index, boolean value);
public static native int registerPulseLengthCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPulseLengthCallback(int index, int uid);
public static native double getPulseLength(int index);
public static native void setPulseLength(int index, double pulseLength);
public static native int registerIsInputCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelIsInputCallback(int index, int uid);
public static native boolean getIsInput(int index);
public static native void setIsInput(int index, boolean isInput);
public static native int registerFilterIndexCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelFilterIndexCallback(int index, int uid);
public static native int getFilterIndex(int index);
public static native void setFilterIndex(int index, int filterIndex);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,30 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class DigitalPWMDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerDutyCycleCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelDutyCycleCallback(int index, int uid);
public static native double getDutyCycle(int index);
public static native void setDutyCycle(int index, double dutyCycle);
public static native int registerPinCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPinCallback(int index, int uid);
public static native int getPin(int index);
public static native void setPin(int index, int pin);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,54 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
import edu.wpi.first.wpilibj.hal.MatchInfoData;
public class DriverStationDataJNI extends JNIWrapper {
public static native int registerEnabledCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelEnabledCallback(int uid);
public static native boolean getEnabled();
public static native void setEnabled(boolean enabled);
public static native int registerAutonomousCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelAutonomousCallback(int uid);
public static native boolean getAutonomous();
public static native void setAutonomous(boolean autonomous);
public static native int registerTestCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelTestCallback(int uid);
public static native boolean getTest();
public static native void setTest(boolean test);
public static native int registerEStopCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelEStopCallback(int uid);
public static native boolean getEStop();
public static native void setEStop(boolean eStop);
public static native int registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelFmsAttachedCallback(int uid);
public static native boolean getFmsAttached();
public static native void setFmsAttached(boolean fmsAttached);
public static native int registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify);
public static native void cancelDsAttachedCallback(int uid);
public static native boolean getDsAttached();
public static native void setDsAttached(boolean dsAttached);
public static native void setJoystickAxes(byte joystickNum, float[] axesArray);
public static native void setJoystickPOVs(byte joystickNum, short[] povsArray);
public static native void setJoystickButtons(byte joystickNum, int buttons, int count);
public static native void setMatchInfo(MatchInfoData info);
public static native void registerAllCallbacks(NotifyCallback callback, boolean initialNotify);
public static native void notifyNewData();
public static native void resetData();
}

View File

@@ -0,0 +1,55 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class EncoderDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerCountCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCountCallback(int index, int uid);
public static native int getCount(int index);
public static native void setCount(int index, int count);
public static native int registerPeriodCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPeriodCallback(int index, int uid);
public static native double getPeriod(int index);
public static native void setPeriod(int index, double period);
public static native int registerResetCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelResetCallback(int index, int uid);
public static native boolean getReset(int index);
public static native void setReset(int index, boolean reset);
public static native int registerMaxPeriodCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelMaxPeriodCallback(int index, int uid);
public static native double getMaxPeriod(int index);
public static native void setMaxPeriod(int index, double maxPeriod);
public static native int registerDirectionCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelDirectionCallback(int index, int uid);
public static native boolean getDirection(int index);
public static native void setDirection(int index, boolean direction);
public static native int registerReverseDirectionCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelReverseDirectionCallback(int index, int uid);
public static native boolean getReverseDirection(int index);
public static native void setReverseDirection(int index, boolean reverseDirection);
public static native int registerSamplesToAverageCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelSamplesToAverageCallback(int index, int uid);
public static native int getSamplesToAverage(int index);
public static native void setSamplesToAverage(int index, int samplesToAverage);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,28 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.BufferCallback;
import edu.wpi.first.wpilibj.sim.ConstBufferCallback;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class I2CDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerReadCallback(int index, BufferCallback callback);
public static native void cancelReadCallback(int index, int uid);
public static native int registerWriteCallback(int index, ConstBufferCallback callback);
public static native void cancelWriteCallback(int index, int uid);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,53 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class PCMDataJNI extends JNIWrapper {
public static native int registerSolenoidInitializedCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void cancelSolenoidInitializedCallback(int index, int channel, int uid);
public static native boolean getSolenoidInitialized(int index, int channel);
public static native void setSolenoidInitialized(int index, int channel, boolean solenoidInitialized);
public static native int registerSolenoidOutputCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void cancelSolenoidOutputCallback(int index, int channel, int uid);
public static native boolean getSolenoidOutput(int index, int channel);
public static native void setSolenoidOutput(int index, int channel, boolean solenoidOutput);
public static native int registerCompressorInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCompressorInitializedCallback(int index, int uid);
public static native boolean getCompressorInitialized(int index);
public static native void setCompressorInitialized(int index, boolean compressorInitialized);
public static native int registerCompressorOnCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCompressorOnCallback(int index, int uid);
public static native boolean getCompressorOn(int index);
public static native void setCompressorOn(int index, boolean compressorOn);
public static native int registerClosedLoopEnabledCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelClosedLoopEnabledCallback(int index, int uid);
public static native boolean getClosedLoopEnabled(int index);
public static native void setClosedLoopEnabled(int index, boolean closeLoopEnabled);
public static native int registerPressureSwitchCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPressureSwitchCallback(int index, int uid);
public static native boolean getPressureSwitch(int index);
public static native void setPressureSwitch(int index, boolean pressureSwitch);
public static native int registerCompressorCurrentCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCompressorCurrentCallback(int index, int uid);
public static native double getCompressorCurrent(int index);
public static native void setCompressorCurrent(int index, double compressorCurrent);
public static native void registerAllNonSolenoidCallbacks(int index, NotifyCallback callback, boolean initialNotify);
public static native void registerAllSolenoidCallbacks(int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,36 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class PDPDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerTemperatureCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelTemperatureCallback(int index, int uid);
public static native double getTemperature(int index);
public static native void setTemperature(int index, double temperature);
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelVoltageCallback(int index, int uid);
public static native double getVoltage(int index);
public static native void setVoltage(int index, double voltage);
public static native int registerCurrentCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void cancelCurrentCallback(int index, int channel, int uid);
public static native double getCurrent(int index, int channel);
public static native void setCurrent(int index, int channel, double current);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class PWMDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerRawValueCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelRawValueCallback(int index, int uid);
public static native int getRawValue(int index);
public static native void setRawValue(int index, int rawValue);
public static native int registerSpeedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelSpeedCallback(int index, int uid);
public static native double getSpeed(int index);
public static native void setSpeed(int index, double speed);
public static native int registerPositionCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPositionCallback(int index, int uid);
public static native double getPosition(int index);
public static native void setPosition(int index, double position);
public static native int registerPeriodScaleCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPeriodScaleCallback(int index, int uid);
public static native int getPeriodScale(int index);
public static native void setPeriodScale(int index, int periodScale);
public static native int registerZeroLatchCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelZeroLatchCallback(int index, int uid);
public static native boolean getZeroLatch(int index);
public static native void setZeroLatch(int index, boolean zeroLatch);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,35 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class RelayDataJNI extends JNIWrapper {
public static native int registerInitializedForwardCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedForwardCallback(int index, int uid);
public static native boolean getInitializedForward(int index);
public static native void setInitializedForward(int index, boolean initializedForward);
public static native int registerInitializedReverseCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedReverseCallback(int index, int uid);
public static native boolean getInitializedReverse(int index);
public static native void setInitializedReverse(int index, boolean initializedReverse);
public static native int registerForwardCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelForwardCallback(int index, int uid);
public static native boolean getForward(int index);
public static native void setForward(int index, boolean forward);
public static native int registerReverseCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelReverseCallback(int index, int uid);
public static native boolean getReverse(int index);
public static native void setReverse(int index, boolean reverse);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,90 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class RoboRioDataJNI extends JNIWrapper {
public static native int registerFPGAButtonCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelFPGAButtonCallback(int index, int uid);
public static native boolean getFPGAButton(int index);
public static native void setFPGAButton(int index, boolean fPGAButton);
public static native int registerVInVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelVInVoltageCallback(int index, int uid);
public static native double getVInVoltage(int index);
public static native void setVInVoltage(int index, double vInVoltage);
public static native int registerVInCurrentCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelVInCurrentCallback(int index, int uid);
public static native double getVInCurrent(int index);
public static native void setVInCurrent(int index, double vInCurrent);
public static native int registerUserVoltage6VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserVoltage6VCallback(int index, int uid);
public static native double getUserVoltage6V(int index);
public static native void setUserVoltage6V(int index, double userVoltage6V);
public static native int registerUserCurrent6VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserCurrent6VCallback(int index, int uid);
public static native double getUserCurrent6V(int index);
public static native void setUserCurrent6V(int index, double userCurrent6V);
public static native int registerUserActive6VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserActive6VCallback(int index, int uid);
public static native boolean getUserActive6V(int index);
public static native void setUserActive6V(int index, boolean userActive6V);
public static native int registerUserVoltage5VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserVoltage5VCallback(int index, int uid);
public static native double getUserVoltage5V(int index);
public static native void setUserVoltage5V(int index, double userVoltage5V);
public static native int registerUserCurrent5VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserCurrent5VCallback(int index, int uid);
public static native double getUserCurrent5V(int index);
public static native void setUserCurrent5V(int index, double userCurrent5V);
public static native int registerUserActive5VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserActive5VCallback(int index, int uid);
public static native boolean getUserActive5V(int index);
public static native void setUserActive5V(int index, boolean userActive5V);
public static native int registerUserVoltage3V3Callback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserVoltage3V3Callback(int index, int uid);
public static native double getUserVoltage3V3(int index);
public static native void setUserVoltage3V3(int index, double userVoltage3V3);
public static native int registerUserCurrent3V3Callback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserCurrent3V3Callback(int index, int uid);
public static native double getUserCurrent3V3(int index);
public static native void setUserCurrent3V3(int index, double userCurrent3V3);
public static native int registerUserActive3V3Callback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserActive3V3Callback(int index, int uid);
public static native boolean getUserActive3V3(int index);
public static native void setUserActive3V3(int index, boolean userActive3V3);
public static native int registerUserFaults6VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserFaults6VCallback(int index, int uid);
public static native int getUserFaults6V(int index);
public static native void setUserFaults6V(int index, int userFaults6V);
public static native int registerUserFaults5VCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserFaults5VCallback(int index, int uid);
public static native int getUserFaults5V(int index);
public static native void setUserFaults5V(int index, int userFaults5V);
public static native int registerUserFaults3V3Callback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelUserFaults3V3Callback(int index, int uid);
public static native int getUserFaults3V3(int index);
public static native void setUserFaults3V3(int index, int userFaults3V3);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,40 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class SPIAccelerometerDataJNI extends JNIWrapper {
public static native int registerActiveCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelActiveCallback(int index, int uid);
public static native boolean getActive(int index);
public static native void setActive(int index, boolean active);
public static native int registerRangeCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelRangeCallback(int index, int uid);
public static native int getRange(int index);
public static native void setRange(int index, int range);
public static native int registerXCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelXCallback(int index, int uid);
public static native double getX(int index);
public static native void setX(int index, double x);
public static native int registerYCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelYCallback(int index, int uid);
public static native double getY(int index);
public static native void setY(int index, double y);
public static native int registerZCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelZCallback(int index, int uid);
public static native double getZ(int index);
public static native void setZ(int index, double z);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,32 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.sim.BufferCallback;
import edu.wpi.first.wpilibj.sim.ConstBufferCallback;
import edu.wpi.first.wpilibj.sim.NotifyCallback;
import edu.wpi.first.wpilibj.sim.SpiReadAutoReceiveBufferCallback;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class SPIDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerReadCallback(int index, BufferCallback callback);
public static native void cancelReadCallback(int index, int uid);
public static native int registerWriteCallback(int index, ConstBufferCallback callback);
public static native void cancelWriteCallback(int index, int uid);
public static native int registerReadAutoReceiveBufferCallback(int index, SpiReadAutoReceiveBufferCallback callback);
public static native void cancelReadAutoReceiveBufferCallback(int index, int uid);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,17 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.wpilibj.hal.JNIWrapper;
public class SimulatorJNI extends JNIWrapper {
public static native void waitForProgramStart();
public static native void setProgramStarted();
public static native void restartTiming();
public static native void resetHandles();
}

View File

@@ -0,0 +1,77 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.AccelerometerDataJNI;
public class AccelerometerSim {
private int m_index;
public AccelerometerSim() {
m_index = 0;
}
public CallbackStore registerActiveCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerActiveCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelActiveCallback);
}
public boolean getActive() {
return AccelerometerDataJNI.getActive(m_index);
}
public void setActive(boolean active) {
AccelerometerDataJNI.setActive(m_index, active);
}
public CallbackStore registerRangeCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerRangeCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelRangeCallback);
}
public int getRange() {
return AccelerometerDataJNI.getRange(m_index);
}
public void setRange(int range) {
AccelerometerDataJNI.setRange(m_index, range);
}
public CallbackStore registerXCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerXCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelXCallback);
}
public double getX() {
return AccelerometerDataJNI.getX(m_index);
}
public void setX(double x) {
AccelerometerDataJNI.setX(m_index, x);
}
public CallbackStore registerYCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerYCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelYCallback);
}
public double getY() {
return AccelerometerDataJNI.getY(m_index);
}
public void setY(double y) {
AccelerometerDataJNI.setY(m_index, y);
}
public CallbackStore registerZCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AccelerometerDataJNI.registerZCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AccelerometerDataJNI::cancelZCallback);
}
public double getZ() {
return AccelerometerDataJNI.getZ(m_index);
}
public void setZ(double z) {
AccelerometerDataJNI.setZ(m_index, z);
}
public void resetData() {
AccelerometerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,55 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.AnalogGyroDataJNI;
public class AnalogGyroSim {
private int m_index;
public AnalogGyroSim(int index) {
m_index = index;
}
public CallbackStore registerAngleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerAngleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelAngleCallback);
}
public double getAngle() {
return AnalogGyroDataJNI.getAngle(m_index);
}
public void setAngle(double angle) {
AnalogGyroDataJNI.setAngle(m_index, angle);
}
public CallbackStore registerRateCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerRateCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelRateCallback);
}
public double getRate() {
return AnalogGyroDataJNI.getRate(m_index);
}
public void setRate(double rate) {
AnalogGyroDataJNI.setRate(m_index, rate);
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogGyroDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogGyroDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogGyroDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogGyroDataJNI.setInitialized(m_index, initialized);
}
public void resetData() {
AnalogGyroDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,121 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.AnalogInDataJNI;
public class AnalogInSim {
private int m_index;
public AnalogInSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogInDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogInDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerAverageBitsCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAverageBitsCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAverageBitsCallback);
}
public int getAverageBits() {
return AnalogInDataJNI.getAverageBits(m_index);
}
public void setAverageBits(int averageBits) {
AnalogInDataJNI.setAverageBits(m_index, averageBits);
}
public CallbackStore registerOversampleBitsCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerOversampleBitsCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelOversampleBitsCallback);
}
public int getOversampleBits() {
return AnalogInDataJNI.getOversampleBits(m_index);
}
public void setOversampleBits(int oversampleBits) {
AnalogInDataJNI.setOversampleBits(m_index, oversampleBits);
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return AnalogInDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
AnalogInDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerAccumulatorInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorInitializedCallback);
}
public boolean getAccumulatorInitialized() {
return AnalogInDataJNI.getAccumulatorInitialized(m_index);
}
public void setAccumulatorInitialized(boolean accumulatorInitialized) {
AnalogInDataJNI.setAccumulatorInitialized(m_index, accumulatorInitialized);
}
public CallbackStore registerAccumulatorValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorValueCallback);
}
public long getAccumulatorValue() {
return AnalogInDataJNI.getAccumulatorValue(m_index);
}
public void setAccumulatorValue(long accumulatorValue) {
AnalogInDataJNI.setAccumulatorValue(m_index, accumulatorValue);
}
public CallbackStore registerAccumulatorCountCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorCountCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorCountCallback);
}
public long getAccumulatorCount() {
return AnalogInDataJNI.getAccumulatorCount(m_index);
}
public void setAccumulatorCount(long accumulatorCount) {
AnalogInDataJNI.setAccumulatorCount(m_index, accumulatorCount);
}
public CallbackStore registerAccumulatorCenterCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorCenterCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorCenterCallback);
}
public int getAccumulatorCenter() {
return AnalogInDataJNI.getAccumulatorCenter(m_index);
}
public void setAccumulatorCenter(int accumulatorCenter) {
AnalogInDataJNI.setAccumulatorCenter(m_index, accumulatorCenter);
}
public CallbackStore registerAccumulatorDeadbandCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogInDataJNI.registerAccumulatorDeadbandCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogInDataJNI::cancelAccumulatorDeadbandCallback);
}
public int getAccumulatorDeadband() {
return AnalogInDataJNI.getAccumulatorDeadband(m_index);
}
public void setAccumulatorDeadband(int accumulatorDeadband) {
AnalogInDataJNI.setAccumulatorDeadband(m_index, accumulatorDeadband);
}
public void resetData() {
AnalogInDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,44 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.AnalogOutDataJNI;
public class AnalogOutSim {
private int m_index;
public AnalogOutSim(int index) {
m_index = index;
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogOutDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogOutDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return AnalogOutDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
AnalogOutDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogOutDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogOutDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogOutDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogOutDataJNI.setInitialized(m_index, initialized);
}
public void resetData() {
AnalogOutDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,55 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.AnalogTriggerDataJNI;
public class AnalogTriggerSim {
private int m_index;
public AnalogTriggerSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AnalogTriggerDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AnalogTriggerDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerTriggerLowerBoundCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerTriggerLowerBoundCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelTriggerLowerBoundCallback);
}
public double getTriggerLowerBound() {
return AnalogTriggerDataJNI.getTriggerLowerBound(m_index);
}
public void setTriggerLowerBound(double triggerLowerBound) {
AnalogTriggerDataJNI.setTriggerLowerBound(m_index, triggerLowerBound);
}
public CallbackStore registerTriggerUpperBoundCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AnalogTriggerDataJNI.registerTriggerUpperBoundCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AnalogTriggerDataJNI::cancelTriggerUpperBoundCallback);
}
public double getTriggerUpperBound() {
return AnalogTriggerDataJNI.getTriggerUpperBound(m_index);
}
public void setTriggerUpperBound(double triggerUpperBound) {
AnalogTriggerDataJNI.setTriggerUpperBound(m_index, triggerUpperBound);
}
public void resetData() {
AnalogTriggerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,12 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
public interface BufferCallback {
void callback(String name, byte[] buffer, int count);
}

View File

@@ -0,0 +1,83 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import java.io.Closeable;
public class CallbackStore implements Closeable {
interface CancelCallbackFunc {
void cancel(int index, int uid);
}
interface CancelCallbackChannelFunc {
void cancel(int index, int channel, int uid);
}
interface CancelCallbackNoIndexFunc {
void cancel(int uid);
}
public CallbackStore(int index, int uid, CancelCallbackFunc ccf) {
this.cancelType = normalCancel;
this.index = index;
this.uid = uid;
this.cancelCallback = ccf;
}
public CallbackStore(int index, int channel, int uid, CancelCallbackChannelFunc ccf) {
this.cancelType = channelCancel;
this.index = index;
this.uid = uid;
this.channel = channel;
this.cancelCallbackChannel = ccf;
}
public CallbackStore(int uid, CancelCallbackNoIndexFunc ccf) {
this.cancelType = noIndexCancel;
this.uid = uid;
this.cancelCallbackNoIndex = ccf;
}
private int index;
private int channel;
private int uid;
private CancelCallbackFunc cancelCallback;
private CancelCallbackChannelFunc cancelCallbackChannel;
private CancelCallbackNoIndexFunc cancelCallbackNoIndex;
private static final int normalCancel = 0;
private static final int channelCancel = 1;
private static final int noIndexCancel = 2;
private int cancelType;
@Override
public void close() {
switch (cancelType) {
case normalCancel:
cancelCallback.cancel(index, uid);
break;
case channelCancel:
cancelCallbackChannel.cancel(index, channel, uid);
break;
case noIndexCancel:
cancelCallbackNoIndex.cancel(uid);
break;
}
cancelType = -1;
}
@Override
protected void finalize() throws Throwable {
try {
if (cancelType >= 0) {
close(); // close open files
}
} finally {
super.finalize();
}
}
}

View File

@@ -0,0 +1,12 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
public interface ConstBufferCallback {
void callback(String name, byte[] buffer, int count);
}

View File

@@ -0,0 +1,77 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.DIODataJNI;
public class DIOSim {
private int m_index;
public DIOSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DIODataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DIODataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelValueCallback);
}
public boolean getValue() {
return DIODataJNI.getValue(m_index);
}
public void setValue(boolean value) {
DIODataJNI.setValue(m_index, value);
}
public CallbackStore registerPulseLengthCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerPulseLengthCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelPulseLengthCallback);
}
public double getPulseLength() {
return DIODataJNI.getPulseLength(m_index);
}
public void setPulseLength(double pulseLength) {
DIODataJNI.setPulseLength(m_index, pulseLength);
}
public CallbackStore registerIsInputCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerIsInputCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelIsInputCallback);
}
public boolean getIsInput() {
return DIODataJNI.getIsInput(m_index);
}
public void setIsInput(boolean isInput) {
DIODataJNI.setIsInput(m_index, isInput);
}
public CallbackStore registerFilterIndexCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DIODataJNI.registerFilterIndexCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DIODataJNI::cancelFilterIndexCallback);
}
public int getFilterIndex() {
return DIODataJNI.getFilterIndex(m_index);
}
public void setFilterIndex(int filterIndex) {
DIODataJNI.setFilterIndex(m_index, filterIndex);
}
public void resetData() {
DIODataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,55 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.DigitalPWMDataJNI;
public class DigitalPWMSim {
private int m_index;
public DigitalPWMSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DigitalPWMDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DigitalPWMDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerDutyCycleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerDutyCycleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelDutyCycleCallback);
}
public double getDutyCycle() {
return DigitalPWMDataJNI.getDutyCycle(m_index);
}
public void setDutyCycle(double dutyCycle) {
DigitalPWMDataJNI.setDutyCycle(m_index, dutyCycle);
}
public CallbackStore registerPinCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DigitalPWMDataJNI.registerPinCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DigitalPWMDataJNI::cancelPinCallback);
}
public int getPin() {
return DigitalPWMDataJNI.getPin(m_index);
}
public void setPin(int pin) {
DigitalPWMDataJNI.setPin(m_index, pin);
}
public void resetData() {
DigitalPWMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,82 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.DriverStationDataJNI;
public class DriverStationSim {
public CallbackStore registerEnabledCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerEnabledCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelEnabledCallback);
}
public boolean getEnabled() {
return DriverStationDataJNI.getEnabled();
}
public void setEnabled(boolean enabled) {
DriverStationDataJNI.setEnabled(enabled);
}
public CallbackStore registerAutonomousCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerAutonomousCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelAutonomousCallback);
}
public boolean getAutonomous() {
return DriverStationDataJNI.getAutonomous();
}
public void setAutonomous(boolean autonomous) {
DriverStationDataJNI.setAutonomous(autonomous);
}
public CallbackStore registerTestCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerTestCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelTestCallback);
}
public boolean getTest() {
return DriverStationDataJNI.getTest();
}
public void setTest(boolean test) {
DriverStationDataJNI.setTest(test);
}
public CallbackStore registerEStopCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerEStopCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelEStopCallback);
}
public boolean getEStop() {
return DriverStationDataJNI.getEStop();
}
public void setEStop(boolean eStop) {
DriverStationDataJNI.setEStop(eStop);
}
public CallbackStore registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerFmsAttachedCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelFmsAttachedCallback);
}
public boolean getFmsAttached() {
return DriverStationDataJNI.getFmsAttached();
}
public void setFmsAttached(boolean fmsAttached) {
DriverStationDataJNI.setFmsAttached(fmsAttached);
}
public CallbackStore registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DriverStationDataJNI.registerDsAttachedCallback(callback, initialNotify);
return new CallbackStore(uid, DriverStationDataJNI::cancelDsAttachedCallback);
}
public boolean getDsAttached() {
return DriverStationDataJNI.getDsAttached();
}
public void setDsAttached(boolean dsAttached) {
DriverStationDataJNI.setDsAttached(dsAttached);
}
public void resetData() {
DriverStationDataJNI.resetData();
}
}

View File

@@ -0,0 +1,110 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.EncoderDataJNI;
public class EncoderSim {
private int m_index;
public EncoderSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return EncoderDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
EncoderDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerCountCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerCountCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelCountCallback);
}
public int getCount() {
return EncoderDataJNI.getCount(m_index);
}
public void setCount(int count) {
EncoderDataJNI.setCount(m_index, count);
}
public CallbackStore registerPeriodCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerPeriodCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelPeriodCallback);
}
public double getPeriod() {
return EncoderDataJNI.getPeriod(m_index);
}
public void setPeriod(double period) {
EncoderDataJNI.setPeriod(m_index, period);
}
public CallbackStore registerResetCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerResetCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelResetCallback);
}
public boolean getReset() {
return EncoderDataJNI.getReset(m_index);
}
public void setReset(boolean reset) {
EncoderDataJNI.setReset(m_index, reset);
}
public CallbackStore registerMaxPeriodCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerMaxPeriodCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelMaxPeriodCallback);
}
public double getMaxPeriod() {
return EncoderDataJNI.getMaxPeriod(m_index);
}
public void setMaxPeriod(double maxPeriod) {
EncoderDataJNI.setMaxPeriod(m_index, maxPeriod);
}
public CallbackStore registerDirectionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerDirectionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelDirectionCallback);
}
public boolean getDirection() {
return EncoderDataJNI.getDirection(m_index);
}
public void setDirection(boolean direction) {
EncoderDataJNI.setDirection(m_index, direction);
}
public CallbackStore registerReverseDirectionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerReverseDirectionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelReverseDirectionCallback);
}
public boolean getReverseDirection() {
return EncoderDataJNI.getReverseDirection(m_index);
}
public void setReverseDirection(boolean reverseDirection) {
EncoderDataJNI.setReverseDirection(m_index, reverseDirection);
}
public CallbackStore registerSamplesToAverageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = EncoderDataJNI.registerSamplesToAverageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelSamplesToAverageCallback);
}
public int getSamplesToAverage() {
return EncoderDataJNI.getSamplesToAverage(m_index);
}
public void setSamplesToAverage(int samplesToAverage) {
EncoderDataJNI.setSamplesToAverage(m_index, samplesToAverage);
}
public void resetData() {
EncoderDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,43 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.I2CDataJNI;
public class I2CSim {
private int m_index;
public I2CSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = I2CDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return I2CDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
I2CDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerReadCallback(BufferCallback callback) {
int uid = I2CDataJNI.registerReadCallback(m_index, callback);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelReadCallback);
}
public CallbackStore registerWriteCallback(ConstBufferCallback callback) {
int uid = I2CDataJNI.registerWriteCallback(m_index, callback);
return new CallbackStore(m_index, uid, I2CDataJNI::cancelWriteCallback);
}
public void resetData() {
I2CDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,34 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
public interface NotifyCallback {
void callback(String name, SimValue value);
default void callbackNative(String name, int type, long value1, double value2) {
switch(type) {
case 0x01:
callback(name, SimValue.makeBoolean(value1 != 0));
break;
case 0x02:
callback(name, SimValue.makeDouble(value2));
break;
case 0x16:
callback(name, SimValue.makeEnum((int)value1));
break;
case 0x32:
callback(name, SimValue.makeInt((int)value1));
break;
case 0x64:
callback(name, SimValue.makeLong(value1));
break;
default:
callback(name, SimValue.makeUnassigned());
}
}
}

View File

@@ -0,0 +1,99 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.PCMDataJNI;
public class PCMSim {
private int m_index;
public PCMSim(int index) {
m_index = index;
}
public CallbackStore registerSolenoidInitializedCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerSolenoidInitializedCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PCMDataJNI::cancelSolenoidInitializedCallback);
}
public boolean getSolenoidInitialized(int channel) {
return PCMDataJNI.getSolenoidInitialized(m_index, channel);
}
public void setSolenoidInitialized(int channel, boolean solenoidInitialized) {
PCMDataJNI.setSolenoidInitialized(m_index, channel, solenoidInitialized);
}
public CallbackStore registerSolenoidOutputCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerSolenoidOutputCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PCMDataJNI::cancelSolenoidOutputCallback);
}
public boolean getSolenoidOutput(int channel) {
return PCMDataJNI.getSolenoidOutput(m_index, channel);
}
public void setSolenoidOutput(int channel, boolean solenoidOutput) {
PCMDataJNI.setSolenoidOutput(m_index, channel, solenoidOutput);
}
public CallbackStore registerCompressorInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorInitializedCallback);
}
public boolean getCompressorInitialized() {
return PCMDataJNI.getCompressorInitialized(m_index);
}
public void setCompressorInitialized(boolean compressorInitialized) {
PCMDataJNI.setCompressorInitialized(m_index, compressorInitialized);
}
public CallbackStore registerCompressorOnCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorOnCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorOnCallback);
}
public boolean getCompressorOn() {
return PCMDataJNI.getCompressorOn(m_index);
}
public void setCompressorOn(boolean compressorOn) {
PCMDataJNI.setCompressorOn(m_index, compressorOn);
}
public CallbackStore registerClosedLoopEnabledCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerClosedLoopEnabledCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelClosedLoopEnabledCallback);
}
public boolean getClosedLoopEnabled() {
return PCMDataJNI.getClosedLoopEnabled(m_index);
}
public void setClosedLoopEnabled(boolean closedLoopEnabled) {
PCMDataJNI.setClosedLoopEnabled(m_index, closedLoopEnabled);
}
public CallbackStore registerPressureSwitchCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerPressureSwitchCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelPressureSwitchCallback);
}
public boolean getPressureSwitch() {
return PCMDataJNI.getPressureSwitch(m_index);
}
public void setPressureSwitch(boolean pressureSwitch) {
PCMDataJNI.setPressureSwitch(m_index, pressureSwitch);
}
public CallbackStore registerCompressorCurrentCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PCMDataJNI.registerCompressorCurrentCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PCMDataJNI::cancelCompressorCurrentCallback);
}
public double getCompressorCurrent() {
return PCMDataJNI.getCompressorCurrent(m_index);
}
public void setCompressorCurrent(double compressorCurrent) {
PCMDataJNI.setCompressorCurrent(m_index, compressorCurrent);
}
public void resetData() {
PCMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,66 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.PDPDataJNI;
public class PDPSim {
private int m_index;
public PDPSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return PDPDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
PDPDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerTemperatureCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerTemperatureCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelTemperatureCallback);
}
public double getTemperature() {
return PDPDataJNI.getTemperature(m_index);
}
public void setTemperature(double temperature) {
PDPDataJNI.setTemperature(m_index, temperature);
}
public CallbackStore registerVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PDPDataJNI::cancelVoltageCallback);
}
public double getVoltage() {
return PDPDataJNI.getVoltage(m_index);
}
public void setVoltage(double voltage) {
PDPDataJNI.setVoltage(m_index, voltage);
}
public CallbackStore registerCurrentCallback(int channel, NotifyCallback callback, boolean initialNotify) {
int uid = PDPDataJNI.registerCurrentCallback(m_index, channel, callback, initialNotify);
return new CallbackStore(m_index, channel, uid, PDPDataJNI::cancelCurrentCallback);
}
public double getCurrent(int channel) {
return PDPDataJNI.getCurrent(channel, m_index);
}
public void setCurrent(int channel, double current) {
PDPDataJNI.setCurrent(m_index, channel, current);
}
public void resetData() {
PDPDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,88 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.PWMDataJNI;
public class PWMSim {
private int m_index;
public PWMSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return PWMDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
PWMDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerRawValueCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerRawValueCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelRawValueCallback);
}
public int getRawValue() {
return PWMDataJNI.getRawValue(m_index);
}
public void setRawValue(int rawValue) {
PWMDataJNI.setRawValue(m_index, rawValue);
}
public CallbackStore registerSpeedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerSpeedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelSpeedCallback);
}
public double getSpeed() {
return PWMDataJNI.getSpeed(m_index);
}
public void setSpeed(double speed) {
PWMDataJNI.setSpeed(m_index, speed);
}
public CallbackStore registerPositionCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerPositionCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelPositionCallback);
}
public double getPosition() {
return PWMDataJNI.getPosition(m_index);
}
public void setPosition(double position) {
PWMDataJNI.setPosition(m_index, position);
}
public CallbackStore registerPeriodScaleCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerPeriodScaleCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelPeriodScaleCallback);
}
public int getPeriodScale() {
return PWMDataJNI.getPeriodScale(m_index);
}
public void setPeriodScale(int periodScale) {
PWMDataJNI.setPeriodScale(m_index, periodScale);
}
public CallbackStore registerZeroLatchCallback(NotifyCallback callback, boolean initialNotify) {
int uid = PWMDataJNI.registerZeroLatchCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, PWMDataJNI::cancelZeroLatchCallback);
}
public boolean getZeroLatch() {
return PWMDataJNI.getZeroLatch(m_index);
}
public void setZeroLatch(boolean zeroLatch) {
PWMDataJNI.setZeroLatch(m_index, zeroLatch);
}
public void resetData() {
PWMDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,66 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.RelayDataJNI;
public class RelaySim {
private int m_index;
public RelaySim(int index) {
m_index = index;
}
public CallbackStore registerInitializedForwardCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerInitializedForwardCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedForwardCallback);
}
public boolean getInitializedForward() {
return RelayDataJNI.getInitializedForward(m_index);
}
public void setInitializedForward(boolean initializedForward) {
RelayDataJNI.setInitializedForward(m_index, initializedForward);
}
public CallbackStore registerInitializedReverseCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerInitializedReverseCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedReverseCallback);
}
public boolean getInitializedReverse() {
return RelayDataJNI.getInitializedReverse(m_index);
}
public void setInitializedReverse(boolean initializedReverse) {
RelayDataJNI.setInitializedReverse(m_index, initializedReverse);
}
public CallbackStore registerForwardCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerForwardCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelForwardCallback);
}
public boolean getForward() {
return RelayDataJNI.getForward(m_index);
}
public void setForward(boolean forward) {
RelayDataJNI.setForward(m_index, forward);
}
public CallbackStore registerReverseCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RelayDataJNI.registerReverseCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RelayDataJNI::cancelReverseCallback);
}
public boolean getReverse() {
return RelayDataJNI.getReverse(m_index);
}
public void setReverse(boolean reverse) {
RelayDataJNI.setReverse(m_index, reverse);
}
public void resetData() {
RelayDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,187 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.RoboRioDataJNI;
public class RoboRioSim {
private int m_index;
public RoboRioSim(int index) {
m_index = index;
}
public CallbackStore registerFPGAButtonCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerFPGAButtonCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelFPGAButtonCallback);
}
public boolean getFPGAButton() {
return RoboRioDataJNI.getFPGAButton(m_index);
}
public void setFPGAButton(boolean fPGAButton) {
RoboRioDataJNI.setFPGAButton(m_index, fPGAButton);
}
public CallbackStore registerVInVoltageCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerVInVoltageCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelVInVoltageCallback);
}
public double getVInVoltage() {
return RoboRioDataJNI.getVInVoltage(m_index);
}
public void setVInVoltage(double vInVoltage) {
RoboRioDataJNI.setVInVoltage(m_index, vInVoltage);
}
public CallbackStore registerVInCurrentCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerVInCurrentCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelVInCurrentCallback);
}
public double getVInCurrent() {
return RoboRioDataJNI.getVInCurrent(m_index);
}
public void setVInCurrent(double vInCurrent) {
RoboRioDataJNI.setVInCurrent(m_index, vInCurrent);
}
public CallbackStore registerUserVoltage6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage6VCallback);
}
public double getUserVoltage6V() {
return RoboRioDataJNI.getUserVoltage6V(m_index);
}
public void setUserVoltage6V(double userVoltage6V) {
RoboRioDataJNI.setUserVoltage6V(m_index, userVoltage6V);
}
public CallbackStore registerUserCurrent6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent6VCallback);
}
public double getUserCurrent6V() {
return RoboRioDataJNI.getUserCurrent6V(m_index);
}
public void setUserCurrent6V(double userCurrent6V) {
RoboRioDataJNI.setUserCurrent6V(m_index, userCurrent6V);
}
public CallbackStore registerUserActive6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive6VCallback);
}
public boolean getUserActive6V() {
return RoboRioDataJNI.getUserActive6V(m_index);
}
public void setUserActive6V(boolean userActive6V) {
RoboRioDataJNI.setUserActive6V(m_index, userActive6V);
}
public CallbackStore registerUserVoltage5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage5VCallback);
}
public double getUserVoltage5V() {
return RoboRioDataJNI.getUserVoltage5V(m_index);
}
public void setUserVoltage5V(double userVoltage5V) {
RoboRioDataJNI.setUserVoltage5V(m_index, userVoltage5V);
}
public CallbackStore registerUserCurrent5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent5VCallback);
}
public double getUserCurrent5V() {
return RoboRioDataJNI.getUserCurrent5V(m_index);
}
public void setUserCurrent5V(double userCurrent5V) {
RoboRioDataJNI.setUserCurrent5V(m_index, userCurrent5V);
}
public CallbackStore registerUserActive5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive5VCallback);
}
public boolean getUserActive5V() {
return RoboRioDataJNI.getUserActive5V(m_index);
}
public void setUserActive5V(boolean userActive5V) {
RoboRioDataJNI.setUserActive5V(m_index, userActive5V);
}
public CallbackStore registerUserVoltage3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserVoltage3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserVoltage3V3Callback);
}
public double getUserVoltage3V3() {
return RoboRioDataJNI.getUserVoltage3V3(m_index);
}
public void setUserVoltage3V3(double userVoltage3V3) {
RoboRioDataJNI.setUserVoltage3V3(m_index, userVoltage3V3);
}
public CallbackStore registerUserCurrent3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserCurrent3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserCurrent3V3Callback);
}
public double getUserCurrent3V3() {
return RoboRioDataJNI.getUserCurrent3V3(m_index);
}
public void setUserCurrent3V3(double userCurrent3V3) {
RoboRioDataJNI.setUserCurrent3V3(m_index, userCurrent3V3);
}
public CallbackStore registerUserActive3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserActive3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserActive3V3Callback);
}
public boolean getUserActive3V3() {
return RoboRioDataJNI.getUserActive3V3(m_index);
}
public void setUserActive3V3(boolean userActive3V3) {
RoboRioDataJNI.setUserActive3V3(m_index, userActive3V3);
}
public CallbackStore registerUserFaults6VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults6VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults6VCallback);
}
public int getUserFaults6V() {
return RoboRioDataJNI.getUserFaults6V(m_index);
}
public void setUserFaults6V(int userFaults6V) {
RoboRioDataJNI.setUserFaults6V(m_index, userFaults6V);
}
public CallbackStore registerUserFaults5VCallback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults5VCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults5VCallback);
}
public int getUserFaults5V() {
return RoboRioDataJNI.getUserFaults5V(m_index);
}
public void setUserFaults5V(int userFaults5V) {
RoboRioDataJNI.setUserFaults5V(m_index, userFaults5V);
}
public CallbackStore registerUserFaults3V3Callback(NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerUserFaults3V3Callback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, RoboRioDataJNI::cancelUserFaults3V3Callback);
}
public int getUserFaults3V3() {
return RoboRioDataJNI.getUserFaults3V3(m_index);
}
public void setUserFaults3V3(int userFaults3V3) {
RoboRioDataJNI.setUserFaults3V3(m_index, userFaults3V3);
}
public void resetData() {
RoboRioDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,77 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.SPIAccelerometerDataJNI;
public class SPIAccelerometerSim {
private int m_index;
public SPIAccelerometerSim(int index) {
m_index = index;
}
public CallbackStore registerActiveCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerActiveCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelActiveCallback);
}
public boolean getActive() {
return SPIAccelerometerDataJNI.getActive(m_index);
}
public void setActive(boolean active) {
SPIAccelerometerDataJNI.setActive(m_index, active);
}
public CallbackStore registerRangeCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerRangeCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelRangeCallback);
}
public int getRange() {
return SPIAccelerometerDataJNI.getRange(m_index);
}
public void setRange(int range) {
SPIAccelerometerDataJNI.setRange(m_index, range);
}
public CallbackStore registerXCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerXCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelXCallback);
}
public double getX() {
return SPIAccelerometerDataJNI.getX(m_index);
}
public void setX(double x) {
SPIAccelerometerDataJNI.setX(m_index, x);
}
public CallbackStore registerYCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerYCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelYCallback);
}
public double getY() {
return SPIAccelerometerDataJNI.getY(m_index);
}
public void setY(double y) {
SPIAccelerometerDataJNI.setY(m_index, y);
}
public CallbackStore registerZCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIAccelerometerDataJNI.registerZCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIAccelerometerDataJNI::cancelZCallback);
}
public double getZ() {
return SPIAccelerometerDataJNI.getZ(m_index);
}
public void setZ(double z) {
SPIAccelerometerDataJNI.setZ(m_index, z);
}
public void resetData() {
SPIAccelerometerDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,48 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.SPIDataJNI;
public class SPISim {
private int m_index;
public SPISim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = SPIDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return SPIDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
SPIDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerReadCallback(BufferCallback callback) {
int uid = SPIDataJNI.registerReadCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelReadCallback);
}
public CallbackStore registerWriteCallback(ConstBufferCallback callback) {
int uid = SPIDataJNI.registerWriteCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelWriteCallback);
}
public CallbackStore registerReadAutoReceiveBufferCallback(SpiReadAutoReceiveBufferCallback callback) {
int uid = SPIDataJNI.registerReadAutoReceiveBufferCallback(m_index, callback);
return new CallbackStore(m_index, uid, SPIDataJNI::cancelReadAutoReceiveBufferCallback);
}
public void resetData() {
SPIDataJNI.resetData(m_index);
}
}

View File

@@ -0,0 +1,27 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import edu.wpi.first.hal.sim.mockdata.SimulatorJNI;
public class SimHooks {
private SimHooks() {
}
public static void waitForProgramStart() {
SimulatorJNI.waitForProgramStart();
}
public static void setProgramStarted() {
SimulatorJNI.setProgramStarted();
}
public static void restartTiming() {
SimulatorJNI.restartTiming();
}
}

View File

@@ -0,0 +1,66 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
public class SimValue {
private boolean v_boolean;
private long v_long;
private double v_double;
private SimValue(boolean b) {
v_boolean = b;
}
private SimValue(double v) {
v_double = v;
}
private SimValue(long v) {
v_long = v;
}
private SimValue() {
}
public boolean getBoolean() {
return v_boolean;
}
public long getLong() {
return v_long;
}
public double getDouble() {
return v_double;
}
public static SimValue makeBoolean(boolean value) {
return new SimValue(value);
}
public static SimValue makeEnum(int value) {
return new SimValue(value);
}
public static SimValue makeInt(int value) {
return new SimValue(value);
}
public static SimValue makeLong(long value) {
return new SimValue(value);
}
public static SimValue makeDouble(double value) {
return new SimValue(value);
}
public static SimValue makeUnassigned() {
return new SimValue();
}
}

View File

@@ -0,0 +1,12 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
public interface SpiReadAutoReceiveBufferCallback {
int callback(String name, byte[] buffer, int numToRead);
}

View File

@@ -0,0 +1,92 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/AccelerometerData.h"
namespace frc {
namespace sim {
class AccelerometerSim {
public:
explicit AccelerometerSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetActive() { return HALSIM_GetAccelerometerActive(m_index); }
void SetActive(bool active) {
HALSIM_SetAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
HAL_AccelerometerRange GetRange() {
return HALSIM_GetAccelerometerRange(m_index);
}
void SetRange(HAL_AccelerometerRange range) {
HALSIM_SetAccelerometerRange(m_index, range);
}
std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerXCallback);
store->SetUid(HALSIM_RegisterAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetX() { return HALSIM_GetAccelerometerX(m_index); }
void SetX(double x) { HALSIM_SetAccelerometerX(m_index, x); }
std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerYCallback);
store->SetUid(HALSIM_RegisterAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetY() { return HALSIM_GetAccelerometerY(m_index); }
void SetY(double y) { HALSIM_SetAccelerometerY(m_index, y); }
std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerZCallback);
store->SetUid(HALSIM_RegisterAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetZ() { return HALSIM_GetAccelerometerZ(m_index); }
void SetZ(double z) { HALSIM_SetAccelerometerZ(m_index, z); }
void ResetData() { HALSIM_ResetAccelerometerData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,66 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/AnalogGyroData.h"
namespace frc {
namespace sim {
class AnalogGyroSim {
public:
explicit AnalogGyroSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetAngle() { return HALSIM_GetAnalogGyroAngle(m_index); }
void SetAngle(double angle) { HALSIM_SetAnalogGyroAngle(m_index, angle); }
std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetRate() { return HALSIM_GetAnalogGyroRate(m_index); }
void SetRate(double rate) { HALSIM_SetAnalogGyroRate(m_index, rate); }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetAnalogGyroInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetAnalogGyroInitialized(m_index, initialized);
}
void ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,160 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/AnalogInData.h"
namespace frc {
namespace sim {
class AnalogInSim {
public:
explicit AnalogInSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogInInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetAnalogInInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetAnalogInInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterAverageBitsCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetAverageBits() { return HALSIM_GetAnalogInAverageBits(m_index); }
void SetAverageBits(int averageBits) {
HALSIM_SetAnalogInAverageBits(m_index, averageBits);
}
std::unique_ptr<CallbackStore> RegisterOversampleBitsCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetOversampleBits() { return HALSIM_GetAnalogInOversampleBits(m_index); }
void SetOversampleBits(int oversampleBits) {
HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
}
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInVoltageCallback);
store->SetUid(HALSIM_RegisterAnalogInVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetVoltage() { return HALSIM_GetAnalogInVoltage(m_index); }
void SetVoltage(double voltage) {
HALSIM_SetAnalogInVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore> RegisterAccumulatorInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogInAccumulatorInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetAccumulatorInitialized() {
return HALSIM_GetAnalogInAccumulatorInitialized(m_index);
}
void SetAccumulatorInitialized(bool accumulatorInitialized) {
HALSIM_SetAnalogInAccumulatorInitialized(m_index, accumulatorInitialized);
}
std::unique_ptr<CallbackStore> RegisterAccumulatorValueCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorValueCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorValueCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int64_t GetAccumulatorValue() {
return HALSIM_GetAnalogInAccumulatorValue(m_index);
}
void SetAccumulatorValue(int64_t accumulatorValue) {
HALSIM_SetAnalogInAccumulatorValue(m_index, accumulatorValue);
}
std::unique_ptr<CallbackStore> RegisterAccumulatorCountCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCountCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCountCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int64_t GetAccumulatorCount() {
return HALSIM_GetAnalogInAccumulatorCount(m_index);
}
void SetAccumulatorCount(int64_t accumulatorCount) {
HALSIM_SetAnalogInAccumulatorCount(m_index, accumulatorCount);
}
std::unique_ptr<CallbackStore> RegisterAccumulatorCenterCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCenterCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCenterCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetAccumulatorCenter() {
return HALSIM_GetAnalogInAccumulatorCenter(m_index);
}
void SetAccumulatorCenter(int accumulatorCenter) {
HALSIM_SetAnalogInAccumulatorCenter(m_index, accumulatorCenter);
}
std::unique_ptr<CallbackStore> RegisterAccumulatorDeadbandCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetAccumulatorDeadband() {
return HALSIM_GetAnalogInAccumulatorDeadband(m_index);
}
void SetAccumulatorDeadband(int accumulatorDeadband) {
HALSIM_SetAnalogInAccumulatorDeadband(m_index, accumulatorDeadband);
}
void ResetData() { HALSIM_ResetAnalogInData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,57 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/AnalogOutData.h"
namespace frc {
namespace sim {
class AnalogOutSim {
public:
explicit AnalogOutSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetVoltage() { return HALSIM_GetAnalogOutVoltage(m_index); }
void SetVoltage(double voltage) {
HALSIM_SetAnalogOutVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetAnalogOutInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetAnalogOutInitialized(m_index, initialized);
}
void ResetData() { HALSIM_ResetAnalogOutData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,76 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/AnalogTriggerData.h"
namespace frc {
namespace sim {
class AnalogTriggerSim {
public:
explicit AnalogTriggerSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetAnalogTriggerInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetTriggerLowerBound() {
return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
}
void SetTriggerLowerBound(double triggerLowerBound) {
HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
}
std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetTriggerUpperBound() {
return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
}
void SetTriggerUpperBound(double triggerUpperBound) {
HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
}
void ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,90 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <wpi/StringRef.h>
#include <functional>
#include "MockData/HAL_Value.h"
namespace frc {
namespace sim {
using NotifyCallback = std::function<void(wpi::StringRef, const HAL_Value*)>;
typedef void (*CancelCallbackFunc)(int32_t index, int32_t uid);
typedef void (*CancelCallbackNoIndexFunc)(int32_t uid);
typedef void (*CancelCallbackChannelFunc)(int32_t index, int32_t channel,
int32_t uid);
void CallbackStoreThunk(const char* name, void* param, const HAL_Value* value);
class CallbackStore {
public:
CallbackStore(int32_t i, NotifyCallback cb, CancelCallbackNoIndexFunc ccf) {
index = i;
callback = cb;
this->ccnif = ccf;
cancelType = NoIndex;
}
CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
CancelCallbackFunc ccf) {
index = i;
uid = u;
callback = cb;
this->ccf = ccf;
cancelType = Normal;
}
CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
CancelCallbackChannelFunc ccf) {
index = i;
channel = c;
uid = u;
callback = cb;
this->cccf = ccf;
cancelType = Channel;
}
~CallbackStore() {
switch (cancelType) {
case Normal:
ccf(index, uid);
break;
case Channel:
cccf(index, channel, uid);
break;
case NoIndex:
ccnif(uid);
break;
}
}
void SetUid(int32_t uid) { this->uid = uid; }
friend void CallbackStoreThunk(const char* name, void* param,
const HAL_Value* value);
private:
int32_t index;
int32_t channel;
int32_t uid;
NotifyCallback callback;
union {
CancelCallbackFunc ccf;
CancelCallbackChannelFunc cccf;
CancelCallbackNoIndexFunc ccnif;
};
enum CancelType { Normal, Channel, NoIndex };
CancelType cancelType;
};
} // namespace sim
} // namespace frc
#endif

View File

@@ -0,0 +1,92 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/DIOData.h"
namespace frc {
namespace sim {
class DIOSim {
public:
explicit DIOSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOInitializedCallback);
store->SetUid(HALSIM_RegisterDIOInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetDIOInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetDIOInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterValueCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOValueCallback);
store->SetUid(HALSIM_RegisterDIOValueCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return std::move(store);
}
bool GetValue() { return HALSIM_GetDIOValue(m_index); }
void SetValue(bool value) { HALSIM_SetDIOValue(m_index, value); }
std::unique_ptr<CallbackStore> RegisterPulseLengthCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOPulseLengthCallback);
store->SetUid(HALSIM_RegisterDIOPulseLengthCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetPulseLength() { return HALSIM_GetDIOPulseLength(m_index); }
void SetPulseLength(double pulseLength) {
HALSIM_SetDIOPulseLength(m_index, pulseLength);
}
std::unique_ptr<CallbackStore> RegisterIsInputCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOIsInputCallback);
store->SetUid(HALSIM_RegisterDIOIsInputCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetIsInput() { return HALSIM_GetDIOIsInput(m_index); }
void SetIsInput(bool isInput) { HALSIM_SetDIOIsInput(m_index, isInput); }
std::unique_ptr<CallbackStore> RegisterFilterIndexCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOFilterIndexCallback);
store->SetUid(HALSIM_RegisterDIOFilterIndexCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetFilterIndex() { return HALSIM_GetDIOFilterIndex(m_index); }
void SetFilterIndex(int filterIndex) {
HALSIM_SetDIOFilterIndex(m_index, filterIndex);
}
void ResetData() { HALSIM_ResetDIOData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,68 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/DigitalPWMData.h"
namespace frc {
namespace sim {
class DigitalPWMSim {
public:
explicit DigitalPWMSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMInitializedCallback);
store->SetUid(HALSIM_RegisterDigitalPWMInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetDigitalPWMInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetDigitalPWMInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterDutyCycleCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMDutyCycleCallback);
store->SetUid(HALSIM_RegisterDigitalPWMDutyCycleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetDutyCycle() { return HALSIM_GetDigitalPWMDutyCycle(m_index); }
void SetDutyCycle(double dutyCycle) {
HALSIM_SetDigitalPWMDutyCycle(m_index, dutyCycle);
}
std::unique_ptr<CallbackStore> RegisterPinCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMPinCallback);
store->SetUid(HALSIM_RegisterDigitalPWMPinCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetPin() { return HALSIM_GetDigitalPWMPin(m_index); }
void SetPin(int pin) { HALSIM_SetDigitalPWMPin(m_index, pin); }
void ResetData() { HALSIM_ResetDigitalPWMData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,98 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/DriverStationData.h"
namespace frc {
namespace sim {
class DriverStationSim {
public:
std::unique_ptr<CallbackStore> RegisterEnabledCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationEnabledCallback);
store->SetUid(HALSIM_RegisterDriverStationEnabledCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetEnabled() { return HALSIM_GetDriverStationEnabled(); }
void SetEnabled(bool enabled) { HALSIM_SetDriverStationEnabled(enabled); }
std::unique_ptr<CallbackStore> RegisterAutonomousCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationAutonomousCallback);
store->SetUid(HALSIM_RegisterDriverStationAutonomousCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetAutonomous() { return HALSIM_GetDriverStationAutonomous(); }
void SetAutonomous(bool autonomous) {
HALSIM_SetDriverStationAutonomous(autonomous);
}
std::unique_ptr<CallbackStore> RegisterTestCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationTestCallback);
store->SetUid(HALSIM_RegisterDriverStationTestCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetTest() { return HALSIM_GetDriverStationTest(); }
void SetTest(bool test) { HALSIM_SetDriverStationTest(test); }
std::unique_ptr<CallbackStore> RegisterEStopCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationEStopCallback);
store->SetUid(HALSIM_RegisterDriverStationEStopCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetEStop() { return HALSIM_GetDriverStationEStop(); }
void SetEStop(bool eStop) { HALSIM_SetDriverStationEStop(eStop); }
std::unique_ptr<CallbackStore> RegisterFmsAttachedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationFmsAttachedCallback);
store->SetUid(HALSIM_RegisterDriverStationFmsAttachedCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetFmsAttached() { return HALSIM_GetDriverStationFmsAttached(); }
void SetFmsAttached(bool fmsAttached) {
HALSIM_SetDriverStationFmsAttached(fmsAttached);
}
std::unique_ptr<CallbackStore> RegisterDsAttachedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationDsAttachedCallback);
store->SetUid(HALSIM_RegisterDriverStationDsAttachedCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetDsAttached() { return HALSIM_GetDriverStationDsAttached(); }
void SetDsAttached(bool dsAttached) {
HALSIM_SetDriverStationDsAttached(dsAttached);
}
void ResetData() { HALSIM_ResetDriverStationData(); }
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,133 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/EncoderData.h"
namespace frc {
namespace sim {
class EncoderSim {
public:
explicit EncoderSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderInitializedCallback);
store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetEncoderInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetEncoderInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterCountCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
store->SetUid(HALSIM_RegisterEncoderCountCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetCount() { return HALSIM_GetEncoderCount(m_index); }
void SetCount(int count) { HALSIM_SetEncoderCount(m_index, count); }
std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetPeriod() { return HALSIM_GetEncoderPeriod(m_index); }
void SetPeriod(double period) { HALSIM_SetEncoderPeriod(m_index, period); }
std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
store->SetUid(HALSIM_RegisterEncoderResetCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetReset() { return HALSIM_GetEncoderReset(m_index); }
void SetReset(bool reset) { HALSIM_SetEncoderReset(m_index, reset); }
std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetMaxPeriod() { return HALSIM_GetEncoderMaxPeriod(m_index); }
void SetMaxPeriod(double maxPeriod) {
HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
}
std::unique_ptr<CallbackStore> RegisterDirectionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetDirection() { return HALSIM_GetEncoderDirection(m_index); }
void SetDirection(bool direction) {
HALSIM_SetEncoderDirection(m_index, direction);
}
std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetReverseDirection() {
return HALSIM_GetEncoderReverseDirection(m_index);
}
void SetReverseDirection(bool reverseDirection) {
HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
}
std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetSamplesToAverage() {
return HALSIM_GetEncoderSamplesToAverage(m_index);
}
void SetSamplesToAverage(int samplesToAverage) {
HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
}
void ResetData() { HALSIM_ResetEncoderData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,134 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/PCMData.h"
namespace frc {
namespace sim {
class PCMSim {
public:
explicit PCMSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterSolenoidInitializedCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback,
&HALSIM_CancelPCMSolenoidInitializedCallback);
store->SetUid(HALSIM_RegisterPCMSolenoidInitializedCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetSolenoidInitialized(int channel) {
return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
}
void SetSolenoidInitialized(int channel, bool solenoidInitialized) {
HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
}
std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback,
&HALSIM_CancelPCMSolenoidOutputCallback);
store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetSolenoidOutput(int channel) {
return HALSIM_GetPCMSolenoidOutput(m_index, channel);
}
void SetSolenoidOutput(int channel, bool solenoidOutput) {
HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
}
std::unique_ptr<CallbackStore> RegisterCompressorInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetCompressorInitialized() {
return HALSIM_GetPCMCompressorInitialized(m_index);
}
void SetCompressorInitialized(bool compressorInitialized) {
HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
}
std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetCompressorOn() { return HALSIM_GetPCMCompressorOn(m_index); }
void SetCompressorOn(bool compressorOn) {
HALSIM_SetPCMCompressorOn(m_index, compressorOn);
}
std::unique_ptr<CallbackStore> RegisterClosedLoopEnabledCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetClosedLoopEnabled() {
return HALSIM_GetPCMClosedLoopEnabled(m_index);
}
void SetClosedLoopEnabled(bool closedLoopEnabled) {
HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
}
std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetPressureSwitch() { return HALSIM_GetPCMPressureSwitch(m_index); }
void SetPressureSwitch(bool pressureSwitch) {
HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
}
std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetCompressorCurrent() {
return HALSIM_GetPCMCompressorCurrent(m_index);
}
void SetCompressorCurrent(double compressorCurrent) {
HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
}
void ResetData() { HALSIM_ResetPCMData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,83 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/PDPData.h"
namespace frc {
namespace sim {
class PDPSim {
public:
explicit PDPSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPInitializedCallback);
store->SetUid(HALSIM_RegisterPDPInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetPDPInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetPDPInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetTemperature() { return HALSIM_GetPDPTemperature(m_index); }
void SetTemperature(double temperature) {
HALSIM_SetPDPTemperature(m_index, temperature);
}
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
store->SetUid(HALSIM_RegisterPDPVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetVoltage() { return HALSIM_GetPDPVoltage(m_index); }
void SetVoltage(double voltage) { HALSIM_SetPDPVoltage(m_index, voltage); }
std::unique_ptr<CallbackStore> RegisterCurrentCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
store->SetUid(HALSIM_RegisterPDPCurrentCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetCurrent(int channel) {
return HALSIM_GetPDPCurrent(m_index, channel);
}
void SetCurrent(int channel, double current) {
HALSIM_SetPDPCurrent(m_index, channel, current);
}
void ResetData() { HALSIM_ResetPDPData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,105 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/PWMData.h"
namespace frc {
namespace sim {
class PWMSim {
public:
explicit PWMSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMInitializedCallback);
store->SetUid(HALSIM_RegisterPWMInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitialized() { return HALSIM_GetPWMInitialized(m_index); }
void SetInitialized(bool initialized) {
HALSIM_SetPWMInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> RegisterRawValueCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMRawValueCallback);
store->SetUid(HALSIM_RegisterPWMRawValueCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetRawValue() { return HALSIM_GetPWMRawValue(m_index); }
void SetRawValue(int rawValue) { HALSIM_SetPWMRawValue(m_index, rawValue); }
std::unique_ptr<CallbackStore> RegisterSpeedCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMSpeedCallback);
store->SetUid(HALSIM_RegisterPWMSpeedCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return std::move(store);
}
double GetSpeed() { return HALSIM_GetPWMSpeed(m_index); }
void SetSpeed(double speed) { HALSIM_SetPWMSpeed(m_index, speed); }
std::unique_ptr<CallbackStore> RegisterPositionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMPositionCallback);
store->SetUid(HALSIM_RegisterPWMPositionCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetPosition() { return HALSIM_GetPWMPosition(m_index); }
void SetPosition(double position) {
HALSIM_SetPWMPosition(m_index, position);
}
std::unique_ptr<CallbackStore> RegisterPeriodScaleCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMPeriodScaleCallback);
store->SetUid(HALSIM_RegisterPWMPeriodScaleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetPeriodScale() { return HALSIM_GetPWMPeriodScale(m_index); }
void SetPeriodScale(int periodScale) {
HALSIM_SetPWMPeriodScale(m_index, periodScale);
}
std::unique_ptr<CallbackStore> RegisterZeroLatchCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMZeroLatchCallback);
store->SetUid(HALSIM_RegisterPWMZeroLatchCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetZeroLatch() { return HALSIM_GetPWMZeroLatch(m_index); }
void SetZeroLatch(bool zeroLatch) {
HALSIM_SetPWMZeroLatch(m_index, zeroLatch);
}
void ResetData() { HALSIM_ResetPWMData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,83 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/RelayData.h"
namespace frc {
namespace sim {
class RelaySim {
public:
explicit RelaySim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterInitializedForwardCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback);
store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitializedForward() {
return HALSIM_GetRelayInitializedForward(m_index);
}
void SetInitializedForward(bool initializedForward) {
HALSIM_SetRelayInitializedForward(m_index, initializedForward);
}
std::unique_ptr<CallbackStore> RegisterInitializedReverseCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback);
store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetInitializedReverse() {
return HALSIM_GetRelayInitializedReverse(m_index);
}
void SetInitializedReverse(bool initializedReverse) {
HALSIM_SetRelayInitializedReverse(m_index, initializedReverse);
}
std::unique_ptr<CallbackStore> RegisterForwardCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayForwardCallback);
store->SetUid(HALSIM_RegisterRelayForwardCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetForward() { return HALSIM_GetRelayForward(m_index); }
void SetForward(bool forward) { HALSIM_SetRelayForward(m_index, forward); }
std::unique_ptr<CallbackStore> RegisterReverseCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayReverseCallback);
store->SetUid(HALSIM_RegisterRelayReverseCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetReverse() { return HALSIM_GetRelayReverse(m_index); }
void SetReverse(bool reverse) { HALSIM_SetRelayReverse(m_index, reverse); }
void ResetData() { HALSIM_ResetRelayData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,230 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/RoboRioData.h"
namespace frc {
namespace sim {
class RoboRioSim {
public:
explicit RoboRioSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(m_index); }
void SetFPGAButton(bool fPGAButton) {
HALSIM_SetRoboRioFPGAButton(m_index, fPGAButton);
}
std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetVInVoltage() { return HALSIM_GetRoboRioVInVoltage(m_index); }
void SetVInVoltage(double vInVoltage) {
HALSIM_SetRoboRioVInVoltage(m_index, vInVoltage);
}
std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetVInCurrent() { return HALSIM_GetRoboRioVInCurrent(m_index); }
void SetVInCurrent(double vInCurrent) {
HALSIM_SetRoboRioVInCurrent(m_index, vInCurrent);
}
std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserVoltage6V() { return HALSIM_GetRoboRioUserVoltage6V(m_index); }
void SetUserVoltage6V(double userVoltage6V) {
HALSIM_SetRoboRioUserVoltage6V(m_index, userVoltage6V);
}
std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserCurrent6V() { return HALSIM_GetRoboRioUserCurrent6V(m_index); }
void SetUserCurrent6V(double userCurrent6V) {
HALSIM_SetRoboRioUserCurrent6V(m_index, userCurrent6V);
}
std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(m_index); }
void SetUserActive6V(bool userActive6V) {
HALSIM_SetRoboRioUserActive6V(m_index, userActive6V);
}
std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserVoltage5V() { return HALSIM_GetRoboRioUserVoltage5V(m_index); }
void SetUserVoltage5V(double userVoltage5V) {
HALSIM_SetRoboRioUserVoltage5V(m_index, userVoltage5V);
}
std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserCurrent5V() { return HALSIM_GetRoboRioUserCurrent5V(m_index); }
void SetUserCurrent5V(double userCurrent5V) {
HALSIM_SetRoboRioUserCurrent5V(m_index, userCurrent5V);
}
std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(m_index); }
void SetUserActive5V(bool userActive5V) {
HALSIM_SetRoboRioUserActive5V(m_index, userActive5V);
}
std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserVoltage3V3() {
return HALSIM_GetRoboRioUserVoltage3V3(m_index);
}
void SetUserVoltage3V3(double userVoltage3V3) {
HALSIM_SetRoboRioUserVoltage3V3(m_index, userVoltage3V3);
}
std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetUserCurrent3V3() {
return HALSIM_GetRoboRioUserCurrent3V3(m_index);
}
void SetUserCurrent3V3(double userCurrent3V3) {
HALSIM_SetRoboRioUserCurrent3V3(m_index, userCurrent3V3);
}
std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(m_index); }
void SetUserActive3V3(bool userActive3V3) {
HALSIM_SetRoboRioUserActive3V3(m_index, userActive3V3);
}
std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(m_index); }
void SetUserFaults6V(int userFaults6V) {
HALSIM_SetRoboRioUserFaults6V(m_index, userFaults6V);
}
std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(m_index); }
void SetUserFaults5V(int userFaults5V) {
HALSIM_SetRoboRioUserFaults5V(m_index, userFaults5V);
}
std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(m_index); }
void SetUserFaults3V3(int userFaults3V3) {
HALSIM_SetRoboRioUserFaults3V3(m_index, userFaults3V3);
}
void ResetData() { HALSIM_ResetRoboRioData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,88 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include <memory>
#include <utility>
#include "CallbackStore.h"
#include "MockData/SPIAccelerometerData.h"
namespace frc {
namespace sim {
class SPIAccelerometerSim {
public:
explicit SPIAccelerometerSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
bool GetActive() { return HALSIM_GetSPIAccelerometerActive(m_index); }
void SetActive(bool active) {
HALSIM_SetSPIAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
int GetRange() { return HALSIM_GetSPIAccelerometerRange(m_index); }
void SetRange(int range) { HALSIM_SetSPIAccelerometerRange(m_index, range); }
std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetX() { return HALSIM_GetSPIAccelerometerX(m_index); }
void SetX(double x) { HALSIM_SetSPIAccelerometerX(m_index, x); }
std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetY() { return HALSIM_GetSPIAccelerometerY(m_index); }
void SetY(double y) { HALSIM_SetSPIAccelerometerY(m_index, y); }
std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return std::move(store);
}
double GetZ() { return HALSIM_GetSPIAccelerometerZ(m_index); }
void SetZ(double z) { HALSIM_SetSPIAccelerometerZ(m_index, z); }
void ResetData() { HALSIM_ResetSPIAccelerometerData(m_index); }
private:
int m_index;
};
} // namespace sim
} // namespace frc
#endif // __FRC_ROBORIO__

View File

@@ -0,0 +1,22 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#ifndef __FRC_ROBORIO__
#include "MockData/MockHooks.h"
namespace frc {
namespace sim {
void WaitForProgramStart() { HALSIM_WaitForProgramStart(); }
void SetProgramStarted() { HALSIM_SetProgramStarted(); }
void RestartTiming() { HALSIM_RestartTiming(); }
} // namespace sim
} // namespace frc
#endif

View File

@@ -0,0 +1,13 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "Simulation/CallbackStore.h"
void frc::sim::CallbackStoreThunk(const char* name, void* param,
const HAL_Value* value) {
reinterpret_cast<CallbackStore*>(param)->callback(name, value);
}

View File

@@ -0,0 +1,161 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/AccelerometerData.h"
#include "edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerActiveCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerActiveCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelActiveCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerActiveCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getActive(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAccelerometerActive(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setActive(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAccelerometerActive(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerRangeCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerRangeCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelRangeCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerRangeCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getRange(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAccelerometerRange(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setRange(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetAccelerometerRange(index,
static_cast<HAL_AccelerometerRange>(value));
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerXCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerXCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelXCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerXCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getX(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerX(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setX(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerX(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerYCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerYCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelYCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerYCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getY(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerY(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setY(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerY(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerZCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerZCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelZCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerZCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getZ(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerZ(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setZ(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerZ(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_resetData(JNIEnv*,
jclass,
jint index) {
HALSIM_ResetAccelerometerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,102 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/AnalogGyroData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerAngleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroAngleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelAngleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroAngleCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getAngle(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogGyroAngle(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setAngle(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogGyroAngle(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerRateCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroRateCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelRateCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroRateCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getRate(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogGyroRate(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setRate(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogGyroRate(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogGyroInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogGyroInitialized(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogGyroData(index);
}
} // extern "C"

View File

@@ -0,0 +1,266 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/AnalogInData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getInitialized(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAnalogInInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogInInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAverageBitsCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAverageBitsCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAverageBitsCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAverageBitsCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAverageBits(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAnalogInAverageBits(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAverageBits(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetAnalogInAverageBits(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerOversampleBitsCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInOversampleBitsCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelOversampleBitsCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInOversampleBitsCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getOversampleBits(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInOversampleBits(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setOversampleBits(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInOversampleBits(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogInVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogInVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogInAccumulatorInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogInAccumulatorInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorValueCallback);
}
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorValue(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorValue(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorValue(
JNIEnv*, jclass, jint index, jlong value) {
HALSIM_SetAnalogInAccumulatorValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorCountCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCountCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorCountCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCountCallback);
}
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorCount(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorCount(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorCount(
JNIEnv*, jclass, jint index, jlong value) {
HALSIM_SetAnalogInAccumulatorCount(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorCenterCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCenterCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorCenterCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCenterCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorCenter(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorCenter(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorCenter(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInAccumulatorCenter(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorDeadbandCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorDeadbandCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorDeadbandCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorDeadband(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorDeadband(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorDeadband(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInAccumulatorDeadband(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogInData(index);
}
} // extern "C"

View File

@@ -0,0 +1,75 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/AnalogOutData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogOutVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogOutVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogOutVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogOutVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogOutInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogOutInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogOutInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogOutInitialized(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogOutData(index);
}
} // extern "C"

View File

@@ -0,0 +1,104 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/AnalogTriggerData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogTriggerInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogTriggerInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerTriggerLowerBoundCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelTriggerLowerBoundCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getTriggerLowerBound(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerTriggerLowerBound(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setTriggerLowerBound(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetAnalogTriggerTriggerLowerBound(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerTriggerUpperBoundCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelTriggerUpperBoundCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getTriggerUpperBound(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerTriggerUpperBound(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setTriggerUpperBound(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetAnalogTriggerTriggerUpperBound(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_resetData(JNIEnv*,
jclass,
jint index) {
HALSIM_ResetAnalogTriggerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,124 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "BufferCallbackStore.h"
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
void BufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);
}
void BufferCallbackStore::performCallback(const char* name, uint8_t* buffer,
uint32_t length) {
JNIEnv* env;
JavaVM* vm = sim::GetJVM();
bool didAttachThread = false;
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
if (tryGetEnv == JNI_EDETACHED) {
// Thread not attached
didAttachThread = true;
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
// Failed to attach, log and return
wpi::outs() << "Failed to attach\n";
wpi::outs().flush();
return;
}
} else if (tryGetEnv == JNI_EVERSION) {
wpi::outs() << "Invalid JVM Version requested\n";
wpi::outs().flush();
}
auto toCallbackArr =
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
static_cast<size_t>(length)});
env->CallVoidMethod(m_call, sim::GetBufferCallback(), MakeJString(env, name),
toCallbackArr, (jint)length);
jbyte* fromCallbackArr = reinterpret_cast<jbyte*>(
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));
for (size_t i = 0; i < length; i++) {
buffer[i] = fromCallbackArr[i];
}
env->ReleasePrimitiveArrayCritical(toCallbackArr, fromCallbackArr, JNI_ABORT);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
if (didAttachThread) {
vm->DetachCurrentThread();
}
}
void BufferCallbackStore::free(JNIEnv* env) { m_call.free(env); }
SIM_JniHandle sim::AllocateBufferCallback(
JNIEnv* env, jint index, jobject callback,
RegisterBufferCallbackFunc createCallback) {
auto callbackStore = std::make_shared<BufferCallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param, uint8_t* buffer,
uint32_t length) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
data->performCallback(name, buffer, length);
};
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeBufferCallbackFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(index, callback->getCallbackId());
callback->free(env);
}

View File

@@ -0,0 +1,44 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
namespace sim {
class BufferCallbackStore {
public:
void create(JNIEnv* env, jobject obj);
void performCallback(const char* name, uint8_t* buffer, uint32_t length);
void free(JNIEnv* env);
void setCallbackId(int32_t id) { callbackId = id; }
int32_t getCallbackId() { return callbackId; }
private:
wpi::java::JGlobal<jobject> m_call;
int32_t callbackId;
};
void InitializeBufferStore();
typedef int32_t (*RegisterBufferCallbackFunc)(int32_t index,
HAL_BufferCallback callback,
void* param);
typedef void (*FreeBufferCallbackFunc)(int32_t index, int32_t uid);
SIM_JniHandle AllocateBufferCallback(JNIEnv* env, jint index, jobject callback,
RegisterBufferCallbackFunc createCallback);
void FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeBufferCallbackFunc freeCallback);
} // namespace sim

View File

@@ -0,0 +1,193 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "CallbackStore.h"
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
void CallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);
}
void CallbackStore::performCallback(const char* name, const HAL_Value* value) {
JNIEnv* env;
JavaVM* vm = sim::GetJVM();
bool didAttachThread = false;
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
if (tryGetEnv == JNI_EDETACHED) {
// Thread not attached
didAttachThread = true;
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
// Failed to attach, log and return
wpi::outs() << "Failed to attach\n";
wpi::outs().flush();
return;
}
} else if (tryGetEnv == JNI_EVERSION) {
wpi::outs() << "Invalid JVM Version requested\n";
wpi::outs().flush();
}
env->CallVoidMethod(m_call, sim::GetNotifyCallback(), MakeJString(env, name),
(jint)value->type, (jlong)value->data.v_long,
(jdouble)value->data.v_double);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
if (didAttachThread) {
vm->DetachCurrentThread();
}
}
void CallbackStore::free(JNIEnv* env) { m_call.free(env); }
SIM_JniHandle sim::AllocateCallback(JNIEnv* env, jint index, jobject callback,
jboolean initialNotify,
RegisterCallbackFunc createCallback) {
auto callbackStore = std::make_shared<CallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param,
const HAL_Value* value) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
data->performCallback(name, value);
};
auto id = createCallback(index, callbackFunc, handleAsVoidPtr, initialNotify);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeCallbackFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(index, callback->getCallbackId());
callback->free(env);
}
SIM_JniHandle sim::AllocateChannelCallback(
JNIEnv* env, jint index, jint channel, jobject callback,
jboolean initialNotify, RegisterChannelCallbackFunc createCallback) {
auto callbackStore = std::make_shared<CallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param,
const HAL_Value* value) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
data->performCallback(name, value);
};
auto id = createCallback(index, channel, callbackFunc, handleAsVoidPtr,
initialNotify);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
jint channel,
FreeChannelCallbackFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(index, channel, callback->getCallbackId());
callback->free(env);
}
SIM_JniHandle sim::AllocateCallbackNoIndex(
JNIEnv* env, jobject callback, jboolean initialNotify,
RegisterCallbackNoIndexFunc createCallback) {
auto callbackStore = std::make_shared<CallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param,
const HAL_Value* value) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
data->performCallback(name, value);
};
auto id = createCallback(callbackFunc, handleAsVoidPtr, initialNotify);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
FreeCallbackNoIndexFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(callback->getCallbackId());
callback->free(env);
}

View File

@@ -0,0 +1,65 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
namespace sim {
class CallbackStore {
public:
void create(JNIEnv* env, jobject obj);
void performCallback(const char* name, const HAL_Value* value);
void free(JNIEnv* env);
void setCallbackId(int32_t id) { callbackId = id; }
int32_t getCallbackId() { return callbackId; }
private:
wpi::java::JGlobal<jobject> m_call;
int32_t callbackId;
};
void InitializeStore();
typedef int32_t (*RegisterCallbackFunc)(int32_t index,
HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);
typedef void (*FreeCallbackFunc)(int32_t index, int32_t uid);
typedef int32_t (*RegisterChannelCallbackFunc)(int32_t index, int32_t channel,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify);
typedef void (*FreeChannelCallbackFunc)(int32_t index, int32_t channel,
int32_t uid);
typedef int32_t (*RegisterCallbackNoIndexFunc)(HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify);
typedef void (*FreeCallbackNoIndexFunc)(int32_t uid);
SIM_JniHandle AllocateCallback(JNIEnv* env, jint index, jobject callback,
jboolean initialNotify,
RegisterCallbackFunc createCallback);
SIM_JniHandle AllocateChannelCallback(
JNIEnv* env, jint index, jint channel, jobject callback,
jboolean initialNotify, RegisterChannelCallbackFunc createCallback);
SIM_JniHandle AllocateCallbackNoIndex(
JNIEnv* env, jobject callback, jboolean initialNotify,
RegisterCallbackNoIndexFunc createCallback);
void FreeCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeCallbackFunc freeCallback);
void FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
jint channel, FreeChannelCallbackFunc freeCallback);
void FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
FreeCallbackNoIndexFunc freeCallback);
} // namespace sim

View File

@@ -0,0 +1,116 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "ConstBufferCallbackStore.h"
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeConstBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
void ConstBufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);
}
void ConstBufferCallbackStore::performCallback(const char* name,
const uint8_t* buffer,
uint32_t length) {
JNIEnv* env;
JavaVM* vm = sim::GetJVM();
bool didAttachThread = false;
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
if (tryGetEnv == JNI_EDETACHED) {
// Thread not attached
didAttachThread = true;
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
// Failed to attach, log and return
wpi::outs() << "Failed to attach\n";
wpi::outs().flush();
return;
}
} else if (tryGetEnv == JNI_EVERSION) {
wpi::outs() << "Invalid JVM Version requested\n";
wpi::outs().flush();
}
auto toCallbackArr =
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
static_cast<size_t>(length)});
env->CallVoidMethod(m_call, sim::GetConstBufferCallback(),
MakeJString(env, name), toCallbackArr, (jint)length);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
if (didAttachThread) {
vm->DetachCurrentThread();
}
}
void ConstBufferCallbackStore::free(JNIEnv* env) { m_call.free(env); }
SIM_JniHandle sim::AllocateConstBufferCallback(
JNIEnv* env, jint index, jobject callback,
RegisterConstBufferCallbackFunc createCallback) {
auto callbackStore = std::make_shared<ConstBufferCallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param, const uint8_t* buffer,
uint32_t length) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
data->performCallback(name, buffer, length);
};
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeConstBufferCallbackFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(index, callback->getCallbackId());
callback->free(env);
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
namespace sim {
class ConstBufferCallbackStore {
public:
void create(JNIEnv* env, jobject obj);
void performCallback(const char* name, const uint8_t* buffer,
uint32_t length);
void free(JNIEnv* env);
void setCallbackId(int32_t id) { callbackId = id; }
int32_t getCallbackId() { return callbackId; }
private:
wpi::java::JGlobal<jobject> m_call;
int32_t callbackId;
};
void InitializeConstBufferStore();
typedef int32_t (*RegisterConstBufferCallbackFunc)(
int32_t index, HAL_ConstBufferCallback callback, void* param);
typedef void (*FreeConstBufferCallbackFunc)(int32_t index, int32_t uid);
SIM_JniHandle AllocateConstBufferCallback(
JNIEnv* env, jint index, jobject callback,
RegisterConstBufferCallbackFunc createCallback);
void FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeConstBufferCallbackFunc freeCallback);
} // namespace sim

View File

@@ -0,0 +1,153 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/DIOData.h"
#include "edu_wpi_first_hal_sim_mockdata_DIODataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetDIOInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index, &HALSIM_CancelDIOValueCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getValue(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOValue(index);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setValue(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetDIOValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerPulseLengthCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOPulseLengthCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelPulseLengthCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOPulseLengthCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getPulseLength(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOPulseLength(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setPulseLength(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetDIOPulseLength(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerIsInputCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOIsInputCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelIsInputCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOIsInputCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getIsInput(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOIsInput(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setIsInput(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetDIOIsInput(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerFilterIndexCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOFilterIndexCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelFilterIndexCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOFilterIndexCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getFilterIndex(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOFilterIndex(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setFilterIndex(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetDIOFilterIndex(index, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetDIOData(index);
}
} // extern "C"

View File

@@ -0,0 +1,102 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/DigitalPWMData.h"
#include "edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetDigitalPWMInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetDigitalPWMInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerDutyCycleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMDutyCycleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelDutyCycleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMDutyCycleCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getDutyCycle(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetDigitalPWMDutyCycle(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setDutyCycle(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetDigitalPWMDutyCycle(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerPinCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMPinCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelPinCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMPinCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getPin(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDigitalPWMPin(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setPin(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetDigitalPWMPin(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetDigitalPWMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,283 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/DriverStationData.h"
#include "edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerEnabledCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationEnabledCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelEnabledCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationEnabledCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getEnabled(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationEnabled();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setEnabled(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationEnabled(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerAutonomousCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationAutonomousCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelAutonomousCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationAutonomousCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getAutonomous(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationAutonomous();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setAutonomous(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationAutonomous(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerTestCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify, &HALSIM_RegisterDriverStationTestCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelTestCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationTestCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getTest(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationTest();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setTest(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationTest(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerEStopCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify, &HALSIM_RegisterDriverStationEStopCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelEStopCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationEStopCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getEStop(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationEStop();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setEStop(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationEStop(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerFmsAttachedCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationFmsAttachedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelFmsAttachedCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationFmsAttachedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getFmsAttached(
JNIEnv*, jclass) {
return HALSIM_GetDriverStationFmsAttached();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setFmsAttached(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationFmsAttached(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerDsAttachedCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationDsAttachedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelDsAttachedCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationDsAttachedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getDsAttached(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationDsAttached();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setDsAttached(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationDsAttached(value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: setJoystickAxes
* Signature: (B[F)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setJoystickAxes(
JNIEnv* env, jclass, jbyte joystickNum, jfloatArray axesArray) {
HAL_JoystickAxes axes;
{
wpi::java::JFloatArrayRef jArrayRef(env, axesArray);
auto arrayRef = jArrayRef.array();
auto arraySize = arrayRef.size();
int maxCount =
arraySize < HAL_kMaxJoystickAxes ? arraySize : HAL_kMaxJoystickAxes;
axes.count = maxCount;
for (int i = 0; i < maxCount; i++) {
axes.axes[i] = arrayRef[i];
}
}
HALSIM_SetJoystickAxes(joystickNum, &axes);
return;
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: setJoystickPOVs
* Signature: (B[S)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setJoystickPOVs(
JNIEnv* env, jclass, jbyte joystickNum, jshortArray povsArray) {
HAL_JoystickPOVs povs;
{
wpi::java::JShortArrayRef jArrayRef(env, povsArray);
auto arrayRef = jArrayRef.array();
auto arraySize = arrayRef.size();
int maxCount =
arraySize < HAL_kMaxJoystickPOVs ? arraySize : HAL_kMaxJoystickPOVs;
povs.count = maxCount;
for (int i = 0; i < maxCount; i++) {
povs.povs[i] = arrayRef[i];
}
}
HALSIM_SetJoystickPOVs(joystickNum, &povs);
return;
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: setJoystickButtons
* Signature: (BII)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setJoystickButtons(
JNIEnv* env, jclass, jbyte joystickNum, jint buttons, jint count) {
if (count > 32) {
count = 32;
}
HAL_JoystickButtons joystickButtons;
joystickButtons.count = count;
joystickButtons.buttons = buttons;
HALSIM_SetJoystickButtons(joystickNum, &joystickButtons);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: setMatchInfo
* Signature: (Ledu/wpi/first/wpilibj/hal/MatchInfoData;)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setMatchInfo(
JNIEnv* env, jclass, jobject info) {}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: registerAllCallbacks
* Signature: (Ledu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerAllCallbacks(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
[](HAL_NotifyCallback cb, void* param, HAL_Bool in) {
HALSIM_RegisterDriverStationAllCallbacks(cb, param, in);
return 0;
});
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: notifyNewData
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_notifyNewData(JNIEnv*,
jclass) {
HALSIM_NotifyDriverStationNewData();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_resetData(JNIEnv*,
jclass) {
HALSIM_ResetDriverStationData();
}
} // extern "C"

View File

@@ -0,0 +1,235 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/EncoderData.h"
#include "edu_wpi_first_hal_sim_mockdata_EncoderDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getInitialized(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetEncoderInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerCountCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderCountCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelCountCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderCountCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getCount(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderCount(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setCount(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetEncoderCount(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerPeriodCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderPeriodCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelPeriodCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderPeriodCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getPeriod(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderPeriod(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setPeriod(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetEncoderPeriod(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerResetCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderResetCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelResetCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderResetCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getReset(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderReset(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setReset(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetEncoderReset(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerMaxPeriodCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderMaxPeriodCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelMaxPeriodCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderMaxPeriodCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getMaxPeriod(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderMaxPeriod(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setMaxPeriod(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetEncoderMaxPeriod(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerDirectionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderDirectionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelDirectionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderDirectionCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getDirection(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderDirection(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setDirection(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderDirection(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerReverseDirectionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderReverseDirectionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelReverseDirectionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderReverseDirectionCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getReverseDirection(
JNIEnv*, jclass, jint index) {
return HALSIM_GetEncoderReverseDirection(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setReverseDirection(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderReverseDirection(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerSamplesToAverageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderSamplesToAverageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelSamplesToAverageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderSamplesToAverageCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getSamplesToAverage(
JNIEnv*, jclass, jint index) {
return HALSIM_GetEncoderSamplesToAverage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setSamplesToAverage(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetEncoderSamplesToAverage(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetEncoderData(index);
}
} // extern "C"

View File

@@ -0,0 +1,124 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "BufferCallbackStore.h"
#include "CallbackStore.h"
#include "ConstBufferCallbackStore.h"
#include "MockData/I2CData.h"
#include "edu_wpi_first_hal_sim_mockdata_I2CDataJNI.h"
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerInitializedCallback
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterI2CInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelI2CInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetI2CInitialized(index);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetI2CInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerReadCallback
* Signature: (ILedu/wpi/first/hal/sim/BufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_registerReadCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateBufferCallback(env, index, callback,
&HALSIM_RegisterI2CReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: cancelReadCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelReadCallback(JNIEnv* env,
jclass,
jint index,
jint handle) {
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelI2CReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerWriteCallback
* Signature: (ILedu/wpi/first/hal/sim/ConstBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_registerWriteCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateConstBufferCallback(env, index, callback,
&HALSIM_RegisterI2CWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: cancelWriteCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelWriteCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeConstBufferCallback(env, handle, index,
&HALSIM_CancelI2CWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetI2CData(index);
}
} // extern "C"

View File

@@ -0,0 +1,246 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/PCMData.h"
#include "edu_wpi_first_hal_sim_mockdata_PCMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerSolenoidInitializedCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
&HALSIM_RegisterPCMSolenoidInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelSolenoidInitializedCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPCMSolenoidInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getSolenoidInitialized(
JNIEnv*, jclass, jint index, jint channel) {
return HALSIM_GetPCMSolenoidInitialized(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setSolenoidInitialized(
JNIEnv*, jclass, jint index, jint channel, jboolean value) {
HALSIM_SetPCMSolenoidInitialized(index, channel, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerSolenoidOutputCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
&HALSIM_RegisterPCMSolenoidOutputCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelSolenoidOutputCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPCMSolenoidOutputCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getSolenoidOutput(JNIEnv*,
jclass,
jint index,
jint channel) {
return HALSIM_GetPCMSolenoidOutput(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setSolenoidOutput(
JNIEnv*, jclass, jint index, jint channel, jboolean value) {
HALSIM_SetPCMSolenoidOutput(index, channel, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMCompressorInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMCompressorInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorOnCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorOnCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorOnCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorOnCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorOn(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPCMCompressorOn(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorOn(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPCMCompressorOn(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerClosedLoopEnabledCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMClosedLoopEnabledCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelClosedLoopEnabledCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMClosedLoopEnabledCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getClosedLoopEnabled(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMClosedLoopEnabled(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setClosedLoopEnabled(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMClosedLoopEnabled(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerPressureSwitchCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMPressureSwitchCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelPressureSwitchCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMPressureSwitchCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getPressureSwitch(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetPCMPressureSwitch(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setPressureSwitch(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMPressureSwitch(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorCurrentCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorCurrentCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorCurrent(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMCompressorCurrent(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorCurrent(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetPCMCompressorCurrent(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_PCMSim
* Method: registerAllNonSolenoidCallbacks
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerAllNonSolenoidCallbacks(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
sim::AllocateCallback(
env, index, callback, initialNotify,
[](int32_t index, HAL_NotifyCallback cb, void* param, HAL_Bool in) {
HALSIM_RegisterPCMAllNonSolenoidCallbacks(index, cb, param, in);
return 0;
});
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_PCMSim
* Method: registerAllSolenoidCallbacks
* Signature: (IILedu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerAllSolenoidCallbacks(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
[](int32_t index, int32_t channel, HAL_NotifyCallback cb, void* param,
HAL_Bool in) {
HALSIM_RegisterPCMAllSolenoidCallbacks(index, channel, cb, param, in);
return 0;
});
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPCMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,133 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/PDPData.h"
#include "edu_wpi_first_hal_sim_mockdata_PDPDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPDPInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerTemperatureCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPTemperatureCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelTemperatureCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPTemperatureCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getTemperature(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPTemperature(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setTemperature(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPDPTemperature(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPDPVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerCurrentCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(env, index, channel, callback,
initialNotify,
&HALSIM_RegisterPDPCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelCurrentCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPDPCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getCurrent(JNIEnv*, jclass,
jint index,
jint channel) {
return HALSIM_GetPDPCurrent(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setCurrent(JNIEnv*, jclass,
jint index,
jint channel,
jdouble value) {
HALSIM_SetPDPCurrent(index, channel, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPDPData(index);
}
} // extern "C"

View File

@@ -0,0 +1,180 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/PWMData.h"
#include "edu_wpi_first_hal_sim_mockdata_PWMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPWMInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerRawValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMRawValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelRawValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMRawValueCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getRawValue(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMRawValue(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setRawValue(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetPWMRawValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerSpeedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMSpeedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelSpeedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index, &HALSIM_CancelPWMSpeedCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getSpeed(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMSpeed(index);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setSpeed(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetPWMSpeed(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerPositionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMPositionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelPositionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMPositionCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getPosition(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMPosition(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setPosition(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPWMPosition(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerPeriodScaleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMPeriodScaleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelPeriodScaleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMPeriodScaleCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getPeriodScale(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMPeriodScale(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setPeriodScale(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetPWMPeriodScale(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerZeroLatchCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMZeroLatchCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelZeroLatchCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMZeroLatchCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getZeroLatch(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMZeroLatch(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setZeroLatch(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPWMZeroLatch(index, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPWMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,128 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/RelayData.h"
#include "edu_wpi_first_hal_sim_mockdata_RelayDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerInitializedForwardCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayInitializedForwardCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelInitializedForwardCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayInitializedForwardCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getInitializedForward(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRelayInitializedForward(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setInitializedForward(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRelayInitializedForward(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerInitializedReverseCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayInitializedReverseCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelInitializedReverseCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayInitializedReverseCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getInitializedReverse(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRelayInitializedReverse(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setInitializedReverse(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRelayInitializedReverse(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerForwardCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayForwardCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelForwardCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayForwardCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getForward(JNIEnv*, jclass,
jint index) {
return HALSIM_GetRelayForward(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setForward(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetRelayForward(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerReverseCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayReverseCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelReverseCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayReverseCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getReverse(JNIEnv*, jclass,
jint index) {
return HALSIM_GetRelayReverse(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setReverse(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetRelayReverse(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetRelayData(index);
}
} // extern "C"

View File

@@ -0,0 +1,423 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/RoboRioData.h"
#include "edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerFPGAButtonCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioFPGAButtonCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelFPGAButtonCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioFPGAButtonCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getFPGAButton(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioFPGAButton(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setFPGAButton(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioFPGAButton(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerVInVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioVInVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelVInVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioVInVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getVInVoltage(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioVInVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setVInVoltage(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioVInVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerVInCurrentCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioVInCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelVInCurrentCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioVInCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getVInCurrent(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioVInCurrent(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setVInCurrent(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioVInCurrent(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage6VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage6V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage6V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent6VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent6V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent6V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive6VCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive6V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserActive6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive6V(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage5VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage5V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage5V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent5VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent5V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent5V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive5VCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive5V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserActive5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive5V(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage3V3Callback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage3V3(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent3V3Callback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent3V3(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive3V3Callback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserActive3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive3V3(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults6VCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults6V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserFaults6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults6V(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetRoboRioUserFaults6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults5VCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults5V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserFaults5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults5V(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetRoboRioUserFaults5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults3V3Callback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserFaults3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults3V3(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetRoboRioUserFaults3V3(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetRoboRioData(index);
}
} // extern "C"

View File

@@ -0,0 +1,155 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "CallbackStore.h"
#include "MockData/SPIAccelerometerData.h"
#include "edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerActiveCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerActiveCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelActiveCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerActiveCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getActive(
JNIEnv*, jclass, jint index) {
return HALSIM_GetSPIAccelerometerActive(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setActive(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetSPIAccelerometerActive(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerRangeCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerRangeCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelRangeCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerRangeCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getRange(
JNIEnv*, jclass, jint index) {
return HALSIM_GetSPIAccelerometerRange(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setRange(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetSPIAccelerometerRange(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerXCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerXCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelXCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerXCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getX(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerX(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setX(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerX(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerYCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerYCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelYCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerYCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getY(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerY(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setY(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerY(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerZCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerZCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelZCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerZCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getZ(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerZ(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setZ(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerZ(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetSPIAccelerometerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,149 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "BufferCallbackStore.h"
#include "CallbackStore.h"
#include "ConstBufferCallbackStore.h"
#include "MockData/SPIData.h"
#include "SpiReadAutoReceiveBufferCallbackStore.h"
#include "edu_wpi_first_hal_sim_mockdata_SPIDataJNI.h"
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerInitializedCallback
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetSPIInitialized(index);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetSPIInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerReadCallback
* Signature: (ILedu/wpi/first/hal/sim/BufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerReadCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateBufferCallback(env, index, callback,
&HALSIM_RegisterSPIReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelReadCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelReadCallback(JNIEnv* env,
jclass,
jint index,
jint handle) {
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelSPIReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerWriteCallback
* Signature: (ILedu/wpi/first/hal/sim/ConstBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerWriteCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateConstBufferCallback(env, index, callback,
&HALSIM_RegisterSPIWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelWriteCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelWriteCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeConstBufferCallback(env, handle, index,
&HALSIM_CancelSPIWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerReadAutoReceiveBufferCallback
* Signature: (ILedu/wpi/first/hal/sim/SpiReadAutoReceiveBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerReadAutoReceiveBufferCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateSpiBufferCallback(
env, index, callback, &HALSIM_RegisterSPIReadAutoReceivedDataCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelReadAutoReceiveBufferCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelReadAutoReceiveBufferCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeSpiBufferCallback(env, handle, index,
&HALSIM_CancelSPIReadAutoReceivedDataCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetSPIData(index);
}
} // extern "C"

View File

@@ -0,0 +1,151 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "BufferCallbackStore.h"
#include "CallbackStore.h"
#include "ConstBufferCallbackStore.h"
#include "HAL/HAL.h"
#include "HAL/cpp/Log.h"
#include "HAL/handles/HandlesInternal.h"
#include "MockData/MockHooks.h"
#include "SimulatorJNI.h"
#include "SpiReadAutoReceiveBufferCallbackStore.h"
#include "edu_wpi_first_hal_sim_mockdata_SimulatorJNI.h"
using namespace wpi::java;
static JavaVM* jvm = nullptr;
static JClass simValueCls;
static JClass notifyCallbackCls;
static JClass bufferCallbackCls;
static JClass constBufferCallbackCls;
static JClass spiReadAutoReceiveBufferCallbackCls;
static jmethodID notifyCallbackCallback;
static jmethodID bufferCallbackCallback;
static jmethodID constBufferCallbackCallback;
static jmethodID spiReadAutoReceiveBufferCallbackCallback;
namespace sim {
jint SimOnLoad(JavaVM* vm, void* reserved) {
jvm = vm;
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
return JNI_ERR;
simValueCls = JClass(env, "edu/wpi/first/wpilibj/sim/SimValue");
if (!simValueCls) return JNI_ERR;
notifyCallbackCls = JClass(env, "edu/wpi/first/wpilibj/sim/NotifyCallback");
if (!notifyCallbackCls) return JNI_ERR;
notifyCallbackCallback = env->GetMethodID(notifyCallbackCls, "callbackNative",
"(Ljava/lang/String;IJD)V");
if (!notifyCallbackCallback) return JNI_ERR;
bufferCallbackCls = JClass(env, "edu/wpi/first/wpilibj/sim/BufferCallback");
if (!bufferCallbackCls) return JNI_ERR;
bufferCallbackCallback = env->GetMethodID(bufferCallbackCls, "callback",
"(Ljava/lang/String;[BI)V");
if (!bufferCallbackCallback) return JNI_ERR;
constBufferCallbackCls =
JClass(env, "edu/wpi/first/wpilibj/sim/ConstBufferCallback");
if (!constBufferCallbackCls) return JNI_ERR;
constBufferCallbackCallback = env->GetMethodID(
constBufferCallbackCls, "callback", "(Ljava/lang/String;[BI)V");
if (!constBufferCallbackCallback) return JNI_ERR;
spiReadAutoReceiveBufferCallbackCls =
JClass(env, "edu/wpi/first/wpilibj/sim/SpiReadAutoReceiveBufferCallback");
if (!spiReadAutoReceiveBufferCallbackCls) return JNI_ERR;
spiReadAutoReceiveBufferCallbackCallback =
env->GetMethodID(spiReadAutoReceiveBufferCallbackCls, "callback",
"(Ljava/lang/String;[BI)I");
if (!spiReadAutoReceiveBufferCallbackCallback) return JNI_ERR;
InitializeStore();
InitializeBufferStore();
InitializeConstBufferStore();
InitializeSpiBufferStore();
return JNI_VERSION_1_6;
}
void SimOnUnload(JavaVM* vm, void* reserved) {
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
return;
simValueCls.free(env);
notifyCallbackCls.free(env);
bufferCallbackCls.free(env);
constBufferCallbackCls.free(env);
spiReadAutoReceiveBufferCallbackCls.free(env);
jvm = nullptr;
}
JavaVM* GetJVM() { return jvm; }
jmethodID GetNotifyCallback() { return notifyCallbackCallback; }
jmethodID GetBufferCallback() { return bufferCallbackCallback; }
jmethodID GetConstBufferCallback() { return constBufferCallbackCallback; }
jmethodID GetSpiReadAutoReceiveBufferCallback() {
return spiReadAutoReceiveBufferCallbackCallback;
}
} // namespace sim
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: waitForProgramStart
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_waitForProgramStart(JNIEnv*,
jclass) {
HALSIM_WaitForProgramStart();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: setProgramStarted
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_setProgramStarted(JNIEnv*,
jclass) {
HALSIM_SetProgramStarted();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: restartTiming
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_restartTiming(JNIEnv*,
jclass) {
HALSIM_RestartTiming();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: resetHandles
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_resetHandles(JNIEnv*, jclass) {
hal::HandleBase::ResetGlobalHandles();
}
} // extern "C"

View File

@@ -0,0 +1,25 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "MockData/HAL_Value.h"
#include "jni.h"
typedef HAL_Handle SIM_JniHandle;
namespace sim {
JavaVM* GetJVM();
jmethodID GetNotifyCallback();
jmethodID GetBufferCallback();
jmethodID GetConstBufferCallback();
jmethodID GetSpiReadAutoReceiveBufferCallback();
} // namespace sim

View File

@@ -0,0 +1,130 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "SpiReadAutoReceiveBufferCallbackStore.h"
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<
SIM_JniHandle, SpiReadAutoReceiveBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
namespace sim {
void InitializeSpiBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle,
SpiReadAutoReceiveBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
void SpiReadAutoReceiveBufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);
}
int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback(
const char* name, unsigned char* buffer, int32_t numToRead) {
JNIEnv* env;
JavaVM* vm = sim::GetJVM();
bool didAttachThread = false;
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
if (tryGetEnv == JNI_EDETACHED) {
// Thread not attached
didAttachThread = true;
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
// Failed to attach, log and return
wpi::outs() << "Failed to attach\n";
wpi::outs().flush();
return -1;
}
} else if (tryGetEnv == JNI_EVERSION) {
wpi::outs() << "Invalid JVM Version requested\n";
wpi::outs().flush();
}
auto toCallbackArr =
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
static_cast<size_t>(numToRead)});
jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(),
MakeJString(env, name), toCallbackArr,
(jint)numToRead);
jbyte* fromCallbackArr = reinterpret_cast<jbyte*>(
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));
for (int i = 0; i < ret; i++) {
buffer[i] = fromCallbackArr[i];
}
env->ReleasePrimitiveArrayCritical(toCallbackArr, fromCallbackArr, JNI_ABORT);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
if (didAttachThread) {
vm->DetachCurrentThread();
}
return ret;
}
void SpiReadAutoReceiveBufferCallbackStore::free(JNIEnv* env) {
m_call.free(env);
}
SIM_JniHandle sim::AllocateSpiBufferCallback(
JNIEnv* env, jint index, jobject callback,
RegisterSpiBufferCallbackFunc createCallback) {
auto callbackStore =
std::make_shared<SpiReadAutoReceiveBufferCallbackStore>();
auto handle = callbackHandles->Allocate(callbackStore);
if (handle == HAL_kInvalidHandle) {
return -1;
}
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
callbackStore->create(env, callback);
auto callbackFunc = [](const char* name, void* param, unsigned char* buffer,
int32_t numToRead, int32_t* outputCount) {
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
auto data = callbackHandles->Get(handle);
if (!data) return;
*outputCount = data->performCallback(name, buffer, numToRead);
};
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
callbackStore->setCallbackId(id);
return handle;
}
void sim::FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeSpiBufferCallbackFunc freeCallback) {
auto callback = callbackHandles->Free(handle);
freeCallback(index, callback->getCallbackId());
callback->free(env);
}

View File

@@ -0,0 +1,46 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <jni.h>
#include <wpi/jni_util.h>
#include "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "MockData/SPIData.h"
#include "SimulatorJNI.h"
namespace sim {
class SpiReadAutoReceiveBufferCallbackStore {
public:
void create(JNIEnv* env, jobject obj);
int32_t performCallback(const char* name, unsigned char* buffer,
int32_t numToRead);
void free(JNIEnv* env);
void setCallbackId(int32_t id) { callbackId = id; }
int32_t getCallbackId() { return callbackId; }
private:
wpi::java::JGlobal<jobject> m_call;
int32_t callbackId;
};
void InitializeSpiBufferStore();
typedef int32_t (*RegisterSpiBufferCallbackFunc)(
int32_t index, HAL_SpiReadAutoReceiveBufferCallback callback, void* param);
typedef void (*FreeSpiBufferCallbackFunc)(int32_t index, int32_t uid);
SIM_JniHandle AllocateSpiBufferCallback(
JNIEnv* env, jint index, jobject callback,
RegisterSpiBufferCallbackFunc createCallback);
void FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeSpiBufferCallbackFunc freeCallback);
} // namespace sim

View File

@@ -1,23 +0,0 @@
// This will be removed when new sim is added in
#include <jni.h>
static JavaVM* jvm = nullptr;
namespace sim {
jint SimOnLoad(JavaVM* vm, void* reserved) {
jvm = vm;
JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK)
return JNI_ERR;
return JNI_VERSION_1_6;
}
void SimOnUnload(JavaVM * vm, void* reserved) {
JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK)
return;
jvm = nullptr;
}
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import edu.wpi.first.wpilibj.hal.AccelerometerJNI;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.sim.AccelerometerSim;
import edu.wpi.first.wpilibj.sim.CallbackStore;
public class AccelerometerSimTest {
static class TriggeredStore {
public boolean wasTriggered = false;
public boolean setValue = true;
}
@Test
public void testCallbacks() {
HAL.initialize(500, 0);
AccelerometerSim sim = new AccelerometerSim();
sim.resetData();
TriggeredStore store = new TriggeredStore();
try (CallbackStore cb = sim.registerActiveCallback((s, v) -> {
store.wasTriggered = true;
store.setValue = v.getBoolean();
}, false)) {
assertFalse(store.wasTriggered);
AccelerometerJNI.setAccelerometerActive(true);
assertTrue(store.wasTriggered);
assertTrue(store.setValue);
}
}
}

View File

@@ -0,0 +1,42 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "HAL/Accelerometer.h"
#include "HAL/HAL.h"
#include "Simulation/AccelerometerSim.h"
#include "gtest/gtest.h"
using namespace frc::sim;
namespace hal {
TEST(AcclerometerSimTests, TestActiveCallback) {
HAL_Initialize(500, 0);
AccelerometerSim sim{0};
sim.ResetData();
bool wasTriggered = false;
bool lastValue = false;
auto cb = sim.RegisterActiveCallback(
[&](wpi::StringRef name, const HAL_Value* value) {
wasTriggered = true;
lastValue = value->data.v_boolean;
},
false);
EXPECT_FALSE(wasTriggered);
HAL_SetAccelerometerActive(true);
EXPECT_TRUE(wasTriggered);
EXPECT_TRUE(lastValue);
}
} // namespace hal

View File

@@ -9,6 +9,7 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.hal.AnalogJNI;
import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.sim.AnalogInSim;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.util.AllocationException;
@@ -350,4 +351,8 @@ public class AnalogInput extends SensorBase implements PIDSource, Sendable {
builder.setSmartDashboardType("Analog Input");
builder.addDoubleProperty("Value", this::getAverageVoltage, null);
}
public AnalogInSim getSimObject() {
return new AnalogInSim(m_channel);
}
}

View File

@@ -9,6 +9,7 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.hal.AnalogJNI;
import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.sim.AnalogOutSim;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
@@ -66,4 +67,8 @@ public class AnalogOutput extends SendableBase implements Sendable {
builder.setSmartDashboardType("Analog Output");
builder.addDoubleProperty("Value", this::getVoltage, this::setVoltage);
}
public AnalogOutSim getSimObject() {
return new AnalogOutSim(m_channel);
}
}

View File

@@ -11,6 +11,7 @@ import edu.wpi.first.wpilibj.hal.AccelerometerJNI;
import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.interfaces.Accelerometer;
import edu.wpi.first.wpilibj.sim.AccelerometerSim;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
/**
@@ -97,4 +98,8 @@ public class BuiltInAccelerometer extends SensorBase implements Accelerometer, S
builder.addDoubleProperty("Y", this::getY, null);
builder.addDoubleProperty("Z", this::getZ, null);
}
public AccelerometerSim getSimObject() {
return new AccelerometerSim();
}
}

View File

@@ -0,0 +1,47 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import edu.wpi.first.wpilibj.AnalogInput;
import edu.wpi.first.wpilibj.hal.HAL;
public class AnalogInputSimTest {
static class DoubleStore {
public boolean wasTriggered = false;
public boolean wasCorrectType = false;
public double setValue = 0;
}
@Test
public void testSetCallback() {
HAL.initialize(500, 0);
AnalogInput input = new AnalogInput(5);
AnalogInSim inputSim = input.getSimObject();
for (double i = 0; i < 5.0; i+=0.1) {
inputSim.setVoltage(0);
assertEquals(input.getVoltage(), 0, 0.001);
inputSim.setVoltage(i);
assertEquals(input.getVoltage(), i, 0.001);
}
}
}

View File

@@ -0,0 +1,69 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.sim;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import edu.wpi.first.wpilibj.AnalogOutput;
import edu.wpi.first.wpilibj.hal.HAL;
public class AnalogOutputSimTest {
static class DoubleStore {
public boolean wasTriggered = false;
public boolean wasCorrectType = false;
public double setValue = -1;
public void reset() {
wasCorrectType = false;
wasTriggered = false;
setValue = -1;
}
}
@Test
public void testSetCallback() {
HAL.initialize(500, 0);
AnalogOutput output = new AnalogOutput(0);
output.setVoltage(0.5);
AnalogOutSim outputSim = output.getSimObject();
DoubleStore store = new DoubleStore();
try (CallbackStore cb = outputSim.registerVoltageCallback((s, v) -> {
store.wasTriggered = true;
store.wasCorrectType = true;
store.setValue = v.getDouble();
}, false)) {
assertFalse(store.wasTriggered);
for (double i = 0.1; i < 5.0; i+=0.1) {
store.reset();
output.setVoltage(0);
assertTrue(store.wasTriggered);
assertEquals(store.setValue, 0, 0.001);
store.reset();
output.setVoltage(i);
assertTrue(store.wasTriggered);
assertEquals(store.setValue, i, 0.001);
}
}
}
}