/*----------------------------------------------------------------------------*/ /* Copyright (c) 2018-2020 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 "frc/simulation/AnalogOutputSim.h" #include #include #include #include "frc/AnalogOutput.h" using namespace frc; using namespace frc::sim; AnalogOutputSim::AnalogOutputSim(const AnalogOutput& analogOutput) : m_index{analogOutput.GetChannel()} {} AnalogOutputSim::AnalogOutputSim(int channel) : m_index{channel} {} std::unique_ptr AnalogOutputSim::RegisterVoltageCallback( NotifyCallback callback, bool initialNotify) { auto store = std::make_unique( m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback); store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback( m_index, &CallbackStoreThunk, store.get(), initialNotify)); return store; } double AnalogOutputSim::GetVoltage() const { return HALSIM_GetAnalogOutVoltage(m_index); } void AnalogOutputSim::SetVoltage(double voltage) { HALSIM_SetAnalogOutVoltage(m_index, voltage); } std::unique_ptr AnalogOutputSim::RegisterInitializedCallback( NotifyCallback callback, bool initialNotify) { auto store = std::make_unique( m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback); store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback( m_index, &CallbackStoreThunk, store.get(), initialNotify)); return store; } bool AnalogOutputSim::GetInitialized() const { return HALSIM_GetAnalogOutInitialized(m_index); } void AnalogOutputSim::SetInitialized(bool initialized) { HALSIM_SetAnalogOutInitialized(m_index, initialized); } void AnalogOutputSim::ResetData() { HALSIM_ResetAnalogOutData(m_index); }