Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and liangpy4 committed Nov 30, 2023
1 parent 764c467 commit ad5668d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate,
mMicrowaveOvenControlInstance(this, aClustersEndpoint, MicrowaveOvenControl::Id, &mOperationalStateInstance,
&mMicrowaveOvenModeInstance),
mOperationalStateInstance(this, aClustersEndpoint, OperationalState::Id),
mMicrowaveOvenModeInstance(this, aClustersEndpoint, MicrowaveOvenMode::Id,0)
mMicrowaveOvenModeInstance(this, aClustersEndpoint, MicrowaveOvenMode::Id, 0)
{}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,23 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::
auto & cookTime = req.cookTime;
auto & powerSetting = req.powerSetting;

VerifyOrExit((cookMode.HasValue() || cookTime.HasValue() || powerSetting.HasValue()),
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cooking parameters, command fields are null "));
VerifyOrExit((cookMode.HasValue() || cookTime.HasValue() || powerSetting.HasValue()), status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cooking parameters, command fields are null "));

VerifyOrExit(!(cookMode.HasValue() && (!mMicrowaveOvenModeInstance->IsSupportedMode(cookMode.Value()))),
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookMode, cookMode is not supported"));
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookMode, cookMode is not supported"));

VerifyOrExit(!(cookTime.HasValue() && (!IsCookTimeInRange(cookTime.Value()))),
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookTime, cookTime value is out of range"));
VerifyOrExit(!(cookTime.HasValue() && (!IsCookTimeInRange(cookTime.Value()))), status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookTime, cookTime value is out of range"));

VerifyOrExit(!(powerSetting.HasValue() && (!IsPowerSettingInRange(powerSetting.Value(), mDelegate->GetMinPower(), mDelegate->GetMaxPower()))),
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookPower, cookPower value is out of range"));
VerifyOrExit(!(powerSetting.HasValue() &&
(!IsPowerSettingInRange(powerSetting.Value(), mDelegate->GetMinPower(), mDelegate->GetMaxPower()))),
status = Status::InvalidCommand;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookPower, cookPower value is out of range"));

opState = mOpStateInstance->GetCurrentOperationalState();
VerifyOrExit(opState == to_underlying(OperationalStateEnum::kStopped),
status = Status::InvalidInState);
VerifyOrExit(opState == to_underlying(OperationalStateEnum::kStopped), status = Status::InvalidInState);

if (cookTime.HasValue())
{
Expand All @@ -214,7 +212,6 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::
}
status = mDelegate->HandleSetCookingParametersCallback(cookMode, reqCookTime, reqPowerSetting);


exit:
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status);
}
Expand All @@ -227,14 +224,12 @@ void Instance::HandleAddMoreTime(HandlerContext & ctx, const Commands::AddMoreTi
uint32_t finalCookTime;

opState = mOpStateInstance->GetCurrentOperationalState();
VerifyOrExit(opState != to_underlying(OperationalStateEnum::kError),
status = Status::InvalidInState);
VerifyOrExit(opState != to_underlying(OperationalStateEnum::kError), status = Status::InvalidInState);

finalCookTime = GetCookTime() + req.timeToAdd;
// if the added cooking time is greater than the max cooking time, the cooking time stay unchanged.
VerifyOrExit(finalCookTime < kMaxCookTime,
status = Status::ConstraintError;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookTime, cookTime value is out of range"));
VerifyOrExit(finalCookTime < kMaxCookTime, status = Status::ConstraintError;
ChipLogError(Zcl, "Microwave Oven Control: Failed to set cookTime, cookTime value is out of range"));

status = mDelegate->HandleModifyCookTimeCallback(finalCookTime);
exit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface
Delegate * mDelegate;
EndpointId mEndpointId;
ClusterId mClusterId;
Clusters::OperationalState::Instance * mOpStateInstance = nullptr;
Clusters::OperationalState::Instance * mOpStateInstance = nullptr;
Clusters::ModeBase::Instance * mMicrowaveOvenModeInstance = nullptr;

uint32_t mCookTime = kDefaultCookTime;
Expand Down

0 comments on commit ad5668d

Please sign in to comment.