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

Method SetValue

cpp/src/command_classes/Clock.cpp:166–231  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

164// Set a value in the Z-Wave device
165//-----------------------------------------------------------------------------
166bool Clock::SetValue
167(
168 Value const& _value
169)
170{
171 bool ret = false;
172
173 uint8 instance = _value.GetID().GetInstance();
174
175 ValueList* dayValue = static_cast<ValueList*>( GetValue( instance, ClockIndex_Day ) );
176 ValueByte* hourValue = static_cast<ValueByte*>( GetValue( instance, ClockIndex_Hour ) );
177 ValueByte* minuteValue = static_cast<ValueByte*>( GetValue( instance, ClockIndex_Minute ) );
178
179 if( dayValue && hourValue && minuteValue )
180 {
181 if (dayValue->GetItem() == NULL) {
182 ret = false;
183 } else {
184 uint8 day = dayValue->GetItem()->m_value;
185 if (_value.GetID() == dayValue->GetID()) {
186 ValueList const * dayvaluetmp = static_cast<ValueList const*>(&_value);
187 day = dayvaluetmp->GetItem()->m_value;
188 dayValue->OnValueRefreshed(day);
189 }
190 uint8 hour = hourValue->GetValue();
191 if (_value.GetID() == hourValue->GetID()) {
192 ValueByte const * hourvaluetmp = static_cast<ValueByte const*>(&_value);
193 hour = hourvaluetmp->GetValue();
194 hourValue->OnValueRefreshed(hour);
195 }
196 uint8 minute = minuteValue->GetValue();
197 if (_value.GetID() == minuteValue->GetID()) {
198 ValueByte const * minuteValuetmp = static_cast<ValueByte const*>(&_value);
199 minute = minuteValuetmp->GetValue();
200 minuteValue->OnValueRefreshed(minute);
201 }
202
203
204 Msg* msg = new Msg( "ClockCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
205 msg->SetInstance( this, instance );
206 msg->Append( GetNodeId() );
207 msg->Append( 4 );
208 msg->Append( GetCommandClassId() );
209 msg->Append( ClockCmd_Set );
210 msg->Append( ( day << 5 ) | hour );
211 msg->Append( minute );
212 msg->Append( GetDriver()->GetTransmitOptions() );
213 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
214 ret = true;
215 }
216 }
217
218 if( dayValue != NULL )
219 {
220 dayValue->Release();
221 }
222 if( hourValue != NULL )
223 {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected