MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SetValue

Method SetValue

cpp/src/command_classes/BarrierOperator.cpp:338–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336//-----------------------------------------------------------------------------
337
338bool BarrierOperator::SetValue
339(
340 Value const& _value
341 )
342{
343 uint8 idx = (uint8_t)(_value.GetID().GetIndex() & 0xFF);
344 if (ValueID::ValueType_List == _value.GetID().GetType())
345 {
346 if (idx == BarrierOperatorLabel_Index)
347 {
348 ValueList const* value = static_cast<ValueList const*>(&_value);
349 const ValueList::Item *item = value->GetItem();
350 uint8 position = BarrierOperatorState_Closed;
351 if (item->m_value > 0)
352 position = BarrierOperatorState_Open;
353 Log::Write(LogLevel_Info, GetNodeId(), "BarrierOperator::Set - Requesting barrier to be %s", position > 0 ? "Open" : "Closed");
354 Msg* msg = new Msg("BarrierOperatorCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true);
355 msg->SetInstance(this, _value.GetID().GetInstance());
356 msg->Append(GetNodeId());
357 msg->Append(3);
358 msg->Append(GetCommandClassId());
359 msg->Append(BarrierOperatorCmd_Set);
360 msg->Append(position);
361 msg->Append(GetDriver()->GetTransmitOptions());
362 GetDriver()->SendMsg(msg, Driver::MsgQueue_Send);
363 return true;
364 }
365 }
366 if (ValueID::ValueType_Bool == _value.GetID().GetType())
367 {
368 if (idx == BarrierOperatorAudible_Index)
369 {
370 ValueBool const* value = static_cast<ValueBool const*>(&_value);
371 Log::Write(LogLevel_Info, GetNodeId(), "BarrierOperatorSignal::Set - Requesting Audible to be %s", value->GetValue() ? "ON" : "OFF");
372 Msg* msg = new Msg("BarrierOperatorSignalCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true);
373 msg->SetInstance(this, _value.GetID().GetInstance());
374 msg->Append(GetNodeId());
375 msg->Append(4);
376 msg->Append(GetCommandClassId());
377 msg->Append(BarrierOperatorCmd_SignalSet);
378 msg->Append(BarrierOperatorSignalMask_Audible);
379 msg->Append(value->GetValue() ? 0xFF : 0x00);
380 msg->Append(GetDriver()->GetTransmitOptions());
381 GetDriver()->SendMsg(msg, Driver::MsgQueue_Send);
382 return true;
383 }
384 else if (idx == BarrierOperatorVisual_Index)
385 {
386 ValueBool const* value = static_cast<ValueBool const*>(&_value);
387 Log::Write(LogLevel_Info, GetNodeId(), "BarrierOperatorSignal::Set - Requesting Visual to be %s", value->GetValue() ? "ON" : "OFF");
388 Msg* msg = new Msg("BarrierOperatorSignalCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true);
389 msg->SetInstance(this, _value.GetID().GetInstance());
390 msg->Append(GetNodeId());
391 msg->Append(4);
392 msg->Append(GetCommandClassId());
393 msg->Append(BarrierOperatorCmd_SignalSet);
394 msg->Append(BarrierOperatorSignalMask_Visual);
395 msg->Append(value->GetValue() ? 0xFF : 0x00);

Callers

nothing calls this directly

Calls 9

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
GetItemMethod · 0.80
GetInstanceMethod · 0.80
SendMsgMethod · 0.80
GetNodeIdFunction · 0.70
SetInstanceMethod · 0.45
AppendMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected