DBInterface.cpp 175 KB

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