StaticData.cpp 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205
  1. /**************************************************************************************************
  2. 版本所有(C), 2020-2022, 北京普达迪泰
  3. ***************************************************************************************************
  4. 文 件 名: StaticData.h
  5. 功能描述: Static Task任务报告数据
  6. 版 本 号: 1.00初版
  7. 作 者: HYF
  8. 生成日期; 2021-12-20
  9. 最近修改:
  10. 函数列表:
  11. 修改历史:
  12. 1.日 期 :2021-12-20
  13. 作 者 : HYF
  14. 修改内容 : 创建文件
  15. **************************************************************************************************/
  16. #include "pch.h"
  17. #include <afx.h>
  18. #include <afxtempl.h>
  19. #include "StaticData.h"
  20. #include "EquipDataManager.h"
  21. #include "DictManager.h"
  22. #include "EquipDataPointManager.h"
  23. #include "EquipDataCircleManager.h"
  24. #include "EquipDataPlaneManager.h"
  25. #include "EquipDataLineManager.h"
  26. #include "EquipDataCylinderManager.h"
  27. #include "EquipDataAngleManager.h"
  28. #include "EquipDataPointRelatedManager.h"
  29. #include "EquipData.h"
  30. #include "EquipDataPlane.h"
  31. #include "EquipDataCircle.h"
  32. #include "EquipDataLine.h"
  33. #include "EquipDataPoint.h"
  34. #include "EquipDataCylinder.h"
  35. #include "EquipDataAngle.h"
  36. #include "EquipDataPointRelated.h"
  37. #include "Utils.h"
  38. // StaticData
  39. StaticData::StaticData(DWORD iTaskId, LPCTSTR szEquipTypeCode, LPCTSTR szEquipCode)
  40. : m_iTaskId(iTaskId)
  41. , m_szEquipTypeCode(szEquipTypeCode)
  42. , m_szEquipCode(szEquipCode)
  43. {
  44. m_pDictManager = new DictManager();
  45. }
  46. StaticData::~StaticData()
  47. {
  48. if (NULL != m_pDictManager) {
  49. delete m_pDictManager;
  50. m_pDictManager = NULL;
  51. }
  52. }
  53. /**************************************************************************************************
  54. 函 数 名 :LoadDataFromFile
  55. 功能描述 :从IDPMS报告加载数据
  56. 输入参数 :无
  57. 输出参数 :无
  58. 返 回 值 :void
  59. **************************************************************************************************/
  60. BOOL StaticData::LoadDataFromFile(LPCTSTR szFile)
  61. {
  62. CStdioFile file;
  63. CFileException e;
  64. CString szErr;
  65. CString szFilePath;
  66. DWORD pos=0;
  67. if (!file.Open(szFile, CFile::typeText|CFile::modeRead))
  68. {
  69. LOG::E(_T("静态数据文件打不开"));
  70. return FALSE;
  71. }
  72. int iType = 1;
  73. int iItemId = 0;
  74. int iSubItemId = 0;
  75. BOOL bRet = TRUE;
  76. CString szLine;
  77. while (TRUE) {
  78. if (!file.ReadString(szLine)) break;
  79. if ((szLine.Find(_T("点名称")) >= 0) && (iType == 1))
  80. {
  81. AddEquipItemData(iType);
  82. bRet = this->ParsePoint(&file);
  83. if (!bRet) break;
  84. }
  85. else if (szLine.Find(_T("点残差")) >= 0)
  86. {
  87. bRet = this->ParsePointRelated(&file, iType);
  88. if (!bRet) break;
  89. }
  90. else if (szLine.Find(_T("平面:")) >= 0)
  91. {
  92. iType = 2;
  93. AddEquipItemData(iType);
  94. bRet = this->ParsePlane(&file, szLine);
  95. if (!bRet) break;
  96. }
  97. else if (szLine.Find(_T("Circle:")) >= 0)
  98. {
  99. iType = 3;
  100. AddEquipItemData(iType);
  101. bRet = this->ParseCircle(&file, szLine);
  102. if (!bRet) break;
  103. }
  104. else if (szLine.Find(_T("直线:")) >= 0)
  105. {
  106. iType = 4;
  107. AddEquipItemData(iType);
  108. bRet = this->ParseLine(&file, szLine);
  109. if (!bRet) break;
  110. }
  111. else if (szLine.Find(_T("圆柱:")) >= 0)
  112. {
  113. iType = 5;
  114. AddEquipItemData(iType);
  115. bRet = this->ParseCylinder(&file, szLine);
  116. if (!bRet) break;
  117. }
  118. }
  119. // 关闭文件
  120. file.Close();
  121. return bRet;
  122. }
  123. /**************************************************************************************************
  124. 函 数 名 :ParsePoint
  125. 功能描述 :解析Point行
  126. 输入参数 :无
  127. 输出参数 :无
  128. 返 回 值 :void
  129. **************************************************************************************************/
  130. BOOL StaticData::ParsePoint(CStdioFile *pFile)
  131. {
  132. EquipDataPoint *pPoint = NULL;
  133. CStringArray szArray;
  134. CString szLine;
  135. DWORD iSubItemId = 0;
  136. while (pFile->ReadString(szLine)) {
  137. if (szLine.IsEmpty()) return TRUE;
  138. int iNum = Utils::StrSplit(szLine, ' ', szArray);
  139. if (iNum < 2) continue;
  140. CString szPointTitle(szArray.GetAt(0));
  141. CString szPointCode(szArray.GetAt(0));
  142. CString szPointAX = szArray.GetAt(1);
  143. CString szPointAY = szArray.GetAt(2);
  144. CString szPointAZ = szArray.GetAt(3);
  145. CString szPointTotal = szArray.GetAt(7);
  146. DOUBLE pointAX = atof(szPointAX.GetBuffer());
  147. DOUBLE pointAY = atof(szPointAY.GetBuffer());
  148. DOUBLE pointAZ = atof(szPointAZ.GetBuffer());
  149. DOUBLE pointTotal = atof(szPointTotal.GetBuffer());
  150. // SubItemId
  151. iSubItemId = (DWORD)m_PointList.GetCount() + 1;
  152. // 新增
  153. pPoint = new EquipDataPoint();
  154. pPoint->SetTaskId(m_iTaskId);
  155. pPoint->SetEquipCode(m_szEquipCode);
  156. pPoint->SetItemId(1);
  157. pPoint->SetSubItemId(iSubItemId);
  158. pPoint->SetPointTitle(m_pDictManager->GetDictItemTitle(szPointCode, szPointCode));
  159. pPoint->SetPointCode(szPointCode);
  160. pPoint->SetPointAX(pointAX);
  161. pPoint->SetPointAY(pointAY);
  162. pPoint->SetPointAZ(pointAZ);
  163. pPoint->SetPointTotal(pointTotal);
  164. m_PointList.AddTail(pPoint);
  165. }
  166. return TRUE;
  167. }
  168. /**************************************************************************************************
  169. 函 数 名 :ParsePlane
  170. 功能描述 :解析Plane行
  171. 输入参数 :无
  172. 输出参数 :无
  173. 返 回 值 :void
  174. **************************************************************************************************/
  175. BOOL StaticData::ParsePlane(CStdioFile *pFile, CString& szTitleLine)
  176. {
  177. CStringArray szTitleArray;
  178. int iNum = Utils::StrSplit(szTitleLine, ' ', szTitleArray);
  179. CString szPlaneCode(szTitleArray.GetAt(1));
  180. CStringArray szArray;
  181. DWORD iSubItemId = (DWORD)m_PlaneList.GetCount()+1;
  182. CString szLine;
  183. EquipDataPlane* pPlane = new EquipDataPlane();
  184. while (pFile->ReadString(szLine)) {
  185. if (szLine.IsEmpty()) break;
  186. iNum = Utils::StrSplit(szLine, ' ', szArray);
  187. if (iNum < 2) continue;
  188. CString szParam = szArray.GetAt(0);
  189. if (szParam.CompareNoCase("A:") == 0)
  190. {
  191. CString szA = szArray.GetAt(1);
  192. DOUBLE fA = atof(szA.GetBuffer());
  193. pPlane->SetPlaneA(fA);
  194. }
  195. else if (szParam.CompareNoCase("B:") == 0)
  196. {
  197. CString szB = szArray.GetAt(1);
  198. DOUBLE fB = atof(szB.GetBuffer());
  199. pPlane->SetPlaneB(fB);
  200. }
  201. else if (szParam.CompareNoCase("C:") == 0)
  202. {
  203. CString szC = szArray.GetAt(1);
  204. DOUBLE fC = atof(szC.GetBuffer());
  205. pPlane->SetPlaneC(fC);
  206. }
  207. else if (szParam.CompareNoCase("D:") == 0)
  208. {
  209. CString szD = szArray.GetAt(1);
  210. DOUBLE fD = atof(szD.GetBuffer());
  211. pPlane->SetPlaneD(fD);
  212. }
  213. else if (szParam.CompareNoCase("RMS:") == 0)
  214. {
  215. CString szRMS = szArray.GetAt(1);
  216. DOUBLE fRMS = atof(szRMS.GetBuffer());
  217. pPlane->SetPlaneRMS(fRMS);
  218. }
  219. }
  220. pPlane->SetTaskId(m_iTaskId);
  221. pPlane->SetEquipCode(m_szEquipCode);
  222. pPlane->SetPlaneTitle(m_pDictManager->GetDictItemTitle(szPlaneCode, szPlaneCode));
  223. pPlane->SetPlaneCode(szPlaneCode);
  224. pPlane->SetItemId(2);
  225. pPlane->SetSubItemId(iSubItemId);
  226. m_PlaneList.AddTail(pPlane);
  227. return TRUE;
  228. }
  229. /**************************************************************************************************
  230. 函 数 名 :ParseCircle
  231. 功能描述 :解析Circle行
  232. 输入参数 :无
  233. 输出参数 :无
  234. 返 回 值 :void
  235. **************************************************************************************************/
  236. BOOL StaticData::ParseCircle(CStdioFile *pFile, CString& szTitleLine )
  237. {
  238. CStringArray szTitleArray;
  239. int iNum = Utils::StrSplit(szTitleLine, ' ', szTitleArray);
  240. CString szCircleCode(szTitleArray.GetAt(1));
  241. CStringArray szArray;
  242. CString szLine;
  243. DWORD iSubItemId = (DWORD)m_CircleList.GetCount()+1;
  244. EquipDataCircle *pCircle = new EquipDataCircle();
  245. while (pFile->ReadString(szLine)) {
  246. if (szLine.IsEmpty()) break;
  247. iNum = Utils::StrSplit(szLine, ' ', szArray);
  248. if (iNum < 2) continue;
  249. CString szParam = szArray.GetAt(0);
  250. if (szParam.CompareNoCase("中心点:") == 0) {
  251. CString szCCX = szArray.GetAt(1);
  252. CString szCCY = szArray.GetAt(2);
  253. CString szCCZ = szArray.GetAt(3);
  254. DOUBLE fCCX = atof(szCCX.GetBuffer());
  255. DOUBLE fCCY = atof(szCCY.GetBuffer());
  256. DOUBLE fCCZ = atof(szCCZ.GetBuffer());
  257. pCircle->SetCircleCenterX(fCCX);
  258. pCircle->SetCircleCenterY(fCCY);
  259. pCircle->SetCircleCenterZ(fCCZ);
  260. }
  261. else if(szParam.CompareNoCase("半径:") == 0)
  262. {
  263. CString szRadius = szArray.GetAt(1);
  264. DOUBLE fRadius = atof(szRadius);
  265. pCircle->SetCircleRadius(fRadius);
  266. }
  267. else if(szParam.CompareNoCase("总RMS:") == 0)
  268. {
  269. CString szRMS = szArray.GetAt(1);
  270. DOUBLE fRMS = atof(szRMS);
  271. pCircle->SetCircleRMS(fRMS);
  272. }
  273. }
  274. pCircle->SetTaskId(m_iTaskId);
  275. pCircle->SetEquipCode(m_szEquipCode);
  276. pCircle->SetCircleTitle(m_pDictManager->GetDictItemTitle(szCircleCode, szCircleCode));
  277. pCircle->SetCircleCode(szCircleCode);
  278. pCircle->SetItemId(3);
  279. pCircle->SetSubItemId(iSubItemId);
  280. m_CircleList.AddTail(pCircle);
  281. return TRUE;
  282. }
  283. /**************************************************************************************************
  284. 函 数 名 :ParseLine
  285. 功能描述 :解析Line行
  286. 输入参数 :无
  287. 输出参数 :无
  288. 返 回 值 :void
  289. **************************************************************************************************/
  290. BOOL StaticData::ParseLine(CStdioFile *pFile, CString& szTitleLine )
  291. {
  292. CStringArray szTitleArray;
  293. int iNum = Utils::StrSplit(szTitleLine, ' ', szTitleArray);
  294. CString szLineCode(szTitleArray.GetAt(1));
  295. CStringArray szArray;
  296. CString szLine;
  297. DWORD iSubItemId = (DWORD)m_LineList.GetCount()+1;
  298. EquipDataLine *pLine = new EquipDataLine();
  299. while (pFile->ReadString(szLine)) {
  300. if (szLine.IsEmpty()) break;
  301. iNum = Utils::StrSplit(szLine, ' ', szArray);
  302. if (iNum < 2) continue;
  303. CString szParam = szArray.GetAt(0);
  304. if (szParam.CompareNoCase("方向向量:") == 0) {
  305. CString szVecX = szArray.GetAt(1);
  306. CString szVecY = szArray.GetAt(2);
  307. CString szVecZ = szArray.GetAt(3);
  308. DOUBLE fVecX = atof(szVecX.GetBuffer());
  309. DOUBLE fVecY = atof(szVecY.GetBuffer());
  310. DOUBLE fVecZ = atof(szVecZ.GetBuffer());
  311. pLine->SetLineVectorX(fVecX);
  312. pLine->SetLineVectorY(fVecY);
  313. pLine->SetLineVectorZ(fVecZ);
  314. }
  315. else if (szParam.CompareNoCase("终点1:") == 0) {
  316. CString szStartX = szArray.GetAt(1);
  317. CString szStartY = szArray.GetAt(2);
  318. CString szStartZ = szArray.GetAt(3);
  319. DOUBLE fStartX = atof(szStartX.GetBuffer());
  320. DOUBLE fStartY = atof(szStartY.GetBuffer());
  321. DOUBLE fStartZ = atof(szStartZ.GetBuffer());
  322. pLine->SetLineStartX(fStartX);
  323. pLine->SetLineStartY(fStartY);
  324. pLine->SetLineStartZ(fStartZ);
  325. }
  326. else if (szParam.CompareNoCase("终点2:") == 0) {
  327. CString szEndX = szArray.GetAt(1);
  328. CString szEndY = szArray.GetAt(2);
  329. CString szEndZ = szArray.GetAt(3);
  330. DOUBLE fEndX = atof(szEndX.GetBuffer());
  331. DOUBLE fEndY = atof(szEndY.GetBuffer());
  332. DOUBLE fEndZ = atof(szEndZ.GetBuffer());
  333. pLine->SetLineEndX(fEndX);
  334. pLine->SetLineEndY(fEndY);
  335. pLine->SetLineEndZ(fEndZ);
  336. }
  337. else if(szParam.CompareNoCase("长度:") == 0)
  338. {
  339. CString szLength = szArray.GetAt(1);
  340. DOUBLE fLength = atof(szLength);
  341. pLine->SetLineLength(fLength);
  342. }
  343. }
  344. pLine->SetTaskId(m_iTaskId);
  345. pLine->SetEquipCode(m_szEquipCode);
  346. pLine->SetLineTitle(m_pDictManager->GetDictItemTitle(szLineCode, szLineCode));
  347. pLine->SetLineCode(szLineCode);
  348. pLine->SetItemId(4);
  349. pLine->SetSubItemId(iSubItemId);
  350. m_LineList.AddTail(pLine);
  351. return TRUE;
  352. }
  353. /**************************************************************************************************
  354. 函 数 名 :ParseCylinder
  355. 功能描述 :解析Cylinder行
  356. 输入参数 :无
  357. 输出参数 :无
  358. 返 回 值 :void
  359. **************************************************************************************************/
  360. BOOL StaticData::ParseCylinder(CStdioFile *pFile, CString& szTitleLine)
  361. {
  362. CStringArray szTitleArray;
  363. int iNum = Utils::StrSplit(szTitleLine, ' ', szTitleArray);
  364. CString szCylinderCode(szTitleArray.GetAt(1));
  365. CStringArray szArray;
  366. CString szLine;
  367. DWORD iSubItemId = (DWORD)m_CylinderList.GetCount()+1;
  368. EquipDataCylinder *pCylinder = new EquipDataCylinder();
  369. while (pFile->ReadString(szLine)) {
  370. if (szLine.IsEmpty()) break;
  371. iNum = Utils::StrSplit(szLine, ' ', szArray);
  372. CString szParam = szArray.GetAt(0);
  373. if (szParam.CompareNoCase("终点1:") == 0) {
  374. CString szP1X = szArray.GetAt(1);
  375. CString szP1Y = szArray.GetAt(2);
  376. CString szP1Z = szArray.GetAt(3);
  377. DOUBLE fP1X = atof(szP1X.GetBuffer());
  378. DOUBLE fP1Y = atof(szP1Y.GetBuffer());
  379. DOUBLE fP1Z = atof(szP1Z.GetBuffer());
  380. pCylinder->SetPoint1X(fP1X);
  381. pCylinder->SetPoint1Y(fP1Y);
  382. pCylinder->SetPoint1Z(fP1Z);
  383. }
  384. else if (szParam.CompareNoCase("终点2:") == 0) {
  385. CString szP2X = szArray.GetAt(1);
  386. CString szP2Y = szArray.GetAt(2);
  387. CString szP2Z = szArray.GetAt(3);
  388. DOUBLE fP2X = atof(szP2X.GetBuffer());
  389. DOUBLE fP2Y = atof(szP2Y.GetBuffer());
  390. DOUBLE fP2Z = atof(szP2Z.GetBuffer());
  391. pCylinder->SetPoint2X(fP2X);
  392. pCylinder->SetPoint2Y(fP2Y);
  393. pCylinder->SetPoint2Z(fP2Z);
  394. }
  395. else if(szParam.CompareNoCase("半径:") == 0)
  396. {
  397. CString szRadius = szArray.GetAt(1);
  398. DOUBLE fRadius = atof(szRadius);
  399. pCylinder->SetCylinderRadius(fRadius);
  400. }
  401. else if(szParam.CompareNoCase("长度:") == 0)
  402. {
  403. CString szLength = szArray.GetAt(1);
  404. DOUBLE fLength = atof(szLength.GetBuffer());
  405. pCylinder->SetCylinderLength(fLength);
  406. }
  407. }
  408. pCylinder->SetTaskId(m_iTaskId);
  409. pCylinder->SetEquipCode(m_szEquipCode);
  410. pCylinder->SetCylinderTitle(m_pDictManager->GetDictItemTitle(szCylinderCode, szCylinderCode));
  411. pCylinder->SetCylinderCode(szCylinderCode);
  412. pCylinder->SetItemId(5);
  413. pCylinder->SetSubItemId(iSubItemId);
  414. m_CylinderList.AddTail(pCylinder);
  415. return TRUE;
  416. }
  417. void StaticData::AddAngle(EquipDataAngle *pNewAngle)
  418. {
  419. DWORD iSubItemId = (DWORD)m_AngleList.GetCount();
  420. pNewAngle->SetSubItemId(iSubItemId+1);
  421. m_AngleList.AddTail(pNewAngle);
  422. }
  423. /**************************************************************************************************
  424. 函 数 名 :ParsePointRelated
  425. 功能描述 :解析点残差
  426. 输入参数 :无
  427. 输出参数 :无
  428. 返 回 值 :void
  429. **************************************************************************************************/
  430. BOOL StaticData::ParsePointRelated(CStdioFile *pFile, int iType)
  431. {
  432. switch (iType) {
  433. case 2:
  434. this->ParsePlanePointRelated(pFile);
  435. break;
  436. case 3:
  437. this->ParseCirclePointRelated(pFile);
  438. break;
  439. case 4:
  440. this->ParseLinePointRelated(pFile);
  441. break;
  442. case 5:
  443. this->ParseCylinderPointRelated(pFile);
  444. break;
  445. }
  446. return TRUE;
  447. }
  448. // Plane Points related Parser
  449. BOOL StaticData::ParsePlanePointRelated(CStdioFile *pFile) {
  450. EquipDataPointRelated *pPointRelated = NULL;
  451. CStringArray szArray;
  452. CString szLine;
  453. int iItemId = 2;
  454. int iSubItemId;
  455. iSubItemId = (int)m_PlaneList.GetCount();
  456. while (pFile->ReadString(szLine)) {
  457. if (szLine.IsEmpty()) return TRUE;
  458. int iNum = Utils::StrSplit(szLine, ' ', szArray);
  459. CString szPointCode(szArray.GetAt(0));
  460. if ((iNum < 2) || (szPointCode.Compare("点名称") == 0)) continue;
  461. CString szPointTitle(szArray.GetAt(0));
  462. CString szPointAX = szArray.GetAt(1);
  463. CString szPointAY = szArray.GetAt(2);
  464. CString szPointAZ = szArray.GetAt(3);
  465. CString szDX = szArray.GetAt(4);
  466. CString szDY = szArray.GetAt(5);
  467. CString szDZ = szArray.GetAt(6);
  468. CString szTotal = szArray.GetAt(7);
  469. CString szOffset = szArray.GetAt(8);
  470. DOUBLE fPointAX = atof(szPointAX.GetBuffer());
  471. DOUBLE fPointAY = atof(szPointAY.GetBuffer());
  472. DOUBLE fPointAZ = atof(szPointAZ.GetBuffer());
  473. DOUBLE fDX = atof(szDX.GetBuffer());
  474. DOUBLE fDY = atof(szDY.GetBuffer());
  475. DOUBLE fDZ = atof(szDZ.GetBuffer());
  476. DOUBLE fTotal = atof(szTotal.GetBuffer());
  477. DOUBLE fOffset = atof(szOffset.GetBuffer());
  478. // 1.查询点数据是否存在,如果不存在则保存
  479. EquipDataPoint *pPoint = this->SearchPointByCode(szPointCode);
  480. DWORD iPointSubItemId;
  481. if (!pPoint)
  482. {
  483. iPointSubItemId = (DWORD)m_PointList.GetCount() + 1;
  484. EquipDataPoint *pPoint = new EquipDataPoint();
  485. pPoint->SetItemId(1);
  486. pPoint->SetTaskId(m_iTaskId);
  487. pPoint->SetEquipCode(m_szEquipCode);
  488. pPoint->SetSubItemId(iPointSubItemId);
  489. pPoint->SetPointTitle(m_pDictManager->GetDictItemTitle(szPointCode, szPointCode));
  490. pPoint->SetPointCode(szPointCode);
  491. pPoint->SetPointAX(fPointAX);
  492. pPoint->SetPointAY(fPointAY);
  493. pPoint->SetPointAZ(fPointAZ);
  494. m_PointList.AddTail(pPoint);
  495. }
  496. else
  497. {
  498. iPointSubItemId = pPoint->GetSubItemId();
  499. }
  500. // 2.新增点列差到列表中
  501. pPointRelated = new EquipDataPointRelated();
  502. pPointRelated->SetTaskId(m_iTaskId);
  503. pPointRelated->SetEquipCode(m_szEquipCode);
  504. pPointRelated->SetItemId(iItemId);
  505. pPointRelated->SetSubItemId(iSubItemId);
  506. pPointRelated->SetItemType(2);
  507. pPointRelated->SetPointSubItemId(iPointSubItemId);
  508. pPointRelated->SetDX(fDX);
  509. pPointRelated->SetDY(fDY);
  510. pPointRelated->SetDZ(fDZ);
  511. pPointRelated->SetTotal(fTotal);
  512. pPointRelated->SetOffset(fOffset);
  513. m_PointRelatedList.AddTail(pPointRelated);
  514. }
  515. return TRUE;
  516. }
  517. // Circle Points related Parser
  518. BOOL StaticData::ParseCirclePointRelated(CStdioFile *pFile) {
  519. EquipDataPointRelated *pPointRelated = NULL;
  520. CStringArray szArray;
  521. CString szLine;
  522. int iItemId = 3;
  523. int iSubItemId;
  524. iSubItemId = (int)m_CircleList.GetCount();
  525. while (pFile->ReadString(szLine)) {
  526. if (szLine.IsEmpty()) return TRUE;
  527. int iNum = Utils::StrSplit(szLine, ' ', szArray);
  528. CString szPointCode(szArray.GetAt(0));
  529. if ((iNum < 2) || (szPointCode.Compare("点名称") == 0)) continue;
  530. CString szPointTitle(szArray.GetAt(0));
  531. CString szPointAX = szArray.GetAt(1);
  532. CString szPointAY = szArray.GetAt(2);
  533. CString szPointAZ = szArray.GetAt(3);
  534. CString szDX = szArray.GetAt(4);
  535. CString szDY = szArray.GetAt(5);
  536. CString szDZ = szArray.GetAt(6);
  537. CString szOnPlane = szArray.GetAt(7);
  538. CString szOutPlane = szArray.GetAt(8);
  539. CString szTotal = szArray.GetAt(9);
  540. CString szOffset = szArray.GetAt(10);
  541. DOUBLE fPointAX = atof(szPointAX.GetBuffer());
  542. DOUBLE fPointAY = atof(szPointAY.GetBuffer());
  543. DOUBLE fPointAZ = atof(szPointAZ.GetBuffer());
  544. DOUBLE fDX = atof(szDX.GetBuffer());
  545. DOUBLE fDY = atof(szDY.GetBuffer());
  546. DOUBLE fDZ = atof(szDZ.GetBuffer());
  547. DOUBLE fOnPlane = atof(szOnPlane.GetBuffer());
  548. DOUBLE fOutPlane = atof(szOutPlane.GetBuffer());
  549. DOUBLE fTotal = atof(szTotal.GetBuffer());
  550. DOUBLE fOffset = atof(szOffset.GetBuffer());
  551. // 1.查询点数据是否存在,如果不存在则保存
  552. EquipDataPoint *pPoint = this->SearchPointByCode(szPointCode);
  553. DWORD iPointSubItemId;
  554. if (!pPoint)
  555. {
  556. iPointSubItemId = (DWORD)m_PointList.GetCount() + 1;
  557. EquipDataPoint *pPoint = new EquipDataPoint();
  558. pPoint->SetTaskId(m_iTaskId);
  559. pPoint->SetItemId(1);
  560. pPoint->SetEquipCode(m_szEquipCode);
  561. pPoint->SetSubItemId(iPointSubItemId);
  562. pPoint->SetPointTitle(szPointTitle);
  563. pPoint->SetPointCode(szPointCode);
  564. pPoint->SetPointAX(fPointAX);
  565. pPoint->SetPointAY(fPointAY);
  566. pPoint->SetPointAZ(fPointAZ);
  567. m_PointList.AddTail(pPoint);
  568. }
  569. else
  570. {
  571. iPointSubItemId = pPoint->GetSubItemId();
  572. }
  573. // 2.新增点列差到列表中
  574. pPointRelated = new EquipDataPointRelated();
  575. pPointRelated->SetTaskId(m_iTaskId);
  576. pPointRelated->SetEquipCode(m_szEquipCode);
  577. pPointRelated->SetItemId(iItemId);
  578. pPointRelated->SetSubItemId(iSubItemId);
  579. pPointRelated->SetItemType(3);
  580. pPointRelated->SetPointSubItemId(iPointSubItemId);
  581. pPointRelated->SetDX(fDX);
  582. pPointRelated->SetDY(fDY);
  583. pPointRelated->SetDZ(fDZ);
  584. pPointRelated->SetOnPlane(fOnPlane);
  585. pPointRelated->SetOutPlane(fOutPlane);
  586. pPointRelated->SetTotal(fTotal);
  587. pPointRelated->SetOffset(fOffset);
  588. m_PointRelatedList.AddTail(pPointRelated);
  589. }
  590. return TRUE;
  591. }
  592. // Line Points related Parser
  593. BOOL StaticData::ParseLinePointRelated(CStdioFile *pFile) {
  594. EquipDataPointRelated *pPointRelated = NULL;
  595. CStringArray szArray;
  596. CString szLine;
  597. int iItemId = 4;
  598. int iSubItemId;
  599. iSubItemId = (int)m_LineList.GetCount();
  600. while (pFile->ReadString(szLine)) {
  601. if (szLine.IsEmpty()) return TRUE;
  602. int iNum = Utils::StrSplit(szLine, ' ', szArray);
  603. CString szPointCode(szArray.GetAt(0));
  604. if ((iNum < 2) || (szPointCode.Compare("点名称") == 0)) continue;
  605. CString szPointTitle(szArray.GetAt(0));
  606. CString szPointAX = szArray.GetAt(1);
  607. CString szPointAY = szArray.GetAt(2);
  608. CString szPointAZ = szArray.GetAt(3);
  609. CString szDX = szArray.GetAt(4);
  610. CString szDY = szArray.GetAt(5);
  611. CString szDZ = szArray.GetAt(6);
  612. CString szTotal = szArray.GetAt(7);
  613. CString szOffset = szArray.GetAt(8);
  614. DOUBLE fPointAX = atof(szPointAX.GetBuffer());
  615. DOUBLE fPointAY = atof(szPointAY.GetBuffer());
  616. DOUBLE fPointAZ = atof(szPointAZ.GetBuffer());
  617. DOUBLE fDX = atof(szDX.GetBuffer());
  618. DOUBLE fDY = atof(szDY.GetBuffer());
  619. DOUBLE fDZ = atof(szDZ.GetBuffer());
  620. DOUBLE fTotal = atof(szTotal.GetBuffer());
  621. DOUBLE fOffset = atof(szOffset.GetBuffer());
  622. // 1.查询点数据是否存在,如果不存在则保存
  623. EquipDataPoint *pPoint = this->SearchPointByCode(szPointCode);
  624. DWORD iPointSubItemId;
  625. if (!pPoint)
  626. {
  627. iPointSubItemId = (DWORD)m_PointList.GetCount() + 1;
  628. EquipDataPoint *pPoint = new EquipDataPoint();
  629. pPoint->SetTaskId(m_iTaskId);
  630. pPoint->SetItemId(1);
  631. pPoint->SetEquipCode(m_szEquipCode);
  632. pPoint->SetSubItemId(iPointSubItemId);
  633. pPoint->SetPointTitle(szPointTitle);
  634. pPoint->SetPointCode(szPointCode);
  635. pPoint->SetPointAX(fPointAX);
  636. pPoint->SetPointAY(fPointAY);
  637. pPoint->SetPointAZ(fPointAZ);
  638. m_PointList.AddTail(pPoint);
  639. }
  640. else
  641. {
  642. iPointSubItemId = pPoint->GetSubItemId();
  643. }
  644. // 2.新增点列差到列表中
  645. pPointRelated = new EquipDataPointRelated();
  646. pPointRelated->SetTaskId(m_iTaskId);
  647. pPointRelated->SetEquipCode(m_szEquipCode);
  648. pPointRelated->SetItemId(iItemId);
  649. pPointRelated->SetSubItemId(iSubItemId);
  650. pPointRelated->SetItemType(4);
  651. pPointRelated->SetPointSubItemId(iPointSubItemId);
  652. pPointRelated->SetDX(fDX);
  653. pPointRelated->SetDY(fDY);
  654. pPointRelated->SetDZ(fDZ);
  655. pPointRelated->SetTotal(fTotal);
  656. pPointRelated->SetOffset(fOffset);
  657. m_PointRelatedList.AddTail(pPointRelated);
  658. }
  659. return TRUE;
  660. }
  661. // Cylinder Points related Parser
  662. BOOL StaticData::ParseCylinderPointRelated(CStdioFile *pFile) {
  663. EquipDataPointRelated *pPointRelated = NULL;
  664. CStringArray szArray;
  665. CString szLine;
  666. int iItemId = 5;
  667. int iSubItemId;
  668. iSubItemId = (int)m_CylinderList.GetCount();
  669. while (pFile->ReadString(szLine)) {
  670. if (szLine.IsEmpty()) return TRUE;
  671. int iNum = Utils::StrSplit(szLine, ' ', szArray);
  672. CString szPointCode(szArray.GetAt(0));
  673. if ((iNum < 2) || (szPointCode.Compare("点名称") == 0)) continue;
  674. CString szPointTitle(szArray.GetAt(0));
  675. CString szPointAX = szArray.GetAt(1);
  676. CString szPointAY = szArray.GetAt(2);
  677. CString szPointAZ = szArray.GetAt(3);
  678. CString szDX = szArray.GetAt(4);
  679. CString szDY = szArray.GetAt(5);
  680. CString szDZ = szArray.GetAt(6);
  681. CString szTotal = szArray.GetAt(7);
  682. CString szOffset = szArray.GetAt(8);
  683. DOUBLE fPointAX = atof(szPointAX.GetBuffer());
  684. DOUBLE fPointAY = atof(szPointAY.GetBuffer());
  685. DOUBLE fPointAZ = atof(szPointAZ.GetBuffer());
  686. DOUBLE fDX = atof(szDX.GetBuffer());
  687. DOUBLE fDY = atof(szDY.GetBuffer());
  688. DOUBLE fDZ = atof(szDZ.GetBuffer());
  689. DOUBLE fTotal = atof(szTotal.GetBuffer());
  690. DOUBLE fOffset = atof(szOffset.GetBuffer());
  691. // 1.查询点数据是否存在,如果不存在则保存
  692. EquipDataPoint *pPoint = this->SearchPointByCode(szPointCode);
  693. DWORD iPointSubItemId;
  694. if (!pPoint)
  695. {
  696. iPointSubItemId = (DWORD)m_PointList.GetCount() + 1;
  697. EquipDataPoint *pPoint = new EquipDataPoint();
  698. pPoint->SetTaskId(m_iTaskId);
  699. pPoint->SetItemId(1);
  700. pPoint->SetEquipCode(m_szEquipCode);
  701. pPoint->SetSubItemId(iPointSubItemId);
  702. pPoint->SetPointTitle(szPointTitle);
  703. pPoint->SetPointCode(szPointCode);
  704. pPoint->SetPointAX(fPointAX);
  705. pPoint->SetPointAY(fPointAY);
  706. pPoint->SetPointAZ(fPointAZ);
  707. m_PointList.AddTail(pPoint);
  708. }
  709. else
  710. {
  711. iPointSubItemId = pPoint->GetSubItemId();
  712. }
  713. // 2.新增点列差到列表中
  714. pPointRelated = new EquipDataPointRelated();
  715. pPointRelated->SetTaskId(m_iTaskId);
  716. pPointRelated->SetEquipCode(m_szEquipCode);
  717. pPointRelated->SetItemId(iItemId);
  718. pPointRelated->SetSubItemId(iSubItemId);
  719. pPointRelated->SetItemType(5);
  720. pPointRelated->SetPointSubItemId(iPointSubItemId);
  721. pPointRelated->SetDX(fDX);
  722. pPointRelated->SetDY(fDY);
  723. pPointRelated->SetDZ(fDZ);
  724. pPointRelated->SetTotal(fTotal);
  725. pPointRelated->SetOffset(fOffset);
  726. m_PointRelatedList.AddTail(pPointRelated);
  727. }
  728. return TRUE;
  729. }
  730. /**************************************************************************************************
  731. 函 数 名 :SearchPointByCode
  732. 功能描述 :基于编号查询
  733. 输入参数 :无
  734. 输出参数 :无
  735. 返 回 值 :void
  736. **************************************************************************************************/
  737. EquipDataPoint* StaticData::SearchPointByCode(LPCTSTR szCode)
  738. {
  739. POSITION pos;
  740. EquipDataPoint *pPoint = NULL;
  741. pos = m_PointList.GetHeadPosition();
  742. while (pos != NULL)
  743. {
  744. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos);
  745. if (pPoint != NULL)
  746. {
  747. CString szPointCode = pPoint->GetPointCode();
  748. if (szPointCode.Compare(szCode) == 0)
  749. {
  750. return pPoint;
  751. }
  752. }
  753. }
  754. return NULL;
  755. }
  756. /**************************************************************************************************
  757. 函 数 名 :SearchPointByCode
  758. 功能描述 :基于编号查询
  759. 输入参数 :无
  760. 输出参数 :无
  761. 返 回 值 :void
  762. **************************************************************************************************/
  763. BOOL StaticData::IsEquipDataExist(int iType)
  764. {
  765. POSITION pos;
  766. EquipData *pData = NULL;
  767. BOOL bRet = TRUE;
  768. pos = m_DataList.GetHeadPosition();
  769. while (pos != NULL)
  770. {
  771. pData = (EquipData *)m_DataList.GetNext(pos);
  772. if (pData != NULL)
  773. {
  774. if ( pData->GetItemType() == iType)
  775. {
  776. return TRUE;
  777. }
  778. }
  779. }
  780. return FALSE;
  781. }
  782. /**************************************************************************************************
  783. 函 数 名 :AddEquipItemData
  784. 功能描述 :添加数据项到结构中
  785. 输入参数 :无
  786. 输出参数 :无
  787. 返 回 值 :void
  788. **************************************************************************************************/
  789. void StaticData::AddEquipItemData(int iType)
  790. {
  791. EquipData *pEquipData = NULL;
  792. if (IsEquipDataExist(iType)) return;
  793. pEquipData = new EquipData();
  794. pEquipData->SetTaskId(m_iTaskId);
  795. pEquipData->SetEquipCode(m_szEquipCode);
  796. pEquipData->SetItemType(iType);
  797. pEquipData->SetItemId(iType);
  798. if (iType == 1)
  799. {
  800. pEquipData->SetItemCode("Point");
  801. pEquipData->SetItemTitle("Point");
  802. pEquipData->SetItemDesc("Point");
  803. }
  804. else if (iType == 2) {
  805. pEquipData->SetItemCode("Plane");
  806. pEquipData->SetItemTitle("Plane");
  807. pEquipData->SetItemDesc("Plane");
  808. }
  809. else if (iType == 3)
  810. {
  811. pEquipData->SetItemCode("Circle");
  812. pEquipData->SetItemTitle("Circle");
  813. pEquipData->SetItemDesc("Circle");
  814. }
  815. else if (iType == 4)
  816. {
  817. pEquipData->SetItemCode("Line");
  818. pEquipData->SetItemTitle("Line");
  819. pEquipData->SetItemDesc("Line");
  820. }
  821. else if (iType == 5)
  822. {
  823. pEquipData->SetItemCode("Cylinder");
  824. pEquipData->SetItemTitle("Cylinder");
  825. pEquipData->SetItemDesc("Cylinder");
  826. }
  827. m_DataList.AddTail((EquipData *)pEquipData);
  828. }
  829. /**************************************************************************************************
  830. 函 数 名 :AddEquipSubItemData
  831. 功能描述 :添加子项数据到结构中
  832. 输入参数 :无
  833. 输出参数 :无
  834. 返 回 值 :void
  835. **************************************************************************************************/
  836. void StaticData::AddEquipSubItemData(int iType, void *pData)
  837. {
  838. if (iType == 1)
  839. {
  840. m_PointList.AddTail((EquipDataPoint *)pData);
  841. }
  842. else if (iType == 2)
  843. {
  844. m_PlaneList.AddTail((EquipDataPlane *)pData);
  845. }
  846. else if (iType == 3)
  847. {
  848. m_CircleList.AddTail((EquipDataCircle *)pData);
  849. }
  850. else if (iType == 4)
  851. {
  852. m_LineList.AddTail((EquipDataLine *)pData);
  853. }
  854. else if (iType == 5)
  855. {
  856. m_CylinderList.AddTail((EquipDataCylinder *)pData);
  857. }
  858. else if (iType == 6) // 点残差数据
  859. {
  860. }
  861. }
  862. /**************************************************************************************************
  863. 函 数 名 :Clear
  864. 功能描述 :清空数据
  865. 输入参数 :无
  866. 输出参数 :无
  867. 返 回 值 :void
  868. **************************************************************************************************/
  869. void StaticData::Clear()
  870. {
  871. while (!m_DataList.IsEmpty())
  872. {
  873. delete m_DataList.RemoveHead();
  874. }
  875. while (!m_PointList.IsEmpty())
  876. {
  877. delete m_PointList.RemoveHead();
  878. }
  879. while (!m_PlaneList.IsEmpty())
  880. {
  881. delete m_PlaneList.RemoveHead();
  882. }
  883. while (!m_CircleList.IsEmpty())
  884. {
  885. delete m_CircleList.RemoveHead();
  886. }
  887. while (!m_LineList.IsEmpty())
  888. {
  889. delete m_LineList.RemoveHead();
  890. }
  891. while (!m_CylinderList.IsEmpty())
  892. {
  893. delete m_CylinderList.RemoveHead();
  894. }
  895. while (!m_AngleList.IsEmpty())
  896. {
  897. delete m_AngleList.RemoveHead();
  898. }
  899. while (!m_PointRelatedList.IsEmpty())
  900. {
  901. delete m_PointRelatedList.RemoveHead();
  902. }
  903. }
  904. /**************************************************************************************************
  905. 函 数 名 :CalcPointFlatness
  906. 功能描述 :计算平面度
  907. 输入参数 :无
  908. 输出参数 :无
  909. 返 回 值 :void
  910. **************************************************************************************************/
  911. void StaticData::CalcPointFlatness()
  912. {
  913. EquipDataPlane *pPlane = NULL;
  914. POSITION pos1;
  915. pos1 = m_PlaneList.GetHeadPosition();
  916. while (pos1 != NULL)
  917. {
  918. pPlane = (EquipDataPlane *)m_PlaneList.GetNext(pos1);
  919. if (pPlane != NULL)
  920. {
  921. DWORD itemId1 = pPlane->GetItemId();
  922. DWORD subItemId1 = pPlane->GetSubItemId();
  923. EquipDataPointRelated *pPointRelated = NULL;
  924. DOUBLE fMax = 0.0;
  925. DOUBLE fMin = 0.0;
  926. // 1.获取结点
  927. POSITION pos2;
  928. pos2 = m_PointRelatedList.GetHeadPosition();
  929. while (pos2 != NULL)
  930. {
  931. pPointRelated = (EquipDataPointRelated *)m_PointRelatedList.GetNext(pos2);
  932. if (pPointRelated != NULL)
  933. {
  934. DWORD itemId2 = pPointRelated->GetItemId();
  935. DWORD subItemId2 = pPointRelated->GetSubItemId();
  936. DWORD pointId1 = pPointRelated->GetPointSubItemId();
  937. DWORD itemType = pPointRelated->GetItemType();
  938. if ((itemType == 2)&&(itemId1 == itemId2) && (subItemId1 == subItemId2))
  939. {
  940. DOUBLE fTotal = pPointRelated->GetTotal();
  941. if (fTotal > fMax) fMax = fTotal;
  942. if (fTotal < fMin) fMin = fTotal;
  943. }
  944. }
  945. }
  946. // 平面度 = 点总计最大值 - 点总计最小值
  947. pPlane->SetPlaneFlatness(fMax - fMin);
  948. }
  949. }
  950. return;
  951. }
  952. /**************************************************************************************************
  953. 函 数 名 :CalcPointFlatness
  954. 功能描述 :计算圆度
  955. 输入参数 :无
  956. 输出参数 :无
  957. 返 回 值 :void
  958. **************************************************************************************************/
  959. void StaticData::CalcCircleRoundness()
  960. {
  961. EquipDataCircle *pCircle = NULL;
  962. POSITION pos1;
  963. pos1 = m_CircleList.GetHeadPosition();
  964. while (pos1 != NULL)
  965. {
  966. pCircle = (EquipDataCircle *)m_CircleList.GetNext(pos1);
  967. if (pCircle != NULL)
  968. {
  969. DWORD itemId1 = pCircle->GetItemId();
  970. DWORD subItemId1 = pCircle->GetSubItemId();
  971. EquipDataPointRelated *pPointRelated = NULL;
  972. DOUBLE fMax = 0.0;
  973. DOUBLE fMin = 0.0;
  974. // 1.获取结点
  975. POSITION pos2;
  976. pos2 = m_PointRelatedList.GetHeadPosition();
  977. while (pos2 != NULL)
  978. {
  979. pPointRelated = (EquipDataPointRelated *)m_PointRelatedList.GetNext(pos2);
  980. if (pPointRelated != NULL)
  981. {
  982. DWORD itemId2 = pPointRelated->GetItemId();
  983. DWORD subItemId2 = pPointRelated->GetSubItemId();
  984. DWORD pointId1 = pPointRelated->GetPointSubItemId();
  985. DWORD iItemType = pPointRelated->GetItemType();
  986. if ((iItemType == 3 )&&(itemId1 == itemId2) && (subItemId1 == subItemId2))
  987. {
  988. DOUBLE fOnPlane = pPointRelated->GetOnPlane();
  989. if (fOnPlane > fMax) fMax = fOnPlane;
  990. if (fOnPlane < fMin) fMin = fOnPlane;
  991. }
  992. }
  993. }
  994. // 圆度 = 点总计最大值 - 点总计最小值
  995. pCircle->SetCircleRoundness(fMax - fMin);
  996. }
  997. }
  998. return;
  999. }
  1000. /**************************************************************************************************
  1001. 函 数 名 :GetAngleParam
  1002. 功能描述 :新增推力线偏角
  1003. 输入参数 :无
  1004. 输出参数 :无
  1005. 返 回 值 :void
  1006. **************************************************************************************************/
  1007. void StaticData::GenerateAngle()
  1008. {
  1009. CString szCylinderCode = AppConfig::GetString("Static", "Cylinder");
  1010. CString szPointCode = AppConfig::GetString("Static", "Point1");
  1011. //this->HandleAngle("cl1", "CODE489");
  1012. this->HandleAngle(szCylinderCode, szPointCode);
  1013. }
  1014. /**************************************************************************************************
  1015. 函 数 名 :GetAngleParam
  1016. 功能描述 :新增推力线偏角
  1017. 输入参数 :无
  1018. 输出参数 :无
  1019. 返 回 值 :void
  1020. **************************************************************************************************/
  1021. void StaticData::GenerateAngleText()
  1022. {
  1023. int i = 1;
  1024. CString Cylinder;
  1025. CString Point;
  1026. while (i < 5) {
  1027. Cylinder.Format("Cylinder%d", i);
  1028. Point.Format("Point%d", i);
  1029. CString szCylinderCode = AppConfig::GetString("Static", Cylinder);
  1030. CString szPointCode = AppConfig::GetString("Static", Point);
  1031. this->HandleAngle(szCylinderCode, szPointCode);
  1032. i++;
  1033. }
  1034. }
  1035. /**************************************************************************************************
  1036. 函 数 名 :GenerateDoublePoint
  1037. 功能描述 :新增两点式推力线偏角
  1038. 输入参数 :无
  1039. 输出参数 :无
  1040. 返 回 值 :void
  1041. **************************************************************************************************/
  1042. void StaticData::GenerateDoublePoint()
  1043. {
  1044. int i = 1;
  1045. CString StartPoint;
  1046. CString EndPoint;
  1047. while (i < 5) {
  1048. StartPoint.Format("SPoint%d", i);
  1049. EndPoint.Format("EPoint%d", i);
  1050. CString szPointCodeStart = AppConfig::GetString("Static", StartPoint);
  1051. CString szPointCodeEnd = AppConfig::GetString("Static", EndPoint);
  1052. this->HandleAngleDoublePoint(szPointCodeStart, szPointCodeEnd);
  1053. i++;
  1054. }
  1055. }
  1056. /**************************************************************************************************
  1057. 函 数 名 :GetAngleParam
  1058. 功能描述 :新增推力线偏角
  1059. 输入参数 :无
  1060. 输出参数 :无
  1061. 返 回 值 :void
  1062. **************************************************************************************************/
  1063. void StaticData::HandleAngle(LPCTSTR szTargetCylinderCode, LPCTSTR szTargetPointCode)
  1064. {
  1065. DOUBLE x1 = 0.0;
  1066. DOUBLE y1 = 0.0;
  1067. DOUBLE z1 = 0.0;
  1068. DOUBLE x2 = 0.0;
  1069. DOUBLE y2 = 0.0;
  1070. DOUBLE z2 = 0.0;
  1071. CString m_linecode;
  1072. CString m_pointcode;
  1073. bool bExist = false;
  1074. // 1. Cylinder
  1075. POSITION pos1;
  1076. EquipDataCylinder *pCylinder = NULL;
  1077. pos1 = m_CylinderList.GetHeadPosition();
  1078. while (pos1 != NULL)
  1079. {
  1080. pCylinder = (EquipDataCylinder *)m_CylinderList.GetNext(pos1);
  1081. if (pCylinder == NULL) break;
  1082. CString szCylinderCode = pCylinder->GetCylinderCode();
  1083. if (szCylinderCode.Compare(szTargetCylinderCode) == 0)
  1084. {
  1085. DOUBLE point1x = pCylinder->GetPoint1X();
  1086. DOUBLE point1y = pCylinder->GetPoint1Y();
  1087. DOUBLE point1z = pCylinder->GetPoint1Z();
  1088. DOUBLE point2x = pCylinder->GetPoint2X();
  1089. DOUBLE point2y = pCylinder->GetPoint2Y();
  1090. DOUBLE point2z = pCylinder->GetPoint2Z();
  1091. x1 = (point1x + point2x) / 2;
  1092. y1 = (point1y + point2y) / 2;
  1093. z1 = (point1z + point2z) / 2;
  1094. bExist = true;
  1095. break;
  1096. }
  1097. }
  1098. if (!bExist) return;
  1099. // 2.Point
  1100. POSITION pos2;
  1101. EquipDataPoint *pPoint = NULL;
  1102. pos2 = m_PointList.GetHeadPosition();
  1103. while (pos2 != NULL)
  1104. {
  1105. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos2);
  1106. if (pPoint == NULL) break;
  1107. CString szPointCode = pPoint->GetPointCode();
  1108. if (szPointCode.Compare(szTargetPointCode) == 0)
  1109. {
  1110. x2 = pPoint->GetPointAX();
  1111. y2 = pPoint->GetPointAY();
  1112. z2 = pPoint->GetPointAZ();
  1113. break;
  1114. }
  1115. }
  1116. m_linecode.Format("%s & %s", szTargetCylinderCode, szTargetPointCode);
  1117. m_pointcode.Format("%sO", szTargetCylinderCode);
  1118. //3.
  1119. DWORD iTaskId = pPoint->GetTaskId();
  1120. CString szEquipCode = pPoint->GetEquipCode();
  1121. DWORD iPointSubItemId = m_PointList.GetCount()+1;
  1122. DWORD iCylinderSubItemId = pCylinder->GetSubItemId();
  1123. EquipDataPoint *pCyCenter = new EquipDataPoint();
  1124. pCyCenter->SetTaskId(iTaskId);
  1125. pCyCenter->SetEquipCode(szEquipCode);
  1126. pCyCenter->SetItemId(1);
  1127. pCyCenter->SetSubItemId(iPointSubItemId);
  1128. pCyCenter->SetPointCode(m_pointcode);
  1129. pCyCenter->SetPointTitle(m_pointcode);
  1130. pCyCenter->SetPointAX(x1);
  1131. pCyCenter->SetPointAY(y1);
  1132. pCyCenter->SetPointAZ(z1);
  1133. pCyCenter->SetPointEX(0.0);
  1134. pCyCenter->SetPointEY(0.0);
  1135. pCyCenter->SetPointEZ(0.0);
  1136. pCyCenter->SetPointDesc("");
  1137. m_PointList.AddTail(pCyCenter);
  1138. //4.
  1139. EquipDataPointRelated* pCyRelated = new EquipDataPointRelated();
  1140. pCyRelated->SetTaskId(iTaskId);
  1141. pCyRelated->SetEquipCode(szEquipCode);
  1142. pCyRelated->SetItemId(5);
  1143. pCyRelated->SetItemType(5);
  1144. pCyRelated->SetSubItemId(iCylinderSubItemId);
  1145. pCyRelated->SetPointSubItemId(iPointSubItemId);
  1146. pCyRelated->SetDX(0.0);
  1147. pCyRelated->SetDY(0.0);
  1148. pCyRelated->SetDZ(0.0);
  1149. pCyRelated->SetTotal(0.0);
  1150. pCyRelated->SetOffset(0.0);
  1151. pCyRelated->SetOnPlane(0.0);
  1152. pCyRelated->SetOutPlane(0.0);
  1153. m_PointRelatedList.AddTail(pCyRelated);
  1154. if (x1 != 0 && x2 != 0)
  1155. {
  1156. this->CalcAngle(m_linecode,x1, y1, z1, x2, y2, z2);
  1157. }
  1158. return;
  1159. }
  1160. /**************************************************************************************************
  1161. 函 数 名 :GetAngleParam
  1162. 功能描述 :新增推力线偏角两点式
  1163. 输入参数 :无
  1164. 输出参数 :无
  1165. 返 回 值 :void
  1166. **************************************************************************************************/
  1167. void StaticData::HandleAngleDoublePoint(LPCTSTR szPointCodeStart, LPCTSTR szPointCodeEnd)
  1168. {
  1169. DOUBLE x1 = 0.0;
  1170. DOUBLE y1 = 0.0;
  1171. DOUBLE z1 = 0.0;
  1172. DOUBLE x2 = 0.0;
  1173. DOUBLE y2 = 0.0;
  1174. DOUBLE z2 = 0.0;
  1175. CString count;
  1176. // 1. PointStart
  1177. POSITION pos1;
  1178. EquipDataPoint *pPoint = NULL;
  1179. pos1 = m_PointList.GetHeadPosition();
  1180. while (pos1 != NULL)
  1181. {
  1182. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos1);
  1183. if (pPoint == NULL) break;
  1184. CString szPointCode = pPoint->GetPointCode();
  1185. if (szPointCode.Compare(szPointCodeStart) == 0)
  1186. {
  1187. x1 = pPoint->GetPointAX();
  1188. y1 = pPoint->GetPointAY();
  1189. z1 = pPoint->GetPointAZ();
  1190. }
  1191. }
  1192. // 2.PointEnd
  1193. POSITION pos2;
  1194. EquipDataPoint *pPoint1 = NULL;
  1195. pos2 = m_PointList.GetHeadPosition();
  1196. while (pos2 != NULL)
  1197. {
  1198. pPoint1 = (EquipDataPoint *)m_PointList.GetNext(pos2);
  1199. if (pPoint1 == NULL) break;
  1200. CString szPointCode = pPoint1->GetPointCode();
  1201. if (szPointCode.Compare(szPointCodeEnd) == 0)
  1202. {
  1203. x2 = pPoint1->GetPointAX();
  1204. y2 = pPoint1->GetPointAY();
  1205. z2 = pPoint1->GetPointAZ();
  1206. }
  1207. }
  1208. count.Format("%s And %s", szPointCodeStart, szPointCodeEnd);
  1209. if (x1 != 0 && x2 != 0)
  1210. {
  1211. this->CalcAngle(count,x1, y1, z1, x2, y2, z2);
  1212. }
  1213. return;
  1214. }
  1215. /**************************************************************************************************
  1216. 函 数 名 :CalcAngle
  1217. 功能描述 :计算推力线偏角
  1218. 输入参数 :无
  1219. 输出参数 :无
  1220. 返 回 值 :void
  1221. **************************************************************************************************/
  1222. void StaticData::CalcAngle(DOUBLE x1, DOUBLE y1, DOUBLE z1, DOUBLE x2, DOUBLE y2, DOUBLE z2)
  1223. {
  1224. // 1.获取坐标值
  1225. DOUBLE fX1 = x1;
  1226. DOUBLE fY1 = y1;
  1227. DOUBLE fZ1 = z1;
  1228. DOUBLE fX2 = x2;
  1229. DOUBLE fY2 = y2;
  1230. DOUBLE fZ2 = z2;
  1231. // 2.计算偏角数据
  1232. DOUBLE v1 = (fX2 - fX1)*(fX2 - fX1);
  1233. DOUBLE v2 = (fY2 - fY1)*(fY2 - fY1);
  1234. DOUBLE v3 = (fZ2 - fZ1)*(fZ2 - fZ1);
  1235. DOUBLE fLength = sqrt(v1 + v2 + v3);
  1236. DOUBLE ax = acos((fX2 - fX1) / fLength) * 180 / PI;
  1237. DOUBLE ay = acos((fY2 - fY1) / fLength) * 180 / PI;
  1238. DOUBLE az = acos((fZ2 - fZ1) / fLength) * 180 / PI;
  1239. // 3. 存储数据
  1240. EquipDataAngle *pAngle = new EquipDataAngle();
  1241. pAngle->SetEquipCode(m_szEquipCode);
  1242. pAngle->SetItemId(6); //
  1243. pAngle->SetLineTitle("AS1AE1");
  1244. pAngle->SetLineCode("AS1AE1");
  1245. pAngle->SetLineStartX(fX1);
  1246. pAngle->SetLineStartY(fY1);
  1247. pAngle->SetLineStartZ(fZ1);
  1248. pAngle->SetLineEndX(fX2);
  1249. pAngle->SetLineEndY(fY2);
  1250. pAngle->SetLineEndZ(fZ2);
  1251. pAngle->SetAngleAX(ax);
  1252. pAngle->SetAngleAY(ay);
  1253. pAngle->SetAngleAZ(az);
  1254. this->AddAngle(pAngle);
  1255. return;
  1256. }
  1257. /**************************************************************************************************
  1258. 函 数 名 :CalcAngle
  1259. 功能描述 :计算推力线偏角有推力线名
  1260. 输入参数 :无
  1261. 输出参数 :无
  1262. 返 回 值 :void
  1263. **************************************************************************************************/
  1264. void StaticData::CalcAngle(CString count,DOUBLE x1, DOUBLE y1, DOUBLE z1, DOUBLE x2, DOUBLE y2, DOUBLE z2)
  1265. {
  1266. //0.获取推力线编号
  1267. CString fcount = count;
  1268. // 1.获取坐标值
  1269. DOUBLE fX1 = x1;
  1270. DOUBLE fY1 = y1;
  1271. DOUBLE fZ1 = z1;
  1272. DOUBLE fX2 = x2;
  1273. DOUBLE fY2 = y2;
  1274. DOUBLE fZ2 = z2;
  1275. // 2.计算偏角数据
  1276. DOUBLE v1 = (fX2 - fX1)*(fX2 - fX1);
  1277. DOUBLE v2 = (fY2 - fY1)*(fY2 - fY1);
  1278. DOUBLE v3 = (fZ2 - fZ1)*(fZ2 - fZ1);
  1279. DOUBLE fLength = sqrt(v1 + v2 + v3);
  1280. DOUBLE ax = acos((fX2 - fX1) / fLength) * 180 / PI;
  1281. DOUBLE ay = acos((fY2 - fY1) / fLength) * 180 / PI;
  1282. DOUBLE az = acos((fZ2 - fZ1) / fLength) * 180 / PI;
  1283. // 3. 存储数据
  1284. EquipDataAngle *pAngle = new EquipDataAngle();
  1285. pAngle->SetTaskId(m_iTaskId);
  1286. pAngle->SetEquipCode(m_szEquipCode);
  1287. pAngle->SetItemId(6); //
  1288. pAngle->SetLineTitle(fcount);
  1289. pAngle->SetLineCode(fcount);
  1290. pAngle->SetLineStartX(fX1);
  1291. pAngle->SetLineStartY(fY1);
  1292. pAngle->SetLineStartZ(fZ1);
  1293. pAngle->SetLineEndX(fX2);
  1294. pAngle->SetLineEndY(fY2);
  1295. pAngle->SetLineEndZ(fZ2);
  1296. pAngle->SetAngleAX(ax);
  1297. pAngle->SetAngleAY(ay);
  1298. pAngle->SetAngleAZ(az);
  1299. this->AddAngle(pAngle);
  1300. return;
  1301. }
  1302. /**************************************************************************************************
  1303. 函 数 名 :SaveToDB
  1304. 功能描述 :批量存储到数据库
  1305. 输入参数 :无
  1306. 输出参数 :无
  1307. 返 回 值 :void
  1308. **************************************************************************************************/
  1309. BOOL StaticData::SaveToDB()
  1310. {
  1311. // 计算Plane平面度
  1312. this->CalcPointFlatness();
  1313. // Calc Circle Roundness
  1314. this->CalcCircleRoundness();
  1315. // 生成偏角数据
  1316. this->GenerateAngleText();
  1317. this->GenerateDoublePoint();
  1318. // 保存到数据库中
  1319. int iRet = 0;
  1320. iRet += SaveEquipDataToDB();
  1321. iRet += SavePointToDB();
  1322. iRet += SavePlaneToDB();
  1323. iRet += SaveCircleToDB();
  1324. iRet += SaveLineToDB();
  1325. iRet += SaveCylinderToDB();
  1326. iRet += SaveAngleToDB();
  1327. iRet += SavePointRelatedToDB();
  1328. if (iRet > 0) return FALSE;
  1329. return TRUE;
  1330. }
  1331. /**************************************************************************************************
  1332. 函 数 名 :Validate
  1333. 功能描述 :数据完整性验证
  1334. 输入参数 :无
  1335. 输出参数 :无
  1336. 返 回 值 :void
  1337. **************************************************************************************************/
  1338. BOOL StaticData::Validate(CString &szMsg) {
  1339. CString rules = AppConfig::GetString(_T("Data-Integrity"), this->m_szEquipTypeCode);
  1340. CStringArray arrRules;
  1341. Utils::StrSplit(rules, ",", arrRules);
  1342. int icount = (int)arrRules.GetCount();
  1343. EquipDataPoint *pPoint = NULL;
  1344. BOOL bRet = TRUE;
  1345. for (int i = 0; i < icount; i++) {
  1346. pPoint = this->SearchPointByCode(arrRules[i]);
  1347. if (pPoint == NULL) {
  1348. if (bRet) {
  1349. szMsg.Append(_T("关键点未测得:"));
  1350. bRet = FALSE;
  1351. }
  1352. szMsg.Append(arrRules[i]);
  1353. szMsg.Append("/");
  1354. }
  1355. }
  1356. if (!szMsg.IsEmpty())
  1357. {
  1358. szMsg.TrimRight('/');
  1359. }
  1360. return bRet;
  1361. }
  1362. /**************************************************************************************************
  1363. 函 数 名 :SaveEquipDataToDB
  1364. 功能描述 :存储Equip数据类别到数据库
  1365. 输入参数 :无
  1366. 输出参数 :无
  1367. 返 回 值 :void
  1368. **************************************************************************************************/
  1369. int StaticData::SaveEquipDataToDB()
  1370. {
  1371. POSITION pos;
  1372. EquipData *pData = NULL;
  1373. CString szLine;
  1374. EquipDataManager *pManager = new EquipDataManager();
  1375. pManager->Delete(m_iTaskId);
  1376. pos = m_DataList.GetHeadPosition();
  1377. while (pos != NULL)
  1378. {
  1379. pData = (EquipData *)m_DataList.GetNext(pos);
  1380. if (pData != NULL)
  1381. {
  1382. pManager->Add(*pData);
  1383. }
  1384. }
  1385. delete pManager;
  1386. return 0;
  1387. }
  1388. /**************************************************************************************************
  1389. 函 数 名 :SavePointToDB
  1390. 功能描述 :存储Line到数据库
  1391. 输入参数 :无
  1392. 输出参数 :无
  1393. 返 回 值 :void
  1394. **************************************************************************************************/
  1395. int StaticData::SavePointToDB()
  1396. {
  1397. POSITION pos;
  1398. EquipDataPoint *pPoint = NULL;
  1399. EquipDataPointManager *pPointManager = new EquipDataPointManager();
  1400. pPointManager->Delete(m_iTaskId);
  1401. BOOL bRet = TRUE;
  1402. pos = m_PointList.GetHeadPosition();
  1403. while (pos != NULL)
  1404. {
  1405. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos);
  1406. if (pPoint != NULL)
  1407. {
  1408. bRet = pPointManager->Add(*pPoint);
  1409. if (bRet != TRUE)
  1410. {
  1411. AfxMessageBox("Point数据存储失败!");
  1412. break;
  1413. }
  1414. }
  1415. }
  1416. delete pPointManager;
  1417. return 0;
  1418. }
  1419. /**************************************************************************************************
  1420. 函 数 名 :SavePlaneToDB
  1421. 功能描述 :存储Plane到数据库
  1422. 输入参数 :无
  1423. 输出参数 :无
  1424. 返 回 值 :void
  1425. **************************************************************************************************/
  1426. int StaticData::SavePlaneToDB()
  1427. {
  1428. POSITION pos;
  1429. EquipDataPlane *pPlane = NULL;
  1430. EquipDataPlaneManager *pPlaneManager = new EquipDataPlaneManager();
  1431. pPlaneManager->Delete(m_iTaskId);
  1432. BOOL bRet = TRUE;
  1433. pos = m_PlaneList.GetHeadPosition();
  1434. while (pos != NULL)
  1435. {
  1436. pPlane = (EquipDataPlane *)m_PlaneList.GetNext(pos);
  1437. if (pPlane != NULL)
  1438. {
  1439. bRet = pPlaneManager->Add(*pPlane);
  1440. if (bRet != TRUE)
  1441. {
  1442. AfxMessageBox("Plane数据存储失败!");
  1443. break;
  1444. }
  1445. }
  1446. }
  1447. delete pPlaneManager;
  1448. return 0;
  1449. }
  1450. /**************************************************************************************************
  1451. 函 数 名 :SaveCircleToDB
  1452. 功能描述 :存储Circle到数据库
  1453. 输入参数 :无
  1454. 输出参数 :无
  1455. 返 回 值 :void
  1456. **************************************************************************************************/
  1457. int StaticData::SaveCircleToDB()
  1458. {
  1459. POSITION pos;
  1460. EquipDataCircle *pCircle = NULL;
  1461. EquipDataCircleManager *pCircleManager = new EquipDataCircleManager();
  1462. pCircleManager->Delete(m_iTaskId);
  1463. BOOL bRet = TRUE;
  1464. pos = m_CircleList.GetHeadPosition();
  1465. while (pos != NULL)
  1466. {
  1467. pCircle = (EquipDataCircle *)m_CircleList.GetNext(pos);
  1468. if (pCircle != NULL)
  1469. {
  1470. bRet = pCircleManager->Add(*pCircle);
  1471. if (bRet != TRUE)
  1472. {
  1473. AfxMessageBox("Circle数据存储失败!");
  1474. break;
  1475. }
  1476. }
  1477. }
  1478. delete pCircleManager;
  1479. return 0;
  1480. }
  1481. /**************************************************************************************************
  1482. 函 数 名 :SaveLineToDB
  1483. 功能描述 :存储Line到数据库
  1484. 输入参数 :无
  1485. 输出参数 :无
  1486. 返 回 值 :void
  1487. **************************************************************************************************/
  1488. int StaticData::SaveLineToDB()
  1489. {
  1490. POSITION pos;
  1491. EquipDataLine *pLine = NULL;
  1492. EquipDataLineManager *pLineManager = new EquipDataLineManager();
  1493. pLineManager->Delete(m_iTaskId);
  1494. BOOL bRet = TRUE;
  1495. pos = m_LineList.GetHeadPosition();
  1496. while (pos != NULL)
  1497. {
  1498. pLine = (EquipDataLine *)m_LineList.GetNext(pos);
  1499. if (pLine != NULL)
  1500. {
  1501. bRet = pLineManager->Add(*pLine);
  1502. if (bRet != TRUE)
  1503. {
  1504. AfxMessageBox("Line数据存储失败!");
  1505. break;
  1506. }
  1507. }
  1508. }
  1509. delete pLineManager;
  1510. return 0;
  1511. }
  1512. /**************************************************************************************************
  1513. 函 数 名 :SavePointToDB
  1514. 功能描述 :存储Line到数据库
  1515. 输入参数 :无
  1516. 输出参数 :无
  1517. 返 回 值 :void
  1518. **************************************************************************************************/
  1519. int StaticData::SaveCylinderToDB()
  1520. {
  1521. POSITION pos;
  1522. EquipDataCylinder *pCylinder = NULL;
  1523. EquipDataCylinderManager *pCylinderManager = new EquipDataCylinderManager();
  1524. pCylinderManager->Delete(m_iTaskId);
  1525. BOOL bRet = TRUE;
  1526. pos = m_CylinderList.GetHeadPosition();
  1527. while (pos != NULL)
  1528. {
  1529. pCylinder = (EquipDataCylinder *)m_CylinderList.GetNext(pos);
  1530. if (pCylinder != NULL)
  1531. {
  1532. bRet = pCylinderManager->Add(*pCylinder);
  1533. if (bRet != TRUE)
  1534. {
  1535. AfxMessageBox("Line数据存储失败!");
  1536. break;
  1537. }
  1538. }
  1539. }
  1540. delete pCylinderManager;
  1541. return 0;
  1542. }
  1543. /**************************************************************************************************
  1544. 函 数 名 :SaveAngleToDB
  1545. 功能描述 :存储Angle到数据库
  1546. 输入参数 :无
  1547. 输出参数 :无
  1548. 返 回 值 :void
  1549. **************************************************************************************************/
  1550. int StaticData::SaveAngleToDB()
  1551. {
  1552. POSITION pos;
  1553. EquipDataAngle *pAngle = NULL;
  1554. EquipDataAngleManager *pAngleManager = new EquipDataAngleManager();
  1555. pAngleManager->Delete(m_iTaskId);
  1556. BOOL bRet = TRUE;
  1557. pos = m_AngleList.GetHeadPosition();
  1558. while (pos != NULL)
  1559. {
  1560. pAngle = (EquipDataAngle *)m_AngleList.GetNext(pos);
  1561. if (pAngle != NULL)
  1562. {
  1563. bRet = pAngleManager->Add(*pAngle);
  1564. if (bRet != TRUE)
  1565. {
  1566. AfxMessageBox("Angle数据存储失败!");
  1567. break;
  1568. }
  1569. }
  1570. }
  1571. delete pAngleManager;
  1572. return 0;
  1573. }
  1574. /**************************************************************************************************
  1575. 函 数 名 :SavePointToDB
  1576. 功能描述 :存储Line到数据库
  1577. 输入参数 :无
  1578. 输出参数 :无
  1579. 返 回 值 :void
  1580. **************************************************************************************************/
  1581. int StaticData::SavePointRelatedToDB()
  1582. {
  1583. POSITION pos;
  1584. EquipDataPointRelated *pPointRelated = NULL;
  1585. EquipDataPointRelatedManager *pPointRelatedManager = new EquipDataPointRelatedManager();
  1586. pPointRelatedManager->Delete(m_iTaskId);
  1587. BOOL bRet = TRUE;
  1588. pos = m_PointRelatedList.GetHeadPosition();
  1589. while (pos != NULL)
  1590. {
  1591. pPointRelated = (EquipDataPointRelated *)m_PointRelatedList.GetNext(pos);
  1592. if (pPointRelated != NULL)
  1593. {
  1594. bRet = pPointRelatedManager->Add(*pPointRelated);
  1595. if (bRet != TRUE)
  1596. {
  1597. AfxMessageBox("Line数据存储失败!");
  1598. break;
  1599. }
  1600. }
  1601. }
  1602. delete pPointRelatedManager;
  1603. return 0;
  1604. }
  1605. /**************************************************************************************************
  1606. 函 数 名 :OutputConfig
  1607. 功能描述 :输出配置文件
  1608. 输入参数 :无
  1609. 输出参数 :无
  1610. 返 回 值 :void
  1611. **************************************************************************************************/
  1612. int StaticData::OutputConfig()
  1613. {
  1614. CString szFile1 = AppConfig::GetString("Output", "File1");
  1615. CString szPoints1 = AppConfig::GetString("Output", "File1_Points");
  1616. if (!szFile1.IsEmpty()) {
  1617. this->OutputDataToFile(szFile1, szPoints1);
  1618. }
  1619. CString szFile2 = AppConfig::GetString("Output", "File2");
  1620. CString szPoints2 = AppConfig::GetString("Output", "File2_Points");
  1621. if (!szFile2.IsEmpty()) {
  1622. this->OutputDataToFile(szFile2, szPoints2);
  1623. }
  1624. CString szFile3 = AppConfig::GetString("Output", "File3");
  1625. CString szPoints3 = AppConfig::GetString("Output", "File3_Points");
  1626. if (!szFile3.IsEmpty()) {
  1627. this->OutputDataToFile(szFile3, szPoints3);
  1628. }
  1629. CString szFile4 = AppConfig::GetString("Output", "File4");
  1630. CString szPoints4 = AppConfig::GetString("Output", "File4_Points");
  1631. if (!szFile4.IsEmpty()) {
  1632. this->OutputDataToFile(szFile4, szPoints4);
  1633. }
  1634. CString szFile5 = AppConfig::GetString("Output", "File5");
  1635. CString szPoints5 = AppConfig::GetString("Output", "File5_Points");
  1636. if (!szFile5.IsEmpty()) {
  1637. this->OutputDataToFile(szFile5, szPoints5);
  1638. }
  1639. return 0;
  1640. }
  1641. /**************************************************************************************************
  1642. 函 数 名 :OutputDataToFile
  1643. 功能描述 :输出点数据到文件
  1644. 输入参数 :无
  1645. 输出参数 :无
  1646. 返 回 值 :void
  1647. **************************************************************************************************/
  1648. int StaticData::OutputDataToFile(const CString &szFile, const CString &strPoints)
  1649. {
  1650. CStdioFile file;
  1651. if (!file.Open(szFile, CFile::typeText | CFile::modeCreate | CFile::modeReadWrite))
  1652. {
  1653. LOG::E(_T("文件失败"));
  1654. return 1;
  1655. }
  1656. CStringArray szArray;
  1657. Utils::StrSplit(strPoints, ",", szArray);
  1658. POSITION pos;
  1659. EquipDataPoint *pPoint = NULL;
  1660. CString szLine;
  1661. pos = m_PointList.GetHeadPosition();
  1662. while (pos != NULL)
  1663. {
  1664. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos);
  1665. if (pPoint != NULL)
  1666. {
  1667. CString szPoint = pPoint->GetPointCode();
  1668. for (int i = 0; i < szArray.GetSize(); i++)
  1669. {
  1670. CString szPointTarget = szArray.GetAt(i);
  1671. if (!szPointTarget.IsEmpty())
  1672. {
  1673. if (szPointTarget.CompareNoCase(szPoint)==0)
  1674. {
  1675. szLine.Format("%20s %.3f %.3f %.3f\n"
  1676. , pPoint->GetPointTitle()
  1677. , pPoint->GetPointAX()
  1678. , pPoint->GetPointAY()
  1679. , pPoint->GetPointAZ());
  1680. file.WriteString(szLine);
  1681. }
  1682. }
  1683. }
  1684. }
  1685. }
  1686. file.Close();
  1687. return 0;
  1688. }
  1689. /**************************************************************************************************
  1690. 函 数 名 :PrintData
  1691. 功能描述 :调试打印
  1692. 输入参数 :无
  1693. 输出参数 :无
  1694. 返 回 值 :void
  1695. **************************************************************************************************/
  1696. void StaticData::PrintData()
  1697. {
  1698. CStdioFile file;
  1699. CString szFile("D:\\data.txt");
  1700. if (!file.Open(szFile, CFile::typeText|CFile::modeCreate|CFile::modeReadWrite))
  1701. {
  1702. LOG::E(_T("打开文件失败"));
  1703. return ;
  1704. }
  1705. this->PrintEquipData(&file);
  1706. this->PrintPoint(&file);
  1707. this->PrintPlane(&file);
  1708. this->PrintCircle(&file);
  1709. this->PrintLine(&file);
  1710. this->PrintCylinder(&file);
  1711. this->PrintAngle(&file);
  1712. this->PrintPointRelated(&file);
  1713. file.Close();
  1714. }
  1715. // 打印输出Equip Data
  1716. void StaticData::PrintEquipData(CStdioFile *pFile)
  1717. {
  1718. POSITION pos;
  1719. EquipData *pData = NULL;
  1720. CString szLine;
  1721. szLine.Format("-------------------------------------------------------------------------------\n");
  1722. pFile->WriteString(szLine);
  1723. szLine.Format(" equipCode itemId itemCode itemTitle itemType\n");
  1724. pFile->WriteString(szLine);
  1725. pos = m_DataList.GetHeadPosition();
  1726. while (pos != NULL)
  1727. {
  1728. pData = (EquipData *)m_DataList.GetNext(pos);
  1729. if (pData != NULL)
  1730. {
  1731. szLine.Format(" %20s %d %s %s %d\n"
  1732. ,pData->GetEquipCode()
  1733. ,pData->GetItemId()
  1734. ,pData->GetItemCode()
  1735. ,pData->GetItemTitle()
  1736. ,pData->GetItemType());
  1737. pFile->WriteString(szLine);
  1738. }
  1739. }
  1740. }
  1741. // 打印输出点数据
  1742. void StaticData::PrintPoint(CStdioFile *pFile)
  1743. {
  1744. POSITION pos;
  1745. EquipDataPoint *pPoint = NULL;
  1746. CString szLine;
  1747. szLine.Format("------------------------------------------------------------------------------------\n");
  1748. pFile->WriteString(szLine);
  1749. szLine.Format("equipCode itemId subitemId pointTitle pointAX pointAY pointAZ pointTotal\n");
  1750. pFile->WriteString(szLine);
  1751. pos = m_PointList.GetHeadPosition();
  1752. while (pos != NULL)
  1753. {
  1754. pPoint = (EquipDataPoint *)m_PointList.GetNext(pos);
  1755. if (pPoint != NULL)
  1756. {
  1757. szLine.Format(" %20s %d %d %s %.3f %.3f %.3f %.3f\n"
  1758. ,pPoint->GetEquipCode()
  1759. ,pPoint->GetItemId()
  1760. ,pPoint->GetSubItemId()
  1761. ,pPoint->GetPointTitle()
  1762. ,pPoint->GetPointAX()
  1763. ,pPoint->GetPointAY()
  1764. ,pPoint->GetPointAZ()
  1765. ,pPoint->GetPointTotal());
  1766. pFile->WriteString(szLine);
  1767. }
  1768. }
  1769. }
  1770. // 打印输出平面数据
  1771. void StaticData::PrintPlane(CStdioFile *pFile)
  1772. {
  1773. POSITION pos;
  1774. EquipDataPlane *pPlane = NULL;
  1775. CString szLine;
  1776. szLine.Format("------------------------------------------------------------------------------------\r\n");
  1777. pFile->WriteString(szLine);
  1778. szLine.Format("%20s %20s %20s %20s %20s \r\n", "equipCode", "itemId", "subitemId" , "planeCode", "A", "B", "C", "D", "RMS");
  1779. pFile->WriteString(szLine);
  1780. pos = m_PlaneList.GetHeadPosition();
  1781. while (pos != NULL)
  1782. {
  1783. pPlane = (EquipDataPlane *)m_PlaneList.GetNext(pos);
  1784. if (pPlane != NULL)
  1785. {
  1786. szLine.Format("%20s %20d %20d %20s %20.3f %20.3f %20.3f %20.3f %20.3f %20.3f\r\n"
  1787. ,pPlane->GetEquipCode()
  1788. ,pPlane->GetItemId()
  1789. ,pPlane->GetSubItemId()
  1790. ,pPlane->GetPlaneCode()
  1791. ,pPlane->GetPlaneA()
  1792. ,pPlane->GetPlaneB()
  1793. ,pPlane->GetPlaneC()
  1794. ,pPlane->GetPlaneD()
  1795. ,pPlane->GetPlaneRMS()
  1796. ,pPlane->GetPlaneFlatness());
  1797. pFile->WriteString(szLine);
  1798. }
  1799. }
  1800. }
  1801. // 打印输出圆数据
  1802. void StaticData::PrintCircle(CStdioFile *pFile)
  1803. {
  1804. POSITION pos;
  1805. EquipDataCircle *pCircle = NULL;
  1806. CString szLine;
  1807. szLine.Format("------------------------------------------------------------------------------------\r\n");
  1808. pFile->WriteString(szLine);
  1809. szLine.Format("equipCode itemId subitemId CircelCode C-X C-Y C-Z Raidus RMS \r\n");
  1810. pFile->WriteString(szLine);
  1811. pos = m_CircleList.GetHeadPosition();
  1812. while (pos != NULL)
  1813. {
  1814. pCircle = (EquipDataCircle *)m_CircleList.GetNext(pos);
  1815. if (pCircle != NULL)
  1816. {
  1817. szLine.Format("%20s %d %d %s (%.3f %.3f %.3f) %.3f %.3f \r\n"
  1818. ,pCircle->GetEquipCode()
  1819. ,pCircle->GetItemId()
  1820. ,pCircle->GetSubItemId()
  1821. ,pCircle->GetCircleCode()
  1822. ,pCircle->GetCircleCenterX()
  1823. ,pCircle->GetCircleCenterY()
  1824. ,pCircle->GetCircleCenterZ()
  1825. ,pCircle->GetCircleRadius()
  1826. ,pCircle->GetCircleRMS());
  1827. pFile->WriteString(szLine);
  1828. }
  1829. }
  1830. }
  1831. // 打印输出直线数据
  1832. void StaticData::PrintLine(CStdioFile *pFile)
  1833. {
  1834. POSITION pos;
  1835. EquipDataLine *pLine = NULL;
  1836. CString szLine;
  1837. szLine.Format("---------------------------------------------------------------------------------------------------------------------------------------------------\r\n");
  1838. pFile->WriteString(szLine);
  1839. szLine.Format("equipCode itemId subitemId lineCode Vec-X Vec-Y Vec-Z Start-X Start-Y Start-Z End-X End-Y End-Z Length \r\n");
  1840. pFile->WriteString(szLine);
  1841. pos = m_LineList.GetHeadPosition();
  1842. while (pos != NULL)
  1843. {
  1844. pLine = (EquipDataLine *)m_LineList.GetNext(pos);
  1845. if (pLine != NULL)
  1846. {
  1847. szLine.Format("%20s %d %d %s (%.3f %.3f %.3f)(%.3f %.3f %.3f) (%.3f %.3f %.3f) %.3f \r\n"
  1848. ,pLine->GetEquipCode()
  1849. ,pLine->GetItemId()
  1850. ,pLine->GetSubItemId()
  1851. ,pLine->GetLineCode()
  1852. ,pLine->GetLineVectorX()
  1853. ,pLine->GetLineVectorY()
  1854. ,pLine->GetLineVectorZ()
  1855. ,pLine->GetLineStartX()
  1856. ,pLine->GetLineStartY()
  1857. ,pLine->GetLineStartZ()
  1858. ,pLine->GetLineEndX()
  1859. ,pLine->GetLineEndY()
  1860. ,pLine->GetLineEndZ()
  1861. ,pLine->GetLineLength());
  1862. pFile->WriteString(szLine);
  1863. }
  1864. }
  1865. }
  1866. // 打印输出圆柱数据
  1867. void StaticData::PrintCylinder(CStdioFile *pFile)
  1868. {
  1869. POSITION pos;
  1870. EquipDataCylinder *pCylinder = NULL;
  1871. CString szLine;
  1872. szLine.Format("------------------------------------------------------------------------------------------------------------------------------------------\r\n");
  1873. pFile->WriteString(szLine);
  1874. szLine.Format("equipCode itemId subitemId CylinderCode P1-X P1-Y P1-Z P2-X P2-Y P2-Z Radius Length \r\n");
  1875. pFile->WriteString(szLine);
  1876. pos = m_CylinderList.GetHeadPosition();
  1877. while (pos != NULL)
  1878. {
  1879. pCylinder = (EquipDataCylinder *)m_CylinderList.GetNext(pos);
  1880. if (pCylinder != NULL)
  1881. {
  1882. szLine.Format("%20s %d %d %s (%.3f %.3f %.3f) (%.3f %.3f %.3f) %.3f %.3f \r\n"
  1883. ,pCylinder->GetEquipCode()
  1884. ,pCylinder->GetItemId()
  1885. ,pCylinder->GetSubItemId()
  1886. ,pCylinder->GetCylinderCode()
  1887. ,pCylinder->GetPoint1X()
  1888. ,pCylinder->GetPoint1Y()
  1889. ,pCylinder->GetPoint1Z()
  1890. ,pCylinder->GetPoint2X()
  1891. ,pCylinder->GetPoint2Y()
  1892. ,pCylinder->GetPoint2Z()
  1893. ,pCylinder->GetCylinderRadius()
  1894. ,pCylinder->GetCylinderLength());
  1895. pFile->WriteString(szLine);
  1896. }
  1897. }
  1898. }
  1899. // 打印输出圆柱数据
  1900. void StaticData::PrintAngle(CStdioFile *pFile)
  1901. {
  1902. POSITION pos;
  1903. EquipDataAngle *pAngle = NULL;
  1904. CString szLine;
  1905. szLine.Format("------------------------------------------------------------------------------------------------------------------------------------------\r\n");
  1906. pFile->WriteString(szLine);
  1907. szLine.Format("equipCode itemId subitemId CylinderCode P1-X P1-Y P1-Z P2-X P2-Y P2-Z Radius Length \r\n");
  1908. pFile->WriteString(szLine);
  1909. pos = m_AngleList.GetHeadPosition();
  1910. while (pos != NULL)
  1911. {
  1912. pAngle = (EquipDataAngle *)m_AngleList.GetNext(pos);
  1913. if (pAngle != NULL)
  1914. {
  1915. szLine.Format("%20s %d %d %s %s (%.3f %.3f %.3f) (%.3f %.3f %.3f) \r\n"
  1916. , pAngle->GetEquipCode()
  1917. , pAngle->GetItemId()
  1918. , pAngle->GetSubItemId()
  1919. , pAngle->GetLineCode()
  1920. , pAngle->GetLineTitle()
  1921. , pAngle->GetAngleAX()
  1922. , pAngle->GetAngleAY()
  1923. , pAngle->GetAngleAZ()
  1924. , pAngle->GetAngleEX()
  1925. , pAngle->GetAngleEY()
  1926. , pAngle->GetAngleEZ());
  1927. pFile->WriteString(szLine);
  1928. }
  1929. }
  1930. }
  1931. // 打印点残差数据
  1932. void StaticData::PrintPointRelated(CStdioFile *pFile)
  1933. {
  1934. POSITION pos;
  1935. EquipDataPointRelated *pPointRelated = NULL;
  1936. CString szLine;
  1937. szLine.Format("---------------------------------------------------------------------------\r\n");
  1938. pFile->WriteString(szLine);
  1939. szLine.Format("equipCode itemId subitemId itemType PointSubItemId \r\n");
  1940. pFile->WriteString(szLine);
  1941. pos = m_PointRelatedList.GetHeadPosition();
  1942. while (pos != NULL)
  1943. {
  1944. pPointRelated = (EquipDataPointRelated *)m_PointRelatedList.GetNext(pos);
  1945. if (pPointRelated != NULL)
  1946. {
  1947. szLine.Format("%20s %d %d %d %d\n"
  1948. ,pPointRelated->GetEquipCode()
  1949. ,pPointRelated->GetItemId()
  1950. ,pPointRelated->GetSubItemId()
  1951. ,pPointRelated->GetItemType()
  1952. ,pPointRelated->GetPointSubItemId());
  1953. pFile->WriteString(szLine);
  1954. }
  1955. }
  1956. }