// CalcFeedDataDlg.cpp : implementation file // #include "stdafx.h" #include #include #include "CalcFeedDataDlg.h" #include "SanitaryDangDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // 修改当量 ///////////////////////////////////////////////////////////////////////////// //判断这根管线是不是连接立管的干管,GetSysLabel==“” BOOL IsMainPipeLink2VPipe(Entity ent) { BOOL bRet = FALSE; OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe); if(pPipe){ AcDbObjectId id1 = pPipe->GetNode(0); AcDbObjectId id2 = pPipe->GetNode(1); OPENOBJ_BEGIN(id1, AcDb::kForRead, TDbPipeNode, pNode); if(pNode){ int num = pNode->GetInterfaceNum(); for(int m=0;mGetInterface(m, iFace); AcDbObjectId idPipe = iFace.m_idPipe; CString csPipeName; OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe); if(pPipe){ CString csPipeName = pPipe->GetSysLabel(); // cet 2012.6.5 modify 不指定楼层号,否则从非一楼无法计算 // if(csPipeName.Find(_T("1楼立管")) > -1) // return TRUE; if (csPipeName.Find(_T("楼立管")) > -1) { return TRUE; } } OPENOBJ_END(); } } OPENOBJ_END(); OPENOBJ_BEGIN(id2, AcDb::kForRead, TDbPipeNode, pNode); if(pNode){ int num = pNode->GetInterfaceNum(); for(int m=0;mGetInterface(m, iFace); AcDbObjectId idPipe = iFace.m_idPipe; CString csPipeName; OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe); if(pPipe){ CString csPipeName = pPipe->GetSysLabel(); // cet 2012.6.5 modify 不指定楼层号,否则从非一楼无法计算 // if(csPipeName.Find(_T("1楼立管")) > -1) // return TRUE; if (csPipeName.Find(_T("楼立管")) > -1) { return TRUE; } } OPENOBJ_END(); } } OPENOBJ_END(); } OPENOBJ_END(); return bRet; } //修改住宅立管编号,因为有的系统是由用户拼接完成 void ModifyVPipeIdx() { RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL); Entity entMainPipe; if(SelectEntity(_T("\n请选择给水总干管<退出>"), entMainPipe, rbMask) != RTNORM) { return; } PickSet ssAll(SS_FREE); ssAll += entMainPipe; SSearchPipeList *pListAll = new SSearchPipeList(); SearchSprinkPipeSys(entMainPipe, NULL, pListAll, ssAll); delete pListAll; long len = ssAll.Length(); for(long i=0;iGetSysLabel(); if(csLabel == _T("")){ if(IsMainPipeLink2VPipe(ent)){ if(pPipe->upgradeOpen()==Acad::eOk) { pPipe->SetSysLabel(_T("干管-1")); pPipe->SetModelType(TPipeSys::kSystem); pPipe->downgradeOpen(); } } } } OPENOBJ_END(); // OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe); // if(pPipe){ // CString csLabel = pPipe->GetSysLabel(); // int idx = csLabel.Find(_T("-")); // if(idx > -1){ // CString csVPipeName = csLabel.Right(csLabel.GetLength()-idx-1); // int iDn = _ttoi(csVPipeName); // pPipe->SetDnDiameter(iDn); // } // } // OPENOBJ_END(); // DoDimPipeDn(ent,-1,_T(""),3,TRUE); } PickSet ss(SS_FREE); while(SelectEntities(_T("\n请选择要修改楼栋编号的管线:<退出>"), ss, rbMask) == RTNORM){ int iStart(1); ads_getint(_T("\n请输入立管(楼栋)编号<1>"), &iStart); len = ss.Length(); for(i=0;iGetSysLabel(); int idx = csLabel.Find(_T("-")); if(idx > -1){ CString csFloor = csLabel.Left(idx+1); csFloor.Format(_T("%s%d"), csFloor, iStart); pPipe->SetSysLabel(csFloor); // pPipe->SetDnDiameter(iStart); } } OPENOBJ_END(); } } len = ssAll.Length(); for(i=0;iEnableDrawLabel(FALSE); } OPENOBJ_END(); } } void ModifyNg() { PickSet ss(SS_FREE); RBList rbMask = ads_buildlist( -4, _T(""), -4, _T(""), -4, _T("or>"), NULL); RBList rbMask2(RTDXF0, _T("TEXT"), 8, LAY_CALC_TEXT, NULL); if(SelectEntities(_T("\n请选择每层支管末端的断管符号或水龙头:<修改楼栋编号>"), ss, rbMask) != RTNORM){ ModifyVPipeIdx(); return; } if(ss.Length() < 1) return; BOOL bIsResidence = FALSE; BOOL bIsFeedSys = TRUE; OPENOBJ_BEGIN(ss[0L], AcDb::kForRead, TDbEquipment, pEquip); if(pEquip){ if(pEquip->GetInterfaceNum() > 0){ TPipeInterface face; pEquip->GetInterface(0, face); AcDbObjectId nextPipeId = face.m_idPipe; OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe); if(pPipe){ if(pPipe->GetSysType() != TPipeSys::kFeedWater) bIsFeedSys = FALSE; } OPENOBJ_END(); } double nNg = pEquip->GetDang(); if(nNg < 0) bIsResidence = TRUE; else{ double nPeopleNum = pEquip->GetPipeLength(); if(nPeopleNum > 0 && bIsFeedSys) bIsResidence = TRUE; } } OPENOBJ_END(); double nNewDang(0), dBigQ(0); double nPeopleNum(0); double nFactor(2.8); int iRation(250), iDoorNum(1); double nU0(0); CString csDim; if(!bIsResidence){ if(bIsFeedSys){//公建给水 CTemporaryResourceOverride vTemp; CSanitaryDangDlg dlg; dlg.m_bMultSel = TRUE; if(dlg.DoModal() == IDOK){ nNewDang = dlg.m_nRet; dBigQ = dlg.m_nBigQ; if(dBigQ > 1.0) nPeopleNum = -1;//如果是公建,要问当量是否包含“自闭式冲洗阀” } // csDim.Format(_T("Ng=%.1f"), nNewDang); // //如果是公建,要问当量是否包含“自闭式冲洗阀” // ads_getstring(0, _T("\n本层洁具是否包括自闭式冲洗阀?: "), szText); // if(_tcsicmp(szText, _T("Y")) == 0){ // nPeopleNum = -1; // } } else{//排水 TCHAR szText[32]; ads_getreal(_T("\n请输入器具的当量值:<退出>"), &nNewDang); ads_getstring(0, _T("\n本层最大卫生器具的排水流量(L/s): "), szText); nPeopleNum = _tstof(szText); csDim.Format(_T("Ng=%.1f Q=%.2f"), nNewDang, nPeopleNum); } } else{ CTemporaryResourceOverride vTemp; CCalcFeedDataDlg dlg; if(dlg.DoModal() != IDOK) return; bIsResidence = TRUE; nNewDang = dlg.m_nNg; iDoorNum = dlg.m_iDoorNum; nPeopleNum = dlg.m_nNumPeople; iRation = dlg.m_iRation; nFactor = dlg.m_nFactor; //U0 = (q0*m*Kh)/(0.2*Ng*T*3600) if(iDoorNum < 0.001 || nNewDang < 0.001) nU0 = 0; else nU0 = (iDoorNum * iRation * nPeopleNum * nFactor) / (0.2*iDoorNum * nNewDang*24*3600); if(dlg.m_bDim) csDim.Format(_T("%d户/%.1f人每户/q0=%d/Ng=%.1f每户/Kh=%.1f/U0=%.3f"), iDoorNum, nPeopleNum, iRation, nNewDang, nFactor, nU0); } XPoint ptLow, ptUp; ss.GetExtend(ptLow, ptUp); AssureInCurrentView(ptLow, ptUp); InitTwtTextStyle(g_csTwtDimStyle); for(long i=0;iGetDang(); if(bIsFeedSys){ pEquip->SetSpare(dBigQ); pEquip->SetDang(nNewDang); //总当量 SetDang pEquip->SetPipeLength(nPeopleNum); //每户人数 SetPipeLength pEquip->SetNumber(XString(_T("%.2f"), nFactor)); //小时变化系数 SetNumber pEquip->SetSysBlock(XString(_T("%.d"), iRation));//用水定额 SetSysBlock pEquip->SetICookie(0, iDoorNum); //该户型户数 SetICookie } else pEquip->SetSpare(nPeopleNum); //最大排水流量 ptLoc = pEquip->GetLocation(); } OPENOBJ_END(); if(bIsResidence && csDim == _T("")) continue; PickSet ssText(SS_FREE); ads_polar(ptLoc, 0, g_nTwtDimHeight * DocGetPScale(), ptLoc); XPoint ptUcs = Wcs2Ucs(ptLoc); GetPointPickSet(ptUcs, ssText, rbMask2, 100); if(ssText.Length() == 1){ Entity entTmp = ssText[0L]; TCHAR szText[256]; entTmp.GetData(1, szText); CString csNg = szText; csNg = csNg.Right(csNg.GetLength() - 3); if(fabs(nNg - _tstof(csNg)) < 0.01 || bIsResidence){ entTmp.SetData(1, csDim); entTmp.Modify(); } } else{ XText text(csDim, ptLoc, g_nTwtDimHeight * DocGetPScale(), g_nDimScale, g_csTwtDimStyle, LAY_CALC_TEXT); text.Draw(); Entity entLast; entLast.GetLast(); WriteXdata(entLast, _T("TG-LAYER"), LAY_PIPE_FEED); } } } ///////////////////////////////////////////////////////////////////////////// // CCalcFeedDataDlg dialog CCalcFeedDataDlg::CCalcFeedDataDlg(CWnd* pParent /*=NULL*/) : CDialog(CCalcFeedDataDlg::IDD, pParent) { //{{AFX_DATA_INIT(CCalcFeedDataDlg) m_iRation = 250; m_nFactor = 2.8; m_nNg = 4; m_nNumPeople = 3.5; m_bDim = TRUE; m_iDoorNum = 1; //}}AFX_DATA_INIT } void CCalcFeedDataDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCalcFeedDataDlg) DDX_Control(pDX, IDC_SPIN_DOORNUM, m_spinDoorNum); DDX_Text(pDX, IDC_EDIT_RATION, m_iRation); DDX_Text(pDX, IDC_EDIT_HOUR_FACTOR, m_nFactor); DDX_Text(pDX, IDC_EDIT_DOOR_DANG, m_nNg); DDX_Text(pDX, IDC_EDIT_PEOPLE_NUM, m_nNumPeople); DDX_Check(pDX, IDC_CHECK_DIM, m_bDim); DDX_Text(pDX, IDC_EDIT_DOOR_NUM, m_iDoorNum); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCalcFeedDataDlg, CDialog) //{{AFX_MSG_MAP(CCalcFeedDataDlg) ON_BN_CLICKED(IDC_BUTTON_RATION, OnButtonRation) ON_BN_CLICKED(IDC_BUTTON_FACTOR, OnButtonFactor) ON_BN_CLICKED(IDC_BUTTON_DANG, OnButtonDang) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCalcFeedDataDlg message handlers void CCalcFeedDataDlg::OnButtonRation() { //AfxMessageBox(_T("住宅最高日生活用水定额\n\n1.普通住宅Ⅰ (有大便器、洗涤盆) 85~150\n2.普通住宅Ⅱ(有大便器、洗脸盆、洗涤盆、洗衣机、 热水器和沐浴设备) 130~300\n3.普通住宅Ⅲ(有大便器、洗脸盆、洗涤盆、洗衣机、 集中热水供应和沐浴设备) 180~320\n4.别墅 (有大便器、洗脸盆、洗涤盆、洗衣机、洒水栓,家用热水机组和沐浴设备) 200~350\n\n")); RBList rbCmd=ads_buildlist(RTSTR, _T("IPrincipleFeed"), NULL); resbuf *rbRes=NULL; if(ads_invoke(rbCmd, &rbRes) == RTNORM && rbRes) { ads_relrb(rbRes); } } void CCalcFeedDataDlg::OnButtonFactor() { //AfxMessageBox(_T("住宅最高日生活用水小时变化系数Kh\n\n1.普通住宅Ⅰ (有大便器、洗涤盆) 3.0~2.5\n2.普通住宅Ⅱ(有大便器、洗脸盆、洗涤盆、洗衣机、 热水器和沐浴设备) 2.8~2.3\n3.普通住宅Ⅲ(有大便器、洗脸盆、洗涤盆、洗衣机、 集中热水供应和沐浴设备) 2.5~2.0\n4.别墅 (有大便器、洗脸盆、洗涤盆、洗衣机、洒水栓,家用热水机组和沐浴设备) 2.3~1.8\n\n")); RBList rbCmd=ads_buildlist(RTSTR, _T("IPrincipleFeed"), NULL); resbuf *rbRes=NULL; if(ads_invoke(rbCmd, &rbRes) == RTNORM && rbRes) { ads_relrb(rbRes); } } void CCalcFeedDataDlg::OnButtonDang() { CTemporaryResourceOverride vTemp; CSanitaryDangDlg dlg; dlg.m_bMultSel = TRUE; if(dlg.DoModal() == IDOK){ m_nNg = dlg.m_nRet; UpdateData(FALSE); } } BOOL CCalcFeedDataDlg::OnInitDialog() { CDialog::OnInitDialog(); m_spinDoorNum.SetRange(1, 20); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }