Counter::Counter(AnalogTrigger &trigger)
{
	InitCounter();
	SetUpSource(trigger.CreateOutput(AnalogTriggerOutput::kState));
	ClearDownSource();
	m_allocatedUpSource = true;
}
示例#2
0
xCounter::xCounter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL),
	m_encodingType(encodingType)
{
	if (encodingType != k1X && encodingType != k2X)
	{
		wpi_setWPIErrorWithContext(ParameterOutOfRange, "Counter only supports 1X and 2X quadrature decoding.");
		return;
	}
	InitCounter(kExternalDirection);
	SetUpSource(upSource);
	SetDownSource(downSource);
	tRioStatusCode localStatus = NiFpga_Status_Success;

	if (encodingType == k1X)
	{
		SetUpSourceEdge(true, false);
		m_counter->writeTimerConfig_AverageSize(1, &localStatus);
	}
	else
	{
		SetUpSourceEdge(true, true);
		m_counter->writeTimerConfig_AverageSize(2, &localStatus);
	}

	wpi_setError(localStatus);
	SetDownSourceEdge(inverted, true);
}
示例#3
0
/**
 * Create an instance of a Counter object.
 * Create an up-Counter instance given a channel. The default digital module is assumed.
 */
Counter::Counter(UINT32 channel) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL)
{
	InitCounter();
	SetUpSource(channel);
	ClearDownSource();
}
示例#4
0
文件: Counter.cpp 项目: 0xacf/wpilib
/**
 * Create an instance of a Counter object.
 * Create an instance of an up-Counter given a digital module and a channel.
 * @param moduleNumber The digital module (1 or 2).
 * @param channel The channel in the digital module
 */
Counter::Counter(uint8_t moduleNumber, uint32_t channel) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL)
{
	InitCounter();
	SetUpSource(moduleNumber, channel);
	ClearDownSource();
}
示例#5
0
Counter::Counter(DigitalSource &source) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL)
{
	InitCounter();
	SetUpSource(&source);
	ClearDownSource();
}
示例#6
0
/**
 * Create an instance of a Counter object.
 * Create an instance of an up-Counter given a digital module and a channel.
 * @param moduleNumber The digital module (1 or 2).
 * @param channel The channel in the digital module
 */
Counter::Counter(UINT8 moduleNumber, UINT32 channel) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL)
{
	InitCounter();
	SetUpSource(moduleNumber, channel);
	ClearDownSource();
}
示例#7
0
/**
 * Create an instance of a Counter object.
 * Create an instance of a simple up-Counter given an analog trigger.
 * Use the trigger state output from the analog trigger.
 */
Counter::Counter(AnalogTrigger *trigger) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL)
{
	InitCounter();
	SetUpSource(trigger->CreateOutput(AnalogTriggerOutput::kState));
	ClearDownSource();
	m_allocatedUpSource = true;
}
示例#8
0
xCounter::xCounter(DigitalSource &source) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL),
	m_encodingType(k1X)
{
	InitCounter();
	SetUpSource(&source);
	ClearDownSource();
}
示例#9
0
/**
 * Create an instance of a Counter object.
 * Create an up-Counter instance given a channel. The default digital module is assumed.
 */
xCounter::xCounter(UINT32 channel) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL),
	m_encodingType(k1X)
{
	InitCounter();
	SetUpSource(channel);
	ClearDownSource();
}
示例#10
0
xCounter::xCounter(AnalogTrigger &trigger) :
	m_upSource(NULL),
	m_downSource(NULL),
	m_counter(NULL),
	m_encodingType(k1X)
{
	InitCounter();
	SetUpSource(trigger.CreateOutput(AnalogTriggerOutput::kState));
	ClearDownSource();
	m_allocatedUpSource = true;
}
Counter::Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted)
{
	wpi_assert(encodingType == k1X || encodingType == k2X);
	InitCounter(kExternalDirection);
	SetUpSource(upSource);
	SetDownSource(downSource);

	if (encodingType == k1X)
	{
		SetUpSourceEdge(true, false);
		m_counter->writeTimerConfig_AverageSize(1, &status);
	}
	else
	{
		SetUpSourceEdge(true, true);
		m_counter->writeTimerConfig_AverageSize(2, &status);
	}

	SetDownSourceEdge(inverted, true);
}
/**
 * Set the upsource for the counter as a digital input channel.
 * The slot will be the default digital module slot.
 */
void Counter::SetUpSource(UINT32 channel)
{
	SetUpSource(GetDefaultDigitalModule(), channel);
}
Counter::Counter(DigitalSource &source)
{
	InitCounter();
	SetUpSource(&source);
	ClearDownSource();
}
示例#14
0
/**
 * Set the source object that causes the counter to count up.
 * Set the up counting DigitalSource.
 */
void xCounter::SetUpSource(DigitalSource &source)
{
	SetUpSource(&source);
}
示例#15
0
/**
 * Set the up counting source to be an analog trigger.
 * @param analogTrigger The analog trigger object that is used for the Up Source
 * @param triggerType The analog trigger output that will trigger the counter.
 */
void xCounter::SetUpSource(AnalogTrigger &analogTrigger, AnalogTriggerOutput::Type triggerType)
{
	SetUpSource(&analogTrigger, triggerType);
}
示例#16
0
/**
 * Set the up counting source to be an analog trigger.
 * @param analogTrigger The analog trigger object that is used for the Up Source
 * @param triggerType The analog trigger output that will trigger the counter.
 */
void xCounter::SetUpSource(AnalogTrigger *analogTrigger, AnalogTriggerOutput::Type triggerType)
{
	if (StatusIsFatal()) return;
	SetUpSource(analogTrigger->CreateOutput(triggerType));
	m_allocatedUpSource = true;
}
示例#17
0
/**
 * Set the upsource for the counter as a digital input channel.
 * The slot will be the default digital module slot.
 */
void xCounter::SetUpSource(UINT32 channel)
{
	if (StatusIsFatal()) return;
	SetUpSource(GetDefaultDigitalModule(), channel);
	m_allocatedUpSource = true;
}
示例#18
0
/**
 * Set the up source for the counter as digital input channel and slot.
 *
 * @param moduleNumber The digital module (1 or 2).
 * @param channel The digital channel (1..14).
 */
void xCounter::SetUpSource(UINT8 moduleNumber, UINT32 channel)
{
	if (StatusIsFatal()) return;
	SetUpSource(new DigitalInput(moduleNumber, channel));
	m_allocatedUpSource = true;
}
/**
 * Set the up counting source to be an analog trigger.
 * @param analogTrigger The analog trigger object that is used for the Up Source
 * @param triggerType The analog trigger output that will trigger the counter.
 */
void Counter::SetUpSource(AnalogTrigger &analogTrigger, AnalogTriggerOutput::Type triggerType)
{
	SetUpSource(analogTrigger.CreateOutput(triggerType));
	m_allocatedUpSource = true;
}
/**
 * Create an instance of a Counter object.
 * Create an instance of an up-Counter given a digital module and a channel.
 * @param slot The cRIO chassis slot for the digital module used
 * @param channel The channel in the digital module
 */
Counter::Counter(UINT32 slot, UINT32 channel)
{
	InitCounter();
	SetUpSource(slot, channel);
	ClearDownSource();
}
示例#21
0
文件: Counter.cpp 项目: 0xacf/wpilib
/**
 * Set the up source for the counter as digital input channel and slot.
 *
 * @param moduleNumber The digital module (1 or 2).
 * @param channel The digital channel (1..14).
 */
void Counter::SetUpSource(uint8_t moduleNumber, uint32_t channel)
{
	if (StatusIsFatal()) return;
	SetUpSource(new DigitalInput(moduleNumber, channel));
	m_allocatedUpSource = true;
}
/**
 * Set the up source for the counter as digital input channel and slot.
 */
void Counter::SetUpSource(UINT32 slot, UINT32 channel)
{
	SetUpSource(new DigitalInput(slot, channel));
	m_allocatedUpSource = true;
}