HM-SPMS/platform/src/application/app_fbd/fbd_common/FbdDiagDataStructPrivate.h
2025-03-13 10:13:07 +08:00

281 lines
9.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************//**
* @file FbdDiagDataStructPrivate.h
* @brief 功能块图Diagram数据私有结构
* 仅供 fbd_common 库及 app_fbd_server服务使用模块插件不应使用
* @author yikenan
* @version 1.0
* @date 2020/12/7
**********************************************************************************/
#pragma once
#include "boost/any.hpp"
#include "boost/multi_index/member.hpp"
#include "boost/multi_index/mem_fun.hpp"
//#include "boost/multi_index/identity.hpp"
#include "boost/multi_index_container.hpp"
//#include "boost/multi_index/hashed_index.hpp"
#include "boost/multi_index/ordered_index.hpp"
//#include "boost/multi_index/sequenced_index.hpp"
#include "boost/unordered_map.hpp"
#include "app_fbd/fbd_common/FbdDiagDataStruct.h"
namespace iot_app
{
namespace app_fbd
{
//< 注意: 本文件内容仅供 fbd_common 库及 app_fbd_server服务使用模块插件不应使用
/***********************************************************************************************/
//< FBD组信息表
#define CN_TN_FbdGroup "fbd_group"
//< 注意:对应实时库 fbd_group 表结构
struct SFbdGroupInfo
{
int m_nId{-1}; //< 组ID
char m_szName[64]{}; //< 组名
char m_szDesc[128]{}; //< 组描述
int m_nBusinessType{-1}; //< 业务类型
int m_nRefreshTime{-1}; //< 组扫描间隔,单位毫秒
int m_nVersion{-1}; //< 组版本号,用于实现在线组态,用来判断组是否发生了变化
char m_szUpdateTime[32]{}; //< 最后更新时间,仅展示用
int m_nLocationId{-1}; //< 所属车站
int m_nSubsystemId{-1}; //< 所属子系统
};
/***********************************************************************************************/
struct SFbdModInfo
{
int m_nLevel{-1}; //< 模块所处图中层级
int m_nGroupId{-1}; //< 所属组ID
int m_nInPortSize{-1}; //< 输入端口数量
int m_nOutPortSize{-1}; //< 输出端口数量
std::string m_strModType; //< 模块类型
SFbdModKey m_stModKey; //< 模块主键
inline bool isValid() const
{
return m_nLevel > 0 && m_nGroupId > 0 && m_nInPortSize >= 0 && m_nOutPortSize >= 0 && m_stModKey.isValid();
}
inline const std::string &getDiagName() const
{
return m_stModKey.m_strDiagName;
}
};
typedef boost::shared_ptr<SFbdModInfo> SFbdModInfoPtr;
//< 即使不用也要保留,作为主键,防重
struct SFbdModInfo_Key
{
};
struct SFbdModInfo_GrpId
{
};
typedef boost::multi_index_container
<
SFbdModInfoPtr,
boost::multi_index::indexed_by
<
boost::multi_index::ordered_unique
<
boost::multi_index::tag<SFbdModInfo_Key>,
BOOST_MULTI_INDEX_MEMBER(
SFbdModInfo, SFbdModKey, m_stModKey )
>,
boost::multi_index::ordered_non_unique
<
boost::multi_index::tag<SFbdModInfo_GrpId>,
BOOST_MULTI_INDEX_MEMBER(
SFbdModInfo, int, m_nGroupId )
>
>
> SFbdModInfoPtrContainer;
/***********************************************************************************************/
struct SFbdModInput
{
SFbdModInputKey m_stInputKey;
SFbdModOutputKey m_stOutputKey; //< 关联的上一级输出
inline bool isValid() const
{
return m_stInputKey.isValid() && m_stOutputKey.isValid();
}
inline const std::string &getDiagName() const
{
return m_stInputKey.m_stModKey.m_strDiagName;
}
};
typedef boost::shared_ptr<SFbdModInput> SFbdModInputPtr;
struct SFbdModInput_Key
{
};
struct SFbdModInput_DiagName
{
};
typedef boost::multi_index_container
<
SFbdModInputPtr,
boost::multi_index::indexed_by
<
boost::multi_index::ordered_unique
<
boost::multi_index::tag<SFbdModInput_Key>,
BOOST_MULTI_INDEX_MEMBER(
SFbdModInput, SFbdModInputKey, m_stInputKey )
>,
boost::multi_index::ordered_non_unique
<
boost::multi_index::tag<SFbdModInput_DiagName>,
BOOST_MULTI_INDEX_CONST_MEM_FUN(
SFbdModInput, const std::string &, getDiagName )
>
>
> SFbdModInputPtrContainer;
/***********************************************************************************************/
struct SFbdModOutput
{
SFbdModOutputKey m_stOutputKey;
boost::any m_anyOutputValue; //< 输出值
inline bool isValid() const
{
return m_stOutputKey.isValid();
}
inline const std::string &getDiagName() const
{
return m_stOutputKey.m_stModKey.m_strDiagName;
}
//< 将 m_anyOutputValue 输出为文本,当前用于生成调试信息
bool getValueString( int &nStatus, std::string &strValue ) const;
};
typedef boost::shared_ptr<SFbdModOutput> SFbdModOutputPtr;
struct SFbdModOutput_Key
{
};
struct SFbdModOutput_DiagName
{
};
typedef boost::multi_index_container
<
SFbdModOutputPtr,
boost::multi_index::indexed_by
<
boost::multi_index::ordered_unique
<
boost::multi_index::tag<SFbdModOutput_Key>,
BOOST_MULTI_INDEX_MEMBER(
SFbdModOutput, SFbdModOutputKey, m_stOutputKey )
>,
boost::multi_index::ordered_non_unique
<
boost::multi_index::tag<SFbdModOutput_DiagName>,
BOOST_MULTI_INDEX_CONST_MEM_FUN(
SFbdModOutput, const std::string &, getDiagName )
>
>
> SFbdModOutputPtrContainer;
/***********************************************************************************************/
struct SFbdModProperty
{
SFbdModPropKey m_stPropKey; //< 模块属性主键
std::string m_strValue; //< 属性值
inline bool isValid() const
{
return m_stPropKey.isValid();
}
inline const std::string &getDiagName() const
{
return m_stPropKey.m_stModKey.m_strDiagName;
}
};
typedef boost::shared_ptr<SFbdModProperty> SFbdModPropertyPtr;
struct SFbdModProperty_Key
{
};
struct SFbdModProperty_DiagName
{
};
typedef boost::multi_index_container
<
SFbdModPropertyPtr,
boost::multi_index::indexed_by
<
boost::multi_index::ordered_unique<
boost::multi_index::tag<SFbdModProperty_Key>,
BOOST_MULTI_INDEX_MEMBER(
SFbdModProperty, SFbdModPropKey, m_stPropKey )
>,
boost::multi_index::ordered_non_unique
<
boost::multi_index::tag<SFbdModProperty_DiagName>,
BOOST_MULTI_INDEX_CONST_MEM_FUN(
SFbdModProperty, const std::string &, getDiagName )
>
>
> SFbdModPropertyPtrContainer;
/***********************************************************************************************/
/* @brief 一个FBD组包含的所有信息用于在线组态时更新 */
struct SFbdGroupData
{
std::vector<SFbdModInfoPtr> m_vecPtrModInfo;
std::vector<SFbdModInputPtr> m_vecPtrModInput;
std::vector<SFbdModOutputPtr> m_vecPtrModOutput;
std::vector<SFbdModPropertyPtr> m_vecPtrModProp;
};
typedef boost::unordered_map<std::string,boost::any> GlobalVarHashMAP;
} //< namespace app_fbd
} //< namespace iot_app