Browse Source

interval option

old
Robin Thoni 9 years ago
parent
commit
e91667c2e4
2 changed files with 13 additions and 1 deletions
  1. 11
    1
      server/mainclass.cpp
  2. 2
    0
      server/mainclass.h

+ 11
- 1
server/mainclass.cpp View File

@@ -16,6 +16,7 @@ MainClass::MainClass(QObject *parent)
16 16
     , m_address(QHostAddress::Any)
17 17
     , m_port(39415)
18 18
     , m_verbose(false)
19
+    , m_interval(100)
19 20
     , m_lastTime(0)
20 21
 {
21 22
 }
@@ -47,7 +48,7 @@ void MainClass::main()
47 48
     m_input = new InputBusiness(input, m_channels, server);
48 49
     m_timer = new QTimer(this);
49 50
     m_timer->setSingleShot(false);
50
-    m_timer->setInterval(0);
51
+    m_timer->setInterval(m_interval / 1000);
51 52
     connect(m_timer, SIGNAL(timeout()), this, SLOT(maySend()));
52 53
     m_timer->start();
53 54
 }
@@ -86,6 +87,8 @@ void MainClass::getOpts()
86 87
     parser.addOption(port);
87 88
     QCommandLineOption verbose((QStringList() << "verbose"), "enable verbose mode");
88 89
     parser.addOption(verbose);
90
+    QCommandLineOption interval((QStringList() << "i" << "interval"), "interval between measures in usec", "INTERVAL", QString::number(m_interval));
91
+    parser.addOption(interval);
89 92
 
90 93
     parser.process(*qApp);
91 94
 
@@ -123,5 +126,12 @@ void MainClass::getOpts()
123 126
         parser.showHelp(EX_USAGE);
124 127
     }
125 128
 
129
+    m_interval = parser.value(interval).toInt(&ok);
130
+    if (!ok || m_interval < 0)
131
+    {
132
+        std::cerr << "Invalid interval" << std::endl;
133
+        parser.showHelp(EX_USAGE);
134
+    }
135
+
126 136
     m_verbose = parser.isSet(verbose);
127 137
 }

+ 2
- 0
server/mainclass.h View File

@@ -41,6 +41,8 @@ private:
41 41
 
42 42
     bool m_verbose;
43 43
 
44
+    int m_interval;
45
+
44 46
     __suseconds_t m_lastTime;
45 47
 
46 48
     void getOpts();

Loading…
Cancel
Save