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

Method SetValue

cpp/src/command_classes/DoorLock.cpp:285–442  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set the lock's state -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

283// Set the lock's state
284//-----------------------------------------------------------------------------
285bool DoorLock::SetValue
286(
287 Value const& _value
288)
289{
290 uint8 instance = _value.GetID().GetInstance();
291 if( (Value_Lock == _value.GetID().GetIndex()) && ValueID::ValueType_Bool == _value.GetID().GetType() )
292 {
293 ValueBool const* value = static_cast<ValueBool const*>(&_value);
294
295 Log::Write( LogLevel_Info, GetNodeId(), "Value_Lock::Set - Requesting lock to be %s", value->GetValue() ? "Locked" : "Unlocked" );
296 Msg* msg = new Msg( "DoorLockCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
297 msg->SetInstance( this, _value.GetID().GetInstance() );
298 msg->Append( GetNodeId() );
299 msg->Append( 3 );
300 msg->Append( GetCommandClassId() );
301 msg->Append( DoorLockCmd_Set );
302 msg->Append( value->GetValue() ? 0xFF:0x00 );
303 msg->Append( GetDriver()->GetTransmitOptions() );
304 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
305 return true;
306 }
307 if ( (Value_Lock_Mode == _value.GetID().GetIndex()) && (ValueID::ValueType_List == _value.GetID().GetType()) )
308 {
309 ValueList const* value = static_cast<ValueList const*>(&_value);
310 ValueList::Item const *item = value->GetItem();
311 if (item == NULL)
312 return false;
313
314
315 Log::Write( LogLevel_Info, GetNodeId(), "Value_Lock_Mode::Set - Requesting lock to be %s", item->m_label.c_str() );
316 Msg* msg = new Msg( "DoorLockCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
317 msg->SetInstance( this, _value.GetID().GetInstance() );
318 msg->Append( GetNodeId() );
319 msg->Append( 3 );
320 msg->Append( GetCommandClassId() );
321 msg->Append( DoorLockCmd_Set );
322 msg->Append( item->m_value );
323 msg->Append( GetDriver()->GetTransmitOptions() );
324 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
325 return true;
326 }
327 /* if its any of our System Messages.... */
328 if ( Value_System_Config_Mode <= _value.GetID().GetIndex() && Value_System_Config_InsideHandles >= _value.GetID().GetIndex() )
329 {
330 bool sendmsg = true;
331 switch (_value.GetID().GetIndex()) {
332 /* this is a List */
333 case Value_System_Config_Mode:
334 if (ValueID::ValueType_List != _value.GetID().GetType()) {
335 sendmsg = false;
336 break;
337 }
338 if( ValueList* value = static_cast<ValueList*>( GetValue( instance, _value.GetID().GetIndex() ) ) )
339 {
340 ValueList::Item const *item = (static_cast<ValueList const*>( &_value))->GetItem();
341 if (item != NULL)
342 value->OnValueRefreshed( item->m_value );

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected