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

@@ -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;
}
}