|
@@ -373,6 +373,7 @@ void JavaScriptDevice::start()
|
373
|
373
|
{
|
374
|
374
|
QScriptValue object = scriptengine->newQObject(this);
|
375
|
375
|
@<Expose device settings as object property@>@;
|
|
376
|
+ @<Expose channels and channel settings to device script@>@;
|
376
|
377
|
QScriptContext *context = scriptengine->currentContext();
|
377
|
378
|
QScriptValue oldThis = context->thisObject();
|
378
|
379
|
context->setThisObject(object);
|
|
@@ -396,6 +397,28 @@ while(i != deviceSettings.constEnd())
|
396
|
397
|
}
|
397
|
398
|
object.setProperty("settings", settingsObject);
|
398
|
399
|
|
|
400
|
+@ While channels are available to the device script through the same
|
|
401
|
+|getChannel()| interface used outside of the device script for integration
|
|
402
|
+purposes, it is more convenient to have an array of channels with channel
|
|
403
|
+specific settings as properties of the channel.
|
|
404
|
+
|
|
405
|
+@<Expose channels and channel settings to device script@>=
|
|
406
|
+QScriptValue channelsArray = scriptengine->newArray(channelCount());
|
|
407
|
+for(int i = 0; i < channelCount(); i++)
|
|
408
|
+{
|
|
409
|
+ QScriptValue channelObject = scriptengine->newQObject(getChannel(i));
|
|
410
|
+ QScriptValue channelSettingsObject = scriptengine->newObject();
|
|
411
|
+ QVariantMap::const_iterator j = channelSettings.at(i).constBegin();
|
|
412
|
+ while(j != channelSettings.at(i).constEnd())
|
|
413
|
+ {
|
|
414
|
+ channelSettingsObject.setProperty(j.key(), j.value().toString());
|
|
415
|
+ j++;
|
|
416
|
+ }
|
|
417
|
+ channelObject.setProperty("settings", channelSettingsObject);
|
|
418
|
+ channelsArray.setProperty(i, channelObject);
|
|
419
|
+}
|
|
420
|
+object.setProperty("channels", channelsArray);
|
|
421
|
+
|
399
|
422
|
@ Currently we require wrapper functions to work with channels in the host
|
400
|
423
|
environment.
|
401
|
424
|
|
|
@@ -493,7 +516,7 @@ JavaScriptDevice::JavaScriptDevice(const QModelIndex &index,
|
493
|
516
|
QStringList channelValues;
|
494
|
517
|
for(int j = 0; j < channelConfigData.size(); j++)
|
495
|
518
|
{
|
496
|
|
- node = channelConfigData.at(i).toElement();
|
|
519
|
+ node = channelConfigData.at(j).toElement();
|
497
|
520
|
if(node.attribute("name") == "keys")
|
498
|
521
|
{
|
499
|
522
|
QString data = node.attribute("value");
|
|
@@ -514,7 +537,7 @@ JavaScriptDevice::JavaScriptDevice(const QModelIndex &index,
|
514
|
537
|
}
|
515
|
538
|
channelValues = data.split(", ");
|
516
|
539
|
}
|
517
|
|
- else if(node.attribute("nane") == "hidden")
|
|
540
|
+ else if(node.attribute("name") == "hidden")
|
518
|
541
|
{
|
519
|
542
|
hiddenState.append(node.attribute("value") == "true");
|
520
|
543
|
}
|