/******************************************************************************* ModuleName: ODB Real Time Database management system FileName: odb_apinet.h DESCRIPTION: for class CTableNet of net access FUNCTION LIST: COMMENT: for net access History: Date Version Modifier Activities 2004-06-25 1.1 add context_no parameter 2003-01-09 1.0 modify ================================================================================ 2003-01-09 1.0 created *******************************************************************************/ #ifndef __ODB_APINET_h__ #define __ODB_APINET_h__ #ifndef __ODB_COMMON_H__ #include "db_api/odb_common.h" #endif #ifndef __ODB_TABLEBASE_H__ #include "db_api/odb_tablebase.h" #endif #ifndef __ODB_NETFACTORY_h__ #include "db_api/odb_netfactory.h" #endif #include "task_service.h" #include "db_api/odb_net_m.h" #include "db_api/codb_net.h" #ifdef _WINDOWS64 #ifdef ODB_API_LIB_EXPORTS #define ODB_API_LIB_API __declspec(dllexport) #else #define ODB_API_LIB_API __declspec(dllimport) #endif #else #define ODB_API_LIB_API #endif using namespace std; //using namespace RTDB_SERVER; using namespace ODB; namespace NET_ODB { //lmj add for GraphGetDataEx typedef struct { cmnInt64 graph_id; cmnInt64 cal_type; cmnInt64 req_status; //-1,0��ȡ����,1(����) Handle hdl; } TGraphReq; typedef struct { std::string scn_name; std::string subscn_name; int type; } TApiNetPriv; class ODB_API_LIB_API CApiNet: public CTableBase { public: CApiNet(); CApiNet(const int app_no, const short context_no = 0 ); CApiNet(const int app_no, const int table_no, const short context_no=0); //CApiNet(const char *hostname); ~CApiNet(); public: int SetAppNo(const int app_no, const short context_no = 0); int SetScenario(const std::string& scenario_name, int scenario_inst_no, const std::string& sub_scenario_name, int sub_scenario_inst_no); int SetScenario(const int scenario_no, const int scenario_inst_no, const int sub_scenario_no, const int sub_scenario_inst_no); int SetAppNo(const std::string& scenario_name, int scenario_inst_no, const std::string& sub_scenario_name, int sub_scenario_inst_no); int Open(const std::string& scenario_name, int scenario_inst_no, const std::string& sub_scenario_name, int sub_scenario_inst_no, int table_no); int SetHostMode(const char* host_name); int Open(const int table_no ); int Open(const int app_no, const int table_no, const short context_no=0); //int Open(const char* hostname); public: int MenuRead(const char* menu_name, std::vector& vec_menu, const int menu_status=MENU_ON); int TableReleMenuRead(const int table_no, std::vector& vec_menu); //int GetNameStringByKeyID(const KEY_ID_STRU& keyid_stru, string& ref_string); //int GetNameStringByKeyIDSplit(const KEY_ID_STRU& keyid_stru, string& ref_string); //int GetNameStringByKeyID(const std::vector& vec_keyid, std::vector& vec_ref_string); //int GetNameStringByKeyIDSplit(const std::vector& vec_keyid, std::vector& vec_ref_string); int GetRefMenuString(const int table_no, std::vector& vec_menu); int GetRefMenuStringSplit(const int table_no, std::vector& vec_menu); //jinjing 2017-01-17 int GetRefMenuStringMultiKeys(const int table_no, std::vector& vec_rtdbkeyid, std::vector& vec_menu); //int GetNameStringByID(const cmnInt64 reference_id, string& ref_string); //int GetNameStringByIDSplit(const long reference_id, string& ref_string); //int GetNameStringByID(const std::vector& vec_refid, std::vector& vec_ref_string); //int GetNameStringByIDSplit(const std::vector& vec_refid, std::vector& vec_ref_string); int GetNameStringBykey(const char* key_ptr, string& ref_string); int GetNameStringBykeySplit(const char* key_ptr, string& ref_string); int GetNameStringByAppKeyID( const std::vector& vec_appkeyid, std::vector& vec_name_string); int GetNameStringByAppID( const std::vector& vec_appid, std::vector& vec_name_string); int GetNameStringByRtdbKeyID(const RTDB_KEY_STRU& rtdb_keyid_stru, string& ref_string); int GetNameStringByRtdbKeyIDSplit(const RTDB_KEY_STRU& rtdb_keyid_stru, string& ref_string); int GetNameStringByRtdbKeyID(const std::vector& vec_rtdbkeyid, std::vector& vec_ref_string); int GetNameStringByRtdbKeyIDSplit(const std::vector& vec_rtdbkeyid, std::vector& vec_ref_string); int GraphGetAppInfo(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp); int GraphGetAppInfoSplit(const struct ODB::GRAPH_ORDER_KEY_REQ& graph_req, struct ODB::GRAPH_ORDER_KEY_RSP& graph_rsp); int GraphGetData(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp); int GraphGetDataSplit(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp); int GraphGetDataSplitSimple(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP& real_rsp); private: int GraphGetData(const RTDB_PROTO::GRAPH_REAL_REQ& real_req, RTDB_SERVER::GRAPH_REAL_RSP& real_rsp); void GraphRealReqConv(const RTDB_SERVER::GRAPH_REAL_REQ &real_req, RTDB_PROTO::GRAPH_REAL_REQ &real_req_inner); void GraphRealRspConv(const RTDB_PROTO::GRAPH_REAL_RSP &real_rsp_inner, RTDB_SERVER::GRAPH_REAL_RSP &real_rsp); //int GraphGetDataEx(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp, bool is_req=true); //int GraphDataRecv(const struct RTDB_SERVER::GRAPH_REAL_REQ& real_req , RTDB_SERVER::GRAPH_REAL_RSP_out real_rsp ); //int SqlGet(const char* str_sql, char** buf_ptr, int& buf_size); public: int GetFacNameByKeyNo(const int table_no, const char* key_ptr, string& ref_string); int GetFacNameByFacID(char* fac_name, const RTDB_KEY_STRU fac_id); int GetFacNameByFacNo(char* fac_name, const int fac_no); int GetFacIDByFacName(RTDB_KEY_STRU& fac_id, const char* fac_name); int GetFacNoByFacName(int& fac_no, const char* fac_name); int GetFacIDByFacNo(RTDB_KEY_STRU& fac_id, const int fac_no); int GetFacNoByFacID( int& fac_no, const RTDB_KEY_STRU fac_id); int ColMeasType( const std::vector vec_keyid , std::vector& vec_col_prop ); public: int GetAppNameByNo(char* app_name, const int app_no) { return 0;} int GetAppNoByName(int& app_no, const char* app_name) { return 0;} int GetTableNameByNo(char* table_name, const int table_no, const bool is_eng=true) { return 0;} int GetTableNoByName(int& table_no, const char* table_name, const bool is_eng=true) { return 0;} int GetFieldNameByNo(char* field_name, const int field_no, const bool is_eng=true) { return 0;} int GetFieldNoByName(int& field_no, const char* field_name, const bool is_eng=true) { return 0;} public: /*int GetValueAndStatus(const std::vector &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym int GetValueAndStatus(const std::vector &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc int GetValueAndStatus(const std::vector &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatus(const std::vector &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetValueAndStatus(const std::vector &struVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type */ int GetValueAndStatus(const std::vector &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym int GetValueAndStatusSplit(const std::vector &staStruVec , std::vector< struct INT_VALUE_STATUS> & KeyIdValVec);//ym int GetValueAndStatus(const std::vector &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc int GetValueAndStatusSplit(const std::vector &staStruVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec);//yc int GetValueAndStatus(const std::vector &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatusSplit(const std::vector &staStruVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatus(const std::vector &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetValueAndStatusSplit(const std::vector &staStruVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetValueAndStatus(const std::vector &staStruVec , std::vector< struct UNION_VALUE_STATUS> & KeyIdValVec );//union type int GetValueAndStatus(const std::vector &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct INT_VALUE_STATUS > &KeyIdValVec); //ym int GetValueAndStatus(const std::vector &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct FLOAT_VALUE_STATUS> & KeyIdValVec); //yc int GetValueAndStatus(const std::vector &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec); //yx int GetValueAndStatus(const std::vector &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetValueAndStatusSplit(const std::vector &struVec , std::vector< struct LONG_VALUE_STATUS > & KeyIdValVec); //long int GetRefMenuString (int table_no, std::vector& vec_menu, short area_no); int GetRefMenuStringWithAreaSplit(int table_no, std::vector& vec_menu, short area_no); int GetRefMenuString(const vector vec_table, std::vector& vec_menu); public: int PingRtdbServer(int req_data , int & rep_data); int GraphDataSend(const struct RTDB_PROTO::GRAPH_REAL_REQ& real_req ); int GraphDataRecv(RTDB_PROTO::GRAPH_REAL_RSP& real_rsp ); public: int SetDomainName(const char* domain_name); int SetSecLabel(tSecLabel& sec_label); void ClearDomainName(); int SetSliceNo(cmnUint32 slice_no); private: int Start(); int Refresh(); int Refresh(int app_no); int GetSliceByKey(const char* key, cmnUint32& slice_no); int GetAllSlice(vector& slice_no); int GetKeyInfo(); int GetKeyInfoSlice(); inline int slice_app_to_no(int slice_app_no){return slice_app_no % 1000;} inline int slice_no_to_app(int slice_no){return slice_no+AP_SCADA_AREA;} private: CApiNet(const CApiNet&); CApiNet& operator=(const CApiNet&); private: RTDB_SERVER::CODB_NET* m_OdbNet; CNetFactory* m_Factory; //Handle m_Handle; //for service_bus std::vector m_VecKey; std::vector m_IsSliced; // short m_ContextNo; int m_AppNo; int m_TableNo; DB_BYTE_T m_ByteTag; string m_ScenarioName ; int m_ScenarioInstance ; string m_SubScenarioName ; int m_SubScenarioInstance ; char m_DomainName[40]; tSecLabel m_SecLabel; bool m_IsRemote; int m_SliceNo; TaskService* task_service; bool m_IsSysAdmHost; char m_HostName[MAX_NAME_STRING_LEN]; TGraphReq *m_pGraphReq; //lmj add for GraphGetDataEx TApiNetPriv *m_pPrvStru; //lmj add for reserver }; } #endif