38 #include <QScriptValueIterator>
39 #include <QMetaObject>
40 #include <QMetaProperty>
54 printf(
"QxrdScriptEngine::QxrdScriptEngine(%p)\n",
this);
61 printf(
"QxrdScriptEngine::~QxrdScriptEngine(%p)\n",
this);
102 globalObject().setProperty(
"window", newQObject(w.data()));
104 QCEP_DOC_OBJECT(
"imageGraph",
"The Image Plot in the Main Experiment Window");
105 globalObject().setProperty(
"imageGraph", newQObject(w->m_ImagePlot));
108 globalObject().setProperty(
"centeringGraph", newQObject(w->m_CenterFinderPlot));
111 globalObject().setProperty(
"integratorGraph", newQObject(w->m_IntegratorPlot));
131 INVOKE_CHECK(QMetaObject::invokeMethod(
this,
"evaluateScript", Qt::QueuedConnection, Q_ARG(
int, 0), Q_ARG(QString, expr)));
140 INVOKE_CHECK(QMetaObject::invokeMethod(
this,
"evaluateScript", Qt::QueuedConnection, Q_ARG(
int, 1), Q_ARG(QString, expr)));
149 INVOKE_CHECK(QMetaObject::invokeMethod(
this,
"evaluateScript", Qt::QueuedConnection, Q_ARG(
int, 2), Q_ARG(QString, expr)));
154 if (QThread::currentThread() != thread()) {
155 INVOKE_CHECK(QMetaObject::invokeMethod(
this,
"loadScript", Qt::QueuedConnection, Q_ARG(QString, path)));
157 QFile scriptFile(path);
159 if (scriptFile.open(QFile::ReadOnly)) {
160 QTextStream scriptStream(&scriptFile);
161 QString script = scriptStream.readAll();
163 QScriptValue res = QScriptEngine::evaluate(script, path);
169 expt->printLine(tr(
"Script error, file %1, line %2 : %3")
172 QStringList bt = uncaughtExceptionBacktrace();
174 foreach (QString s, bt) {
178 expt->printLine(tr(
"= %1").arg(res.toString()));
187 if (result.isError()) {
188 return "ERROR : "+result.property(
"error").toString();
189 }
else if (result.isArray()) {
190 int len = result.property(
"length").toInteger();
194 for (
int i=0; i<len; i++) {
206 }
else if (result.isObject()) {
207 QScriptValueIterator it(result);
211 while(it.hasNext()) {
227 return result.toString();
237 QScriptValue result = QScriptEngine::evaluate(expr);
243 exp->printMessage(tr(
"Evaluate[%1] %2 = %3").arg(src).arg(expr).arg(result.toString()));
269 return QScriptEngine::hasUncaughtException();
276 return QScriptEngine::uncaughtExceptionLineNumber();
283 return uncaughtException().toString();
289 "Print values to the log file and message window",
290 "<p>The values of the arguments are catenated into a single string which is "
291 "printed to the log file and to the message window</p>\n"
292 "<p>The following is a typical use: print out the names and values of the "
293 "elements of an object:</p>\n"
295 "for(i in acquisition) print(i, acquisition[i])"
304 int nArgs = context->argumentCount();
307 for (
int i=0; i<nArgs; i++) {
312 msg += context -> argument(i).toString();
318 expt->printLine(msg);
322 return QScriptValue(engine, 1);
328 "Open a script output file",
329 "<p>The fileName given is opened as the current output file ussed by fprint</p>\n"
330 "<p>Only one script output file may be open at a time</p>\n"
338 int nArgs = context->argumentCount();
345 return QScriptValue(engine, 1);
350 "fprint([value]...)",
351 "Print values to the script output file",
352 "<p>The values of the arguments are catenated into a single string which is "
353 "printed to the script output file</p>\n"
354 "<p>The following is a typical use: print out the names and values of the "
355 "elements of an object:</p>\n"
357 "for(i in acquisition) fprint(i, acquisition[i])"
366 int nArgs = context->argumentCount();
369 for (
int i=0; i<nArgs; i++) {
374 msg += context -> argument(i).toString();
380 return QScriptValue(engine, 1);
386 "Closes the script output file",
387 "<p>Note that only one script output file may be open at a time</p>\n"
398 return QScriptValue(engine, 1);
405 "<p>If the file does not exist no error occurs</p>"
415 QString path = context -> argument(0).toString();
417 if (path.length() > 0) {
418 res = QFile::remove(path);
422 return QScriptValue(engine, res);
428 "acquire([fileName[, exposure[, summedExposures[, postTriggerFiles[, preTriggerFiles[, nPhases]]]]]])",
429 "Start acquisition of a sequence of images",
431 "<p>The arguments are optional and may be successively omitted from the "
432 "right. If <i>preTriggerFiles</i> is omitted, zero is used instead. "
433 "If <i>nPhases</i> is omitted, one is used. "
434 "Any other argument which is omitted will take its value "
435 "instead from the values entered in the acquire dialog. Any "
436 "argument which is given will replace the corresponding value "
437 "in the acquire dialog.</p>\n"
438 "<p>Note that the script function merely starts the acquisition "
439 "- you should use the separate \"status\" function to wait for "
440 "acquisition and processing to be completed.</p>\n"
441 "<p>The following is a typical example of the use of this "
442 "command from spec:</p>\n"
444 "def PEexp(filename,exposure,subframes,frames) '{<br/>"
445 " remote_eval(PEHOST,"
446 "sprintf(\"acquire(\\\"%s\\\",%g,%d,%d,0)\",filename,exposure,subframes,frames));<br/>"
447 " <br/> PEwait()<br/> }'<br/>"
458 if (!acq)
return QScriptValue(engine, -1);
460 int nArgs = context->argumentCount();
463 acq -> set_PhasesInGroup(1);
467 acq -> set_PreTriggerFiles(0);
474 acq -> set_PhasesInGroup(context -> argument(5).toUInt32());
477 acq -> set_PreTriggerFiles(context -> argument(4).toUInt32());
480 acq -> set_PostTriggerFiles(context -> argument(3).toUInt32());
483 acq -> set_SummedExposures(context -> argument(2).toUInt32());
486 acq -> set_ExposureTime(context -> argument(1).toNumber());
489 acq -> set_FilePattern(context -> argument(0).toString());
496 return QScriptValue(engine, 1);
501 "acquireDark([filename [,exposure [,darkSummedExposures]]])",
502 "Start acquisition of a dark image",
503 "<p>Arguments are optional and, if given, will replace the "
504 "corresponding value in the acquire dialog, if not given the "
505 "dialog values are used.</p>\n"
506 "<p>The following is a typical example of the use of this "
507 "command from spec:</p>\n"
509 "def PEexpd(filename, exposure, subframes) '{<br/>\n"
510 " remote_eval(PEHOST,"
511 "sprintf(\"acquireDark(\\\"%s\\\",%g,%d)\",filename,exposure,subframes));<br/>\n"
512 " <br/> PEwait()<br/> }'<br/>\n"
523 if (!acq)
return QScriptValue(engine, -1);
525 int nArgs = context->argumentCount();
530 acq -> set_DarkSummedExposures(context -> argument(2).toUInt32());
533 acq -> set_ExposureTime(context -> argument(1).toNumber());
536 acq -> set_FilePattern(context -> argument(0).toString());
539 acq -> acquireDark();
543 return QScriptValue(engine, 1);
549 "Test if acquisition and processing have finished",
551 "If the argument is given the function will wait up to that "
552 "many seconds - if acquisition and processing finish before "
553 "the time elapsed then <code>status</code> will return at "
554 "that time, otherwise at the end of the timeout period. The "
555 "function returns a non-zero result if acquisition and "
556 "processing are complete, or zero if they are not."
559 "If no argument is given the function tests if acquisition "
560 "and processing are complete and returns the result of the "
564 "The following is a typical use of this command from spec:"
567 "def PEwait() '{<br/>"
568 " while(remote_eval(PEHOST,\"status(1.0)\")==0) {<br/>"
569 " }<br/> }'<br/>"
581 if (!acq || !proc)
return QScriptValue(engine, -1);
586 if (context->argumentCount() > 0) {
587 time = context->argument(0).toNumber();
590 status = acq -> acquisitionStatus(time);
593 status = proc -> status(time);
596 return QScriptValue(engine, status);
598 return QScriptValue(engine, -1);
604 "acquireStatus([time])",
605 "Test if acquisition has finished",
607 "Similar to 'status' "
608 "except that it only tests for the acquisition operation being complete."
620 if (context->argumentCount() == 0) {
621 return QScriptValue(engine, acq -> acquisitionStatus(0));
623 double time = context->argument(0).toNumber();
624 return QScriptValue(engine, acq -> acquisitionStatus(time));
629 return QScriptValue(engine, -1);
634 "processStatus([time])",
635 "Test if processing has finished",
637 "Similar to 'status' "
638 "except that it only tests for the processing operation being complete."
650 if (context->argumentCount() == 0) {
651 return QScriptValue(engine, proc -> status(0));
653 double time = context->argument(0).toNumber();
654 return QScriptValue(engine, proc -> status(time));
659 return QScriptValue(engine, -1);
665 "Cancel the current acquisition operation",
679 return QScriptValue(engine, 1);
683 return QScriptValue(engine, -1);
688 "vals <- acquireScalers()",
689 "Returns the scaler counts values for the latest acquisition operation",
700 int i = context->argument(0).toInteger();
702 return QScriptValue(eng, acq->scalerValue(i));
706 return QScriptValue();
712 "Trigger triggered acquisition",
713 "<p>If 'preTriggerFiles' is greater than zero then acquisition operations proceed in the "
714 "'triggered' mode. This acts much like a digital oscilloscope trigger where a certain number "
715 "('preTriggerFiles') of acquired images are held in the computer RAM until the trigger operation occurs "
716 "and then the most recent acquired images are written to disk, along with a number of post-trigger images</p>"
729 return QScriptValue(engine, 1);
733 return QScriptValue(engine, -1);
738 "exposureTime([time])",
739 "Get or set the acquisition exposure time (also for dark exposures)",
740 "<p>If the time argument is given, set the exposure time, otherwise return the "
741 "current exposure time</p>"
742 "<p>This function provides a convenient method to access the "
743 "<code>acquisition.exposureTime</code> property</p>"
754 if (context->argumentCount() != 0) {
755 acq -> set_ExposureTime(context->argument(0).toNumber());
758 return QScriptValue(engine, acq -> get_ExposureTime());
762 return QScriptValue(engine, -1);
767 "summedExposures([n])",
768 "Get or set the number of summed exposures for acquisition",
769 "<p>If the n argument is given, set the number of summed exposures, otherwise return the "
771 "<p>Easy access to <code>acquisition.summedExposures</code></p>"
782 if (context->argumentCount() != 0) {
783 acq -> set_SummedExposures(context->argument(0).toUInt32());
786 return QScriptValue(engine, acq -> get_SummedExposures());
790 return QScriptValue(engine, -1);
795 "skippedExposures([n])",
796 "Get or set the number of skipped exposures for acquisition",
797 "<p>If the n argument is given, set the number of skipped exposures, otherwise return the "
799 "<p>Easy access to <code>acquisition.skippedExposures</code></p>"
810 if (context->argumentCount() != 0) {
811 acq -> set_SkippedExposures(context->argument(0).toUInt32());
814 return QScriptValue(engine, acq -> get_SkippedExposures());
818 return QScriptValue(engine, -1);
822 "darkSummedExposures",
823 "darkSummedExposures([n])",
824 "Get or set the number of summed exposures for dark acquisition",
825 "<p>If the n argument is given, set the number of summed exposures, otherwise return the "
827 "<p>Easy access to <code>acquisition.darkSummedExposures</code></p>"
838 if (context->argumentCount() != 0) {
839 acq -> set_DarkSummedExposures(context->argument(0).toUInt32());
842 return QScriptValue(engine, acq -> get_DarkSummedExposures());
846 return QScriptValue(engine, -1);
851 "phasesInGroup([n])",
852 "Get or set the number of phases for synchronized acquisition",
853 "<p>If the n argument is given, set the number of phases, otherwise return the "
855 "<p>Easy access to <code>acquisition.phasesInGroup</code></p>"
866 if (context->argumentCount() != 0) {
867 acq -> set_PhasesInGroup(context->argument(0).toUInt32());
870 return QScriptValue(engine, acq -> get_PhasesInGroup());
874 return QScriptValue(engine, -1);
879 "preTriggerFiles([n])",
880 "Get or set the number of pre-trigger file groups for triggered acquisition",
881 "<p>If the n argument is given, set the number of pre-trigger file groups, otherwise return the "
883 "<p>Easy access to <code>acquisition.preTriggerFiles</code></p>"
894 if (context->argumentCount() != 0) {
895 acq -> set_PreTriggerFiles(context->argument(0).toUInt32());
898 return QScriptValue(engine, acq -> get_PreTriggerFiles());
902 return QScriptValue(engine, -1);
907 "postTriggerFiles([n])",
908 "Get or set the number of post-trigger file groups for triggered acquisition",
909 "<p>If the n argument is given, set the number of post-trigger file groups, otherwise return the "
911 "<p>Easy access to <code>acquisition.postTriggerFiles</code></p>"
922 if (context->argumentCount() != 0) {
923 acq -> set_PostTriggerFiles(context->argument(0).toUInt32());
926 return QScriptValue(engine, acq -> get_PostTriggerFiles());
930 return QScriptValue(engine, -1);
935 "filePattern([pattern])",
936 "Get or set the acquisition file name pattern",
937 "<p>If the pattern argument is given, set the file name pattern, otherwise return the "
939 "<p>Easy access to <code>acquisition.filePattern</code></p>"
950 if (context->argumentCount() != 0) {
951 acq -> set_FilePattern(context->argument(0).toString());
954 return QScriptValue(engine, acq -> get_FilePattern());
958 return QScriptValue(engine, -1);
963 "outputDirectory([dir])",
964 "Get or set the acquisition output directory",
965 "<p>If the dir argument is given, set the output directory, otherwise return the "
967 "<p>Easy access to <code>experiment.dataDirectory</code></p>"
978 if (context->argumentCount() != 0) {
979 doc -> set_DataDirectory(context->argument(0).toString());
982 return QScriptValue(engine, doc -> get_DataDirectory());
986 return QScriptValue(engine, -1);
992 "Get or set the acquisition file index",
993 "<p>If the n argument is given, set the file index, otherwise return the "
995 "<p>Easy access to <code>acquisition.fileIndex</code></p>"
1006 if (context->argumentCount() != 0) {
1007 acq -> set_FileIndex(context->argument(0).toUInt32());
1010 return QScriptValue(engine, acq -> get_FileIndex());
1014 return QScriptValue(engine, -1);
1020 "Get the current image",
1021 "<p>Returns a reference to the most recently acquired or most recently loaded image.</p>"
1022 "<p>The returned object can have its properties queried.</p>"
1023 "<p>Note that the value returned by this function will change as each "
1024 "new image is acquired so be careful if calling this function during acquisition.</p>"
1035 return engine -> newQObject(proc -> data().data(),QtOwnership, QScriptEngine::AutoCreateDynamicProperties);
1039 return QScriptValue(engine, -1);
1045 "Get the dark image (or null if none has been taken)",
1046 "<p>Returns a reference to the current dark image.</p>"
1047 "<p>The returned object can have its properties queried.</p>"
1048 "<p>For example, to get the file name of the dark image:</p>"
1049 "<code>print(dark().fileName)</code>"
1050 "<p>Or to show a list of properties of the dark image:</p>"
1051 "<code>for(i in dark()) print(i, dark()[i])</code>"
1062 return engine -> newQObject(proc -> darkImage().data(), QtOwnership, QScriptEngine::AutoCreateDynamicProperties);
1066 return QScriptValue(engine, -1);
1072 "Get the top item of the mask stack",
1073 "<p>Returns a reference to the top of the mask stack, or null if the "
1074 "mask stack is empty.</p>"
1085 return engine -> newQObject(proc -> mask().data(), QtOwnership, QScriptEngine::AutoCreateDynamicProperties);
1089 return QScriptValue(engine, -1);
1095 "Get the overflow pixel map for acquired images",
1096 "<p>Returns the overflow pixels map for the most recently acquired image "
1097 "(if overflow processing is enabled)</p>\n"
1098 "<p>The overflow map is non-zero wherever an image pixel exceeded the overflow "
1099 "threshold during acquisition. Where more than one exposures are summed, the overflow "
1100 "map will count the number of exposures for which the pixel overflowed.</p>"
1111 return engine -> newQObject(proc -> overflow().data(), QtOwnership, QScriptEngine::AutoCreateDynamicProperties);
1115 return QScriptValue(engine, -1);
1121 "Get the current live view image",
1122 "<p>Returns a reference to the most recently acquired live view image.</p>"
1123 "<p>The returned object can have its properties queried.</p>"
1124 "<p>Note that the value returned by this function will change as each "
1125 "new live view image is acquired so be careful when calling this function.</p>"
1136 return engine -> newQObject(proc -> liveData().data(), QtOwnership, QScriptEngine::AutoCreateDynamicProperties);
1140 return QScriptValue(engine, -1);
1146 "Returns help text for a given name or names",
1147 "<p>Returns a string containing an html representation of the help text "
1148 "for a name or names. If more than one name is given the result is the "
1149 "concatenation of the help for each name in turn</p>"
1150 "<p>The names may contain wildcard characters, the result will contain help "
1151 "for all available matching the wildcard patterns.</p>"
1152 "<p>If no name is given the command returns help for the help command itself.</p>"
1153 "<p>If the command is executed in the QXRD script window the html result will "
1154 "be properly formatted in the message window.</p>"
1155 "<p>For example:</p>"
1156 "<code>help(\"help\")</code>"
1164 int n=context->argumentCount();
1170 for (
int i=0; i<n; i++) {
1171 QString name = context->argument(i).toString();
1173 QRegExp re(name, Qt::CaseInsensitive, QRegExp::Wildcard);
1179 return QScriptValue(engine, res);
1181 return QScriptValue(engine, QString());
1188 "Access channels for extra inputs",
1189 "<p>Returns a reference to configuration data for an extra input channel.</p>"
1190 "<p>Example: to access the acquired waveform for extra channel 0</p>"
1191 "<code>extraChannel(0).waveform</code>"
1205 if (context->argumentCount() != 0) {
1206 int channel = context->argument(0).toInteger();
1210 return engine->newQObject(chan.data());
1216 return QScriptValue();
1221 "process(filename [, norm...])",
1222 "Load and process an image file",
1223 "<p>Load and process the file filename. The norm arguments are used as "
1224 "normalization values during processing</p>"
1225 "<p>The function is closely related to</p>"
1226 "<code>processor.processNormalizedFile(QString,QDoubleList)</code>"
1237 if (context->argumentCount() >= 1) {
1238 QString file = context->argument(0).toString();
1239 QList<double> normVals;
1241 for (
int i=1; i<context->argumentCount(); i++) {
1242 normVals.append(context->argument(i).toNumber());
1245 proc -> processNormalizedFile(file, normVals);
1248 return QScriptValue(engine, 1);
1252 return QScriptValue(engine, -1);
1256 "setFileNormalization",
1257 "setFileNormalization(filename [, norm...])",
1258 "Set the normalization values for an image file",
1259 "<p>Loads the file filename, sets its normalization values and "
1260 "rewrites the metadata file</p>"
1261 "<p>The function is closely related to</p>"
1262 "<code>processor.setFileNormalization(QString,QDoubleList)</code>"
1273 if (context->argumentCount() >= 1) {
1274 QString file = context->argument(0).toString();
1275 QList<double> normVals;
1277 for (
int i=1; i<context->argumentCount(); i++) {
1278 normVals.append(context->argument(i).toNumber());
1281 proc -> setFileNormalization(file, normVals);
1284 return QScriptValue(engine, 1);
1288 return QScriptValue(engine, -1);
1293 "matchFiles([pattern]...)",
1294 "Return a list of files matching a pattern",
1295 "<p>Returns a list of file names matching the provided pattern(s).</p>"
1296 "<p>The patterns support 'wild card' characters sush as * and ?.</p>"
1297 "<p>Example - to calculate the sum of the pixel intensity of pixel 100,100 in "
1298 "all the TIFF files in the current directory:</p>"
1299 "<code>var sum=0;<br/>\n"
1300 "for(f in matchFiles(\"*.tif\") {<br/>\n"
1301 " processor.loadData(f);<br/>\n"
1302 " sum += data().getImageData(100,100);<br/>\n"
1310 if (context->argumentCount() >= 1) {
1311 QString dir = context->argument(0).toString();
1313 if (context->argumentCount() == 1) {
1315 a.setFilter(QDir::Dirs | QDir::Files);
1317 result.append(a.entryList());
1319 for (
int i=1; i<context->argumentCount(); i++) {
1320 QString patt = context->argument(i).toString();
1326 a.setFilter(QDir::Dirs | QDir::Files);
1330 a.setNameFilters(patts);
1332 QStringList entries = a.entryList();
1336 result.append(entries);
1341 return engine->toScriptValue(result);
1346 "mapUserFunction(functionname)",
1347 "Map a user function over current data",
1361 int ht = d->get_Height();
1362 int wd = d->get_Width();
1364 if (context->argumentCount() == 1) {
1365 QScriptValue func = context->argument(0);
1367 if (!func.isFunction()) {
1368 func = eng->globalObject().property(func.toString());
1371 if (func.isFunction()) {
1372 for (
int i=0; i<wd; i++) {
1373 for (
int j=0; j<ht; j++) {
1374 d->setValue(i,j, func.call(QScriptValue(), QScriptValueList() << i << j).toNumber());
1384 return engine->toScriptValue(0);
1390 "Returns system time as seconds since unix epoch",
1398 return engine->toScriptValue(val);
1404 "newDataGroup(name)",
1405 "Creates a new named data group",
1420 QString name = context->argument(0).toString();
1422 return engine->newQObject(
1423 dataModel->newGroup(name).data());
1428 return QScriptValue();
1433 "newDataArray(name,dim1 .. dimn)",
1434 "Creates a new named n-dimensional data array",
1449 QString name = context->argument(0).toString();
1453 for (
int i=1; i<context->argumentCount(); i++) {
1454 dims.append(context->argument(i).toInteger());
1457 return engine->newQObject(
1458 dataModel->newArray(name, dims).data());
1463 return QScriptValue();
1468 "newDataColumn(name, npts)",
1469 "Creates a new named data column",
1484 QString name = context->argument(0).toString();
1485 int npts = context->argument(1).toInteger();
1487 return engine->newQObject(
1488 dataModel->newColumn(name, npts).data());
1493 return QScriptValue();
1497 "newDataColumnScan",
1498 "newDataColumnScan(name, npts, col1name .. colnname)",
1499 "Creates a new named data column scan",
1514 QString name = context->argument(0).toString();
1515 int npts = context->argument(1).toInteger();
1519 for (
int i=2; i<context->argumentCount(); i++) {
1520 cols.append(context->argument(i).toString());
1523 return engine->newQObject(
1524 dataModel->newColumnScan(name, npts, cols).data());
1529 return QScriptValue();
1534 "newDataImage(name, width, height)",
1535 "Creates a new named data image",
1552 QString name = context->argument(0).toString();
1553 int width = context->argument(1).toInteger();
1554 int height = context->argument(2).toInteger();
1556 return engine->newQObject(
1557 dataModel->newImage(name, width, height).data());
1562 return QScriptValue();
1566 "newIntegratedData",
1567 "newIntegratedData(name, size)",
1568 "Creates a new integrated data object",
1584 QString name = context->argument(0).toString();
1585 int size = context->argument(1).toInteger();
1587 return engine->newQObject(
1588 dataModel->newIntegratedData(name, size).data());
1593 return QScriptValue();
1599 "Returns a reference to the 'n'th detector",
1610 int n = context->argument(0).toInteger();
1612 return engine->newQObject(acq->detector(n).data());
1616 return QScriptValue();
1622 "Returns a reference to the 'm'th ROI of the 'n'th detector",
1634 int n = context->argument(0).toInteger();
1635 int m = context->argument(1).toInteger();
1640 return engine->newQObject(d->roi(m).data());
1645 return QScriptValue();
1650 "Qt Built-in JSON Parser"
1655 "JSON.parse(
string)",
1656 "Parse a
string as a JSON
object",
1657 "<p>A built-in function in the Qt script system</p>"
1662 "JSON.stringify(
object)",
1663 "Produce JSON
string representation of an
object",
1664 "<p>A built-in function in the Qt script system</p>"
1669 "var x = Math.sqrt(2)",
1670 "Qt Built-in Math Module",
1671 "<p>Qt Script mathematical functions module</p>"
1672 "<p>See also: <a href=\"http:
1677 "Qt Script built-in
object with infinite value"
1682 "Qt Script built-in
object with NaN (Not-a-Number) Value"
1687 "Qt Script built-in
object with undefined value"
1693 "var x=Array([value...])",
1694 "Qt Script built in array constructor function (<a href=\"http:
1695 "<p>Construct a QtScript array containing the indicated elements</p>"
1697 "<code>Array(1,2,3,4)</code>"
1702 "var
bool=Boolean(value)",
1703 "Qt Script built in Boolean constructor function",
1704 "<p>Construct a QtScript
boolean with the given value<p>"
1706 "<code>Boolean(0)</code>"
1711 "var d=new Date(|msec|
string|year,month[,day[,hr[,min[,sec[,msec]]]]])",
1712 "Qt Script built in date
object",
1713 "<p>Construct dates given various inputs</p>"
1714 "<code>var d = new Date()
1715 "var d = new Date(msec)
1716 "var d = new Date(\"October 13, 1975 11:13:00\")
1717 "var d = new Date(2001,5,24)
1718 "<p>See also: <a href=\"http:
1723 "var patt=new RegExp(pattern,modifiers) or var patt=/pattern/modifiers",
1724 "Qt Script built in Regular Expression Object",
1725 "<p>Construct regular expression matching objects</p>"
1727 "<code>var p1 = new RegExp(\".*\\.tif\",\"i\")<br/>"
1728 "var p2=/.*\\.tif/i</code>"
1729 "<p>See also: <a href=\"http:
1734 "var txt = new String(\"
string\"); var t2=\"hhh\";",
1735 "Qt Script built in String Object",
1736 "<p>Construct and manipulate
string values.</p>"
1737 "<p>See also: <a href=\"http:
1742 "var num = new Number(42)",
1743 "Qt Script Built in Number Object",
1744 "<p>Construct and manipulate numeric values.</p>"
1745 "<p>See also: <a href=\"http:
1752 qRegisterMetaType< QVector<int> >(
"QVector<int>");
1753 qRegisterMetaType< QVector<bool> >(
"QVector<bool>");
1754 qRegisterMetaType< QVector<double> >(
"QVector<double>");
1755 qRegisterMetaType< QVector<QString> >(
"QVector<QString>");
1760 qRegisterMetaType< QList<QString> >(
"QList<QString>");
1762 qScriptRegisterSequenceMetaType< QList<int> >(
this);
1763 qScriptRegisterSequenceMetaType< QList<bool> >(
this);
1764 qScriptRegisterSequenceMetaType< QList<double> >(
this);
1765 qScriptRegisterSequenceMetaType< QList<QString> >(
this);
1767 qScriptRegisterSequenceMetaType< QVector<int> >(
this);
1768 qScriptRegisterSequenceMetaType< QVector<bool> >(
this);
1769 qScriptRegisterSequenceMetaType< QVector<double> >(
this);
1770 qScriptRegisterSequenceMetaType< QVector<QString> >(
this);
1777 qRegisterMetaType<QxrdPowderPoint>(
"QxrdPowderPoint");
1778 qScriptRegisterMetaType(
this,
1783 qScriptRegisterMetaType(
this,
1787 qRegisterMetaType<QxrdCalibrantWPtr>(
"QxrdCalibrantWPtr");
1788 qScriptRegisterMetaType(
this,
1792 qRegisterMetaType<QcepDataObjectPtr>(
"QcepDataObjectPtr");
1793 qScriptRegisterMetaType(
this,
1797 qRegisterMetaType<QcepDataGroupPtr>(
"QcepDataGroupPtr");
1798 qScriptRegisterMetaType(
this,
1802 qRegisterMetaType<QcepDataArrayPtr>(
"QcepDataArrayPtr");
1803 qScriptRegisterMetaType(
this,
1807 qRegisterMetaType<QcepDataColumnPtr>(
"QcepDataColumnPtr");
1808 qScriptRegisterMetaType(
this,
1812 qRegisterMetaType<QcepIntegratedDataPtr>(
"QcepIntegratedDataPtr");
1813 qScriptRegisterMetaType(
this,
1817 qRegisterMetaType<QcepDataColumnScanPtr>(
"QcepDataColumnScanPtr");
1818 qScriptRegisterMetaType(
this,
1822 qRegisterMetaType<QcepImageDataBasePtr>(
"QcepImageDataBasePtr");
1823 qScriptRegisterMetaType(
this,
1827 qRegisterMetaType<QcepDoubleImageDataPtr>(
"QcepDoubleImageDataPtr");
1828 qScriptRegisterMetaType(
this,
1832 qRegisterMetaType<QcepInt16ImageDataPtr>(
"QcepInt16ImageDataPtr");
1833 qScriptRegisterMetaType(
this,
1837 qRegisterMetaType<QcepInt32ImageDataPtr>(
"QcepInt32ImageDataPtr");
1838 qScriptRegisterMetaType(
this,
1842 qRegisterMetaType<QcepMaskDataPtr>(
"QcepMaskDataPtr");
1843 qScriptRegisterMetaType(
this,
1847 qRegisterMetaType<QxrdCalibrantDSpacing>(
"QxrdCalibrantDSpacing");
1848 qScriptRegisterSequenceMetaType<QxrdCalibrantDSpacings>(
this);
1850 qScriptRegisterMetaType(
this,
1858 qRegisterMetaType<QxrdDetectorPtr>(
"QxrdDetectorPtr");
1859 qScriptRegisterMetaType(
this,
1863 qRegisterMetaType<QxrdDetectorProcessorPtr>(
"QxrdDetectorProcessorPtr");
1864 qScriptRegisterMetaType(
this,
1868 qRegisterMetaType<QxrdCenterFinderPtr>(
"QxrdCenterFinderPtr");
1869 qScriptRegisterMetaType(
this,
1873 qRegisterMetaType<QxrdIntegratorPtr>(
"QxrdIntegratorPtr");
1874 qScriptRegisterMetaType(
this,
1878 qRegisterMetaType<QxrdROICalculatorPtr>(
"QxrdROICalculatorPtr");
1879 qScriptRegisterMetaType(
this,
1883 qRegisterMetaType<QxrdROICoordinatesPtr>(
"QxrdROICoordinatesPtr");
1884 qScriptRegisterMetaType(
this,
1888 qRegisterMetaType<QxrdROICoordinatesListModelPtr>(
"QxrdROICoordinatesListModelPtr");
1889 qScriptRegisterMetaType(
this,
1897 globalObject().setProperty(
"application", newQObject(app.data()));
1903 globalObject().setProperty(
"allocator", newQObject(alloc.data()));
1908 globalObject().setProperty(
"global", globalObject());
1911 globalObject().setProperty(
"scripting", newQObject(
this));
1913 globalObject().setProperty(
"acquire", newFunction(
acquireFunc));
1914 globalObject().setProperty(
"acquireDark", newFunction(
acquireDarkFunc));
1915 globalObject().setProperty(
"status", newFunction(
statusFunc));
1920 globalObject().setProperty(
"trigger", newFunction(
triggerFunc));
1921 globalObject().setProperty(
"exposureTime", newFunction(
exposureTimeFunc, 1));
1928 globalObject().setProperty(
"filePattern", newFunction(
filePatternFunc, 1));
1930 globalObject().setProperty(
"fileIndex", newFunction(
fileIndexFunc, 1));
1931 globalObject().setProperty(
"print", newFunction(
printFunc, NULL));
1932 globalObject().setProperty(
"fopen", newFunction(
fopenFunc, NULL));
1933 globalObject().setProperty(
"fdelete", newFunction(
fdeleteFunc, NULL));
1934 globalObject().setProperty(
"fprint", newFunction(
fprintFunc, NULL));
1935 globalObject().setProperty(
"fclose", newFunction(
fcloseFunc, NULL));
1936 globalObject().setProperty(
"printMessage", newFunction(
printFunc, NULL));
1937 globalObject().setProperty(
"data", newFunction(
dataFunc));
1938 globalObject().setProperty(
"dark", newFunction(
darkFunc));
1939 globalObject().setProperty(
"mask", newFunction(
maskFunc));
1940 globalObject().setProperty(
"overflow", newFunction(
overflowFunc));
1941 globalObject().setProperty(
"liveData", newFunction(
liveDataFunc));
1942 globalObject().setProperty(
"help", newFunction(
helpFunc));
1943 globalObject().setProperty(
"process", newFunction(
processFunc));
1945 globalObject().setProperty(
"matchFiles", newFunction(
matchFilesFunc));
1946 globalObject().setProperty(
"extraChannel", newFunction(
extraChannelFunc, 1));
1948 globalObject().setProperty(
"timeStamp", newFunction(
timeStampFunc, 1));
1950 globalObject().setProperty(
"detector", newFunction(
detectorFunc, 1));
1951 globalObject().setProperty(
"roi", newFunction(
roiFunc, 1));
1962 QObject *plugin =
dynamic_cast<QObject*
>(app->nidaqPlugin().data());
1966 globalObject().setProperty(
"nidaq", newQObject(plugin));
1974 globalObject().setProperty(
"experiment", newQObject(expt.data()));
1982 globalObject().setProperty(
"acquisition", newQObject(acq.data(), QtOwnership, QScriptEngine::AutoCreateDynamicProperties));
1988 globalObject().setProperty(
"synchronization", newQObject(sync.data()));
1995 globalObject().setProperty(
"extraInputs", newQObject(extra.data()));
2009 QCEP_DOC_OBJECT(
"simpleServer",
"Remote Control Text Based Socket Server");
2010 globalObject().setProperty(
"simpleServer", newQObject(ssrv.data()));
2016 QCEP_DOC_OBJECT(
"specServer",
"Remote Control Server for use with Spec");
2017 globalObject().setProperty(
"specServer", newQObject(srv.data()));
2026 globalObject().setProperty(
"processor", newQObject(dp.data()));
2028 QCEP_DOC_OBJECT(
"centering",
"Beam Center and Detector Alignment Options");
2029 globalObject().setProperty(
"centering", newQObject(dp->centerFinder().data()));
2032 globalObject().setProperty(
"integrator", newQObject(dp->integrator().data()));
2035 globalObject().setProperty(
"polarTransform", newQObject(dp->polarTransform().data()));
2038 globalObject().setProperty(
"polarNormalization", newQObject(dp->polarNormalization().data()));
2044 globalObject().setProperty(
"testImage", newQObject(gti.data()));
2048 globalObject().setProperty(
"distortion", newQObject(dp->distortionCorrection().data()));
2055 globalObject().setProperty(
"calibrants", newQObject(cals.data()));
2061 globalObject().setProperty(
"dataset", newQObject(ds.data()));
2073 QScriptValue obj = engine->newArray(2);
2075 obj.setProperty(0, in.x());
2076 obj.setProperty(1, in.y());
2083 pt.setX(
object.property(0).toNumber());
2084 pt.setY(
object.property(1).toNumber());
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QSharedPointer< QxrdWindow > QxrdWindowPtr
static QScriptValue triggerFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue fdeleteFunc(QScriptContext *context, QScriptEngine *engine, void *u)
static QScriptValue QPointFToScriptValue(QScriptEngine *engine, const QPointF &in)
static QScriptValue matchFilesFunc(QScriptContext *context, QScriptEngine *engine)
QSharedPointer< QxrdServer > QxrdServerPtr
virtual ~QxrdScriptEngine()
static QScriptValue roiFunc(QScriptContext *context, QScriptEngine *engine)
QWeakPointer< QxrdDataProcessor > QxrdDataProcessorWPtr
static void fromScriptValue(const QScriptValue &obj, QcepDataObjectPtr &data)
qint64 qcepDebug(int cond)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdDetectorPtr &det)
static void fromScriptValue(const QScriptValue &obj, QxrdDetectorProcessorPtr &proc)
static QScriptValue newDataArrayFunc(QScriptContext *context, QScriptEngine *engine)
static void fromColumnScanScriptValue(const QScriptValue &obj, QcepDataColumnScanPtr &data)
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
static QScriptValue timeStampFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdROICalculatorPtr &proc)
static QScriptValue setFileNormalizationFunc(QScriptContext *context, QScriptEngine *engine)
static void fromGroupScriptValue(const QScriptValue &obj, QcepDataGroupPtr &data)
static QScriptValue toScriptValue(QScriptEngine *engine, const QcepDataObjectPtr &data)
static QScriptValue newDataImageFunc(QScriptContext *context, QScriptEngine *engine)
void evaluateSimpleServerCommand(QString cmd)
void openScriptOutput(const QString &fileName)
QSharedPointer< QxrdCalibrantLibrary > QxrdCalibrantLibraryPtr
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
static QScriptValue exposureTimeFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue acquireFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue newDataColumnScanFunc(QScriptContext *context, QScriptEngine *engine)
QString documentationText(QString item)
QxrdExperimentWPtr m_Experiment
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdDetectorProcessorPtr &proc)
static QScriptValue processStatusFunc(QScriptContext *context, QScriptEngine *engine)
QxrdScriptEngine(QxrdApplicationWPtr app, QxrdExperimentWPtr exp)
static void fromScriptValue(const QScriptValue &obj, QxrdIntegratorPtr &proc)
void evaluateSpecCommand(QString cmd)
static QScriptValue helpFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue postTriggerFilesFunc(QScriptContext *context, QScriptEngine *engine)
QSharedPointer< QxrdSimpleServer > QxrdSimpleServerPtr
QWeakPointer< QxrdApplication > QxrdApplicationWPtr
static QScriptValue newDataGroupFunc(QScriptContext *context, QScriptEngine *engine)
static void fromIntegratedDataScriptValue(const QScriptValue &obj, QcepIntegratedDataPtr &data)
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
QString uncaughtExceptionString() const
static void fromScriptValue(const QScriptValue &obj, QxrdCalibrantDSpacing &spc)
static void fromScriptValue(const QScriptValue &obj, QxrdROICalculatorPtr &proc)
void setWindow(QxrdWindowWPtr win)
static void fromScriptValue(const QScriptValue &obj, QSharedPointer< QcepImageData< T > > &data)
QxrdDataProcessorWPtr dataProcessor() const
static QScriptValue liveDataFunc(QScriptContext *context, QScriptEngine *engine)
static void fromArrayScriptValue(const QScriptValue &obj, QcepDataArrayPtr &data)
static QScriptValue toScriptValue(QScriptEngine *engine, const QSharedPointer< QcepImageData< T > > &data)
static QScriptValue statusFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue newDataColumnFunc(QScriptContext *context, QScriptEngine *engine)
static void fromScriptValue(const QScriptValue &obj, QxrdPowderPoint &pt)
static void fromScriptValue(const QScriptValue &obj, QxrdCenterFinderPtr &proc)
QCEP_DOC_OBJECT("JSON","Qt Built-in JSON Parser") QCEP_DOC_FUNCTION("JSON.parse"
QSharedPointer< QxrdSynchronizedAcquisition > QxrdSynchronizedAcquisitionPtr
static QScriptValue extraChannelFunc(QScriptContext *context, QScriptEngine *engine)
static QString convertToString(QScriptValue result)
#define INVOKE_CHECK(res)
QxrdApplicationWPtr m_Application
QxrdWindowWPtr window() const
static void fromScriptValue(const QScriptValue &obj, QxrdDetectorPtr &det)
static QScriptValue skippedExposuresFunc(QScriptContext *context, QScriptEngine *engine)
void evaluateScript(int src, QString cmd)
static QScriptValue acquireStatusFunc(QScriptContext *context, QScriptEngine *engine)
static void fromScriptValue(const QScriptValue &obj, QxrdCalibrantWPtr &cal)
QWeakPointer< QxrdWindow > QxrdWindowWPtr
QSharedPointer< QxrdGenerateTestImage > QxrdGenerateTestImagePtr
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdCenterFinderPtr &proc)
static QScriptValue fcloseFunc(QScriptContext *context, QScriptEngine *engine, void *u)
static QScriptValue toColumnScriptValue(QScriptEngine *engine, const QcepDataColumnPtr &data)
static QScriptValue printFunc(QScriptContext *context, QScriptEngine *engine, void *u)
QxrdDataProcessorWPtr m_DataProcessor
static QScriptValue dataFunc(QScriptContext *context, QScriptEngine *engine)
QCEP_DOC_FUNCTION("print","print([value]...)","Print values to the log file and message window","<p>The values of the arguments are catenated into a single string which is ""printed to the log file and to the message window</p>\n""<p>The following is a typical use: print out the names and values of the ""elements of an object:</p>\n""<code>""for(i in acquisition) print(i, acquisition[i])""</code>") QScriptValue QxrdScriptEngine
static void fromScriptValue(const QScriptValue &obj, QxrdROICoordinatesListModelPtr &coords)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdROICoordinatesListModelPtr &coords)
QxrdApplicationWPtr application() const
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdCalibrantWPtr &cal)
static QScriptValue outputDirectoryFunc(QScriptContext *context, QScriptEngine *engine)
void appResultAvailable(QScriptValue res)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdPowderPoint &pt)
static void QPointFFromScriptValue(const QScriptValue &object, QPointF &pt)
static QScriptValue phasesInGroupFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue overflowFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdPowderPointVector &vec)
void evaluateAppCommand(QString cmd)
static QScriptValue detectorFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue filePatternFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toArrayScriptValue(QScriptEngine *engine, const QcepDataArrayPtr &data)
static QScriptValue darkFunc(QScriptContext *context, QScriptEngine *engine)
static void fromColumnScriptValue(const QScriptValue &obj, QcepDataColumnPtr &data)
static QScriptValue fopenFunc(QScriptContext *context, QScriptEngine *engine, void *u)
static QScriptValue toGroupScriptValue(QScriptEngine *engine, const QcepDataGroupPtr &data)
static QScriptValue fprintFunc(QScriptContext *context, QScriptEngine *engine, void *u)
QWeakPointer< QxrdAcquisition > QxrdAcquisitionWPtr
static QScriptValue mapUserFunctionFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdIntegratorPtr &proc)
static QScriptValue acquireScalersFunc(QScriptContext *context, QScriptEngine *engine)
QSharedPointer< QcepAllocator > QcepAllocatorPtr
void simpleServerResultAvailable(QScriptValue cmd)
static QScriptValue darkSummedExposuresFunc(QScriptContext *context, QScriptEngine *engine)
int uncaughtExceptionLineNumber() const
static QScriptValue processFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toIntegratedDataScriptValue(QScriptEngine *engine, const QcepIntegratedDataPtr &data)
void writeScriptOutput(const QString &outputLine)
QxrdExperimentWPtr experiment() const
QSharedPointer< QxrdDetector > QxrdDetectorPtr
static QScriptValue newIntegratedDataFunc(QScriptContext *context, QScriptEngine *engine)
static void fromScriptValue(const QScriptValue &obj, QxrdPowderPointVector &vec)
void loadScript(QString path)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdCalibrantDSpacing &spc)
static QScriptValue summedExposuresFunc(QScriptContext *context, QScriptEngine *engine)
QSharedPointer< QcepMaskData > QcepMaskDataPtr
static QScriptValue maskFunc(QScriptContext *context, QScriptEngine *engine)
QSharedPointer< QxrdApplication > QxrdApplicationPtr
bool hasUncaughtException() const
QxrdAcquisitionWPtr m_Acquisition
QSharedPointer< QcepDatasetModel > QcepDatasetModelPtr
static double secondsSinceEpoch()
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdROICoordinatesPtr &coords)
static QScriptValue acquireDarkFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue toColumnScanScriptValue(QScriptEngine *engine, const QcepDataColumnScanPtr &data)
void specResultAvailable(QScriptValue cmd)
static QScriptValue fileIndexFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue preTriggerFilesFunc(QScriptContext *context, QScriptEngine *engine)
static QScriptValue acquireCancelFunc(QScriptContext *context, QScriptEngine *engine)
static void fromScriptValue(const QScriptValue &obj, QxrdROICoordinatesPtr &coords)
QxrdAcquisitionWPtr acquisition() const
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr