15 #ifndef SV_OSC_SCRIPT_H 16 #define SV_OSC_SCRIPT_H 20 #include <QTextStream> 22 #include "base/Debug.h" 23 #include "base/StringBits.h" 24 #include "data/osc/OSCQueue.h" 25 #include "data/osc/OSCMessage.h" 43 SVCERR <<
"OSCScript: No OSC queue available" << endl;
44 throw std::runtime_error(
"OSC queue not running");
48 QString reportedFilename;
51 f.open(stdin, QFile::ReadOnly | QFile::Text);
52 reportedFilename =
"<stdin>";
55 if (!f.open(QFile::ReadOnly | QFile::Text)) {
56 SVCERR <<
"OSCScript: Failed to open script file \"" 58 throw std::runtime_error(
"OSC script file not found");
70 QString line = str.readLine().trimmed();
71 if (line == QString())
continue;
76 }
else if (line[0].isDigit()) {
78 float pause = line.toFloat(&ok);
80 SVCERR <<
"OSCScript: " 81 << reportedFilename <<
":" << lineno
82 <<
": pausing for " << pause <<
" sec" << endl;
83 msleep(
unsigned(round(pause * 1000.0f)));
86 SVCERR <<
"OSCScript: " 87 << reportedFilename <<
":" << lineno
88 <<
": warning: failed to parse sleep time, ignoring" 93 }
else if (line[0] ==
'/' && line.size() > 1) {
94 QStringList parts = StringBits::splitQuoted(line,
' ');
96 SVCERR <<
"OSCScript: " 97 << reportedFilename <<
":" << lineno
98 <<
": warning: empty command spec, ignoring" 103 message.setMethod(parts[0].mid(1));
104 for (
int i = 1; i < parts.size(); ++i) {
105 message.addArg(parts[i]);
107 SVCERR <<
"OSCScript: " << reportedFilename <<
":" << lineno
108 <<
": posting " << message.toString() << endl;
112 SVCERR <<
"OSCScript: " << reportedFilename <<
":" << lineno
113 <<
": warning: message expected, ignoring" << endl;
117 SVCERR <<
"OSCScript: " << reportedFilename <<
": finished" << endl;
OSCScript(QString filename, OSCQueue *queue)