Skip to content

Commit f0a6e02

Browse files
committed
Ensure that AuxiliaryIO is correctly enabled/disabled
1 parent ec6a9bc commit f0a6e02

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

Source/Devices/AuxiliaryIO.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ using namespace OnixSourcePlugin;
2929
AuxiliaryIO::AuxiliaryIO(std::string name, std::string hubName, const oni_dev_idx_t analogIndex, const oni_dev_idx_t digitalIndex, std::shared_ptr<Onix1> oni_ctx)
3030
: CompositeDevice(name, hubName, AuxiliaryIO::getCompositeDeviceType(), createAuxiliaryIODevices(hubName, analogIndex, digitalIndex, oni_ctx), oni_ctx)
3131
{
32+
analogIO = getDevice<AnalogIO>(OnixDeviceType::ANALOGIO);
33+
digitalIO = getDevice<DigitalIO>(OnixDeviceType::DIGITALIO);
3234
}
3335

3436
// NB: This constructor assumes that the digitalIO device is located at one index above the analogIndex
@@ -47,11 +49,13 @@ OnixDeviceVector AuxiliaryIO::createAuxiliaryIODevices(std::string hubName, cons
4749
return devices;
4850
}
4951

50-
void AuxiliaryIO::processFrames()
52+
bool AuxiliaryIO::isEnabled() const
5153
{
52-
auto analogIO = getAnalogIO();
53-
auto digitalIO = getDigitalIO();
54+
return analogIO->isEnabled();
55+
}
5456

57+
void AuxiliaryIO::processFrames()
58+
{
5559
if (!digitalIO->isEnabled() && !analogIO->isEnabled())
5660
{
5761
return;
@@ -99,10 +103,10 @@ CompositeDeviceType AuxiliaryIO::getCompositeDeviceType()
99103

100104
std::shared_ptr<AnalogIO> AuxiliaryIO::getAnalogIO()
101105
{
102-
return getDevice<AnalogIO>(OnixDeviceType::ANALOGIO);
106+
return analogIO;
103107
}
104108

105109
std::shared_ptr<DigitalIO> AuxiliaryIO::getDigitalIO()
106110
{
107-
return getDevice<DigitalIO>(OnixDeviceType::DIGITALIO);
111+
return digitalIO;
108112
}

Source/Devices/AuxiliaryIO.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ namespace OnixSourcePlugin
4040

4141
AuxiliaryIO(std::string name, std::string hubName, const oni_dev_idx_t analogIndex, const oni_dev_idx_t digitalIndex, std::shared_ptr<Onix1> oni_ctx);
4242

43+
bool isEnabled() const override;
44+
4345
static OnixDeviceType getDeviceType();
4446
static CompositeDeviceType getCompositeDeviceType();
4547

@@ -52,6 +54,9 @@ namespace OnixSourcePlugin
5254

5355
static OnixDeviceVector createAuxiliaryIODevices(std::string hubName, const oni_dev_idx_t analogIndex, const oni_dev_idx_t digitalIndex, std::shared_ptr<Onix1> oni_ctx);
5456

57+
std::shared_ptr<AnalogIO> analogIO;
58+
std::shared_ptr<DigitalIO> digitalIO;
59+
5560
JUCE_LEAK_DETECTOR(AuxiliaryIO);
5661
};
5762
}

Source/OnixDevice.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ bool CompositeDevice::compareIndex(uint32_t index)
251251
return false;
252252
}
253253

254+
bool CompositeDevice::isEnabled() const
255+
{
256+
bool enabled = true;
257+
258+
for (const auto& device : devices)
259+
{
260+
enabled &= device->isEnabled();
261+
}
262+
263+
return enabled;
264+
}
265+
254266
bool CompositeDevice::isEnabled(uint32_t index)
255267
{
256268
for (const auto& device : devices)
@@ -267,6 +279,14 @@ bool CompositeDevice::isEnabled(uint32_t index)
267279
return false;
268280
}
269281

282+
void CompositeDevice::setEnabled(bool newState)
283+
{
284+
for (const auto& device : devices)
285+
{
286+
device->setEnabled(newState);
287+
}
288+
}
289+
270290
void CompositeDevice::setEnabled(uint32_t index, bool newState)
271291
{
272292
for (const auto& device : devices)

Source/OnixDevice.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ namespace OnixSourcePlugin
166166
virtual bool compareIndex(uint32_t index);
167167

168168
const std::string getName() { return name; }
169-
bool isEnabled() const { return enabled; }
170-
void setEnabled(bool newState) { enabled = newState; }
169+
virtual bool isEnabled() const { return enabled; }
170+
virtual void setEnabled(bool newState) { enabled = newState; }
171171
oni_dev_idx_t getDeviceIdx(bool getPassthroughIndex = false);
172172

173173
/** Creates a stream name using the provided inputs, returning a string following the pattern: name[0]-name[1]-name[2]-etc., with all spaces removed */
@@ -245,7 +245,9 @@ namespace OnixSourcePlugin
245245
CompositeDeviceType getCompositeDeviceType() const;
246246

247247
bool compareIndex(uint32_t index) override;
248+
bool isEnabled() const override;
248249
bool isEnabled(uint32_t index);
250+
void setEnabled(bool newState) override;
249251
void setEnabled(uint32_t index, bool newState);
250252
int configureDevice() override;
251253
bool updateSettings() override;

Source/UI/AuxiliaryIOInterface.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,20 @@ AuxiliaryIOInterface::AuxiliaryIOInterface(std::shared_ptr<AuxiliaryIO> d, OnixS
3838
static int offset = 55;
3939
FontOptions font = FontOptions("Fira Code", "Bold", 22.0f);
4040

41-
analogLabel = std::make_unique<Label>("analogLabel", "Analog IO");
42-
analogLabel->setBounds(20, 20, 150, 35);
43-
analogLabel->setFont(font);
44-
addAndMakeVisible(analogLabel.get());
41+
analogDigitalLabel = std::make_unique<Label>("analogDigitalLabel", "Analog and Digital IO");
42+
analogDigitalLabel->setBounds(20, 20, 350, 35);
43+
analogDigitalLabel->setFont(font);
44+
addAndMakeVisible(analogDigitalLabel.get());
4545

4646
analogInterface = std::make_unique<AnalogIOInterface>(auxiliaryIO->getAnalogIO(), e, c);
4747
analogViewport = std::make_unique<CustomViewport>(analogInterface.get(), SettingsInterface::Width / 2, SettingsInterface::Height);
4848
analogViewport->setBounds(0, offset, SettingsInterface::Width / 2, SettingsInterface::Height);
4949
addAndMakeVisible(analogViewport.get());
5050

51-
digitalLabel = std::make_unique<Label>("digitalLabel", "Digital IO");
52-
digitalLabel->setBounds(analogLabel->getX() + SettingsInterface::Width / 2, analogLabel->getY(), analogLabel->getWidth(), analogLabel->getHeight());
53-
digitalLabel->setFont(font);
54-
addAndMakeVisible(digitalLabel.get());
55-
5651
digitalInterface = std::make_unique<DigitalIOInterface>(auxiliaryIO->getDigitalIO(), e, c);
5752
digitalViewport = std::make_unique<CustomViewport>(digitalInterface.get(), SettingsInterface::Width / 2, SettingsInterface::Height);
5853
digitalViewport->setBounds(SettingsInterface::Width / 2, offset, SettingsInterface::Width / 2, SettingsInterface::Height);
59-
addAndMakeVisible(digitalViewport.get());
54+
//addAndMakeVisible(digitalViewport.get()); // NB: Hide digital interface for now, if the digitalIO UI gets updates that need to be displayed they can be shown here
6055
}
6156
}
6257

@@ -74,8 +69,8 @@ void AuxiliaryIOInterface::saveParameters(XmlElement* xml)
7469

7570
void AuxiliaryIOInterface::loadParameters(XmlElement* xml)
7671
{
77-
analogInterface->saveParameters(xml);
78-
digitalInterface->saveParameters(xml);
72+
analogInterface->loadParameters(xml);
73+
digitalInterface->loadParameters(xml);
7974
}
8075

8176
void AuxiliaryIOInterface::updateInfoString()

Source/UI/AuxiliaryIOInterface.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ namespace OnixSourcePlugin
5757
std::unique_ptr<AnalogIOInterface> analogInterface;
5858
std::unique_ptr<DigitalIOInterface> digitalInterface;
5959

60-
std::unique_ptr<Label> analogLabel;
61-
std::unique_ptr<Label> digitalLabel;
60+
std::unique_ptr<Label> analogDigitalLabel;
6261

6362
JUCE_LEAK_DETECTOR(AuxiliaryIOInterface);
6463
};

0 commit comments

Comments
 (0)