Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "fsm/wait_push_state.h"
12 : #include "common/bqs_log.h"
13 : #include "entity.h"
14 : #include "state_manager.h"
15 :
16 : namespace dgw {
17 54 : FsmStatus WaitPushState::PreProcess(Entity& entity)
18 : {
19 54 : DGW_LOG_INFO(
20 : "[FSM] Entity id:[%u] type:[%s] state:[%s] desc:[%s].", entity.GetId(), entity.GetTypeDesc().c_str(),
21 : entity.GetStateDesc(FsmState::FSM_WAIT_PUSH_STATE).c_str(), entity.ToString().c_str());
22 54 : return FsmStatus::FSM_SUCCESS;
23 : }
24 :
25 53 : FsmStatus WaitPushState::ProcessMessage(Entity& entity, const InnerMessage& msg)
26 : {
27 53 : if (msg.msgType == InnerMsgType::INNER_MSG_PUSH) {
28 52 : return PostProcess(entity);
29 : }
30 :
31 1 : DGW_LOG_INFO(
32 : "[FSM] Entity id:[%u] type:[%s] state:[%s] desc:[%s] ignore msg:[%s].", entity.GetId(),
33 : entity.GetTypeDesc().c_str(), entity.GetStateDesc(FsmState::FSM_WAIT_PUSH_STATE).c_str(),
34 : entity.ToString().c_str(), GetMsgDesc(msg));
35 1 : return FsmStatus::FSM_SUCCESS;
36 : }
37 :
38 52 : FsmStatus WaitPushState::PostProcess(Entity& entity) { return entity.ChangeState(FsmState::FSM_PUSH_STATE); }
39 :
40 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_QUEUE, WaitPushState);
41 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_TAG, WaitPushState);
42 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_GROUP, WaitPushState);
43 : } // namespace dgw
|