12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853 |
- // Dlg_ZuTaiAdd.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "Dlg_ZuTaiAdd.h"
- #include ".\dlg_zutaiadd.h"
- #include "MainFrm.h"
- #include "resource.h"
- #include "Shlwapi.h"
- #include "Network.h"
- #include "DrawObj.h"
- #include "SysLib.h"
- #include "IniFile.h"
- // CDlg_ZuTaiAdd 对话框
- typedef struct
- {
- CString sDevUid;//设备UID
- CString sVarName;//变量名称
- CString sVarDesc;//变量描述
- int nVarTypeID;//变量类型ID
- int nDataLen;//变量数据长度
- int nRegNum;//请求寄存器个数
- int nFuncCode;//功能码id
- int nRegStartAddr;//寄存器起始地址
- CString sRs232Cmd;// 串口232请求命令
- CString sRs232Type;// 串口232请求类型
- int nRs232Index;//索引
- int nIdentifyTime;//辨识时间
- int nRedetectTime;//重新检测等待时间
- BOOL bIsNormalAlarm;//恢复正常是否触发远程报警
- CString sSnmpOid;//snmp对象oid
- CString sFields;//SNMP域
- int nMaxValues;//最大值
- int nMinValues;//最小值
- int nMaxConvtRate;//最大转换比率
- int nMinConvtRate;//最小转换比率
- int nLowerLimit;//下限
- int nUpperLimit;//上限
- int nNormalState;//正常状态
- int nRearm;//校正值
- int nOffset;//偏移值
- CString sUnit;//单位
- int nCollectFreq;//采集频率
- float fCoef;//转换系数
- int nWaringLevel;//告警级别
- int nPurview;//读写权限
- BOOL bIsSave;//是否保存数值
- BOOL bRealtimeFlag;//是否实时采集数据
- BOOL bRecCurve;//是否记录实时曲线
- BOOL bIsDDE;//是否允许DDE访问
- int nRegChildID;//寄存器子ID ????????????????????????????
- int nVarItemID;//位信息ID
- int nDevID;//设备类型ID ??????????????????????
- CString sOnDesc;//开的描述
- CString sOffDesc;//关的描述
- CString sSetValue;//设定值
- int nStartBit;//变量起始BIT位
- int nEndBit;//变量终止BIT位
- CString sReserved1;//预留1_Str
- CString sReserved2;//预留2_Str
- CString sReserved3;//预留3_Str
- CString sReserved4;//预留4_Str
- CString sReserved5;//预留5_Str
- CString sReserved6;//预留6_Str
- CString sReserved7;//预留7_Str
- CString sReserved8;//预留8_Str
- CString sReserved9;//预留9_Str
- CString sReserved10;//预留10_Str
- int nReserved1;//预留1_Int
- int nReserved2;//预留2_Int
- int nReserved3;//预留3_Int
- int nReserved4;//预留4_Int
- int nReserved5;//预留5_Int
- int nReserved6;//预留6_Int
- int nReserved7;//预留7_Int
- int nReserved8;//预留8_Int
- int nReserved9;//预留9_Int
- int nReserved10;//预留10_Int
- BOOL bReserved1;//预留1_Bool
- BOOL bReserved2;//预留2_Bool
- BOOL bReserved3;//预留3_Bool
- BOOL bReserved4;//预留4_Bool
- BOOL bReserved5;//预留5_Bool
- BOOL bReserved6;//预留6_Bool
- BOOL bReserved7;//预留7_Bool
- BOOL bReserved8;//预留8_Bool
- BOOL bReserved9;//预留9_Bool
- BOOL bReserved10;//预留10_Bool
- int nVarStatusNum;//变量状态个数
- int nVarStatusID;//变量状态ID
- CString sVarStatusDesc;//变量状态描述
- //下面是临时的
- CString sVarNameTemp;//变量名称
- CString sVarDescTemp;//变量描述
- }VARLIST;//变量列表
- VARLIST g_VarList[1000];
- typedef struct
- {
- CString sMainType;//主类
- CString sSlaveType;//次类
- CString sDevBrand;//设备品牌
- CString sDevVersion;//设备型号
- //Parameters
- CString sDevUid;//设备UID
- CString sVarFileName;//变量文件名称
- CString sPicFileName;//界面文件名称
- int nCommunicationType;//通信类型
- int nCommunicationTreaty;//通信协议
- CString sDllName;//驱动名称
- CString sIniName;//配置文件
- int nBaudRate;//波特率
- int nDataBit;//数据位
- int nStopBit;//停止位
- int nCheckBit;//校验位
- int nNetPort;//通讯端口
- }DEV_VAR_PIC;//设备列表
- DEV_VAR_PIC g_DVP[1000];
- void g_FunInitVarList()
- {
- for( int i=0;i<1000;i++ )
- {
- if( g_VarList[i].sVarName=="" )
- break;
- g_VarList[i].sVarName = "";
- }
- }
- IMPLEMENT_DYNAMIC(CDlg_ZuTaiAdd, CDialog)
- CDlg_ZuTaiAdd::CDlg_ZuTaiAdd(CWnd* pParent /*=NULL*/)
- : CDialog(CDlg_ZuTaiAdd::IDD, pParent)
- , m_nDevAddr(1)
- , m_nCommPort(1)
- , m_nEdit_DevNumber(1)
- , m_nNetIP(0)
- , m_nNetPort(0)
- {
- m_nChooseItem = -1;
- m_bIsJubgeHaveBit = false;
- m_bHaveBit = false;
- m_bChangeVarToPic = false;
- m_bIsExistExcel = false;
- m_bReadResourceFinish = false;
- m_bIsUserZuTai = false;
- m_sFilePath = "C:\\WINDOWS\\system32\\drivers\\lastday.sys";
- }
- CDlg_ZuTaiAdd::~CDlg_ZuTaiAdd()
- {
- if( m_bIsUserZuTai )
- {
- CIniFile IniFile;
- IniFile.SetPath( m_sFilePath );
- int n=0;
- IniFile.GetVarInt(_T("ZT"),_T("USERTIME"),n );
- IniFile.SetVarInt(_T("ZT"),_T("USERTIME"),n+1 );
- }
- }
- void CDlg_ZuTaiAdd::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDT_DEV_ADDR, m_nDevAddr);
- DDX_Text(pDX, IDC_EDT_COMM_PORT, m_nCommPort);
- DDX_Text(pDX, IDC_EDT_DEVNUMBER, m_nEdit_DevNumber);
- DDX_IPAddress(pDX, IDC_IPADDR_DEV, m_nNetIP);
- DDX_Text(pDX, IDC_EDT_NET_PORT, m_nNetPort);
- DDX_Control(pDX, IDC_TREE_DEVICE_FOLDER, m_ctrlDevFolder);
- }
- BEGIN_MESSAGE_MAP(CDlg_ZuTaiAdd, CDialog)
- ON_WM_CTLCOLOR()
- ON_WM_ERASEBKGND()
- ON_BN_CLICKED(IDC_BTN_TEST, OnBnClickedBtnTest)
- ON_BN_CLICKED(IDC_BTN_CREAT, OnBnClickedBtnCreate)
- ON_BN_CLICKED(IDC_BTN_QUIT, OnBnClickedBtnQuit)
- ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_DEVICE_FOLDER, OnTvnSelchangedTreeDeviceFolder)
- ON_WM_CLOSE()
- END_MESSAGE_MAP()
- // CDlg_ZuTaiAdd 消息处理程序
- BOOL CDlg_ZuTaiAdd::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- if( !m_imagelistTree )
- {
- m_imagelistTree.Create(IDB_ADD_DEVICE, 16, 16, RGB(255,255,255));
- }
- m_ctrlDevFolder.SetImageList(&m_imagelistTree, TVSIL_NORMAL);
- GetDlgItem( IDC_IPADDR_DEV )->EnableWindow( false );
- GetDlgItem( IDC_EDT_NET_PORT )->EnableWindow( false );
- m_nNetIP = htonl(inet_addr("192.168.1.111"));
- m_nNetPort = 6000;
- //int nDevDriveID=0,nDevFactoryID=0,nDevTypeID=0;
- //GetDevIDFromUID( "5.32.131.1",nDevDriveID,nDevFactoryID,nDevTypeID );
- //CString sDevDriveName,sDevFactoryName,sDevTypeName;
- //CDBInterface::GetInstancePtr()->GetDriverName( nDevDriveID,sDevDriveName );
- //CDBInterface::GetInstancePtr()->GetFactoryName( nDevDriveID,nDevFactoryID,sDevFactoryName );
- //CDBInterface::GetInstancePtr()->GetDevicesName( nDevDriveID,nDevFactoryID,nDevTypeID,sDevTypeName );
- if( !m_ExcelMain.IsExistExcel() )
- {
- m_bIsExistExcel = false;
- return false;
- }
- else
- m_bIsExistExcel = true;
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- void CDlg_ZuTaiAdd::MyExpandTree(HTREEITEM hTreeItem)
- {
- if(!m_ctrlDevFolder.ItemHasChildren(hTreeItem))
- {
- return;
- }
- HTREEITEM hNextItem = m_ctrlDevFolder.GetChildItem(hTreeItem);
- while (hNextItem != NULL)
- {
- MyExpandTree(hNextItem);
- hNextItem = m_ctrlDevFolder.GetNextItem(hNextItem, TVGN_NEXT);
- }
- m_ctrlDevFolder.Expand(hTreeItem,TVE_EXPAND);
- }
- HBRUSH CDlg_ZuTaiAdd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: 在此更改 DC 的任何属性
- // TODO: 如果默认的不是所需画笔,则返回另一个画笔
- return hbr;
- }
- BOOL CDlg_ZuTaiAdd::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- return CDialog::OnEraseBkgnd(pDC);
- }
- void CDlg_ZuTaiAdd::OnBnClickedBtnTest()
- {
- // TODO: 在此添加控件通知处理程序代码
- }
- void CDlg_ZuTaiAdd::OnBnClickedBtnCreate()
- {
- UpdateData();
- if( m_nEdit_DevNumber<=0 )
- {
- MessageBox( "设备个数不能少于1!","提示" );
- return;
- }
- if( m_nChooseItem==-1 && m_sMainType=="" || m_sSlaveType=="" || m_sDevBrand=="" || m_sDevVersion=="" )
- {
- MessageBox( "先选择设备!","提示" );
- return;
- }
- CString sShow;
- sShow.Format( "%s %s %s %s",m_sMainType,m_sSlaveType,m_sDevBrand,m_sDevVersion );
- if( MessageBox( sShow,"提示",MB_YESNO )!=IDYES )
- return;
- m_bIsJubgeHaveBit = false;
- m_bHaveBit = false;
- m_bChangeVarToPic = false;
- CString strName,strUID;
- CString sDevName,sDevUid;
- int nDevIndex=0;
-
- strUID = g_DVP[m_nChooseItem].sDevUid.Left( g_DVP[m_nChooseItem].sDevUid.GetLength()-2 );
- strName.Format( "%s(%s)",m_sSlaveType,m_sDevBrand );
- bool bOpenVarFile=false;//是否已经从变量文件读取到变量信息
- int nDevAddr = m_nDevAddr;
- for( int iDevIndex=0;iDevIndex<m_nEdit_DevNumber;iDevIndex++ )
- {
- //uid
- CHAR szDevNum[MAX_ID + 1] = {0};
- CDBInterface::GetInstancePtr()->FindDevInfoByUID((char *)(LPCTSTR)strUID, szDevNum);
- sDevUid.Format("%s.%d", strUID, atoi(szDevNum) + 1);
- //name
- CDBInterface::GetInstancePtr()->FindDevNameByName( (char *)(LPCTSTR)strName,sDevName,nDevIndex );
- int nRet = AddDeviceToDB( sDevName,sDevUid,m_nCommPort,nDevAddr,m_nNetIP,m_nNetPort );
- if( nRet==1 )
- {
- //一。从变量文件读取变量信息 只操作一次
- if( !bOpenVarFile )
- {
- bOpenVarFile = true;
- OpenVarExcel( g_DVP[m_nChooseItem].sVarFileName );
- }
-
- //二。设备UID,变量名,变量描述, 位信息ID( 变量起始BIT位, 变量终止BIT )
- ChangeVarInfo( sDevUid,nDevIndex );
- //三。把变量写入数据库
- AddVarToDB();
- //四。生成画面文件
- ChangePicRelevanceVar( g_DVP[m_nChooseItem].sPicFileName,sDevName+".view" );//g_DVP[m_nChooseItem].sPicFileName,nDevIndex );
- if( !m_bChangeVarToPic )
- {
- MessageBox( "画面文件不对!","提示" );
- return;
- }
- nDevAddr++;
- }
- else if( nRet==100 )//IP与端口重复
- {
- MessageBox( "设备IP重复!","提示" );
- return;
- }
- else
- {
- iDevIndex--;
- nDevAddr++;
- }
- }
- MessageBox( "生成完成!","提示" );
- m_bIsUserZuTai = true;
- }
- void CDlg_ZuTaiAdd::ChangeVarInfo( CString sDevUid,int nDevIndex )
- {
- //是否已经判断过有没有BIT位信息
- if( !m_bIsJubgeHaveBit )
- {
- m_bIsJubgeHaveBit = true;
- if( !m_bHaveBit )
- {
- //判断有没有BIT位信息
- for( int i=0;i<1000;i++ )
- {
- if( g_VarList[i].sVarName=="" )
- break;
- if( g_VarList[i].nStartBit>0 || g_VarList[i].nEndBit>0 )
- {
- m_bHaveBit = true;
- break;
- }
- }
- }
- }
- //位信息ID( 变量起始BIT位, 变量终止BIT )
- if( m_bHaveBit )
- {
- int nBitID=0;
- for( int i=0;i<1000;i++ )
- {
- if( g_VarList[i].sVarName=="" )
- break;
- if( -1!=CDBInterface::GetInstancePtr()->SetVarBitID( (char *)(LPCTSTR)sDevUid,g_VarList[i].nStartBit,g_VarList[i].nEndBit,nBitID ) )
- {
- g_VarList[i].nVarItemID = nBitID;
- }
- }
- }
- for( int i=0;i<1000;i++ )
- {
- if( g_VarList[i].sVarName=="" )
- break;
- g_VarList[i].sDevUid = sDevUid;//设备UID
- g_VarList[i].sVarNameTemp.Format( "%s_%d",g_VarList[i].sVarName,nDevIndex );//变量名
-
- if( -1!=g_VarList[i].sVarDesc.Find( "*" ) )//变量描述
- {
- CString s;
- s.Format( "%d",nDevIndex );
- g_VarList[i].sVarDescTemp = g_VarList[i].sVarDesc;
- g_VarList[i].sVarDescTemp.Replace( "*",s );
- }
- else
- {
- g_VarList[i].sVarDescTemp.Format( "%s_%d",g_VarList[i].sVarDesc,nDevIndex );
- }
- }
- }
- void CDlg_ZuTaiAdd::OnBnClickedBtnQuit()
- {
- OnOK();
- }
- bool CDlg_ZuTaiAdd::OpenDevExcel()
- {
- if( !m_bIsExistExcel )
- return false;
- char Path[_MAX_PATH] = {0};
- strcat(Path, g_strDirectory);
- strcat(Path,"\\");
- strcat(Path, _LIBRARY);
- strcat(Path, "设备列表.xls");
- if( !PathFileExists( Path ) )
- return false;
- CString sMainType;//主类
- CString sSlaveType;//次类
- CString sDevBrand;//设备品牌
- CString sDevVersion;//设备型号
- CString sDevUid;//设备UID
- CString sVarFileName;//变量文件名称
- CString sPicFileName;//界面文件名称
- CString sCommunicationType;//通信类型
- CString sCommunicationTreaty;//通信协议
- CString sDllName;//驱动名称
- CString sIniName;//配置文件
- CString sBaudRate;//波特率
- CString sDataBit;//数据位
- CString sStopBit;//停止位
- CString sCheckBit;//校验位
- CString sNetPort;//通讯端口
- int nIndex=0;
- int i,j,k=0;
-
- CString strText;
- if(m_ExcelMain.IsFileExist(Path,FALSE))
- {
- if( !m_ExcelMain.Open(Path) )
- return false;
- if( !m_ExcelMain.OpenSheet("View") )
- return false;
- m_ExcelMain.AutoRange();
- //size_t maxRows = ExcelMain.GetColS();
- //size_t maxCols = ExcelMain.GetRowS();
- int INDEX=0;
- bool bBreak=false;
- for(i=2;i<99999;i++)
- {
- if( m_ExcelMain.IsRowEmpty( i ) )
- break;
- for(j=1;j<30;j++)
- {
- strText=m_ExcelMain.GetItemText(i,j);
- if( j==1 )
- {
- if( strText!="" )
- {
- sMainType = strText;
- sSlaveType = "";
- sDevBrand = "";
- }
- }
- else if( j==2 )
- {
- if( strText!="" )
- {
- sSlaveType = strText;
- sDevBrand = "";
- }
- }
- else if( j==3 )
- {
- if( strText!="" )
- {
- sDevBrand = strText;
- }
- }
- else if( j==4 )
- {
- sDevVersion = strText;
- }
- else if( j==5 )
- {
- sDevUid = strText;
- }
- else if( j==6 )
- {
- sVarFileName = strText;
- }
- else if( j==7 )
- {
- sPicFileName = strText;
- }
- else if( j==8 )
- {
- sCommunicationType = strText;
- }
- else if( j==9 )
- {
- sCommunicationTreaty = strText;
- }
- else if( j==10 )
- {
- sDllName = strText;
- }
- else if( j==11 )
- {
- sIniName = strText;
- }
- else if( j==12 )
- {
- sBaudRate = strText;
- }
- else if( j==13 )
- {
- sDataBit = strText;
- }
- else if( j==14 )
- {
- sStopBit = strText;
- }
- else if( j==15 )
- {
- sCheckBit = strText;
- }
- else if( j==17 )//16是IP
- {
- sNetPort = strText;
- }
- }
- g_DVP[nIndex].sMainType = sMainType;
- g_DVP[nIndex].sSlaveType = sSlaveType;
- g_DVP[nIndex].sDevBrand = sDevBrand;
- g_DVP[nIndex].sDevVersion = sDevVersion;
- g_DVP[nIndex].sDevUid = sDevUid;
- g_DVP[nIndex].sVarFileName = sVarFileName;
- g_DVP[nIndex].sPicFileName = sPicFileName;
- g_DVP[nIndex].nCommunicationType = sCommunicationType=="串口"?0:1;
- g_DVP[nIndex].nCommunicationTreaty = GetCommunicationTreaty( sCommunicationTreaty );
- g_DVP[nIndex].sDllName = sDllName;
- g_DVP[nIndex].sIniName = sIniName;
- g_DVP[nIndex].nBaudRate = GetBaudRateIndex( sBaudRate );
- g_DVP[nIndex].nDataBit = GetCommDataBitIndex( sDataBit );
- if( sStopBit=="1" )
- g_DVP[nIndex].nStopBit = 0;
- else if( sStopBit=="1.5" )
- g_DVP[nIndex].nStopBit = 1;
- else if( sStopBit=="2" )
- g_DVP[nIndex].nStopBit = 2;
- g_DVP[nIndex].nCheckBit = atoi( sCheckBit );
- g_DVP[nIndex].nNetPort = atoi( sNetPort );
- nIndex++;
- if( nIndex==1000 )
- break;
- }
-
- }
- else
- {
- return false;
- }
- return true;
- }
- bool CDlg_ZuTaiAdd::OpenVarExcel( CString sPath )
- {
- char Path[_MAX_PATH] = {0};
- strcat(Path, g_strDirectory);
- strcat(Path,"\\");
- strcat(Path, _LIBRARY);
- strcat(Path, "变量\\");
- strcat(Path, sPath);
- if( !PathFileExists( Path ) )
- return false;
- g_FunInitVarList();//初始化变量列表
- int nIndex=0;
- int i,j,k=0;
-
- CString strText;
- if(m_ExcelMain.IsFileExist(Path,FALSE))
- {
- m_ExcelMain.Open(Path);//ExcelMain.GetAppPath()+"\\Test.xls");
- m_ExcelMain.OpenSheet("View");
- m_ExcelMain.AutoRange();
- int INDEX=0;
- bool bBreak=false;
- for(i=2;i<99999;i++)
- {
- if( m_ExcelMain.IsRowEmpty( i ) )
- break;
- for(j=2;j<80;j++)
- {
- strText=m_ExcelMain.GetItemText(i,j);
- if( j==2 )
- g_VarList[nIndex].sDevUid = strText;
- else if( j==3 )
- g_VarList[nIndex].sVarName = strText;
- else if( j==4 )
- g_VarList[nIndex].sVarDesc = strText;
- else if( j==5 )
- g_VarList[nIndex].nVarTypeID = atoi( strText );
- else if( j==6 )
- g_VarList[nIndex].nDataLen = atoi( strText );
- else if( j==7 )
- g_VarList[nIndex].nRegNum = atoi( strText );
- else if( j==8 )
- g_VarList[nIndex].nFuncCode = atoi( strText );
- else if( j==9 )
- g_VarList[nIndex].nRegStartAddr = atoi( strText );
- else if( j==10 )
- g_VarList[nIndex].sRs232Cmd = strText;
- else if( j==11 )
- g_VarList[nIndex].sRs232Type = strText;
- else if( j==12 )
- g_VarList[nIndex].nRs232Index = atoi( strText );
- else if( j==13 )
- g_VarList[nIndex].nIdentifyTime = atoi( strText );
- else if( j==14 )
- g_VarList[nIndex].nRedetectTime = atoi( strText );
- else if( j==15 )
- g_VarList[nIndex].bIsNormalAlarm = atoi( strText );
- else if( j==16 )
- g_VarList[nIndex].sSnmpOid = strText;
- else if( j==17 )
- g_VarList[nIndex].sFields = strText;
- else if( j==18 )
- g_VarList[nIndex].nMaxValues = atoi( strText );
- else if( j==19 )
- g_VarList[nIndex].nMinValues = atoi( strText );
- else if( j==20 )
- g_VarList[nIndex].nMaxConvtRate = atoi( strText );
- else if( j==21 )
- g_VarList[nIndex].nMinValues = atoi( strText );
- else if( j==22 )
- g_VarList[nIndex].nLowerLimit = atoi( strText );
- else if( j==23 )
- g_VarList[nIndex].nUpperLimit = atoi( strText );
- else if( j==24 )
- g_VarList[nIndex].nNormalState = atoi( strText );
- else if( j==25 )
- g_VarList[nIndex].nRearm = atoi( strText );
- else if( j==26 )
- g_VarList[nIndex].nOffset = atoi( strText );
- else if( j==27 )
- g_VarList[nIndex].sUnit = strText;
- else if( j==28 )
- g_VarList[nIndex].nCollectFreq = atoi( strText );
- else if( j==29 )
- g_VarList[nIndex].fCoef = atof( strText );
- else if( j==30 )
- g_VarList[nIndex].nWaringLevel = atoi( strText );
- else if( j==31 )
- g_VarList[nIndex].nPurview = atoi( strText );
- else if( j==32 )
- g_VarList[nIndex].bIsSave = atoi( strText );
- else if( j==33 )
- g_VarList[nIndex].bRealtimeFlag = atoi( strText );
- else if( j==34 )
- g_VarList[nIndex].bRecCurve = atoi( strText );
- else if( j==35 )
- g_VarList[nIndex].bIsDDE = atoi( strText );
- else if( j==36 )
- g_VarList[nIndex].nRegChildID = atoi( strText );
- else if( j==37 )
- g_VarList[nIndex].nVarItemID = atoi( strText );
- else if( j==38 )
- g_VarList[nIndex].nDevID = atoi( strText );
- else if( j==39 )
- g_VarList[nIndex].sOnDesc = strText;
- else if( j==40 )
- g_VarList[nIndex].sOffDesc = strText;
- else if( j==41 )
- g_VarList[nIndex].sSetValue = strText;
- else if( j==42 )
- g_VarList[nIndex].nStartBit = atoi( strText );
- else if( j==43 )
- g_VarList[nIndex].nEndBit = atoi( strText );
- else if( j==44 )
- g_VarList[nIndex].sReserved1 = strText;
- else if( j==45 )
- g_VarList[nIndex].sReserved2 = strText;
- else if( j==46 )
- g_VarList[nIndex].sReserved3 = strText;
- else if( j==47 )
- g_VarList[nIndex].sReserved4 = strText;
- else if( j==48 )
- g_VarList[nIndex].sReserved5 = strText;
- else if( j==49 )
- g_VarList[nIndex].sReserved6 = strText;
- else if( j==50 )
- g_VarList[nIndex].sReserved7 = strText;
- else if( j==51 )
- g_VarList[nIndex].sReserved8 = strText;
- else if( j==52 )
- g_VarList[nIndex].sReserved9 = strText;
- else if( j==53 )
- g_VarList[nIndex].sReserved10 = strText;
- else if( j==54 )
- g_VarList[nIndex].nReserved1 = atoi( strText );
- else if( j==55 )
- g_VarList[nIndex].nReserved2 = atoi( strText );
- else if( j==56 )
- g_VarList[nIndex].nReserved3 = atoi( strText );
- else if( j==57 )
- g_VarList[nIndex].nReserved4 = atoi( strText );
- else if( j==58 )
- g_VarList[nIndex].nReserved5 = atoi( strText );
- else if( j==59 )
- g_VarList[nIndex].nReserved6 = atoi( strText );
- else if( j==60 )
- g_VarList[nIndex].nReserved7 = atoi( strText );
- else if( j==61 )
- g_VarList[nIndex].nReserved8 = atoi( strText );
- else if( j==62 )
- g_VarList[nIndex].nReserved9 = atoi( strText );
- else if( j==63 )
- g_VarList[nIndex].nReserved10 = atoi( strText );
- else if( j==64 )
- g_VarList[nIndex].bReserved1 = atoi( strText );
- else if( j==65 )
- g_VarList[nIndex].bReserved2 = atoi( strText );
- else if( j==66 )
- g_VarList[nIndex].bReserved3 = atoi( strText );
- else if( j==67 )
- g_VarList[nIndex].bReserved4 = atoi( strText );
- else if( j==68 )
- g_VarList[nIndex].bReserved5 = atoi( strText );
- else if( j==69 )
- g_VarList[nIndex].bReserved6 = atoi( strText );
- else if( j==70 )
- g_VarList[nIndex].bReserved7 = atoi( strText );
- else if( j==71 )
- g_VarList[nIndex].bReserved8 = atoi( strText );
- else if( j==72 )
- g_VarList[nIndex].bReserved9 = atoi( strText );
- else if( j==73 )
- g_VarList[nIndex].bReserved10 = atoi( strText );
- else if( j==74 )
- g_VarList[nIndex].nVarStatusNum = atoi( strText );
- else if( j==75 )
- g_VarList[nIndex].nVarStatusID = atoi( strText );
- else if( j==76 )
- g_VarList[nIndex].sVarStatusDesc = strText;
- }
- nIndex++;
- if( nIndex==1000 )
- break;
- }
- }
- else
- {
- return false;
- }
- return true;
- }
- int CDlg_ZuTaiAdd::GetCommunicationTreaty( CString sData )
- {
- int nRet=-1;
- if( sData=="Modbus Rtu" )
- nRet = 0;
- if( sData=="Modbus Ascii" )
- nRet = 1;
- if( sData=="Modbus Tcp" )
- nRet = 2;
- if( sData=="Snmp" )
- nRet = 3;
- if( sData=="RS232" )
- nRet = 4;
- return nRet;
- }
- int CDlg_ZuTaiAdd::GetBaudRateIndex( CString sBaudRate )
- {
- int nRet=-1;
- if( sBaudRate=="1200" )
- nRet = 0;
- if( sBaudRate=="2400" )
- nRet = 1;
- if( sBaudRate=="4800" )
- nRet = 2;
- if( sBaudRate=="9600" )
- nRet = 3;
- if( sBaudRate=="14400" )
- nRet = 4;
- if( sBaudRate=="19200" )
- nRet = 5;
- if( sBaudRate=="38400" )
- nRet = 6;
- if( sBaudRate=="57600" )
- nRet = 7;
- if( sBaudRate=="115200" )
- nRet = 8;
- if( sBaudRate=="128000" )
- nRet = 9;
- if( sBaudRate=="256000" )
- nRet = 10;
- return nRet;
- }
- // 获取实际数据位
- int CDlg_ZuTaiAdd::GetCommDataBitIndex( CString sDataBit )
- {
- int nRet=-1;
- if( sDataBit=="7" )
- nRet = 0;
- if( sDataBit=="8" )
- nRet = 1;
- return nRet;
- }
- void CDlg_ZuTaiAdd::ListDeviceTypes( HTREEITEM hItemParent )
- {
- HTREEITEM hItemDrive=NULL, hItemFactory=NULL, hItemType=NULL;
- CString sMainType,sMainTypeOld="1";//主类
- CString sSlaveType,sSlaveTypeOld="1";//次类
- CString sDevBrand,sDevBrandOld="1";//设备品牌
- CString sDevVersion;//设备型号
- for( int i=0;i<1000;i++ )
- {
- if( g_DVP[i].sMainType=="" )
- break;
- sMainType = g_DVP[i].sMainType;
- if( sMainType!="" && sMainType!=sMainTypeOld )
- {
- sMainTypeOld = sMainType;
- hItemDrive = m_ctrlDevFolder.InsertItem( sMainType, 0, 1, hItemParent );
- sSlaveTypeOld = "";
- sDevBrandOld = "";
- hItemFactory = NULL;
- hItemType = NULL;
- }
- sSlaveType = g_DVP[i].sSlaveType;
- if( sSlaveType!="" && sSlaveType!=sSlaveTypeOld && hItemDrive )
- {
- sSlaveTypeOld = sSlaveType;
- hItemFactory = m_ctrlDevFolder.InsertItem( sSlaveType, 0, 1, hItemDrive );
- sDevBrandOld = "";
- hItemType = NULL;
- }
- sDevBrand = g_DVP[i].sDevBrand;
- if( sDevBrand!="" && sDevBrand!=sDevBrandOld && hItemFactory )
- {
- sDevBrandOld = sDevBrand;
- hItemType = m_ctrlDevFolder.InsertItem( sDevBrand, 0, 1, hItemFactory );
- }
- sDevVersion = g_DVP[i].sDevVersion;
- if( sDevVersion!="" && hItemType )
- m_ctrlDevFolder.InsertItem( sDevVersion, 2, 2, hItemType );
- }
- }
- int CDlg_ZuTaiAdd::SelChangedTreeDeviceFolder(HTREEITEM hItemSelect)
- {
- int nRet = -1;
- CString strSelect = m_ctrlDevFolder.GetItemText( hItemSelect );
- CString strDevDriveName = "", strDevFactoryName = "", strDevTypeName = "";
-
- HTREEITEM hItemParent = m_ctrlDevFolder.GetParentItem( hItemSelect );
- HTREEITEM hItemChild = m_ctrlDevFolder.GetChildItem( hItemSelect );
- if( hItemParent && hItemChild == NULL )
- {
- m_sDevVersion = m_ctrlDevFolder.GetItemText( hItemSelect );
- m_sDevBrand = m_ctrlDevFolder.GetItemText( hItemParent );
- hItemParent = m_ctrlDevFolder.GetParentItem( hItemParent );
- if( hItemParent != NULL )
- {
- m_sSlaveType = m_ctrlDevFolder.GetItemText( hItemParent );
- hItemParent = m_ctrlDevFolder.GetParentItem( hItemParent );
- if( hItemParent != NULL )
- {
- m_sMainType = m_ctrlDevFolder.GetItemText( hItemParent );
- }
- }
- for( int i=0;i<1000;i++ )
- {
- if( m_sMainType==g_DVP[i].sMainType && m_sSlaveType==g_DVP[i].sSlaveType && m_sDevBrand==g_DVP[i].sDevBrand && m_sDevVersion==g_DVP[i].sDevVersion )
- {
- nRet = i;
- break;
- }
- }
- if( g_DVP[nRet].nCommunicationType==0 )
- {
- GetDlgItem( IDC_EDT_DEVNUMBER )->EnableWindow( true );
- GetDlgItem( IDC_EDT_DEV_ADDR )->EnableWindow( true );
- GetDlgItem( IDC_EDT_COMM_PORT )->EnableWindow( true );
- GetDlgItem( IDC_IPADDR_DEV )->EnableWindow( false );
- GetDlgItem( IDC_EDT_NET_PORT )->EnableWindow( false );
- }
- else
- {
- m_nEdit_DevNumber = 1;
- UpdateData(false);
- GetDlgItem( IDC_EDT_DEVNUMBER )->EnableWindow( false );
- GetDlgItem( IDC_EDT_DEV_ADDR )->EnableWindow( false );
- GetDlgItem( IDC_EDT_COMM_PORT )->EnableWindow( false );
- GetDlgItem( IDC_IPADDR_DEV )->EnableWindow( true );
- GetDlgItem( IDC_EDT_NET_PORT )->EnableWindow( true );
- }
- }
- return nRet;
- }
- void CDlg_ZuTaiAdd::OnTvnSelchangedTreeDeviceFolder(NMHDR *pNMHDR, LRESULT *pResult)
- {
- LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
- // TODO: 在此添加控件通知处理程序代码
- HTREEITEM hItemSelect = pNMTreeView->itemNew.hItem;
- m_nChooseItem = SelChangedTreeDeviceFolder( hItemSelect );
- *pResult = 0;
- }
- void CDlg_ZuTaiAdd::GetDevIDFromUID( CString sDevUid,int &nDevDriveID, int &nDevFactoryID, int &nDevTypeID )
- {
- int n1=-1,n2=-1,n3=-1,n4=-1;
- n1 = sDevUid.Find( "." );
- n2 = sDevUid.Find( ".",n1+1 );
- n3 = sDevUid.Find( ".",n2+1 );
- nDevDriveID = atoi( sDevUid.Mid( 0,n1 ) );
- nDevFactoryID = atoi( sDevUid.Mid( n1+1,n2-n1-1 ) );
- nDevTypeID = atoi( sDevUid.Mid( n2+1,n3-n2-1 ) );
- }
- int CDlg_ZuTaiAdd::AddDeviceToDB( CString sDevName,CString sDevUid,int nCommPort,int nDevAddr,DWORD nNetIP,int nNetPort )
- {
- int nDevDriveID=0,nDevFactoryID=0,nDevTypeID=0;
- GetDevIDFromUID( sDevUid,nDevDriveID,nDevFactoryID,nDevTypeID );
- CString sDevDriveName,sDevFactoryName,sDevTypeName;
- CDBInterface::GetInstancePtr()->GetDriverName( nDevDriveID,sDevDriveName );
- CDBInterface::GetInstancePtr()->GetFactoryName( nDevDriveID,nDevFactoryID,sDevFactoryName );
- CDBInterface::GetInstancePtr()->GetDevicesName( nDevDriveID,nDevFactoryID,nDevTypeID,sDevTypeName );
- // 加入该设备的参数
- CChannel* pChannel = NULL;
- //
- CDevice* pDev = new CDevice();
- pDev->Create();
- CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- int nIP;
- nIP = htonl(nNetIP);
- // 通信协议(例:Modbus rtu, Modbus Ascii, Modbus tcp)
- pDev->m_nProtocolType = g_DVP[m_nChooseItem].nCommunicationTreaty;
- // 动态库名称
- pDev->m_strProtocolName = g_DVP[m_nChooseItem].sDllName;
- // 配置文件名称
- pDev->m_strIniName = g_DVP[m_nChooseItem].sIniName;
- // 是否为采集模块
- pDev->m_nIsCollectDev = 0;
- // 是否启用设备
- pDev->m_bUsed = 1;
- // 设备UID
- pDev->m_strUID = sDevUid;
- // 设备名称
- pDev->m_strName = sDevName;
- // 设备类型
- pDev->m_strType = sDevTypeName;//GetDevTypeID(sDevUid); ****
- // 设备地址
- pDev->m_Address = (BYTE)nDevAddr;
- // 驱动名称(例:UPS、空调)
- pDev->m_strDevDriveName = sDevDriveName;//m_wndDevice.m_strDevDriveName; ****
- // 设备厂家名称
- pDev->m_strDevFactoryName = sDevFactoryName;//m_wndDevice.m_strDevFactoryName; ****
- // 通讯超时
- pDev->m_nTimeout = 10000;
- // 网络设备IP
- pDev->m_strDevIP = inet_ntoa(*(struct in_addr *)&nIP);
- // 网络设备通信端口
- pDev->m_nNetPort = nNetPort;
-
- // 预留1 设备所属区域
- pDev->m_strReserved1 = "";
- // 预留2
- pDev->m_strReserved2 = "";
- // 预留3
- pDev->m_strReserved3 = "";
- // 预留4
- pDev->m_strReserved4 = "";
- // 预留5
- pDev->m_strReserved5 = "";
- // 预留6
- pDev->m_strReserved6 = "";
- // 预留7
- pDev->m_strReserved7 = "";
- // 预留8
- pDev->m_strReserved8 = "";
- // 预留9
- pDev->m_strReserved9 = "";
- // 预留10
- pDev->m_strReserved10 = "";
- // 预留1
- pDev->m_nReserved1 = 0;
- // 预留2
- pDev->m_nReserved2 = 0;
- // 预留3
- pDev->m_nReserved3 = 0;
- // 预留4
- pDev->m_nReserved4 = 0;
- // 预留5
- pDev->m_nReserved5 = 0;
- // 预留6
- pDev->m_nReserved6 = 0;
- // 预留7
- pDev->m_nReserved7 = 0;
- // 预留8
- pDev->m_nReserved8 = 0;
- // 预留9
- pDev->m_nReserved9 = 0;
- // 预留10
- pDev->m_nReserved10 = 0;
- // 预留1
- pDev->m_bReserved1 = 0;
- // 预留2
- pDev->m_bReserved2 = 0;
- // 预留3
- pDev->m_bReserved3 = 0;
- // 预留4
- pDev->m_bReserved4 = 0;
- // 预留5
- pDev->m_bReserved5 = 0;
- // 预留6
- pDev->m_bReserved6 = 0;
- // 预留7
- pDev->m_bReserved7 = 0;
- // 预留8
- pDev->m_bReserved8 = 0;
- // 预留9
- pDev->m_bReserved9 = 0;
- // 预留10
- pDev->m_bReserved10 = 0;
- CString strCommPort;
- int nIndex, nFreeIndex;
- int nChannelSize;
- int nDeviceSize;
- CHAR szMaxID[MAX_ID + 1] = {0};
- CHAR szDevTypeID[MAX_ID + 1] = {0};
- // 获取t_dev_property设备属性表字段ID的最大值
- int nRet = CDBInterface::GetInstancePtr()->GetMaxID("t_dev_property", "id", szMaxID);
- if( -1 == nRet )
- {
- pDev->Destroy();
- delete pDev;
- return -1;
- }
- int nID;
- if( atoi(szMaxID) > 0 )
- {
- nID = atoi(szMaxID) + 1;
- }
- else if( atoi(szMaxID) == 0 )
- {
- nID = 1;
- }
- //// 获取设备类型ID
- //CDBInterface::GetInstancePtr()->GetDevTypeID((char *)(LPCTSTR)m_wndDevice.m_strDevTypeName, szDevTypeID);
- //if( !m_wndComport.m_strDevName.Compare("") )
- //{
- // MessageBox(g_strDevNumCannotBlank,g_strTip,MB_ICONWARNING);
- // pDev->Destroy();
- // delete pDev;
- // return 0;
- //}
- //检查合法值
- CHAR szDevName[MAX_DESC + 1] = {0};
- CHAR szDevUID[MAX_DESC + 1] = {0};
- nRet = CDBInterface::GetInstancePtr()->GetDevName((char *)(LPCTSTR)sDevUid, szDevName);
- if( nRet > 0 )
- {
- //MessageBox(g_strDevUidExist,g_strTip,MB_ICONWARNING);
- pDev->Destroy();
- delete pDev;
- return 0;
- }
-
- nRet = CDBInterface::GetInstancePtr()->GetDevUID( (char *)(LPCTSTR)sDevName, (char *)(LPCTSTR)sDevUid );
- if( nRet > 0 )
- {
- //MessageBox(g_strDevNameExist,g_strTip,MB_ICONWARNING);
- pDev->Destroy();
- delete pDev;
- return 0;
- }
- // 串口设备
- if( g_DVP[m_nChooseItem].nCommunicationType == 0 )
- {
- strCommPort.Format("COM%d", nCommPort);
- nIndex = pMainFrm->GetIndexSerialTreeItem(strCommPort);//得到COM的序列号
- if( nIndex == -1 )
- {
- nFreeIndex = pMainFrm->GetFreeSerialTreeItem();
- CChannel* pComport = new CChannel();
- //CSerial* pComport = new CSerial();
- // 串行端口
- pComport->m_strPort = strCommPort.Trim();
- // 串行端口地址
- pComport->m_nAddr = nDevAddr;
- // 波特率
- pComport->m_nBaudRate = g_DVP[m_nChooseItem].nBaudRate; // 1200;2400;4800;9600;14400;19200;38400;57600;115200;128000;256000
- // 数据位
- pComport->m_nByteSize = g_DVP[m_nChooseItem].nDataBit; // 0-1=7,8
- // 检验位
- pComport->m_nParity = g_DVP[m_nChooseItem].nCheckBit; // 0-4=no,odd,even,mark
- // 停止位
- pComport->m_nStopBits = g_DVP[m_nChooseItem].nStopBit; // 0-2=1,1.5,2
-
- pDevicesManager->m_channels.Add(pComport);
- nChannelSize = pDevicesManager->m_channels.GetSize();
- pChannel = pDevicesManager->m_channels[nChannelSize - 1];
- pChannel->m_strName = strCommPort.Trim();
- pChannel->m_nCommunicateType = g_DVP[m_nChooseItem].nCommunicationType;
- nDeviceSize = pChannel->m_Devices.GetSize();
- pMainFrm->m_hSerialGroup[nFreeIndex] = pMainFrm->m_wndTree.InsertItem(strCommPort, 4, 4, pMainFrm->m_hSerial);
- pMainFrm->m_hSerialDev[nFreeIndex][nDeviceSize] = pMainFrm->m_wndTree.InsertItem( sDevName, 4, 4, pMainFrm->m_hSerialGroup[nFreeIndex] );
- }
- else
- {
- nChannelSize = pDevicesManager->m_channels.GetSize();
- for( int i = 0; i < nChannelSize; i++ )
- {
- CChannel* pCommPort =pDevicesManager->m_channels[i];
- if( ( !pCommPort->m_strPort.Compare(strCommPort) ) && pCommPort->m_Devices.GetSize() > 0 )
- {
- nDeviceSize = pCommPort->m_Devices.GetSize();
- for( int j = 0; j < nDeviceSize; j++ )
- {
- if( (int)pCommPort->m_Devices[j]->m_Address == nDevAddr )
- {
- //MessageBox(g_strSerialPortInUse,g_strTip,MB_ICONWARNING);
- pDev->Destroy();
- delete pDev;
- return 0;
- }
- }
- }
- }
- for( int i = 0; i < nChannelSize; i++ )
- {
- CChannel* pCommPort = pDevicesManager->m_channels[i];
- if( !pCommPort->m_strPort.Compare(strCommPort) )
- {
- nDeviceSize = pCommPort->m_Devices.GetSize();
- pChannel = pDevicesManager->m_channels[i];
- break;
- }
- }
- pMainFrm->m_hSerialDev[nIndex][nDeviceSize] = pMainFrm->m_wndTree.InsertItem( sDevName, 4, 4, pMainFrm->m_hSerialGroup[nIndex]);
- }
- if( pChannel != NULL )
- {
- pDev->m_pChannel = pChannel;
- pChannel->m_Devices.Add(pDev);
- }
- }
- else// 网络设备
- {
- int nChannelIndex;
- // 得到m_channels数组中网络设备的索引,有且只有一个
- nIndex = pMainFrm->GetIndexNetworkTreeItem( sDevName );
- if( nIndex == -1 )
- {
- nChannelIndex = pMainFrm->GetNetworkChannelIndex();
- if( nChannelIndex == -1 )
- {
- CNetwork *pNetwork = new CNetwork();
- pNetwork->m_strName = g_strNetDev;
- pDevicesManager->m_channels.Add(pNetwork);
- nChannelIndex = pDevicesManager->m_channels.GetSize() - 1;
- }
- else
- {
- pChannel = pDevicesManager->m_channels[nChannelIndex];
- for( int j = 0; j < pChannel->m_Devices.GetSize(); j ++ )
- {
- if( !(pChannel->m_Devices[j]->m_strDevIP.Compare(inet_ntoa(*(struct in_addr *)&nIP))) &&
- (pChannel->m_Devices[j]->m_nNetPort == nNetPort ) )
- {
- //MessageBox(g_strIPConflict, g_strTip, MB_ICONWARNING);
- pDev->Destroy();
- delete pDev;
- return 100;
- }
- }
- }
-
- pChannel = pDevicesManager->m_channels[nChannelIndex];
- pChannel->m_nCommunicateType = g_DVP[m_nChooseItem].nCommunicationType;
- nDeviceSize = pChannel->m_Devices.GetSize();
- nFreeIndex = pMainFrm->GetFreeNetworkTreeItem();
- pMainFrm->m_hNetworkDev[nFreeIndex] = pMainFrm->m_wndTree.InsertItem( sDevName, 2, 2, pMainFrm->m_hEtherNet);
- pDev->m_pChannel = pChannel;
- pChannel->m_Devices.Add(pDev);
- }
- else
- {
- //MessageBox(g_strDevNameExist,g_strTip,MB_ICONWARNING);
- pDev->Destroy();
- delete pDev;
- return 0;
- }
- }
- // 插入设备信息
- CDBInterface::GetInstancePtr()->InsertDevInfo(
- nID,
- (char *)(LPCTSTR)sDevUid,
- nCommPort,
- nDevAddr,
- (char *)(LPCTSTR)sDevName,
- nDevTypeID,
- g_DVP[m_nChooseItem].nBaudRate,
- g_DVP[m_nChooseItem].nDataBit,
- g_DVP[m_nChooseItem].nStopBit,
- g_DVP[m_nChooseItem].nCheckBit,
- 0,
- inet_ntoa( *(struct in_addr *)&nIP ),
- nNetPort,
- g_DVP[m_nChooseItem].nCommunicationType,
- 0,
- g_DVP[m_nChooseItem].nCommunicationTreaty,
- 10000,//通信超时
- 1,
- (char *)(LPCTSTR)g_DVP[m_nChooseItem].sDllName,
- (char *)(LPCTSTR)g_DVP[m_nChooseItem].sIniName,
- "",//设备所属区域 //(char *)(LPCTSTR)m_wndDevice.m_strReserved1,
- "",//(char *)(LPCTSTR)m_wndDevice.m_strReserved2,
- "",//(char *)(LPCTSTR)m_wndDevice.m_strReserved3,
- "",//(char *)(LPCTSTR)m_wndDevice.m_strReserved4,
- "",//(char *)(LPCTSTR)m_wndDevice.m_strReserved5,
- "",//(char *)(LPCTSTR)m_wndComport.m_strReserved6,
- "",//(char *)(LPCTSTR)m_wndComport.m_strReserved7,
- "",//(char *)(LPCTSTR)m_wndComport.m_strReserved8,
- "",//(char *)(LPCTSTR)m_wndComport.m_strReserved9,
- "",//(char *)(LPCTSTR)m_wndComport.m_strReserved10,
- 0,//m_wndDevice.m_nReserved1,
- 0,//m_wndDevice.m_nReserved2,
- 0,//m_wndDevice.m_nReserved3,
- 0,//m_wndDevice.m_nReserved4,
- 0,//m_wndDevice.m_nReserved5,
- 0,//m_wndComport.m_nReserved6,
- 0,//m_wndComport.m_nReserved7,
- 0,//m_wndComport.m_nReserved8,
- 0,//m_wndComport.m_nReserved9,
- 0,//m_wndComport.m_nReserved10,
- 0,//(int)m_wndDevice.m_bReserved1,
- 0,//(int)m_wndDevice.m_bReserved2,
- 0,//(int)m_wndDevice.m_bReserved3,
- 0,//(int)m_wndDevice.m_bReserved4,
- 0,//(int)m_wndDevice.m_bReserved5,
- 0,//(int)m_wndComport.m_bReserved6,
- 0,//(int)m_wndComport.m_bReserved7,
- 0,//(int)m_wndComport.m_bReserved8,
- 0,//(int)m_wndComport.m_bReserved9,
- 0//(int)m_wndComport.m_bReserved10
- );
- return 1;
- }
- int CDlg_ZuTaiAdd::AddVarToDB( )
- {
- int INDEX=0;
- CHAR szMaxID[MAX_ID + 1] = {0};
- for( int i=0;i<1000;i++ )
- {
- INDEX = i;
- if( g_VarList[INDEX].sVarName=="" )
- break;
- CDBInterface::GetInstancePtr()->GetMaxID("t_dev_variant", "id", szMaxID);
- int nID;
- if( atoi(szMaxID) > 0 )
- {
- nID = atoi(szMaxID) + 1;
- }
- else if( atoi(szMaxID) == 0 )
- {
- nID = 1;
- }
- // 插入变量信息
- CDBInterface::GetInstancePtr()->InsertVarInfo(
- nID,
- g_VarList[INDEX].nDevID, //(char *)(LPCTSTR)
- (char *)(LPCTSTR)g_VarList[INDEX].sVarNameTemp,
- (char *)(LPCTSTR)g_VarList[INDEX].sVarDescTemp,
- g_VarList[INDEX].nVarTypeID,
- g_VarList[INDEX].nMinValues,
- g_VarList[INDEX].nMaxValues,
- g_VarList[INDEX].nMaxConvtRate,
- g_VarList[INDEX].nMinConvtRate,
- g_VarList[INDEX].nCollectFreq,
- g_VarList[INDEX].bIsDDE,
- g_VarList[INDEX].nRegStartAddr,
- g_VarList[INDEX].nWaringLevel,
- (char *)(LPCTSTR)g_VarList[INDEX].sSetValue,
- (char *)(LPCTSTR)g_VarList[INDEX].sUnit,
- (char *)(LPCTSTR)g_VarList[INDEX].sDevUid,
- "",//(char *)(LPCTSTR)g_VarList[INDEX].sRelatepage,
- g_VarList[INDEX].bRecCurve,
- g_VarList[INDEX].nRegNum,
- (char *)(LPCTSTR)g_VarList[INDEX].sOnDesc,
- (char *)(LPCTSTR)g_VarList[INDEX].sOffDesc,
- g_VarList[INDEX].nUpperLimit,
- g_VarList[INDEX].nLowerLimit,
- 0,//g_VarList[INDEX].nChildid,
- g_VarList[INDEX].nVarItemID,
- g_VarList[INDEX].nNormalState,
- (char *)(LPCTSTR)g_VarList[INDEX].sFields,
- (char *)(LPCTSTR)g_VarList[INDEX].sSnmpOid,
- g_VarList[INDEX].nRearm,
- g_VarList[INDEX].nOffset,
- g_VarList[INDEX].nFuncCode,
- g_VarList[INDEX].nDataLen,
- g_VarList[INDEX].fCoef,
- g_VarList[INDEX].bRealtimeFlag,
- g_VarList[INDEX].bIsSave,
- (char *)(LPCTSTR)g_VarList[INDEX].sRs232Cmd,
- (char *)(LPCTSTR)g_VarList[INDEX].sRs232Type,
- g_VarList[INDEX].nRs232Index,
- g_VarList[INDEX].nIdentifyTime,
- g_VarList[INDEX].nRedetectTime,
- g_VarList[INDEX].bIsNormalAlarm,
- g_VarList[INDEX].nPurview,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved1,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved2,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved3,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved4,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved5,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved6,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved7,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved8,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved9,
- (char *)(LPCTSTR)g_VarList[INDEX].sReserved10,
- g_VarList[INDEX].nReserved1,
- g_VarList[INDEX].nReserved2,
- g_VarList[INDEX].nReserved3,
- g_VarList[INDEX].nReserved4,
- g_VarList[INDEX].nReserved5,
- g_VarList[INDEX].nReserved6,
- g_VarList[INDEX].nReserved7,
- g_VarList[INDEX].nReserved8,
- g_VarList[INDEX].nReserved9,
- g_VarList[INDEX].nReserved10,
- g_VarList[INDEX].bReserved1,
- g_VarList[INDEX].bReserved2,
- g_VarList[INDEX].bReserved3,
- g_VarList[INDEX].bReserved4,
- g_VarList[INDEX].bReserved5,
- g_VarList[INDEX].bReserved6,
- g_VarList[INDEX].bReserved7,
- g_VarList[INDEX].bReserved8,
- g_VarList[INDEX].bReserved9,
- g_VarList[INDEX].bReserved10
- );
- // 插入变量状态表
- int n = g_VarList[INDEX].sVarStatusDesc.Find( "," );
- if( n!=-1 )
- {
- g_VarList[INDEX].sVarStatusDesc.Delete( n );
- }
- if( g_VarList[INDEX].nVarStatusID!=0 )
- CDBInterface::GetInstancePtr()->SetVarStatusID( (char *)(LPCTSTR)g_VarList[INDEX].sDevUid,nID,g_VarList[INDEX].nVarStatusID,(char *)(LPCTSTR)g_VarList[INDEX].sVarStatusDesc );
- else if(g_VarList[INDEX].sVarStatusDesc!="0" )
- CDBInterface::GetInstancePtr()->SetVarStatusID( (char *)(LPCTSTR)g_VarList[INDEX].sDevUid,nID,g_VarList[INDEX].nVarStatusID,(char *)(LPCTSTR)g_VarList[INDEX].sVarStatusDesc );
- CAnalog *pAnalog = new CAnalog();
- int nTemp = -1;
- // 变量ID
- pAnalog->m_nVarID = nID;
- // 是否需要用户设置
- if( g_VarList[INDEX].bReserved3 == 1 )
- {
- pAnalog->m_bReserved3 = TRUE;
- }
- else if( g_VarList[INDEX].bReserved3 == 0 )
- {
- pAnalog->m_bReserved3 = FALSE;
- }
- // 变量UID
- pAnalog->m_strVarUID = g_VarList[INDEX].sDevUid;
- // 变量名称
- pAnalog->m_strName = g_VarList[INDEX].sVarNameTemp;
- // 变量描述
- pAnalog->m_strDesc = g_VarList[INDEX].sVarDescTemp;
- // 变量类型ID
- pAnalog->m_nVarTypeID = g_VarList[INDEX].nVarTypeID;
- // 变量数据长度
- pAnalog->m_nDataLen = g_VarList[INDEX].nDataLen;
- // 开的描述
- pAnalog->m_strOnDesc = g_VarList[INDEX].sOnDesc;
- // 关的描述
- pAnalog->m_strOffDesc = g_VarList[INDEX].sOffDesc;
- // 最大值
- pAnalog->m_nMaxValues = g_VarList[INDEX].nMaxValues;
- // 最小值
- pAnalog->m_nMinValues = g_VarList[INDEX].nMinValues;
- // 最大转换比率
- pAnalog->m_nMaxConvtRate = g_VarList[INDEX].nMaxConvtRate;
- // 最小转换比率
- pAnalog->m_nMinConvtRate = g_VarList[INDEX].nMinConvtRate;
-
- // 下限
- pAnalog->m_nLowerLimit = g_VarList[INDEX].nLowerLimit;
- // 上限
- pAnalog->m_nUpperLimit = g_VarList[INDEX].nUpperLimit;
- // 正常状态
- pAnalog->m_nNormalState = g_VarList[INDEX].nNormalState;
- // 设定值
- pAnalog->m_strSetValue = g_VarList[INDEX].sSetValue;
- // 校正值
- pAnalog->m_nRearm = g_VarList[INDEX].nRearm;
- // 偏移量
- pAnalog->m_nOffset = g_VarList[INDEX].nOffset;
- // 单位
- pAnalog->m_strUnit = g_VarList[INDEX].sUnit;
- // 采集频率
- pAnalog->m_nCollectFreq = g_VarList[INDEX].nCollectFreq;
- // 转换系数
- pAnalog->m_fCoef = g_VarList[INDEX].fCoef;
- // 告警级别
- pAnalog->m_nWaringLevel = g_VarList[INDEX].nWaringLevel;
- // 读写权限
- pAnalog->m_nPurview = g_VarList[INDEX].nPurview;
- // 是否保存数值
- pAnalog->m_bIsSave = g_VarList[INDEX].bIsSave;
- // 是否实时采集数据
- pAnalog->m_bRealtimeFlag = g_VarList[INDEX].bRealtimeFlag;
- // 是否记录实时曲线
- pAnalog->m_bRecCurve = g_VarList[INDEX].bRecCurve;
- // 是否允许DDE访问
- pAnalog->m_bIsDDE = g_VarList[INDEX].bIsDDE;
- // 请求寄存器个数
- pAnalog->m_nRegNum = g_VarList[INDEX].nRegNum;
- // 功能码id
- pAnalog->m_nFuncCode = g_VarList[INDEX].nFuncCode;
- // 寄存器子id
- pAnalog->m_nVarChildID = 0;//g_VarList[INDEX].nvar
- // 位信息id
- pAnalog->m_nVarItemID = g_VarList[INDEX].nVarItemID;
- // SNMP对象oid
- pAnalog->m_strSnmpOid = g_VarList[INDEX].sSnmpOid;
-
- // SNMP域
- pAnalog->m_strFields = g_VarList[INDEX].sFields;
- // 设备类型ID
- pAnalog->m_nDevID = g_VarList[INDEX].nDevID;
- // 起始地址
- pAnalog->m_nRegStartAddr = g_VarList[INDEX].nRegStartAddr;
- // Rs232请求命令
- pAnalog->m_strRs232Cmd = g_VarList[INDEX].sRs232Cmd;
- // Rs232请求类型
- pAnalog->m_strRs232Type = g_VarList[INDEX].sRs232Type;
- // Rs232数据索引
- pAnalog->m_nRs232Index = g_VarList[INDEX].nRs232Index;
- // 辨別時間
- pAnalog->m_nIdentifyTime = g_VarList[INDEX].nIdentifyTime;
- // 重新檢測時間
- pAnalog->m_nRedetectTime = g_VarList[INDEX].nRedetectTime;
- //// 起始BIT位
- //if( m_nStartBit >= 0 && m_nStartBit <= 64 )
- //{
- // pAnalog->m_nStartBit = m_nStartBit;
- //}
- //// 终止BIT位
- //if( m_nEndBit >= 0 && m_nEndBit <= 64 )
- //{
- // pAnalog->m_nEndBit = m_nEndBit;
- //}
- pAnalog->m_strReserved1 = g_VarList[INDEX].sReserved1;
- pAnalog->m_strReserved2 = "";
- pAnalog->m_strReserved3 = "";
- pAnalog->m_strReserved4 = "";
- pAnalog->m_strReserved5 = "";
- pAnalog->m_strReserved6 = "";
- pAnalog->m_strReserved7 = "";
- pAnalog->m_strReserved8 = "";
- pAnalog->m_strReserved9 = "";
- pAnalog->m_strReserved10 = "";
- pAnalog->m_nReserved1 = g_VarList[INDEX].nReserved1;
- pAnalog->m_nReserved2 = g_VarList[INDEX].nReserved2;
- pAnalog->m_nReserved3 = g_VarList[INDEX].nReserved3;
- pAnalog->m_nReserved4 = 0;
- pAnalog->m_nReserved5 = 0;
- pAnalog->m_nReserved6 = 0;
- pAnalog->m_nReserved7 = 0;
- pAnalog->m_nReserved8 = 0;
- pAnalog->m_nReserved9 = 0;
- pAnalog->m_nReserved10 = 0;
- if( g_VarList[INDEX].bReserved1 == 1 )
- {
- pAnalog->m_bReserved1 = TRUE;
- }
- else if( g_VarList[INDEX].bReserved1 == 0 )
- {
- pAnalog->m_bReserved1 = FALSE;
- }
- if( g_VarList[INDEX].bReserved2 == 1 )
- {
- pAnalog->m_bReserved2 = TRUE;
- }
- else if( g_VarList[INDEX].bReserved2 == 0 )
- {
- pAnalog->m_bReserved2 = FALSE;
- }
- //pAnalog->m_bReserved1 = FALSE;
- //pAnalog->m_bReserved2 = FALSE;
- //pAnalog->m_bReserved3 = FALSE;
- pAnalog->m_bReserved4 = FALSE;
- pAnalog->m_bReserved5 = FALSE;
- pAnalog->m_bReserved6 = FALSE;
- pAnalog->m_bReserved7 = FALSE;
- pAnalog->m_bReserved8 = FALSE;
- pAnalog->m_bReserved9 = FALSE;
- pAnalog->m_bReserved10 = FALSE;
- pAnalog->m_pDevice = NULL;
- pAnalog->m_fData = 0.0;
- pVariantsManager->m_analog.Add(pAnalog);
- }
- return 1;
- }
- void CDlg_ZuTaiAdd::ChangeVarToPic( CString &sVarName )
- {
- CString sVarName1 = sVarName;
- CString sVarName2 = sVarName;
- sVarName1.MakeLower();
- CString sTemp;
- CString s1,s2,s3;
- for( int i=0;i<1000;i++ )
- {
- if( g_VarList[i].sVarName=="" )
- break;
- sTemp = g_VarList[i].sVarName;
- sTemp.MakeLower();
- int nPos=sVarName1.Find( sTemp );
- if( sVarName1.GetLength()>sTemp.GetLength() )
- {
- s3 = sVarName2.Right( sVarName2.GetLength()-sTemp.GetLength()-nPos );
- if( s3[0]=='_' )
- continue;
- }
- if( nPos!=-1 )
- {
- s1 = sVarName2.Left( nPos );
- s3 = sVarName2.Right( sVarName2.GetLength()-sTemp.GetLength()-nPos );
- sVarName = s1+sTemp+s3;
- sVarName.Replace( sTemp,g_VarList[i].sVarNameTemp );
- m_bChangeVarToPic = true;
- break;
- }
- }
- if( !m_bChangeVarToPic )
- {
- CString str;
- str.Format( "%s",sVarName );
- AfxMessageBox( str );
- }
- int a = 0;
- }
- bool CDlg_ZuTaiAdd::ChangePicRelevanceVar(CString sPicPath,CString sPicName )
- {
- char PathScr[_MAX_PATH] = {0};
- strcat(PathScr, g_strDirectory);
- strcat(PathScr,"\\");
- strcat(PathScr, _LIBRARY);
- strcat(PathScr,"画面\\");
- strcat(PathScr, sPicPath );
- CString sTemp,sBack=".view";
- //sTemp = sPicName.Left( sPicName.GetLength()-sBack.GetLength() );
- //sPicName.Format( "%s[%d]%s",sTemp,nDevIndex,sBack );
- char PathDes[_MAX_PATH] = {0};
- strcat(PathDes, g_strDirectory);
- strcat(PathDes,"\\");
- strcat(PathDes, _PICTUREDIR);
- strcat(PathDes, sPicName );
- if( !PathFileExists( PathScr ) )
- return false;
- if( PathFileExists( PathDes ) )
- DeleteFile( PathDes );
- else
- {
- CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->m_wndTree.InsertItem( sPicName.Left(sPicName.GetLength()-sBack.GetLength()), 1, 1, pMainFrm->m_wndTree.GetRootItem() );
- }
- CopyFile( PathScr,PathDes,false );
- //////////////////////////////////////////////////////////////
- CDrawObjList _ObjList;
- BYTE m_Type;
- CSize m_sizePic;
- CSize m_sizeGrid;
- BOOL m_bGrid;
- COLORREF m_clrBack;
- CFile file;
- if(file.Open(PathDes,CFile::modeRead))
- {
- CArchive ar(&file,CArchive::load);
- ar >> m_Type;
- ar >> m_sizePic;
- ar >> m_sizeGrid;
- ar >> m_bGrid;
- ar >> m_clrBack;
- _ObjList.Serialize(ar);
- if( !_ObjList.IsEmpty() )
- {
- for(POSITION pos = _ObjList.GetHeadPosition();pos!=NULL;)
- {
- POSITION pos1 = pos ;
- CDrawObj *ct = (CDrawObj *)_ObjList.GetNext(pos);
- if( ct->m_bVariant && ct->m_strCaption!="" )
- ChangeVarToPic( ct->m_strCaption );
- if( ct->m_strDynShow!="" )
- ChangeVarToPic( ct->m_strDynShow );
- if( ct->m_strDynForeCon!="" )
- ChangeVarToPic( ct->m_strDynForeCon );
- if( ct->m_strDynBackCon!="" )
- ChangeVarToPic( ct->m_strDynBackCon );
- if( ct->m_strDynLineCon!="" )
- ChangeVarToPic( ct->m_strDynLineCon );
- if( ct->m_strHoriPos!="" )
- ChangeVarToPic( ct->m_strHoriPos );
- if( ct->m_strHoriSize!="" )
- ChangeVarToPic( ct->m_strHoriSize );
- if( ct->m_strVertiPos!="" )
- ChangeVarToPic( ct->m_strVertiPos );
- if( ct->m_strVertiSize!="" )
- ChangeVarToPic( ct->m_strVertiSize );
- if( ct->m_strCurrentCaption!="" )
- ChangeVarToPic( ct->m_strCurrentCaption );
- if( ct->m_downAction.m_strVariant!="" )
- ChangeVarToPic( ct->m_downAction.m_strVariant );
- if( ct->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) )
- {
- if( ((CDrawBitmap *)ct)->m_strDynCondition!="" )
- ChangeVarToPic( ((CDrawBitmap *)ct)->m_strDynCondition );
- }
- if( ct->IsKindOf( RUNTIME_CLASS(CDrawGif) ) )
- {
- if( ((CDrawGif *)ct)->m_strDynCondition!="" )
- ChangeVarToPic( ((CDrawGif *)ct)->m_strDynCondition );
- }
- }
- }
- ///////////////////////////////////////
- ar.Close();
- file.Close();
- }
- if( PathFileExists( PathDes ) )
- DeleteFile( PathDes );
- CFile fileWrite;
- if(fileWrite.Open(PathDes,CFile::modeCreate|CFile::modeWrite))
- {
- CArchive ar(&fileWrite,CArchive::store);
- ar << m_Type;
- ar << m_sizePic;
- ar << m_sizeGrid;
- ar << m_bGrid;
- ar << m_clrBack;
- _ObjList.Serialize(ar);
- ar.Flush();
- ar.Close();
- fileWrite.Flush();
- fileWrite.Close();
- }
- if(!_ObjList.IsEmpty())
- {
- for(POSITION pos = _ObjList.GetHeadPosition();pos!=NULL;)
- {
- POSITION pos1 = pos ;
- CDrawObj *ct = (CDrawObj *)_ObjList.GetNext(pos);
- _ObjList.RemoveAt(pos1);
- delete ct;
- }
- _ObjList.RemoveAll();
- ASSERT(_ObjList.IsEmpty());
- }
- return true;
- }
- void CDlg_ZuTaiAdd::OnClose()
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- m_ExcelMain.Exit();
- CDialog::OnClose();
- }
- void CDlg_ZuTaiAdd::ReadResource()
- {
- if( m_bReadResourceFinish )
- return;
- m_bReadResourceFinish = true;
- OpenDevExcel();
- ListDeviceTypes();
- MyExpandTree( m_ctrlDevFolder.GetRootItem() );
- UpdateData( false );
- }
|