Fixed C++ side of artf2604 in FRCSim - synchronized C++ codebases, updated examples.

Change-Id: I2fdc9deb4c8e249448dcbda4214fd900c2bc4ea8
This commit is contained in:
Colby Skeggs
2014-06-24 10:37:02 -07:00
parent 02e19a0147
commit ff597e6ac4
72 changed files with 763 additions and 861 deletions

View File

@@ -3,9 +3,7 @@
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef QUAD_ENCODER_H_
#define QUAD_ENCODER_H_
#pragma once
#include "simulation/SimEncoder.h"
#include "CounterBase.h"
@@ -21,22 +19,26 @@
* reverse direction counting. When creating QuadEncoders, a direction is supplied that changes the
* sense of the output to make code more readable if the encoder is mounted such that forward movement
* generates negative values. Quadrature encoders have two digital outputs, an A Channel and a B Channel
* that are out of phase with each other to allow the FPGA to do direction sensing.
* that are out of phase with each other to allow the FPGA to do direction sensing.
*/
class Encoder: public SensorBase, public CounterBase, public PIDSource, public LiveWindowSendable
class Encoder : public SensorBase, public CounterBase, public PIDSource, public LiveWindowSendable
{
public:
Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
Encoder(uint8_t aModuleNumber, uint32_t aChannel, uint8_t bModuleNumber, uint32_t _bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection = false,
EncodingType encodingType = k4X);
// TODO: [Not Supported] Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
// TODO: [Not Supported] Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
virtual ~Encoder();
// CounterBase interface
void Start();
int32_t Get();
int32_t GetRaw();
void Reset();
void Stop();
double GetPeriod();
void SetMaxPeriod(double maxPeriod);
bool GetStopped();
bool GetDirection();
double GetDistance();
@@ -48,7 +50,7 @@ public:
int GetSamplesToAverage();
void SetPIDSourceParameter(PIDSourceParameter pidSource);
double PIDGet();
void UpdateTable();
void StartLiveWindowMode();
void StopLiveWindowMode();
@@ -57,23 +59,19 @@ public:
ITable * GetTable();
private:
void InitEncoder(int slotA, int channelA, int slotB, int channelB,
bool _reverseDirection, EncodingType encodingType);
void InitEncoder(int channelA, int channelB, bool _reverseDirection, EncodingType encodingType);
double DecodingScaleFactor();
// TODO: [Not Supported] DigitalSource *m_aSource; // the A phase of the quad encoder
// TODO: [Not Supported] DigitalSource *m_bSource; // the B phase of the quad encoder
// TODO: [Not Supported] bool m_allocatedASource; // was the A source allocated locally?
// TODO: [Not Supported] bool m_allocatedBSource; // was the B source allocated locally?
int slotA, channelA, slotB, channelB;
int channelA, channelB;
double m_distancePerPulse; // distance of travel for each encoder tick
EncodingType m_encodingType; // Encoding type
PIDSourceParameter m_pidSource; // Encoder parameter that sources a PID controller
bool reversed;
SimEncoder* impl;
PIDSourceParameter m_pidSource; // Encoder parameter that sources a PID controller
bool reversed;
SimEncoder* impl;
ITable *m_table;
};
#endif