@@ -111,67 +111,98 @@ OnixSourceEditor::OnixSourceEditor(GenericProcessor* parentNode, OnixSource* oni
111
111
112
112
void OnixSourceEditor::labelTextChanged (Label* l)
113
113
{
114
+ // TODO: Add headstage specific parameters to limit voltage within safe levels
114
115
if (l == portVoltageValueA.get ())
115
116
{
117
+ float input = l->getText ().getFloatValue ();
118
+
119
+ if (input < 0 .0f )
120
+ {
121
+ l->setText (" 0.0" , dontSendNotification);
122
+ }
123
+ else if (input > 7 .0f )
124
+ {
125
+ l->setText (" 7.0" , dontSendNotification);
126
+ }
127
+ }
128
+ else if (l == portVoltageValueB.get ())
129
+ {
130
+ float input = l->getText ().getFloatValue ();
131
+
132
+ if (input < 0 .0f )
133
+ {
134
+ l->setText (" 0.0" , dontSendNotification);
135
+ }
136
+ else if (input > 7 .0f )
137
+ {
138
+ l->setText (" 7.0" , dontSendNotification);
139
+ }
116
140
}
117
141
}
118
142
119
143
void OnixSourceEditor::buttonClicked (Button* b)
120
144
{
121
145
if (b == connectButton.get ())
122
146
{
123
- if (connectButton->getToggleState () == true )
147
+ updateConnectedStatus (connectButton->getToggleState ());
148
+ }
149
+ }
150
+
151
+ void OnixSourceEditor::updateConnectedStatus (bool connected)
152
+ {
153
+ connectButton->setToggleState (connected, dontSendNotification);
154
+
155
+ if (connected)
156
+ {
157
+ // NB: Configure port voltages, using either the automated voltage discovery algorithm, or the explicit voltage value given
158
+ if (isHeadstageSelected (PortName::PortA))
124
159
{
125
- // NB: Configure port voltages, using either the automated voltage discovery algorithm, or the explicit voltage value given
126
- if (isHeadstageSelected (PortName::PortA))
127
- {
128
- if (!thread->configurePortVoltage (PortName::PortA, portVoltageValueA->getText ()))
129
- {
130
- CoreServices::sendStatusMessage (" Unable to acquire communication lock on Port A." );
131
- connectButton->setToggleState (false , true );
132
- return ;
133
- }
134
- }
135
- else
160
+ if (!thread->configurePortVoltage (PortName::PortA, portVoltageValueA->getText ()))
136
161
{
137
- thread->setPortVoltage (PortName::PortA, 0 );
162
+ CoreServices::sendStatusMessage (" Unable to acquire communication lock on Port A." );
163
+ connectButton->setToggleState (false , dontSendNotification);
164
+ return ;
138
165
}
139
-
140
- if (isHeadstageSelected (PortName::PortB))
141
- {
142
- if (!thread->configurePortVoltage (PortName::PortB, portVoltageValueB->getText ()))
143
- {
144
- CoreServices::sendStatusMessage (" Unable to acquire communication lock on Port B." );
145
- connectButton->setToggleState (false , true );
146
- return ;
147
- }
148
- }
149
- else
150
- {
151
- thread->setPortVoltage (PortName::PortB, 0 );
152
- }
153
-
154
- thread->initializeDevices (true );
155
- canvas->refreshTabs ();
156
-
157
- connectButton->setLabel (" DISCONNECT" );
166
+ }
167
+ else
168
+ {
169
+ thread->setPortVoltage (PortName::PortA, 0 );
170
+ }
158
171
159
- if (!thread->foundInputSource ())
172
+ if (isHeadstageSelected (PortName::PortB))
173
+ {
174
+ if (!thread->configurePortVoltage (PortName::PortB, portVoltageValueB->getText ()))
160
175
{
161
- CoreServices::sendStatusMessage (" No Onix hardware found." );
162
- connectButton->setToggleState (false , true );
176
+ CoreServices::sendStatusMessage (" Unable to acquire communication lock on Port B." );
177
+ connectButton->setToggleState (false , dontSendNotification);
178
+ return ;
163
179
}
164
180
}
165
181
else
166
182
{
167
- thread->setPortVoltage (PortName::PortA, 0 );
168
183
thread->setPortVoltage (PortName::PortB, 0 );
184
+ }
185
+
186
+ thread->initializeDevices (true );
187
+ canvas->refreshTabs ();
169
188
170
- canvas->removeTabs ();
171
- thread->disconnectDevices (true );
172
- connectButton->setLabel (" CONNECT" );
189
+ connectButton->setLabel (" DISCONNECT" );
190
+
191
+ if (!thread->foundInputSource ())
192
+ {
193
+ CoreServices::sendStatusMessage (" No Onix hardware found." );
194
+ connectButton->setToggleState (false , sendNotification);
173
195
}
174
196
}
197
+ else
198
+ {
199
+ thread->setPortVoltage (PortName::PortA, 0 );
200
+ thread->setPortVoltage (PortName::PortB, 0 );
201
+
202
+ canvas->removeTabs ();
203
+ thread->disconnectDevices (true );
204
+ connectButton->setLabel (" CONNECT" );
205
+ }
175
206
}
176
207
177
208
void OnixSourceEditor::comboBoxChanged (ComboBox* cb)
0 commit comments