@@ -103,18 +103,122 @@ void RecordNode::checkDiskSpace()
103103
104104String RecordNode::handleConfigMessage (String msg)
105105{
106+ /*
107+ Available messages:
108+ - engine=<engine_name> -- changes the record engine
109+ - SELECT <stream_index> NONE / ALL / <channels> -- selects which channels to record, e.g.:
110+ "SELECT 0 NONE" -- deselect all channels for stream 0
111+ "SELECT 1 1 2 3 4 5 6 7 8" -- select channels 1-8 for stream 1
112+
113+ */
114+
115+ if (CoreServices::getAcquisitionStatus ())
116+ {
117+ return " Cannot configure Record Node while acquisition is active." ;
118+ }
106119
107120 const MessageManagerLock mml;
108121
109122 StringArray tokens;
110123 tokens.addTokens (msg, " =" , " \" " );
111124
112- if (tokens. size () != 2 ) return " Invalid msg " ;
125+ LOGD (tokens[ 0 ]) ;
113126
114127 if (tokens[0 ] == " engine" )
115- static_cast <RecordNodeEditor*> (getEditor ())->engineSelectCombo ->setSelectedItemIndex (std::stoi (tokens[1 ].toStdString ()), sendNotification);
116- else
117- LOGD (" Record Node: invalid engine key" );
128+ {
129+ if (tokens.size () == 2 )
130+ {
131+ RecordNodeEditor* ed = static_cast <RecordNodeEditor*> (getEditor ());
132+
133+ int engineIndex = tokens[1 ].getIntValue ();
134+
135+ int numEngines = ed->engineSelectCombo ->getNumItems ();
136+
137+ if (engineIndex >= 0 && engineIndex < numEngines)
138+ {
139+ ed->engineSelectCombo ->setSelectedItemIndex (engineIndex, sendNotification);
140+ return " Record Node: updated record engine to " + ed->engineSelectCombo ->getText ();
141+ }
142+ else {
143+ return " Record Node: invalid engine index (max = " + String (numEngines - 1 ) + " )" ;
144+ }
145+
146+ }
147+ else
148+ {
149+ return " Record Node: invalid engine key" ;
150+ }
151+ }
152+
153+ tokens.clear ();
154+ tokens.addTokens (msg, " " , " " );
155+
156+ LOGD (tokens[0 ]);
157+
158+ if (tokens[0 ] == " SELECT" )
159+ {
160+
161+ if (tokens.size () >= 3 )
162+ {
163+
164+ int streamIndex = tokens[1 ].getIntValue ();
165+ uint16 streamId;
166+ std::vector<bool > channelStates;
167+ int channelCount;
168+
169+ if (streamIndex >= 0 && streamIndex < dataStreams.size ())
170+ {
171+ streamId = dataStreams[streamIndex]->getStreamId ();
172+ channelCount = dataStreams[streamIndex]->getChannelCount ();
173+ }
174+ else {
175+ return " Record Node: Invalid stream index; max = " + String (dataStreams.size () - 1 );
176+ }
177+
178+ if (tokens[2 ] == " NONE" )
179+ {
180+ // select no channels
181+ for (int i = 0 ; i < channelCount; i++)
182+ {
183+ channelStates.push_back (false );
184+ }
185+ }
186+ else if (tokens[2 ] == " ALL" )
187+ {
188+ // select all channels
189+ for (int i = 0 ; i < channelCount; i++)
190+ {
191+ channelStates.push_back (true );
192+ }
193+ }
194+ else
195+ {
196+
197+ Array<int > channels;
198+
199+ for (int i = 2 ; i < tokens.size (); i++)
200+ {
201+ int ch = tokens[i].getIntValue () - 1 ;
202+ channels.add (ch);
203+ }
204+
205+ // select some channels
206+ for (int i = 0 ; i < channelCount; i++)
207+ {
208+ if (channels.contains (i))
209+ channelStates.push_back (true );
210+ else
211+ channelStates.push_back (false );
212+ }
213+ }
214+
215+ updateChannelStates (streamId, channelStates);
216+ }
217+ else
218+ {
219+ LOGD (" Record Node: invalid config message" );
220+ }
221+ }
118222
119223 return " Record Node received config: " + msg;
120224}
0 commit comments