• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenLightingProject / ola / 24609258679

18 Apr 2026 04:46PM UTC coverage: 44.825% (-0.04%) from 44.864%
24609258679

Pull #1607

github

web-flow
Merge 8f509a535 into c6196f753
Pull Request #1607: Various minor improvements to the example programs

8554 of 19875 branches covered (43.04%)

0 of 49 new or added lines in 3 files covered. (0.0%)

12 existing lines in 4 files now uncovered.

22105 of 49314 relevant lines covered (44.82%)

48.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/examples/ShowRecorder.cpp
1
/*
2
 * This program is free software; you can redistribute it and/or modify
3
 * it under the terms of the GNU General Public License as published by
4
 * the Free Software Foundation; either version 2 of the License, or
5
 * (at your option) any later version.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU Library General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15
 *
16
 * ShowRecorder.cpp
17
 * Create recordings for the simple show playback system.
18
 * Copyright (C) 2011 Simon Newton
19
 *
20
 * The data file is in the form:
21
 * universe-number channel1,channel2,channel3
22
 * delay-in-ms
23
 * universe-number channel1,channel2,channel3
24
 */
25

26
#include <errno.h>
27
#include <string.h>
28
#include <ola/Callback.h>
29
#include <ola/DmxBuffer.h>
30
#include <ola/Logging.h>
31
#include <ola/OlaDevice.h>
32
#include <ola/StringUtils.h>
33
#include <ola/base/SysExits.h>
34
#include <ola/client/ClientWrapper.h>
35
#include <ola/client/OlaClient.h>
36
#include <fstream>
37
#include <iostream>
38
#include <string>
39
#include <vector>
40

41
#include "examples/ShowRecorder.h"
42

43
using ola::DmxBuffer;
44
using ola::client::Result;
45
using std::string;
46
using std::vector;
47

48

49
ShowRecorder::ShowRecorder(const string &filename,
×
50
                           const vector<unsigned int> &universes,
NEW
51
                           const unsigned int duration)
×
52
    : m_saver(filename),
×
53
      m_universes(universes),
×
NEW
54
      m_duration(duration),
×
55
      m_frame_count(0) {
×
56
}
×
57

58

59
ShowRecorder::~ShowRecorder() {
×
60
}
×
61

62

63
/**
64
 * Init the ShowRecorder
65
 */
66
int ShowRecorder::Init() {
×
67
  if (!m_client.Setup()) {
×
68
    OLA_FATAL << "Client Setup failed";
×
69
    return ola::EXIT_UNAVAILABLE;
×
70
  }
71

72
  if (!m_saver.Open()) {
×
73
    return ola::EXIT_CANTCREAT;
×
74
  }
75

NEW
76
  if (m_duration != 0) {
×
NEW
77
    m_client.GetSelectServer()->RegisterSingleTimeout(
×
NEW
78
        m_duration * 1000,
×
79
        ola::NewSingleCallback(this, &ShowRecorder::Stop));
80
  }
81

UNCOV
82
  m_client.GetClient()->SetDMXCallback(
×
83
      ola::NewCallback(this, &ShowRecorder::NewFrame));
84

85
  vector<unsigned int>::const_iterator iter = m_universes.begin();
×
86
  for (; iter != m_universes.end(); ++iter) {
×
87
    m_client.GetClient()->RegisterUniverse(
×
88
        *iter,
×
89
        ola::client::REGISTER,
90
        ola::NewSingleCallback(this, &ShowRecorder::RegisterComplete));
91
  }
92

93
  return ola::EXIT_OK;
×
94
}
95

96

97
/**
98
 * Record the show.
99
 */
100
int ShowRecorder::Record() {
×
101
  m_client.GetSelectServer()->Run();
×
102
  return ola::EXIT_OK;
×
103
}
104

105

106
/**
107
 * Stop recording
108
 */
109
void ShowRecorder::Stop() {
×
110
  // TODO(Peter): This should really write the current delay out at the end if
111
  // we're looping
112
  m_client.GetSelectServer()->Terminate();
×
113
}
×
114

115

116
/**
117
 * Record the new frame
118
 */
119
void ShowRecorder::NewFrame(const ola::client::DMXMetadata &meta,
×
120
                            const ola::DmxBuffer &data) {
121
  ola::TimeStamp now;
×
122
  m_clock.CurrentMonotonicTime(&now);
×
123
  m_saver.NewFrame(now, meta.universe, data);
×
124
  m_frame_count++;
×
125
}
×
126

127

128
void ShowRecorder::RegisterComplete(const Result &result) {
×
129
  if (!result.Success()) {
×
130
    OLA_WARN << "Register failed: " << result.Error();
×
131
  } else {
132
    OLA_INFO << "Register completed";
×
133
  }
134
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc