implement sync stream printer
Stefan Schuermans

Stefan Schuermans commited on 2014-01-03 14:57:20
Showing 6 changed files, with 158 additions and 0 deletions.

... ...
@@ -109,6 +109,7 @@
109 109
         <li><a href="ratelimiter.html">Rate Limiter</a></li>
110 110
         <li><a href="resizer.html">Resizer</a></li>
111 111
         <li><a href="scaler.html">Scaler</a></li>
112
+        <li><a href="syncprinter.html">Synchronization Printer</a></li>
112 113
         <li><a href="transformer.html">Transformer</a></li>
113 114
         <li><a href="udp4phone.html">UDP4 Phone Connector</a></li>
114 115
         <li><a href="udp4receiver.html">UDP4 Receiver</a></li>
... ...
@@ -0,0 +1,28 @@
1
+<html>
2
+  <head>
3
+    <title>Blinker - Synchronization Printer</title>
4
+  </head>
5
+  <body>
6
+    <h1>Blinker - Synchronization Printer</h1>
7
+    <p>
8
+      The synchronization printer module is primary intended for debugging
9
+      purposes.
10
+      It receives a synchronization stream and prints received information
11
+      to standard output.
12
+    </p>
13
+    <h2>Configuration</h2>
14
+    <p>
15
+      The configuration of the synchronization printer module with name
16
+      <code>NAME</code> is located in the <code>syncprinters/NAME</code>
17
+      subdirectory.
18
+    </p>
19
+    <h3>Input Synchronization Stream</h3>
20
+    <p>
21
+      The file <code>insync</code> contains the name of the synchronization
22
+      stream to read.
23
+      The information received from this synchronization stream is written
24
+      to standard output.
25
+    </p>
26
+  </body>
27
+</html>
28
+
... ...
@@ -0,0 +1,66 @@
1
+/* Blinker
2
+   Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#include <iostream>
7
+#include <stdlib.h>
8
+#include <string>
9
+#include <string.h>
10
+
11
+#include "Directory.h"
12
+#include "File.h"
13
+#include "InSyncFile.h"
14
+#include "Mgrs.h"
15
+#include "Module.h"
16
+#include "SyncPrinter.h"
17
+#include "SyncRecv.h"
18
+
19
+namespace Blinker {
20
+
21
+/**
22
+ * @brief constructor
23
+ * @param[in] name module name
24
+ * @param[in] mgrs managers
25
+ * @param[in] dirBase base directory
26
+ */
27
+SyncPrinter::SyncPrinter(const std::string &name, Mgrs &mgrs,
28
+                 const Directory &dirBase):
29
+  Module(name, mgrs, dirBase),
30
+  m_fileInSync(dirBase.getFile("insync"), mgrs.m_syncMgr)
31
+{
32
+  // set up
33
+  m_fileInSync.setSyncRecv(this);
34
+}
35
+
36
+/// virtual destructor
37
+SyncPrinter::~SyncPrinter()
38
+{
39
+  // clean up
40
+  m_fileInSync.setSyncRecv(NULL);
41
+}
42
+
43
+/// check for update of configuration
44
+void SyncPrinter::updateConfig()
45
+{
46
+  // input sync stream name file was modified -> re-get input sync stream
47
+  if (m_fileInSync.checkModified())
48
+    m_fileInSync.update();
49
+}
50
+
51
+/**
52
+ * @brief send synchronization information
53
+ * @param[in] sync sync stream name
54
+ * @param[in] pInfo synchronization information
55
+ */
56
+void SyncPrinter::sendInfo(const std::string &sync, Info &info)
57
+{
58
+  std::cout << "sync pause=" << (info.pause ? "true" : "false") <<
59
+               " name=\"" << info.name << "\"" <<
60
+               " pos=" << info.pos_ms << "ms" <<
61
+               std::endl;
62
+  (void)sync; // unused
63
+}
64
+
65
+} // namespace Blinker
66
+
... ...
@@ -0,0 +1,60 @@
1
+/* Blinker
2
+   Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#ifndef BLINKER_SYNCPRINTER_H
7
+#define BLINKER_SYNCPRINTER_H
8
+
9
+#include <string>
10
+
11
+#include "Directory.h"
12
+#include "File.h"
13
+#include "InSyncFile.h"
14
+#include "Mgrs.h"
15
+#include "Module.h"
16
+#include "SyncRecv.h"
17
+
18
+namespace Blinker {
19
+
20
+/// a sync stream printer
21
+class SyncPrinter: public Module, public SyncRecv
22
+{
23
+public:
24
+  /**
25
+   * @brief constructor
26
+   * @param[in] name module name
27
+   * @param[in] mgrs managers
28
+   * @param[in] dirBase base directory
29
+   */
30
+  SyncPrinter(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
31
+
32
+  /// virtual destructor
33
+  virtual ~SyncPrinter();
34
+
35
+private:
36
+  /// copy constructor disabled
37
+  SyncPrinter(const SyncPrinter &that);
38
+
39
+  /// assignment operator disabled
40
+  const SyncPrinter & operator=(const SyncPrinter &that);
41
+
42
+public:
43
+  /// check for update of configuration
44
+  virtual void updateConfig();
45
+
46
+  /**
47
+   * @brief send synchronization information
48
+   * @param[in] sync sync stream name
49
+   * @param[in] pInfo synchronization information
50
+   */
51
+  virtual void sendInfo(const std::string &sync, Info &info);
52
+
53
+protected:
54
+  InSyncFile m_fileInSync; ///< input sync stream name file
55
+}; // class SyncPrinter
56
+
57
+} // namespace Blinker
58
+
59
+#endif // #ifndef BLINKER_SYNCPRINTER_H
60
+
... ...
@@ -22,6 +22,7 @@
22 22
 #include "RateLimiter.h"
23 23
 #include "Resizer.h"
24 24
 #include "Scaler.h"
25
+#include "SyncPrinter.h"
25 26
 #include "Transformer.h"
26 27
 #include "Udp4Phone.h"
27 28
 #include "Udp4Receiver.h"
... ...
@@ -53,6 +54,7 @@ void run(const std::string &dirConfig)
53 54
   MODULEMGR(Resizer,      resizers);
54 55
   MODULEMGR(RateLimiter,  ratelimiters);
55 56
   MODULEMGR(Scaler,       scalers);
57
+  MODULEMGR(SyncPrinter,  syncprinters);
56 58
   MODULEMGR(Transformer,  transformers);
57 59
   MODULEMGR(Udp4Phone,    udp4phones);
58 60
   MODULEMGR(Udp4Receiver, udp4receivers);
59 61