ElectricDataBaseManger.cpp 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466
  1. #include "pch.h"
  2. #include "ElectricDataBaseManger.h"
  3. #include "math.h"
  4. #include "PublicEqpmtID.h"
  5. #include "YD_Public_OCC.h"
  6. #include <string>
  7. #include <sstream>
  8. #include <iomanip> // 用于std::fixed等格式化
  9. #define ISCS_SUBELCMSG_ALLLINEVIEW 101 //ViewID视图ID(一次主接线的视图ID)
  10. #define ISCS_SUBELCMSG_ALLLINE1500VVIEW 16 //全线1500V系统视图 add by hcz 2015-10-12
  11. #define ISCS_SUBELCMSG_XMALLLINEVIEW 2101 //ViewID视图ID(厦门一次主接线的视图ID) added by zhangjh on 2016.12.28
  12. ElectricDataBaseManger::ElectricDataBaseManger(void)
  13. {
  14. m_pDataBase=nullptr;
  15. m_CourseID=-1;//课程ID
  16. }
  17. ElectricDataBaseManger::~ElectricDataBaseManger(void)
  18. {
  19. }
  20. bool ElectricDataBaseManger::SavePowerValue(int trainid,int stationid,string eqpmtName,int datatype,double tvalue)
  21. {//保存电力计算数据
  22. if (tvalue<0.0001)
  23. {
  24. return false;
  25. }
  26. int64_t time = GetNumTime_Second_2();
  27. std::stringstream ss;
  28. ss << "insert into Table_PowerValue(EqpmtName,TrianID,StationID,DataType,Value,OccTime) values('"
  29. << eqpmtName << "',"
  30. << trainid << ","
  31. << stationid << ","
  32. << datatype << ","
  33. << std::fixed /*<< std::setprecision(6)*/<< tvalue << "," // 控制浮点数格式,精度
  34. << time << ")";
  35. std::string strSql = ss.str();
  36. if(!m_pDataBase->DirectExecute(strSql))//adCmdText = 1,执行SQL语句增加文本
  37. {
  38. return false;
  39. }
  40. return true;
  41. }
  42. void ElectricDataBaseManger::setDDServerConfig(string configItem, string configValue)
  43. {
  44. if (configItem == "DataAssociationView")
  45. {
  46. SetDataAssociationView(configValue);
  47. }
  48. if (configItem == "EqpmtStartID")
  49. {
  50. SetEqpmtStartID(stoi(configValue));
  51. }
  52. if (configItem == "MainViewID_35kV")
  53. {
  54. m_nMainViewID_35kV = stoi(configValue);
  55. }
  56. if (configItem == "MainViewID_1500V")
  57. {
  58. m_nMainViewID_1500V = stoi(configValue);
  59. }
  60. if (configItem == "MainViewID_400V")
  61. {
  62. m_nMainViewID_400V = stoi(configValue);
  63. }
  64. if (configItem == "Power_Station_Nums")
  65. {
  66. Power_Station_Nums = stoi(configValue);
  67. }
  68. if (configItem == "All_Power_Station_Nums")
  69. {
  70. All_Power_Station_Nums = stoi(configValue);
  71. }
  72. if (configItem == "Node_Matric_Collom")
  73. {
  74. NODE_MATRIC_COLLOM = stoi(configValue);
  75. }
  76. if (configItem == "Node_Matric_Row")
  77. {
  78. NODE_MATRIC_ROW = stoi(configValue);
  79. }
  80. if (configItem == "Max_SigleArrowTrain_Nums")
  81. {
  82. Max_SigleArrowTrain_Nums = stoi(configValue);
  83. }
  84. if (configItem == "Voltage_Calculate_InitValueV")
  85. {
  86. Voltage_Calculate_InitValueV = stoi(configValue);
  87. }
  88. }
  89. bool ElectricDataBaseManger::initDDServerConfigInfo()
  90. {
  91. std::stringstream ss;
  92. ss << "Select * from Table_DDServerConfigInfo where RunLineID = " << m_nLineID ;
  93. std::string strSql = ss.str();
  94. std::shared_ptr<iDBReadSet> query_result = { 0 };
  95. query_result = m_pDataBase->DirectQuery(strSql);
  96. if (query_result) {
  97. std::string sConfigItem = "", sConfigValue = "";
  98. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  99. {
  100. try
  101. {
  102. sConfigItem = query_result->GetFieldValue("ConfigItem", std::string(""));
  103. sConfigValue = query_result->GetFieldValue("ConfigValue", std::string(""));
  104. setDDServerConfig(sConfigItem, sConfigValue);
  105. }
  106. catch (const std::exception&)
  107. {
  108. return false;
  109. }
  110. }
  111. }
  112. return true;
  113. }
  114. bool ElectricDataBaseManger::initBaseEqpmtDefineInfo()
  115. {
  116. std::stringstream ss;
  117. ss << "Select * from Table_BaseEqpmtDefineInfo where RunLineID = " << m_nLineID;
  118. std::string strSql = ss.str();
  119. std::shared_ptr<iDBReadSet> query_result = { 0 };
  120. query_result = m_pDataBase->DirectQuery(strSql);
  121. if (query_result) {
  122. int nEqpmtType = -1, nEqpmtID = -1;
  123. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  124. {
  125. try
  126. {
  127. nEqpmtType = query_result->GetFieldValue("EqpmtDefineTypeID", int(-1));
  128. nEqpmtID = query_result->GetFieldValue("EqpmtTypeID", int(-1));
  129. SetEqpmtTypeID(nEqpmtType, nEqpmtID);
  130. }
  131. catch (const std::exception&)
  132. {
  133. return false;
  134. }
  135. }
  136. }
  137. return true;
  138. }
  139. bool ElectricDataBaseManger::GetPowerStationFromDB(ELECSTATIONMAP& stationmap)//从数据库中获取电站信息数据
  140. {
  141. std::string strSql="truncate table Table_PowerValue";
  142. if(!m_pDataBase->DirectExecute(strSql))
  143. {
  144. return false;
  145. }
  146. std::stringstream ss;
  147. ss << "Select * from Table_StationInfo where RunLineID = " << m_nLineID;
  148. strSql = ss.str();
  149. std::shared_ptr<iDBReadSet> query_result = { 0 };
  150. query_result = m_pDataBase->DirectQuery(strSql);
  151. if (query_result) {
  152. PowerStationInfo pt;//电站信息
  153. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  154. {
  155. try
  156. {
  157. pt.stationID = query_result->GetFieldValue("StationID", int(-1));
  158. pt.nextstationid = query_result->GetFieldValue("NextStation", int(-1));
  159. pt.strstationname = query_result->GetFieldValue("StationName", std::string(""));
  160. pt.stationType = query_result->GetFieldValue("Type", int(-1));
  161. pt.ctrlarea = query_result->GetFieldValue("ControlArea", int(-1));
  162. stationmap.insert(ELECSTATIONMAP::value_type(pt.stationID, pt));
  163. }
  164. catch (const std::exception&)
  165. {
  166. return false;
  167. }
  168. }
  169. }
  170. return true;
  171. }
  172. bool ElectricDataBaseManger::GetEqpmt_TouchNet_Track_Relation_FromDB(DCSysMG& DcSys)
  173. {//从数据库获取接触网与轨道之间的关系数据
  174. std::stringstream ss;
  175. ss << "Select * from Table_TouchNet_Track_Relation where RunLineID = " << m_nLineID;
  176. std::string strSql = ss.str();
  177. std::shared_ptr<iDBReadSet> query_result = { 0 };
  178. query_result = m_pDataBase->DirectQuery(strSql);
  179. if (query_result) {
  180. Track_Section tracksec;
  181. string sTouchNetID = "";
  182. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  183. {
  184. try
  185. {
  186. tracksec.TrackID = query_result->GetFieldValue("TrackLineID", int(-1));//轨道线路ID
  187. tracksec.StartPos = query_result->GetFieldValue("StartPos", int(-1));//轨道起始位置
  188. tracksec.EndPos = query_result->GetFieldValue("EndPos", int(-1));//轨道终点
  189. tracksec.Index = query_result->GetFieldValue("index", int(-1));//索引
  190. sTouchNetID = query_result->GetFieldValue("TouchNetID", std::string(""));
  191. DcSys.AdjustTouchNetRelation(sTouchNetID, tracksec);
  192. }
  193. catch (const std::exception&)
  194. {
  195. return false;
  196. }
  197. }
  198. }
  199. std::stringstream ss_2;
  200. ss_2 << "Select * from Table_TouchNetHeadTailInfo where RunLineID = " << m_nLineID;
  201. strSql = ss_2.str();
  202. std::shared_ptr<iDBReadSet> query_result_2 = { 0 };
  203. query_result_2 = m_pDataBase->DirectQuery(strSql);
  204. if (query_result_2) {
  205. int nArrow = -1, nLineType = -1;
  206. string sLineID = "";
  207. for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext())
  208. {
  209. try
  210. {
  211. nArrow = query_result_2->GetFieldValue("Arrow", int(-1));
  212. nLineType = query_result_2->GetFieldValue("LineType", int(-1));
  213. sLineID = query_result_2->GetFieldValue("LineID", std::string(""));
  214. //根据列车运行方向,线路类型和线路ID设置接触网的头尾节点
  215. DcSys.SetHeadTailTouchNet(nArrow, nLineType, sLineID);
  216. }
  217. catch (const std::exception&)
  218. {
  219. return false;
  220. }
  221. }
  222. }
  223. return true;
  224. }
  225. bool ElectricDataBaseManger::GetEqpmt_TouchNet_FromDB(ELEEQPMTMAP* ElectricEqpmtMap,TOUCHNETMAP* TouchNetMap)
  226. {//从数据库获取接触网信息
  227. std::stringstream ss;
  228. ss << "Select * from Table_TouchNetInfo,Table_EqpmtBaseInfo where Table_EqpmtBaseInfo.RunLineID = "
  229. << m_nLineID << "and Table_EqpmtBaseInfo.StrID=Table_TouchNetInfo.StrID";
  230. std::string strSql = ss.str();
  231. std::shared_ptr<iDBReadSet> query_result = { 0 };
  232. query_result = m_pDataBase->DirectQuery(strSql);
  233. if (query_result) {
  234. ProtectEqpmtRelationMAP::iterator iterProtect;
  235. string strEqpmtID = "";
  236. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  237. {
  238. try
  239. {
  240. CElectricEqpmt_Line_TouchNet* pUnit = new CElectricEqpmt_Line_TouchNet;
  241. strEqpmtID = query_result->GetFieldValue("StrID", std::string(""));
  242. pUnit->SetEqpmentID(strEqpmtID);
  243. pUnit->SetStatus(query_result->GetFieldValue("Status", int(-1)));
  244. pUnit->SetEqmpInitStatus(query_result->GetFieldValue("Status", int(-1)));
  245. pUnit->SetStationID(query_result->GetFieldValue("StationID", int(-1)));
  246. pUnit->SetViewID(query_result->GetFieldValue("ViewID", int(-1)));
  247. pUnit->SetBaseType(query_result->GetFieldValue("EqpmtType", int(-1)));
  248. pUnit->SetEqpmentName(query_result->GetFieldValue("Name", std::string("")));
  249. pUnit->SetStartStation(query_result->GetFieldValue("StartStationID", int(-1)));
  250. pUnit->SetEndStation(query_result->GetFieldValue("EndStationID", int(-1)));
  251. pUnit->SetIndex(query_result->GetFieldValue("Index", int(-1)));
  252. pUnit->SetRunDirection(query_result->GetFieldValue("Kind", int(-1)));//类型 上行还是下行
  253. for (iterProtect = m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID); iterProtect != m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID); iterProtect++)
  254. {
  255. pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID);
  256. }
  257. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  258. TouchNetMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  259. }
  260. catch (const std::exception&)
  261. {
  262. return false;
  263. }
  264. }
  265. }
  266. return true;
  267. }
  268. bool ElectricDataBaseManger::GetEqpmt_InPutRelation_FromDB(ELEEQPMTMAP* ElectricEqpmtMap)
  269. {//获取设备输入关系
  270. std::stringstream ss;
  271. ss << "Select * from Table_InPutRelation where RunLineID = " << m_nLineID;
  272. std::string strSql = ss.str();
  273. std::shared_ptr<iDBReadSet> query_result = { 0 };
  274. query_result = m_pDataBase->DirectQuery(strSql);
  275. if (query_result) {
  276. ProtectEqpmtRelationMAP::iterator iterProtect;
  277. std::string strsourceid = "", strinputid = "";
  278. int relation = -1;
  279. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  280. {
  281. try
  282. {
  283. strsourceid = query_result->GetFieldValue("StrID", std::string(""));
  284. strinputid = query_result->GetFieldValue("InputEqpmtStrID", std::string(""));
  285. relation = query_result->GetFieldValue("Relation", int(-1));
  286. // 查找源设备
  287. ELEEQPMTMAP::iterator iter = ElectricEqpmtMap->find(strsourceid);
  288. if (iter == ElectricEqpmtMap->end())
  289. {
  290. continue;
  291. }
  292. // 查找目标设备
  293. ELEEQPMTMAP::iterator iter1 = ElectricEqpmtMap->find(strinputid);
  294. if (iter1 == ElectricEqpmtMap->end())
  295. {
  296. continue;
  297. }
  298. if (relation == EQPMT_RELATIONTYPE_INPUT) //输入关系
  299. {
  300. iter->second->AddInputRelation(strinputid);
  301. iter1->second->AddOutputRelation(strsourceid);
  302. }
  303. if (relation == EQPMT_RELATIONTYPE_AUTOBOLTLSWITCH) //备自投开关 左
  304. {
  305. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT)
  306. {
  307. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  308. pbolt->SetLeftInputBreak(strinputid); //设置左边输入断路器
  309. //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复
  310. pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto);
  311. }
  312. iter1->second->SetAutoBoltID(strsourceid);
  313. iter1->second->SetMotherAutoBolt(strsourceid);
  314. if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker)
  315. {
  316. ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second;
  317. pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLTLSWITCH); //设置断路器为类型为左进线
  318. }
  319. }
  320. if (relation == EQPMT_RELATIONTYPE_AUTOBOLTRSWITCH) //备自投开关 右
  321. {
  322. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) //电源开关
  323. {
  324. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  325. pbolt->SetRightInputBreak(strinputid);
  326. //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复
  327. pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto);
  328. }
  329. iter1->second->SetAutoBoltID(strsourceid);
  330. iter1->second->SetMotherAutoBolt(strsourceid);
  331. if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker)
  332. {
  333. ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second;
  334. pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLTRSWITCH);//设置断路器为类型为右进线
  335. }
  336. }
  337. if (relation == EQPMT_RELATIONTYPE_AUTOBOLT) //备自投关系类型锁
  338. {
  339. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT)
  340. {
  341. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  342. pbolt->SetRelationBreaker(strinputid); //设置断路器
  343. //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复
  344. pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto);
  345. }
  346. iter1->second->SetAutoBoltID(strsourceid);
  347. iter1->second->SetMotherAutoBolt(strsourceid);
  348. if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker)
  349. {
  350. ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second;
  351. pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLT); //设置断路器为类型为母联
  352. }
  353. }
  354. if (relation == EQPMT_RELATIONTYPE_NEXTAUTOBOLT) //下一个备自投
  355. {
  356. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT)
  357. {
  358. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  359. pbolt->SetNextBolt(strinputid);
  360. //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复
  361. pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto);
  362. }
  363. }
  364. if (relation == EQPMT_RELATIONTYPE_AUTOBOLTAASWITCH || relation == EQPMT_RELATIONTYPE_AUTOBOLTAMSWITCH || relation == EQPMT_RELATIONTYPE_AUTOBOLTMMSWITCH) //备自投模式关联设备
  365. {
  366. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT)
  367. {
  368. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  369. pbolt->SetModeStatusShowEqpmt(strinputid, relation); //设置备自投模式关联设备
  370. }
  371. }
  372. }
  373. catch (const std::exception&)
  374. {
  375. return false;
  376. }
  377. }
  378. }
  379. return true;
  380. }
  381. //获取接地开关相关元件信息 add by yangs
  382. bool ElectricDataBaseManger::GetEqpmt_EarthSwitchRelation_FromDB(ELEEQPMTMAP* ElectricEqpmtMap)
  383. {
  384. std::stringstream ss;
  385. ss << "Select * from Table_EarthSwitchRelation where RunLineID = " << m_nLineID;
  386. std::string strSql = ss.str();
  387. std::shared_ptr<iDBReadSet> query_result = { 0 };
  388. query_result = m_pDataBase->DirectQuery(strSql);
  389. if (query_result) {
  390. ProtectEqpmtRelationMAP::iterator iterProtect;
  391. std::string strsourceid = "", strinputid = "";
  392. int relation = -1;
  393. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  394. {
  395. try {
  396. strsourceid = query_result->GetFieldValue("StrID", std::string(""));
  397. strinputid = query_result->GetFieldValue("InputEqpmtStrID", std::string(""));
  398. relation = query_result->GetFieldValue("Relation", int(-1));
  399. ELEEQPMTMAP::iterator iter = ElectricEqpmtMap->find(strsourceid);
  400. if (iter == ElectricEqpmtMap->end())
  401. {
  402. continue;
  403. }
  404. ELEEQPMTMAP::iterator iter1 = ElectricEqpmtMap->find(strinputid);
  405. if (iter1 == ElectricEqpmtMap->end())
  406. {
  407. continue;
  408. }
  409. if (relation == EQPMT_RELATIONTYPE_EARTHSWITCH) //断路器关联接地开关
  410. {
  411. iter->second->SetEarthSwitchID(strinputid);
  412. }
  413. if (relation == EQPMT_RELATIONTYPE_EARTHSWITCHINPUT) //接地开关关联的输入
  414. {
  415. iter->second->SetEarthSwitchRelationSwitch(strinputid);
  416. }
  417. }
  418. catch (const std::exception&)
  419. {
  420. return false;
  421. }
  422. }
  423. }
  424. return true;
  425. }
  426. bool ElectricDataBaseManger::InitDC_StationInfo(DCSysMG& DcSys)//初始化直流车站信息
  427. {
  428. std::stringstream ss;
  429. ss << "Select * from Table_DCStationInfo where RunLineID = " << m_nLineID;
  430. std::string strSql = ss.str();
  431. std::shared_ptr<iDBReadSet> query_result = { 0 };
  432. query_result = m_pDataBase->DirectQuery(strSql);
  433. if (query_result) {
  434. Dc_PowerStation DcStationInfo;
  435. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  436. {
  437. try
  438. {
  439. DcStationInfo.SetWorkArea(1);//设置工区
  440. DcStationInfo.SetID(query_result->GetFieldValue("StationID", int(-1)));//设置车站ID
  441. DcStationInfo.SetName(query_result->GetFieldValue("StationName", std::string("")));//设置车站名字
  442. DcStationInfo.SetNearStation(query_result->GetFieldValue("PreStationID", int(-1)), query_result->GetFieldValue("NextStationID",int(-1)));//设置临近车站,此处为前一个和下一个车站
  443. DcStationInfo.SetUpTouchNetID(query_result->GetFieldValue("UpTouchNetID",std::string("")));//设置上行接触网ID
  444. DcStationInfo.SetDownTouchNetID(query_result->GetFieldValue("DownTouchNetID", std::string("")));//设置下行接触 ID
  445. DcStationInfo.SetFeedBackLineLen(stod(query_result->GetFieldValue("upfeedbacklineLenght",std::string(""))), stod(query_result->GetFieldValue("downfeedbacklineLenght",std::string(""))));//设置馈线长度
  446. DcStationInfo.SetContactNetLineLen(stod(query_result->GetFieldValue("upprelineLenght",std::string(""))), stod(query_result->GetFieldValue("downprelineLenght",std::string(""))), stod(query_result->GetFieldValue("downnextlineLenght",std::string(""))), stod(query_result->GetFieldValue("upnextlineLenght", std::string(""))));//设置接触线的长度
  447. //added by zhangjiahua
  448. DcStationInfo.SetOverZoneUpSwitchID(query_result->GetFieldValue("OverZoneUpSwitchID",std::string(""))); //设置上行越区隔离开关图元ID
  449. DcStationInfo.SetOverZoneDownSwitchID(query_result->GetFieldValue("OverZoneDownSwitchID", std::string(""))); //设置下行越区隔离开关图元ID
  450. //xyx新增 begin
  451. DcStationInfo.SetFeedUpPreBreakerID(query_result->GetFieldValue("FeedUpPreBreakerID", std::string(""))); //设置上行前一直流馈线断路器图元ID
  452. DcStationInfo.SetFeedUpNextBreakerID(query_result->GetFieldValue("FeedUpNextBreakerID", std::string(""))); //设置上行后一直流馈线断路器图元ID
  453. DcStationInfo.SetFeedDownPreBreakerID(query_result->GetFieldValue("FeedDownPreBreakerID", std::string(""))); //设置下行前一直流馈线断路器图元ID
  454. DcStationInfo.SetFeedDownNextBreakerID(query_result->GetFieldValue("FeedDownNextBreakerID", std::string(""))); //设置下行前一直流馈线断路器图元ID
  455. DcStationInfo.SetRectierToTouchNetUnitID(query_result->GetFieldValue("DCPositiveBusID", std::string(""))); //设置直流正极母线图元ID
  456. DcStationInfo.SetRectierToRailwayUnitID(query_result->GetFieldValue("DCNegativeBusID", std::string(""))); //设置直流负极母线图元ID
  457. DcStationInfo.SetFirstDCInputBreakerUnitID(query_result->GetFieldValue("FirstInputBreakerID", std::string(""))); //设置直流进线开关I图元ID
  458. DcStationInfo.SetSecondDCInputBreakerUnitID(query_result->GetFieldValue("SecondInputBreakerID", std::string(""))); //设置直流进线开关II图元ID
  459. //xyx新增 end
  460. DcSys.AddStationInfo(DcStationInfo);//增加车站信息
  461. }
  462. catch (const std::exception&)
  463. {
  464. return false;
  465. }
  466. }
  467. }
  468. return true;
  469. }
  470. bool ElectricDataBaseManger::InitAc_PowerLineInfo(ACSysMG& AcSys)//初始化交流电力线信息
  471. {
  472. //根据基准值计算相应的标幺值,S为视载功率,即容量
  473. double Iac = OCC_POWER_Sacbase/(sqrt(3.0)*OCC_POWER_Vacbase);//交流侧电流基准值,(出自王大论文P25)
  474. double Zac = OCC_POWER_Vacbase/(sqrt(3.0)*Iac);
  475. double Yac = 1/Zac;
  476. AcSys.SetYBZ(Iac,Zac,Yac,OCC_POWER_Sacbase,OCC_POWER_Vacbase);
  477. std::stringstream ss;
  478. ss << "Select * from Table_PowerLine where LineCalID = " << m_nLineID;
  479. std::string strSql = ss.str();
  480. std::shared_ptr<iDBReadSet> query_result = { 0 };
  481. query_result = m_pDataBase->DirectQuery(strSql);
  482. if (query_result) {
  483. int nID = -1, category = -1, status = 0;
  484. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  485. {
  486. try
  487. {
  488. nID = query_result->GetFieldValue("ID", int(-1));
  489. if (nID > 0)
  490. {
  491. PowerLine* pline = new PowerLine;
  492. string name = query_result->GetFieldValue("StrID", std::string(""));
  493. //int id = atoi((LPCSTR)(_bstr_t)r_set1->GetCollect("ID"));
  494. category = query_result->GetFieldValue("Category", int(-1));
  495. status = query_result->GetFieldValue("Status", int(-1));
  496. pline->SetEqpmtInfo(nID, category, status, name);
  497. pline->SetLenght(query_result->GetFieldValue("Lenght", int(-1)));
  498. double R = stod(query_result->GetFieldValue("R", std::string(""))) / Zac;
  499. double X = stod(query_result->GetFieldValue("X", std::string(""))) / Zac;
  500. double B = stod(query_result->GetFieldValue("B", std::string(""))) / Yac;//导纳虚部的计算
  501. R = OCC_POWER_R_RATE * pline->GetLenght();//电阻率的实部
  502. X = OCC_POWER_X_RATE * pline->GetLenght();//电阻率的虚部
  503. pline->SetBgkLineID(query_result->GetFieldValue("GraphUnitLineID", int(-1)));
  504. pline->SetRXB(R, X, B);
  505. pline->SetLineID(query_result->GetFieldValue("LlineID", int(-1)), query_result->GetFieldValue("RlineID", int(-1)));
  506. pline->SetBranchGraphUnitID(query_result->GetFieldValue("BranchGraphUnitID", std::string(""))); //设置支路对应图元ID xyx新增
  507. AcSys.AddEqpmtData(pline);
  508. }
  509. }
  510. catch (const std::exception&)
  511. {
  512. return false;
  513. }
  514. }
  515. }
  516. return true;
  517. }
  518. bool ElectricDataBaseManger::InitAc_PowerCalNodeInfo(ACSysMG& AcSys)//初始化交流计算节点信息
  519. {
  520. std::stringstream ss;
  521. ss << "Select * from Table_PowerCalNode where LineCalID = " << m_nLineID;
  522. std::string strSql = ss.str();
  523. std::shared_ptr<iDBReadSet> query_result = { 0 };
  524. query_result = m_pDataBase->DirectQuery(strSql);
  525. if (query_result) {
  526. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  527. {
  528. try
  529. {
  530. CalNode PQNode;//计算节点类
  531. PQNode.ID = query_result->GetFieldValue("NodeID", int(-1));//节点ID
  532. PQNode.BgkID = query_result->GetFieldValue("MotherLineID",std::string(""));//母线ID
  533. PQNode.Category = query_result->GetFieldValue("Category", int(-1));//节点类型
  534. PQNode.Position = query_result->GetFieldValue("Position", int(-1));//节点位置
  535. PQNode.strName = query_result->GetFieldValue("strName", std::string(""));//节点名称
  536. PQNode.StationID = query_result->GetFieldValue("StationID",int(-1));//车站ID
  537. PQNode.Index = query_result->GetFieldValue("Index", int(-1));//节点索引
  538. PQNode.Pis = stod(query_result->GetFieldValue("Pi", std::string("")));//第i节点的有功功率
  539. PQNode.Qis = stod(query_result->GetFieldValue("Qi", std::string("")));
  540. double P = stod(query_result->GetFieldValue("ConsumePowerR", std::string(""))) / OCC_POWER_Sacbase;//消耗功率的实部
  541. double Q = stod(query_result->GetFieldValue("ConsumePowerX", std::string(""))) / OCC_POWER_Sacbase;
  542. PQNode.ConsumePowerR = P;//有功功率
  543. PQNode.ConsumePowerX = Q;
  544. PQNode.E = stod(query_result->GetFieldValue("E", std::string("")));//系统修正变量
  545. PQNode.F = stod(query_result->GetFieldValue("F", std::string("")));
  546. PQNode.m_IniE = PQNode.E;
  547. PQNode.m_IniF = PQNode.F;
  548. PQNode.InputV = stod(query_result->GetFieldValue("InputV", std::string("")));//输入电压
  549. PQNode.inputlineid = query_result->GetFieldValue("InputLineID", std::string(""));//输入线ID
  550. PQNode.outputlineid = query_result->GetFieldValue("OuputLineID", std::string(""));//输出线ID
  551. std::stringstream ss_2;
  552. ss_2 << "Select * from Table_NodeRelation where NodeID = " << PQNode.ID;
  553. std::string strSql_2 = ss_2.str();
  554. std::shared_ptr<iDBReadSet> query_result_2 = { 0 };
  555. query_result_2 = m_pDataBase->DirectQuery(strSql_2);
  556. if (query_result_2)
  557. {
  558. for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext())
  559. {
  560. try
  561. {
  562. PQNode.m_Relations.push_back(query_result_2->GetFieldValue("InLineID", int(-1)));
  563. }
  564. catch (const std::exception&)
  565. {
  566. }
  567. }
  568. }
  569. std::stringstream ss_3;
  570. ss_3 << "Select * from Table_NodeRelationLine where NodeID = " << PQNode.ID
  571. << " and RunLineID = " << m_nLineID;
  572. std::string strSql_3 = ss_3.str();
  573. std::shared_ptr<iDBReadSet> query_result_3 = { 0 };
  574. query_result_3 = m_pDataBase->DirectQuery(strSql_3);
  575. if (query_result_3)
  576. {
  577. for (query_result_3->MoveFirst(); !query_result_3->IsEOF(); query_result_3->MoveNext())
  578. {
  579. try
  580. {
  581. SubLine subline;
  582. subline.breakerid = query_result_3->GetFieldValue("RelaBreaker", std::string(""));//断路器ID //表中的断路器名称
  583. subline.tranformid = query_result_3->GetFieldValue("RelaTranform", std::string(""));//变压器ID //表中的变压器名称
  584. subline.BaseP = subline.P = stod(query_result_3->GetFieldValue("P", std::string("")));//有功功率基准值
  585. subline.BaseQ = subline.Q = stod(query_result_3->GetFieldValue("Q", std::string("")));//无功功率基准值
  586. subline.type = query_result_3->GetFieldValue("Type",int(-1));//子线类型
  587. PQNode.m_SubLines.push_back(subline);
  588. }
  589. catch (const std::exception&)
  590. {
  591. }
  592. }
  593. }
  594. //xyx新增 begin 增加与母线节点相关联的开关图元ID
  595. //查找节点ID与PQ节点ID一致的
  596. std::stringstream ss_4;
  597. ss_4 << "Select * from Table_LineSwitch where BusID = %d = " << PQNode.ID;
  598. std::string strSql_4 = ss_4.str();
  599. std::shared_ptr<iDBReadSet> query_result_4 = { 0 };
  600. query_result_4 = m_pDataBase->DirectQuery(strSql_4);
  601. if (query_result_4)
  602. {
  603. for (query_result_4->MoveFirst(); !query_result_4->IsEOF(); query_result_4->MoveNext())
  604. {
  605. try
  606. {
  607. PQNode.m_RelationsSwitch.push_back(query_result_4->GetFieldValue("SwitchID", std::string("")));
  608. }
  609. catch (const std::exception&)
  610. {
  611. }
  612. }
  613. }
  614. //xyx新增 end
  615. AcSys.AddPQNodeData(PQNode);
  616. }
  617. catch (const std::exception&)
  618. {
  619. return false;
  620. }
  621. }
  622. }
  623. return true;
  624. }
  625. bool ElectricDataBaseManger::InitAc_PowerLineSwitch(ACSysMG& AcSys)
  626. {
  627. std::stringstream ss;
  628. ss << "Select * from Table_LineSwitch where RunLineID = " << m_nLineID;
  629. std::string strSql = ss.str();
  630. std::shared_ptr<iDBReadSet> query_result = { 0 };
  631. query_result = m_pDataBase->DirectQuery(strSql);
  632. if (query_result) {
  633. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  634. {
  635. try
  636. {
  637. int LineID = query_result->GetFieldValue("LineID", int(-1));
  638. map<int, EqpmtInfo*>::iterator iter = AcSys.m_EqpmtInfoMap.find(LineID);
  639. if (iter != AcSys.m_EqpmtInfoMap.end())
  640. {
  641. PowerLine* pLine = (PowerLine*)iter->second;
  642. pLine->AddSwitchID(query_result->GetFieldValue("SwitchID", std::string("")));
  643. }
  644. }
  645. catch (const std::exception&)
  646. {
  647. return false;
  648. }
  649. }
  650. }
  651. return true;
  652. }
  653. bool ElectricDataBaseManger::GetTrackRelationXDData( TrackRelationXDMAP& trackrelationxdmap )
  654. {
  655. std::stringstream ss;
  656. ss << "Select * from Table_TrackRelationXD where RunLineID = " << m_nLineID;
  657. std::string strSql = ss.str();
  658. std::shared_ptr<iDBReadSet> query_result = { 0 };
  659. query_result = m_pDataBase->DirectQuery(strSql);
  660. if (query_result) {
  661. TrackRelationXD* ptrackrelationxd = nullptr;
  662. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  663. {
  664. try
  665. {
  666. ptrackrelationxd = new TrackRelationXD;
  667. ptrackrelationxd->m_strID = query_result->GetFieldValue("StrID", std::string(""));
  668. ptrackrelationxd->m_stationID = query_result->GetFieldValue("StationID", int(-1));
  669. ptrackrelationxd->m_StationName = query_result->GetFieldValue("StationName", std::string(""));
  670. ptrackrelationxd->m_Direction = query_result->GetFieldValue("Direction", int(-1));
  671. ptrackrelationxd->m_IsPower = query_result->GetFieldValue("IsPower", int(-1));
  672. ptrackrelationxd->m_SectionNo = query_result->GetFieldValue("SectionNo", int(-1));
  673. ptrackrelationxd->m_NoID = query_result->GetFieldValue("NoID", int(-1));
  674. trackrelationxdmap.insert(make_pair(ptrackrelationxd->m_strID, ptrackrelationxd));
  675. }
  676. catch (const std::exception&)
  677. {
  678. return false;
  679. }
  680. }
  681. }
  682. return true;
  683. }
  684. bool ElectricDataBaseManger::GetEqpmtsFromDB( ELEEQPMTMAP* ElectricEqpmtMap )
  685. {
  686. if (ElectricEqpmtMap->size()>0)
  687. {
  688. ElectricEqpmtMap->clear();
  689. }
  690. if (!InitLogicRelationData())
  691. {
  692. return FALSE;
  693. }
  694. if(!GetEqpmtsBeeLineFromDB(ElectricEqpmtMap) || !GetEqpmtsPicUnitFromDB(ElectricEqpmtMap))
  695. {
  696. return false;
  697. }
  698. if (!AddProtectingEqpmt(ElectricEqpmtMap))
  699. {
  700. return false;
  701. }
  702. return true;
  703. }
  704. bool ElectricDataBaseManger::GetEqpmtsBeeLineFromDB(/* _RecordsetPtr r_set,*/ELEEQPMTMAP* ElectricEqpmtMap )
  705. {
  706. string strEqpmtID;
  707. ProtectEqpmtRelationMAP::iterator iterProtect;
  708. EqpmtCtrlUnionMAP::iterator iterCtrlUnion;
  709. int nEqpmtType;
  710. int nSubEqpmtType;
  711. std::stringstream ss;
  712. if (m_nLineID == 300)
  713. {
  714. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_BaseGraphInfo.Type = " << OCC_GRAPHUNIT_TYPE_LINE
  715. << " and Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID";
  716. }
  717. else if (m_nLineID == 200)
  718. {
  719. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID
  720. << " and Table_BaseGraphInfo.type=501 and 2000000 > Table_BaseGraphInfo.ID";
  721. }
  722. else
  723. {
  724. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID
  725. << " and Table_BaseGraphInfo.type = 501 and " << m_nEqpmtStartID << " < Table_BaseGraphInfo.ID and ViewID in(" << m_strDataAssociationView << ")";
  726. }
  727. std::string strSql = ss.str();
  728. std::shared_ptr<iDBReadSet> query_result = { 0 };
  729. query_result = m_pDataBase->DirectQuery(strSql);
  730. if (query_result) {
  731. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  732. {
  733. try
  734. {
  735. BaseElectricEqpmt* pUnit = nullptr;
  736. //ElectricEqpmt_Line* pLine=new ElectricEqpmt_Line;
  737. nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1));
  738. nSubEqpmtType = query_result->GetFieldValue("SubEqpmtType", int(-1));
  739. if (nEqpmtType == OCC_EQPMTTYPE_110kVACMLine) //110kV母线
  740. {
  741. CElectricEqpmt_Line_110kV_BusLine* pLine = new CElectricEqpmt_Line_110kV_BusLine;
  742. pUnit = pLine;
  743. }
  744. else if (nEqpmtType == OCC_EQPMTTYPE_110kvPowerLine) //110kV输电线
  745. {
  746. if (nSubEqpmtType == Electric_PowerLine_Input) //进线
  747. {
  748. CElectricEqpmt_Line_110kV_PowerLine_Input* pLine = new CElectricEqpmt_Line_110kV_PowerLine_Input;
  749. pUnit = pLine;
  750. pUnit->SetSubTypeName("进线");
  751. }
  752. else
  753. {
  754. CElectricEqpmt_Line_110kV_PowerLine* pLine = new CElectricEqpmt_Line_110kV_PowerLine;
  755. pUnit = pLine;
  756. pUnit->SetSubTypeName("输电线");
  757. }
  758. }
  759. else if (nEqpmtType == OCC_EQPMTTYPE_35kVMOTHERLINE) //35kv母线
  760. {
  761. CElectricEqpmt_Line_35kV_BusLine* pLine = new CElectricEqpmt_Line_35kV_BusLine;
  762. pUnit = pLine;
  763. }
  764. else if (nEqpmtType == OCC_EQPMTTYPE_35kvACPowerLine) //35kv输电线
  765. {
  766. if (nSubEqpmtType == Electric_PowerLine_Input)
  767. {
  768. CElectricEqpmt_Line_35kV_PowerLine_Input* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Input;
  769. pUnit = pLine;
  770. pUnit->SetSubTypeName("进线");
  771. }
  772. else if (nSubEqpmtType == Electric_PowerLine_Output)
  773. {
  774. CElectricEqpmt_Line_35kV_PowerLine_Output* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Output;
  775. pUnit = pLine;
  776. pUnit->SetSubTypeName("出线");
  777. }
  778. else if (nSubEqpmtType == Electric_PowerLine_Feeder)
  779. {
  780. CElectricEqpmt_Line_35kV_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Feeder;
  781. pUnit = pLine;
  782. pUnit->SetSubTypeName("馈线");
  783. }
  784. else
  785. {
  786. ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line;
  787. pUnit = pLine;
  788. pUnit->SetSubTypeName("输电线");
  789. }
  790. }
  791. else if (nEqpmtType == OCC_EQPMTTYPE_400vACMLine) //400V母线
  792. {
  793. CElectricEqpmt_Line_400V_BusLine* pLine = new CElectricEqpmt_Line_400V_BusLine;
  794. pUnit = pLine;
  795. }
  796. else if (nEqpmtType == OCC_EQPMTTYPE_400vACPowerLine) //400v输电线
  797. {
  798. if (nSubEqpmtType == Electric_PowerLine_Input)
  799. {
  800. CElectricEqpmt_Line_400V_PowerLine_Input* pLine = new CElectricEqpmt_Line_400V_PowerLine_Input;
  801. pUnit = pLine;
  802. pUnit->SetSubTypeName("进线");
  803. }
  804. else if (nSubEqpmtType == Electric_PowerLine_Feeder)
  805. {
  806. CElectricEqpmt_Line_400V_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_400V_PowerLine_Feeder;
  807. pUnit = pLine;
  808. pUnit->SetSubTypeName("馈线");
  809. }
  810. else
  811. {
  812. ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line;
  813. pUnit = pLine;
  814. pUnit->SetSubTypeName("输电线");
  815. }
  816. }
  817. else if (nEqpmtType == OCC_EQPMTTYPE_1500vDCMLine) //直流正级母线
  818. {
  819. CElectricEqpmt_Line_DC_Positive_BusLine* pLine = new CElectricEqpmt_Line_DC_Positive_BusLine;
  820. pUnit = pLine;
  821. }
  822. else if (nEqpmtType == OCC_EQPMTTYPE_1500VNegativeBusLine) //直流负极母线
  823. {
  824. CElectricEqpmt_Line_DC_Negative_BusLine* pLine = new CElectricEqpmt_Line_DC_Negative_BusLine;
  825. pUnit = pLine;
  826. }
  827. else if (nEqpmtType == OCC_EQPMTTYPE_TouchNet) //接触网/轨
  828. {
  829. CElectricEqpmt_Line_TouchNet* pLine = new CElectricEqpmt_Line_TouchNet;
  830. pUnit = pLine;
  831. }
  832. else if (nEqpmtType == OCC_EQPMTTYPE_Track) //回流轨
  833. {
  834. CElectricEqpmt_Line_Track* pLine = new CElectricEqpmt_Line_Track;
  835. pUnit = pLine;
  836. }
  837. else if (nEqpmtType == OCC_EQPMTTYPE_DCPowerLine) //直流输电线
  838. {
  839. if (nSubEqpmtType == Electric_PowerLine_Input)
  840. {
  841. CElectricEqpmt_Line_DC_PowerLine_Input* pLine = new CElectricEqpmt_Line_DC_PowerLine_Input;
  842. pUnit = pLine;
  843. pUnit->SetSubTypeName("进线");
  844. }
  845. else if (nSubEqpmtType == Electric_PowerLine_Feeder)
  846. {
  847. CElectricEqpmt_Line_DC_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_DC_PowerLine_Feeder;
  848. pUnit = pLine;
  849. pUnit->SetSubTypeName("馈线");
  850. }
  851. else
  852. {
  853. ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line;
  854. pUnit = pLine;
  855. pUnit->SetSubTypeName("输电线");
  856. }
  857. }
  858. else if (nEqpmtType == OCC_EQPMTTYPE_DC_ReturnLine) //回流线
  859. {
  860. CElectricEqpmt_Line_DC_ReturnLine* pLine = new CElectricEqpmt_Line_DC_ReturnLine;
  861. pUnit = pLine;
  862. }
  863. else if (nEqpmtType == OCC_EQPMTTYPE_TouchNet)
  864. {
  865. CElectricEqpmt_Line_TouchNet* pLine = new CElectricEqpmt_Line_TouchNet;
  866. pUnit = pLine;
  867. }
  868. else
  869. {
  870. ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line;
  871. pUnit = pLine;
  872. }
  873. strEqpmtID = query_result->GetFieldValue("StrID", std::string(""));
  874. pUnit->SetEqpmentID(strEqpmtID);
  875. if (pUnit != nullptr)
  876. {
  877. pUnit->SetBaseTypeName(query_result->GetFieldValue("StrName", std::string("")));
  878. pUnit->SetStatus(query_result->GetFieldValue("Status", int(-1)));
  879. pUnit->SetEqmpInitStatus(query_result->GetFieldValue("Status", int(-1)));
  880. if (pUnit->GetStatus() == Electric_Eqpmt_Status_ON)
  881. {
  882. pUnit->SetPower(true);
  883. }
  884. else if (pUnit->GetStatus() == Electric_Eqpmt_Status_OFF)
  885. {
  886. pUnit->SetPower(false);
  887. }
  888. pUnit->SetStationID(query_result->GetFieldValue("StationID", int(-1)));
  889. pUnit->SetViewID(query_result->GetFieldValue("ViewID", int(-1)));
  890. pUnit->SetBaseType(query_result->GetFieldValue("EqpmtType", int(-1)));
  891. pUnit->SetEqpmentName(query_result->GetFieldValue("Name", std::string("")));
  892. pUnit->SetSourceStationID(query_result->GetFieldValue("SourceStation", int(-1)));
  893. pUnit->SetControlType(query_result->GetFieldValue("CtrlType", int(-1)));
  894. //添加保护设备
  895. if (pUnit->GetStationID() == 0 && (pUnit->GetViewID() == m_nMainViewID_35kV || pUnit->GetViewID() == m_nMainViewID_1500V || pUnit->GetViewID() == m_nMainViewID_400V))
  896. {
  897. for (iterProtect = m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID); iterProtect != m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID); iterProtect++)
  898. {
  899. pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID);
  900. }
  901. }
  902. //添加联控设备
  903. for (iterCtrlUnion = m_EqpmtCtrlUnionMap.lower_bound(strEqpmtID); iterCtrlUnion != m_EqpmtCtrlUnionMap.upper_bound(strEqpmtID); iterCtrlUnion++)
  904. {
  905. pUnit->AddCtrlUnoin(iterCtrlUnion->second.m_OpeStatus, iterCtrlUnion->second.m_PreEqpmtID, iterCtrlUnion->second.m_PreStatus,
  906. iterCtrlUnion->second.m_Relation, iterCtrlUnion->second.m_DelayTime, iterCtrlUnion->second.m_Index);
  907. }
  908. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  909. }
  910. }
  911. catch (const std::exception&)
  912. {
  913. return false;
  914. }
  915. }
  916. }
  917. return true;
  918. }
  919. bool ElectricDataBaseManger::GetEqpmtsPicUnitFromDB( ELEEQPMTMAP* ElectricEqpmtMap )
  920. {
  921. string strEqpmtID;
  922. string strkey;
  923. ProtectValueMap::iterator iterProtectValue;
  924. AutoActUnionMAP::iterator iterAutoActUnion;
  925. InPutRelationDataMAP::iterator iterHanderRela;
  926. EqpmtCtrlAreaRelationMAP::iterator iterEqpmCtrlAreaRela;
  927. ProtectEqpmtRelationMAP::iterator iterProtect;
  928. EqpmtCtrlUnionMAP::iterator iterCtrlUnion;
  929. std::stringstream ss;
  930. if (m_nLineID == 300)
  931. {
  932. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_BaseGraphInfo.Type = " << OCC_GRAPHUNIT_TYPE_PIC
  933. << " and Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID";
  934. }
  935. else if (m_nLineID == 200)
  936. {
  937. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID
  938. << " and Table_BaseGraphInfo.type=500 and 2000000 > Table_BaseGraphInfo.ID";//昆明项目特殊处理 add by chenht
  939. }
  940. else
  941. {
  942. ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID
  943. << " and Table_BaseGraphInfo.type = 500 and " << m_nEqpmtStartID << " < Table_BaseGraphInfo.ID and Table_EqpmtBaseInfo.ViewID in(" << m_strDataAssociationView << ")";
  944. }
  945. std::string strSql = ss.str();
  946. std::shared_ptr<iDBReadSet> query_result = { 0 };
  947. query_result = m_pDataBase->DirectQuery(strSql);
  948. if (query_result) {
  949. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  950. {
  951. try
  952. {
  953. BaseElectricEqpmt* pUnit = nullptr;
  954. strEqpmtID = query_result->GetFieldValue("StrID", std::string(""));
  955. int type = query_result->GetFieldValue("EqpmtType", int(-1)); //设备类型即各图元的ID
  956. int subtype = query_result->GetFieldValue("SubEqpmtType", int(-1)); //设备子类型
  957. if (type == OCC_EQPMTTYPE_35kVLineInOutlet || type == OCC_EQPMTTYPE_400VLineInOutlet || type == OCC_EQPMTTYPE_110kVLineInOutlet ||
  958. type == OCC_EQPMTTYPE_1500VNegativeBusLine || type == OCC_EQPMTTYPE_DC_ReturnLine)
  959. {
  960. ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line;
  961. pUnit = pLine;
  962. pUnit->SetEqpmentID(strEqpmtID);
  963. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  964. {
  965. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  966. }
  967. } //Noted by zhangjiahua on 2019.4.9
  968. ElectricEqpmt_Breaker* pBaseBreak = nullptr;
  969. if (type == OCC_EQPMTTYPE_110kVBreaker) //110kv断路器
  970. {
  971. if (subtype == Electric_Breaker_Input)
  972. {
  973. CElectricEqpmt_Breaker_110kV_Input* pBreak = new CElectricEqpmt_Breaker_110kV_Input;
  974. pBaseBreak = pBreak;
  975. }
  976. else if (subtype == Electric_Breaker_Circuit)
  977. {
  978. CElectricEqpmt_Breaker_110kV_Circuit* pBreak = new CElectricEqpmt_Breaker_110kV_Circuit;
  979. pBaseBreak = pBreak;
  980. }
  981. else
  982. {
  983. pBaseBreak = new ElectricEqpmt_Breaker;
  984. }
  985. pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  986. }
  987. //add by dengt 27.5kv增加故障保护
  988. if (type == OCC_EQPMTTYPE_27_5kVBREAKER) //27.5kv断路器
  989. {
  990. pBaseBreak = new ElectricEqpmt_Breaker;
  991. pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  992. }
  993. else if (type == OCC_EQPMTTYPE_35kVBREAKER) //35kv断路器
  994. {
  995. if (subtype == Electric_Breaker_Input)
  996. {
  997. CElectricEqpmt_Breaker_35kV_Input* pBreak = new CElectricEqpmt_Breaker_35kV_Input;
  998. pBaseBreak = pBreak;
  999. }
  1000. else if (subtype == Electric_Breaker_Output)
  1001. {
  1002. CElectricEqpmt_Breaker_35kV_Output* pBreak = new CElectricEqpmt_Breaker_35kV_Output;
  1003. pBaseBreak = pBreak;
  1004. }
  1005. else if (subtype == Electric_Breaker_Feeder)
  1006. {
  1007. CElectricEqpmt_Breaker_35kV_Feeder* pBreak = new CElectricEqpmt_Breaker_35kV_Feeder;
  1008. pBaseBreak = pBreak;
  1009. }
  1010. else if (subtype == Electric_Breaker_Circuit)
  1011. {
  1012. CElectricEqpmt_Breaker_35kV_Circuit* pBreak = new CElectricEqpmt_Breaker_35kV_Circuit;
  1013. pBaseBreak = pBreak;
  1014. }
  1015. else
  1016. {
  1017. pBaseBreak = new ElectricEqpmt_Breaker;
  1018. }
  1019. pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  1020. }
  1021. else if (type == OCC_EQPMTTYPE_400vACControlBreaker) //400V断路器
  1022. {
  1023. if (subtype == Electric_Breaker_Input)
  1024. {
  1025. CElectricEqpmt_Breaker_400V_Input* pBreak = new CElectricEqpmt_Breaker_400V_Input;
  1026. pBaseBreak = pBreak;
  1027. }
  1028. else if (subtype == Electric_Breaker_Feeder)
  1029. {
  1030. CElectricEqpmt_Breaker_400V_Feeder* pBreak = new CElectricEqpmt_Breaker_400V_Feeder;
  1031. pBaseBreak = pBreak;
  1032. }
  1033. else if (subtype == Electric_Breaker_Circuit)
  1034. {
  1035. CElectricEqpmt_Breaker_400V_Circuit* pBreak = new CElectricEqpmt_Breaker_400V_Circuit;
  1036. pBaseBreak = pBreak;
  1037. }
  1038. else
  1039. {
  1040. pBaseBreak = new ElectricEqpmt_Breaker;
  1041. }
  1042. pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  1043. }
  1044. else if (type == OCC_EQPMTTYPE_BREAKER_DC)
  1045. {
  1046. if (subtype == Electric_Breaker_Input)
  1047. {
  1048. CElectricEqpmt_Breaker_DC_Input* pBreak = new CElectricEqpmt_Breaker_DC_Input;
  1049. pBaseBreak = pBreak;
  1050. }
  1051. else if (subtype == Electric_Breaker_Feeder)
  1052. {
  1053. CElectricEqpmt_Breaker_DC_Feeder* pBreak = new CElectricEqpmt_Breaker_DC_Feeder;
  1054. pBaseBreak = pBreak;
  1055. }
  1056. else
  1057. {
  1058. CElectricEqpmt_Breaker_DC* pBreak = new CElectricEqpmt_Breaker_DC;
  1059. pBaseBreak = pBreak;
  1060. }
  1061. //pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  1062. }
  1063. if (pBaseBreak != nullptr)
  1064. {
  1065. pBaseBreak->SetEqpmentID(strEqpmtID);
  1066. //if (atoi((LPCSTR)(_bstr_t)r_set->GetCollect("StationID"))==0) //花溪没有假线,不做车站限制 ---delete by dt 20250208
  1067. {
  1068. for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++)
  1069. {
  1070. pBaseBreak->AddProtectRelation(iterProtectValue->second);
  1071. }
  1072. for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++)
  1073. {
  1074. pBaseBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式
  1075. }
  1076. }
  1077. iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID);
  1078. if (iterHanderRela != m_HanderRelationDataMap.end())
  1079. {
  1080. pBaseBreak->SetBreakHandID(iterHanderRela->second.m_InputEqpmtStrID);
  1081. }
  1082. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1083. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1084. {
  1085. pBaseBreak->SetControlArea(iterEqpmCtrlAreaRela->second);
  1086. }
  1087. if (UpdateEqpmtBaseInfo(query_result, pBaseBreak))
  1088. {
  1089. ElectricEqpmtMap->insert(make_pair(pBaseBreak->GetEqpmentID(), pBaseBreak));
  1090. }
  1091. }
  1092. else if (type == OCC_EQPMTTYPE_MainLineElement) //主所线路元件
  1093. {
  1094. CElectricEqpmt_SwicthEqpmt* pswitch = new CElectricEqpmt_SwicthEqpmt;
  1095. pUnit = pswitch;
  1096. pUnit->SetEqpmentID(strEqpmtID);
  1097. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1098. {
  1099. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1100. }
  1101. }
  1102. else if (type == OCC_EQPMTTYPE_PowerTransformer) //动力变压器
  1103. {
  1104. //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer;
  1105. //modified by zhangjiahua on 2019.4.9
  1106. CElectricEqpmt_Transformer_Power* pTransfrom = new CElectricEqpmt_Transformer_Power;
  1107. pUnit = pTransfrom;
  1108. pUnit->SetEqpmentID(strEqpmtID);
  1109. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1110. {
  1111. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1112. }
  1113. }
  1114. else if (type == OCC_EQPMTTYPE_MainTransformer) //主变压器
  1115. {
  1116. //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer;
  1117. //modified by zhangjiahua on 2019.4.9
  1118. CElectricEqpmt_Transformer_Main* pTransfrom = new CElectricEqpmt_Transformer_Main;
  1119. pUnit = pTransfrom;
  1120. pUnit->SetEqpmentID(strEqpmtID);
  1121. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1122. {
  1123. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1124. }
  1125. }
  1126. else if (type == OCC_EQPMTTYPE_TractionTransformer) //牵引变压器
  1127. {
  1128. //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer;
  1129. //modified by zhangjiahua on 2019.4.9
  1130. CElectricEqpmt_Transformer_Traction* pTransfrom = new CElectricEqpmt_Transformer_Traction;
  1131. pUnit = pTransfrom;
  1132. pUnit->SetEqpmentID(strEqpmtID);
  1133. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1134. {
  1135. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1136. }
  1137. }
  1138. else if (type == OCC_EQPMTTYPE_ThreePositong_ELCSWICTH || type == OCC_EQPMTTYPE_110kVSwitch) //三工位隔离开关
  1139. {
  1140. CElectricEqpmt_IsolatingSwitch_ThreePosition* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_ThreePosition;
  1141. pUnit = pIsolatingSwitch;
  1142. pUnit->SetEqpmentID(strEqpmtID);
  1143. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1144. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1145. {
  1146. pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second);
  1147. }
  1148. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1149. {
  1150. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1151. }
  1152. }
  1153. else if (type == OCC_EQPMTTYPE_Power_ELCSWICTH || type == OCC_EQPMTTYPE_27_5kVSwitch) //电动隔离开关
  1154. {
  1155. CElectricEqpmt_IsolatingSwitch_Power* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_Power;
  1156. pUnit = pIsolatingSwitch;
  1157. pUnit->SetEqpmentID(strEqpmtID);
  1158. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1159. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1160. {
  1161. pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second);
  1162. }
  1163. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1164. {
  1165. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1166. }
  1167. }
  1168. else if (type == OCC_EQPMTTYPE_Mannual_ELCSWICTH) //手动隔离开关
  1169. {
  1170. CElectricEqpmt_IsolatingSwitch_Manual* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_Manual;
  1171. pUnit = pIsolatingSwitch;
  1172. pUnit->SetEqpmentID(strEqpmtID);
  1173. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1174. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1175. {
  1176. pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second);
  1177. }
  1178. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1179. {
  1180. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1181. }
  1182. }
  1183. else if (type == OCC_EQPMTTYPE_400vACControlBreaker) //400V断路器
  1184. {
  1185. ElectricEqpmt_Breaker* pBreak = new ElectricEqpmt_Breaker;
  1186. pUnit = pBreak;
  1187. pUnit->SetEqpmentID(strEqpmtID);
  1188. //if (atoi((LPCSTR)(_bstr_t)r_set->GetCollect("StationID"))==0) //张家华
  1189. {
  1190. //add 400断路器保护信息//20230131
  1191. for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++)
  1192. {
  1193. pBreak->AddProtectRelation(iterProtectValue->second);
  1194. }
  1195. for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++)
  1196. {
  1197. pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式
  1198. }
  1199. }
  1200. pBreak->SetEqpmentType(Electric_EqpmentType_Breaker);
  1201. iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID);
  1202. if (iterHanderRela != m_HanderRelationDataMap.end())
  1203. {
  1204. pBreak->SetBreakHandID(iterHanderRela->second.m_StrID);
  1205. }
  1206. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1207. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1208. {
  1209. pBreak->SetControlArea(iterEqpmCtrlAreaRela->second);
  1210. }
  1211. if (UpdateEqpmtBaseInfo(query_result, pBreak))
  1212. {
  1213. ElectricEqpmtMap->insert(make_pair(pBreak->GetEqpmentID(), pBreak));
  1214. }
  1215. }
  1216. else if (type == OCC_EQPMTTYPE_400vACUncontrolBreaker) //400V不可控断路器
  1217. {
  1218. ElectricEqpmt_Breaker* pBreak = new ElectricEqpmt_Breaker;
  1219. pUnit = pBreak;
  1220. pUnit->SetEqpmentID(strEqpmtID);
  1221. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1222. {
  1223. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1224. }
  1225. }
  1226. else if (type == OCC_EQPMTTYPE_AUTOBOLT_110KV) //110kv备自投
  1227. {
  1228. CElectricEqpmt_PowerBolt_110kV* pbolt = new CElectricEqpmt_PowerBolt_110kV;
  1229. pUnit = pbolt;
  1230. pUnit->SetEqpmentID(strEqpmtID);
  1231. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1232. {
  1233. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1234. }
  1235. }
  1236. else if (type == OCC_EQPMTTYPE_AUTOBOLT)
  1237. {
  1238. if (subtype == Electric_AutoBolt_35kV)
  1239. {
  1240. CElectricEqpmt_PowerBolt_35kV* pbolt = new CElectricEqpmt_PowerBolt_35kV;
  1241. pUnit = pbolt;
  1242. }
  1243. else if (subtype == Electric_AutoBolt_110kV)
  1244. {
  1245. CElectricEqpmt_PowerBolt_110kV* pbolt = new CElectricEqpmt_PowerBolt_110kV;
  1246. pUnit = pbolt;
  1247. }
  1248. else if (subtype == Electric_AutoBolt_400V)
  1249. {
  1250. CElectricEqpmt_PowerBolt_400V* pbolt = new CElectricEqpmt_PowerBolt_400V;
  1251. pUnit = pbolt;
  1252. }
  1253. else
  1254. {
  1255. ElectricEqpmt_PowerBolt* pbolt = new ElectricEqpmt_PowerBolt;
  1256. pUnit = pbolt;
  1257. }
  1258. if (pUnit != nullptr)
  1259. {
  1260. pUnit->SetEqpmentID(strEqpmtID);
  1261. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1262. {
  1263. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1264. }
  1265. }
  1266. }
  1267. else if (type == OCC_EQPMTTYPE_BREAKER_DC) //1500V断路器
  1268. {
  1269. //ElectricEqpmt_Breaker* pBreak=new ElectricEqpmt_Breaker;
  1270. CElectricEqpmt_Breaker_DC* pBreak = new CElectricEqpmt_Breaker_DC;
  1271. pUnit = pBreak;
  1272. pUnit->SetEqpmentID(strEqpmtID);
  1273. for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++)
  1274. {
  1275. pBreak->AddProtectRelation(iterProtectValue->second);
  1276. }
  1277. for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++)
  1278. {
  1279. pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式
  1280. }
  1281. iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID);
  1282. if (iterHanderRela != m_HanderRelationDataMap.end())
  1283. {
  1284. pBreak->SetBreakHandID(iterHanderRela->second.m_StrID);
  1285. }
  1286. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1287. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1288. {
  1289. pBreak->SetControlArea(iterEqpmCtrlAreaRela->second);
  1290. }
  1291. if (UpdateEqpmtBaseInfo(query_result, pBreak))
  1292. {
  1293. ElectricEqpmtMap->insert(make_pair(pBreak->GetEqpmentID(), pBreak));
  1294. }
  1295. }
  1296. else if (type == OCC_EQPMTTYPE_1500vRectifier) //整流器
  1297. {
  1298. ElectricEqpmt_Rectifier* pRectfier = new ElectricEqpmt_Rectifier;
  1299. pUnit = pRectfier;
  1300. pUnit->SetEqpmentID(strEqpmtID);
  1301. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1302. {
  1303. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1304. }
  1305. }
  1306. else if (type == OCC_EQPMTTYPE_Power_ELCSWICTH || type == OCC_EQPMTTYPE_27_5kVSwitch/*|| type == OCC_EQPMTTYPE_1500vMannualIsolationSwitch*/) //1500v电动隔离开关
  1307. {
  1308. CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt;
  1309. pUnit = pSwicthEqpmt;
  1310. pUnit->SetEqpmentID(strEqpmtID);
  1311. //AddCtrlType(pSwicthEqpmt);
  1312. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1313. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1314. {
  1315. pSwicthEqpmt->SetControlArea(iterEqpmCtrlAreaRela->second);
  1316. }
  1317. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1318. {
  1319. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1320. }
  1321. }
  1322. else if (OCC_EQPMTTYPE_EarthBrake == type || OCC_EQPMTTYPE_GroundDevice == type)
  1323. {
  1324. ElectricEqpmt_EarthSwitch* pEarthBrake = new ElectricEqpmt_EarthSwitch;
  1325. pUnit = pEarthBrake;
  1326. pUnit->SetEqpmentID(strEqpmtID);
  1327. //AddCtrlType(pEarthBrake);
  1328. iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID);
  1329. if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end())
  1330. {
  1331. pEarthBrake->SetControlArea(iterEqpmCtrlAreaRela->second);
  1332. }
  1333. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1334. {
  1335. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1336. }
  1337. }
  1338. else if (type == OCC_EQPMTTYPE_BREAKER_HANDER) //手车
  1339. {
  1340. ElectricEqpmt_BreakHand* pHandr = new ElectricEqpmt_BreakHand;
  1341. pUnit = pHandr;
  1342. pUnit->SetEqpmentID(strEqpmtID);
  1343. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1344. {
  1345. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1346. }
  1347. }
  1348. else if (type == OCC_EQPMTTYPE_Potential_Transformer) //// 母线电压互感器
  1349. {
  1350. ElectricEqpmt_Transformer* pLine = new ElectricEqpmt_Transformer;
  1351. pUnit = pLine;
  1352. pUnit->SetEqpmentID(strEqpmtID);
  1353. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1354. {
  1355. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1356. }
  1357. }
  1358. else if (type == OCC_EQPMTTYPE_SettingGroup) //// 整定值组
  1359. {
  1360. ElectricEqpmt_SettingGroup* pSettingGroup = new ElectricEqpmt_SettingGroup;
  1361. pUnit = pSettingGroup;
  1362. pUnit->SetEqpmentID(strEqpmtID);
  1363. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1364. {
  1365. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1366. }
  1367. }
  1368. else if (type == OCC_EQPMTTYPE_StationThreeLoadCut)
  1369. {
  1370. ElectricEqpmt_StationThreeLoadCut* pStationThreeLoadCut = new ElectricEqpmt_StationThreeLoadCut;
  1371. pUnit = pStationThreeLoadCut;
  1372. pUnit->SetEqpmentID(strEqpmtID);
  1373. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1374. {
  1375. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1376. }
  1377. }
  1378. else if (type == OCC_EQPMTTYPE_StationControlPermission)
  1379. {
  1380. CElectricEqpmt_ControlPermission* pControlPermission = new CElectricEqpmt_ControlPermission;
  1381. pUnit = pControlPermission;
  1382. pUnit->SetEqpmentID(strEqpmtID);
  1383. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1384. {
  1385. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1386. }
  1387. }
  1388. else if (type == OCC_EQPMTTYPE_BreakRailPotential) //轨电位
  1389. {
  1390. ElectricEqpmt_BreakRailPotential* pBreak = new ElectricEqpmt_BreakRailPotential;
  1391. pUnit = pBreak;
  1392. pUnit->SetEqpmentID(strEqpmtID);
  1393. for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++)
  1394. {
  1395. pBreak->AddProtectRelation(iterProtectValue->second);
  1396. }
  1397. for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++)
  1398. {
  1399. pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式
  1400. }
  1401. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1402. {
  1403. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1404. }
  1405. }
  1406. else if (type == OCC_EQPMTTYPE_AutoBoltSoftPlate) //备自投软压板
  1407. {
  1408. CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt;
  1409. pUnit = pSwicthEqpmt;
  1410. pUnit->SetEqpmentID(strEqpmtID);
  1411. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1412. {
  1413. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1414. }
  1415. }
  1416. else if (type == OCC_EQPMTTYPE_ReclosingSoftPlate) //重合闸软压板
  1417. {
  1418. CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt;
  1419. pUnit = pSwicthEqpmt;
  1420. pUnit->SetEqpmentID(strEqpmtID);
  1421. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1422. {
  1423. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1424. }
  1425. }
  1426. else
  1427. {
  1428. //mod by yangs 没有对应类的设备暂时用基础类代替
  1429. pUnit = new BaseElectricEqpmt;
  1430. pUnit->SetEqpmentID(strEqpmtID);
  1431. if (UpdateEqpmtBaseInfo(query_result, pUnit))
  1432. {
  1433. ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit));
  1434. }
  1435. }
  1436. }
  1437. catch (...)
  1438. {
  1439. return false;
  1440. }
  1441. }
  1442. }
  1443. return true;
  1444. }
  1445. bool ElectricDataBaseManger::GetEqpmtsProtects()
  1446. {
  1447. string strSql = "Select Table_ProtectRelation.*,Table_ProtectValue.*,Table_FaultInfo.* "
  1448. "from Table_ProtectRelation,Table_ProtectValue,Table_FaultInfo "
  1449. "where Table_ProtectRelation.ProtectID=Table_ProtectValue.ID and Table_FaultInfo.protectno = Table_ProtectRelation.ProtectID";
  1450. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1451. query_result = m_pDataBase->DirectQuery(strSql);
  1452. if (query_result) {
  1453. string eqpmtid;
  1454. ProtectValue protect;
  1455. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1456. {
  1457. try
  1458. {
  1459. eqpmtid = query_result->GetFieldValue("EqpmtID", std::string(""));
  1460. protect.pretectid = query_result->GetFieldValue("ProtectID", int(-1));
  1461. protect.faultid = query_result->GetFieldValue("faultno", int(-1));
  1462. protect.faulttype = query_result->GetFieldValue("type", int(-1));
  1463. protect.PRI = query_result->GetFieldValue("PRI", int(-1));
  1464. protect.delaytime = query_result->GetFieldValue("DelayTime", int(-1));
  1465. protect.kind = query_result->GetFieldValue("Kind", int(-1));
  1466. protect.strname = query_result->GetFieldValue("StrName", std::string(""));
  1467. protect.status = query_result->GetFieldValue("Status", int(-1));
  1468. protect.strfaultname = query_result->GetFieldValue("faultname", std::string(""));
  1469. protect.breakerRejection = query_result->GetFieldValue("BreakerRejection", int(-1));
  1470. protect.protectDisplayContent = query_result->GetFieldValue("ProtectDisplayContent", std::string(""));
  1471. protect.trippingDisplayContent = query_result->GetFieldValue("TrippingDisplayContent", std::string(""));
  1472. protect.trippingRepeatShut = query_result->GetFieldValue("TrippingRepeatShut", int(-1));
  1473. protect.nPermanentFault = query_result->GetFieldValue("PermanentFault", int(-1));
  1474. m_ProtectValueMap.insert(make_pair(eqpmtid, protect));
  1475. }
  1476. catch (...)
  1477. {
  1478. return false;
  1479. }
  1480. }
  1481. }
  1482. return true;
  1483. }
  1484. bool ElectricDataBaseManger::GetEqpmtsActUnions()
  1485. {
  1486. string strSql = "Select * from Table_AutoActUnion order by SEqpmtID";
  1487. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1488. query_result = m_pDataBase->DirectQuery(strSql);
  1489. if (query_result) {
  1490. string strkey = "";
  1491. string preStrtemp = "";
  1492. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1493. {
  1494. try
  1495. {
  1496. AutoActUnion autoactunion;
  1497. autoactunion.m_SEqpmtID = query_result->GetFieldValue("SEqpmtID", std::string(""));
  1498. autoactunion.m_Sstatus = query_result->GetFieldValue("Sstatus", int(-1));
  1499. autoactunion.m_Dstatus = query_result->GetFieldValue("Dstatus", int(-1));
  1500. autoactunion.m_DEqpmtID = query_result->GetFieldValue("DEqpmtID", std::string(""));
  1501. autoactunion.m_EventID = query_result->GetFieldValue("EventID", int(-1));
  1502. preStrtemp = autoactunion.m_SEqpmtID;
  1503. m_AutoActUnionMap.insert(make_pair(preStrtemp, autoactunion));
  1504. }
  1505. catch (...)
  1506. {
  1507. return false;
  1508. }
  1509. }
  1510. }
  1511. return true;
  1512. }
  1513. bool ElectricDataBaseManger::GetEqpmtsHander()
  1514. {
  1515. std::stringstream ss;
  1516. ss << "Select * from Table_InPutRelation where Relation = " << EQPMT_RELATIONTYPE_BREAKHANDER;
  1517. std::string strSql = ss.str();
  1518. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1519. query_result = m_pDataBase->DirectQuery(strSql);
  1520. if (query_result) {
  1521. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1522. {
  1523. try
  1524. {
  1525. InPutRelationData inputrelationdata;
  1526. inputrelationdata.m_StrID = query_result->GetFieldValue("StrID", std::string(""));
  1527. inputrelationdata.m_InputEqpmtStrID = query_result->GetFieldValue("InputEqpmtStrID", std::string(""));
  1528. inputrelationdata.m_RunLineID = query_result->GetFieldValue("RunLineID", int(-1));
  1529. inputrelationdata.m_Relation = query_result->GetFieldValue("Relation", int(-1));
  1530. m_HanderRelationDataMap.insert(make_pair(inputrelationdata.m_StrID, inputrelationdata));
  1531. }
  1532. catch (...)
  1533. {
  1534. return false;
  1535. }
  1536. }
  1537. }
  1538. return true;
  1539. }
  1540. bool ElectricDataBaseManger::GetEqpmtsCtrlType() //待优化、可以直接存储到图片设备中
  1541. {
  1542. std::string strSql = "Select * from Table_EqpmtCtrlArea";
  1543. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1544. query_result = m_pDataBase->DirectQuery(strSql);
  1545. if (query_result) {
  1546. std::string EqpmtStrID = "";
  1547. int nCtrlArea = -1;
  1548. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1549. {
  1550. try
  1551. {
  1552. EqpmtStrID = query_result->GetFieldValue("EqpmtStrID", std::string(""));
  1553. nCtrlArea = query_result->GetFieldValue("CtrlArea", int(-1));
  1554. m_EqpmtCtrlAreaRelationMap.insert(make_pair(EqpmtStrID, nCtrlArea));
  1555. }
  1556. catch (...)
  1557. {
  1558. return false;
  1559. }
  1560. }
  1561. }
  1562. return true;
  1563. }
  1564. bool ElectricDataBaseManger::GetEqpmtsProtectEqpmts()
  1565. {
  1566. std::string strSql = "Select * from Table_ProtectEqpmt";
  1567. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1568. query_result = m_pDataBase->DirectQuery(strSql);
  1569. if (query_result) {
  1570. ProtectCtrl protectCtrl;
  1571. std::string EqpmtStrID = "";
  1572. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1573. {
  1574. try
  1575. {
  1576. protectCtrl.ProtectStrID = query_result->GetFieldValue("ProtectID", std::string(""));
  1577. protectCtrl.EventID = query_result->GetFieldValue("EventID", int(-1));
  1578. EqpmtStrID = query_result->GetFieldValue("EqpmtID", std::string(""));
  1579. m_ProtectEqpmtRelationMap.insert(make_pair(EqpmtStrID, protectCtrl));
  1580. }
  1581. catch (...)
  1582. {
  1583. return false;
  1584. }
  1585. }
  1586. }
  1587. return true;
  1588. }
  1589. bool ElectricDataBaseManger::GetEqpmtsCtrlUnions()
  1590. {
  1591. std::string strSql = "Select * from Table_EqpmtCtrlUnion order by OperEqpmtID";
  1592. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1593. query_result = m_pDataBase->DirectQuery(strSql);
  1594. if (query_result) {
  1595. string strkey;
  1596. string preStrtemp = "";
  1597. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1598. {
  1599. try
  1600. {
  1601. EqpmtCtrlUnion eqpmtctrlunion;
  1602. eqpmtctrlunion.m_OperEqpmtID = query_result->GetFieldValue("OperEqpmtID", std::string(""));
  1603. eqpmtctrlunion.m_PreEqpmtID = query_result->GetFieldValue("PreEpmtID", std::string(""));
  1604. eqpmtctrlunion.m_OpeStatus = query_result->GetFieldValue("OpeStatus", int(-1));
  1605. eqpmtctrlunion.m_PreStatus = query_result->GetFieldValue("PreStatus", int(-1));
  1606. eqpmtctrlunion.m_DelayTime = query_result->GetFieldValue("DelayTime", int(-1));
  1607. eqpmtctrlunion.m_Relation = query_result->GetFieldValue("Relation", int(-1));
  1608. eqpmtctrlunion.m_Index = query_result->GetFieldValue("IndexNum", int(-1));
  1609. preStrtemp = eqpmtctrlunion.m_OperEqpmtID;
  1610. m_EqpmtCtrlUnionMap.insert(make_pair(eqpmtctrlunion.m_OperEqpmtID, eqpmtctrlunion));
  1611. }
  1612. catch (...)
  1613. {
  1614. return false;
  1615. }
  1616. }
  1617. }
  1618. return true;
  1619. }
  1620. bool ElectricDataBaseManger::InitLogicRelationData()
  1621. {
  1622. if (!GetEqpmtsCtrlUnions())
  1623. {
  1624. return false;
  1625. }
  1626. else if (!GetEqpmtsProtectEqpmts())
  1627. {
  1628. return false;
  1629. }
  1630. else if (!GetEqpmtsCtrlType())
  1631. {
  1632. return false;
  1633. }
  1634. else if (!GetEqpmtsHander())
  1635. {
  1636. return false;
  1637. }
  1638. else if (!GetEqpmtsActUnions())
  1639. {
  1640. return false;
  1641. }
  1642. else if (!GetEqpmtsProtects())
  1643. {
  1644. return false;
  1645. }
  1646. return true;
  1647. }
  1648. bool ElectricDataBaseManger::UpdateEqpmtBaseInfo(std::shared_ptr<iDBReadSet> r_set,BaseElectricEqpmt* pUnit )
  1649. {
  1650. ProtectEqpmtRelationMAP::iterator iterProtect;
  1651. EqpmtCtrlUnionMAP::iterator iterCtrlUnion;
  1652. string strtemp;
  1653. string strkey;
  1654. int num =-1;
  1655. int stationid;
  1656. try
  1657. {
  1658. pUnit->SetBaseTypeName(r_set->GetFieldValue("StrName", std::string("")));
  1659. pUnit->SetStatus(r_set->GetFieldValue("Status", int(-1)));
  1660. pUnit->SetEqmpInitStatus(r_set->GetFieldValue("Status", int(-1)));
  1661. if (pUnit->GetStatus()==Electric_Eqpmt_Status_ON)
  1662. {
  1663. pUnit->SetPower(true);
  1664. }
  1665. else if (pUnit->GetStatus()==Electric_Eqpmt_Status_OFF)
  1666. {
  1667. pUnit->SetPower(false);
  1668. }
  1669. pUnit->SetStationID(r_set->GetFieldValue("StationID", int(-1)));
  1670. pUnit->SetViewID(r_set->GetFieldValue("ViewID", int(-1)));
  1671. pUnit->SetBaseType(r_set->GetFieldValue("EqpmtType", int(-1)));
  1672. pUnit->SetEqpmentName(r_set->GetFieldValue("Name", std::string("")));
  1673. pUnit->SetControlType(r_set->GetFieldValue("CtrlType", int(-1)));
  1674. pUnit->SetSourceStationID(r_set->GetFieldValue("SourceStation", int(-1)));
  1675. string strEqpmtID = r_set->GetFieldValue("StrID", std::string(""));
  1676. for (iterProtect=m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID);iterProtect!=m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID);iterProtect++)
  1677. {
  1678. pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID );
  1679. }
  1680. strtemp = strEqpmtID;
  1681. stationid = r_set->GetFieldValue("StationID", int(-1));
  1682. EqpmtCtrlUnionMAP::iterator CtrilUnion=m_EqpmtCtrlUnionMap.begin();//added by zhangjh on 2017.3.20
  1683. for (iterCtrlUnion=m_EqpmtCtrlUnionMap.lower_bound(strtemp);iterCtrlUnion!=m_EqpmtCtrlUnionMap.upper_bound(strtemp);iterCtrlUnion++)
  1684. {
  1685. pUnit->AddCtrlUnoin(iterCtrlUnion->second.m_OpeStatus,iterCtrlUnion->second.m_PreEqpmtID,iterCtrlUnion->second.m_PreStatus,
  1686. iterCtrlUnion->second.m_Relation,iterCtrlUnion->second.m_DelayTime,iterCtrlUnion->second.m_Index);
  1687. }
  1688. }
  1689. catch (...)
  1690. {
  1691. return false;
  1692. }
  1693. return true;
  1694. }
  1695. bool ElectricDataBaseManger::GetRepeatShutData()
  1696. {
  1697. std::string strSql = "Select * from Table_RepeatShut";
  1698. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1699. query_result = m_pDataBase->DirectQuery(strSql);
  1700. if (query_result) {
  1701. int nEqpmtType = 0;
  1702. int nIndex = 0;
  1703. int nDelayTime = 0;
  1704. int nOneTime = 0;
  1705. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1706. {
  1707. try
  1708. {
  1709. nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1));
  1710. nIndex = query_result->GetFieldValue("Index", int(-1));
  1711. nDelayTime = query_result->GetFieldValue("DelayTime", int(-1));
  1712. nOneTime = query_result->GetFieldValue("OneTime", int(-1));
  1713. ElectricEqpmt_Breaker::AddRepeatShut(nEqpmtType, nIndex, nDelayTime, nOneTime);
  1714. }
  1715. catch (const std::exception&)
  1716. {
  1717. return false;
  1718. }
  1719. }
  1720. }
  1721. return true;
  1722. }
  1723. bool ElectricDataBaseManger::GetErrorToProtectData()
  1724. {
  1725. std::string strSql = "Select * from Table_FaultInfo";
  1726. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1727. query_result = m_pDataBase->DirectQuery(strSql);
  1728. if (query_result) {
  1729. BaseElectricEqpmt::ClearErrorToProtectMAP();
  1730. ErrorToProtectMAP* pMapErrorToProtect = BaseElectricEqpmt::GetErrorToProtectMAP();
  1731. ErrorToProtectMAP::iterator iterErrorToProtect;
  1732. int nProtectID = -1;
  1733. ErrorToProtect errorToProtect;
  1734. int nBreakerRejection = 0;
  1735. bool bSelfLost = false;
  1736. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1737. {
  1738. try
  1739. {
  1740. errorToProtect.nErrorID = query_result->GetFieldValue("faultno", int(-1));
  1741. nBreakerRejection = query_result->GetFieldValue("BreakerRejection", int(-1));
  1742. // BreakerRejection在此范围内,表示故障发生时,故障设备是否跳闸,2表示需要跳闸
  1743. if (2 == nBreakerRejection)
  1744. {
  1745. bSelfLost = true;
  1746. }
  1747. else
  1748. {
  1749. bSelfLost = false;
  1750. }
  1751. nProtectID = query_result->GetFieldValue("protectno", int(-1));
  1752. errorToProtect.nErrorType = query_result->GetFieldValue("type", int(-1));
  1753. iterErrorToProtect = pMapErrorToProtect->find(errorToProtect.nErrorID);
  1754. if (iterErrorToProtect != pMapErrorToProtect->end())
  1755. {
  1756. iterErrorToProtect->second.AddProtectClass(nProtectID);
  1757. if (bSelfLost)
  1758. {
  1759. iterErrorToProtect->second.SelfLost(true);
  1760. }
  1761. else
  1762. {
  1763. iterErrorToProtect->second.SelfLost(false);
  1764. }
  1765. }
  1766. else
  1767. {
  1768. errorToProtect.Clear();
  1769. errorToProtect.strFaultName = query_result->GetFieldValue("faultname", std::string(""));
  1770. errorToProtect.AddProtectClass(nProtectID);
  1771. if (bSelfLost)
  1772. {
  1773. errorToProtect.SelfLost(true);
  1774. }
  1775. else
  1776. {
  1777. errorToProtect.SelfLost(false);
  1778. }
  1779. pMapErrorToProtect->insert(make_pair(errorToProtect.nErrorID, errorToProtect));
  1780. }
  1781. }
  1782. catch (const std::exception&)
  1783. {
  1784. return false;
  1785. }
  1786. }
  1787. }
  1788. return true;
  1789. }
  1790. bool ElectricDataBaseManger::UpdateProtectLockingEqpmt( ELEEQPMTMAP* ElectricEqpmtMap )
  1791. {
  1792. std::string strSql = "Select * from Table_ProtectLockingEqpmt";
  1793. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1794. query_result = m_pDataBase->DirectQuery(strSql);
  1795. if (query_result) {
  1796. string strCurEqpmtStrID;
  1797. string strProtectLockingEqpmtID;
  1798. int nProtectID;
  1799. string strProtectLockingText;
  1800. ELEEQPMTMAP::iterator iterEqpmt;
  1801. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1802. {
  1803. try
  1804. {
  1805. strCurEqpmtStrID = query_result->GetFieldValue("CurEqpmtStrID", std::string(""));
  1806. strProtectLockingEqpmtID = query_result->GetFieldValue("ProtectLockingEqpmtID", std::string(""));
  1807. nProtectID = query_result->GetFieldValue("ProtectID", int(-1));
  1808. strProtectLockingText = query_result->GetFieldValue("LockingText", std::string(""));
  1809. iterEqpmt = ElectricEqpmtMap->find(strCurEqpmtStrID);
  1810. if (iterEqpmt != ElectricEqpmtMap->end())
  1811. {
  1812. iterEqpmt->second->AddProtectLockingEqpmt(strProtectLockingEqpmtID, nProtectID, strProtectLockingText);
  1813. }
  1814. }
  1815. catch (const std::exception&)
  1816. {
  1817. return false;
  1818. }
  1819. }
  1820. }
  1821. return true;
  1822. }
  1823. bool ElectricDataBaseManger::UpdateFaultSceneLockingEqpmt(ELEEQPMTMAP* ElectricEqpmtMap)
  1824. {
  1825. std::string strSql = "Select * from Table_FaultSceneLockingEqpmt";
  1826. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1827. query_result = m_pDataBase->DirectQuery(strSql);
  1828. if (query_result) {
  1829. string strCurEqpmtStrID;
  1830. string strProtectLockingEqpmtID;
  1831. int nProtectID;
  1832. ELEEQPMTMAP::iterator iterEqpmt;
  1833. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1834. {
  1835. try
  1836. {
  1837. strCurEqpmtStrID = query_result->GetFieldValue("CurEqpmtStrID", std::string(""));
  1838. strProtectLockingEqpmtID = query_result->GetFieldValue("ProtectLockingEqpmtID", std::string(""));
  1839. nProtectID = query_result->GetFieldValue("ProtectID", int(-1));
  1840. iterEqpmt = ElectricEqpmtMap->find(strCurEqpmtStrID);
  1841. if (iterEqpmt != ElectricEqpmtMap->end())
  1842. {
  1843. iterEqpmt->second->AddFaultSceneLockingEqpmt(strProtectLockingEqpmtID, nProtectID);
  1844. }
  1845. }
  1846. catch (const std::exception&)
  1847. {
  1848. return false;
  1849. }
  1850. }
  1851. }
  1852. return true;
  1853. }
  1854. bool ElectricDataBaseManger::LoadTelesignalisationData( ElectricEqpmt_TelesignalisationMng& telesignalisationMng, ELEEQPMTMAP* ElectricEqpmtMap)
  1855. {
  1856. std::string strSql = "Select * from Table_TelProtectShow";
  1857. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1858. query_result = m_pDataBase->DirectQuery(strSql);
  1859. if (query_result) {
  1860. ElectricEqpmt_TelProtectShow telProtectShow;
  1861. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1862. {
  1863. try
  1864. {
  1865. telProtectShow.m_nProtectShowID = query_result->GetFieldValue("ProtectShowID", int(-1));
  1866. telProtectShow.m_nRecoverStatus = query_result->GetFieldValue("RecoverStatus", int(-1));
  1867. telProtectShow.m_nProtectStatus = query_result->GetFieldValue("ProtectStatus", int(-1));
  1868. telProtectShow.m_strRecoverShowText = query_result->GetFieldValue("RecoverShowText", std::string(""));
  1869. telProtectShow.m_strProtectShowText = query_result->GetFieldValue("ProtectShowText", std::string(""));
  1870. telProtectShow.m_nRecoverColor = query_result->GetFieldValue("RecoverColor", int(-1));
  1871. telProtectShow.m_nProtectColor = query_result->GetFieldValue("ProtectColor", int(-1));
  1872. ElectricEqpmt_Telesignalisation::AddTelProtectShow(telProtectShow);
  1873. }
  1874. catch (const std::exception&)
  1875. {
  1876. return false;
  1877. }
  1878. }
  1879. }
  1880. std::string strSql_2 = "Select * from Table_Telesignalisation";
  1881. std::shared_ptr<iDBReadSet> query_result_2 = { 0 };
  1882. query_result_2 = m_pDataBase->DirectQuery(strSql_2);
  1883. if (query_result_2) {
  1884. ElectricEqpmt_Telesignalisation telesignalisation;
  1885. ELEEQPMTMAP::iterator iterEqpmt;
  1886. int nMark = 0;
  1887. for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext())
  1888. {
  1889. try
  1890. {
  1891. telesignalisation.m_nProtectID = query_result_2->GetFieldValue("ProtectID", int(-1));
  1892. telesignalisation.m_strEqpmtStrID = query_result_2->GetFieldValue("EqpmtStrID", std::string(""));
  1893. telesignalisation.m_nStationID = query_result_2->GetFieldValue("StationID", int(-1));
  1894. telesignalisation.m_nViewID = query_result_2->GetFieldValue("ViewID", int(-1));
  1895. telesignalisation.m_strDestEqpmtStrID = query_result_2->GetFieldValue("DestEqpmtStrID", std::string(""));
  1896. telesignalisation.m_nProtectShowID = query_result_2->GetFieldValue("PrptectShowID", int(-1));
  1897. telesignalisation.m_nPropertyPageCtrlID = query_result_2->GetFieldValue("PropertyPageCtrlID", int(-1));
  1898. iterEqpmt = ElectricEqpmtMap->find(telesignalisation.m_strEqpmtStrID);
  1899. nMark = 0;
  1900. if (iterEqpmt != ElectricEqpmtMap->end())
  1901. {
  1902. if (Electric_Eqpmt_Status_OFF == telesignalisation.m_nProtectID && Electric_Eqpmt_Status_OFF == iterEqpmt->second->GetStatus())
  1903. {
  1904. nMark = 1;
  1905. }
  1906. else if (Electric_Eqpmt_Status_ON == telesignalisation.m_nProtectID && Electric_Eqpmt_Status_ON == iterEqpmt->second->GetStatus())
  1907. {
  1908. nMark = 1;
  1909. }
  1910. }
  1911. telesignalisationMng.AddStationEqpmtTelesignalisation(telesignalisation, nMark);
  1912. }
  1913. catch (const std::exception&)
  1914. {
  1915. return false;
  1916. }
  1917. }
  1918. }
  1919. return true;
  1920. }
  1921. bool ElectricDataBaseManger::LoadElcTurnOffAreaData( ELEEQPMTMAP* ElectricEqpmtMap, ElectricEqpmt_ElcTurnOffAreaMng& elcTurnOffAreaMng )
  1922. {
  1923. std::string strSql = "Select * from Table_ElcTurnOffArea";
  1924. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1925. query_result = m_pDataBase->DirectQuery(strSql);
  1926. if (query_result) {
  1927. string strEqpmtStrID;
  1928. ELEEQPMTMAP::iterator iterEqpmt;
  1929. int nAreaID = -1, nStationID = -1;
  1930. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1931. {
  1932. try
  1933. {
  1934. strEqpmtStrID = query_result->GetFieldValue("EqpmtStrID", std::string(""));
  1935. nAreaID = query_result->GetFieldValue("OffArea", int(-1));
  1936. nStationID = query_result->GetFieldValue("StationID", int(-1));
  1937. elcTurnOffAreaMng.AddElcTurnOffArea(nAreaID,nStationID,strEqpmtStrID);
  1938. iterEqpmt = ElectricEqpmtMap->find(strEqpmtStrID);
  1939. if (iterEqpmt != ElectricEqpmtMap->end())
  1940. {
  1941. iterEqpmt->second->SetRelationElcTurnOffArea(nAreaID);
  1942. }
  1943. }
  1944. catch (const std::exception&)
  1945. {
  1946. return false;
  1947. }
  1948. }
  1949. }
  1950. return true;
  1951. }
  1952. bool ElectricDataBaseManger::LoadElcEqpmtAutoBoltLogic( ELEEQPMTMAP* ElectricEqpmtMap )
  1953. {
  1954. std::string strSql = "Select * from Table_AutoBoltLogic";
  1955. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1956. query_result = m_pDataBase->DirectQuery(strSql);
  1957. if (query_result) {
  1958. int nType = -1;
  1959. string strEqpmtID = "";
  1960. string strOutPutBreaker = "";
  1961. ELEEQPMTMAP::iterator iterEqpmt;
  1962. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  1963. {
  1964. try
  1965. {
  1966. strEqpmtID = query_result->GetFieldValue("InputBreaker", std::string(""));
  1967. iterEqpmt = ElectricEqpmtMap->find(strEqpmtID);
  1968. if (iterEqpmt != ElectricEqpmtMap->end())
  1969. {
  1970. nType = query_result->GetFieldValue("LogicType", int(-1));
  1971. strOutPutBreaker = query_result->GetFieldValue("OutputBreaker", std::string(""));
  1972. iterEqpmt->second->AddOutLineElectricEqpmt(nType, strOutPutBreaker);
  1973. }
  1974. }
  1975. catch (const std::exception&)
  1976. {
  1977. return false;
  1978. }
  1979. }
  1980. }
  1981. return true;
  1982. }
  1983. bool ElectricDataBaseManger::LoadStation400VLoadMng( ElectricEqpmt_Station400VLoadMng* pStation400VLoadMng, ELEEQPMTMAP* ElectricEqpmtMap )
  1984. {
  1985. if ( nullptr == pStation400VLoadMng )
  1986. {
  1987. return true;
  1988. }
  1989. std::string strSql = "Select * from Table_400Load";
  1990. std::shared_ptr<iDBReadSet> query_result = { 0 };
  1991. query_result = m_pDataBase->DirectQuery(strSql);
  1992. if (query_result) {
  1993. int nStationID = -1;
  1994. int nButtonID = -1;
  1995. string strEqpmtID = "";
  1996. string strInputEqpmtStrID = "";
  1997. string strRelationBolt = "";
  1998. ELEEQPMTMAP::iterator iterEqpmt;
  1999. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2000. {
  2001. try
  2002. {
  2003. nStationID = query_result->GetFieldValue("StationID", int(-1));
  2004. strEqpmtID = query_result->GetFieldValue("StrID", std::string(""));
  2005. strInputEqpmtStrID = query_result->GetFieldValue("InputStrID", std::string(""));
  2006. nButtonID = query_result->GetFieldValue("ButtonID", int(-1));
  2007. strRelationBolt = query_result->GetFieldValue("RelationBolt", std::string(""));
  2008. pStation400VLoadMng->Add400VLoadData(nStationID, strEqpmtID, strInputEqpmtStrID, nButtonID, strRelationBolt);
  2009. iterEqpmt = ElectricEqpmtMap->find(strInputEqpmtStrID);
  2010. if (iterEqpmt != ElectricEqpmtMap->end())
  2011. {
  2012. iterEqpmt->second->Set400VLoadID(nButtonID);
  2013. }
  2014. }
  2015. catch (const std::exception&)
  2016. {
  2017. return false;
  2018. }
  2019. }
  2020. }
  2021. return true;
  2022. }
  2023. bool ElectricDataBaseManger::AddProtectingEqpmt(ELEEQPMTMAP* ElectricEqpmtMap)
  2024. {
  2025. ProtectEqpmtRelationMAP::iterator iterProtect=m_ProtectEqpmtRelationMap.begin();
  2026. for (;iterProtect!=m_ProtectEqpmtRelationMap.end();iterProtect++)
  2027. {
  2028. ELEEQPMTMAP::iterator eqpmt=ElectricEqpmtMap->find(iterProtect->second.ProtectStrID);
  2029. if (eqpmt!=ElectricEqpmtMap->end())
  2030. {
  2031. eqpmt->second->AddFaultEqpmt(iterProtect->first);
  2032. }
  2033. }
  2034. return true;
  2035. }
  2036. bool ElectricDataBaseManger::GetMultiModeData(MULTIMODEMAP& multimodemap)
  2037. {
  2038. std::string strSql = "Select * from Table_MultiModeInfo";
  2039. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2040. query_result = m_pDataBase->DirectQuery(strSql);
  2041. if (query_result) {
  2042. int modeid = -1;
  2043. int multimodeid = -1;
  2044. int type = -1;
  2045. string multimodename = "";
  2046. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2047. {
  2048. try
  2049. {
  2050. multimodeid = query_result->GetFieldValue("MultiModeID", int(-1));
  2051. multimodename = query_result->GetFieldValue("MultiModeName", std::string(""));
  2052. modeid = query_result->GetFieldValue("ModeID", int(-1));
  2053. type = query_result->GetFieldValue("Type", int(-1));
  2054. MULTIMODEMAP::iterator iter = multimodemap.find(multimodeid);
  2055. if (iter == multimodemap.end())
  2056. {
  2057. MULTIMODEINFO multimodeinfo;
  2058. multimodeinfo.m_nMultiModeID = multimodeid;
  2059. multimodeinfo.m_strMultiModeName = multimodename;
  2060. multimodeinfo.m_nType = type;
  2061. multimodeinfo.m_vecModeID.push_back(modeid);
  2062. multimodemap.insert(make_pair(multimodeid, multimodeinfo));
  2063. }
  2064. else
  2065. {
  2066. iter->second.m_vecModeID.push_back(modeid);
  2067. }
  2068. }
  2069. catch (const std::exception&)
  2070. {
  2071. return false;
  2072. }
  2073. }
  2074. }
  2075. return true;
  2076. }
  2077. bool ElectricDataBaseManger::GetModeInfoData(MODEDATAMAP& modemap,MODEIDDATAMAP& modeidmap )
  2078. {
  2079. std::stringstream ss;
  2080. ss << "Select * from Table_EqpmtModeCtrl, Table_ModeInfo "
  2081. << "where Table_EqpmtModeCtrl.ModeID = Table_ModeInfo.ModeID and Table_ModeInfo.StationID = 0 and RunLineID = "
  2082. << m_nLineID;
  2083. std::string strSql = ss.str();
  2084. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2085. query_result = m_pDataBase->DirectQuery(strSql);
  2086. if (query_result) {
  2087. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2088. {
  2089. try
  2090. {
  2091. MODEDATA mode;
  2092. mode.dstatus = query_result->GetFieldValue("EqpmtStatus", int(-1));
  2093. mode.index = query_result->GetFieldValue("CtrlIndex", int(-1));
  2094. mode.strid = query_result->GetFieldValue("EqpmtID", std::string(""));
  2095. mode.modeid = query_result->GetFieldValue("ModeID", int(-1));
  2096. mode.station = query_result->GetFieldValue("StationID", int(-1));
  2097. mode.viewid = query_result->GetFieldValue("ViewID", int(-1));
  2098. mode.modename = query_result->GetFieldValue("ModeName", std::string(""));
  2099. mode.statusname = query_result->GetFieldValue("EqpmtStatusName", std::string(""));
  2100. mode.strModeShowID = query_result->GetFieldValue("ModeShowID", std::string(""));
  2101. mode.strModeShowCode = query_result->GetFieldValue("ModeShowCode", std::string(""));
  2102. modemap.insert(make_pair(Make2IntKey(mode.modeid, mode.index), mode));
  2103. MODEIDDATAMAP::iterator iter1 = modeidmap.find(mode.modeid);
  2104. if (iter1 == modeidmap.end())
  2105. {
  2106. modeidmap.insert(make_pair(mode.modeid, map<int, MODEDATA>()));
  2107. iter1 = modeidmap.find(mode.modeid);
  2108. }
  2109. map<int, MODEDATA>::iterator iter2 = iter1->second.find(mode.index);
  2110. if (iter2 == iter1->second.end())
  2111. {
  2112. iter1->second.insert(make_pair(mode.index, mode));
  2113. }
  2114. }
  2115. catch (const std::exception&)
  2116. {
  2117. return false;
  2118. }
  2119. }
  2120. }
  2121. return true;
  2122. }
  2123. bool ElectricDataBaseManger::GetEqpmtAlarmInfoFromDB(ELCEQPMTALARMINFOMAP* ElcEqpmtAlarmInfoMap)
  2124. {
  2125. std::string strSql = "Select * from Table_EqpmtAlarmInfo";
  2126. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2127. query_result = m_pDataBase->DirectQuery(strSql);
  2128. if (query_result) {
  2129. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2130. {
  2131. try
  2132. {
  2133. ELCEQPMTALARMINFO ElcEqpmtAlarmInfo;
  2134. ElcEqpmtAlarmInfo.m_nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1));
  2135. ElcEqpmtAlarmInfo.m_strAlrmText = query_result->GetFieldValue("AlarmText", std::string(""));
  2136. ElcEqpmtAlarmInfo.m_nAlarmLevel = query_result->GetFieldValue("AlarmLevel", int(-1));
  2137. ElcEqpmtAlarmInfo.m_nAlarmType = query_result->GetFieldValue("AlarmType", int(-1));
  2138. ElcEqpmtAlarmInfo.m_nAlarmSystem = query_result->GetFieldValue("AlramSystem", int(-1));
  2139. ElcEqpmtAlarmInfo.m_nTripActType = query_result->GetFieldValue("TripActType", int(-1));
  2140. ElcEqpmtAlarmInfo.m_nIsFault = query_result->GetFieldValue("IsFault", int(-1));
  2141. ElcEqpmtAlarmInfo.m_strTripText = query_result->GetFieldValue("TripText", std::string(""));
  2142. ElcEqpmtAlarmInfo.m_strProtectLock = query_result->GetFieldValue("LockingText", std::string(""));
  2143. ELCEQPMTALARMINFOMAP::iterator iter1 = ElcEqpmtAlarmInfoMap->find(ElcEqpmtAlarmInfo.m_nEqpmtType);
  2144. if (iter1 == ElcEqpmtAlarmInfoMap->end())
  2145. {
  2146. ElcEqpmtAlarmInfoMap->insert(make_pair(ElcEqpmtAlarmInfo.m_nEqpmtType, ELCEQPMTALARMACTTYPEMAP()));
  2147. iter1 = ElcEqpmtAlarmInfoMap->find(ElcEqpmtAlarmInfo.m_nEqpmtType);
  2148. }
  2149. ELCEQPMTALARMACTTYPEMAP::iterator iter2 = iter1->second.find(ElcEqpmtAlarmInfo.m_nTripActType);
  2150. if (iter2 == iter1->second.end())
  2151. {
  2152. iter1->second.insert(make_pair(ElcEqpmtAlarmInfo.m_nTripActType, ElcEqpmtAlarmInfo));
  2153. }
  2154. }
  2155. catch (const std::exception&)
  2156. {
  2157. return false;
  2158. }
  2159. }
  2160. }
  2161. return true;
  2162. }
  2163. bool ElectricDataBaseManger::LoadElcToEnvRelaData( ELEEQPMTMAP* ElectricEqpmtMap, ElectricEqpmt_ElcTurnOffAreaMng& elcTurnOffAreaMng )
  2164. {
  2165. std::string strSql = "Select * from Table_ElcToEnvRelaInfo";
  2166. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2167. query_result = m_pDataBase->DirectQuery(strSql);
  2168. if (query_result) {
  2169. ELEEQPMTMAP::iterator iterEqpmt;
  2170. int nStationID = -1;
  2171. int nAreaID = -1;
  2172. string strEqpmtStrID;
  2173. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2174. {
  2175. nStationID = query_result->GetFieldValue("StationID", int(-1));
  2176. nAreaID = query_result->GetFieldValue("CtrlAreaID", int(-1));
  2177. strEqpmtStrID = query_result->GetFieldValue("ElcEqpmtStrID", std::string(""));
  2178. elcTurnOffAreaMng.AddElcToRelaData(nStationID, nAreaID, strEqpmtStrID);
  2179. ELEEQPMTMAP::iterator iterEqpmt;
  2180. iterEqpmt = ElectricEqpmtMap->find(strEqpmtStrID);
  2181. if (iterEqpmt != ElectricEqpmtMap->end())
  2182. {
  2183. iterEqpmt->second->SetElcToEnvCtrlArea(nAreaID);
  2184. }
  2185. }
  2186. }
  2187. return true;
  2188. }
  2189. bool ElectricDataBaseManger::GetEqpmtTelemeteryValue(EQPMTTELEINFO& mapTeleInfo)
  2190. {
  2191. std::string strSql = "Select * from Table_EqpmtTelemeteryValue";
  2192. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2193. query_result = m_pDataBase->DirectQuery(strSql);
  2194. if (query_result) {
  2195. EQPMTTELEINFO::iterator iter;
  2196. EqpmtTelemeteryValueInfo* ptrEqpmtTeleInfo;
  2197. string strKey("");
  2198. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2199. {
  2200. try
  2201. {
  2202. ptrEqpmtTeleInfo = new EqpmtTelemeteryValueInfo;
  2203. ptrEqpmtTeleInfo->nType = query_result->GetFieldValue("Type", int(-1));
  2204. ptrEqpmtTeleInfo->nSubType = query_result->GetFieldValue("SubType", int(-1));
  2205. ptrEqpmtTeleInfo->Namol_nMaxV = query_result->GetFieldValue("NormalMax_V", int(-1));
  2206. ptrEqpmtTeleInfo->Namol_nMinV = query_result->GetFieldValue("NormalMin_V", int(-1));
  2207. ptrEqpmtTeleInfo->Namol_nMaxA = query_result->GetFieldValue("NormalMax_A", int(-1));
  2208. ptrEqpmtTeleInfo->Namol_nMinA = query_result->GetFieldValue("NormalMin_A", int(-1));
  2209. ptrEqpmtTeleInfo->Excptional_nMaxV = query_result->GetFieldValue("ExceptionalMax_V", int(-1));
  2210. ptrEqpmtTeleInfo->Excptional_nMinV = query_result->GetFieldValue("ExceptionalMin_V", int(-1));
  2211. ptrEqpmtTeleInfo->Excptional_nMaxA = query_result->GetFieldValue("ExceptionalMax_A", int(-1));
  2212. ptrEqpmtTeleInfo->Excptional_nMinA = query_result->GetFieldValue("ExceptionalMin_A", int(-1));
  2213. strKey = std::to_string(ptrEqpmtTeleInfo->nType);
  2214. if (mapTeleInfo.find(strKey) == mapTeleInfo.end())
  2215. {
  2216. mapTeleInfo.insert(make_pair(strKey, ptrEqpmtTeleInfo));
  2217. }
  2218. else
  2219. {
  2220. std::stringstream sss;
  2221. sss << ptrEqpmtTeleInfo->nType << "_" << ptrEqpmtTeleInfo->nSubType;
  2222. strKey = sss.str();
  2223. mapTeleInfo.insert(make_pair(strKey, ptrEqpmtTeleInfo));
  2224. }
  2225. }
  2226. catch (const std::exception&)
  2227. {
  2228. return false;
  2229. }
  2230. }
  2231. }
  2232. return true;
  2233. }
  2234. bool ElectricDataBaseManger::GetElectric_EqpmtStatusToIBPLight_FromDB(MapIndex_ElcEqpmtStatusToIBPLight& MIEqpmtStatusToIBPLight)
  2235. {
  2236. std::string strSql = "Select * from Table_EqpmtStatusToIBPLight";
  2237. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2238. query_result = m_pDataBase->DirectQuery(strSql);
  2239. if (query_result) {
  2240. MIEqpmtStatusToIBPLight.clear();
  2241. CElcEqpmtStatusToIBPLight eqpmtStatusToIBPLight;
  2242. string strKey("");
  2243. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2244. {
  2245. try
  2246. {
  2247. eqpmtStatusToIBPLight.m_strEqpmtID = query_result->GetFieldValue("EqpmtStrID", std::string(""));
  2248. eqpmtStatusToIBPLight.m_nEqpmtStatus = query_result->GetFieldValue("EqpmtStatus", int(-1));
  2249. eqpmtStatusToIBPLight.m_strStatusName = query_result->GetFieldValue("StatusName", std::string(""));
  2250. eqpmtStatusToIBPLight.m_strLightenIBPKey = query_result->GetFieldValue("LightenIBPKey", std::string(""));
  2251. eqpmtStatusToIBPLight.m_strLightingOffIBPkey = query_result->GetFieldValue("LightingOffIBPkey", std::string(""));
  2252. eqpmtStatusToIBPLight.m_nIBPSysID = query_result->GetFieldValue("IBPSysID", int(-1));
  2253. eqpmtStatusToIBPLight.m_nEventEqpmtID = query_result->GetFieldValue("EventEqpmtID", int(-1));
  2254. eqpmtStatusToIBPLight.m_nEventID = query_result->GetFieldValue("EventID", int(-1));
  2255. eqpmtStatusToIBPLight.m_nIBPStationID = query_result->GetFieldValue("IBPIOID", int(-1));
  2256. strKey = MakeCStr_IntKey_2(eqpmtStatusToIBPLight.m_strEqpmtID, eqpmtStatusToIBPLight.m_nEqpmtStatus);
  2257. MIEqpmtStatusToIBPLight.insert(make_pair(strKey, eqpmtStatusToIBPLight));
  2258. }
  2259. catch (const std::exception&)
  2260. {
  2261. return false;
  2262. }
  2263. }
  2264. }
  2265. return true;
  2266. }
  2267. //加载仿真设备与真实设备映射数据
  2268. bool ElectricDataBaseManger::loadRealEqpmtRelationFromDB(ELEEQPMTMAP* ElectricEqpmtMap)
  2269. {
  2270. std::stringstream ss;
  2271. ss << "Select * from Table_RealEqpmtRelation where RunLineID = "
  2272. << m_nLineID;
  2273. std::string strSql = ss.str();
  2274. std::shared_ptr<iDBReadSet> query_result = { 0 };
  2275. query_result = m_pDataBase->DirectQuery(strSql);
  2276. if (query_result) {
  2277. string strEqpmtID = "";
  2278. ELEEQPMTMAP::iterator iterEqpmt;
  2279. for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext())
  2280. {
  2281. try
  2282. {
  2283. strEqpmtID = query_result->GetFieldValue("StrID", std::string(""));
  2284. iterEqpmt = ElectricEqpmtMap->find(strEqpmtID);
  2285. if (iterEqpmt != ElectricEqpmtMap->end())
  2286. {
  2287. iterEqpmt->second->setReallyEqpmtFlag();
  2288. }
  2289. }
  2290. catch (const std::exception&)
  2291. {
  2292. return false;
  2293. }
  2294. }
  2295. }
  2296. return true;
  2297. }