mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
artf4162: Fixes multiple solenoid creations in java
Change-Id: Iff1d6cb608c1c95723fa3121fd6c24629952f4dd
This commit is contained in:
@@ -35,6 +35,13 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
checkSolenoidModule(m_moduleNumber);
|
||||
checkSolenoidChannel(m_channel);
|
||||
|
||||
try {
|
||||
m_allocated.allocate(m_moduleNumber * kSolenoidChannels + m_channel);
|
||||
} catch (CheckedAllocationException e) {
|
||||
throw new AllocationException("Solenoid channel " + m_channel + " on module "
|
||||
+ m_moduleNumber + " is already allocated");
|
||||
}
|
||||
|
||||
long port = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_channel);
|
||||
m_solenoid_port = SolenoidJNI.initializeSolenoidPort(port);
|
||||
|
||||
@@ -69,8 +76,7 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
* Destructor.
|
||||
*/
|
||||
public synchronized void free() {
|
||||
// m_allocated.free((m_moduleNumber - 1) * kSolenoidChannels + m_channel -
|
||||
// 1);
|
||||
m_allocated.free(m_moduleNumber * kSolenoidChannels + m_channel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
private long[] m_ports;
|
||||
protected int m_moduleNumber; // /< The number of the solenoid module being
|
||||
// used.
|
||||
protected Resource m_allocated = new Resource(63 * SensorBase.kSolenoidChannels);
|
||||
protected static Resource m_allocated = new Resource(63 * SensorBase.kSolenoidChannels);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
Reference in New Issue
Block a user