mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Fixes HALSim_Print build to be the standardized pattern (#721)
Now publishes in zips, and with proper artifacts. The code files just moved, and no changes.
This commit is contained in:
committed by
Peter Johnson
parent
42096fac3f
commit
c885251367
29
simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp
Normal file
29
simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 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 "PrintPWM.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "MockData/HAL_Value.h"
|
||||
#include "MockData/NotifyListener.h"
|
||||
#include "MockData/PWMData.h"
|
||||
|
||||
static void PWMCallback(const char* name, void* param,
|
||||
const struct HAL_Value* value) {
|
||||
auto pwm = static_cast<PrintPWM*>(param);
|
||||
pwm->Publish(value->data.v_double);
|
||||
}
|
||||
|
||||
PrintPWM::PrintPWM(int port) {
|
||||
m_port = port;
|
||||
HALSIM_RegisterPWMSpeedCallback(port, PWMCallback, this, false);
|
||||
}
|
||||
|
||||
void PrintPWM::Publish(double value) {
|
||||
std::cout << "PWM " << m_port << ": " << value << std::endl;
|
||||
}
|
||||
34
simulation/halsim_print/src/main/native/cpp/main.cpp
Normal file
34
simulation/halsim_print/src/main/native/cpp/main.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 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 <iostream>
|
||||
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "HALSimPrint.h"
|
||||
#include "PrintPWM.h"
|
||||
|
||||
/**
|
||||
* Currently, robots never terminate, so we keep a single static object
|
||||
* and it is never properly released or cleaned up.
|
||||
*/
|
||||
static HALSimPrint halsim;
|
||||
|
||||
extern "C" {
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int HALSIM_InitExtension(void) {
|
||||
std::cout << "Print Simulator Initializing." << std::endl;
|
||||
|
||||
int pwmCount = HAL_GetNumPWMChannels();
|
||||
halsim.m_pwms.reserve(pwmCount);
|
||||
for (int i = 0; i < pwmCount; i++) halsim.m_pwms.emplace_back(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user