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("[FSM] Entity id:[%u] type:[%s] state:[%s] desc:[%s].",
20 : 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("[FSM] Entity id:[%u] type:[%s] state:[%s] desc:[%s] ignore msg:[%s].", entity.GetId(),
32 : entity.GetTypeDesc().c_str(), entity.GetStateDesc(FsmState::FSM_WAIT_PUSH_STATE).c_str(),
33 : entity.ToString().c_str(), GetMsgDesc(msg));
34 1 : return FsmStatus::FSM_SUCCESS;
35 : }
36 :
37 52 : FsmStatus WaitPushState::PostProcess(Entity &entity)
38 : {
39 52 : return entity.ChangeState(FsmState::FSM_PUSH_STATE);
40 : }
41 :
42 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_QUEUE, WaitPushState);
43 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_TAG, WaitPushState);
44 : REGISTER_STATE(FSM_WAIT_PUSH_STATE, ENTITY_GROUP, WaitPushState);
45 : } // namespace dgw
|