DBInterface.cpp 152 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433
  1. /*************************************************************
  2. /* Copyright (C), 2008-2010, StoneU Tech. Co., Ltd.
  3. /* 文件名: DBInterface.h
  4. /* 作者: Jesse
  5. /* 创建日期: 2010-08-02
  6. /* 版本号: V1.0
  7. /* 描述: 实现多种数据库的支持
  8. /* 其它:
  9. /* 主要类模块: CDBInterface
  10. /* 历史修改记录:
  11. 作者 时间 版本 描述
  12. Jesse 10/08/02 1.0 创建这个模块
  13. ***************************************************************/
  14. #include "stdafx.h"
  15. #include "DBInterface.h"
  16. #include "Global.h"
  17. #include "Syslib.h"
  18. namespace DBInterface
  19. {
  20. CDBInterface* CDBInterface::m_pDBInterface = NULL;
  21. // 静态成员函数,提供全局访问的接口
  22. CDBInterface* CDBInterface::GetInstancePtr()
  23. {
  24. if( NULL == m_pDBInterface )
  25. {
  26. m_pDBInterface = new CDBInterface();
  27. }
  28. return m_pDBInterface;
  29. }
  30. // 设置数据库类型
  31. void CDBInterface::SetDBType(char *pDBType)
  32. {
  33. strcpy(m_chDBType, pDBType);
  34. }
  35. //获取表最大的ID, 通用函数
  36. INT CDBInterface::GetMaxID( CHAR *pTableName, CHAR *pFieldName, CHAR *pMaxID )
  37. {
  38. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  39. list<string> list1;
  40. list<string>::iterator it;
  41. sprintf(strSQLText, "select max(%s) as maxid from %s", pFieldName, pTableName);
  42. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
  43. if( 0 == list1.size() )
  44. {
  45. return 0;
  46. }
  47. if( nRet != -1 )
  48. {
  49. strcpy(pMaxID, list1.begin()->c_str());
  50. }
  51. for( it = list1.begin(); it != list1.end(); )
  52. {
  53. list1.erase(it++);
  54. }
  55. return nRet;
  56. }
  57. // 分配用户角色
  58. void CDBInterface::InitUserRoleInfo()
  59. {
  60. char szUid[MAX_UID] = {0};
  61. list<string> list_uid;
  62. list<string>::iterator it_uid;
  63. int iUIDCount = GetHasPurviewUidList(list_uid);
  64. if( iUIDCount <= 0 || 0 == list_uid.size() )
  65. {
  66. return;
  67. }
  68. for( it_uid = list_uid.begin(); it_uid != list_uid.end(); )
  69. {
  70. USERROLEINFO tagUserRoleInfo;
  71. USERINFO tagUserInfo;
  72. memset(&tagUserRoleInfo, 0, sizeof(USERROLEINFO));
  73. memset(&tagUserInfo, 0, sizeof(USERINFO));
  74. strcpy( szUid, (*it_uid++).c_str() );
  75. strcpy( tagUserRoleInfo.szDevUID, szUid );
  76. list<string> list_tel, list_mobile, list_fax, list_email;
  77. list<string>::iterator it_tel, it_mobile, it_fax, it_email;
  78. int iUserCount = GetUserInfoList(szUid, list_tel, list_mobile, list_fax, list_email);
  79. for( it_tel = list_tel.begin(), it_mobile = list_mobile.begin(), it_fax = list_fax.begin(), it_email = list_email.begin();
  80. it_tel != list_tel.end(), it_mobile != list_mobile.end(), it_fax != list_fax.end(), it_email != list_email.end(); )
  81. {
  82. strcpy(tagUserInfo.szTel, (*it_tel++).c_str());
  83. strcpy(tagUserInfo.szMobileTel, (*it_mobile++).c_str());
  84. strcpy(tagUserInfo.szFax, (*it_fax++).c_str());
  85. strcpy(tagUserInfo.szEmail, (*it_email++).c_str());
  86. tagUserRoleInfo.vtUserInfo.push_back(tagUserInfo);
  87. //LOG4C((LOG_NOTICE, "tel=%s, MobileTel=%s", tagUserInfo.szTel, tagUserInfo.szMobileTel));
  88. }
  89. //LOG4C((LOG_NOTICE, "tagUserRoleInfo.szDevUID=%s", szUid));
  90. g_vtUserRoleInfo.push_back( tagUserRoleInfo );
  91. //释放
  92. for( it_tel = list_tel.begin(), it_mobile = list_mobile.begin(), it_fax = list_fax.begin(), it_email = list_email.begin();
  93. it_tel != list_tel.end(), it_mobile != list_mobile.end(), it_fax != list_fax.end(), it_email != list_email.end(); )
  94. {
  95. list_tel.erase(it_tel++);
  96. list_mobile.erase(it_mobile++);
  97. list_fax.erase(it_fax++);
  98. list_email.erase(it_email++);
  99. tagUserRoleInfo.vtUserInfo.pop_back();
  100. }
  101. }
  102. for( it_uid = list_uid.begin(); it_uid != list_uid.end(); )
  103. {
  104. list_uid.erase(it_uid++);
  105. }
  106. }
  107. // 回收用户角色
  108. void CDBInterface::UnInitUserRoleInfo()
  109. {
  110. for( int i = 0; i < g_vtUserRoleInfo.size(); i++ )
  111. {
  112. for( int j = 0; j < g_vtUserRoleInfo[i].vtUserInfo.size(); j++ )
  113. {
  114. g_vtUserRoleInfo[i].vtUserInfo.pop_back();
  115. }
  116. g_vtUserRoleInfo.pop_back();
  117. }
  118. }
  119. // 获取有权限的设备UID
  120. int CDBInterface::GetHasPurviewUidList(list<string>& list1)
  121. {
  122. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  123. sprintf(strSQLText, "select uid from t_role_equip group by uid");
  124. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  125. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
  126. return nRet;
  127. }
  128. // 获取具有某个设备权限的用户信息
  129. int CDBInterface::GetUserInfoList(char *pUid, list<string>& list1, list<string>& list2, list<string>& list3, list<string>& list4)
  130. {
  131. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  132. if (!_stricmp(m_chDBType, "SQL SERVER"))
  133. {
  134. sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
  135. "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
  136. "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin'",
  137. pUid);
  138. }
  139. else if (!_stricmp(m_chDBType, "ACCESS97"))
  140. {
  141. sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
  142. "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
  143. "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin'",
  144. pUid);
  145. }
  146. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  147. {
  148. sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
  149. "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
  150. "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin'",
  151. pUid);
  152. }
  153. else if(!_stricmp(m_chDBType, "PGSQL"))
  154. {
  155. sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
  156. "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
  157. "where a.uid = \'%s\' and b.status = false or b.status is null and b.uid <> 'admin'",
  158. pUid);
  159. }
  160. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  161. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
  162. return nRet;
  163. }
  164. // 获取用户信息
  165. int CDBInterface::GetUserInfoList(list<string>& list1, list<string>& list2, list<string>& list3, list<string>& list4)
  166. {
  167. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  168. if (!_stricmp(m_chDBType, "SQL SERVER"))
  169. {
  170. sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin'");
  171. }
  172. else if (!_stricmp(m_chDBType, "ACCESS97"))
  173. {
  174. sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin'");
  175. }
  176. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  177. {
  178. sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin'");
  179. }
  180. else if(!_stricmp(m_chDBType, "PGSQL"))
  181. {
  182. sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = false or status is null and uid <> 'admin'");
  183. }
  184. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
  185. return nRet;
  186. }
  187. //得到时间计划
  188. INT CDBInterface::GetDatePlan( int nPlanType, CHAR *pPlanID, unsigned char nBufDate[7][24] )
  189. {
  190. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  191. list<string> list1, list2, list3, list4;
  192. list<string>::iterator it_list1, it_list2, it_list3, it_list4;
  193. sprintf(strSQLText, "select starttime, endtime, startweekofday, endweekofday " \
  194. "from t_plan_info where planid=\'%s\' and plantype = %d",
  195. pPlanID, nPlanType);
  196. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
  197. if( list1.size() == 0 || list2.size() == 0 || list3.size() == 0 || list4.size() == 0 )
  198. {
  199. return 0;
  200. }
  201. if( nRet != -1 )
  202. {
  203. for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
  204. it_list1 != list1.end() && it_list2 != list2.end() && it_list3 != list3.end() && it_list4 != list4.end();
  205. it_list1++, it_list2++, it_list3++, it_list4++)
  206. {
  207. for( int i = atoi((*it_list3).c_str()); i < atoi((*it_list4).c_str()) + 1; i++ )
  208. {
  209. for( int j = atoi((*it_list1).c_str()); j < atoi((*it_list2).c_str()) + 1; j++ )
  210. {
  211. nBufDate[i][j] = 15;
  212. }
  213. }
  214. }
  215. }
  216. for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
  217. it_list1 != list1.end(), it_list2 != list2.end(), it_list3 != list3.end(), it_list4 != list4.end(); )
  218. {
  219. list1.erase(it_list1++);
  220. list2.erase(it_list2++);
  221. list3.erase(it_list3++);
  222. list4.erase(it_list4++);
  223. }
  224. return nRet;
  225. }
  226. //得到时间计划
  227. INT CDBInterface::GetDatePlan( int nPlanType, CHAR *pUid, int nVarID, unsigned char nBufDate[7][24] )
  228. {
  229. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  230. list<string> list1, list2, list3, list4;
  231. list<string>::iterator it_list1, it_list2, it_list3, it_list4;
  232. sprintf(strSQLText, "select starttime, endtime, startweekofday, endweekofday " \
  233. "from t_plan_info where uid=\'%s\' and varid = %d and plantype = %d",
  234. pUid, nVarID, nPlanType);
  235. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
  236. if( list1.size() == 0 || list2.size() == 0 || list3.size() == 0 || list4.size() == 0 )
  237. {
  238. return 0;
  239. }
  240. if( nRet != -1 )
  241. {
  242. for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
  243. it_list1 != list1.end() && it_list2 != list2.end() && it_list3 != list3.end() && it_list4 != list4.end();
  244. it_list1++, it_list2++, it_list3++, it_list4++ )
  245. {
  246. for( int i = atoi((*it_list3).c_str()); i < atoi((*it_list4).c_str()) + 1; i++ )
  247. {
  248. for( int j = atoi((*it_list1).c_str()); j < atoi((*it_list2).c_str()) + 1; j++ )
  249. {
  250. nBufDate[i][j] = 15;
  251. }
  252. }
  253. }
  254. }
  255. for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
  256. it_list1 != list1.end(), it_list2 != list2.end(), it_list3 != list3.end(), it_list4 != list4.end(); )
  257. {
  258. list1.erase(it_list1++);
  259. list2.erase(it_list2++);
  260. list3.erase(it_list3++);
  261. list4.erase(it_list4++);
  262. }
  263. return nRet;
  264. }
  265. // 获取设备资料
  266. INT CDBInterface::GetDevInfo()
  267. {
  268. //LOG4C((LOG_NOTICE,"加载设备"));
  269. CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
  270. list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
  271. list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
  272. list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
  273. list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
  274. list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
  275. list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
  276. list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
  277. list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
  278. list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
  279. list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
  280. list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
  281. list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
  282. list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
  283. list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
  284. list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
  285. list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
  286. list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
  287. list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
  288. sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
  289. " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
  290. " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  291. " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  292. " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  293. " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  294. " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  295. " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  296. " from t_dev_property where isuse = '1'");
  297. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
  298. ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
  299. ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
  300. ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
  301. ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
  302. ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
  303. ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
  304. ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
  305. ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
  306. ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
  307. if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
  308. || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
  309. || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
  310. || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
  311. || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
  312. || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
  313. || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
  314. || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
  315. || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
  316. || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
  317. || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
  318. || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
  319. || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
  320. || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
  321. || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
  322. )
  323. {
  324. LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
  325. return 0;
  326. }
  327. if( nRet != -1 )
  328. {
  329. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  330. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  331. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  332. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  333. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  334. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  335. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  336. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  337. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  338. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  339. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  340. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  341. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  342. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  343. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  344. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  345. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  346. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  347. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  348. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  349. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  350. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  351. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  352. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  353. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  354. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  355. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  356. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  357. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  358. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  359. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  360. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  361. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  362. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  363. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  364. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  365. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  366. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  367. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  368. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  369. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  370. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  371. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  372. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  373. )
  374. {
  375. CDevice* pDev = new CDevice();
  376. // 获取设备ID
  377. pDev->m_iID = atoi((*it_dev_id++).c_str());
  378. // 获取设备UID
  379. pDev->m_strUid = (*it_uid++).c_str();
  380. // 获取设备端口号
  381. pDev->m_iPort = atoi((*it_port++).c_str());
  382. // 获取设备名称
  383. pDev->m_strDeviceName = (*it_device_name++).c_str();
  384. // 获取设备的波特率
  385. pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
  386. // 获取设备的数据位
  387. pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
  388. // 获取设备的停止位
  389. pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
  390. // 获取设备的校验位
  391. pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
  392. // 通信的方式
  393. pDev->m_iCommmode = atoi((*it_commmode++).c_str());
  394. // 设备地址
  395. pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
  396. // 设备是否启用
  397. CString strIsUse = (*it_is_use++).c_str();
  398. if( 0 == atoi(strIsUse) )
  399. {
  400. pDev->m_iIsuse = 0;
  401. }
  402. else
  403. {
  404. pDev->m_iIsuse = 1;
  405. }
  406. // 协议DLL名称
  407. pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
  408. // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
  409. CString strSpecialDevice = (*it_special_device++).c_str();
  410. pDev->m_bySpecialdevice = atoi(strSpecialDevice);
  411. //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
  412. // 设备IP
  413. pDev->m_strIp = (*it_ip++).c_str();
  414. // 网络通信端口
  415. pDev->m_iIpport = atoi((*it_ip_port++).c_str());
  416. // ini配置文件名称
  417. pDev->m_strIniName = (*it_ini_name++).c_str();
  418. // 字符串预留1
  419. pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
  420. // 字符串预留2
  421. pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
  422. // 字符串预留3
  423. pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
  424. // 字符串预留4
  425. pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
  426. // 字符串预留5
  427. pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
  428. // 字符串预留6
  429. pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
  430. // 字符串预留7
  431. pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
  432. // 字符串预留8
  433. pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
  434. // 字符串预留9
  435. pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
  436. // 字符串预留10
  437. pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
  438. // 整形预留1
  439. pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
  440. // 整形预留2
  441. pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
  442. // 整形预留3
  443. pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
  444. // 整形预留4
  445. pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
  446. // 整形预留5
  447. pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
  448. // 整形预留6
  449. pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
  450. // 整形预留7
  451. pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
  452. // 整形预留8
  453. pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
  454. // 整形预留9
  455. pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
  456. // 整形预留10
  457. pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
  458. CString strBoolReserved1 = (*it_bool_reserved1++).c_str();
  459. //LOG4C((LOG_NOTICE, "strBoolReserved1=%s", strBoolReserved1));
  460. //布尔型预留1
  461. if( 0 == atoi(strBoolReserved1) )
  462. {
  463. pDev->m_bReserved1 = false;
  464. }
  465. else
  466. {
  467. pDev->m_bReserved1 = true;
  468. }
  469. //布尔型预留2
  470. if( 0 == atoi((*it_bool_reserved2++).c_str()) )
  471. {
  472. pDev->m_bReserved2 = false;
  473. }
  474. else
  475. {
  476. pDev->m_bReserved2 = true;
  477. }
  478. //布尔型预留3
  479. if( 0 == atoi((*it_bool_reserved3++).c_str()) )
  480. {
  481. pDev->m_bReserved3 = false;
  482. }
  483. else
  484. {
  485. pDev->m_bReserved3 = true;
  486. }
  487. //布尔型预留4
  488. if( 0 == atoi((*it_bool_reserved4++).c_str()) )
  489. {
  490. pDev->m_bReserved4 = false;
  491. }
  492. else
  493. {
  494. pDev->m_bReserved4 = true;
  495. }
  496. //布尔型预留5
  497. if( 0 == atoi((*it_bool_reserved5++).c_str()) )
  498. {
  499. pDev->m_bReserved5 = false;
  500. }
  501. else
  502. {
  503. pDev->m_bReserved5 = true;
  504. }
  505. //布尔型预留6
  506. if( 0 == atoi((*it_bool_reserved6++).c_str()) )
  507. {
  508. pDev->m_bReserved6 = false;
  509. }
  510. else
  511. {
  512. pDev->m_bReserved6 = true;
  513. }
  514. //布尔型预留7
  515. if( 0 == atoi((*it_bool_reserved7++).c_str()) )
  516. {
  517. pDev->m_bReserved7 = false;
  518. }
  519. else
  520. {
  521. pDev->m_bReserved7 = true;
  522. }
  523. //布尔型预留8
  524. if( 0 == atoi((*it_bool_reserved8++).c_str()) )
  525. {
  526. pDev->m_bReserved8 = false;
  527. }
  528. else
  529. {
  530. pDev->m_bReserved8 = true;
  531. }
  532. //布尔型预留9
  533. if( 0 == atoi((*it_bool_reserved9++).c_str()) )
  534. {
  535. pDev->m_bReserved9 = false;
  536. }
  537. else
  538. {
  539. pDev->m_bReserved9 = true;
  540. }
  541. //布尔型预留10
  542. if( 0 == atoi((*it_bool_reserved10++).c_str()) )
  543. {
  544. pDev->m_bReserved10 = false;
  545. }
  546. else
  547. {
  548. pDev->m_bReserved10 = true;
  549. }
  550. if( g_pDevicesManager )
  551. {
  552. GetVarInfo((void *)pDev, (char *)(LPCTSTR)pDev->m_strUid );
  553. int nVarSize = (int)pDev->m_Vars.GetSize();
  554. for( int j = 0; j < nVarSize; j++ )
  555. {
  556. CBaseVar *pBaseVar = pDev->m_Vars[j];
  557. }
  558. //LOG4C((LOG_NOTICE, "add device desc %s", pDev->m_strDeviceName));
  559. g_pDevicesManager->m_Devices.Add(pDev);
  560. }
  561. }
  562. }
  563. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  564. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  565. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  566. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  567. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  568. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  569. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  570. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  571. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  572. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  573. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  574. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  575. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  576. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  577. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  578. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  579. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  580. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  581. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  582. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  583. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  584. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  585. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  586. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  587. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  588. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  589. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  590. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  591. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  592. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  593. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  594. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  595. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  596. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  597. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  598. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  599. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  600. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  601. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  602. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  603. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  604. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  605. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  606. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  607. )
  608. {
  609. list_dev_id.erase(it_dev_id++);
  610. list_uid.erase(it_uid++);
  611. list_port.erase(it_port++);
  612. list_device_name.erase(it_device_name++);
  613. list_device_baudrate.erase(it_device_baudrate++);
  614. list_commmode.erase(it_commmode++);
  615. list_devide_addr.erase(it_devide_addr++);
  616. list_is_use.erase(it_is_use++);
  617. list_protocol_dll_name.erase(it_protocol_dll_name++);
  618. list_special_device.erase(it_special_device++);
  619. list_data_bit.erase(it_data_bit++);
  620. list_stop_bit.erase(it_stop_bit++);
  621. list_parity_bit.erase(it_parity_bit++);
  622. list_ip.erase(it_ip++);
  623. list_ip_port.erase(it_ip_port++);
  624. list_ini_name.erase(it_ini_name++);
  625. list_str_reserved1.erase(it_str_reserved1++);
  626. list_str_reserved2.erase(it_str_reserved2++);
  627. list_str_reserved3.erase(it_str_reserved3++);
  628. list_str_reserved4.erase(it_str_reserved4++);
  629. list_str_reserved5.erase(it_str_reserved5++);
  630. list_str_reserved6.erase(it_str_reserved6++);
  631. list_str_reserved7.erase(it_str_reserved7++);
  632. list_str_reserved8.erase(it_str_reserved8++);
  633. list_str_reserved9.erase(it_str_reserved9++);
  634. list_str_reserved10.erase(it_str_reserved10++);
  635. list_int_reserved1.erase(it_int_reserved1++);
  636. list_int_reserved2.erase(it_int_reserved2++);
  637. list_int_reserved3.erase(it_int_reserved3++);
  638. list_int_reserved4.erase(it_int_reserved4++);
  639. list_int_reserved5.erase(it_int_reserved5++);
  640. list_int_reserved6.erase(it_int_reserved6++);
  641. list_int_reserved7.erase(it_int_reserved7++);
  642. list_int_reserved8.erase(it_int_reserved8++);
  643. list_int_reserved9.erase(it_int_reserved9++);
  644. list_int_reserved10.erase(it_int_reserved10++);
  645. list_bool_reserved1.erase(it_bool_reserved1++);
  646. list_bool_reserved2.erase(it_bool_reserved2++);
  647. list_bool_reserved3.erase(it_bool_reserved3++);
  648. list_bool_reserved4.erase(it_bool_reserved4++);
  649. list_bool_reserved5.erase(it_bool_reserved5++);
  650. list_bool_reserved6.erase(it_bool_reserved6++);
  651. list_bool_reserved7.erase(it_bool_reserved7++);
  652. list_bool_reserved8.erase(it_bool_reserved8++);
  653. list_bool_reserved9.erase(it_bool_reserved9++);
  654. list_bool_reserved10.erase(it_bool_reserved10++);
  655. }
  656. return nRet;
  657. }
  658. // 修改设备资料
  659. INT CDBInterface::EditDevInfo()
  660. {
  661. CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
  662. list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
  663. list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
  664. list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
  665. list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
  666. list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
  667. list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
  668. list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
  669. list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
  670. list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
  671. list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
  672. list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
  673. list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
  674. list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
  675. list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
  676. list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
  677. list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
  678. list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
  679. list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
  680. sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
  681. " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
  682. " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  683. " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  684. " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  685. " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  686. " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  687. " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  688. " from t_dev_property where isuse = '1'");
  689. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
  690. ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
  691. ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
  692. ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
  693. ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
  694. ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
  695. ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
  696. ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
  697. ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
  698. ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
  699. if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
  700. || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
  701. || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
  702. || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
  703. || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
  704. || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
  705. || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
  706. || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
  707. || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
  708. || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
  709. || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
  710. || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
  711. || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
  712. || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
  713. || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
  714. )
  715. {
  716. LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
  717. return 0;
  718. }
  719. int nDeviceIndex = 0;
  720. if( nRet != -1 )
  721. {
  722. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  723. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  724. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  725. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  726. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  727. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  728. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  729. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  730. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  731. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  732. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  733. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  734. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  735. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  736. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  737. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  738. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  739. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  740. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  741. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  742. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  743. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  744. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  745. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  746. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  747. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  748. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  749. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  750. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  751. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  752. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  753. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  754. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  755. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  756. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  757. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  758. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  759. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  760. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  761. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  762. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  763. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  764. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  765. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  766. )
  767. {
  768. CDevice* pDev = g_pDevicesManager->m_Devices[nDeviceIndex];
  769. // 获取设备ID
  770. pDev->m_iID = atoi((*it_dev_id++).c_str());
  771. // 获取设备UID
  772. pDev->m_strUid = (*it_uid++).c_str();
  773. // 获取设备端口号
  774. pDev->m_iPort = atoi((*it_port++).c_str());
  775. // 获取设备名称
  776. pDev->m_strDeviceName = (*it_device_name++).c_str();
  777. // 获取设备的波特率
  778. pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
  779. // 获取设备的数据位
  780. pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
  781. // 获取设备的停止位
  782. pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
  783. // 获取设备的校验位
  784. pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
  785. // 通信的方式
  786. pDev->m_iCommmode = atoi((*it_commmode++).c_str());
  787. // 设备地址
  788. pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
  789. // 设备是否启用
  790. CString strIsUse = (*it_is_use++).c_str();
  791. if( 0 == atoi(strIsUse) )
  792. {
  793. pDev->m_iIsuse = FALSE;
  794. }
  795. else
  796. {
  797. pDev->m_iIsuse = TRUE;
  798. }
  799. // 协议DLL名称
  800. pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
  801. // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
  802. CString strSpecialDevice = (*it_special_device++).c_str();
  803. pDev->m_bySpecialdevice = atoi(strSpecialDevice);
  804. //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
  805. // 设备IP
  806. pDev->m_strIp = (*it_ip++).c_str();
  807. // 网络通信端口
  808. pDev->m_iIpport = atoi((*it_ip_port++).c_str());
  809. // ini配置文件名称
  810. pDev->m_strIniName = (*it_ini_name++).c_str();
  811. // 字符串预留1
  812. pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
  813. // 字符串预留2
  814. pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
  815. // 字符串预留3
  816. pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
  817. // 字符串预留4
  818. pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
  819. // 字符串预留5
  820. pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
  821. // 字符串预留6
  822. pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
  823. // 字符串预留7
  824. pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
  825. // 字符串预留8
  826. pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
  827. // 字符串预留9
  828. pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
  829. // 字符串预留10
  830. pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
  831. // 整形预留1
  832. pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
  833. // 整形预留2
  834. pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
  835. // 整形预留3
  836. pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
  837. // 整形预留4
  838. pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
  839. // 整形预留5
  840. pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
  841. // 整形预留6
  842. pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
  843. // 整形预留7
  844. pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
  845. // 整形预留8
  846. pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
  847. // 整形预留9
  848. pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
  849. // 整形预留10
  850. pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
  851. //布尔型预留1
  852. if( 0 == atoi((*it_bool_reserved1++).c_str()) )
  853. {
  854. pDev->m_bReserved1 = false;
  855. }
  856. else
  857. {
  858. pDev->m_bReserved1 = true;
  859. }
  860. //布尔型预留2
  861. if( 0 == atoi((*it_bool_reserved2++).c_str()) )
  862. {
  863. pDev->m_bReserved2 = false;
  864. }
  865. else
  866. {
  867. pDev->m_bReserved2 = true;
  868. }
  869. //布尔型预留3
  870. if( 0 == atoi((*it_bool_reserved3++).c_str()) )
  871. {
  872. pDev->m_bReserved3 = false;
  873. }
  874. else
  875. {
  876. pDev->m_bReserved3 = true;
  877. }
  878. //布尔型预留4
  879. if( 0 == atoi((*it_bool_reserved4++).c_str()) )
  880. {
  881. pDev->m_bReserved4 = false;
  882. }
  883. else
  884. {
  885. pDev->m_bReserved4 = true;
  886. }
  887. //布尔型预留5
  888. if( 0 == atoi((*it_bool_reserved5++).c_str()) )
  889. {
  890. pDev->m_bReserved5 = false;
  891. }
  892. else
  893. {
  894. pDev->m_bReserved5 = true;
  895. }
  896. //布尔型预留6
  897. if( 0 == atoi((*it_bool_reserved6++).c_str()) )
  898. {
  899. pDev->m_bReserved6 = false;
  900. }
  901. else
  902. {
  903. pDev->m_bReserved6 = true;
  904. }
  905. //布尔型预留7
  906. if( 0 == atoi((*it_bool_reserved7++).c_str()) )
  907. {
  908. pDev->m_bReserved7 = false;
  909. }
  910. else
  911. {
  912. pDev->m_bReserved7 = true;
  913. }
  914. //布尔型预留8
  915. if( 0 == atoi((*it_bool_reserved8++).c_str()) )
  916. {
  917. pDev->m_bReserved8 = false;
  918. }
  919. else
  920. {
  921. pDev->m_bReserved8 = true;
  922. }
  923. //布尔型预留9
  924. if( 0 == atoi((*it_bool_reserved9++).c_str()) )
  925. {
  926. pDev->m_bReserved9 = false;
  927. }
  928. else
  929. {
  930. pDev->m_bReserved9 = true;
  931. }
  932. //布尔型预留10
  933. if( 0 == atoi((*it_bool_reserved10++).c_str()) )
  934. {
  935. pDev->m_bReserved10 = false;
  936. }
  937. else
  938. {
  939. pDev->m_bReserved10 = true;
  940. }
  941. nDeviceIndex++;
  942. }
  943. }
  944. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  945. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  946. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  947. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  948. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  949. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  950. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  951. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  952. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  953. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  954. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  955. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  956. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  957. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  958. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  959. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  960. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  961. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  962. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  963. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  964. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  965. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  966. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  967. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  968. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  969. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  970. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  971. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  972. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  973. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  974. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  975. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  976. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  977. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  978. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  979. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  980. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  981. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  982. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  983. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  984. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  985. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  986. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  987. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  988. )
  989. {
  990. list_dev_id.erase(it_dev_id++);
  991. list_uid.erase(it_uid++);
  992. list_port.erase(it_port++);
  993. list_device_name.erase(it_device_name++);
  994. list_device_baudrate.erase(it_device_baudrate++);
  995. list_commmode.erase(it_commmode++);
  996. list_devide_addr.erase(it_devide_addr++);
  997. list_is_use.erase(it_is_use++);
  998. list_protocol_dll_name.erase(it_protocol_dll_name++);
  999. list_special_device.erase(it_special_device++);
  1000. list_data_bit.erase(it_data_bit++);
  1001. list_stop_bit.erase(it_stop_bit++);
  1002. list_parity_bit.erase(it_parity_bit++);
  1003. list_ip.erase(it_ip++);
  1004. list_ip_port.erase(it_ip_port++);
  1005. list_ini_name.erase(it_ini_name++);
  1006. list_str_reserved1.erase(it_str_reserved1++);
  1007. list_str_reserved2.erase(it_str_reserved2++);
  1008. list_str_reserved3.erase(it_str_reserved3++);
  1009. list_str_reserved4.erase(it_str_reserved4++);
  1010. list_str_reserved5.erase(it_str_reserved5++);
  1011. list_str_reserved6.erase(it_str_reserved6++);
  1012. list_str_reserved7.erase(it_str_reserved7++);
  1013. list_str_reserved8.erase(it_str_reserved8++);
  1014. list_str_reserved9.erase(it_str_reserved9++);
  1015. list_str_reserved10.erase(it_str_reserved10++);
  1016. list_int_reserved1.erase(it_int_reserved1++);
  1017. list_int_reserved2.erase(it_int_reserved2++);
  1018. list_int_reserved3.erase(it_int_reserved3++);
  1019. list_int_reserved4.erase(it_int_reserved4++);
  1020. list_int_reserved5.erase(it_int_reserved5++);
  1021. list_int_reserved6.erase(it_int_reserved6++);
  1022. list_int_reserved7.erase(it_int_reserved7++);
  1023. list_int_reserved8.erase(it_int_reserved8++);
  1024. list_int_reserved9.erase(it_int_reserved9++);
  1025. list_int_reserved10.erase(it_int_reserved10++);
  1026. list_bool_reserved1.erase(it_bool_reserved1++);
  1027. list_bool_reserved2.erase(it_bool_reserved2++);
  1028. list_bool_reserved3.erase(it_bool_reserved3++);
  1029. list_bool_reserved4.erase(it_bool_reserved4++);
  1030. list_bool_reserved5.erase(it_bool_reserved5++);
  1031. list_bool_reserved6.erase(it_bool_reserved6++);
  1032. list_bool_reserved7.erase(it_bool_reserved7++);
  1033. list_bool_reserved8.erase(it_bool_reserved8++);
  1034. list_bool_reserved9.erase(it_bool_reserved9++);
  1035. list_bool_reserved10.erase(it_bool_reserved10++);
  1036. }
  1037. return nRet;
  1038. }
  1039. // 修改设备资料
  1040. INT CDBInterface::EditDevInfo(int nDevideIndex, char *pDevUid)
  1041. {
  1042. CDevice *pDev = g_pDevicesManager->m_Devices[nDevideIndex];
  1043. CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
  1044. list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
  1045. list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
  1046. list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
  1047. list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
  1048. list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
  1049. list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
  1050. list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
  1051. list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
  1052. list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
  1053. list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
  1054. list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
  1055. list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
  1056. list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
  1057. list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
  1058. list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
  1059. list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
  1060. list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
  1061. list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
  1062. sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
  1063. " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
  1064. " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  1065. " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  1066. " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  1067. " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  1068. " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  1069. " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  1070. " from t_dev_property where uid = '%s'", pDevUid);
  1071. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
  1072. ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
  1073. ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
  1074. ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
  1075. ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
  1076. ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
  1077. ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
  1078. ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
  1079. ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
  1080. ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
  1081. if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
  1082. || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
  1083. || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
  1084. || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
  1085. || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
  1086. || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
  1087. || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
  1088. || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
  1089. || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
  1090. || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
  1091. || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
  1092. || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
  1093. || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
  1094. || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
  1095. || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
  1096. )
  1097. {
  1098. LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
  1099. return 0;
  1100. }
  1101. if( nRet != -1 )
  1102. {
  1103. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  1104. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  1105. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  1106. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  1107. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  1108. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  1109. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  1110. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  1111. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  1112. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  1113. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  1114. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  1115. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  1116. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  1117. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  1118. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  1119. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  1120. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  1121. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  1122. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  1123. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  1124. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  1125. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  1126. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  1127. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  1128. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  1129. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  1130. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  1131. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  1132. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  1133. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  1134. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  1135. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  1136. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  1137. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  1138. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  1139. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  1140. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  1141. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  1142. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  1143. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  1144. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  1145. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  1146. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  1147. )
  1148. {
  1149. // 获取设备ID
  1150. pDev->m_iID = atoi((*it_dev_id++).c_str());
  1151. // 获取设备UID
  1152. pDev->m_strUid = (*it_uid++).c_str();
  1153. // 获取设备端口号
  1154. pDev->m_iPort = atoi((*it_port++).c_str());
  1155. // 获取设备名称
  1156. pDev->m_strDeviceName = (*it_device_name++).c_str();
  1157. // 获取设备的波特率
  1158. pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
  1159. // 获取设备的数据位
  1160. pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
  1161. // 获取设备的停止位
  1162. pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
  1163. // 获取设备的校验位
  1164. pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
  1165. // 通信的方式
  1166. pDev->m_iCommmode = atoi((*it_commmode++).c_str());
  1167. // 设备地址
  1168. pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
  1169. // 设备是否启用
  1170. CString strIsUse = (*it_is_use++).c_str();
  1171. if( 0 == atoi(strIsUse) )
  1172. {
  1173. pDev->m_iIsuse = FALSE;
  1174. }
  1175. else
  1176. {
  1177. pDev->m_iIsuse = TRUE;
  1178. }
  1179. // 协议DLL名称
  1180. pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
  1181. // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
  1182. CString strSpecialDevice = (*it_special_device++).c_str();
  1183. pDev->m_bySpecialdevice = atoi(strSpecialDevice);
  1184. //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
  1185. // 设备IP
  1186. pDev->m_strIp = (*it_ip++).c_str();
  1187. // 网络通信端口
  1188. pDev->m_iIpport = atoi((*it_ip_port++).c_str());
  1189. // ini配置文件名称
  1190. pDev->m_strIniName = (*it_ini_name++).c_str();
  1191. // 字符串预留1
  1192. pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
  1193. // 字符串预留2
  1194. pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
  1195. // 字符串预留3
  1196. pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
  1197. // 字符串预留4
  1198. pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
  1199. // 字符串预留5
  1200. pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
  1201. // 字符串预留6
  1202. pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
  1203. // 字符串预留7
  1204. pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
  1205. // 字符串预留8
  1206. pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
  1207. // 字符串预留9
  1208. pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
  1209. // 字符串预留10
  1210. pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
  1211. // 整形预留1
  1212. pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
  1213. // 整形预留2
  1214. pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
  1215. // 整形预留3
  1216. pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
  1217. // 整形预留4
  1218. pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
  1219. // 整形预留5
  1220. pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
  1221. // 整形预留6
  1222. pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
  1223. // 整形预留7
  1224. pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
  1225. // 整形预留8
  1226. pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
  1227. // 整形预留9
  1228. pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
  1229. // 整形预留10
  1230. pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
  1231. //布尔型预留1
  1232. if( 0 == atoi((*it_bool_reserved1++).c_str()) )
  1233. {
  1234. pDev->m_bReserved1 = false;
  1235. }
  1236. else
  1237. {
  1238. pDev->m_bReserved1 = true;
  1239. }
  1240. //布尔型预留2
  1241. if( 0 == atoi((*it_bool_reserved2++).c_str()) )
  1242. {
  1243. pDev->m_bReserved2 = false;
  1244. }
  1245. else
  1246. {
  1247. pDev->m_bReserved2 = true;
  1248. }
  1249. //布尔型预留3
  1250. if( 0 == atoi((*it_bool_reserved3++).c_str()) )
  1251. {
  1252. pDev->m_bReserved3 = false;
  1253. }
  1254. else
  1255. {
  1256. pDev->m_bReserved3 = true;
  1257. }
  1258. //布尔型预留4
  1259. if( 0 == atoi((*it_bool_reserved4++).c_str()) )
  1260. {
  1261. pDev->m_bReserved4 = false;
  1262. }
  1263. else
  1264. {
  1265. pDev->m_bReserved4 = true;
  1266. }
  1267. //布尔型预留5
  1268. if( 0 == atoi((*it_bool_reserved5++).c_str()) )
  1269. {
  1270. pDev->m_bReserved5 = false;
  1271. }
  1272. else
  1273. {
  1274. pDev->m_bReserved5 = true;
  1275. }
  1276. //布尔型预留6
  1277. if( 0 == atoi((*it_bool_reserved6++).c_str()) )
  1278. {
  1279. pDev->m_bReserved6 = false;
  1280. }
  1281. else
  1282. {
  1283. pDev->m_bReserved6 = true;
  1284. }
  1285. //布尔型预留7
  1286. if( 0 == atoi((*it_bool_reserved7++).c_str()) )
  1287. {
  1288. pDev->m_bReserved7 = false;
  1289. }
  1290. else
  1291. {
  1292. pDev->m_bReserved7 = true;
  1293. }
  1294. //布尔型预留8
  1295. if( 0 == atoi((*it_bool_reserved8++).c_str()) )
  1296. {
  1297. pDev->m_bReserved8 = false;
  1298. }
  1299. else
  1300. {
  1301. pDev->m_bReserved8 = true;
  1302. }
  1303. //布尔型预留9
  1304. if( 0 == atoi((*it_bool_reserved9++).c_str()) )
  1305. {
  1306. pDev->m_bReserved9 = false;
  1307. }
  1308. else
  1309. {
  1310. pDev->m_bReserved9 = true;
  1311. }
  1312. //布尔型预留10
  1313. if( 0 == atoi((*it_bool_reserved10++).c_str()) )
  1314. {
  1315. pDev->m_bReserved10 = false;
  1316. }
  1317. else
  1318. {
  1319. pDev->m_bReserved10 = true;
  1320. }
  1321. break;
  1322. }
  1323. }
  1324. for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
  1325. ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
  1326. ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
  1327. ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
  1328. ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
  1329. ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
  1330. ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
  1331. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  1332. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  1333. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  1334. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  1335. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  1336. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  1337. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  1338. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  1339. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  1340. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  1341. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  1342. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  1343. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  1344. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  1345. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  1346. it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
  1347. ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
  1348. ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
  1349. ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
  1350. ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
  1351. ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
  1352. ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
  1353. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  1354. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  1355. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  1356. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  1357. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  1358. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  1359. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  1360. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  1361. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  1362. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  1363. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  1364. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  1365. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  1366. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  1367. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  1368. )
  1369. {
  1370. list_dev_id.erase(it_dev_id++);
  1371. list_uid.erase(it_uid++);
  1372. list_port.erase(it_port++);
  1373. list_device_name.erase(it_device_name++);
  1374. list_device_baudrate.erase(it_device_baudrate++);
  1375. list_commmode.erase(it_commmode++);
  1376. list_devide_addr.erase(it_devide_addr++);
  1377. list_is_use.erase(it_is_use++);
  1378. list_protocol_dll_name.erase(it_protocol_dll_name++);
  1379. list_special_device.erase(it_special_device++);
  1380. list_data_bit.erase(it_data_bit++);
  1381. list_stop_bit.erase(it_stop_bit++);
  1382. list_parity_bit.erase(it_parity_bit++);
  1383. list_ip.erase(it_ip++);
  1384. list_ip_port.erase(it_ip_port++);
  1385. list_ini_name.erase(it_ini_name++);
  1386. list_str_reserved1.erase(it_str_reserved1++);
  1387. list_str_reserved2.erase(it_str_reserved2++);
  1388. list_str_reserved3.erase(it_str_reserved3++);
  1389. list_str_reserved4.erase(it_str_reserved4++);
  1390. list_str_reserved5.erase(it_str_reserved5++);
  1391. list_str_reserved6.erase(it_str_reserved6++);
  1392. list_str_reserved7.erase(it_str_reserved7++);
  1393. list_str_reserved8.erase(it_str_reserved8++);
  1394. list_str_reserved9.erase(it_str_reserved9++);
  1395. list_str_reserved10.erase(it_str_reserved10++);
  1396. list_int_reserved1.erase(it_int_reserved1++);
  1397. list_int_reserved2.erase(it_int_reserved2++);
  1398. list_int_reserved3.erase(it_int_reserved3++);
  1399. list_int_reserved4.erase(it_int_reserved4++);
  1400. list_int_reserved5.erase(it_int_reserved5++);
  1401. list_int_reserved6.erase(it_int_reserved6++);
  1402. list_int_reserved7.erase(it_int_reserved7++);
  1403. list_int_reserved8.erase(it_int_reserved8++);
  1404. list_int_reserved9.erase(it_int_reserved9++);
  1405. list_int_reserved10.erase(it_int_reserved10++);
  1406. list_bool_reserved1.erase(it_bool_reserved1++);
  1407. list_bool_reserved2.erase(it_bool_reserved2++);
  1408. list_bool_reserved3.erase(it_bool_reserved3++);
  1409. list_bool_reserved4.erase(it_bool_reserved4++);
  1410. list_bool_reserved5.erase(it_bool_reserved5++);
  1411. list_bool_reserved6.erase(it_bool_reserved6++);
  1412. list_bool_reserved7.erase(it_bool_reserved7++);
  1413. list_bool_reserved8.erase(it_bool_reserved8++);
  1414. list_bool_reserved9.erase(it_bool_reserved9++);
  1415. list_bool_reserved10.erase(it_bool_reserved10++);
  1416. }
  1417. return nRet;
  1418. }
  1419. //获取变量
  1420. INT CDBInterface::GetVarInfo(void *pPara, CHAR *pUid)
  1421. {
  1422. //LOG4C((LOG_NOTICE,"再次读取变量"));
  1423. CDevice *pDev = (CDevice *)pPara;
  1424. CHAR strSQLText[MAX_SQL_LENGTH * 2] = {0};
  1425. list<string> list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit;
  1426. list<string> list_lower_limit, list_normal_state, list_identify_time, list_redetect_time;
  1427. list<string> list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description;
  1428. list<string> list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save;
  1429. list<string> list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit;
  1430. list<string> list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets;
  1431. list<string> list_funcid, list_data_len, list_coefficient, list_realtimeflag;
  1432. list<string> list_rs232_cmd, list_rs232_type, list_rs232_index;
  1433. list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
  1434. list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
  1435. list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
  1436. list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
  1437. list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
  1438. list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
  1439. list<string>::iterator it_var_id, it_set_value, it_var_name, it_uid, it_upper_limit;
  1440. list<string>::iterator it_lower_limit, it_normal_state, it_identify_time, it_redetect_time;
  1441. list<string>::iterator it_normal_is_notice, it_warn_level, it_snmp_oid, it_fields, it_description;
  1442. list<string>::iterator it_max_values, it_min_values, it_max_convtrate, it_min_convtrate, it_is_save;
  1443. list<string>::iterator it_collect_freq, it_var_type_id, it_readonly, it_is_dde, it_address, it_unit;
  1444. list<string>::iterator it_reccurve, it_register_num, it_child_id, it_var_item_id, it_rearm, it_offsets;
  1445. list<string>::iterator it_funcid, it_data_len, it_coefficient, it_realtimeflag;
  1446. list<string>::iterator it_rs232_cmd, it_rs232_type, it_rs232_index;
  1447. list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
  1448. list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
  1449. list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
  1450. list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
  1451. list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
  1452. list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
  1453. if (!_stricmp(m_chDBType, "SQL SERVER"))
  1454. {
  1455. sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  1456. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  1457. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  1458. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  1459. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  1460. "rs232cmd, rs232type, rs232index, " \
  1461. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  1462. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  1463. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  1464. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  1465. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  1466. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  1467. "from t_dev_variant where uid = \'%s\' order by id", pUid);
  1468. }
  1469. else if (!_stricmp(m_chDBType, "ACCESS97"))
  1470. {
  1471. sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  1472. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  1473. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  1474. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  1475. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  1476. "rs232cmd, rs232type, rs232index, " \
  1477. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  1478. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  1479. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  1480. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  1481. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  1482. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  1483. "from t_dev_variant where uid = \'%s\' order by id", pUid);
  1484. }
  1485. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  1486. {
  1487. sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  1488. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  1489. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  1490. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  1491. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  1492. "rs232cmd, rs232type, rs232index, " \
  1493. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  1494. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  1495. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  1496. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  1497. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  1498. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  1499. "from t_dev_variant where uid = \'%s\' order by id", pUid);
  1500. }
  1501. else if(!_stricmp(m_chDBType, "PGSQL"))
  1502. {
  1503. sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  1504. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  1505. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  1506. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  1507. "var_item_id, rearm, offsets, funcid, datalen, coefficient, realtimeflag, " \
  1508. "rs232cmd, rs232type, rs232index, " \
  1509. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  1510. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  1511. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  1512. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  1513. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  1514. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  1515. "from t_dev_variant where uid = \'%s\' order by id", pUid);
  1516. }
  1517. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  1518. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList68(strSQLText
  1519. ,list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit
  1520. ,list_lower_limit, list_normal_state, list_identify_time, list_redetect_time
  1521. ,list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description
  1522. ,list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save
  1523. ,list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit
  1524. ,list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets
  1525. ,list_funcid, list_data_len, list_coefficient, list_realtimeflag
  1526. ,list_rs232_cmd, list_rs232_type, list_rs232_index
  1527. ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
  1528. ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
  1529. ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
  1530. ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
  1531. ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
  1532. ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
  1533. if( 0 == list_var_id.size() || 0 == list_set_value.size() || 0 == list_var_name.size()
  1534. || 0 == list_uid.size() || 0 == list_upper_limit.size() || 0 == list_lower_limit.size()
  1535. || 0 == list_normal_state.size() || 0 == list_identify_time.size() || 0 == list_redetect_time.size()
  1536. || 0 == list_normal_is_notice.size() || 0 == list_warn_level.size() || 0 == list_snmp_oid.size()
  1537. || 0 == list_fields.size() || 0 == list_description.size() || 0 == list_max_values.size() || 0 == list_min_values.size()
  1538. || 0 == list_max_convtrate.size() || 0 == list_min_convtrate.size() || 0 == list_is_save.size()
  1539. || 0 == list_collect_freq.size() || 0 == list_var_type_id.size() || 0 == list_readonly.size()
  1540. || 0 == list_is_dde.size() || 0 == list_address.size() || 0 == list_unit.size()
  1541. || 0 == list_reccurve.size() || 0 == list_register_num.size() || 0 == list_child_id.size()
  1542. || 0 == list_var_item_id.size() || 0 == list_rearm.size() || 0 == list_offsets.size()
  1543. || 0 == list_funcid.size() || 0 == list_data_len.size() || 0 == list_coefficient.size()
  1544. || 0 == list_realtimeflag.size() || 0 == list_rs232_cmd.size() || 0 == list_rs232_type.size() || 0 == list_rs232_index.size()
  1545. || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
  1546. || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
  1547. || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
  1548. || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
  1549. || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
  1550. || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
  1551. || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
  1552. || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
  1553. || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
  1554. || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
  1555. )
  1556. {
  1557. LOG4C((LOG_NOTICE, "device name = %s has not variant!", pDev->m_strDeviceName));
  1558. return 0;
  1559. }
  1560. if( nRet != -1 )
  1561. {
  1562. for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
  1563. ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
  1564. ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
  1565. ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
  1566. ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
  1567. ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
  1568. ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
  1569. ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
  1570. ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
  1571. ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
  1572. ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
  1573. ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
  1574. ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
  1575. ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
  1576. ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
  1577. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  1578. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  1579. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  1580. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  1581. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  1582. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  1583. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  1584. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  1585. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  1586. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  1587. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  1588. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  1589. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  1590. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  1591. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  1592. it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
  1593. ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
  1594. ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
  1595. ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
  1596. ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
  1597. ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
  1598. ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
  1599. ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
  1600. ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
  1601. ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
  1602. ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
  1603. ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
  1604. ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
  1605. ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
  1606. ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
  1607. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  1608. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  1609. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  1610. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  1611. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  1612. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  1613. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  1614. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  1615. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  1616. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  1617. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  1618. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  1619. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  1620. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  1621. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  1622. )
  1623. {
  1624. CBaseVar *pBaseVar;
  1625. pBaseVar = new CBaseVar();
  1626. int nVarID;
  1627. CString strUid;
  1628. nVarID = atoi((*it_var_id++).c_str());
  1629. strUid = (*it_uid++).c_str();
  1630. // 变量ID
  1631. pBaseVar->m_nVarID = nVarID;
  1632. // 设定值
  1633. pBaseVar->m_strSetValue = (*it_set_value++).c_str();
  1634. // 变量名称
  1635. pBaseVar->m_strName = (*it_var_name++).c_str();
  1636. // 变量Uid
  1637. pBaseVar->m_strVarUID = strUid;
  1638. // 上限
  1639. pBaseVar->m_nUpperLimit = atoi((*it_upper_limit++).c_str());
  1640. //LOG4C((LOG_NOTICE, "GetVarInfo pBaseVar->m_nUpperLimit = %d", pBaseVar->m_nUpperLimit));
  1641. // 下限
  1642. pBaseVar->m_nLowerLimit = atoi((*it_lower_limit++).c_str());
  1643. // 正常状态
  1644. pBaseVar->m_nNormalState = atoi((*it_normal_state++).c_str());
  1645. // 辨识时间
  1646. pBaseVar->m_nIdentifyTime = atoi((*it_identify_time++).c_str());
  1647. // 重新检测时间
  1648. pBaseVar->m_nReDetectTime = atoi((*it_redetect_time++).c_str());
  1649. // 恢复正常是否触发远程报警
  1650. CString strNormalIsNotice = (*it_normal_is_notice++).c_str();
  1651. if( 0 == atoi(strNormalIsNotice) )
  1652. {
  1653. pBaseVar->m_bNormalIsNotice = FALSE;
  1654. }
  1655. else
  1656. {
  1657. pBaseVar->m_bNormalIsNotice = TRUE;
  1658. }
  1659. // 报警级别
  1660. pBaseVar->m_nWaringLevel = atoi((*it_warn_level++).c_str());
  1661. // Snmp对象OID
  1662. pBaseVar->m_strSnmpoi = (*it_snmp_oid++).c_str();
  1663. // Snmp对象域
  1664. pBaseVar->m_strFields = (*it_fields++).c_str();
  1665. // 变量描述
  1666. pBaseVar->m_strDesc = (*it_description++).c_str();
  1667. // 最大值
  1668. pBaseVar->m_nMaxValues = atoi((*it_max_values++).c_str());
  1669. // 最小值
  1670. pBaseVar->m_nMinValues = atoi((*it_min_values++).c_str());
  1671. // 最大比例
  1672. pBaseVar->m_nMaxConvtRate = atoi((*it_max_convtrate++).c_str());
  1673. // 最小比例
  1674. pBaseVar->m_nMinConvtRate = atoi((*it_min_convtrate++).c_str());
  1675. // 是否保存数值
  1676. CString strIsSave = (*it_is_save++).c_str();
  1677. if( 0 == atoi(strIsSave) )
  1678. {
  1679. pBaseVar->m_bIsSave = FALSE;
  1680. }
  1681. else
  1682. {
  1683. pBaseVar->m_bIsSave = TRUE;
  1684. }
  1685. //LOG4C((LOG_NOTICE, "var desc = %s, pBaseVar->m_bIsSave = %d, strIsSave = %s", pBaseVar->m_strDesc, pBaseVar->m_bIsSave, strIsSave));
  1686. // 采集频率
  1687. pBaseVar->m_nCollectFreq = atoi((*it_collect_freq++).c_str());
  1688. // 变量类型ID
  1689. pBaseVar->m_nVarTypeID = atoi((*it_var_type_id++).c_str());
  1690. // 读写权限
  1691. CString strReadOnly = (*it_readonly++).c_str();
  1692. if( 0 == atoi(strReadOnly) )
  1693. {
  1694. pBaseVar->m_bReadOnly = FALSE;
  1695. }
  1696. else
  1697. {
  1698. pBaseVar->m_bReadOnly = TRUE;
  1699. }
  1700. // 是否DDE
  1701. CString strDDE = (*it_is_dde++).c_str();
  1702. if( 0 == atoi(strDDE) )
  1703. {
  1704. pBaseVar->m_bIsDDE = FALSE;
  1705. }
  1706. else
  1707. {
  1708. pBaseVar->m_bIsDDE = TRUE;
  1709. }
  1710. // 寄存器起始地址
  1711. pBaseVar->m_nRegStartAddr = atoi((*it_address++).c_str());
  1712. // 单位
  1713. pBaseVar->m_strUnit = (*it_unit++).c_str();
  1714. // 是否记录实时曲线
  1715. CString strRecCurve = (*it_reccurve++).c_str();
  1716. if( 0 == atoi(strRecCurve) )
  1717. {
  1718. pBaseVar->m_bRecCurve = FALSE;
  1719. }
  1720. else
  1721. {
  1722. pBaseVar->m_bRecCurve = TRUE;
  1723. }
  1724. // 寄存器个数
  1725. pBaseVar->m_iRegisterNum = atoi((*it_register_num++).c_str());
  1726. // 变量子ID
  1727. pBaseVar->m_iChildID = atoi((*it_child_id++).c_str());
  1728. // t_dev_varint_item表的ID
  1729. pBaseVar->m_nVarItemID = atoi((*it_var_item_id++).c_str());
  1730. // 校正值
  1731. pBaseVar->m_nRearm = atoi((*it_rearm++).c_str());
  1732. // 偏移值
  1733. pBaseVar->m_nOffset = atoi((*it_offsets++).c_str());
  1734. // 功能码ID
  1735. pBaseVar->m_iFuncID = atoi((*it_funcid++).c_str());
  1736. // 数据长度
  1737. pBaseVar->m_iDataLen = atoi((*it_data_len++).c_str());
  1738. // 系数
  1739. pBaseVar->m_dbCoefficient = atof((*it_coefficient++).c_str());
  1740. // 是否实时采集
  1741. CString strRealTimeFlag = (*it_realtimeflag++).c_str();
  1742. //LOG4C((LOG_NOTICE, "strRealTimeFlag = %s, atoi(strRealTimeFlag) = %d", strRealTimeFlag, atoi(strRealTimeFlag)));
  1743. if( 0 == atoi(strRealTimeFlag) )
  1744. {
  1745. pBaseVar->m_bRealTimeflag = FALSE;
  1746. }
  1747. else
  1748. {
  1749. pBaseVar->m_bRealTimeflag = TRUE;
  1750. }
  1751. //LOG4C((LOG_NOTICE, "pBaseVar->m_bRealTimeflag = %d", pBaseVar->m_bRealTimeflag));
  1752. // RS232命令
  1753. pBaseVar->m_strRs232cmd = (*it_rs232_cmd++).c_str();
  1754. // RS232类型
  1755. pBaseVar->m_strRs232type = (*it_rs232_type++).c_str();
  1756. // RS232索引
  1757. pBaseVar->m_strRs232Index = (*it_rs232_index++).c_str();
  1758. //LOG4C((LOG_NOTICE, "pBaseVar->m_strRs232Index = %s", pBaseVar->m_strRs232Index));
  1759. // 字符串预留1
  1760. pBaseVar->m_strReserved1 = (*it_str_reserved1++).c_str();
  1761. // 字符串预留2
  1762. pBaseVar->m_strReserved2 = (*it_str_reserved2++).c_str();
  1763. // 字符串预留3
  1764. pBaseVar->m_strReserved3 = (*it_str_reserved3++).c_str();
  1765. // 字符串预留4
  1766. pBaseVar->m_strReserved4 = (*it_str_reserved4++).c_str();
  1767. // 字符串预留5
  1768. pBaseVar->m_strReserved5 = (*it_str_reserved5++).c_str();
  1769. // 字符串预留6
  1770. pBaseVar->m_strReserved6 = (*it_str_reserved6++).c_str();
  1771. // 字符串预留7
  1772. pBaseVar->m_strReserved7 = (*it_str_reserved7++).c_str();
  1773. // 字符串预留8
  1774. pBaseVar->m_strReserved8 = (*it_str_reserved8++).c_str();
  1775. // 字符串预留9
  1776. pBaseVar->m_strReserved9 = (*it_str_reserved9++).c_str();
  1777. // 字符串预留10
  1778. pBaseVar->m_strReserved10 = (*it_str_reserved10++).c_str();
  1779. // 整形预留1
  1780. pBaseVar->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
  1781. // 整形预留2
  1782. pBaseVar->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
  1783. // 整形预留3
  1784. pBaseVar->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
  1785. // 整形预留4
  1786. pBaseVar->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
  1787. // 整形预留5
  1788. pBaseVar->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
  1789. // 整形预留6
  1790. pBaseVar->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
  1791. // 整形预留7
  1792. pBaseVar->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
  1793. // 整形预留8
  1794. pBaseVar->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
  1795. // 整形预留9
  1796. pBaseVar->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
  1797. // 整形预留10
  1798. pBaseVar->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
  1799. CString strBoolReserved1 = (*it_bool_reserved1++).c_str();
  1800. //布尔型预留1
  1801. if( 0 == atoi(strBoolReserved1) )
  1802. {
  1803. pBaseVar->m_bReserved1 = false;
  1804. }
  1805. else
  1806. {
  1807. pBaseVar->m_bReserved1 = true;
  1808. }
  1809. //布尔型预留2
  1810. if( 0 == atoi((*it_bool_reserved2++).c_str()) )
  1811. {
  1812. pBaseVar->m_bReserved2 = false;
  1813. }
  1814. else
  1815. {
  1816. pBaseVar->m_bReserved2 = true;
  1817. }
  1818. CString strBoolReserved3 = (*it_bool_reserved3++).c_str();
  1819. //LOG4C((LOG_NOTICE, "strBoolReserved3=%s", strBoolReserved3));
  1820. //布尔型预留3
  1821. if( 0 == atoi(strBoolReserved3) )
  1822. {
  1823. pBaseVar->m_bReserved3 = false;
  1824. }
  1825. else
  1826. {
  1827. pBaseVar->m_bReserved3 = true;
  1828. }
  1829. //布尔型预留4
  1830. if( 0 == atoi((*it_bool_reserved4++).c_str()) )
  1831. {
  1832. pBaseVar->m_bReserved4 = false;
  1833. }
  1834. else
  1835. {
  1836. pBaseVar->m_bReserved4 = true;
  1837. }
  1838. //布尔型预留5
  1839. if( 0 == atoi((*it_bool_reserved5++).c_str()) )
  1840. {
  1841. pBaseVar->m_bReserved5 = false;
  1842. }
  1843. else
  1844. {
  1845. pBaseVar->m_bReserved5 = true;
  1846. }
  1847. //布尔型预留6
  1848. if( 0 == atoi((*it_bool_reserved6++).c_str()) )
  1849. {
  1850. pBaseVar->m_bReserved6 = false;
  1851. }
  1852. else
  1853. {
  1854. pBaseVar->m_bReserved6 = true;
  1855. }
  1856. //布尔型预留7
  1857. if( 0 == atoi((*it_bool_reserved7++).c_str()) )
  1858. {
  1859. pBaseVar->m_bReserved7 = false;
  1860. }
  1861. else
  1862. {
  1863. pBaseVar->m_bReserved7 = true;
  1864. }
  1865. //布尔型预留8
  1866. if( 0 == atoi((*it_bool_reserved8++).c_str()) )
  1867. {
  1868. pBaseVar->m_bReserved8 = false;
  1869. }
  1870. else
  1871. {
  1872. pBaseVar->m_bReserved8 = true;
  1873. }
  1874. //布尔型预留9
  1875. if( 0 == atoi((*it_bool_reserved9++).c_str()) )
  1876. {
  1877. pBaseVar->m_bReserved9 = false;
  1878. }
  1879. else
  1880. {
  1881. pBaseVar->m_bReserved9 = true;
  1882. }
  1883. //布尔型预留10
  1884. if( 0 == atoi((*it_bool_reserved10++).c_str()) )
  1885. {
  1886. pBaseVar->m_bReserved10 = false;
  1887. }
  1888. else
  1889. {
  1890. pBaseVar->m_bReserved10 = true;
  1891. }
  1892. pBaseVar->m_dbData = pBaseVar->m_nReserved1;
  1893. pBaseVar->m_nStatus = -1;
  1894. pBaseVar->m_strContent = "";
  1895. pBaseVar->m_nAlarmNumber = 0;
  1896. pBaseVar->m_nStatusDescCount = CDBInterface::GetInstancePtr()->GetAlarmStatusDescList( (char *)(LPCTSTR)pDev->m_strUid,
  1897. pBaseVar->m_nVarID,
  1898. pBaseVar->m_listStatusID,
  1899. pBaseVar->m_listStatusDesc );
  1900. list<string>::iterator it_desc, it_id;
  1901. if( pBaseVar->m_listStatusDesc.size() > 0 && pBaseVar->m_listStatusID.size() > 0 )
  1902. {
  1903. for( it_desc = pBaseVar->m_listStatusDesc.begin(), it_id = pBaseVar->m_listStatusID.begin();
  1904. it_desc != pBaseVar->m_listStatusDesc.end(), it_id != pBaseVar->m_listStatusID.end(); )
  1905. {
  1906. CString strStatusID = (*it_id++).c_str();
  1907. CString strStatusDesc = (*it_desc++).c_str();
  1908. //LOG4C((LOG_NOTICE, "var desc = %s, StatusID = %d statusdesc = %s",pBaseVar->m_strDesc,atoi(strStatusID), strStatusDesc));
  1909. }
  1910. }
  1911. //LOG4C((LOG_NOTICE, "var desc = %s, value = %d", pBaseVar->m_strDesc, (int)pBaseVar->m_dbData));
  1912. pBaseVar->m_bExistDatePlan = CDBInterface::GetInstancePtr()->IsExistDatePlan((char *)(LPCTSTR)pDev->m_strUid, pBaseVar->m_nVarID);
  1913. if( pBaseVar->m_nVarItemID > 0 )
  1914. {
  1915. char szStartBit[MAX_ID] = {0};
  1916. char szEndBit[MAX_ID] = {0};
  1917. GetVarItemInfo((char *)(LPCTSTR)pDev->m_strUid,
  1918. pBaseVar->m_nVarItemID,
  1919. szStartBit,
  1920. szEndBit);
  1921. pBaseVar->m_nStartBit = atoi(szStartBit);
  1922. pBaseVar->m_nEndBit = atoi(szEndBit);
  1923. }
  1924. CString strTime;
  1925. CTime tm;
  1926. tm = CTime::GetCurrentTime();
  1927. strTime = tm.Format("%Y-%m-%d %H:%M:%S");
  1928. CHAR szID[MAX_ID] = {0};
  1929. int nRet = CDBInterface::GetInstancePtr()->GetSummaryInfo((char *)(LPCTSTR)pDev->m_strUid,
  1930. (char *)(LPCTSTR)pBaseVar->m_strName,
  1931. szID);
  1932. //LOG4C((LOG_NOTICE, "GetSummaryInfo Return %d", nRet));
  1933. if( nRet == 0 )
  1934. {
  1935. if( TRUE == pBaseVar->m_bRealTimeflag )
  1936. {
  1937. CDBInterface::GetInstancePtr()->InsertSummaryRecord(
  1938. (char *)(LPCTSTR)pDev->m_strDeviceName, // 设备名称
  1939. (char *)(LPCTSTR)strTime, // 发生时间
  1940. "", // 备注
  1941. (char *)(LPCTSTR)pBaseVar->m_strDesc, // 变量描述
  1942. pBaseVar->m_dbData, // 变量值
  1943. (char *)(LPCTSTR)pDev->m_strUid, // 设备Uid
  1944. (char *)(LPCTSTR)pBaseVar->m_strName); // 变量名称
  1945. }
  1946. }
  1947. if( pDev )
  1948. {
  1949. pDev->m_Vars.Add(pBaseVar);
  1950. }
  1951. }
  1952. }
  1953. for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
  1954. ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
  1955. ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
  1956. ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
  1957. ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
  1958. ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
  1959. ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
  1960. ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
  1961. ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
  1962. ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
  1963. ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
  1964. ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
  1965. ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
  1966. ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
  1967. ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
  1968. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  1969. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  1970. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  1971. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  1972. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  1973. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  1974. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  1975. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  1976. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  1977. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  1978. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  1979. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  1980. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  1981. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  1982. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  1983. it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
  1984. ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
  1985. ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
  1986. ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
  1987. ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
  1988. ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
  1989. ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
  1990. ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
  1991. ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
  1992. ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
  1993. ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
  1994. ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
  1995. ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
  1996. ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
  1997. ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
  1998. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  1999. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  2000. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  2001. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  2002. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  2003. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  2004. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  2005. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  2006. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  2007. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  2008. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  2009. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  2010. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  2011. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  2012. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  2013. )
  2014. {
  2015. list_var_id.erase(it_var_id++);
  2016. list_set_value.erase(it_set_value++);
  2017. list_var_name.erase(it_var_name++);
  2018. list_uid.erase(it_uid++);
  2019. list_upper_limit.erase(it_upper_limit++);
  2020. list_lower_limit.erase(it_lower_limit++);
  2021. list_normal_state.erase(it_normal_state++);
  2022. list_identify_time.erase(it_identify_time++);
  2023. list_redetect_time.erase(it_redetect_time++);
  2024. list_normal_is_notice.erase(it_normal_is_notice++);
  2025. list_warn_level.erase(it_warn_level++);
  2026. list_snmp_oid.erase(it_snmp_oid++);
  2027. list_fields.erase(it_fields++);
  2028. list_description.erase(it_description++);
  2029. list_max_values.erase(it_max_values++);
  2030. list_min_values.erase(it_min_values++);
  2031. list_max_convtrate.erase(it_max_convtrate++);
  2032. list_min_convtrate.erase(it_min_convtrate++);
  2033. list_is_save.erase(it_is_save++);
  2034. list_collect_freq.erase(it_collect_freq++);
  2035. list_var_type_id.erase(it_var_type_id++);
  2036. list_readonly.erase(it_readonly++);
  2037. list_is_dde.erase(it_is_dde++);
  2038. list_address.erase(it_address++);
  2039. list_unit.erase(it_unit++);
  2040. list_reccurve.erase(it_reccurve++);
  2041. list_register_num.erase(it_register_num++);
  2042. list_child_id.erase(it_child_id++);
  2043. list_var_item_id.erase(it_var_item_id++);
  2044. list_rearm.erase(it_rearm++);
  2045. list_offsets.erase(it_offsets++);
  2046. list_funcid.erase(it_funcid++);
  2047. list_data_len.erase(it_data_len++);
  2048. list_coefficient.erase(it_coefficient++);
  2049. list_realtimeflag.erase(it_realtimeflag++);
  2050. list_rs232_cmd.erase(it_rs232_cmd++);
  2051. list_rs232_type.erase(it_rs232_type++);
  2052. list_rs232_index.erase(it_rs232_index++);
  2053. list_str_reserved1.erase(it_str_reserved1++);
  2054. list_str_reserved2.erase(it_str_reserved2++);
  2055. list_str_reserved3.erase(it_str_reserved3++);
  2056. list_str_reserved4.erase(it_str_reserved4++);
  2057. list_str_reserved5.erase(it_str_reserved5++);
  2058. list_str_reserved6.erase(it_str_reserved6++);
  2059. list_str_reserved7.erase(it_str_reserved7++);
  2060. list_str_reserved8.erase(it_str_reserved8++);
  2061. list_str_reserved9.erase(it_str_reserved9++);
  2062. list_str_reserved10.erase(it_str_reserved10++);
  2063. list_int_reserved1.erase(it_int_reserved1++);
  2064. list_int_reserved2.erase(it_int_reserved2++);
  2065. list_int_reserved3.erase(it_int_reserved3++);
  2066. list_int_reserved4.erase(it_int_reserved4++);
  2067. list_int_reserved5.erase(it_int_reserved5++);
  2068. list_int_reserved6.erase(it_int_reserved6++);
  2069. list_int_reserved7.erase(it_int_reserved7++);
  2070. list_int_reserved8.erase(it_int_reserved8++);
  2071. list_int_reserved9.erase(it_int_reserved9++);
  2072. list_int_reserved10.erase(it_int_reserved10++);
  2073. list_bool_reserved1.erase(it_bool_reserved1++);
  2074. list_bool_reserved2.erase(it_bool_reserved2++);
  2075. list_bool_reserved3.erase(it_bool_reserved3++);
  2076. list_bool_reserved4.erase(it_bool_reserved4++);
  2077. list_bool_reserved5.erase(it_bool_reserved5++);
  2078. list_bool_reserved6.erase(it_bool_reserved6++);
  2079. list_bool_reserved7.erase(it_bool_reserved7++);
  2080. list_bool_reserved8.erase(it_bool_reserved8++);
  2081. list_bool_reserved9.erase(it_bool_reserved9++);
  2082. list_bool_reserved10.erase(it_bool_reserved10++);
  2083. }
  2084. return nRet;
  2085. }
  2086. //获取变量
  2087. INT CDBInterface::EditVarInfo(int nDeviceIndex, int nVarIndex, CHAR *pUid, int nVarID)
  2088. {
  2089. CBaseVar *pBaseVar = g_pDevicesManager->m_Devices[nDeviceIndex]->m_Vars[nVarIndex];
  2090. //LOG4C((LOG_NOTICE, "EditVarInfo DeviceIndex = %d, VarIndex = %d", nDeviceIndex, nVarIndex));
  2091. if( NULL == pBaseVar )
  2092. {
  2093. LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar is NULL"));
  2094. }
  2095. CHAR strSQLText[MAX_SQL_LENGTH * 2] = {0};
  2096. list<string> list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit;
  2097. list<string> list_lower_limit, list_normal_state, list_identify_time, list_redetect_time;
  2098. list<string> list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description;
  2099. list<string> list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save;
  2100. list<string> list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit;
  2101. list<string> list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets;
  2102. list<string> list_funcid, list_data_len, list_coefficient, list_realtimeflag;
  2103. list<string> list_rs232_cmd, list_rs232_type, list_rs232_index;
  2104. list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
  2105. list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
  2106. list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
  2107. list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
  2108. list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
  2109. list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
  2110. list<string>::iterator it_var_id, it_set_value, it_var_name, it_uid, it_upper_limit;
  2111. list<string>::iterator it_lower_limit, it_normal_state, it_identify_time, it_redetect_time;
  2112. list<string>::iterator it_normal_is_notice, it_warn_level, it_snmp_oid, it_fields, it_description;
  2113. list<string>::iterator it_max_values, it_min_values, it_max_convtrate, it_min_convtrate, it_is_save;
  2114. list<string>::iterator it_collect_freq, it_var_type_id, it_readonly, it_is_dde, it_address, it_unit;
  2115. list<string>::iterator it_reccurve, it_register_num, it_child_id, it_var_item_id, it_rearm, it_offsets;
  2116. list<string>::iterator it_funcid, it_data_len, it_coefficient, it_realtimeflag;
  2117. list<string>::iterator it_rs232_cmd, it_rs232_type, it_rs232_index;
  2118. list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
  2119. list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
  2120. list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
  2121. list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
  2122. list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
  2123. list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
  2124. if (!_stricmp(m_chDBType, "SQL SERVER"))
  2125. {
  2126. sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  2127. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  2128. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  2129. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  2130. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  2131. "rs232cmd, rs232type, rs232index, " \
  2132. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  2133. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  2134. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  2135. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  2136. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  2137. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  2138. "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
  2139. }
  2140. else if (!_stricmp(m_chDBType, "ACCESS97"))
  2141. {
  2142. sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  2143. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  2144. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  2145. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  2146. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  2147. "rs232cmd, rs232type, rs232index, " \
  2148. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  2149. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  2150. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  2151. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  2152. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  2153. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  2154. "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
  2155. }
  2156. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  2157. {
  2158. sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  2159. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  2160. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  2161. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  2162. "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
  2163. "rs232cmd, rs232type, rs232index, " \
  2164. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  2165. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  2166. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  2167. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  2168. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  2169. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  2170. "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
  2171. }
  2172. else if(!_stricmp(m_chDBType, "PGSQL"))
  2173. {
  2174. sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
  2175. "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
  2176. "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
  2177. "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
  2178. "var_item_id, rearm, offsets, funcid, datalen, coefficient, realtimeflag, " \
  2179. "rs232cmd, rs232type, rs232index, " \
  2180. "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
  2181. "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
  2182. "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
  2183. "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
  2184. "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
  2185. "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
  2186. "from t_dev_variant where uid = \'%s\' and id = %d limit 1", pUid, nVarID);
  2187. }
  2188. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  2189. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList68(strSQLText
  2190. ,list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit
  2191. ,list_lower_limit, list_normal_state, list_identify_time, list_redetect_time
  2192. ,list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description
  2193. ,list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save
  2194. ,list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit
  2195. ,list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets
  2196. ,list_funcid, list_data_len, list_coefficient, list_realtimeflag
  2197. ,list_rs232_cmd, list_rs232_type, list_rs232_index
  2198. ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
  2199. ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
  2200. ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
  2201. ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
  2202. ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
  2203. ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
  2204. if( 0 == list_var_id.size() || 0 == list_set_value.size() || 0 == list_var_name.size()
  2205. || 0 == list_uid.size() || 0 == list_upper_limit.size() || 0 == list_lower_limit.size()
  2206. || 0 == list_normal_state.size() || 0 == list_identify_time.size() || 0 == list_redetect_time.size()
  2207. || 0 == list_normal_is_notice.size() || 0 == list_warn_level.size() || 0 == list_snmp_oid.size()
  2208. || 0 == list_fields.size() || 0 == list_description.size() || 0 == list_max_values.size() || 0 == list_min_values.size()
  2209. || 0 == list_max_convtrate.size() || 0 == list_min_convtrate.size() || 0 == list_is_save.size()
  2210. || 0 == list_collect_freq.size() || 0 == list_var_type_id.size() || 0 == list_readonly.size()
  2211. || 0 == list_is_dde.size() || 0 == list_address.size() || 0 == list_unit.size()
  2212. || 0 == list_reccurve.size() || 0 == list_register_num.size() || 0 == list_child_id.size()
  2213. || 0 == list_var_item_id.size() || 0 == list_rearm.size() || 0 == list_offsets.size()
  2214. || 0 == list_funcid.size() || 0 == list_data_len.size() || 0 == list_coefficient.size()
  2215. || 0 == list_realtimeflag.size() || 0 == list_rs232_cmd.size() || 0 == list_rs232_type.size() || 0 == list_rs232_index.size()
  2216. || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
  2217. || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
  2218. || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
  2219. || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
  2220. || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
  2221. || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
  2222. || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
  2223. || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
  2224. || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
  2225. || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
  2226. )
  2227. {
  2228. return 0;
  2229. }
  2230. if( nRet != -1 )
  2231. {
  2232. for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
  2233. ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
  2234. ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
  2235. ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
  2236. ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
  2237. ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
  2238. ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
  2239. ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
  2240. ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
  2241. ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
  2242. ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
  2243. ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
  2244. ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
  2245. ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
  2246. ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
  2247. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  2248. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  2249. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  2250. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  2251. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  2252. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  2253. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  2254. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  2255. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  2256. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  2257. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  2258. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  2259. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  2260. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  2261. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  2262. it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
  2263. ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
  2264. ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
  2265. ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
  2266. ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
  2267. ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
  2268. ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
  2269. ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
  2270. ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
  2271. ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
  2272. ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
  2273. ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
  2274. ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
  2275. ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
  2276. ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
  2277. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  2278. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  2279. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  2280. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  2281. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  2282. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  2283. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  2284. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  2285. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  2286. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  2287. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  2288. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  2289. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  2290. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  2291. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  2292. )
  2293. {
  2294. int nVarID;
  2295. CString strUid;
  2296. nVarID = atoi((*it_var_id++).c_str());
  2297. strUid = (*it_uid++).c_str();
  2298. // 变量ID
  2299. pBaseVar->m_nVarID = nVarID;
  2300. // 设定值
  2301. pBaseVar->m_strSetValue = (*it_set_value++).c_str();
  2302. // 变量名称
  2303. pBaseVar->m_strName = (*it_var_name++).c_str();
  2304. // 变量Uid
  2305. pBaseVar->m_strVarUID = strUid;
  2306. //int nUpperLimit = atoi((*it_upper_limit++).c_str());
  2307. // 上限
  2308. pBaseVar->m_nUpperLimit = atoi((*it_upper_limit++).c_str());
  2309. //LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar->m_nUpperLimit = %d, value = %d", pBaseVar->m_nUpperLimit, nUpperLimit));
  2310. // 下限
  2311. pBaseVar->m_nLowerLimit = atoi((*it_lower_limit++).c_str());
  2312. //LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar->m_nUpperLimit = %d", pBaseVar->m_nLowerLimit));
  2313. // 正常状态
  2314. pBaseVar->m_nNormalState = atoi((*it_normal_state++).c_str());
  2315. // 辨识时间
  2316. pBaseVar->m_nIdentifyTime = atoi((*it_identify_time++).c_str());
  2317. // 重新检测时间
  2318. pBaseVar->m_nReDetectTime = atoi((*it_redetect_time++).c_str());
  2319. // 恢复正常是否触发远程报警
  2320. CString strNormalIsNotice = (*it_normal_is_notice++).c_str();
  2321. if( 0 == atoi(strNormalIsNotice) )
  2322. {
  2323. pBaseVar->m_bNormalIsNotice = FALSE;
  2324. }
  2325. else
  2326. {
  2327. pBaseVar->m_bNormalIsNotice = TRUE;
  2328. }
  2329. // 报警级别
  2330. pBaseVar->m_nWaringLevel = atoi((*it_warn_level++).c_str());
  2331. // Snmp对象OID
  2332. pBaseVar->m_strSnmpoi = (*it_snmp_oid++).c_str();
  2333. // Snmp对象域
  2334. pBaseVar->m_strFields = (*it_fields++).c_str();
  2335. // 变量描述
  2336. pBaseVar->m_strDesc = (*it_description++).c_str();
  2337. // 最大值
  2338. pBaseVar->m_nMaxValues = atoi((*it_max_values++).c_str());
  2339. // 最小值
  2340. pBaseVar->m_nMinValues = atoi((*it_min_values++).c_str());
  2341. // 最大比例
  2342. pBaseVar->m_nMaxConvtRate = atoi((*it_max_convtrate++).c_str());
  2343. // 最小比例
  2344. pBaseVar->m_nMinConvtRate = atoi((*it_min_convtrate++).c_str());
  2345. // 是否保存数值
  2346. CString strIsSave = (*it_is_save++).c_str();
  2347. if( 0 == atoi(strIsSave) )
  2348. {
  2349. pBaseVar->m_bIsSave = FALSE;
  2350. }
  2351. else
  2352. {
  2353. pBaseVar->m_bIsSave = TRUE;
  2354. }
  2355. // 采集频率
  2356. pBaseVar->m_nCollectFreq = atoi((*it_collect_freq++).c_str());
  2357. // 变量类型ID
  2358. pBaseVar->m_nVarTypeID = atoi((*it_var_type_id++).c_str());
  2359. // 读写权限
  2360. CString strReadOnly = (*it_readonly++).c_str();
  2361. if( 0 == atoi(strReadOnly) )
  2362. {
  2363. pBaseVar->m_bReadOnly = FALSE;
  2364. }
  2365. else
  2366. {
  2367. pBaseVar->m_bReadOnly = TRUE;
  2368. }
  2369. // 是否DDE
  2370. CString strIsDDE = (*it_is_dde++).c_str();
  2371. if( 0 == atoi(strIsDDE) )
  2372. {
  2373. pBaseVar->m_bIsDDE = FALSE;
  2374. }
  2375. else
  2376. {
  2377. pBaseVar->m_bIsDDE = TRUE;
  2378. }
  2379. // 寄存器起始地址
  2380. pBaseVar->m_nRegStartAddr = atoi((*it_address++).c_str());
  2381. // 单位
  2382. pBaseVar->m_strUnit = (*it_unit++).c_str();
  2383. // 是否记录实时曲线
  2384. CString strRecCurve = (*it_reccurve++).c_str();
  2385. if( 0 == atoi(strRecCurve) )
  2386. {
  2387. pBaseVar->m_bRecCurve = FALSE;
  2388. }
  2389. else
  2390. {
  2391. pBaseVar->m_bRecCurve = TRUE;
  2392. }
  2393. // 寄存器个数
  2394. pBaseVar->m_iRegisterNum = atoi((*it_register_num++).c_str());
  2395. // 变量子ID
  2396. pBaseVar->m_iChildID = atoi((*it_child_id++).c_str());
  2397. // t_dev_varint_item表的ID
  2398. pBaseVar->m_nVarItemID = atoi((*it_var_item_id++).c_str());
  2399. // 校正值
  2400. pBaseVar->m_nRearm = atoi((*it_rearm++).c_str());
  2401. // 偏移值
  2402. pBaseVar->m_nOffset = atoi((*it_offsets++).c_str());
  2403. // 功能码ID
  2404. pBaseVar->m_iFuncID = atoi((*it_funcid++).c_str());
  2405. // 数据长度
  2406. pBaseVar->m_iDataLen = atoi((*it_data_len++).c_str());
  2407. // 系数
  2408. pBaseVar->m_dbCoefficient = atof((*it_coefficient++).c_str());
  2409. // 是否实时采集
  2410. CString strRealTimeFlag = (*it_realtimeflag++).c_str();
  2411. if( 0 == atoi(strRealTimeFlag) )
  2412. {
  2413. pBaseVar->m_bRealTimeflag = FALSE;
  2414. }
  2415. else
  2416. {
  2417. pBaseVar->m_bRealTimeflag = TRUE;
  2418. }
  2419. // RS232命令
  2420. pBaseVar->m_strRs232cmd = (*it_rs232_cmd++).c_str();
  2421. // RS232类型
  2422. pBaseVar->m_strRs232type = (*it_rs232_type++).c_str();
  2423. // RS232索引
  2424. pBaseVar->m_strRs232Index = (*it_rs232_index++).c_str();
  2425. // 字符串预留1
  2426. pBaseVar->m_strReserved1 = (*it_str_reserved1++).c_str();
  2427. // 字符串预留2
  2428. pBaseVar->m_strReserved2 = (*it_str_reserved2++).c_str();
  2429. // 字符串预留3
  2430. pBaseVar->m_strReserved3 = (*it_str_reserved3++).c_str();
  2431. // 字符串预留4
  2432. pBaseVar->m_strReserved4 = (*it_str_reserved4++).c_str();
  2433. // 字符串预留5
  2434. pBaseVar->m_strReserved5 = (*it_str_reserved5++).c_str();
  2435. // 字符串预留6
  2436. pBaseVar->m_strReserved6 = (*it_str_reserved6++).c_str();
  2437. // 字符串预留7
  2438. pBaseVar->m_strReserved7 = (*it_str_reserved7++).c_str();
  2439. // 字符串预留8
  2440. pBaseVar->m_strReserved8 = (*it_str_reserved8++).c_str();
  2441. // 字符串预留9
  2442. pBaseVar->m_strReserved9 = (*it_str_reserved9++).c_str();
  2443. // 字符串预留10
  2444. pBaseVar->m_strReserved10 = (*it_str_reserved10++).c_str();
  2445. // 整形预留1
  2446. pBaseVar->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
  2447. LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar->m_nReserved1 初始值 = %d", pBaseVar->m_nReserved1));
  2448. // 整形预留2
  2449. pBaseVar->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
  2450. // 整形预留3
  2451. pBaseVar->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
  2452. // 整形预留4
  2453. pBaseVar->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
  2454. // 整形预留5
  2455. pBaseVar->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
  2456. // 整形预留6
  2457. pBaseVar->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
  2458. // 整形预留7
  2459. pBaseVar->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
  2460. // 整形预留8
  2461. pBaseVar->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
  2462. // 整形预留9
  2463. pBaseVar->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
  2464. // 整形预留10
  2465. pBaseVar->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
  2466. //布尔型预留1
  2467. if( 0 == atoi((*it_bool_reserved1++).c_str()) )
  2468. {
  2469. pBaseVar->m_bReserved1 = false;
  2470. }
  2471. else
  2472. {
  2473. pBaseVar->m_bReserved1 = true;
  2474. }
  2475. //布尔型预留2
  2476. if( 0 == atoi((*it_bool_reserved2++).c_str()) )
  2477. {
  2478. pBaseVar->m_bReserved2 = false;
  2479. }
  2480. else
  2481. {
  2482. pBaseVar->m_bReserved2 = true;
  2483. }
  2484. //布尔型预留3
  2485. if( 0 == atoi((*it_bool_reserved3++).c_str()) )
  2486. {
  2487. pBaseVar->m_bReserved3 = false;
  2488. }
  2489. else
  2490. {
  2491. pBaseVar->m_bReserved3 = true;
  2492. }
  2493. //布尔型预留4
  2494. if( 0 == atoi((*it_bool_reserved4++).c_str()) )
  2495. {
  2496. pBaseVar->m_bReserved4 = false;
  2497. }
  2498. else
  2499. {
  2500. pBaseVar->m_bReserved4 = true;
  2501. }
  2502. //布尔型预留5
  2503. if( 0 == atoi((*it_bool_reserved5++).c_str()) )
  2504. {
  2505. pBaseVar->m_bReserved5 = false;
  2506. }
  2507. else
  2508. {
  2509. pBaseVar->m_bReserved5 = true;
  2510. }
  2511. //布尔型预留6
  2512. if( 0 == atoi((*it_bool_reserved6++).c_str()) )
  2513. {
  2514. pBaseVar->m_bReserved6 = false;
  2515. }
  2516. else
  2517. {
  2518. pBaseVar->m_bReserved6 = true;
  2519. }
  2520. //布尔型预留7
  2521. if( 0 == atoi((*it_bool_reserved7++).c_str()) )
  2522. {
  2523. pBaseVar->m_bReserved7 = false;
  2524. }
  2525. else
  2526. {
  2527. pBaseVar->m_bReserved7 = true;
  2528. }
  2529. //布尔型预留8
  2530. if( 0 == atoi((*it_bool_reserved8++).c_str()) )
  2531. {
  2532. pBaseVar->m_bReserved8 = false;
  2533. }
  2534. else
  2535. {
  2536. pBaseVar->m_bReserved8 = true;
  2537. }
  2538. //布尔型预留9
  2539. if( 0 == atoi((*it_bool_reserved9++).c_str()) )
  2540. {
  2541. pBaseVar->m_bReserved9 = false;
  2542. }
  2543. else
  2544. {
  2545. pBaseVar->m_bReserved9 = true;
  2546. }
  2547. //布尔型预留10
  2548. if( 0 == atoi((*it_bool_reserved10++).c_str()) )
  2549. {
  2550. pBaseVar->m_bReserved10 = false;
  2551. }
  2552. else
  2553. {
  2554. pBaseVar->m_bReserved10 = true;
  2555. }
  2556. //pBaseVar->m_dbData = -1;
  2557. //pBaseVar->m_nStatus = -1;
  2558. //pBaseVar->m_strContent = "";
  2559. //pBaseVar->m_nAlarmNumber = 0;
  2560. pBaseVar->m_nStatusDescCount = CDBInterface::GetInstancePtr()->GetAlarmStatusDescList( (char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid,
  2561. pBaseVar->m_nVarID,
  2562. pBaseVar->m_listStatusID,
  2563. pBaseVar->m_listStatusDesc );
  2564. //LOG4C((LOG_NOTICE, "var desc = %s, StatusDescCount = %d", pBaseVar->m_strDesc, pBaseVar->m_nStatusDescCount));
  2565. pBaseVar->m_bExistDatePlan = CDBInterface::GetInstancePtr()->IsExistDatePlan((char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid, pBaseVar->m_nVarID);
  2566. if( pBaseVar->m_nVarItemID > 0 )
  2567. {
  2568. char szStartBit[MAX_ID] = {0};
  2569. char szEndBit[MAX_ID] = {0};
  2570. GetVarItemInfo((char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid,
  2571. pBaseVar->m_nVarItemID,
  2572. szStartBit,
  2573. szEndBit);
  2574. pBaseVar->m_nStartBit = atoi(szStartBit);
  2575. pBaseVar->m_nEndBit = atoi(szEndBit);
  2576. }
  2577. }
  2578. }
  2579. for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
  2580. ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
  2581. ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
  2582. ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
  2583. ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
  2584. ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
  2585. ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
  2586. ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
  2587. ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
  2588. ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
  2589. ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
  2590. ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
  2591. ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
  2592. ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
  2593. ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
  2594. ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
  2595. ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
  2596. ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
  2597. ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
  2598. ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
  2599. ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
  2600. ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
  2601. ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
  2602. ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
  2603. ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
  2604. ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
  2605. ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
  2606. ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
  2607. ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
  2608. ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
  2609. it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
  2610. ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
  2611. ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
  2612. ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
  2613. ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
  2614. ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
  2615. ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
  2616. ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
  2617. ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
  2618. ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
  2619. ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
  2620. ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
  2621. ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
  2622. ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
  2623. ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
  2624. ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
  2625. ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
  2626. ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
  2627. ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
  2628. ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
  2629. ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
  2630. ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
  2631. ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
  2632. ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
  2633. ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
  2634. ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
  2635. ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
  2636. ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
  2637. ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
  2638. ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
  2639. )
  2640. {
  2641. list_var_id.erase(it_var_id++);
  2642. list_set_value.erase(it_set_value++);
  2643. list_var_name.erase(it_var_name++);
  2644. list_uid.erase(it_uid++);
  2645. list_upper_limit.erase(it_upper_limit++);
  2646. list_lower_limit.erase(it_lower_limit++);
  2647. list_normal_state.erase(it_normal_state++);
  2648. list_identify_time.erase(it_identify_time++);
  2649. list_redetect_time.erase(it_redetect_time++);
  2650. list_normal_is_notice.erase(it_normal_is_notice++);
  2651. list_warn_level.erase(it_warn_level++);
  2652. list_snmp_oid.erase(it_snmp_oid++);
  2653. list_fields.erase(it_fields++);
  2654. list_description.erase(it_description++);
  2655. list_max_values.erase(it_max_values++);
  2656. list_min_values.erase(it_min_values++);
  2657. list_max_convtrate.erase(it_max_convtrate++);
  2658. list_min_convtrate.erase(it_min_convtrate++);
  2659. list_is_save.erase(it_is_save++);
  2660. list_collect_freq.erase(it_collect_freq++);
  2661. list_var_type_id.erase(it_var_type_id++);
  2662. list_readonly.erase(it_readonly++);
  2663. list_is_dde.erase(it_is_dde++);
  2664. list_address.erase(it_address++);
  2665. list_unit.erase(it_unit++);
  2666. list_reccurve.erase(it_reccurve++);
  2667. list_register_num.erase(it_register_num++);
  2668. list_child_id.erase(it_child_id++);
  2669. list_var_item_id.erase(it_var_item_id++);
  2670. list_rearm.erase(it_rearm++);
  2671. list_offsets.erase(it_offsets++);
  2672. list_funcid.erase(it_funcid++);
  2673. list_data_len.erase(it_data_len++);
  2674. list_coefficient.erase(it_coefficient++);
  2675. list_realtimeflag.erase(it_realtimeflag++);
  2676. list_rs232_cmd.erase(it_rs232_cmd++);
  2677. list_rs232_type.erase(it_rs232_type++);
  2678. list_rs232_index.erase(it_rs232_index++);
  2679. list_str_reserved1.erase(it_str_reserved1++);
  2680. list_str_reserved2.erase(it_str_reserved2++);
  2681. list_str_reserved3.erase(it_str_reserved3++);
  2682. list_str_reserved4.erase(it_str_reserved4++);
  2683. list_str_reserved5.erase(it_str_reserved5++);
  2684. list_str_reserved6.erase(it_str_reserved6++);
  2685. list_str_reserved7.erase(it_str_reserved7++);
  2686. list_str_reserved8.erase(it_str_reserved8++);
  2687. list_str_reserved9.erase(it_str_reserved9++);
  2688. list_str_reserved10.erase(it_str_reserved10++);
  2689. list_int_reserved1.erase(it_int_reserved1++);
  2690. list_int_reserved2.erase(it_int_reserved2++);
  2691. list_int_reserved3.erase(it_int_reserved3++);
  2692. list_int_reserved4.erase(it_int_reserved4++);
  2693. list_int_reserved5.erase(it_int_reserved5++);
  2694. list_int_reserved6.erase(it_int_reserved6++);
  2695. list_int_reserved7.erase(it_int_reserved7++);
  2696. list_int_reserved8.erase(it_int_reserved8++);
  2697. list_int_reserved9.erase(it_int_reserved9++);
  2698. list_int_reserved10.erase(it_int_reserved10++);
  2699. list_bool_reserved1.erase(it_bool_reserved1++);
  2700. list_bool_reserved2.erase(it_bool_reserved2++);
  2701. list_bool_reserved3.erase(it_bool_reserved3++);
  2702. list_bool_reserved4.erase(it_bool_reserved4++);
  2703. list_bool_reserved5.erase(it_bool_reserved5++);
  2704. list_bool_reserved6.erase(it_bool_reserved6++);
  2705. list_bool_reserved7.erase(it_bool_reserved7++);
  2706. list_bool_reserved8.erase(it_bool_reserved8++);
  2707. list_bool_reserved9.erase(it_bool_reserved9++);
  2708. list_bool_reserved10.erase(it_bool_reserved10++);
  2709. }
  2710. return nRet;
  2711. }
  2712. // 获取Summary资料
  2713. INT CDBInterface::GetSummaryInfo(char *pUid, char *pVarDesc, char *pID)
  2714. {
  2715. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2716. list<string> list1;
  2717. list<string>::iterator it;
  2718. if (!_stricmp(m_chDBType, "SQL SERVER"))
  2719. {
  2720. sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
  2721. }
  2722. else if (!_stricmp(m_chDBType, "ACCESS97"))
  2723. {
  2724. sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
  2725. }
  2726. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  2727. {
  2728. sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
  2729. }
  2730. else if(!_stricmp(m_chDBType, "PGSQL"))
  2731. {
  2732. sprintf(strSQLText, "select id from t_summary_log where varuid = \'%s\' and varname = \'%s\' limit 1", pUid, pVarDesc);
  2733. }
  2734. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
  2735. if( 0 == list1.size() )
  2736. {
  2737. return 0;
  2738. }
  2739. if( nRet != -1 )
  2740. {
  2741. strcpy(pID, list1.begin()->c_str());
  2742. }
  2743. for( it = list1.begin(); it != list1.end(); )
  2744. {
  2745. list1.erase(it++);
  2746. }
  2747. return nRet;
  2748. }
  2749. // 获取报警状态ID对应的意义,用来组织报警内容
  2750. INT CDBInterface::GetAlarmStatusDescList(char chDevUid[MAX_UID], int nVarID, list<string>& list1, list<string>& list2)
  2751. {
  2752. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2753. sprintf(strSQLText, "select statusid, statusdesc from t_var_status where " \
  2754. "devuid = \'%s\' and varid = %d ",
  2755. chDevUid, nVarID);
  2756. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList2(strSQLText, list1, list2);
  2757. return nRet;
  2758. }
  2759. // 获取是否设置时间计划
  2760. // char *pDevUid :变量UID,
  2761. // int nVarID :变量ID;
  2762. BOOL CDBInterface::IsExistDatePlan(char *pDevUid, int nVarID)
  2763. {
  2764. unsigned char szArray[7][24];
  2765. memset(szArray, 0, sizeof(szArray) );
  2766. CTime time = CTime::GetCurrentTime();
  2767. // 获取当前时间
  2768. int nWeekOfDay = time.GetDayOfWeek(); // GetDayOfWeek获取的值是0=星期天 , 1=星期六?
  2769. if( nWeekOfDay == 1 )
  2770. {
  2771. nWeekOfDay = 6;
  2772. }
  2773. else
  2774. {
  2775. nWeekOfDay -= 2;
  2776. }
  2777. int nHours = time.GetHour();
  2778. int nRet;
  2779. nRet = GetDatePlan( PLAN_TYPE_EQUIP, pDevUid, nVarID, szArray );
  2780. if( nRet > 0 )
  2781. {
  2782. for( int x=0; x<7; x++ )
  2783. {
  2784. for(int y=0; y<24; y++)
  2785. {
  2786. if( 15 == szArray[x][y] )
  2787. {
  2788. if( x == nWeekOfDay && y == nHours )
  2789. {
  2790. return true;
  2791. }
  2792. }
  2793. }
  2794. }
  2795. return false;
  2796. }
  2797. else
  2798. {
  2799. return true;
  2800. }
  2801. return false;
  2802. }
  2803. // 获取变量对应的bit位信息
  2804. INT CDBInterface::GetVarItemInfo(char chDevUid[MAX_ID], int nVarItemID, CHAR *pStartBit, CHAR *pEndBit)
  2805. {
  2806. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2807. list<string> list1, list2;
  2808. list<string>::iterator it1, it2;
  2809. if (!_stricmp(m_chDBType, "SQL SERVER"))
  2810. {
  2811. sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
  2812. "and id = %d", chDevUid, nVarItemID);
  2813. }
  2814. else if (!_stricmp(m_chDBType, "ACCESS97"))
  2815. {
  2816. sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
  2817. "and id = %d", chDevUid, nVarItemID);
  2818. }
  2819. else if (!_stricmp(m_chDBType, "ACCESS2000"))
  2820. {
  2821. sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
  2822. "and id = %d", chDevUid, nVarItemID);
  2823. }
  2824. else if(!_stricmp(m_chDBType, "PGSQL"))
  2825. {
  2826. sprintf(strSQLText, "select startbit, endbit from t_dev_variant_item where uid = '%s' " \
  2827. "and id = %d limit 1", chDevUid, nVarItemID);
  2828. }
  2829. int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList2(strSQLText, list1, list2);
  2830. if( 0 == list1.size() || 0 == list2.size() )
  2831. {
  2832. return 0;
  2833. }
  2834. if( nRet != -1 )
  2835. {
  2836. strcpy(pStartBit, list1.begin()->c_str());
  2837. strcpy(pEndBit, list2.begin()->c_str());
  2838. }
  2839. for( it1 = list1.begin(), it2 = list2.begin(); it1 != list1.end(), it2 != list2.end(); )
  2840. {
  2841. list1.erase(it1++);
  2842. list2.erase(it2++);
  2843. }
  2844. return nRet;
  2845. }
  2846. // 插入告警记录
  2847. INT CDBInterface::InsertWarningRecord(
  2848. char* pEquipDesc, // 设备描述
  2849. char* pVarDesc, // 变量描述
  2850. char* pHappentime, // 发生时间
  2851. int iCurrStatus, // 当前状态
  2852. double dbCurrValue, // 当前值
  2853. char* pMemos, // 备注
  2854. char* pContent // 报警内容
  2855. )
  2856. {
  2857. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2858. int iMaxID;
  2859. CHAR chMaxID[MAX_ID] = {0};
  2860. GetMaxID("t_waring_record", "id", chMaxID);
  2861. if( 0 == atoi(chMaxID) )
  2862. {
  2863. iMaxID = 1;
  2864. }
  2865. else
  2866. {
  2867. iMaxID = atoi(chMaxID) + 1;
  2868. }
  2869. sprintf(strSQLText, "insert into t_waring_record(id, equip_desc," \
  2870. "type_desc, happen_time, curr_status, curr_value, memos, warncontent) values(" \
  2871. "\'%d\', \'%s\', \'%s\',\' %s\', \'%d\', %f, \'%s\', \'%s\')",
  2872. iMaxID, pEquipDesc, pVarDesc, pHappentime, iCurrStatus, dbCurrValue, pMemos, pContent);
  2873. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  2874. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2875. }
  2876. //插入Summary记录
  2877. INT CDBInterface::InsertSummaryRecord(
  2878. CHAR* pDevName, // 设备名称
  2879. CHAR* pHappenTime, // 发生时间
  2880. CHAR* pMemo, // 备注
  2881. CHAR *pVarDesc, // 变量描述
  2882. double dbCurrValue, // 当前值
  2883. CHAR* pVarUid, // 设备Uid
  2884. CHAR* pVarName // 变量名称
  2885. )
  2886. {
  2887. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2888. int iMaxID;
  2889. CHAR chMaxID[MAX_ID] = {0};
  2890. GetMaxID("t_summary_log", "id", chMaxID);
  2891. if( 0 == atoi(chMaxID) )
  2892. {
  2893. iMaxID = 1;
  2894. }
  2895. else
  2896. {
  2897. iMaxID = atoi(chMaxID) + 1;
  2898. }
  2899. sprintf(strSQLText, "insert into t_summary_log(devname, happentime," \
  2900. "memos, id, type_desc, curr_value, varuid, varname) values(" \
  2901. "\'%s\', \'%s\', \'%s\', %d, \'%s\', %.1f, \'%s\', \'%s\')",
  2902. pDevName, pHappenTime, pMemo, iMaxID, pVarDesc, dbCurrValue, pVarUid, pVarName);
  2903. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  2904. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2905. }
  2906. //更新Summary记录
  2907. INT CDBInterface::EditSummaryRecord(
  2908. CHAR *pDevName, // 设备名称
  2909. CHAR *pHappenTime, // 发生时间
  2910. CHAR* pMemo, // 备注
  2911. int iID, // ID
  2912. CHAR* pVarDesc, // 变量描述
  2913. double dbCurrValue, // 当前值
  2914. CHAR* pVarUid, // 设备Uid
  2915. CHAR* pVarName // 变量名称
  2916. )
  2917. {
  2918. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2919. sprintf(strSQLText, "update t_summary_log set devname = \'%s\', happentime = \'%s\'," \
  2920. "memos = \'%s\', type_desc = \'%s\', curr_value = %.1f, varuid = \'%s\', varname = \'%s\' where id = %d",
  2921. pDevName, pHappenTime, pMemo, pVarDesc, dbCurrValue, pVarUid, pVarName, iID);
  2922. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2923. }
  2924. //更新Summary记录
  2925. INT CDBInterface::EditSummaryRecord(
  2926. CHAR *pDevName, // 设备名称
  2927. CHAR *pHappenTime, // 发生时间
  2928. CHAR* pMemo, // 备注
  2929. CHAR* pVarDesc, // 变量描述
  2930. double dbCurrValue, // 当前值
  2931. CHAR* pVarUid, // 设备Uid
  2932. CHAR* pVarName // 变量名称
  2933. )
  2934. {
  2935. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2936. sprintf(strSQLText, "update t_summary_log set devname = \'%s\', happentime = \'%s\'," \
  2937. "memos = \'%s\', type_desc = \'%s\', curr_value = %.1f, varuid = \'%s\', varname = \'%s\' where varname = \'%s\'",
  2938. pDevName, pHappenTime, pMemo, pVarDesc, dbCurrValue, pVarUid, pVarName, pVarName);
  2939. //LOG4C((LOG_NOTICE, "%s", strSQLText));
  2940. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2941. }
  2942. //插入Sms记录
  2943. INT CDBInterface::InsertSmsRecord(
  2944. CHAR* pTelNum, // 电话号码
  2945. CHAR* pContactName, // 联系人姓名
  2946. CHAR* pSendTime, // 发送时间
  2947. CHAR* pContent, // 内容
  2948. CHAR* pMemo // 备注
  2949. )
  2950. {
  2951. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2952. sprintf(strSQLText, "insert into t_sms_rec(telnum, contactname," \
  2953. "sendtime, contents, memos) values(" \
  2954. "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
  2955. pTelNum, pContactName, pSendTime, pContent, pMemo);
  2956. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2957. }
  2958. //插入Notice记录
  2959. INT CDBInterface::InsertNoticeRecord(
  2960. CHAR* pTelNum, // 电话号码
  2961. CHAR* pContactName, // 联系人姓名
  2962. CHAR* pSendTime, // 发送时间
  2963. CHAR* pContent, // 内容
  2964. CHAR* pMemo // 备注
  2965. )
  2966. {
  2967. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2968. sprintf(strSQLText, "insert into t_notice_rec(telnum, contactname," \
  2969. "sendtime, contents, memos) values(" \
  2970. "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
  2971. pTelNum, pContactName, pSendTime, pContent, pMemo);
  2972. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2973. }
  2974. //插入Email记录
  2975. INT CDBInterface::InsertEmailRecord(
  2976. CHAR* pEmailAddr, // 电话号码
  2977. CHAR* pContactName, // 联系人姓名
  2978. CHAR* pSendTime, // 发送时间
  2979. CHAR* pContent, // 内容
  2980. CHAR* pMemo // 备注
  2981. )
  2982. {
  2983. CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
  2984. sprintf(strSQLText, "insert into t_email_rec(emailaddr, contactname," \
  2985. "sendtime, contents, memos) values(" \
  2986. "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
  2987. pEmailAddr, pContactName, pSendTime, pContent, pMemo);
  2988. return CDBConnection::GetInstancePtr()->Execute(strSQLText);
  2989. }
  2990. };