YN_NodeDef.cpp 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. #include "pch.h"
  2. #include "YN_NodeDef.h"
  3. #include "PublicEqpmtID.h"
  4. DcYNodeBase::DcYNodeBase()
  5. {
  6. p_DcYNodesMap = nullptr;
  7. m_pCritilSecNodesMap = nullptr;
  8. }
  9. DcYNodeBase::~DcYNodeBase()
  10. {
  11. }
  12. double DcYNodeBase::GetSelfYValue() //获取节点自导纳
  13. {
  14. double SelfY = 0;
  15. m_CritilSecRelaNodesMap.lock();
  16. DcRelaNodeMap::iterator iter = m_RelaNodeRsMap.begin();
  17. for (; iter != m_RelaNodeRsMap.end(); iter++)
  18. {
  19. if (iter->second + double_Zero_Offszie != double_Zero_Offszie)
  20. {
  21. SelfY += 1 / iter->second;//自导纳的计算
  22. }
  23. }
  24. m_CritilSecRelaNodesMap.unlock();
  25. return SelfY;
  26. }
  27. double DcYNodeBase::GetRelaNodeYValue(int RelationNodeID)//获取节点导纳值,互导纳值的计算
  28. {
  29. double RelaYValue = 0;
  30. m_CritilSecRelaNodesMap.lock();
  31. DcRelaNodeMap::iterator iter = m_RelaNodeRsMap.find(RelationNodeID);
  32. if (iter != m_RelaNodeRsMap.end())
  33. {
  34. if (iter->second + double_Zero_Offszie != double_Zero_Offszie)
  35. {
  36. RelaYValue = -1 / iter->second;//互导纳的计算
  37. }
  38. }
  39. m_CritilSecRelaNodesMap.unlock();
  40. return RelaYValue;
  41. }
  42. inline int DcYNodeBase::GetRelaNodeRectIndex(int RelationNodeID)//获取关系节点矩阵索引
  43. {
  44. if (p_DcYNodesMap != nullptr)
  45. {
  46. DcNodeMap::iterator iter = p_DcYNodesMap->find(RelationNodeID);
  47. if (iter != p_DcYNodesMap->end())
  48. {
  49. return iter->second->GetRectIndex();
  50. }
  51. }
  52. return 0;
  53. }
  54. void DcYNodeBase::SetDcNodeMap(DcNodeMap* pNodeMap, std::mutex* pCritilSec)//设置直流节点
  55. {
  56. p_DcYNodesMap = pNodeMap;
  57. m_pCritilSecNodesMap = pCritilSec;
  58. m_pCritilSecNodesMap->lock();
  59. p_DcYNodesMap->insert(make_pair(m_NodeID, this));
  60. m_pCritilSecNodesMap->unlock();
  61. }
  62. void DcYNodeBase::SetNodeID(int ID)
  63. {
  64. m_NodeID = ID;
  65. }
  66. int DcYNodeBase::GetNodeID()
  67. {
  68. return m_NodeID;
  69. }
  70. void DcYNodeBase::SetRectIndex(int index)
  71. {
  72. m_RectIndex = index;
  73. }
  74. int DcYNodeBase::GetRectIndex()
  75. {
  76. return m_RectIndex;
  77. }
  78. int DcYNodeBase::GetNodeCategory()
  79. {
  80. return m_NodeCategory;
  81. }
  82. void DcYNodeBase::UpdateRelaNode(int oldid, int newid, double r)//更新关系节点
  83. {
  84. m_CritilSecRelaNodesMap.lock();
  85. DcRelaNodeMap::iterator iter = m_RelaNodeRsMap.find(oldid);
  86. if (iter != m_RelaNodeRsMap.end())
  87. {
  88. m_RelaNodeRsMap.erase(oldid);
  89. }
  90. m_RelaNodeRsMap.insert(make_pair(newid, r));
  91. m_CritilSecRelaNodesMap.unlock();
  92. }
  93. YN_RectierToTouchNet::YN_RectierToTouchNet()
  94. {
  95. Len_UpPreNode = 0;
  96. Len_DownPreNode = 0;
  97. Len_UpNextNode = 0;
  98. Len_DownNextNode = 0;
  99. }
  100. YN_RectierToTouchNet::~YN_RectierToTouchNet() {}
  101. void YN_RectierToTouchNet::SetStationID(int id)
  102. {
  103. StationID = id;
  104. }
  105. int YN_RectierToTouchNet::GetStationID()
  106. {
  107. return StationID;
  108. }
  109. bool YN_RectierToTouchNet::SetTouchLineLen(double lenUpPre, double lenDownPre, double lenUpNext, double lenDownNext)
  110. {
  111. if (lenUpPre < 0 || lenDownPre < 0 || lenUpNext < 0 || lenDownNext < 0)
  112. {
  113. return false;
  114. }
  115. Len_UpPreLine = lenUpPre;
  116. Len_DownPreLine = lenDownPre;
  117. Len_UpNextLine = lenUpNext;
  118. Len_DownNextLine = lenDownNext;
  119. return true;
  120. }
  121. bool YN_RectierToTouchNet::SetUpPreNode(int id, double len) //设置前一个节点的电阻,ID,长度
  122. {
  123. if (len < 0)
  124. return false;
  125. double r = (len + Len_UpPreLine) * R_Rate_ContactLine;//接触网线电阻的计算
  126. UpdateRelaNode(UpPreNodeID, id, r);
  127. UpPreNodeID = id;
  128. Len_UpPreNode = len;
  129. return true;
  130. }
  131. bool YN_RectierToTouchNet::SetDownPreNode(int id, double len)//设置下个节点
  132. {
  133. if (len < 0)
  134. return false;
  135. double r = (len + Len_DownPreLine) * R_Rate_ContactLine;
  136. UpdateRelaNode(DownPreNodeID, id, r);
  137. DownPreNodeID = id;
  138. Len_DownPreNode = len;
  139. return true;
  140. }
  141. bool YN_RectierToTouchNet::SetUpNextNode(int id, double len)//
  142. {
  143. if (len < 0)
  144. return false;
  145. double r = (len + Len_UpNextLine) * R_Rate_ContactLine;
  146. UpdateRelaNode(DownPreNodeID, id, r);
  147. UpNextNodeID = id;
  148. Len_UpNextNode = len;
  149. return true;
  150. }
  151. bool YN_RectierToTouchNet::SetDownNextNode(int id, double len)
  152. {
  153. if (len < 0)
  154. return false;
  155. double r = (len + Len_DownNextLine) * R_Rate_ContactLine;
  156. UpdateRelaNode(DownNextNodeID, id, r);
  157. DownNextNodeID = id;
  158. Len_DownNextNode = len;
  159. return true;
  160. }
  161. void YN_RectierToTouchNet::SetInnerNode(int id, double r) //设置整流器的内节点解 工区节点的ID,电阻
  162. {
  163. UpdateRelaNode(InnerNodeID, id, r);
  164. InnerNodeID = id;
  165. }
  166. int YN_RectierToTouchNet::GetUpPreNodeID()
  167. {
  168. return UpPreNodeID;
  169. }
  170. int YN_RectierToTouchNet::GetDownPreNodeID()
  171. {
  172. return DownPreNodeID;
  173. }
  174. int YN_RectierToTouchNet::GetUpNextNodeID()
  175. {
  176. return UpNextNodeID;
  177. }
  178. int YN_RectierToTouchNet::GetDownNextNodeID()
  179. {
  180. return DownNextNodeID;
  181. }
  182. int YN_RectierToTouchNet::GetInnerNodeID()
  183. {
  184. return InnerNodeID;
  185. }
  186. double YN_RectierToTouchNet::GetUpPreNodeLen()
  187. {
  188. return Len_UpPreNode;
  189. }
  190. double YN_RectierToTouchNet::GetDownPreNodeLen()
  191. {
  192. return Len_DownPreNode;
  193. }
  194. double YN_RectierToTouchNet::GetUpNextNodeLen()
  195. {
  196. return Len_UpNextNode;
  197. }
  198. double YN_RectierToTouchNet::GetDownNextNodeLen()
  199. {
  200. return Len_DownNextNode;
  201. }
  202. YN_RectierToRailway::YN_RectierToRailway()
  203. {
  204. Len_PreFeedBackLine = 0.0; //前一节点回流线的长度
  205. Len_NextFeedBackLine = 0.0; //下一节点回流线的长度
  206. UpNodeID = 0; //上行节点ID
  207. DownNodeID = 0; //下行节点ID
  208. InnerNodeID = 0; //内节点ID
  209. StationID = -1; //车站ID
  210. }
  211. YN_RectierToRailway::~YN_RectierToRailway()
  212. {
  213. }
  214. void YN_RectierToRailway::SetStationID(int id)
  215. {
  216. StationID = id;
  217. }
  218. int YN_RectierToRailway::GetStationID()
  219. {
  220. return StationID;
  221. }
  222. bool YN_RectierToRailway::SetFeedBackLineLen(double lenPre, double lenNext)//馈线的长度
  223. {
  224. if (lenPre <= 0 || lenNext <= 0)
  225. {
  226. return false;
  227. }
  228. Len_PreFeedBackLine = lenPre;
  229. Len_NextFeedBackLine = lenNext;
  230. return true;
  231. }
  232. bool YN_RectierToRailway::SetUpNode(int id, double len)
  233. {
  234. if (len <= 0)
  235. {
  236. return false;
  237. }
  238. double r = len * R_Rate_FeedBack;//电阻的计算
  239. Len_PreFeedBackLine = len;
  240. UpdateRelaNode(UpNodeID, id, r);
  241. UpNodeID = id;
  242. return true;
  243. }
  244. bool YN_RectierToRailway::SetDownNode(int id, double len)
  245. {
  246. if (len <= 0)
  247. {
  248. return false;
  249. }
  250. double r = len * R_Rate_FeedBack;
  251. Len_NextFeedBackLine = len;
  252. UpdateRelaNode(DownNodeID, id, r);
  253. DownNodeID = id;
  254. return true;
  255. }
  256. void YN_RectierToRailway::SetInnerNode(int id, double r)
  257. {
  258. UpdateRelaNode(InnerNodeID, id, r);
  259. InnerNodeID = id;
  260. }
  261. int YN_RectierToRailway::GetDownNode()
  262. {
  263. return DownNodeID;
  264. }
  265. int YN_RectierToRailway::GetUpNode()
  266. {
  267. return UpNodeID;
  268. }
  269. YN_Railway::YN_Railway()
  270. {
  271. Len_RectierFeedBackLine = 0.0; //整流器回流线的长度
  272. PreY = 0.0; //前一个导纳值
  273. NextY = 0.0; //下一个导纳值
  274. PreNodeID = 0; //前一个节点ID
  275. NextNodeID = 0; //下一个节点ID
  276. RectierNodeID = 0; //整流器节点ID
  277. StationID = -1;
  278. }
  279. YN_Railway::~YN_Railway()
  280. {
  281. }
  282. void YN_Railway::SetStationID(int id)
  283. {
  284. StationID = id;
  285. }
  286. int YN_Railway::GetStationID()
  287. {
  288. return StationID;
  289. }
  290. double YN_Railway::GetSelfYValue()
  291. {
  292. double SelfY = 0;
  293. m_CritilSecRelaNodesMap.lock();
  294. DcRelaNodeMap::iterator iter = m_RelaNodeRsMap.begin();
  295. for (; iter != m_RelaNodeRsMap.end(); iter++)
  296. {
  297. if (iter->second + double_Zero_Offszie != double_Zero_Offszie)
  298. {
  299. SelfY += 1 / iter->second;
  300. }
  301. }
  302. m_CritilSecRelaNodesMap.unlock();
  303. SelfY += PreY;
  304. SelfY += NextY;
  305. return SelfY;
  306. }
  307. bool YN_Railway::SetFeedBackLineLen(double len)
  308. {
  309. if (len <= 0)
  310. {
  311. return false;
  312. }
  313. Len_RectierFeedBackLine = len;
  314. return true;
  315. }
  316. bool YN_Railway::SetPreNode(int id, double len)
  317. {
  318. if (len <= 0)
  319. {
  320. return false;
  321. }
  322. double r = len * R_Rate_RailWay;
  323. UpdateRelaNode(PreNodeID, id, r);
  324. PreNodeID = id;
  325. PreY = 1 / len * R_Rate_RailToEarth;
  326. return true;
  327. }
  328. bool YN_Railway::SetNextNode(int id, double len)
  329. {
  330. if (len <= 0)
  331. {
  332. return false;
  333. }
  334. double r = len * R_Rate_RailWay;
  335. UpdateRelaNode(NextNodeID, id, r);
  336. NextNodeID = id;
  337. NextY = 1 / len * R_Rate_RailToEarth;
  338. return true;
  339. }
  340. bool YN_Railway::SetRectierNode(int id, double len)
  341. {
  342. if (len <= 0)
  343. {
  344. return false;
  345. }
  346. Len_RectierFeedBackLine = len;
  347. double r = len * R_Rate_FeedBack;
  348. UpdateRelaNode(RectierNodeID, id, r);
  349. RectierNodeID = id;
  350. return true;
  351. }
  352. YN_HeadTail::YN_HeadTail()
  353. {
  354. DownY = 0.0; //下行导纳值
  355. UpNodeID = 0; //上行节点ID
  356. DowntNodeID = 0; //下行节点ID
  357. }
  358. YN_HeadTail::~YN_HeadTail()
  359. {
  360. }
  361. double YN_HeadTail::GetSelfYValue()
  362. {
  363. double SelfY = 0;
  364. m_CritilSecRelaNodesMap.lock();
  365. DcRelaNodeMap::iterator iter = m_RelaNodeRsMap.begin();
  366. for (; iter != m_RelaNodeRsMap.end(); iter++)
  367. {
  368. if (iter->second + double_Zero_Offszie != double_Zero_Offszie)
  369. {
  370. SelfY += 1 / iter->second;
  371. }
  372. }
  373. m_CritilSecRelaNodesMap.unlock();
  374. SelfY += DownY;
  375. return SelfY;
  376. }
  377. bool YN_HeadTail::SetUpNode(int id, double len)
  378. {
  379. if (len <= 0)
  380. {
  381. return false;
  382. }
  383. double r = len * R_Rate_ContactLine;
  384. UpdateRelaNode(UpNodeID, id, r);
  385. UpNodeID = id;
  386. return true;
  387. }
  388. bool YN_HeadTail::SetDownNode(int id, double len)
  389. {
  390. if (len <= 0)
  391. {
  392. return false;
  393. }
  394. double r = len * R_Rate_RailWay;
  395. UpdateRelaNode(DowntNodeID, id, r);
  396. DowntNodeID = id;
  397. DownY = 1 / len * R_Rate_RailToEarth;
  398. return true;
  399. }
  400. YN_TrianOnLine::YN_TrianOnLine()
  401. {
  402. PreNodeID = 0;
  403. NextNodeID = 0;
  404. RailwayNodeID = 0;
  405. }
  406. YN_TrianOnLine::~YN_TrianOnLine()
  407. {
  408. }
  409. bool YN_TrianOnLine::SetPreNode(int id, double len)
  410. {
  411. if (len <= 0)
  412. {
  413. return false;
  414. }
  415. double r = len * R_Rate_ContactLine;
  416. UpdateRelaNode(PreNodeID, id, r);
  417. PreNodeID = id;
  418. return true;
  419. }
  420. bool YN_TrianOnLine::SetNextNode(int id, double len)
  421. {
  422. if (len <= 0)
  423. {
  424. return false;
  425. }
  426. double r = len * R_Rate_ContactLine;
  427. UpdateRelaNode(NextNodeID, id, r);
  428. NextNodeID = id;
  429. return true;
  430. }
  431. void YN_TrianOnLine::SetRailwayNode(int id)
  432. {
  433. UpdateRelaNode(RailwayNodeID, id, 0);
  434. RailwayNodeID = id;
  435. }
  436. int YN_TrianOnLine::GetPreNodeID()
  437. {
  438. return PreNodeID;
  439. }
  440. int YN_TrianOnLine::GetNextNodeID()
  441. {
  442. return NextNodeID;
  443. }
  444. int YN_TrianOnLine::GetRailwayNodeID()
  445. {
  446. return RailwayNodeID;
  447. }
  448. YN_TrianOnRailway::YN_TrianOnRailway()
  449. {
  450. YPre = 0.0;
  451. YNext = 0.0;
  452. PreNodeID = 0;
  453. NextNodeID = 0;
  454. OnlineNodeID = 0; //列车与接触网ID
  455. }
  456. YN_TrianOnRailway::~YN_TrianOnRailway()
  457. {
  458. }
  459. bool YN_TrianOnRailway::SetPreNode(int id, double len)
  460. {
  461. if (len <= 0)
  462. {
  463. return false;
  464. }
  465. double r = len * R_Rate_RailWay;
  466. UpdateRelaNode(PreNodeID, id, r);
  467. YPre = 1 / R_Rate_RailToEarth * len;
  468. PreNodeID = id;
  469. return true;
  470. }
  471. bool YN_TrianOnRailway::SetNextNode(int id, double len)
  472. {
  473. if (len <= 0)
  474. {
  475. return false;
  476. }
  477. double r = len * R_Rate_RailWay;
  478. UpdateRelaNode(NextNodeID, id, r);
  479. YNext = 1 / R_Rate_RailToEarth * len;
  480. NextNodeID = id;
  481. return true;
  482. }
  483. void YN_TrianOnRailway::SetOnlineNode(int id)
  484. {
  485. UpdateRelaNode(OnlineNodeID, id, 0);
  486. OnlineNodeID = id;
  487. }
  488. void tgPowerNodeBase::Init(int rectindex, int id, int ncategory)
  489. {
  490. m_NodeID = id;
  491. RelationCount = 0;
  492. m_NodeCategory = ncategory;
  493. m_RectIndex = rectindex;
  494. for (int i = 0; i < Max_NodeRelationNums; i++)
  495. {
  496. RelaNodes[i].NodeID = -1;
  497. RelaNodes[i].R = -1;
  498. RelaNodes[i].m_IsPower = true;
  499. }
  500. }
  501. double tgPowerNodeBase::GetRelaNodeYValue(int RelationNodeID)//获取关系节点的导纳值(互导纳),Y代表导纳的意思
  502. {
  503. double RelaYValue = 0;
  504. if (RelationNodeID >= 0)
  505. {
  506. for (int i = 0; i < Max_NodeRelationNums; i++)
  507. {
  508. if (RelaNodes[i].NodeID == RelationNodeID)
  509. {
  510. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie && RelaNodes[i].m_IsPower)
  511. {
  512. RelaYValue += -1 / RelaNodes[i].R;//计算导纳,为电阻的倒数
  513. }
  514. }
  515. }
  516. }
  517. return RelaYValue;
  518. }
  519. int tgPowerNodeBase::GetRectIndex()
  520. {
  521. return m_RectIndex;
  522. }
  523. void tgPowerNodeBase::UpdateRelaNode(int oldid, int newid, double r, bool power)//更新关系节点
  524. {
  525. bool HaveNode = false;
  526. for (int i = 0; i < RelationCount; i++)
  527. {
  528. if (RelaNodes[i].NodeID == oldid)
  529. {
  530. RelaNodes[i].NodeID = newid;
  531. RelaNodes[i].R = r;
  532. RelaNodes[i].m_IsPower = power;
  533. HaveNode = true;
  534. }
  535. }
  536. if (!HaveNode && RelationCount < Max_NodeRelationNums)
  537. {
  538. RelaNodes[RelationCount].NodeID = newid;
  539. RelaNodes[RelationCount].R = r;
  540. RelaNodes[RelationCount].m_IsPower = power;
  541. RelationCount++;
  542. }
  543. }
  544. int tgPowerNodeBase::GetNodeCategory()//获取节点类型
  545. {
  546. return m_NodeCategory;
  547. }
  548. void tgPowerNodeBase::SetPower(bool power)
  549. {
  550. m_IsPower = power;
  551. }
  552. bool tgPowerNodeBase::GetPower()
  553. {
  554. return m_IsPower;
  555. }
  556. void tgRectierToTouchNet::UpdateRelaNodeByIndex(int index, int newid, double r, bool power)//通过索引更新关系节点
  557. {
  558. if (index < Max_NodeRelationNums)
  559. {
  560. if (RelaNodes[index].NodeID != newid && RelaNodes[index].NodeID < 0)
  561. {
  562. RelationCount++;
  563. }
  564. RelaNodes[index].NodeID = newid;
  565. RelaNodes[index].R = r;
  566. RelaNodes[index].m_IsPower = power;
  567. }
  568. }
  569. double tgRectierToTouchNet::GetSelfYValue()//获取自导纳
  570. {
  571. double SelfY = 0;
  572. for (int i = 0; i < Max_NodeRelationNums; i++)
  573. {
  574. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  575. {
  576. if (RelaNodes[i].NodeID >= 0 && RelaNodes[i].m_IsPower)
  577. {
  578. SelfY += 1 / RelaNodes[i].R;
  579. }
  580. }
  581. }
  582. return SelfY;
  583. }
  584. bool tgRectierToTouchNet::SetTouchLineLen(double lenUpPre, double lenDownPre, double lenUpNext, double lenDownNext)//设置接触网线的长度
  585. {
  586. if (lenUpPre < 0 || lenDownPre < 0 || lenUpNext < 0 || lenDownNext < 0)
  587. {
  588. return false;
  589. }
  590. Len_UpPreNode = Len_UpPreLine = lenUpPre; //将牵混所4条直流馈线长度赋给正极母线上的4个节点上馈线相应接触网长度
  591. Len_DownPreNode = Len_DownPreLine = lenDownPre;
  592. Len_UpNextNode = Len_UpNextLine = lenUpNext;
  593. Len_DownNextNode = Len_DownNextLine = lenDownNext;
  594. return true;
  595. }
  596. bool tgRectierToTouchNet::SetUpPreNode(int id, double len, bool power)
  597. {
  598. if (len < 0)
  599. return false;
  600. double r = len * R_Rate_ContactLine;
  601. UpdateRelaNodeByIndex(4, id, r, power);
  602. UpPreNodeID = id;
  603. Len_UpPreNode = len + Len_UpPreLine;
  604. return true;
  605. }
  606. bool tgRectierToTouchNet::SetDownPreNode(int id, double len, bool power)
  607. {
  608. if (len < 0)
  609. return false;
  610. double r = len * R_Rate_ContactLine;
  611. UpdateRelaNodeByIndex(3, id, r, power);
  612. DownPreNodeID = id;
  613. Len_DownPreNode = len + Len_DownPreLine;
  614. return true;
  615. }
  616. bool tgRectierToTouchNet::SetUpNextNode(int id, double len, bool power)
  617. {
  618. if (len < 0)
  619. return false;
  620. double r = len * R_Rate_ContactLine;
  621. UpdateRelaNodeByIndex(1, id, r, power);
  622. UpNextNodeID = id;
  623. Len_UpNextNode = len + Len_UpNextLine;
  624. return true;
  625. }
  626. bool tgRectierToTouchNet::SetDownNextNode(int id, double len, bool power)
  627. {
  628. if (len < 0)
  629. return false;
  630. double r = len * R_Rate_ContactLine;
  631. UpdateRelaNodeByIndex(0, id, r, power);
  632. DownNextNodeID = id;
  633. Len_DownNextNode = len + Len_DownNextLine;
  634. return true;
  635. }
  636. void tgRectierToTouchNet::SetInnerNode(int id, double r, bool power)//设置内节点
  637. {
  638. UpdateRelaNodeByIndex(2, id, r, power); //通过索引更新相关节点
  639. InnerNodeID = id;
  640. }
  641. int tgRectierToTouchNet::GetUpPreNodeID()
  642. {
  643. return UpPreNodeID;
  644. }
  645. int tgRectierToTouchNet::GetDownPreNodeID()
  646. {
  647. return DownPreNodeID;
  648. }
  649. int tgRectierToTouchNet::GetUpNextNodeID()
  650. {
  651. return UpNextNodeID;
  652. }
  653. int tgRectierToTouchNet::GetDownNextNodeID()
  654. {
  655. return DownNextNodeID;
  656. }
  657. int tgRectierToTouchNet::GetInnerNodeID()
  658. {
  659. return InnerNodeID;
  660. }
  661. double tgRectierToTouchNet::GetUpPreNodeLen()
  662. {
  663. return Len_UpPreNode;
  664. }
  665. double tgRectierToTouchNet::GetDownPreNodeLen()
  666. {
  667. return Len_DownPreNode;
  668. }
  669. double tgRectierToTouchNet::GetUpNextNodeLen()
  670. {
  671. return Len_UpNextNode;
  672. }
  673. double tgRectierToTouchNet::GetDownNextNodeLen()
  674. {
  675. return Len_DownNextNode;
  676. }
  677. double tgRectierToRailway::GetSelfYValue()
  678. {
  679. double SelfY = 0;
  680. for (int i = 0; i < RelationCount; i++)
  681. {
  682. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  683. {
  684. if (RelaNodes[i].NodeID >= 0 && RelaNodes[i].m_IsPower)
  685. {
  686. SelfY += 1 / RelaNodes[i].R;
  687. }
  688. //SelfY+=1/RelaNodes[i].R;
  689. }
  690. }
  691. return SelfY;
  692. }
  693. void tgRectierToRailway::SetStationID(int id)
  694. {
  695. StationID = id;
  696. }
  697. int tgRectierToRailway::GetStationID()
  698. {
  699. return StationID;
  700. }
  701. bool tgRectierToRailway::SetFeedBackLineLen(double lenPre, double lenNext)//设置馈线的长度
  702. {
  703. if (lenPre <= 0 || lenNext <= 0)
  704. {
  705. return false;
  706. }
  707. Len_PreFeedBackLine = lenPre;
  708. Len_NextFeedBackLine = lenNext;
  709. return true;
  710. }
  711. bool tgRectierToRailway::SetUpNode(int id, double len, bool power)
  712. {
  713. if (len <= 0)
  714. {
  715. return false;
  716. }
  717. double r = len * R_Rate_FeedBack;
  718. Len_PreFeedBackLine = len;
  719. UpdateRelaNode(UpNodeID, id, r, power);
  720. UpNodeID = id;
  721. return true;
  722. }
  723. bool tgRectierToRailway::SetDownNode(int id, double len, bool power)
  724. {
  725. if (len < 0)
  726. {
  727. return false;
  728. }
  729. double r = len * R_Rate_FeedBack;
  730. Len_NextFeedBackLine = len;
  731. UpdateRelaNode(DownNodeID, id, r, power);
  732. DownNodeID = id;
  733. return true;
  734. }
  735. void tgRectierToRailway::SetInnerNode(int id, double r, bool power)
  736. {
  737. UpdateRelaNode(InnerNodeID, id, r, power);
  738. InnerNodeID = id;
  739. }
  740. int tgRectierToRailway::GetDownNode()
  741. {
  742. return DownNodeID;
  743. }
  744. int tgRectierToRailway::GetUpNode()
  745. {
  746. return UpNodeID;
  747. }
  748. double tgRailway::GetSelfYValue()
  749. {
  750. double SelfY = 0;
  751. for (int i = 0; i < RelationCount; i++)
  752. {
  753. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  754. {
  755. SelfY += 1 / RelaNodes[i].R;
  756. }
  757. }
  758. SelfY += PreY;
  759. SelfY += NextY; //当前轨道节点自导=各关联支路导纳+前侧对地导纳+右后侧对地导纳
  760. return SelfY;
  761. }
  762. void tgRailway::SetStationID(int id)
  763. {
  764. StationID = id;
  765. }
  766. int tgRailway::GetStationID()
  767. {
  768. return StationID;
  769. }
  770. bool tgRailway::SetFeedBackLineLen(double len)
  771. {
  772. if (len <= 0)
  773. {
  774. return false;
  775. }
  776. Len_FeBackLine = len;
  777. return true;
  778. }
  779. bool tgRailway::SetPreNode(int id, double len, bool power)
  780. {
  781. if (len <= 0)
  782. {
  783. return false;
  784. }
  785. double r = len * R_Rate_RailWay;
  786. UpdateRelaNode(PreNodeID, id, r, power);
  787. PreNodeID = id;
  788. PreY = len / R_Rate_RailToEarth;
  789. return true;
  790. }
  791. bool tgRailway::SetNextNode(int id, double len, bool power)
  792. {
  793. if (len <= 0)
  794. {
  795. return false;
  796. }
  797. double r = len * R_Rate_RailWay;
  798. UpdateRelaNode(NextNodeID, id, r, power);
  799. NextNodeID = id;
  800. NextY = len / R_Rate_RailToEarth;
  801. return true;
  802. }
  803. bool tgRailway::SetRectierNode(int id, double len, bool power)
  804. {
  805. if (len <= 0)
  806. {
  807. return false;
  808. }
  809. Len_FeBackLine = len;
  810. double r = len * R_Rate_FeedBack;
  811. UpdateRelaNode(RectierNodeID, id, r, power);
  812. RectierNodeID = id;
  813. return true;
  814. }
  815. double tgHeadTail::GetSelfYValue()
  816. {
  817. double SelfY = 0.0;
  818. for (int i = 0; i < RelationCount; i++)
  819. {
  820. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  821. {
  822. SelfY += 1 / RelaNodes[i].R;
  823. }
  824. }
  825. SelfY += DownY;
  826. return SelfY;
  827. }
  828. bool tgHeadTail::SetDownNode(int id, double len, bool power)//设置轨道ID号与轨道长度
  829. {
  830. if (len <= 0)
  831. {
  832. return false;
  833. }
  834. double r = len * R_Rate_RailWay;//R_Rate_RailWay轨道电阻率,求轨道电阻
  835. UpdateRelaNode(DowntNodeID, id, r, power);//更新轨道关系节点
  836. DowntNodeID = id;
  837. DownY = len / R_Rate_RailToEarth;//R_Rate_RailToEarth轨道到地的电阻率,求下行导纳
  838. return true;
  839. }
  840. double tgTRIANONLINE::GetSelfYValue()
  841. {
  842. double SelfY = 0;
  843. for (int i = 0; i < RelationCount; i++)
  844. {
  845. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  846. {
  847. SelfY += 1 / RelaNodes[i].R;
  848. }
  849. }
  850. return SelfY;
  851. }
  852. bool tgTRIANONLINE::SetPreNode(int id, double len, bool power)
  853. {
  854. if (len <= 0)
  855. {
  856. //TRACE(" tgTRIANONLINE::SetPreNode: len<=0\n");
  857. return false;
  858. }
  859. double r = len * R_Rate_ContactLine;
  860. UpdateRelaNode(PreNodeID, id, r, power);
  861. PreNodeID = id;
  862. return true;
  863. }
  864. bool tgTRIANONLINE::SetNextNode(int id, double len, bool power)
  865. {
  866. if (len <= 0)
  867. {
  868. //TRACE(" tgTRIANONLINE::SetNextNode: len<=0\n");
  869. return false;
  870. }
  871. double r = len * R_Rate_ContactLine;
  872. UpdateRelaNode(NextNodeID, id, r, power);
  873. NextNodeID = id;
  874. return true;
  875. }
  876. void tgTRIANONLINE::SetTrianInfo(int no, int lineno, double ex, int arrow)
  877. {
  878. TrianNO = no;
  879. LineSectionNo = lineno;
  880. excursion = ex;
  881. arrow = arrow;
  882. }
  883. void tgTRIANONLINE::SetRailwayNode(int id)
  884. {
  885. UpdateRelaNode(RailwayNodeID, id, 0, true);
  886. RailwayNodeID = id;
  887. }
  888. int tgTRIANONLINE::GetPreNodeID()
  889. {
  890. return PreNodeID;
  891. }
  892. int tgTRIANONLINE::GetNextNodeID()
  893. {
  894. return NextNodeID;
  895. }
  896. int tgTRIANONLINE::GetRailwayNodeID()
  897. {
  898. return RailwayNodeID;
  899. }
  900. double tgTrianOnRailway::GetSelfYValue()
  901. {
  902. double SelfY = 0;
  903. for (int i = 0; i < RelationCount; i++)
  904. {
  905. if (RelaNodes[i].R + double_Zero_Offszie != double_Zero_Offszie)
  906. {
  907. SelfY += 1 / RelaNodes[i].R;
  908. }
  909. }
  910. SelfY += YPre;
  911. SelfY += YNext;
  912. return SelfY;
  913. }
  914. bool tgTrianOnRailway::SetPreNode(int id, double len, bool power)
  915. {
  916. if (len <= 0)
  917. {
  918. //TRACE(" tgTrianOnRailway::SetPreNode: len<=0\n");
  919. return false;
  920. }
  921. double r = len * R_Rate_RailWay;
  922. UpdateRelaNode(PreNodeID, id, r, power);
  923. YPre = len / R_Rate_RailToEarth; //R_Rate_RailToEarth电阻率,导纳为
  924. PreNodeID = id;
  925. return true;
  926. }
  927. bool tgTrianOnRailway::SetNextNode(int id, double len, bool power)
  928. {
  929. if (len <= 0)
  930. {
  931. //TRACE(" tgTrianOnRailway::SetNextNode: len<=0\n");
  932. return false;
  933. }
  934. double r = len * R_Rate_RailWay;//电阻与电阻率的关系
  935. UpdateRelaNode(NextNodeID, id, r, power);
  936. YNext = len / R_Rate_RailToEarth; //与此公式( r = len*R_Rate_RailWay;),需检查
  937. NextNodeID = id;
  938. return true;
  939. }
  940. void tgTrianOnRailway::SetOnlineNode(int id)//设置车与接触网的节点
  941. {
  942. UpdateRelaNode(OnlineNodeID, id, 0, true);
  943. OnlineNodeID = id;
  944. }
  945. int tgTrianOnRailway::GetOnlineNodeID()
  946. {
  947. return OnlineNodeID;
  948. }
  949. tgPowerNode::tgPowerNode()
  950. {
  951. memset(this, 0, sizeof(tgPowerNode));
  952. nodeType = NodeType::eDc_NodeKind_Unknow;
  953. m_NodeV = Voltage_Calculate_InitValueV;
  954. }
  955. int tgPowerNode::GetRectIndex() //获取矩阵的索引
  956. {
  957. if (nodeType == NodeType::eDc_NodeKind_HeadTail) //节点类型:头尾节点
  958. {
  959. return HeadTailNode.m_RectIndex;
  960. }
  961. else if (nodeType == NodeType::eDc_NodeKind_RectierToTouchNet) //节点类型:整流器到接触网
  962. {
  963. return RectierToTouchNetNode.m_RectIndex;
  964. }
  965. else if (nodeType == NodeType::eDc_NodeKind_RectierToRailWay) //节点类型:整流器到轨道
  966. {
  967. return RectierToRailwayNode.m_RectIndex;
  968. }
  969. else if (nodeType == NodeType::eDc_NodeKind_RailWay) //节点类型:轨道节点
  970. {
  971. return RailWayNode.m_RectIndex;
  972. }
  973. else if (nodeType == NodeType::eDc_NodeKind_UpTrain) //节点类型:上行列车 //列车受电弓节点 xyx注释
  974. {
  975. return TrianOnLineNode.m_RectIndex;
  976. }
  977. else if (nodeType == NodeType::eDc_NodeKind_DownTrain) //节点类型:下行列车 //列车轮对节点 xyx注释
  978. {
  979. return TrianOnRailway.m_RectIndex;
  980. }
  981. return -1;
  982. }
  983. void tgPowerNode::setRectierToTouchNet(const RECTIERTOTOUCHNET* paraNode)
  984. {
  985. nodeType = NodeType::eDc_NodeKind_RectierToTouchNet; //直流正极母线节点 xyx注释
  986. memcpy(&RectierToTouchNetNode, paraNode, sizeof(RECTIERTOTOUCHNET));
  987. NodeID = paraNode->m_NodeID;
  988. }
  989. void tgPowerNode::setRectierToRailway(const RECTIERTORAILWAY* paraNode)
  990. {
  991. nodeType = NodeType::eDc_NodeKind_RectierToRailWay; //直流负极母线节点 xyx注释
  992. memcpy(&RectierToRailwayNode, paraNode, sizeof(RECTIERTORAILWAY));
  993. NodeID = paraNode->m_NodeID;
  994. //m_NodeV=0; //xyx新增 负极母线初始电压为0
  995. }
  996. void tgPowerNode::setRailway(const RAILWAY* paraNode)
  997. {
  998. nodeType = NodeType::eDc_NodeKind_RailWay; //轨道节点 xyx注释
  999. memcpy(&RailWayNode, paraNode, sizeof(RAILWAY));
  1000. NodeID = paraNode->m_NodeID;
  1001. //m_NodeV=0; //xyx新增 轨道初始电压为0
  1002. }
  1003. void tgPowerNode::setHeadTail(const HEADTAIL* paraNode)
  1004. {
  1005. nodeType = NodeType::eDc_NodeKind_HeadTail; //轨道头尾节点 xyx注释
  1006. memcpy(&HeadTailNode, paraNode, sizeof(HEADTAIL));
  1007. NodeID = paraNode->m_NodeID;
  1008. }
  1009. void tgPowerNode::setTrianOnLine(const TRIANONLINE* paraNode)
  1010. {
  1011. nodeType = NodeType::eDc_NodeKind_UpTrain;//上行列车 //列车受电弓节点 xyx注释
  1012. memcpy(&TrianOnLineNode, paraNode, sizeof(TRIANONLINE));
  1013. NodeID = paraNode->m_NodeID;
  1014. }
  1015. void tgPowerNode::setTrianOnRailway(const TRIANONRAILWAY* paraNode)
  1016. {
  1017. nodeType = NodeType::eDc_NodeKind_DownTrain;//下行列车 //列车轮对节点 xyx注释
  1018. memcpy(&TrianOnRailway, paraNode, sizeof(TRIANONRAILWAY));
  1019. NodeID = paraNode->m_NodeID;
  1020. m_NodeV = 0;
  1021. }