1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988 |
- /*************************************************************
- /* Copyright (C), 2008-2010, StoneU Tech. Co., Ltd.
- /* 文件名: DBInterface.h
- /* 作者: Jesse
- /* 创建日期: 2010-08-02
- /* 版本号: V1.0
- /* 描述: 实现多种数据库的支持
- /* 其它:
- /* 主要类模块: CDBInterface
- /* 历史修改记录:
- 作者 时间 版本 描述
- Jesse 10/08/02 1.0 创建这个模块
- ***************************************************************/
- #include "stdafx.h"
- #include "DBInterface.h"
- #include "Global.h"
- #include "Syslib.h"
- namespace DBInterface
- {
- CDBInterface* CDBInterface::m_pDBInterface = NULL;
- // 静态成员函数,提供全局访问的接口
- CDBInterface* CDBInterface::GetInstancePtr()
- {
- if( NULL == m_pDBInterface )
- {
- m_pDBInterface = new CDBInterface();
- }
- return m_pDBInterface;
- }
- // 设置数据库类型
- void CDBInterface::SetDBType(char *pDBType)
- {
- strcpy(m_chDBType, pDBType);
- }
- //获取表最大的ID, 通用函数
- INT CDBInterface::GetMaxID( CHAR *pTableName, CHAR *pFieldName, CHAR *pMaxID )
- {
- #if 1
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1;
- list<string>::iterator it;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select top 1 %s from %s order by id desc", pFieldName, pTableName);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select %s from %s order by id desc limit 1", pFieldName, pTableName);
- }
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
- if( 0 == list1.size() )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- strcpy(pMaxID, list1.begin()->c_str());
- }
- for( it = list1.begin(); it != list1.end(); )
- {
- list1.erase(it++);
- }
- return nRet;
- #else
- CString sTable;
- sTable.Format( "%s",pTableName );
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1;
- list<string>::iterator it;
- sprintf(strSQLText, "select max(%s) as maxid from %s", pFieldName, pTableName);
- //if( sTable=="t_data_rec" )//
- //{
- // LOG4C((LOG_NOTICE, "***** GetMaxID 1" ));
- //}
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
- //if( sTable=="t_data_rec" )
- //{
- // LOG4C((LOG_NOTICE, "***** GetMaxID 2" ));
- //}
- if( 0 == list1.size() )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- strcpy(pMaxID, list1.begin()->c_str());
- }
- for( it = list1.begin(); it != list1.end(); )
- {
- list1.erase(it++);
- }
- return nRet;
- #endif
- }
- //获取表最大的ID, 通用函数 最后一行
- INT CDBInterface::GetMaxIDByLastLow( CHAR *pTableName, CHAR *pFieldName, CHAR *pMaxID )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1;
- list<string>::iterator it;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select top 1 %s from %s order by id desc", pFieldName, pTableName);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select %s from %s order by id desc limit 1", pFieldName, pTableName);
- }
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
- if( 0 == list1.size() )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- strcpy(pMaxID, list1.begin()->c_str());
- }
- for( it = list1.begin(); it != list1.end(); )
- {
- list1.erase(it++);
- }
- return nRet;
- }
- // 分配用户角色
- void CDBInterface::InitUserRoleInfo()
- {
- char szUid[MAX_UID] = {0};
- list<string> list_uid;
- list<string>::iterator it_uid;
- int iUIDCount = GetHasPurviewUidList(list_uid);
- //LOG4C((LOG_NOTICE, "iUIDCount=%d", iUIDCount));
- if( iUIDCount <= 0 || 0 == list_uid.size() )
- {
- LOG4C((LOG_NOTICE, "分配用户角色 iUIDCount=%d", iUIDCount));
- return;
- }
- for( it_uid = list_uid.begin(); it_uid != list_uid.end(); )
- {
- USERROLEINFO tagUserRoleInfo;
- USERINFO tagUserInfo;
- memset(&tagUserRoleInfo, 0, sizeof(USERROLEINFO));
- memset(&tagUserInfo, 0, sizeof(USERINFO));
- strcpy( szUid, (*it_uid++).c_str() );
- strcpy( tagUserRoleInfo.szDevUID, szUid );
- list<string> list_tel, list_mobile, list_fax, list_email;
- list<string>::iterator it_tel, it_mobile, it_fax, it_email;
- int iUserCount = GetUserInfoList(szUid, list_tel, list_mobile, list_fax, list_email);
- //LOG4C((LOG_NOTICE, "szUid = %s,iUserCount=%d",szUid, iUserCount));
- for( it_tel = list_tel.begin(), it_mobile = list_mobile.begin(), it_fax = list_fax.begin(), it_email = list_email.begin();
- it_tel != list_tel.end(), it_mobile != list_mobile.end(), it_fax != list_fax.end(), it_email != list_email.end(); )
- {
- strcpy(tagUserInfo.szTel, (*it_tel++).c_str());
- strcpy(tagUserInfo.szMobileTel, (*it_mobile++).c_str());
- strcpy(tagUserInfo.szFax, (*it_fax++).c_str());
- strcpy(tagUserInfo.szEmail, (*it_email++).c_str());
- bool f1=false,f2=false;
- CString strTel,strMobileTes,strFax,strEmail;
- CString strTel2,strMobileTes2,strFax2,strEmail2;
- int nUserSize = (int)tagUserRoleInfo.vtUserInfo.size();
- //LOG4C((LOG_NOTICE, "szUid = %s,nUserSize=%d",szUid, nUserSize));
- for( int j = 0; j < nUserSize; j++ )
- {
- strTel = CString( tagUserRoleInfo.vtUserInfo[j].szTel );
- strMobileTes = CString( tagUserRoleInfo.vtUserInfo[j].szMobileTel );
- strFax = CString( tagUserRoleInfo.vtUserInfo[j].szFax );
- strEmail = CString( tagUserRoleInfo.vtUserInfo[j].szEmail );
- strTel2.Format("%s",tagUserInfo.szTel );
- strMobileTes2.Format("%s",tagUserInfo.szMobileTel );
- strFax2.Format("%s",tagUserInfo.szFax );
- strEmail2.Format("%s",tagUserInfo.szEmail );
- if( strTel==strTel2 && strMobileTes==strMobileTes2 && strFax==strFax2 && strEmail==strEmail2 &&
- strTel2!="" && strMobileTes2!="" && strFax2!="" && strEmail2!="" )
- {
- f1 = true;
- break;
- }
- else
- {
- if( strTel==strTel2 && strTel2!="" )
- {
- f2 = true;
- break;
- }
- if( strMobileTes==strMobileTes2 && strMobileTes2!="" )
- {
- f2 = true;
- break;
- }
- }
- }
- if( !f1 && !f2 )
- {
- tagUserRoleInfo.vtUserInfo.push_back(tagUserInfo);
- //LOG4C((LOG_NOTICE, "szUid=%s, tel=%s, MobileTel=%s", szUid,tagUserInfo.szTel, tagUserInfo.szMobileTel));
- }
- else if( f2 )
- {
- //LOG4C((LOG_NOTICE, "注意:用户的电话或短信号码重复,这会导致这个用户没有电话和短信通知 %s %s %s",szUid,tagUserInfo.szTel,tagUserInfo.szMobileTel));
- }
- }
- //LOG4C((LOG_NOTICE, "iUserCount=%d", iUserCount));
- //LOG4C((LOG_NOTICE, "tagUserRoleInfo.szDevUID=%s", szUid));
- g_vtUserRoleInfo.push_back( tagUserRoleInfo );
- //释放
- for( it_tel = list_tel.begin(), it_mobile = list_mobile.begin(), it_fax = list_fax.begin(), it_email = list_email.begin();
- it_tel != list_tel.end(), it_mobile != list_mobile.end(), it_fax != list_fax.end(), it_email != list_email.end(); )
- {
- list_tel.erase(it_tel++);
- list_mobile.erase(it_mobile++);
- list_fax.erase(it_fax++);
- list_email.erase(it_email++);
- tagUserRoleInfo.vtUserInfo.pop_back();
- }
- }
- for( it_uid = list_uid.begin(); it_uid != list_uid.end(); )
- {
- list_uid.erase(it_uid++);
- }
- }
- // 回收用户角色
- void CDBInterface::UnInitUserRoleInfo()
- {
- for( int i = 0; i < g_vtUserRoleInfo.size(); i++ )
- {
- for( int j = 0; j < g_vtUserRoleInfo[i].vtUserInfo.size(); j++ )
- {
- g_vtUserRoleInfo[i].vtUserInfo.pop_back();
- }
- g_vtUserRoleInfo.pop_back();
- }
- }
- // 获取有权限的设备UID
- int CDBInterface::GetHasPurviewUidList(list<string>& list1)
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "select uid from t_role_equip group by uid");
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
- return nRet;
- }
- // 获取具有某个设备权限的用户信息
- int CDBInterface::GetUserInfoList(char *pUid, list<string>& list1, list<string>& list2, list<string>& list3, list<string>& list4)
- {
- /*CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- "where a.uid = \'%s\' and b.status = false or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }*/
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a,t_user_info b,t_role_user c where b.uid = c.userid and a.group_id=c.group_id "\
- "and a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }
- //else if (!_stricmp(m_chDBType, "ACCESS97"))
- //{
- // sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- // "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- // "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- // pUid);
- //}
- //else if (!_stricmp(m_chDBType, "ACCESS2000"))
- //{
- // sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- // "t_role_equip a left outer join t_user_info b on a.userid = b.uid " \
- // "where a.uid = \'%s\' and b.status = 0 or b.status is null and b.uid <> 'admin' order by b.id",
- // pUid);
- //}
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from " \
- "t_role_equip a,t_user_info b,t_role_user c where b.uid = c.userid and a.group_id=c.group_id "\
- "and a.uid = \'%s\' and b.status = false or b.status is null and b.uid <> 'admin' order by b.id",
- pUid);
- }
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
- return nRet;
- }
- // 获取用户信息
- int CDBInterface::GetUserInfoList(list<string>& list1, list<string>& list2, list<string>& list3, list<string>& list4)
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin' order by id");
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin' order by id");
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = 0 or status is null and uid <> 'admin' order by id");
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select tel, mobiletel, fax, email from t_user_info where status = false or status is null and uid <> 'admin' order by id");
- }
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
- return nRet;
- }
- //得到时间计划
- INT CDBInterface::GetDatePlan( int nPlanType, CHAR *pPlanID, unsigned char nBufDate[7][24] )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1, list2, list3, list4;
- list<string>::iterator it_list1, it_list2, it_list3, it_list4;
- sprintf(strSQLText, "select starttime, endtime, startweekofday, endweekofday " \
- "from t_plan_info where planid=\'%s\' and plantype = %d",
- pPlanID, nPlanType);
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
- if( nRet == -1 )
- return 0;
- if( list1.size() == 0 || list2.size() == 0 || list3.size() == 0 || list4.size() == 0 )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
- it_list1 != list1.end() && it_list2 != list2.end() && it_list3 != list3.end() && it_list4 != list4.end();
- it_list1++, it_list2++, it_list3++, it_list4++)
- {
- for( int i = atoi((*it_list3).c_str()); i < atoi((*it_list4).c_str()) + 1; i++ )
- {
- for( int j = atoi((*it_list1).c_str()); j < atoi((*it_list2).c_str()) + 1; j++ )
- {
- nBufDate[i][j] = 15;
- }
- }
- }
- }
- for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
- it_list1 != list1.end(), it_list2 != list2.end(), it_list3 != list3.end(), it_list4 != list4.end(); )
- {
- list1.erase(it_list1++);
- list2.erase(it_list2++);
- list3.erase(it_list3++);
- list4.erase(it_list4++);
- }
- return nRet;
- }
- //得到时间计划
- INT CDBInterface::GetDatePlan( int nPlanType, CHAR *pUid, int nVarID, unsigned char nBufDate[7][24] )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1, list2, list3, list4;
- list<string>::iterator it_list1, it_list2, it_list3, it_list4;
- sprintf(strSQLText, "select starttime, endtime, startweekofday, endweekofday " \
- "from t_plan_info where uid=\'%s\' and varid = %d and plantype = %d",
- pUid, nVarID, nPlanType);
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList4(strSQLText, list1, list2, list3, list4);
- if( list1.size() == 0 || list2.size() == 0 || list3.size() == 0 || list4.size() == 0 )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
- it_list1 != list1.end() && it_list2 != list2.end() && it_list3 != list3.end() && it_list4 != list4.end();
- it_list1++, it_list2++, it_list3++, it_list4++ )
- {
- for( int i = atoi((*it_list3).c_str()); i < atoi((*it_list4).c_str()) + 1; i++ )
- {
- for( int j = atoi((*it_list1).c_str()); j < atoi((*it_list2).c_str()) + 1; j++ )
- {
- nBufDate[i][j] = 15;
- }
- }
- }
- }
- for( it_list1 = list1.begin(), it_list2 = list2.begin(), it_list3 = list3.begin(), it_list4 = list4.begin();
- it_list1 != list1.end(), it_list2 != list2.end(), it_list3 != list3.end(), it_list4 != list4.end(); )
- {
- list1.erase(it_list1++);
- list2.erase(it_list2++);
- list3.erase(it_list3++);
- list4.erase(it_list4++);
- }
- return nRet;
- }
- // 获取设备资料
- INT CDBInterface::GetDevInfo()
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
- list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
- list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
- list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
- list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
- list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
- list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
- list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
- list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
- list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
- list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
- list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
- list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
- sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
- " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
- " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- " from t_dev_property where isuse = '1'");
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
- ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
- ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
- ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
- ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
- ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
- ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
- if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
- || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
- || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
- || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
- || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
- || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
- || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
- || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
- || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
- || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
- || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
- || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
- || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
- || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
- )
- {
- LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- CDevice* pDev = new CDevice();
- // 获取设备ID
- pDev->m_iID = atoi((*it_dev_id++).c_str());
- // 获取设备UID
- pDev->m_strUid = (*it_uid++).c_str();
- // 获取设备端口号
- pDev->m_iPort = atoi((*it_port++).c_str());
- // 获取设备名称
- pDev->m_strDeviceName = (*it_device_name++).c_str();
- // 获取设备的波特率
- pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
- // 获取设备的数据位
- pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
- // 获取设备的停止位
- pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
- // 获取设备的校验位
- pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
- // 通信的方式
- pDev->m_iCommmode = atoi((*it_commmode++).c_str());
- // 设备地址
- pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
-
- // 设备是否启用
- CString strIsUse = (*it_is_use++).c_str();
- if( 0 == atoi(strIsUse) )
- {
- pDev->m_iIsuse = 0;
- }
- else
- {
- pDev->m_iIsuse = 1;
- }
- // 协议DLL名称
- pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
- // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
- CString strSpecialDevice = (*it_special_device++).c_str();
- pDev->m_bySpecialdevice = atoi(strSpecialDevice);
- //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
- // 设备IP
- pDev->m_strIp = (*it_ip++).c_str();
- // 网络通信端口
- pDev->m_iIpport = atoi((*it_ip_port++).c_str());
- // ini配置文件名称
- pDev->m_strIniName = (*it_ini_name++).c_str();
- // 字符串预留1
- pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
- // 字符串预留2
- pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
- // 字符串预留3
- pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
- // 字符串预留4
- pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
- // 字符串预留5
- pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
- // 字符串预留6
- pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
- // 字符串预留7
- pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
- // 字符串预留8
- pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
- // 字符串预留9
- pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
- // 字符串预留10
- pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
-
- // 整形预留1
- pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
- // 整形预留2
- pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
- // 整形预留3
- pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
- // 整形预留4
- pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
- // 整形预留5
- pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
- // 整形预留6
- pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
- // 整形预留7
- pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
- // 整形预留8
- pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
- // 整形预留9
- pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
- // 整形预留10
- pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
- CString strBoolReserved1 = (*it_bool_reserved1++).c_str();
- //LOG4C((LOG_NOTICE, "strBoolReserved1=%s", strBoolReserved1));
- //布尔型预留1
- if( 0 == atoi(strBoolReserved1) )
- {
- pDev->m_bReserved1 = false;
- }
- else
- {
- pDev->m_bReserved1 = true;
- }
- //布尔型预留2
- if( 0 == atoi((*it_bool_reserved2++).c_str()) )
- {
- pDev->m_bReserved2 = false;
- }
- else
- {
- pDev->m_bReserved2 = true;
- }
- //布尔型预留3
- if( 0 == atoi((*it_bool_reserved3++).c_str()) )
- {
- pDev->m_bReserved3 = false;
- }
- else
- {
- pDev->m_bReserved3 = true;
- }
- //布尔型预留4
- if( 0 == atoi((*it_bool_reserved4++).c_str()) )
- {
- pDev->m_bReserved4 = false;
- }
- else
- {
- pDev->m_bReserved4 = true;
- }
- //布尔型预留5
- if( 0 == atoi((*it_bool_reserved5++).c_str()) )
- {
- pDev->m_bReserved5 = false;
- }
- else
- {
- pDev->m_bReserved5 = true;
- }
- //布尔型预留6
- if( 0 == atoi((*it_bool_reserved6++).c_str()) )
- {
- pDev->m_bReserved6 = false;
- }
- else
- {
- pDev->m_bReserved6 = true;
- }
- //布尔型预留7
- if( 0 == atoi((*it_bool_reserved7++).c_str()) )
- {
- pDev->m_bReserved7 = false;
- }
- else
- {
- pDev->m_bReserved7 = true;
- }
- //布尔型预留8
- if( 0 == atoi((*it_bool_reserved8++).c_str()) )
- {
- pDev->m_bReserved8 = false;
- }
- else
- {
- pDev->m_bReserved8 = true;
- }
- //布尔型预留9
- if( 0 == atoi((*it_bool_reserved9++).c_str()) )
- {
- pDev->m_bReserved9 = false;
- }
- else
- {
- pDev->m_bReserved9 = true;
- }
- //布尔型预留10
- if( 0 == atoi((*it_bool_reserved10++).c_str()) )
- {
- pDev->m_bReserved10 = false;
- }
- else
- {
- pDev->m_bReserved10 = true;
- }
- if( g_pDevicesManager )
- {
- GetVarInfo((void *)pDev, (char *)(LPCTSTR)pDev->m_strUid );
-
- int nVarSize = (int)pDev->m_Vars.GetSize();
- for( int j = 0; j < nVarSize; j++ )
- {
- CBaseVar *pBaseVar = pDev->m_Vars[j];
- }
- //LOG4C((LOG_NOTICE, "add device desc %s", pDev->m_strDeviceName));
- g_pDevicesManager->m_Devices.Add(pDev);
- }
- }
- }
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- list_dev_id.erase(it_dev_id++);
- list_uid.erase(it_uid++);
- list_port.erase(it_port++);
- list_device_name.erase(it_device_name++);
- list_device_baudrate.erase(it_device_baudrate++);
- list_commmode.erase(it_commmode++);
- list_devide_addr.erase(it_devide_addr++);
- list_is_use.erase(it_is_use++);
- list_protocol_dll_name.erase(it_protocol_dll_name++);
- list_special_device.erase(it_special_device++);
- list_data_bit.erase(it_data_bit++);
- list_stop_bit.erase(it_stop_bit++);
- list_parity_bit.erase(it_parity_bit++);
- list_ip.erase(it_ip++);
- list_ip_port.erase(it_ip_port++);
- list_ini_name.erase(it_ini_name++);
- list_str_reserved1.erase(it_str_reserved1++);
- list_str_reserved2.erase(it_str_reserved2++);
- list_str_reserved3.erase(it_str_reserved3++);
- list_str_reserved4.erase(it_str_reserved4++);
- list_str_reserved5.erase(it_str_reserved5++);
- list_str_reserved6.erase(it_str_reserved6++);
- list_str_reserved7.erase(it_str_reserved7++);
- list_str_reserved8.erase(it_str_reserved8++);
- list_str_reserved9.erase(it_str_reserved9++);
- list_str_reserved10.erase(it_str_reserved10++);
- list_int_reserved1.erase(it_int_reserved1++);
- list_int_reserved2.erase(it_int_reserved2++);
- list_int_reserved3.erase(it_int_reserved3++);
- list_int_reserved4.erase(it_int_reserved4++);
- list_int_reserved5.erase(it_int_reserved5++);
- list_int_reserved6.erase(it_int_reserved6++);
- list_int_reserved7.erase(it_int_reserved7++);
- list_int_reserved8.erase(it_int_reserved8++);
- list_int_reserved9.erase(it_int_reserved9++);
- list_int_reserved10.erase(it_int_reserved10++);
- list_bool_reserved1.erase(it_bool_reserved1++);
- list_bool_reserved2.erase(it_bool_reserved2++);
- list_bool_reserved3.erase(it_bool_reserved3++);
- list_bool_reserved4.erase(it_bool_reserved4++);
- list_bool_reserved5.erase(it_bool_reserved5++);
- list_bool_reserved6.erase(it_bool_reserved6++);
- list_bool_reserved7.erase(it_bool_reserved7++);
- list_bool_reserved8.erase(it_bool_reserved8++);
- list_bool_reserved9.erase(it_bool_reserved9++);
- list_bool_reserved10.erase(it_bool_reserved10++);
- }
- return nRet;
- }
- // 修改设备资料
- INT CDBInterface::EditDevInfo()
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
- list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
- list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
- list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
- list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
- list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
- list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
- list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
- list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
- list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
- list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
- list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
- list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
- sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
- " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
- " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- " from t_dev_property where isuse = '1'");
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
- ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
- ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
- ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
- ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
- ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
- ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
- if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
- || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
- || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
- || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
- || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
- || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
- || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
- || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
- || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
- || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
- || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
- || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
- || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
- || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
- )
- {
- LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
- return 0;
- }
- int nDeviceIndex = 0;
- if( nRet != -1 )
- {
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- CDevice* pDev = g_pDevicesManager->m_Devices[nDeviceIndex];
- // 获取设备ID
- pDev->m_iID = atoi((*it_dev_id++).c_str());
- // 获取设备UID
- pDev->m_strUid = (*it_uid++).c_str();
- // 获取设备端口号
- pDev->m_iPort = atoi((*it_port++).c_str());
- // 获取设备名称
- pDev->m_strDeviceName = (*it_device_name++).c_str();
- // 获取设备的波特率
- pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
- // 获取设备的数据位
- pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
- // 获取设备的停止位
- pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
- // 获取设备的校验位
- pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
- // 通信的方式
- pDev->m_iCommmode = atoi((*it_commmode++).c_str());
- // 设备地址
- pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
-
- // 设备是否启用
- CString strIsUse = (*it_is_use++).c_str();
- if( 0 == atoi(strIsUse) )
- {
- pDev->m_iIsuse = FALSE;
- }
- else
- {
- pDev->m_iIsuse = TRUE;
- }
- // 协议DLL名称
- pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
- // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
- CString strSpecialDevice = (*it_special_device++).c_str();
- pDev->m_bySpecialdevice = atoi(strSpecialDevice);
- //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
- // 设备IP
- pDev->m_strIp = (*it_ip++).c_str();
- // 网络通信端口
- pDev->m_iIpport = atoi((*it_ip_port++).c_str());
- // ini配置文件名称
- pDev->m_strIniName = (*it_ini_name++).c_str();
- // 字符串预留1
- pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
- // 字符串预留2
- pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
- // 字符串预留3
- pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
- // 字符串预留4
- pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
- // 字符串预留5
- pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
- // 字符串预留6
- pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
- // 字符串预留7
- pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
- // 字符串预留8
- pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
- // 字符串预留9
- pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
- // 字符串预留10
- pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
-
- // 整形预留1
- pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
- // 整形预留2
- pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
- // 整形预留3
- pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
- // 整形预留4
- pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
- // 整形预留5
- pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
- // 整形预留6
- pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
- // 整形预留7
- pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
- // 整形预留8
- pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
- // 整形预留9
- pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
- // 整形预留10
- pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
- //布尔型预留1
- if( 0 == atoi((*it_bool_reserved1++).c_str()) )
- {
- pDev->m_bReserved1 = false;
- }
- else
- {
- pDev->m_bReserved1 = true;
- }
- //布尔型预留2
- if( 0 == atoi((*it_bool_reserved2++).c_str()) )
- {
- pDev->m_bReserved2 = false;
- }
- else
- {
- pDev->m_bReserved2 = true;
- }
- //布尔型预留3
- if( 0 == atoi((*it_bool_reserved3++).c_str()) )
- {
- pDev->m_bReserved3 = false;
- }
- else
- {
- pDev->m_bReserved3 = true;
- }
- //布尔型预留4
- if( 0 == atoi((*it_bool_reserved4++).c_str()) )
- {
- pDev->m_bReserved4 = false;
- }
- else
- {
- pDev->m_bReserved4 = true;
- }
- //布尔型预留5
- if( 0 == atoi((*it_bool_reserved5++).c_str()) )
- {
- pDev->m_bReserved5 = false;
- }
- else
- {
- pDev->m_bReserved5 = true;
- }
- //布尔型预留6
- if( 0 == atoi((*it_bool_reserved6++).c_str()) )
- {
- pDev->m_bReserved6 = false;
- }
- else
- {
- pDev->m_bReserved6 = true;
- }
- //布尔型预留7
- if( 0 == atoi((*it_bool_reserved7++).c_str()) )
- {
- pDev->m_bReserved7 = false;
- }
- else
- {
- pDev->m_bReserved7 = true;
- }
- //布尔型预留8
- if( 0 == atoi((*it_bool_reserved8++).c_str()) )
- {
- pDev->m_bReserved8 = false;
- }
- else
- {
- pDev->m_bReserved8 = true;
- }
- //布尔型预留9
- if( 0 == atoi((*it_bool_reserved9++).c_str()) )
- {
- pDev->m_bReserved9 = false;
- }
- else
- {
- pDev->m_bReserved9 = true;
- }
- //布尔型预留10
- if( 0 == atoi((*it_bool_reserved10++).c_str()) )
- {
- pDev->m_bReserved10 = false;
- }
- else
- {
- pDev->m_bReserved10 = true;
- }
- nDeviceIndex++;
- }
- }
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- list_dev_id.erase(it_dev_id++);
- list_uid.erase(it_uid++);
- list_port.erase(it_port++);
- list_device_name.erase(it_device_name++);
- list_device_baudrate.erase(it_device_baudrate++);
- list_commmode.erase(it_commmode++);
- list_devide_addr.erase(it_devide_addr++);
- list_is_use.erase(it_is_use++);
- list_protocol_dll_name.erase(it_protocol_dll_name++);
- list_special_device.erase(it_special_device++);
- list_data_bit.erase(it_data_bit++);
- list_stop_bit.erase(it_stop_bit++);
- list_parity_bit.erase(it_parity_bit++);
- list_ip.erase(it_ip++);
- list_ip_port.erase(it_ip_port++);
- list_ini_name.erase(it_ini_name++);
- list_str_reserved1.erase(it_str_reserved1++);
- list_str_reserved2.erase(it_str_reserved2++);
- list_str_reserved3.erase(it_str_reserved3++);
- list_str_reserved4.erase(it_str_reserved4++);
- list_str_reserved5.erase(it_str_reserved5++);
- list_str_reserved6.erase(it_str_reserved6++);
- list_str_reserved7.erase(it_str_reserved7++);
- list_str_reserved8.erase(it_str_reserved8++);
- list_str_reserved9.erase(it_str_reserved9++);
- list_str_reserved10.erase(it_str_reserved10++);
- list_int_reserved1.erase(it_int_reserved1++);
- list_int_reserved2.erase(it_int_reserved2++);
- list_int_reserved3.erase(it_int_reserved3++);
- list_int_reserved4.erase(it_int_reserved4++);
- list_int_reserved5.erase(it_int_reserved5++);
- list_int_reserved6.erase(it_int_reserved6++);
- list_int_reserved7.erase(it_int_reserved7++);
- list_int_reserved8.erase(it_int_reserved8++);
- list_int_reserved9.erase(it_int_reserved9++);
- list_int_reserved10.erase(it_int_reserved10++);
- list_bool_reserved1.erase(it_bool_reserved1++);
- list_bool_reserved2.erase(it_bool_reserved2++);
- list_bool_reserved3.erase(it_bool_reserved3++);
- list_bool_reserved4.erase(it_bool_reserved4++);
- list_bool_reserved5.erase(it_bool_reserved5++);
- list_bool_reserved6.erase(it_bool_reserved6++);
- list_bool_reserved7.erase(it_bool_reserved7++);
- list_bool_reserved8.erase(it_bool_reserved8++);
- list_bool_reserved9.erase(it_bool_reserved9++);
- list_bool_reserved10.erase(it_bool_reserved10++);
- }
- return nRet;
- }
- // 修改设备资料
- INT CDBInterface::EditDevInfo(int nDevideIndex, char *pDevUid)
- {
- CDevice *pDev = g_pDevicesManager->m_Devices[nDevideIndex];
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = {0};
- list<string> list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate;
- list<string> list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name;
- list<string> list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
- list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
- list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
- list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
- list<string>::iterator it_dev_id, it_uid, it_port, it_device_name, it_device_baudrate;
- list<string>::iterator it_commmode, it_devide_addr, it_is_use, it_protocol_dll_name;
- list<string>::iterator it_special_device, it_data_bit, it_stop_bit, it_parity_bit, it_ip, it_ip_port, it_ini_name;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
- list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
- list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
- list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
- sprintf(strSQLText, "select id as devId, uid, port, devicename, baudrate, commmode, devideaddr, isuse, protocoldllname, " \
- " specialdevice, databit, stopbit, paritybit, ip, ipport, ininame, " \
- " strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- " strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- " intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- " intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- " boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- " boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- " from t_dev_property where uid = '%s'", pDevUid);
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList46(strSQLText
- ,list_dev_id, list_uid, list_port, list_device_name, list_device_baudrate
- ,list_commmode, list_devide_addr, list_is_use, list_protocol_dll_name
- ,list_special_device, list_data_bit, list_stop_bit, list_parity_bit, list_ip, list_ip_port, list_ini_name
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
- ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
- ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
- ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
- if( 0 == list_dev_id.size() || 0 == list_uid.size() || 0 == list_port.size()
- || 0 == list_device_name.size() || 0 == list_device_baudrate.size() || 0 == list_commmode.size()
- || 0 == list_devide_addr.size() || 0 == list_is_use.size() || 0 == list_protocol_dll_name.size()
- || 0 == list_special_device.size() || 0 == list_data_bit.size() || 0 == list_stop_bit.size()
- || 0 == list_parity_bit.size() || 0 == list_ip.size() || 0 == list_ip_port.size() || 0 == list_ini_name.size()
- || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
- || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
- || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
- || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
- || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
- || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
- || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
- || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
- || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
- )
- {
- LOG4C((LOG_NOTICE, "GetDevInfo GetFieldValueList46 list size = 0"));
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- // 获取设备ID
- pDev->m_iID = atoi((*it_dev_id++).c_str());
- // 获取设备UID
- pDev->m_strUid = (*it_uid++).c_str();
- // 获取设备端口号
- pDev->m_iPort = atoi((*it_port++).c_str());
- // 获取设备名称
- pDev->m_strDeviceName = (*it_device_name++).c_str();
- // 获取设备的波特率
- pDev->m_iBaudrate = atoi((*it_device_baudrate++).c_str());
- // 获取设备的数据位
- pDev->m_iDatabit = atoi((*it_data_bit++).c_str());
- // 获取设备的停止位
- pDev->m_iStopbit = atoi((*it_stop_bit++).c_str());
- // 获取设备的校验位
- pDev->m_iParitybit = atoi((*it_parity_bit++).c_str());
- // 通信的方式
- pDev->m_iCommmode = atoi((*it_commmode++).c_str());
- // 设备地址
- pDev->m_iDevideaddr = atoi((*it_devide_addr++).c_str());
-
- // 设备是否启用
- CString strIsUse = (*it_is_use++).c_str();
- if( 0 == atoi(strIsUse) )
- {
- pDev->m_iIsuse = FALSE;
- }
- else
- {
- pDev->m_iIsuse = TRUE;
- }
- // 协议DLL名称
- pDev->m_strProtocoldllname = (*it_protocol_dll_name++).c_str();
- // Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
- CString strSpecialDevice = (*it_special_device++).c_str();
- pDev->m_bySpecialdevice = atoi(strSpecialDevice);
- //LOG4C((LOG_NOTICE, "device name = %s, specialdevice = %d, %s", pDev->m_strDeviceName, pDev->m_bySpecialdevice, strSpecialDevice));
- // 设备IP
- pDev->m_strIp = (*it_ip++).c_str();
- // 网络通信端口
- pDev->m_iIpport = atoi((*it_ip_port++).c_str());
- // ini配置文件名称
- pDev->m_strIniName = (*it_ini_name++).c_str();
- // 字符串预留1
- pDev->m_strReserved1 = (*it_str_reserved1++).c_str();
- // 字符串预留2
- pDev->m_strReserved2 = (*it_str_reserved2++).c_str();
- // 字符串预留3
- pDev->m_strReserved3 = (*it_str_reserved3++).c_str();
- // 字符串预留4
- pDev->m_strReserved4 = (*it_str_reserved4++).c_str();
- // 字符串预留5
- pDev->m_strReserved5 = (*it_str_reserved5++).c_str();
- // 字符串预留6
- pDev->m_strReserved6 = (*it_str_reserved6++).c_str();
- // 字符串预留7
- pDev->m_strReserved7 = (*it_str_reserved7++).c_str();
- // 字符串预留8
- pDev->m_strReserved8 = (*it_str_reserved8++).c_str();
- // 字符串预留9
- pDev->m_strReserved9 = (*it_str_reserved9++).c_str();
- // 字符串预留10
- pDev->m_strReserved10 = (*it_str_reserved10++).c_str();
-
- // 整形预留1
- pDev->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
- // 整形预留2
- pDev->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
- // 整形预留3
- pDev->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
- // 整形预留4
- pDev->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
- // 整形预留5
- pDev->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
- // 整形预留6
- pDev->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
- // 整形预留7
- pDev->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
- // 整形预留8
- pDev->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
- // 整形预留9
- pDev->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
- // 整形预留10
- pDev->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
- //布尔型预留1
- if( 0 == atoi((*it_bool_reserved1++).c_str()) )
- {
- pDev->m_bReserved1 = false;
- }
- else
- {
- pDev->m_bReserved1 = true;
- }
- //布尔型预留2
- if( 0 == atoi((*it_bool_reserved2++).c_str()) )
- {
- pDev->m_bReserved2 = false;
- }
- else
- {
- pDev->m_bReserved2 = true;
- }
- //布尔型预留3
- if( 0 == atoi((*it_bool_reserved3++).c_str()) )
- {
- pDev->m_bReserved3 = false;
- }
- else
- {
- pDev->m_bReserved3 = true;
- }
- //布尔型预留4
- if( 0 == atoi((*it_bool_reserved4++).c_str()) )
- {
- pDev->m_bReserved4 = false;
- }
- else
- {
- pDev->m_bReserved4 = true;
- }
- //布尔型预留5
- if( 0 == atoi((*it_bool_reserved5++).c_str()) )
- {
- pDev->m_bReserved5 = false;
- }
- else
- {
- pDev->m_bReserved5 = true;
- }
- //布尔型预留6
- if( 0 == atoi((*it_bool_reserved6++).c_str()) )
- {
- pDev->m_bReserved6 = false;
- }
- else
- {
- pDev->m_bReserved6 = true;
- }
- //布尔型预留7
- if( 0 == atoi((*it_bool_reserved7++).c_str()) )
- {
- pDev->m_bReserved7 = false;
- }
- else
- {
- pDev->m_bReserved7 = true;
- }
- //布尔型预留8
- if( 0 == atoi((*it_bool_reserved8++).c_str()) )
- {
- pDev->m_bReserved8 = false;
- }
- else
- {
- pDev->m_bReserved8 = true;
- }
- //布尔型预留9
- if( 0 == atoi((*it_bool_reserved9++).c_str()) )
- {
- pDev->m_bReserved9 = false;
- }
- else
- {
- pDev->m_bReserved9 = true;
- }
- //布尔型预留10
- if( 0 == atoi((*it_bool_reserved10++).c_str()) )
- {
- pDev->m_bReserved10 = false;
- }
- else
- {
- pDev->m_bReserved10 = true;
- }
- break;
- }
- }
- for( it_dev_id = list_dev_id.begin(), it_uid = list_uid.begin(), it_port = list_port.begin()
- ,it_device_name = list_device_name.begin(), it_device_baudrate = list_device_baudrate.begin()
- ,it_commmode = list_commmode.begin(), it_devide_addr = list_devide_addr.begin()
- ,it_is_use = list_is_use.begin(),it_protocol_dll_name = list_protocol_dll_name.begin()
- ,it_special_device = list_special_device.begin(), it_data_bit = list_data_bit.begin()
- ,it_stop_bit = list_stop_bit.begin(), it_parity_bit = list_parity_bit.begin(), it_ip = list_ip.begin()
- ,it_ip_port = list_ip_port.begin(), it_ini_name = list_ini_name.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_dev_id != list_dev_id.end(), it_uid != list_uid.end(), it_port != list_port.end()
- ,it_device_name != list_device_name.end(), it_device_baudrate != list_device_baudrate.end()
- ,it_commmode != list_commmode.end(), it_devide_addr != list_devide_addr.end()
- ,it_is_use != list_is_use.end(),it_protocol_dll_name != list_protocol_dll_name.end()
- ,it_special_device != list_special_device.end(), it_data_bit != list_data_bit.end()
- ,it_stop_bit != list_stop_bit.end(), it_parity_bit != list_parity_bit.end(), it_ip != list_ip.end()
- ,it_ip_port != list_ip_port.end(), it_ini_name != list_ini_name.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- list_dev_id.erase(it_dev_id++);
- list_uid.erase(it_uid++);
- list_port.erase(it_port++);
- list_device_name.erase(it_device_name++);
- list_device_baudrate.erase(it_device_baudrate++);
- list_commmode.erase(it_commmode++);
- list_devide_addr.erase(it_devide_addr++);
- list_is_use.erase(it_is_use++);
- list_protocol_dll_name.erase(it_protocol_dll_name++);
- list_special_device.erase(it_special_device++);
- list_data_bit.erase(it_data_bit++);
- list_stop_bit.erase(it_stop_bit++);
- list_parity_bit.erase(it_parity_bit++);
- list_ip.erase(it_ip++);
- list_ip_port.erase(it_ip_port++);
- list_ini_name.erase(it_ini_name++);
- list_str_reserved1.erase(it_str_reserved1++);
- list_str_reserved2.erase(it_str_reserved2++);
- list_str_reserved3.erase(it_str_reserved3++);
- list_str_reserved4.erase(it_str_reserved4++);
- list_str_reserved5.erase(it_str_reserved5++);
- list_str_reserved6.erase(it_str_reserved6++);
- list_str_reserved7.erase(it_str_reserved7++);
- list_str_reserved8.erase(it_str_reserved8++);
- list_str_reserved9.erase(it_str_reserved9++);
- list_str_reserved10.erase(it_str_reserved10++);
- list_int_reserved1.erase(it_int_reserved1++);
- list_int_reserved2.erase(it_int_reserved2++);
- list_int_reserved3.erase(it_int_reserved3++);
- list_int_reserved4.erase(it_int_reserved4++);
- list_int_reserved5.erase(it_int_reserved5++);
- list_int_reserved6.erase(it_int_reserved6++);
- list_int_reserved7.erase(it_int_reserved7++);
- list_int_reserved8.erase(it_int_reserved8++);
- list_int_reserved9.erase(it_int_reserved9++);
- list_int_reserved10.erase(it_int_reserved10++);
- list_bool_reserved1.erase(it_bool_reserved1++);
- list_bool_reserved2.erase(it_bool_reserved2++);
- list_bool_reserved3.erase(it_bool_reserved3++);
- list_bool_reserved4.erase(it_bool_reserved4++);
- list_bool_reserved5.erase(it_bool_reserved5++);
- list_bool_reserved6.erase(it_bool_reserved6++);
- list_bool_reserved7.erase(it_bool_reserved7++);
- list_bool_reserved8.erase(it_bool_reserved8++);
- list_bool_reserved9.erase(it_bool_reserved9++);
- list_bool_reserved10.erase(it_bool_reserved10++);
- }
- return nRet;
- }
- //获取变量
- INT CDBInterface::GetVarInfo(void *pPara, CHAR *pUid)
- {
- CDevice *pDev = (CDevice *)pPara;
- CHAR strSQLText[MAX_SQL_LENGTH * 2] = {0};
- list<string> list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit;
- list<string> list_lower_limit, list_normal_state, list_identify_time, list_redetect_time;
- list<string> list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description;
- list<string> list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save;
- list<string> list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit;
- list<string> list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets;
- list<string> list_funcid, list_data_len, list_coefficient, list_realtimeflag;
- list<string> list_rs232_cmd, list_rs232_type, list_rs232_index;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
- list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
- list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
- list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
- list<string>::iterator it_var_id, it_set_value, it_var_name, it_uid, it_upper_limit;
- list<string>::iterator it_lower_limit, it_normal_state, it_identify_time, it_redetect_time;
- list<string>::iterator it_normal_is_notice, it_warn_level, it_snmp_oid, it_fields, it_description;
- list<string>::iterator it_max_values, it_min_values, it_max_convtrate, it_min_convtrate, it_is_save;
- list<string>::iterator it_collect_freq, it_var_type_id, it_readonly, it_is_dde, it_address, it_unit;
- list<string>::iterator it_reccurve, it_register_num, it_child_id, it_var_item_id, it_rearm, it_offsets;
- list<string>::iterator it_funcid, it_data_len, it_coefficient, it_realtimeflag;
- list<string>::iterator it_rs232_cmd, it_rs232_type, it_rs232_index;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
- list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
- list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
- list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' order by id", pUid);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' order by id", pUid);
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' order by id", pUid);
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, offsets, funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' order by id", pUid);
- }
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList68(strSQLText
- ,list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit
- ,list_lower_limit, list_normal_state, list_identify_time, list_redetect_time
- ,list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description
- ,list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save
- ,list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit
- ,list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets
- ,list_funcid, list_data_len, list_coefficient, list_realtimeflag
- ,list_rs232_cmd, list_rs232_type, list_rs232_index
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
- ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
- ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
- ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
- if( 0 == list_var_id.size() || 0 == list_set_value.size() || 0 == list_var_name.size()
- || 0 == list_uid.size() || 0 == list_upper_limit.size() || 0 == list_lower_limit.size()
- || 0 == list_normal_state.size() || 0 == list_identify_time.size() || 0 == list_redetect_time.size()
- || 0 == list_normal_is_notice.size() || 0 == list_warn_level.size() || 0 == list_snmp_oid.size()
- || 0 == list_fields.size() || 0 == list_description.size() || 0 == list_max_values.size() || 0 == list_min_values.size()
- || 0 == list_max_convtrate.size() || 0 == list_min_convtrate.size() || 0 == list_is_save.size()
- || 0 == list_collect_freq.size() || 0 == list_var_type_id.size() || 0 == list_readonly.size()
- || 0 == list_is_dde.size() || 0 == list_address.size() || 0 == list_unit.size()
- || 0 == list_reccurve.size() || 0 == list_register_num.size() || 0 == list_child_id.size()
- || 0 == list_var_item_id.size() || 0 == list_rearm.size() || 0 == list_offsets.size()
- || 0 == list_funcid.size() || 0 == list_data_len.size() || 0 == list_coefficient.size()
- || 0 == list_realtimeflag.size() || 0 == list_rs232_cmd.size() || 0 == list_rs232_type.size() || 0 == list_rs232_index.size()
- || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
- || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
- || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
- || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
- || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
- || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
- || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
- || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
- || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
- )
- {
- LOG4C((LOG_NOTICE, "device name = %s has not variant!", pDev->m_strDeviceName));
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
- ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
- ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
- ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
- ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
- ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
- ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
- ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
- ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
- ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
- ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
- ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
- ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
- ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
- ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
- ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
- ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
- ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
- ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
- ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
- ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
- ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
- ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
- ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
- ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
- ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
- ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
- ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
- ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- CBaseVar *pBaseVar;
- pBaseVar = new CBaseVar();
- int nVarID;
- CString strUid;
- nVarID = atoi((*it_var_id++).c_str());
- strUid = (*it_uid++).c_str();
- // 变量ID
- pBaseVar->m_nVarID = nVarID;
- // 设定值
- pBaseVar->m_strSetValue = (*it_set_value++).c_str();
-
- // 变量名称
- pBaseVar->m_strName = (*it_var_name++).c_str();
- // 变量Uid
- pBaseVar->m_strVarUID = strUid;
-
- // 上限
- pBaseVar->m_nUpperLimit = atoi((*it_upper_limit++).c_str());
- //LOG4C((LOG_NOTICE, "GetVarInfo pBaseVar->m_nUpperLimit = %d", pBaseVar->m_nUpperLimit));
- // 下限
- pBaseVar->m_nLowerLimit = atoi((*it_lower_limit++).c_str());
- // 正常状态
- pBaseVar->m_nNormalState = atoi((*it_normal_state++).c_str());
-
- // 辨识时间
- pBaseVar->m_nIdentifyTime = atoi((*it_identify_time++).c_str());
- // 重新检测时间
- pBaseVar->m_nReDetectTime = atoi((*it_redetect_time++).c_str());
- // 恢复正常是否触发远程报警
- CString strNormalIsNotice = (*it_normal_is_notice++).c_str();
- if( 0 == atoi(strNormalIsNotice) )
- {
- pBaseVar->m_bNormalIsNotice = FALSE;
- }
- else
- {
- pBaseVar->m_bNormalIsNotice = TRUE;
- }
- // 报警级别
- pBaseVar->m_nWaringLevel = atoi((*it_warn_level++).c_str());
- // Snmp对象OID
- pBaseVar->m_strSnmpoi = (*it_snmp_oid++).c_str();
- // Snmp对象域
- pBaseVar->m_strFields = (*it_fields++).c_str();
- // 变量描述
- pBaseVar->m_strDesc = (*it_description++).c_str();
- // 最大值
- pBaseVar->m_nMaxValues = atoi((*it_max_values++).c_str());
-
- // 最小值
- pBaseVar->m_nMinValues = atoi((*it_min_values++).c_str());
- // 最大比例
- pBaseVar->m_nMaxConvtRate = atoi((*it_max_convtrate++).c_str());
- // 最小比例
- pBaseVar->m_nMinConvtRate = atoi((*it_min_convtrate++).c_str());
- // 是否保存数值
- CString strIsSave = (*it_is_save++).c_str();
- if( 0 == atoi(strIsSave) )
- {
- pBaseVar->m_bIsSave = FALSE;
- }
- else
- {
- pBaseVar->m_bIsSave = TRUE;
- }
-
- //LOG4C((LOG_NOTICE, "var desc = %s, pBaseVar->m_bIsSave = %d, strIsSave = %s", pBaseVar->m_strDesc, pBaseVar->m_bIsSave, strIsSave));
- // 采集频率
- pBaseVar->m_nCollectFreq = atoi((*it_collect_freq++).c_str());
- // 变量类型ID
- pBaseVar->m_nVarTypeID = atoi((*it_var_type_id++).c_str());
- // 读写权限
- CString strReadOnly = (*it_readonly++).c_str();
- if( 0 == atoi(strReadOnly) )
- {
- pBaseVar->m_bReadOnly = FALSE;
- }
- else
- {
- pBaseVar->m_bReadOnly = TRUE;
- }
- // 是否DDE
- CString strDDE = (*it_is_dde++).c_str();
- if( 0 == atoi(strDDE) )
- {
- pBaseVar->m_bIsDDE = FALSE;
- }
- else
- {
- pBaseVar->m_bIsDDE = TRUE;
- }
- // 寄存器起始地址
- pBaseVar->m_nRegStartAddr = atoi((*it_address++).c_str());
- // 单位
- pBaseVar->m_strUnit = (*it_unit++).c_str();
- // 是否记录实时曲线
- CString strRecCurve = (*it_reccurve++).c_str();
- if( 0 == atoi(strRecCurve) )
- {
- pBaseVar->m_bRecCurve = FALSE;
- }
- else
- {
- pBaseVar->m_bRecCurve = TRUE;
- }
- // 寄存器个数
- pBaseVar->m_iRegisterNum = atoi((*it_register_num++).c_str());
- // 变量子ID
- pBaseVar->m_iChildID = atoi((*it_child_id++).c_str());
-
- // t_dev_varint_item表的ID
- pBaseVar->m_nVarItemID = atoi((*it_var_item_id++).c_str());
- // 校正值
- pBaseVar->m_nRearm = atoi((*it_rearm++).c_str());
- // 偏移值
- pBaseVar->m_nOffset = atoi((*it_offsets++).c_str());
- // 功能码ID
- pBaseVar->m_iFuncID = atoi((*it_funcid++).c_str());
- // 数据长度
- pBaseVar->m_iDataLen = atoi((*it_data_len++).c_str());
- // 系数
- pBaseVar->m_dbCoefficient = atof((*it_coefficient++).c_str());
- // 是否实时采集
- CString strRealTimeFlag = (*it_realtimeflag++).c_str();
- //LOG4C((LOG_NOTICE, "strRealTimeFlag = %s, atoi(strRealTimeFlag) = %d", strRealTimeFlag, atoi(strRealTimeFlag)));
- if( 0 == atoi(strRealTimeFlag) )
- {
- pBaseVar->m_bRealTimeflag = FALSE;
- }
- else
- {
- pBaseVar->m_bRealTimeflag = TRUE;
- }
- //LOG4C((LOG_NOTICE, "pBaseVar->m_bRealTimeflag = %d", pBaseVar->m_bRealTimeflag));
- // RS232命令
- pBaseVar->m_strRs232cmd = (*it_rs232_cmd++).c_str();
- // RS232类型
- pBaseVar->m_strRs232type = (*it_rs232_type++).c_str();
- // RS232索引
- pBaseVar->m_strRs232Index = (*it_rs232_index++).c_str();
- //LOG4C((LOG_NOTICE, "pBaseVar->m_strRs232Index = %s", pBaseVar->m_strRs232Index));
- // 字符串预留1
- pBaseVar->m_strReserved1 = (*it_str_reserved1++).c_str();
- // 字符串预留2
- pBaseVar->m_strReserved2 = (*it_str_reserved2++).c_str();
- // 字符串预留3
- pBaseVar->m_strReserved3 = (*it_str_reserved3++).c_str();
- // 字符串预留4
- pBaseVar->m_strReserved4 = (*it_str_reserved4++).c_str();
- // 字符串预留5
- pBaseVar->m_strReserved5 = (*it_str_reserved5++).c_str();
- // 字符串预留6
- pBaseVar->m_strReserved6 = (*it_str_reserved6++).c_str();
- // 字符串预留7
- pBaseVar->m_strReserved7 = (*it_str_reserved7++).c_str();
- // 字符串预留8
- pBaseVar->m_strReserved8 = (*it_str_reserved8++).c_str();
- // 字符串预留9
- pBaseVar->m_strReserved9 = (*it_str_reserved9++).c_str();
- // 字符串预留10
- pBaseVar->m_strReserved10 = (*it_str_reserved10++).c_str();
-
- // 整形预留1
- pBaseVar->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
- // 整形预留2
- pBaseVar->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
- // 整形预留3
- pBaseVar->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
- // 整形预留4
- pBaseVar->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
- // 整形预留5
- pBaseVar->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
- // 整形预留6
- pBaseVar->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
- // 整形预留7
- pBaseVar->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
- // 整形预留8
- pBaseVar->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
- // 整形预留9
- pBaseVar->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
- // 整形预留10
- pBaseVar->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
- CString strBoolReserved1 = (*it_bool_reserved1++).c_str();
- //布尔型预留1
- if( 0 == atoi(strBoolReserved1) )
- {
- pBaseVar->m_bReserved1 = false;
- }
- else
- {
- pBaseVar->m_bReserved1 = true;
- }
- //布尔型预留2
- if( 0 == atoi((*it_bool_reserved2++).c_str()) )
- {
- pBaseVar->m_bReserved2 = false;
- }
- else
- {
- pBaseVar->m_bReserved2 = true;
- }
- CString strBoolReserved3 = (*it_bool_reserved3++).c_str();
- //LOG4C((LOG_NOTICE, "strBoolReserved3=%s", strBoolReserved3));
- //布尔型预留3
- if( 0 == atoi(strBoolReserved3) )
- {
- pBaseVar->m_bReserved3 = false;
- }
- else
- {
- pBaseVar->m_bReserved3 = true;
- }
- //布尔型预留4
- if( 0 == atoi((*it_bool_reserved4++).c_str()) )
- {
- pBaseVar->m_bReserved4 = false;
- }
- else
- {
- pBaseVar->m_bReserved4 = true;
- }
- //布尔型预留5
- if( 0 == atoi((*it_bool_reserved5++).c_str()) )
- {
- pBaseVar->m_bReserved5 = false;
- }
- else
- {
- pBaseVar->m_bReserved5 = true;
- }
- //布尔型预留6
- if( 0 == atoi((*it_bool_reserved6++).c_str()) )
- {
- pBaseVar->m_bReserved6 = false;
- }
- else
- {
- pBaseVar->m_bReserved6 = true;
- }
- //布尔型预留7
- if( 0 == atoi((*it_bool_reserved7++).c_str()) )
- {
- pBaseVar->m_bReserved7 = false;
- }
- else
- {
- pBaseVar->m_bReserved7 = true;
- }
- //布尔型预留8
- if( 0 == atoi((*it_bool_reserved8++).c_str()) )
- {
- pBaseVar->m_bReserved8 = false;
- }
- else
- {
- pBaseVar->m_bReserved8 = true;
- }
- //布尔型预留9
- if( 0 == atoi((*it_bool_reserved9++).c_str()) )
- {
- pBaseVar->m_bReserved9 = false;
- }
- else
- {
- pBaseVar->m_bReserved9 = true;
- }
- //布尔型预留10
- if( 0 == atoi((*it_bool_reserved10++).c_str()) )
- {
- pBaseVar->m_bReserved10 = false;
- }
- else
- {
- pBaseVar->m_bReserved10 = true;
- }
- pBaseVar->m_dbData = pBaseVar->m_nReserved1;
- pBaseVar->m_nStatus = -1;
- pBaseVar->m_strContent = "";
- pBaseVar->m_nAlarmNumber = 0;
- pBaseVar->m_nStatusDescCount = CDBInterface::GetInstancePtr()->GetAlarmStatusDescList( (char *)(LPCTSTR)pDev->m_strUid,
- pBaseVar->m_nVarID,
- pBaseVar->m_listStatusID,
- pBaseVar->m_listStatusDesc );
- list<string>::iterator it_desc, it_id;
- if( pBaseVar->m_listStatusDesc.size() > 0 && pBaseVar->m_listStatusID.size() > 0 )
- {
- for( it_desc = pBaseVar->m_listStatusDesc.begin(), it_id = pBaseVar->m_listStatusID.begin();
- it_desc != pBaseVar->m_listStatusDesc.end(), it_id != pBaseVar->m_listStatusID.end(); )
- {
- CString strStatusID = (*it_id++).c_str();
- CString strStatusDesc = (*it_desc++).c_str();
- //LOG4C((LOG_NOTICE, "var desc = %s, StatusID = %d statusdesc = %s",pBaseVar->m_strDesc,atoi(strStatusID), strStatusDesc));
- }
- }
- //LOG4C((LOG_NOTICE, "var desc = %s, value = %d", pBaseVar->m_strDesc, (int)pBaseVar->m_dbData));
- pBaseVar->m_bExistDatePlan = CDBInterface::GetInstancePtr()->IsExistDatePlan((char *)(LPCTSTR)pDev->m_strUid, pBaseVar->m_nVarID);
- if( pBaseVar->m_nVarItemID > 0 )
- {
- char szStartBit[MAX_ID] = {0};
- char szEndBit[MAX_ID] = {0};
- GetVarItemInfo((char *)(LPCTSTR)pDev->m_strUid,
- pBaseVar->m_nVarItemID,
- szStartBit,
- szEndBit);
- pBaseVar->m_nStartBit = atoi(szStartBit);
- pBaseVar->m_nEndBit = atoi(szEndBit);
- }
- CString strTime;
- CTime tm;
- tm = CTime::GetCurrentTime();
- strTime = tm.Format("%Y-%m-%d %H:%M:%S");
- CHAR szID[MAX_ID] = {0};
- int nRet = CDBInterface::GetInstancePtr()->GetSummaryInfo((char *)(LPCTSTR)pDev->m_strUid,
- (char *)(LPCTSTR)pBaseVar->m_strName,
- szID);
- //LOG4C((LOG_NOTICE, "GetSummaryInfo Return %d", nRet));
- if( nRet == 0 )
- {
- if( TRUE == pBaseVar->m_bRealTimeflag )
- {
- CDBInterface::GetInstancePtr()->InsertSummaryRecord(
- (char *)(LPCTSTR)pDev->m_strDeviceName, // 设备名称
- (char *)(LPCTSTR)strTime, // 发生时间
- "", // 备注
- (char *)(LPCTSTR)pBaseVar->m_strDesc, // 变量描述
- pBaseVar->m_dbData, // 变量值
- (char *)(LPCTSTR)pDev->m_strUid, // 设备Uid
- (char *)(LPCTSTR)pBaseVar->m_strName); // 变量名称
- }
- }
- if( pDev )
- {
- CString sMsg = GetInvalidMessage( pBaseVar->m_strName,pBaseVar->m_nReserved1,pBaseVar->m_nReserved2,pBaseVar->m_nReserved3,
- pBaseVar->m_nLowerLimit,pBaseVar->m_nUpperLimit,pBaseVar->m_nNormalState,pBaseVar->m_nWaringLevel );
- if( sMsg!="" )
- {
- LOG4C((LOG_NOTICE, "变量 %s %s",pBaseVar->m_strName,sMsg ));
- }
- pDev->m_Vars.Add(pBaseVar);
- }
- }
- }
- for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
- ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
- ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
- ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
- ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
- ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
- ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
- ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
- ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
- ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
- ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
- ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
- ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
- ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
- ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
- ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
- ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
- ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
- ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
- ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
- ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
- ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
- ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
- ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
- ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
- ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
- ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
- ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
- ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- list_var_id.erase(it_var_id++);
- list_set_value.erase(it_set_value++);
- list_var_name.erase(it_var_name++);
- list_uid.erase(it_uid++);
- list_upper_limit.erase(it_upper_limit++);
- list_lower_limit.erase(it_lower_limit++);
- list_normal_state.erase(it_normal_state++);
- list_identify_time.erase(it_identify_time++);
- list_redetect_time.erase(it_redetect_time++);
- list_normal_is_notice.erase(it_normal_is_notice++);
- list_warn_level.erase(it_warn_level++);
- list_snmp_oid.erase(it_snmp_oid++);
- list_fields.erase(it_fields++);
- list_description.erase(it_description++);
- list_max_values.erase(it_max_values++);
- list_min_values.erase(it_min_values++);
- list_max_convtrate.erase(it_max_convtrate++);
- list_min_convtrate.erase(it_min_convtrate++);
- list_is_save.erase(it_is_save++);
- list_collect_freq.erase(it_collect_freq++);
- list_var_type_id.erase(it_var_type_id++);
- list_readonly.erase(it_readonly++);
- list_is_dde.erase(it_is_dde++);
- list_address.erase(it_address++);
- list_unit.erase(it_unit++);
- list_reccurve.erase(it_reccurve++);
- list_register_num.erase(it_register_num++);
- list_child_id.erase(it_child_id++);
- list_var_item_id.erase(it_var_item_id++);
- list_rearm.erase(it_rearm++);
- list_offsets.erase(it_offsets++);
- list_funcid.erase(it_funcid++);
- list_data_len.erase(it_data_len++);
- list_coefficient.erase(it_coefficient++);
- list_realtimeflag.erase(it_realtimeflag++);
- list_rs232_cmd.erase(it_rs232_cmd++);
- list_rs232_type.erase(it_rs232_type++);
- list_rs232_index.erase(it_rs232_index++);
- list_str_reserved1.erase(it_str_reserved1++);
- list_str_reserved2.erase(it_str_reserved2++);
- list_str_reserved3.erase(it_str_reserved3++);
- list_str_reserved4.erase(it_str_reserved4++);
- list_str_reserved5.erase(it_str_reserved5++);
- list_str_reserved6.erase(it_str_reserved6++);
- list_str_reserved7.erase(it_str_reserved7++);
- list_str_reserved8.erase(it_str_reserved8++);
- list_str_reserved9.erase(it_str_reserved9++);
- list_str_reserved10.erase(it_str_reserved10++);
- list_int_reserved1.erase(it_int_reserved1++);
- list_int_reserved2.erase(it_int_reserved2++);
- list_int_reserved3.erase(it_int_reserved3++);
- list_int_reserved4.erase(it_int_reserved4++);
- list_int_reserved5.erase(it_int_reserved5++);
- list_int_reserved6.erase(it_int_reserved6++);
- list_int_reserved7.erase(it_int_reserved7++);
- list_int_reserved8.erase(it_int_reserved8++);
- list_int_reserved9.erase(it_int_reserved9++);
- list_int_reserved10.erase(it_int_reserved10++);
- list_bool_reserved1.erase(it_bool_reserved1++);
- list_bool_reserved2.erase(it_bool_reserved2++);
- list_bool_reserved3.erase(it_bool_reserved3++);
- list_bool_reserved4.erase(it_bool_reserved4++);
- list_bool_reserved5.erase(it_bool_reserved5++);
- list_bool_reserved6.erase(it_bool_reserved6++);
- list_bool_reserved7.erase(it_bool_reserved7++);
- list_bool_reserved8.erase(it_bool_reserved8++);
- list_bool_reserved9.erase(it_bool_reserved9++);
- list_bool_reserved10.erase(it_bool_reserved10++);
- }
- return nRet;
- }
- //修改变量
- INT CDBInterface::EditVarInfo(int nDeviceIndex, int nVarIndex, CHAR *pUid, int nVarID)
- {
- CBaseVar *pBaseVar = g_pDevicesManager->m_Devices[nDeviceIndex]->m_Vars[nVarIndex];
- //LOG4C((LOG_NOTICE, "EditVarInfo DeviceIndex = %d, VarIndex = %d", nDeviceIndex, nVarIndex));
- if( NULL == pBaseVar )
- {
- LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar is NULL"));
- }
- CHAR strSQLText[MAX_SQL_LENGTH * 2] = {0};
- list<string> list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit;
- list<string> list_lower_limit, list_normal_state, list_identify_time, list_redetect_time;
- list<string> list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description;
- list<string> list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save;
- list<string> list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit;
- list<string> list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets;
- list<string> list_funcid, list_data_len, list_coefficient, list_realtimeflag;
- list<string> list_rs232_cmd, list_rs232_type, list_rs232_index;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5;
- list<string> list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5;
- list<string> list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5;
- list<string> list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10;
- list<string>::iterator it_var_id, it_set_value, it_var_name, it_uid, it_upper_limit;
- list<string>::iterator it_lower_limit, it_normal_state, it_identify_time, it_redetect_time;
- list<string>::iterator it_normal_is_notice, it_warn_level, it_snmp_oid, it_fields, it_description;
- list<string>::iterator it_max_values, it_min_values, it_max_convtrate, it_min_convtrate, it_is_save;
- list<string>::iterator it_collect_freq, it_var_type_id, it_readonly, it_is_dde, it_address, it_unit;
- list<string>::iterator it_reccurve, it_register_num, it_child_id, it_var_item_id, it_rearm, it_offsets;
- list<string>::iterator it_funcid, it_data_len, it_coefficient, it_realtimeflag;
- list<string>::iterator it_rs232_cmd, it_rs232_type, it_rs232_index;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3, it_str_reserved4, it_str_reserved5;
- list<string>::iterator it_str_reserved6, it_str_reserved7, it_str_reserved8, it_str_reserved9, it_str_reserved10;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3, it_int_reserved4, it_int_reserved5;
- list<string>::iterator it_int_reserved6, it_int_reserved7, it_int_reserved8, it_int_reserved9, it_int_reserved10;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3, it_bool_reserved4, it_bool_reserved5;
- list<string>::iterator it_bool_reserved6, it_bool_reserved7, it_bool_reserved8, it_bool_reserved9, it_bool_reserved10;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select top 1 id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, [offsets], funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' and id = %d", pUid, nVarID);
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select id, setvalue, varname, uid, upperlimit, lowerlimit, normalstate, " \
- "identifytime, redetecttime, normalisnotice, warnlevel, snmpoid, fields, description, " \
- "maxvalues, minvalues, maxconvtrate, minconvtrate, issave, collectfrequence, " \
- "vartypeid, readonly, isdde, address, unit, reccurve, registernum, childid, " \
- "var_item_id, rearm, offsets, funcid, datalen, coefficient, realtimeflag, " \
- "rs232cmd, rs232type, rs232index, " \
- "strreserved1, strreserved2, strreserved3, strreserved4, strreserved5, " \
- "strreserved6, strreserved7, strreserved8, strreserved9, strreserved10, " \
- "intreserved1, intreserved2, intreserved3, intreserved4, intreserved5, " \
- "intreserved6, intreserved7, intreserved8, intreserved9, intreserved10, " \
- "boolreserved1, boolreserved2, boolreserved3, boolreserved4, boolreserved5, " \
- "boolreserved6, boolreserved7, boolreserved8, boolreserved9, boolreserved10 " \
- "from t_dev_variant where uid = \'%s\' and id = %d limit 1", pUid, nVarID);
- }
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList68(strSQLText
- ,list_var_id, list_set_value, list_var_name, list_uid, list_upper_limit
- ,list_lower_limit, list_normal_state, list_identify_time, list_redetect_time
- ,list_normal_is_notice, list_warn_level, list_snmp_oid, list_fields, list_description
- ,list_max_values, list_min_values, list_max_convtrate, list_min_convtrate, list_is_save
- ,list_collect_freq, list_var_type_id, list_readonly, list_is_dde, list_address, list_unit
- ,list_reccurve, list_register_num, list_child_id, list_var_item_id, list_rearm, list_offsets
- ,list_funcid, list_data_len, list_coefficient, list_realtimeflag
- ,list_rs232_cmd, list_rs232_type, list_rs232_index
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3, list_str_reserved4, list_str_reserved5
- ,list_str_reserved6, list_str_reserved7, list_str_reserved8, list_str_reserved9, list_str_reserved10
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3, list_int_reserved4, list_int_reserved5
- ,list_int_reserved6, list_int_reserved7, list_int_reserved8, list_int_reserved9, list_int_reserved10
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3, list_bool_reserved4, list_bool_reserved5
- ,list_bool_reserved6, list_bool_reserved7, list_bool_reserved8, list_bool_reserved9, list_bool_reserved10);
- if( 0 == list_var_id.size() || 0 == list_set_value.size() || 0 == list_var_name.size()
- || 0 == list_uid.size() || 0 == list_upper_limit.size() || 0 == list_lower_limit.size()
- || 0 == list_normal_state.size() || 0 == list_identify_time.size() || 0 == list_redetect_time.size()
- || 0 == list_normal_is_notice.size() || 0 == list_warn_level.size() || 0 == list_snmp_oid.size()
- || 0 == list_fields.size() || 0 == list_description.size() || 0 == list_max_values.size() || 0 == list_min_values.size()
- || 0 == list_max_convtrate.size() || 0 == list_min_convtrate.size() || 0 == list_is_save.size()
- || 0 == list_collect_freq.size() || 0 == list_var_type_id.size() || 0 == list_readonly.size()
- || 0 == list_is_dde.size() || 0 == list_address.size() || 0 == list_unit.size()
- || 0 == list_reccurve.size() || 0 == list_register_num.size() || 0 == list_child_id.size()
- || 0 == list_var_item_id.size() || 0 == list_rearm.size() || 0 == list_offsets.size()
- || 0 == list_funcid.size() || 0 == list_data_len.size() || 0 == list_coefficient.size()
- || 0 == list_realtimeflag.size() || 0 == list_rs232_cmd.size() || 0 == list_rs232_type.size() || 0 == list_rs232_index.size()
- || 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_str_reserved4.size() || 0 == list_str_reserved5.size() || 0 == list_str_reserved6.size()
- || 0 == list_str_reserved7.size() || 0 == list_str_reserved8.size() || 0 == list_str_reserved9.size()
- || 0 == list_str_reserved10.size() || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size()
- || 0 == list_int_reserved3.size() || 0 == list_int_reserved4.size() || 0 == list_int_reserved5.size()
- || 0 == list_int_reserved6.size() || 0 == list_int_reserved7.size() || 0 == list_int_reserved8.size()
- || 0 == list_int_reserved9.size() || 0 == list_int_reserved10.size() || 0 == list_bool_reserved1.size()
- || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size() || 0 == list_bool_reserved4.size()
- || 0 == list_bool_reserved5.size() || 0 == list_bool_reserved6.size() || 0 == list_bool_reserved7.size()
- || 0 == list_bool_reserved8.size() || 0 == list_bool_reserved9.size() || 0 == list_bool_reserved10.size()
- )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
- ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
- ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
- ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
- ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
- ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
- ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
- ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
- ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
- ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
- ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
- ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
- ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
- ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
- ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
- ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
- ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
- ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
- ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
- ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
- ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
- ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
- ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
- ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
- ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
- ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
- ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
- ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
- ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- int nVarID;
- CString strUid;
- nVarID = atoi((*it_var_id++).c_str());
- strUid = (*it_uid++).c_str();
- // 变量ID
- pBaseVar->m_nVarID = nVarID;
- // 设定值
- pBaseVar->m_strSetValue = (*it_set_value++).c_str();
-
- // 变量名称
- pBaseVar->m_strName = (*it_var_name++).c_str();
- // 变量Uid
- pBaseVar->m_strVarUID = strUid;
-
- int nUpperLimit = atoi((*it_upper_limit++).c_str());
- // 上限
- pBaseVar->m_nUpperLimit = nUpperLimit;
- //LOG4C((LOG_NOTICE, "EditVarInfo pBaseVar->m_nUpperLimit = %d, value = %d", pBaseVar->m_nUpperLimit, nUpperLimit));
- // 下限
- pBaseVar->m_nLowerLimit = atoi((*it_lower_limit++).c_str());
- // 正常状态
- pBaseVar->m_nNormalState = atoi((*it_normal_state++).c_str());
-
- // 辨识时间
- pBaseVar->m_nIdentifyTime = atoi((*it_identify_time++).c_str());
- // 重新检测时间
- pBaseVar->m_nReDetectTime = atoi((*it_redetect_time++).c_str());
- // 恢复正常是否触发远程报警
- CString strNormalIsNotice = (*it_normal_is_notice++).c_str();
- if( 0 == atoi(strNormalIsNotice) )
- {
- pBaseVar->m_bNormalIsNotice = FALSE;
- }
- else
- {
- pBaseVar->m_bNormalIsNotice = TRUE;
- }
- // 报警级别
- pBaseVar->m_nWaringLevel = atoi((*it_warn_level++).c_str());
- // Snmp对象OID
- pBaseVar->m_strSnmpoi = (*it_snmp_oid++).c_str();
- // Snmp对象域
- pBaseVar->m_strFields = (*it_fields++).c_str();
- // 变量描述
- pBaseVar->m_strDesc = (*it_description++).c_str();
- // 最大值
- pBaseVar->m_nMaxValues = atoi((*it_max_values++).c_str());
-
- // 最小值
- pBaseVar->m_nMinValues = atoi((*it_min_values++).c_str());
- // 最大比例
- pBaseVar->m_nMaxConvtRate = atoi((*it_max_convtrate++).c_str());
- // 最小比例
- pBaseVar->m_nMinConvtRate = atoi((*it_min_convtrate++).c_str());
- // 是否保存数值
- CString strIsSave = (*it_is_save++).c_str();
- if( 0 == atoi(strIsSave) )
- {
- pBaseVar->m_bIsSave = FALSE;
- }
- else
- {
- pBaseVar->m_bIsSave = TRUE;
- }
- // 采集频率
- pBaseVar->m_nCollectFreq = atoi((*it_collect_freq++).c_str());
- // 变量类型ID
- pBaseVar->m_nVarTypeID = atoi((*it_var_type_id++).c_str());
- // 读写权限
- CString strReadOnly = (*it_readonly++).c_str();
- if( 0 == atoi(strReadOnly) )
- {
- pBaseVar->m_bReadOnly = FALSE;
- }
- else
- {
- pBaseVar->m_bReadOnly = TRUE;
- }
- // 是否DDE
- CString strIsDDE = (*it_is_dde++).c_str();
- if( 0 == atoi(strIsDDE) )
- {
- pBaseVar->m_bIsDDE = FALSE;
- }
- else
- {
- pBaseVar->m_bIsDDE = TRUE;
- }
- // 寄存器起始地址
- pBaseVar->m_nRegStartAddr = atoi((*it_address++).c_str());
- // 单位
- pBaseVar->m_strUnit = (*it_unit++).c_str();
- // 是否记录实时曲线
- CString strRecCurve = (*it_reccurve++).c_str();
- if( 0 == atoi(strRecCurve) )
- {
- pBaseVar->m_bRecCurve = FALSE;
- }
- else
- {
- pBaseVar->m_bRecCurve = TRUE;
- }
- // 寄存器个数
- pBaseVar->m_iRegisterNum = atoi((*it_register_num++).c_str());
- // 变量子ID
- pBaseVar->m_iChildID = atoi((*it_child_id++).c_str());
-
- // t_dev_varint_item表的ID
- pBaseVar->m_nVarItemID = atoi((*it_var_item_id++).c_str());
- // 校正值
- pBaseVar->m_nRearm = atoi((*it_rearm++).c_str());
- // 偏移值
- pBaseVar->m_nOffset = atoi((*it_offsets++).c_str());
- // 功能码ID
- pBaseVar->m_iFuncID = atoi((*it_funcid++).c_str());
- // 数据长度
- pBaseVar->m_iDataLen = atoi((*it_data_len++).c_str());
- // 系数
- pBaseVar->m_dbCoefficient = atof((*it_coefficient++).c_str());
- // 是否实时采集
- CString strRealTimeFlag = (*it_realtimeflag++).c_str();
- if( 0 == atoi(strRealTimeFlag) )
- {
- pBaseVar->m_bRealTimeflag = FALSE;
- }
- else
- {
- pBaseVar->m_bRealTimeflag = TRUE;
- }
- // RS232命令
- pBaseVar->m_strRs232cmd = (*it_rs232_cmd++).c_str();
- // RS232类型
- pBaseVar->m_strRs232type = (*it_rs232_type++).c_str();
- // RS232索引
- pBaseVar->m_strRs232Index = (*it_rs232_index++).c_str();
- // 字符串预留1
- pBaseVar->m_strReserved1 = (*it_str_reserved1++).c_str();
- // 字符串预留2
- pBaseVar->m_strReserved2 = (*it_str_reserved2++).c_str();
- // 字符串预留3
- pBaseVar->m_strReserved3 = (*it_str_reserved3++).c_str();
- // 字符串预留4
- pBaseVar->m_strReserved4 = (*it_str_reserved4++).c_str();
- // 字符串预留5
- pBaseVar->m_strReserved5 = (*it_str_reserved5++).c_str();
- // 字符串预留6
- pBaseVar->m_strReserved6 = (*it_str_reserved6++).c_str();
- // 字符串预留7
- pBaseVar->m_strReserved7 = (*it_str_reserved7++).c_str();
- // 字符串预留8
- pBaseVar->m_strReserved8 = (*it_str_reserved8++).c_str();
- // 字符串预留9
- pBaseVar->m_strReserved9 = (*it_str_reserved9++).c_str();
- // 字符串预留10
- pBaseVar->m_strReserved10 = (*it_str_reserved10++).c_str();
-
- // 整形预留1
- pBaseVar->m_nReserved1 = atoi((*it_int_reserved1++).c_str());
- // 整形预留2
- pBaseVar->m_nReserved2 = atoi((*it_int_reserved2++).c_str());
- // 整形预留3
- pBaseVar->m_nReserved3 = atoi((*it_int_reserved3++).c_str());
- // 整形预留4
- pBaseVar->m_nReserved4 = atoi((*it_int_reserved4++).c_str());
- // 整形预留5
- pBaseVar->m_nReserved5 = atoi((*it_int_reserved5++).c_str());
- // 整形预留6
- pBaseVar->m_nReserved6 = atoi((*it_int_reserved6++).c_str());
- // 整形预留7
- pBaseVar->m_nReserved7 = atoi((*it_int_reserved7++).c_str());
- // 整形预留8
- pBaseVar->m_nReserved8 = atoi((*it_int_reserved8++).c_str());
- // 整形预留9
- pBaseVar->m_nReserved9 = atoi((*it_int_reserved9++).c_str());
- // 整形预留10
- pBaseVar->m_nReserved10 = atoi((*it_int_reserved10++).c_str());
- //布尔型预留1
- if( 0 == atoi((*it_bool_reserved1++).c_str()) )
- {
- pBaseVar->m_bReserved1 = false;
- }
- else
- {
- pBaseVar->m_bReserved1 = true;
- }
- //布尔型预留2
- if( 0 == atoi((*it_bool_reserved2++).c_str()) )
- {
- pBaseVar->m_bReserved2 = false;
- }
- else
- {
- pBaseVar->m_bReserved2 = true;
- }
- //布尔型预留3
- if( 0 == atoi((*it_bool_reserved3++).c_str()) )
- {
- pBaseVar->m_bReserved3 = false;
- }
- else
- {
- pBaseVar->m_bReserved3 = true;
- }
- //布尔型预留4
- if( 0 == atoi((*it_bool_reserved4++).c_str()) )
- {
- pBaseVar->m_bReserved4 = false;
- }
- else
- {
- pBaseVar->m_bReserved4 = true;
- }
- //布尔型预留5
- if( 0 == atoi((*it_bool_reserved5++).c_str()) )
- {
- pBaseVar->m_bReserved5 = false;
- }
- else
- {
- pBaseVar->m_bReserved5 = true;
- }
- //布尔型预留6
- if( 0 == atoi((*it_bool_reserved6++).c_str()) )
- {
- pBaseVar->m_bReserved6 = false;
- }
- else
- {
- pBaseVar->m_bReserved6 = true;
- }
- //布尔型预留7
- if( 0 == atoi((*it_bool_reserved7++).c_str()) )
- {
- pBaseVar->m_bReserved7 = false;
- }
- else
- {
- pBaseVar->m_bReserved7 = true;
- }
- //布尔型预留8
- if( 0 == atoi((*it_bool_reserved8++).c_str()) )
- {
- pBaseVar->m_bReserved8 = false;
- }
- else
- {
- pBaseVar->m_bReserved8 = true;
- }
- //布尔型预留9
- if( 0 == atoi((*it_bool_reserved9++).c_str()) )
- {
- pBaseVar->m_bReserved9 = false;
- }
- else
- {
- pBaseVar->m_bReserved9 = true;
- }
- //布尔型预留10
- if( 0 == atoi((*it_bool_reserved10++).c_str()) )
- {
- pBaseVar->m_bReserved10 = false;
- }
- else
- {
- pBaseVar->m_bReserved10 = true;
- }
- //pBaseVar->m_dbData = -1;
- //pBaseVar->m_nStatus = -1;
- //pBaseVar->m_strContent = "";
- //pBaseVar->m_nAlarmNumber = 0;
- pBaseVar->m_nStatusDescCount = CDBInterface::GetInstancePtr()->GetAlarmStatusDescList( (char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid,
- pBaseVar->m_nVarID,
- pBaseVar->m_listStatusID,
- pBaseVar->m_listStatusDesc );
- //LOG4C((LOG_NOTICE, "var desc = %s, StatusDescCount = %d", pBaseVar->m_strDesc, pBaseVar->m_nStatusDescCount));
- pBaseVar->m_bExistDatePlan = CDBInterface::GetInstancePtr()->IsExistDatePlan((char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid, pBaseVar->m_nVarID);
- if( pBaseVar->m_nVarItemID > 0 )
- {
- char szStartBit[MAX_ID] = {0};
- char szEndBit[MAX_ID] = {0};
- GetVarItemInfo((char *)(LPCTSTR)g_pDevicesManager->m_Devices[nDeviceIndex]->m_strUid,
- pBaseVar->m_nVarItemID,
- szStartBit,
- szEndBit);
- pBaseVar->m_nStartBit = atoi(szStartBit);
- pBaseVar->m_nEndBit = atoi(szEndBit);
- }
- }
- }
- for( it_var_id = list_var_id.begin(), it_set_value = list_set_value.begin(), it_var_name = list_var_name.begin()
- ,it_uid = list_uid.begin(), it_upper_limit = list_upper_limit.begin()
- ,it_lower_limit = list_lower_limit.begin(), it_normal_state = list_normal_state.begin()
- ,it_identify_time = list_identify_time.begin(),it_redetect_time = list_redetect_time.begin()
- ,it_normal_is_notice = list_normal_is_notice.begin(), it_warn_level = list_warn_level.begin()
- ,it_snmp_oid = list_snmp_oid.begin(), it_fields = list_fields.begin(), it_description = list_description.begin()
- ,it_max_values = list_max_values.begin(), it_min_values = list_min_values.begin()
- ,it_max_convtrate = list_max_convtrate.begin(), it_min_convtrate = list_min_convtrate.begin()
- ,it_is_save = list_is_save.begin(), it_collect_freq = list_collect_freq.begin(), it_var_type_id = list_var_type_id.begin()
- ,it_readonly = list_readonly.begin(), it_is_dde = list_is_dde.begin(), it_address = list_address.begin()
- ,it_unit = list_unit.begin(), it_reccurve = list_reccurve.begin(), it_register_num = list_register_num.begin()
- ,it_child_id = list_child_id.begin(), it_var_item_id = list_var_item_id.begin()
- ,it_rearm = list_rearm.begin(), it_offsets = list_offsets.begin(), it_funcid = list_funcid.begin()
- ,it_data_len = list_data_len.begin(), it_coefficient = list_coefficient.begin(), it_realtimeflag = list_realtimeflag.begin()
- ,it_rs232_cmd = list_rs232_cmd.begin(), it_rs232_type = list_rs232_type.begin(), it_rs232_index = list_rs232_index.begin()
- ,it_str_reserved1 = list_str_reserved1.begin(), it_str_reserved2 = list_str_reserved2.begin()
- ,it_str_reserved3 = list_str_reserved3.begin(), it_str_reserved4 = list_str_reserved4.begin()
- ,it_str_reserved5 = list_str_reserved5.begin(), it_str_reserved6 = list_str_reserved6.begin()
- ,it_str_reserved7 = list_str_reserved7.begin(), it_str_reserved8 = list_str_reserved8.begin()
- ,it_str_reserved9 = list_str_reserved9.begin(), it_str_reserved10 = list_str_reserved10.begin()
- ,it_int_reserved1 = list_int_reserved1.begin(), it_int_reserved2 = list_int_reserved2.begin()
- ,it_int_reserved3 = list_int_reserved3.begin(), it_int_reserved4 = list_int_reserved4.begin()
- ,it_int_reserved5 = list_int_reserved5.begin(), it_int_reserved6 = list_int_reserved6.begin()
- ,it_int_reserved7 = list_int_reserved7.begin(), it_int_reserved8 = list_int_reserved8.begin()
- ,it_int_reserved9 = list_int_reserved9.begin(), it_int_reserved10 = list_int_reserved10.begin()
- ,it_bool_reserved1 = list_bool_reserved1.begin(), it_bool_reserved2 = list_bool_reserved2.begin()
- ,it_bool_reserved3 = list_bool_reserved3.begin(), it_bool_reserved4 = list_bool_reserved4.begin()
- ,it_bool_reserved5 = list_bool_reserved5.begin(), it_bool_reserved6 = list_bool_reserved6.begin()
- ,it_bool_reserved7 = list_bool_reserved7.begin(), it_bool_reserved8 = list_bool_reserved8.begin()
- ,it_bool_reserved9 = list_bool_reserved9.begin(), it_bool_reserved10 = list_bool_reserved10.begin();
- it_var_id != list_var_id.end(), it_set_value != list_set_value.end(), it_var_name != list_var_name.end()
- ,it_uid != list_uid.end(), it_upper_limit != list_upper_limit.end()
- ,it_lower_limit != list_lower_limit.end(), it_normal_state != list_normal_state.end()
- ,it_identify_time != list_identify_time.end(),it_redetect_time != list_redetect_time.end()
- ,it_normal_is_notice != list_normal_is_notice.end(), it_warn_level != list_warn_level.end()
- ,it_snmp_oid != list_snmp_oid.end(), it_fields != list_fields.end(), it_description != list_description.end()
- ,it_max_values != list_max_values.end(), it_min_values != list_min_values.end()
- ,it_max_convtrate != list_max_convtrate.end(), it_min_convtrate != list_min_convtrate.end()
- ,it_is_save != list_is_save.end(), it_collect_freq != list_collect_freq.end(), it_var_type_id != list_var_type_id.end()
- ,it_readonly != list_readonly.end(), it_is_dde != list_is_dde.end(), it_address != list_address.end()
- ,it_unit != list_unit.end(), it_reccurve != list_reccurve.end(), it_register_num != list_register_num.end()
- ,it_child_id != list_child_id.end(), it_var_item_id != list_var_item_id.end()
- ,it_rearm != list_rearm.end(), it_offsets != list_offsets.end(), it_funcid != list_funcid.end()
- ,it_data_len != list_data_len.end(), it_coefficient != list_coefficient.end(), it_realtimeflag != list_realtimeflag.end()
- ,it_rs232_cmd != list_rs232_cmd.end(), it_rs232_type != list_rs232_type.end(), it_rs232_index != list_rs232_index.end()
- ,it_str_reserved1 != list_str_reserved1.end(), it_str_reserved2 != list_str_reserved2.end()
- ,it_str_reserved3 != list_str_reserved3.end(), it_str_reserved4 != list_str_reserved4.end()
- ,it_str_reserved5 != list_str_reserved5.end(), it_str_reserved6 != list_str_reserved6.end()
- ,it_str_reserved7 != list_str_reserved7.end(), it_str_reserved8 != list_str_reserved8.end()
- ,it_str_reserved9 != list_str_reserved9.end(), it_str_reserved10 != list_str_reserved10.end()
- ,it_int_reserved1 != list_int_reserved1.end(), it_int_reserved2 != list_int_reserved2.end()
- ,it_int_reserved3 != list_int_reserved3.end(), it_int_reserved4 != list_int_reserved4.end()
- ,it_int_reserved5 != list_int_reserved5.end(), it_int_reserved6 != list_int_reserved6.end()
- ,it_int_reserved7 != list_int_reserved7.end(), it_int_reserved8 != list_int_reserved8.end()
- ,it_int_reserved9 != list_int_reserved9.end(), it_int_reserved10 != list_int_reserved10.end()
- ,it_bool_reserved1 != list_bool_reserved1.end(), it_bool_reserved2 != list_bool_reserved2.end()
- ,it_bool_reserved3 != list_bool_reserved3.end(), it_bool_reserved4 != list_bool_reserved4.end()
- ,it_bool_reserved5 != list_bool_reserved5.end(), it_bool_reserved6 != list_bool_reserved6.end()
- ,it_bool_reserved7 != list_bool_reserved7.end(), it_bool_reserved8 != list_bool_reserved8.end()
- ,it_bool_reserved9 != list_bool_reserved9.end(), it_bool_reserved10 != list_bool_reserved10.end();
- )
- {
- list_var_id.erase(it_var_id++);
- list_set_value.erase(it_set_value++);
- list_var_name.erase(it_var_name++);
- list_uid.erase(it_uid++);
- list_upper_limit.erase(it_upper_limit++);
- list_lower_limit.erase(it_lower_limit++);
- list_normal_state.erase(it_normal_state++);
- list_identify_time.erase(it_identify_time++);
- list_redetect_time.erase(it_redetect_time++);
- list_normal_is_notice.erase(it_normal_is_notice++);
- list_warn_level.erase(it_warn_level++);
- list_snmp_oid.erase(it_snmp_oid++);
- list_fields.erase(it_fields++);
- list_description.erase(it_description++);
- list_max_values.erase(it_max_values++);
- list_min_values.erase(it_min_values++);
- list_max_convtrate.erase(it_max_convtrate++);
- list_min_convtrate.erase(it_min_convtrate++);
- list_is_save.erase(it_is_save++);
- list_collect_freq.erase(it_collect_freq++);
- list_var_type_id.erase(it_var_type_id++);
- list_readonly.erase(it_readonly++);
- list_is_dde.erase(it_is_dde++);
- list_address.erase(it_address++);
- list_unit.erase(it_unit++);
- list_reccurve.erase(it_reccurve++);
- list_register_num.erase(it_register_num++);
- list_child_id.erase(it_child_id++);
- list_var_item_id.erase(it_var_item_id++);
- list_rearm.erase(it_rearm++);
- list_offsets.erase(it_offsets++);
- list_funcid.erase(it_funcid++);
- list_data_len.erase(it_data_len++);
- list_coefficient.erase(it_coefficient++);
- list_realtimeflag.erase(it_realtimeflag++);
- list_rs232_cmd.erase(it_rs232_cmd++);
- list_rs232_type.erase(it_rs232_type++);
- list_rs232_index.erase(it_rs232_index++);
- list_str_reserved1.erase(it_str_reserved1++);
- list_str_reserved2.erase(it_str_reserved2++);
- list_str_reserved3.erase(it_str_reserved3++);
- list_str_reserved4.erase(it_str_reserved4++);
- list_str_reserved5.erase(it_str_reserved5++);
- list_str_reserved6.erase(it_str_reserved6++);
- list_str_reserved7.erase(it_str_reserved7++);
- list_str_reserved8.erase(it_str_reserved8++);
- list_str_reserved9.erase(it_str_reserved9++);
- list_str_reserved10.erase(it_str_reserved10++);
- list_int_reserved1.erase(it_int_reserved1++);
- list_int_reserved2.erase(it_int_reserved2++);
- list_int_reserved3.erase(it_int_reserved3++);
- list_int_reserved4.erase(it_int_reserved4++);
- list_int_reserved5.erase(it_int_reserved5++);
- list_int_reserved6.erase(it_int_reserved6++);
- list_int_reserved7.erase(it_int_reserved7++);
- list_int_reserved8.erase(it_int_reserved8++);
- list_int_reserved9.erase(it_int_reserved9++);
- list_int_reserved10.erase(it_int_reserved10++);
- list_bool_reserved1.erase(it_bool_reserved1++);
- list_bool_reserved2.erase(it_bool_reserved2++);
- list_bool_reserved3.erase(it_bool_reserved3++);
- list_bool_reserved4.erase(it_bool_reserved4++);
- list_bool_reserved5.erase(it_bool_reserved5++);
- list_bool_reserved6.erase(it_bool_reserved6++);
- list_bool_reserved7.erase(it_bool_reserved7++);
- list_bool_reserved8.erase(it_bool_reserved8++);
- list_bool_reserved9.erase(it_bool_reserved9++);
- list_bool_reserved10.erase(it_bool_reserved10++);
- }
- return nRet;
- }
- // 获取Summary资料
- INT CDBInterface::GetSummaryInfo(char *pUid, char *pVarDesc, char *pID)
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1;
- list<string>::iterator it;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select top 1 id from t_summary_log where varuid = \'%s\' and varname = \'%s\'", pUid, pVarDesc);
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select id from t_summary_log where varuid = \'%s\' and varname = \'%s\' limit 1", pUid, pVarDesc);
- }
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList1(strSQLText, list1);
- if( 0 == list1.size() )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- strcpy(pID, list1.begin()->c_str());
- }
- for( it = list1.begin(); it != list1.end(); )
- {
- list1.erase(it++);
- }
- return nRet;
- }
- // 获取报警状态ID对应的意义,用来组织报警内容
- INT CDBInterface::GetAlarmStatusDescList(char chDevUid[MAX_UID], int nVarID, list<string>& list1, list<string>& list2)
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "select statusid, statusdesc from t_var_status where " \
- "devuid = \'%s\' and varid = %d ",
- chDevUid, nVarID);
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList2(strSQLText, list1, list2);
- return nRet;
- }
- // 获取是否设置时间计划
- BOOL CDBInterface::IsExistDatePlan(char *pDevUid, int nVarID)
- {
- unsigned char szArray[7][24];
- memset(szArray, 0, sizeof(szArray) );
- CTime time = CTime::GetCurrentTime();
- // 获取当前时间
- int nWeekOfDay = time.GetDayOfWeek();
- if( nWeekOfDay == 1 )
- {
- nWeekOfDay = 6;
- }
- else
- {
- nWeekOfDay -= 2;
- }
- int nHours = time.GetHour();
- int nRet;
- nRet = GetDatePlan( PLAN_TYPE_EQUIP, pDevUid, nVarID, szArray );
- if( nRet > 0 )
- {
- for( int x=0; x<7; x++ )
- {
- for(int y=0; y<24; y++)
- {
- if( 15 == szArray[x][y] )
- {
- if( x == nWeekOfDay && y == nHours )
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- else
- {
- return true;
- }
- return false;
- }
- // 获取变量对应的bit位信息
- INT CDBInterface::GetVarItemInfo(char chDevUid[MAX_ID], int nVarItemID, CHAR *pStartBit, CHAR *pEndBit)
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- list<string> list1, list2;
- list<string>::iterator it1, it2;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
- "and id = %d", chDevUid, nVarItemID);
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
- "and id = %d", chDevUid, nVarItemID);
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- sprintf(strSQLText, "select top 1 startbit, endbit from t_dev_variant_item where uid = '%s' " \
- "and id = %d", chDevUid, nVarItemID);
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select startbit, endbit from t_dev_variant_item where uid = '%s' " \
- "and id = %d limit 1", chDevUid, nVarItemID);
- }
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList2(strSQLText, list1, list2);
- if( 0 == list1.size() || 0 == list2.size() )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- strcpy(pStartBit, list1.begin()->c_str());
- strcpy(pEndBit, list2.begin()->c_str());
- }
- for( it1 = list1.begin(), it2 = list2.begin(); it1 != list1.end(), it2 != list2.end(); )
- {
- list1.erase(it1++);
- list2.erase(it2++);
- }
- return nRet;
- }
- // 插入告警记录
- INT CDBInterface::InsertWarningRecord(
- char* pEquipDesc, // 设备描述
- char* pVarDesc, // 变量描述
- char* pHappentime, // 发生时间
- int iCurrStatus, // 当前状态
- double dbCurrValue, // 当前值
- char* pMemos, // 备注
- char* pContent // 报警内容
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- int iMaxID;
- CHAR chMaxID[MAX_ID] = {0};
- GetMaxID("t_waring_record", "id", chMaxID);
- if( 0 == atoi(chMaxID) )
- {
- iMaxID = 1;
- }
- else
- {
- iMaxID = atoi(chMaxID) + 1;
- }
- sprintf(strSQLText, "insert into t_waring_record(id, equip_desc," \
- "type_desc, happen_time, curr_status, curr_value, memos, warncontent) values(" \
- "\'%d\', \'%s\', \'%s\',\' %s\', \'%d\', %f, \'%s\', \'%s\')",
- iMaxID, pEquipDesc, pVarDesc, pHappentime, iCurrStatus, dbCurrValue, pMemos, pContent);
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //插入数据记录
- INT CDBInterface::InsertDataRecord(
- int &iMaxID,
- CHAR* pDevName, // 设备名称
- CHAR* pHappenTime, // 发生时间
- CHAR* pVarName, // 变量名称
- CHAR *pVarDesc, // 变量描述
- double dbCurrValue // 当前值
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- if( iMaxID==-1 )
- {
- CHAR chMaxID[MAX_ID] = {0};
- GetMaxID("t_data_rec", "id", chMaxID);
- if( 0 == atoi(chMaxID) )
- {
- iMaxID = 1;
- }
- else
- {
- iMaxID = atoi(chMaxID) + 1;
- }
- }
- //LOG4C((LOG_NOTICE, "***** InsertDataRecord: 行%d ", iMaxID ));
- sprintf(strSQLText, "insert into t_data_rec(id,devname, happentime,varname,vardesc,datavalue) values(" \
- "%d, \'%s\', \'%s\', \'%s\', \'%s\', %.1f)",
- iMaxID, pDevName, pHappenTime,pVarName, pVarDesc, dbCurrValue );
- //LOG4C((LOG_NOTICE, "***** InsertDataRecord: %s ", strSQLText ));
- iMaxID++;
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //插入Summary记录
- INT CDBInterface::InsertSummaryRecord(
- CHAR* pDevName, // 设备名称
- CHAR* pHappenTime, // 发生时间
- CHAR* pMemo, // 备注
- CHAR *pVarDesc, // 变量描述
- double dbCurrValue, // 当前值
- CHAR* pVarUid, // 设备Uid
- CHAR* pVarName // 变量名称
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- int iMaxID;
- CHAR chMaxID[MAX_ID] = {0};
- GetMaxID("t_summary_log", "id", chMaxID);
- if( 0 == atoi(chMaxID) )
- {
- iMaxID = 1;
- }
- else
- {
- iMaxID = atoi(chMaxID) + 1;
- }
- sprintf(strSQLText, "insert into t_summary_log(devname, happentime," \
- "memos, id, type_desc, curr_value, varuid, varname) values(" \
- "\'%s\', \'%s\', \'%s\', %d, \'%s\', %.1f, \'%s\', \'%s\')",
- pDevName, pHappenTime, pMemo, iMaxID, pVarDesc, dbCurrValue, pVarUid, pVarName);
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //更新Summary记录
- INT CDBInterface::EditSummaryRecord(
- CHAR *pDevName, // 设备名称
- CHAR *pHappenTime, // 发生时间
- CHAR* pMemo, // 备注
- int iID, // ID
- CHAR* pVarDesc, // 变量描述
- double dbCurrValue, // 当前值
- CHAR* pVarUid, // 设备Uid
- CHAR* pVarName // 变量名称
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "update t_summary_log set devname = \'%s\', happentime = \'%s\'," \
- "memos = \'%s\', type_desc = \'%s\', curr_value = %.1f, varuid = \'%s\', varname = \'%s\' where id = %d",
- pDevName, pHappenTime, pMemo, pVarDesc, dbCurrValue, pVarUid, pVarName, iID);
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //更新Summary记录
- INT CDBInterface::EditSummaryRecord(
- CHAR *pDevName, // 设备名称
- CHAR *pHappenTime, // 发生时间
- CHAR* pMemo, // 备注
- CHAR* pVarDesc, // 变量描述
- double dbCurrValue, // 当前值
- CHAR* pVarUid, // 设备Uid
- CHAR* pVarName // 变量名称
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "update t_summary_log set devname = \'%s\', happentime = \'%s\'," \
- "memos = \'%s\', type_desc = \'%s\', curr_value = %.1f, varuid = \'%s\', varname = \'%s\' where varname = \'%s\'",
- pDevName, pHappenTime, pMemo, pVarDesc, dbCurrValue, pVarUid, pVarName, pVarName);
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //插入Sms记录
- INT CDBInterface::InsertSmsRecord(
- CHAR* pTelNum, // 电话号码
- CHAR* pContactName, // 联系人姓名
- CHAR* pSendTime, // 发送时间
- CHAR* pContent, // 内容
- CHAR* pMemo // 备注
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "insert into t_sms_rec(telnum, contactname," \
- "sendtime, contents, memos) values(" \
- "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
- pTelNum, pContactName, pSendTime, pContent, pMemo);
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //插入Notice记录
- INT CDBInterface::InsertNoticeRecord(
- CHAR* pTelNum, // 电话号码
- CHAR* pContactName, // 联系人姓名
- CHAR* pSendTime, // 发送时间
- CHAR* pContent, // 内容
- CHAR* pMemo // 备注
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "insert into t_notice_rec(telnum, contactname," \
- "sendtime, contents, memos) values(" \
- "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
- pTelNum, pContactName, pSendTime, pContent, pMemo);
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- //插入Email记录
- INT CDBInterface::InsertEmailRecord(
- CHAR* pEmailAddr, // 电话号码
- CHAR* pContactName, // 联系人姓名
- CHAR* pSendTime, // 发送时间
- CHAR* pContent, // 内容
- CHAR* pMemo // 备注
- )
- {
- CHAR strSQLText[MAX_SQL_LENGTH + 1] = "";
- sprintf(strSQLText, "insert into t_email_rec(emailaddr, contactname," \
- "sendtime, contents, memos) values(" \
- "\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')",
- pEmailAddr, pContactName, pSendTime, pContent, pMemo);
- return CDBConnection::GetInstancePtr()->Execute(strSQLText);
- }
- INT CDBInterface::GetAllActionWithAlarm()
- {
- CHAR strSQLText[MAX_SQL_LENGTH * 2] = {0};
- list<string> list_str_doset, list_str_dostatus;
- list<string> list_int_alarmdata,list_int_resumedata;
- list<string> list_str_reserved1, list_str_reserved2, list_str_reserved3;
- list<string> list_int_reserved1, list_int_reserved2, list_int_reserved3;
- list<string> list_bool_reserved1, list_bool_reserved2, list_bool_reserved3;
- list<string> list_var1, list_var2, list_var3, list_var4, list_var5, list_var6, list_var7, list_var8, list_var9, list_var10;
- list<string> list_var11, list_var12, list_var13, list_var14, list_var15, list_var16, list_var17, list_var18, list_var19, list_var20;
- list<string> list_var21, list_var22, list_var23, list_var24, list_var25, list_var26, list_var27, list_var28, list_var29, list_var30;
- list<string>::iterator it_str_doset, it_str_dostatus;
- list<string>::iterator it_int_alarmdata, it_int_resumedata;
- list<string>::iterator it_str_reserved1, it_str_reserved2, it_str_reserved3;
- list<string>::iterator it_int_reserved1, it_int_reserved2, it_int_reserved3;
- list<string>::iterator it_bool_reserved1, it_bool_reserved2, it_bool_reserved3;
- list<string>::iterator it_var1, it_var2, it_var3, it_var4, it_var5, it_var6, it_var7, it_var8, it_var9, it_var10;
- list<string>::iterator it_var11, it_var12, it_var13, it_var14, it_var15, it_var16, it_var17, it_var18, it_var19, it_var20;
- list<string>::iterator it_var21, it_var22, it_var23, it_var24, it_var25, it_var26, it_var27, it_var28, it_var29, it_var30;
- if (!_stricmp(m_chDBType, "SQL SERVER"))
- {
- sprintf(strSQLText, "select doset_varname,dostatus_varname,alarmdata,resumedata, " \
- "strreserved1, strreserved2, strreserved3, " \
- "intreserved1, intreserved2, intreserved3, " \
- "boolreserved1, boolreserved2, boolreserved3, " \
- "varname1, varname2, varname3, varname4, varname5, varname6, varname7, varname8,varname9,varname10, " \
- "varname11, varname12, varname13, varname14, varname15, varname16, varname17, varname18,varname19,varname20, " \
- "varname21, varname22, varname23, varname24, varname25, varname26, varname27, varname28,varname29,varname30 " \
- "from t_actionwithalarm " );
- }
- else if (!_stricmp(m_chDBType, "ACCESS97"))
- {
- }
- else if (!_stricmp(m_chDBType, "ACCESS2000"))
- {
- }
- else if(!_stricmp(m_chDBType, "PGSQL"))
- {
- sprintf(strSQLText, "select doset_varname,dostatus_varname,alarmdata,resumedata, " \
- "strreserved1, strreserved2, strreserved3, " \
- "intreserved1, intreserved2, intreserved3, " \
- "boolreserved1, boolreserved2, boolreserved3, " \
- "varname1, varname2, varname3, varname4, varname5, varname6, varname7, varname8,varname9,varname10, " \
- "varname11, varname12, varname13, varname14, varname15, varname16, varname17, varname18,varname19,varname20, " \
- "varname21, varname22, varname23, varname24, varname25, varname26, varname27, varname28,varname29,varname30 " \
- "from t_actionwithalarm " );
- }
- //LOG4C((LOG_NOTICE, "%s", strSQLText));
- int nRet = CDBConnection::GetInstancePtr()->GetFieldValueList43(strSQLText
- ,list_str_doset,list_str_dostatus
- ,list_int_alarmdata,list_int_resumedata
- ,list_str_reserved1, list_str_reserved2, list_str_reserved3
- ,list_int_reserved1, list_int_reserved2, list_int_reserved3
- ,list_bool_reserved1, list_bool_reserved2, list_bool_reserved3
- ,list_var1, list_var2, list_var3, list_var4, list_var5, list_var6, list_var7, list_var8, list_var9, list_var10
- ,list_var11, list_var12, list_var13, list_var14, list_var15, list_var16, list_var17, list_var18, list_var19, list_var20
- ,list_var21, list_var22, list_var23, list_var24, list_var25, list_var26, list_var27, list_var28, list_var29, list_var30 );
- LOG4C((LOG_NOTICE, "list_str_doset.size = %d", list_str_doset.size()));
- if( 0 == list_str_reserved1.size() || 0 == list_str_reserved2.size() || 0 == list_str_reserved3.size()
- || 0 == list_int_reserved1.size() || 0 == list_int_reserved2.size() || 0 == list_int_reserved3.size()
- || 0 == list_bool_reserved1.size() || 0 == list_bool_reserved2.size() || 0 == list_bool_reserved3.size()
- )
- {
- return 0;
- }
- if( nRet != -1 )
- {
- for( it_str_doset=list_str_doset.begin(),it_str_dostatus=list_str_dostatus.begin()
- ,it_int_alarmdata=list_int_alarmdata.begin(),it_int_resumedata=list_int_resumedata.begin()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,it_str_reserved1=list_str_reserved1.begin();
- 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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,it_str_reserved1!=list_str_reserved1.end();
- )
- {
- CString str;
- int n=0;
-
- str = (*it_str_doset++).c_str(); str = str.Trim();
- for( int i=0;i<AWA_NUM_MAX;i++ )
- {
- if( g_AWA[i].sDoSet=="" || g_AWA[i].sDoSet==str )
- {
- n = i;
- break;
- }
- }
- bool bOK=true;
- if( !IsExistVar(str) ) bOK = false;
-
- g_AWA[n].sDoSet = str;
-
- str = (*it_str_dostatus++).c_str(); str = str.Trim();
- if( !IsExistVar(str) ) bOK = false;
- g_AWA[n].sDoStatus = str;
- str = (*it_int_alarmdata++).c_str(); str = str.Trim();
- g_AWA[n].nAlarmData = atoi( str );
- str = (*it_int_resumedata++).c_str(); str = str.Trim();
- g_AWA[n].nResumeData = atoi( str );
- str = (*it_var1++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var2++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var3++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var4++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var5++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var6++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var7++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var8++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var9++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var10++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- //11
- str = (*it_var11++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var12++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var13++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var14++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var15++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var16++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var17++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var18++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var19++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var20++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- //21
- str = (*it_var21++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var22++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var23++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var24++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var25++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var26++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var27++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var28++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var29++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_var30++).c_str(); str = str.Trim();
- if( str!="" && IsExistVar(str) ) g_AWA[n].SA.Add( str );
- str = (*it_str_reserved1++).c_str(); str = str.Trim();
- if( str!="" ) g_AWA[n].sPlanTime = str;
- if( !bOK )
- {
- g_AWA[n].sDoSet = "";
- g_AWA[n].SA.RemoveAll();
- }
- }
- }
- for( it_str_doset=list_str_doset.begin(),it_str_dostatus=list_str_dostatus.begin()
- ,it_int_alarmdata=list_int_alarmdata.begin(),it_int_resumedata=list_int_resumedata.begin()
- ,it_str_reserved1=list_str_reserved1.begin(),it_str_reserved2=list_str_reserved2.begin(),it_str_reserved3=list_str_reserved3.begin()
- ,it_int_reserved1=list_int_reserved1.begin(),it_int_reserved2=list_int_reserved2.begin(),it_int_reserved3=list_int_reserved3.begin()
- ,it_bool_reserved1=list_bool_reserved1.begin(),it_bool_reserved2=list_bool_reserved2.begin(),it_bool_reserved3=list_bool_reserved3.begin()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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();
- it_str_doset!=list_str_doset.end(),it_str_dostatus!=list_str_dostatus.end()
- ,it_int_alarmdata!=list_int_alarmdata.end(),it_int_resumedata!=list_int_resumedata.end()
- ,it_str_reserved1!=list_str_reserved1.end(),it_str_reserved2!=list_str_reserved2.end(),it_str_reserved3!=list_str_reserved3.end()
- ,it_int_reserved1!=list_int_reserved1.end(),it_int_reserved2!=list_int_reserved2.end(),it_int_reserved3!=list_int_reserved3.end()
- ,it_bool_reserved1!=list_bool_reserved1.end(),it_bool_reserved3!=list_bool_reserved2.end(),it_bool_reserved3!=list_bool_reserved3.end()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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()
- ,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();
- )
- {
- list_str_doset.erase( it_str_doset++ );
- list_str_dostatus.erase( it_str_dostatus++ );
- list_int_alarmdata.erase( it_int_alarmdata++ );
- list_int_resumedata.erase( it_int_resumedata++ );
- list_str_reserved1.erase( it_str_reserved1++ );
- list_str_reserved2.erase( it_str_reserved2++ );
- list_str_reserved3.erase( it_str_reserved3++ );
- list_int_reserved1.erase( it_int_reserved1++ );
- list_int_reserved2.erase( it_int_reserved2++ );
- list_int_reserved3.erase( it_int_reserved3++ );
- list_bool_reserved1.erase( it_bool_reserved1++ );
- list_bool_reserved2.erase( it_bool_reserved2++ );
- list_bool_reserved3.erase( it_bool_reserved3++ );
- list_var1.erase(it_var1++);
- list_var2.erase(it_var2++);
- list_var3.erase(it_var3++);
- list_var4.erase(it_var4++);
- list_var5.erase(it_var5++);
- list_var6.erase(it_var6++);
- list_var7.erase(it_var7++);
- list_var8.erase(it_var8++);
- list_var9.erase(it_var9++);
- list_var10.erase(it_var10++);
- list_var11.erase(it_var11++);
- list_var12.erase(it_var12++);
- list_var13.erase(it_var13++);
- list_var14.erase(it_var14++);
- list_var15.erase(it_var15++);
- list_var16.erase(it_var16++);
- list_var17.erase(it_var17++);
- list_var18.erase(it_var18++);
- list_var19.erase(it_var19++);
- list_var20.erase(it_var20++);
- list_var21.erase(it_var21++);
- list_var22.erase(it_var22++);
- list_var23.erase(it_var23++);
- list_var24.erase(it_var24++);
- list_var25.erase(it_var25++);
- list_var26.erase(it_var26++);
- list_var27.erase(it_var27++);
- list_var28.erase(it_var28++);
- list_var29.erase(it_var29++);
- list_var30.erase(it_var30++);
- }
- return nRet;
- }
- //得到不合法的变量问题
- CString CDBInterface::GetInvalidMessage( CString sVarName,int iInitValue,int iMinValue,int iMaxValue,int iLowerValue,int iUpperValue,int iNormalValue,int iWarningLevel )
- {
- CString sRet,s;
- if(sVarName=="" )
- {
- s = "变量名不能为空; ";
- sRet += s;
- }
- for( int i=0;i<sVarName.GetLength();i++ )
- {
- if( (sVarName[i]>='0'&&sVarName[i]<='9') || (sVarName[i]>='a'&&sVarName[i]<='z') || (sVarName[i]>='A'&&sVarName[i]<='Z') || (sVarName[i]=='_' ))
- {
- if( i==0 && ( (sVarName[i]>='0'&&sVarName[i]<='9') || (sVarName[i]=='_' ) ) )
- {
- s = "变量名有误,只能是字母开头; ";
- sRet += s;
- break;
- }
- }
- else
- {
- s = "变量名有误,含有非法字符; ";
- sRet += s;
- break;
- }
- }
- if( iMaxValue==0 )
- {
- s = "变量最大值不能为0; ";
- sRet += s;
- }
- if( iMinValue>iMaxValue )
- {
- s = "变量最小值不能大于变量最大值; ";
- sRet += s;
- }
-
- if( iInitValue<iMinValue || iInitValue>iMaxValue )
- {
- s = "变量初始值有误,不在最小最大值之间; ";
- sRet += s;
- }
- if( iLowerValue>iUpperValue )
- {
- s = "变量下限与上限设置有误; ";
- sRet += s;
- }
- if( iLowerValue==0 && iUpperValue==0 )
- {
- if( iNormalValue != iInitValue )
- {
- s = "状态变量的正常状态与初始值不相等; ";
- sRet += s;
- }
- }
- else
- {
- if( iInitValue<iLowerValue || iInitValue>iUpperValue )
- {
- s = "变量初始值有误,不在下限与上限之间; ";
- sRet += s;
- }
- }
- if( iWarningLevel==0 )
- {
- s = "变量的报警级别为0; ";
- sRet += s;
- }
- return sRet;
- }
- };
|