-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalogTriggerOutput.cpp
More file actions
94 lines (82 loc) · 2.39 KB
/
AnalogTriggerOutput.cpp
File metadata and controls
94 lines (82 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "AnalogTriggerOutput.h"
#include "AnalogTrigger.h"
#include "Utility.h"
#include "WPIStatus.h"
/**
* Create an object that represents one of the four outputs from an analog trigger.
*
* Because this class derives from DigitalSource, it can be passed into routing functions
* for Counter, Encoder, etc.
*
* @param trigger A pointer to the trigger for which this is an output.
* @param outputType An enum that specifies the output on the trigger to represent.
*/
AnalogTriggerOutput::AnalogTriggerOutput(AnalogTrigger *trigger, AnalogTriggerOutput::Type outputType)
: m_trigger (trigger)
, m_outputType (outputType)
{
}
AnalogTriggerOutput::~AnalogTriggerOutput()
{
}
/**
* Get the state of the analog trigger output.
* @return The state of the analog trigger output.
*/
bool AnalogTriggerOutput::Get()
{
tRioStatusCode status=0;
switch(m_outputType)
{
case kInWindow:
return m_trigger->m_trigger->readOutput_InHysteresis(m_trigger->m_index, &status);
case kState:
return m_trigger->m_trigger->readOutput_OverLimit(m_trigger->m_index, &status);
case kRisingPulse:
case kFallingPulse:
wpi_fatal(AnalogTriggerPulseOutputError);
}
// Should never get here.
wpi_assert(false);
return false;
}
/**
* @return The value to be written to the channel field of a routing mux.
*/
UINT32 AnalogTriggerOutput::GetChannelForRouting()
{
return (m_trigger->m_index << 2) + m_outputType;
}
/**
* @return The value to be written to the module field of a routing mux.
*/
UINT32 AnalogTriggerOutput::GetModuleForRouting()
{
return m_trigger->m_index >> 2;
}
/**
* @return The value to be written to the module field of a routing mux.
*/
bool AnalogTriggerOutput::GetAnalogTriggerForRouting()
{
return true;
}
/**
* Request interrupts asynchronously on this digital input.
*/
void AnalogTriggerOutput::RequestInterrupts(tInterruptHandler handler, void *param)
{
wpi_assert(false);
}
/**
* Request interrupts synchronously on this digital input.
*/
void AnalogTriggerOutput::RequestInterrupts()
{
wpi_assert(false);
}