Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "configuration.h"
#include <cmath>
Configuration::Configuration(QObject *parent)
: QObject(parent), settings_("matrix-group", "libmueb") {
LoadSettings();
}
QImage Configuration::frame() const { return frame_; }
QHostAddress Configuration::target_address() const { return target_address_; }
std::uint32_t Configuration::floors() const { return floors_; }
std::uint32_t Configuration::rooms_per_floor() const {
return rooms_per_floor_;
}
std::uint32_t Configuration::windows_per_room() const {
return windows_per_room_;
}
std::uint32_t Configuration::vertical_pixel_unit() const {
return vertical_pixel_unit_;
}
std::uint32_t Configuration::horizontal_pixel_unit() const {
return horizontal_pixel_unit_;
}
std::uint32_t Configuration::pixels_per_window() const {
return pixels_per_window_;
}
std::uint32_t Configuration::window_per_floor() const {
return window_per_floor_;
}
std::uint32_t Configuration::windows() const { return windows_; }
std::uint32_t Configuration::pixels() const { return pixels_; }
std::int32_t Configuration::width() const { return width_; }
std::int32_t Configuration::height() const { return height_; }
std::uint8_t Configuration::protocol_type() const { return protocol_type_; }
std::uint32_t Configuration::window_byte_size() const {
return window_byte_size_;
}
std::uint32_t Configuration::max_windows_per_datagram() const {
return max_windows_per_datagram_;
}
std::uint32_t Configuration::packet_header_size() const {
return packet_header_size_;
}
std::uint32_t Configuration::packet_size() const { return packet_size_; }
std::uint32_t Configuration::packet_payload_size() const {
return packet_payload_size_;
}
std::uint32_t Configuration::max_pixel_per_datagram() const {
return max_pixel_per_datagram_;
}
std::uint32_t Configuration::remainder_packet_size() const {
return remainder_packet_size_;
}
std::uint16_t Configuration::unicast_animation_port() const {
return unicast_animation_port_;
}
std::uint16_t Configuration::broadcast_animation_port() const {
return broadcast_animation_port_;
}
std::uint8_t Configuration::max_packet_number() const {
return max_packet_number_;
}
std::uint8_t Configuration::color_depth() const { return color_depth_; }
std::uint8_t Configuration::factor() const { return factor_; }
bool Configuration::debug_mode() const { return debug_mode_; }
void Configuration::LoadSettings() {
// Building specific constants
floors_ = settings_.value("floors", 13).toUInt();
rooms_per_floor_ = settings_.value("rooms_per_floor", 8).toUInt();
windows_per_room_ = settings_.value("windows_per_room", 2).toUInt();
// Hardware specific constants
vertical_pixel_unit_ = settings_.value("vertical_pixel_unit", 2).toUInt();
horizontal_pixel_unit_ = settings_.value("horizontal_pixel_unit", 2).toUInt();
color_depth_ = settings_.value("color_depth", 3).toUInt();
// Software specific constants
pixels_per_window_ = vertical_pixel_unit_ * horizontal_pixel_unit_;
window_per_floor_ = rooms_per_floor_ * windows_per_room_;
windows_ = floors_ * window_per_floor_;
pixels_ = windows_ * pixels_per_window_;
width_ = window_per_floor_ * horizontal_pixel_unit_;
height_ = floors_ * vertical_pixel_unit_;
factor_ = 8 - color_depth_;
frame_ = QImage(width_, height_, QImage::Format_RGB888);
frame_.fill(Qt::black);
// Network protocol specific constants
protocol_type_ = 2;
unicast_animation_port_ =
settings_.value("unicast_animation_port", 3000).toUInt();
broadcast_animation_port_ =
settings_.value("broadcast_animation_port", 10000).toUInt();
// Debug specific constants
// Send packets to localhost
debug_mode_ = settings_.value("debugMode", false).toBool();
target_address_ =
(debug_mode_)
? QHostAddress("127.0.0.1")
: QHostAddress(
settings_.value("target_address", "10.6.255.255").toString());
window_byte_size_ = (color_depth_ >= 3 && color_depth_ < 5)
? pixels_per_window_ * 3 / 2
: pixels_per_window_ * 3;
max_windows_per_datagram_ =
settings_.value("max_windows_per_datagram", windows_).toUInt();
packet_header_size_ = 2;
packet_size_ =
packet_header_size_ + max_windows_per_datagram_ * window_byte_size_;
packet_payload_size_ = max_windows_per_datagram_ * window_byte_size_;
max_pixel_per_datagram_ = max_windows_per_datagram_ * pixels_per_window_;
max_packet_number_ = static_cast<std::uint32_t>(
std::ceil(static_cast<float>(windows_) / max_windows_per_datagram_));
// TODO Configuration check
}