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

Method SetValue

cpp/src/command_classes/BasicWindowCovering.cpp:55–101  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set a value on the Z-Wave device -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

53// Set a value on the Z-Wave device
54//-----------------------------------------------------------------------------
55bool BasicWindowCovering::SetValue
56(
57 Value const& _value
58)
59{
60 if( ValueID::ValueType_Button == _value.GetID().GetType() )
61 {
62 ValueButton const* button = static_cast<ValueButton const*>(&_value);
63
64 uint8 action = 0x40;
65 if( button->GetID().GetIndex() ) // Open is index zero, so non-zero is close.
66 {
67 // Close
68 action = 0;
69 }
70
71 if( button && button->IsPressed() )
72 {
73 Log::Write( LogLevel_Info, GetNodeId(), "BasicWindowCovering - Start Level Change (%s)", action ? "Open" : "Close" );
74 Msg* msg = new Msg( "BasicWindowCoveringCmd_StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
75 msg->SetInstance( this, _value.GetID().GetInstance() );
76 msg->Append( GetNodeId() );
77 msg->Append( 3 );
78 msg->Append( GetCommandClassId() );
79 msg->Append( BasicWindowCoveringCmd_StartLevelChange );
80 msg->Append( action );
81 msg->Append( GetDriver()->GetTransmitOptions() );
82 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
83 return true;
84 }
85 else
86 {
87 Log::Write( LogLevel_Info, GetNodeId(), "BasicWindowCovering - Stop Level Change" );
88 Msg* msg = new Msg( "BasicWindowCoveringCmd_StopLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
89 msg->SetInstance( this, _value.GetID().GetInstance() );
90 msg->Append( GetNodeId() );
91 msg->Append( 2 );
92 msg->Append( GetCommandClassId() );
93 msg->Append( BasicWindowCoveringCmd_StopLevelChange );
94 msg->Append( GetDriver()->GetTransmitOptions() );
95 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
96 return true;
97 }
98 }
99
100 return false;
101}
102
103//-----------------------------------------------------------------------------
104// <BasicWindowCovering::CreateVars>

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected