34 struct SimpleLevelControl:
public HF::Units::Unit<HF::Profiles::SimpleLevelControl>
36 SimpleLevelControl(uint8_t
id,
HF::IDevice &device):
37 HF::Units::Unit<
HF::Profiles::SimpleLevelControl>(id, device)
44 struct SimpleLevelControllable:
public HF::Units::Unit<HF::Profiles::SimpleLevelControllable>
48 SimpleLevelControllable(uint8_t
id,
HF::IDevice &device):
54 _Parent::level_change(source, old_level, new_level);
55 LOG(INFO) <<
"Level Change : " 81 int main(
int argc,
char **argv)
86 LOG(INFO) <<
"Use case : Level Control interface usage" <<
NL;
93 LOG(INFO) <<
"Create the node instances ..." <<
NL;
97 LOG(INFO) <<
"Add unit to node1 instance ..." <<
NL;
98 SimpleLevelControl level_control(1, node1);
102 LOG(INFO) <<
"Add unit to node2 instance ..." <<
NL;
103 SimpleLevelControllable level_controllable(1, node2);
108 LOG(INFO) <<
"Create the base instance ..." <<
NL;
111 LOG(INFO) <<
"Create transport instance" <<
NL;
120 LOG(INFO) <<
"Network setup ..." <<
NL;
122 loop.set_base(&base);
123 loop.add_node(&node1,
"node_1");
124 loop.add_node(&node2,
"node_2");
131 LOG(INFO) <<
"Registering node1 ... " <<
NL;
132 node1.unit0()->device_management()->register_device();
133 LOG(INFO) <<
"Node1 address ... " << node1.address() <<
NL;
136 assert(node1.address() == 1);
141 LOG(INFO) <<
"Registering node2 ... " <<
NL;
142 node2.unit0()->device_management()->register_device();
143 LOG(INFO) <<
"Node2 address ... " << node2.address() <<
NL;
146 assert(node2.address() == 2);
148 LOG(INFO) <<
"There should be two registered devices ... " 149 << base.
unit0()->device_management()->entries().size() <<
NL;
151 assert(base.
unit0()->device_management()->entries().size() == 2);
153 LOG(INFO) <<
"Set initial level value ... 10\%" <<
NL;
154 level_controllable.level(10.0f);
160 LOG(INFO) <<
"Send level change to a specific device/unit ..." <<
NL;
164 LOG(INFO) <<
"Change level to 20\% ..." <<
NL;
165 level_control.level(addr, 20.0f);
167 LOG(INFO) <<
"Level Controllable should have new level value : " 169 assert(level_controllable.level() == HF::Common::from_percent<uint8_t>(20.0));
175 LOG(INFO) <<
"Send level change to the broadcast device/unit ..." <<
NL;
178 LOG(INFO) <<
"Create bind entry on the base ... " <<
NL;
183 base.
unit0()->bind_management()->add(source, destination, itf);
184 LOG(INFO) <<
"There should be one bind entry ... " 185 << base.
unit0()->bind_management()->entries().size() <<
NL;
186 assert(base.
unit0()->bind_management()->entries().size() == 1);
188 LOG(INFO) <<
"Change level to 50\% ..." <<
NL;
189 level_control.level(50.0f);
191 LOG(INFO) <<
"Level Controllable should have new level value : " 193 assert(level_controllable.level() == HF::Common::from_percent<uint8_t>(50));
This class represents a HAN-FUN Concentrator.
This is the top level include file for the HAN-FUN library.
This file contains the prototypes of the debug functionality in HAN-FUN.
constexpr uint16_t BROADCAST_ADDR
HAN-FUN Broadcast - device address.
Helper template class to implement units.
This class represents the interface common to all HAN-FUN devices.
P to_percent(T value)
Convert a value in the [0,std::numeric_limits<T>::max()] range into a percentage. ...
Template for HAN-FUN concentrator devices.
#define NL
Helper define for new-line and stream clear.
CoreServices * unit0() const
Get the unit 0 used by this concentrator device.
Level Control interface UID.
This file contains an implementation of a HAN-FUN transport layer to be used in the example applicati...
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
#define LOG(X)
Log messages with the level given by X.
Template for declaring HAN-FUN node devices.
Top-level namespace for the HAN-FUN library.