1922 lines
53 KiB
C++
1922 lines
53 KiB
C++
#include "stdafx.h"
|
||
#include "AcDbObjectPtr.h"
|
||
#include "globalFunc.h"
|
||
#include "DbEquipment.h"
|
||
#include "msword8.h"
|
||
#include "xtext.h"
|
||
#include "DbWell.h"
|
||
#include "Dbpipe.h"
|
||
#include "CalcDirtWellDlg.h"
|
||
#include "layerdef.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
extern void CalcWellNum(SSearchPipeList *pListAll);
|
||
extern BOOL SetWellName(SSearchPipeList *pListAll);
|
||
extern void DimRainCalcResult(SSearchPipeList *pListAll);
|
||
extern SSearchPipeList *GetWellNode(SSearchPipeList *pListAll, Entity entLongWell, SSearchPipeList *pNode);
|
||
|
||
|
||
//《给水排水管网系统》PAGE 53
|
||
//通过差值法计算充满度 h/D 输入参数q/q0 非满流管道流量比
|
||
// double GlobalFunc::GetFullByPercentQ(double nPercentQ)
|
||
// {
|
||
// //差值法查表 2003规范 P107页
|
||
// double nAc(0);
|
||
// if(nPercentQ <= 0.005)
|
||
// nAc = GlobalFunc::GetValBetween2(0, 0.05, 0, 0.005, nPercentQ);
|
||
// else if(nPercentQ > 0.005 && nPercentQ <= 0.021)
|
||
// nAc = GlobalFunc::GetValBetween2(0.05, 0.1, 0.005, 0.021, nPercentQ);
|
||
// else if(nPercentQ > 0.021 && nPercentQ <= 0.049)
|
||
// nAc = GlobalFunc::GetValBetween2(0.1, 0.15, 0.021, 0.049, nPercentQ);
|
||
// else if(nPercentQ > 0.049 && nPercentQ <= 0.088)
|
||
// nAc = GlobalFunc::GetValBetween2(0.15, 0.2, 0.049, 0.088, nPercentQ);
|
||
// else if(nPercentQ > 0.088 && nPercentQ <= 0.137)
|
||
// nAc = GlobalFunc::GetValBetween2(0.2, 0.25, 0.088, 0.137, nPercentQ);
|
||
// else if(nPercentQ > 0.137 && nPercentQ <= 0.196)
|
||
// nAc = GlobalFunc::GetValBetween2(0.25, 0.3, 0.137, 0.196, nPercentQ);
|
||
// else if(nPercentQ > 0.196 && nPercentQ <= 0.263)
|
||
// nAc = GlobalFunc::GetValBetween2(0.3, 0.35, 0.196, 0.263, nPercentQ);
|
||
// else if(nPercentQ > 0.263 && nPercentQ <= 0.337)
|
||
// nAc = GlobalFunc::GetValBetween2(0.35, 0.4, 0.263, 0.337, nPercentQ);
|
||
// else if(nPercentQ > 0.337 && nPercentQ <= 0.417)
|
||
// nAc = GlobalFunc::GetValBetween2(0.4, 0.45, 0.337, 0.417, nPercentQ);
|
||
// else if(nPercentQ > 0.417 && nPercentQ <= 0.5)
|
||
// nAc = GlobalFunc::GetValBetween2(0.45, 0.5, 0.417, 0.5, nPercentQ);
|
||
// else if(nPercentQ > 0.5 && nPercentQ <= 0.586)
|
||
// nAc = GlobalFunc::GetValBetween2(0.5, 0.55, 0.5, 0.586, nPercentQ);
|
||
// else if(nPercentQ > 0.586 && nPercentQ <= 0.672)
|
||
// nAc = GlobalFunc::GetValBetween2(0.55, 0.6, 0.586, 0.672, nPercentQ);
|
||
// else if(nPercentQ > 0.672 && nPercentQ <= 0.756)
|
||
// nAc = GlobalFunc::GetValBetween2(0.6, 0.65, 0.672, 0.756, nPercentQ);
|
||
// else if(nPercentQ > 0.756 && nPercentQ <= 0.837)
|
||
// nAc = GlobalFunc::GetValBetween2(0.65, 0.7, 0.756, 0.837, nPercentQ);
|
||
// else if(nPercentQ > 0.837 && nPercentQ <= 0.912)
|
||
// nAc = GlobalFunc::GetValBetween2(0.7, 0.75, 0.837, 0.912, nPercentQ);
|
||
// else if(nPercentQ > 0.912 && nPercentQ <= 0.977)
|
||
// nAc = GlobalFunc::GetValBetween2(0.75, 0.8, 0.912, 0.977, nPercentQ);
|
||
// else if(nPercentQ > 0.977 && nPercentQ <= 1.03)
|
||
// nAc = GlobalFunc::GetValBetween2(0.8, 0.85, 0.977, 1.03, nPercentQ);
|
||
// else if(nPercentQ > 1.03 && nPercentQ <= 1.066)
|
||
// nAc = GlobalFunc::GetValBetween2(0.85, 0.9, 1.03, 1.066, nPercentQ);
|
||
// else if(nPercentQ > 1.066 && nPercentQ <= 1.075)
|
||
// nAc = GlobalFunc::GetValBetween2(0.9, 0.95, 1.066, 1.075, nPercentQ);
|
||
// else if(nPercentQ > 1.075)
|
||
// nAc = GlobalFunc::GetValBetween2(0.95, 1, 1.075, 2.0, nPercentQ);
|
||
// else if(fabs(nPercentQ -1) < 0.001)
|
||
// nAc = 1;
|
||
//
|
||
// return nAc;
|
||
// }
|
||
|
||
//《给水排水管网系统》PAGE 53
|
||
//通过差值法计算 非满流管道过水断面面积比 A/A0 输入参数 :充满度 h/D
|
||
double GetPercentAreaByFull(double nFull)
|
||
{
|
||
//差值法查表 2003规范 P107页
|
||
double nAc(0);
|
||
if (nFull <= 0.05)
|
||
nAc = GlobalFunc::GetValBetween2(0, 0.019, 0, 0.05, nFull);
|
||
else if (nFull > 0.05 && nFull <= 0.1)
|
||
nAc = GlobalFunc::GetValBetween2(0.019, 0.052, 0.05, 0.1, nFull);
|
||
else if (nFull > 0.1 && nFull <= 0.15)
|
||
nAc = GlobalFunc::GetValBetween2(0.052, 0.094, 0.1, 0.15, nFull);
|
||
else if (nFull > 0.15 && nFull <= 0.2)
|
||
nAc = GlobalFunc::GetValBetween2(0.094, 0.142, 0.15, 0.2, nFull);
|
||
else if (nFull > 0.2 && nFull <= 0.25)
|
||
nAc = GlobalFunc::GetValBetween2(0.142, 0.196, 0.2, 0.25, nFull);
|
||
else if (nFull > 0.25 && nFull <= 0.3)
|
||
nAc = GlobalFunc::GetValBetween2(0.196, 0.252, 0.25, 0.3, nFull);
|
||
else if (nFull > 0.3 && nFull <= 0.35)
|
||
nAc = GlobalFunc::GetValBetween2(0.252, 0.312, 0.3, 0.35, nFull);
|
||
else if (nFull > 0.35 && nFull <= 0.4)
|
||
nAc = GlobalFunc::GetValBetween2(0.312, 0.374, 0.35, 0.4, nFull);
|
||
else if (nFull > 0.4 && nFull <= 0.45)
|
||
nAc = GlobalFunc::GetValBetween2(0.374, 0.436, 0.4, 0.45, nFull);
|
||
else if (nFull > 0.45 && nFull <= 0.5)
|
||
nAc = GlobalFunc::GetValBetween2(0.436, 0.5, 0.45, 0.5, nFull);
|
||
else if (nFull > 0.5 && nFull <= 0.55)
|
||
nAc = GlobalFunc::GetValBetween2(0.5, 0.564, 0.5, 0.55, nFull);
|
||
else if (nFull > 0.55 && nFull <= 0.6)
|
||
nAc = GlobalFunc::GetValBetween2(0.564, 0.626, 0.55, 0.6, nFull);
|
||
else if (nFull > 0.6 && nFull <= 0.65)
|
||
nAc = GlobalFunc::GetValBetween2(0.626, 0.688, 0.6, 0.65, nFull);
|
||
else if (nFull > 0.65 && nFull <= 0.7)
|
||
nAc = GlobalFunc::GetValBetween2(0.688, 0.748, 0.65, 0.7, nFull);
|
||
else if (nFull > 0.7 && nFull <= 0.75)
|
||
nAc = GlobalFunc::GetValBetween2(0.748, 0.804, 0.7, 0.75, nFull);
|
||
else if (nFull > 0.75 && nFull <= 0.8)
|
||
nAc = GlobalFunc::GetValBetween2(0.804, 0.858, 0.75, 0.8, nFull);
|
||
else if (nFull > 0.8 && nFull <= 0.85)
|
||
nAc = GlobalFunc::GetValBetween2(0.858, 0.906, 0.8, 0.85, nFull);
|
||
else if (nFull > 0.85 && nFull <= 0.9)
|
||
nAc = GlobalFunc::GetValBetween2(0.906, 0.948, 0.85, 0.9, nFull);
|
||
else if (nFull > 0.9 && nFull <= 0.95)
|
||
nAc = GlobalFunc::GetValBetween2(0.948, 0.981, 0.9, 0.95, nFull);
|
||
else if (nFull > 0.95 && nFull <= 1)
|
||
nAc = GlobalFunc::GetValBetween2(0.981, 1, 0.95, 1, nFull);
|
||
else if (nFull > 1)
|
||
nAc = 1;
|
||
return nAc;
|
||
}
|
||
|
||
int PlusDirtDn(int dn, BOOL bPlus)
|
||
{
|
||
int ret(0);
|
||
if (bPlus) { //增大一级管径
|
||
if (dn == 200)
|
||
ret = 250;
|
||
else if (dn == 250)
|
||
ret = 300;
|
||
else if (dn == 300)
|
||
ret = 350;
|
||
else if (dn == 350)
|
||
ret = 400;
|
||
else if (dn == 400)
|
||
ret = 450;
|
||
else if (dn == 450)
|
||
ret = 500;
|
||
else if (dn == 500)
|
||
ret = 600;
|
||
else if (dn == 600)
|
||
ret = 700;
|
||
else if (dn == 700)
|
||
ret = 800;
|
||
else if (dn == 800)
|
||
ret = 900;
|
||
else if (dn == 900)
|
||
ret = 1000;
|
||
else if (dn == 1000)
|
||
ret = 1100;
|
||
else if (dn == 1100)
|
||
ret = 1200;
|
||
else if (dn == 1200)
|
||
ret = 1350;
|
||
else if (dn == 1350)
|
||
ret = 1500;
|
||
else if (dn == 1500)
|
||
ret = 1650;
|
||
else if (dn == 1650)
|
||
ret = 1800;
|
||
else if (dn == 1800)
|
||
ret = 2000;
|
||
else if (dn == 2000)
|
||
ret = 2100;
|
||
else if (dn == 2100)
|
||
ret = 2200;
|
||
else if (dn == 2200)
|
||
ret = 2300;
|
||
else if (dn == 2300)
|
||
ret = 2400;
|
||
else if (dn == 2400)
|
||
ret = 2500;
|
||
else if (dn == 2500)
|
||
ret = 2600;
|
||
else if (dn == 2600)
|
||
ret = 2700;
|
||
else if (dn == 2700)
|
||
ret = 2800;
|
||
else if (dn == 2800)
|
||
ret = 2900;
|
||
else if (dn == 2900)
|
||
ret = 3000;
|
||
else
|
||
ret = 3000;
|
||
}
|
||
else {
|
||
if (dn == 200)
|
||
ret = 200;
|
||
else if (dn == 250)
|
||
ret = 200;
|
||
else if (dn == 300)
|
||
ret = 250;
|
||
else if (dn == 350)
|
||
ret = 300;
|
||
else if (dn == 400)
|
||
ret = 350;
|
||
else if (dn == 450)
|
||
ret = 400;
|
||
else if (dn == 500)
|
||
ret = 450;
|
||
else if (dn == 600)
|
||
ret = 500;
|
||
else if (dn == 700)
|
||
ret = 600;
|
||
else if (dn == 800)
|
||
ret = 700;
|
||
else if (dn == 900)
|
||
ret = 800;
|
||
else if (dn == 1000)
|
||
ret = 900;
|
||
else if (dn == 1100)
|
||
ret = 1000;
|
||
else if (dn == 1200)
|
||
ret = 1100;
|
||
else if (dn == 1350)
|
||
ret = 1200;
|
||
else if (dn == 1500)
|
||
ret = 1350;
|
||
else if (dn == 1650)
|
||
ret = 1500;
|
||
else if (dn == 1800)
|
||
ret = 1650;
|
||
else if (dn == 2000)
|
||
ret = 1800;
|
||
else if (dn == 2100)
|
||
ret = 2000;
|
||
else if (dn == 2200)
|
||
ret = 2100;
|
||
else if (dn == 2300)
|
||
ret = 2200;
|
||
else if (dn == 2400)
|
||
ret = 2300;
|
||
else if (dn == 2500)
|
||
ret = 2400;
|
||
else if (dn == 2600)
|
||
ret = 2500;
|
||
else if (dn == 2700)
|
||
ret = 2600;
|
||
else if (dn == 2800)
|
||
ret = 2700;
|
||
else if (dn == 2900)
|
||
ret = 2800;
|
||
else if (dn == 3000)
|
||
ret = 2900;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
int GetFirstDirtPipeDnByQ2(double nQ, double nN, double nI, double &nV, double &nFull)
|
||
{
|
||
if (nI < 0.000001)
|
||
return 0;
|
||
BOOL bMetal = FALSE;
|
||
if (fabs(nN - 0.012) < 0.001 || fabs(nN - 0.013) < 0.001 || fabs(nN - 0.014) < 0.001)
|
||
bMetal = TRUE;
|
||
//以下数字出自:《给水排水管网系统》P217 主要针对于污水管
|
||
int dn = 200;//小区道路最小是300
|
||
if (nQ < 9.19)
|
||
dn = 200;
|
||
else if (nQ < 16.6)
|
||
dn = 250;
|
||
else if (nQ < 23.9)
|
||
dn = 300;
|
||
else if (nQ < 39.72)
|
||
dn = 350;
|
||
else if (nQ < 51.88)
|
||
dn = 400;
|
||
else if (nQ < 65.66)
|
||
dn = 450;
|
||
else if (nQ < 88.08)
|
||
dn = 500;
|
||
else if (nQ < 126.84)
|
||
dn = 600;
|
||
else if (nQ < 172.65)
|
||
dn = 700;
|
||
else if (nQ < 222.5)
|
||
dn = 800;
|
||
else if (nQ < 285.39)
|
||
dn = 900;
|
||
else if (nQ < 379.11)
|
||
dn = 1000;
|
||
else if (nQ < 458.72)
|
||
dn = 1100;
|
||
else if (nQ < 545.92)
|
||
dn = 1200;
|
||
else if (nQ < 690.93)
|
||
dn = 1350;
|
||
else if (nQ < 853)
|
||
dn = 1500;
|
||
else if (nQ < 1032.13)
|
||
dn = 1650;
|
||
else
|
||
dn = 1800;
|
||
|
||
double nSlowV = 0.6;
|
||
nQ = nQ / 1000;// 把L/S 转化为 M3/S
|
||
int iOldDn(0);
|
||
while (1)
|
||
{
|
||
|
||
int iOldDn2(0);
|
||
double nRadius = (double)dn / 1000;
|
||
double nFullest = 0.55;
|
||
if (dn > 350 && dn < 500)
|
||
nFullest = 0.65;
|
||
else if (dn > 450 && dn < 1000)
|
||
nFullest = 0.7;
|
||
else if (dn >= 1000)
|
||
nFullest = 0.75;
|
||
|
||
double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
double nTmpQ = (nN * nQ) / sqrt(nTmp);
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
nV = 1.27 / (nRadius * nRadius) * nQ / nTmpA;
|
||
|
||
//计算充满度和流速《给水排水管网系统》 利用差值法查表
|
||
while (nV < nSlowV || (nV > 10 && bMetal) || (nV > 5 && !bMetal) || nFull > nFullest) {
|
||
if (nV < nSlowV) {
|
||
if (dn == 200)
|
||
break;
|
||
iOldDn2 = dn;
|
||
dn = PlusDirtDn(dn, FALSE);
|
||
}
|
||
else {
|
||
dn = PlusDirtDn(dn, TRUE);
|
||
if (dn == iOldDn2)
|
||
break;
|
||
}
|
||
nRadius = (double)dn / 1000;
|
||
nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
nTmpQ = (nN * nQ) / sqrt(nTmp);
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
nV = 1.27 / (nRadius * nRadius) * nQ / nTmpA;
|
||
}
|
||
double nTempQ = (0.25 * nRadius * nRadius * PI) * nV * nFull;
|
||
if (nTempQ < nQ && dn < 3000 && fabs(nTempQ - nQ) > 0.01) {
|
||
dn = PlusDirtDn(dn, TRUE); //设计流量不够,管径加大一号
|
||
if (dn == iOldDn)
|
||
break;
|
||
continue;
|
||
}
|
||
if (dn == 200)
|
||
break;
|
||
|
||
if (nFull < (nFullest - 0.1) && nI > 0.002) {
|
||
if (dn == iOldDn)
|
||
break;
|
||
iOldDn = dn;
|
||
dn = PlusDirtDn(dn, FALSE); //充满度太小
|
||
continue;
|
||
}
|
||
|
||
int iTempDn = PlusDirtDn(dn, FALSE);
|
||
iTempDn = PlusDirtDn(iTempDn, FALSE);
|
||
double nTempDn = (double)iTempDn / 1000;
|
||
nTempQ = (0.25 * nTempDn * nTempDn * PI) * nV * nFull;
|
||
if (nTempQ > nQ) {
|
||
if (dn == iOldDn)
|
||
break;
|
||
iOldDn = dn;
|
||
dn = PlusDirtDn(dn, FALSE); //设计流量过了,管径减小一号
|
||
continue;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
return dn;
|
||
}
|
||
|
||
int GetFirstDirtPipeDnByQ(double nQ, double nN, double &nI, double &nV, double &nFull, BOOL bIsCivil)
|
||
{
|
||
BOOL bMetal = FALSE;
|
||
if (fabs(nN - 0.012) < 0.001 || fabs(nN - 0.013) < 0.001 || fabs(nN - 0.014) < 0.001)
|
||
bMetal = TRUE;
|
||
double nTempI = 0.003;
|
||
//以下数字出自:《给水排水管网系统》P217 主要针对于污水管
|
||
int dn = 200; //小区道路最小是200
|
||
if (bIsCivil)
|
||
dn = 300; //市政最小是300
|
||
if (nQ < 9.19 && !bIsCivil) {
|
||
dn = 200;
|
||
nTempI = 0.004;
|
||
}
|
||
else if (nQ < 16.6 && !bIsCivil) {
|
||
dn = 250;
|
||
nTempI = 0.0035;
|
||
}
|
||
else if (nQ < 23.9) {
|
||
dn = 300;
|
||
nTempI = 0.003;
|
||
}
|
||
else if (nQ < 39.72) {
|
||
dn = 350;
|
||
nTempI = 0.003;
|
||
}
|
||
else if (nQ < 51.88) {
|
||
dn = 400;
|
||
nTempI = 0.0025;
|
||
}
|
||
else if (nQ < 65.66) {
|
||
dn = 450;
|
||
nTempI = 0.002;
|
||
}
|
||
else if (nQ < 88.08) {
|
||
dn = 500;
|
||
nTempI = 0.0015;
|
||
}
|
||
else if (nQ < 126.84) {
|
||
dn = 600;
|
||
nTempI = 0.0015;
|
||
}
|
||
else if (nQ < 172.65) {
|
||
dn = 700;
|
||
nTempI = 0.001;
|
||
}
|
||
else if (nQ < 222.5) {
|
||
dn = 800;
|
||
nTempI = 0.001;
|
||
}
|
||
else if (nQ < 285.39) {
|
||
dn = 900;
|
||
nTempI = 0.001;
|
||
}
|
||
else if (nQ < 379.11) {
|
||
dn = 1000;
|
||
nTempI = 0.001;
|
||
}
|
||
else if (nQ < 458.72) {
|
||
dn = 1100;
|
||
nTempI = 0.001;
|
||
}
|
||
else if (nQ < 545.92) {
|
||
dn = 1200;
|
||
nTempI = 0.0005;
|
||
}
|
||
else if (nQ < 690.93) {
|
||
dn = 1350;
|
||
nTempI = 0.0005;
|
||
}
|
||
else if (nQ < 853) {
|
||
dn = 1500;
|
||
nTempI = 0.0005;
|
||
}
|
||
else if (nQ < 1032.13) {
|
||
dn = 1650;
|
||
nTempI = 0.0005;
|
||
}
|
||
else {
|
||
dn = 1800;
|
||
nTempI = 0.0005;
|
||
}
|
||
|
||
double nSlowV = 0.6;
|
||
nQ = nQ / 1000;// 把L/S 转化为 M3/S
|
||
while (1)
|
||
{
|
||
nI = nTempI - 0.0005;
|
||
double nRadius = (double)dn / 1000;
|
||
double nFullest = 0.55;
|
||
if (dn > 350 && dn < 500)
|
||
nFullest = 0.65;
|
||
else if (dn > 450 && dn < 1000)
|
||
nFullest = 0.7;
|
||
else if (dn >= 1000)
|
||
nFullest = 0.75;
|
||
|
||
double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
double nTmpQ = (nN * nQ) / sqrt(nTmp);
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
if (nTmpA < 0.001)
|
||
break;
|
||
nV = 1.27 / (nRadius * nRadius) * nQ / nTmpA;
|
||
|
||
|
||
//计算充满度和流速《给水排水管网系统》 利用差值法查表
|
||
while (nV < nSlowV || (nV > 10 && bMetal) || (nV > 5 && !bMetal) || nFull > nFullest) {
|
||
nI += 0.0005;
|
||
double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
double nTmpQ = (nN * nQ) / sqrt(nTmp);
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
if (nFull < 0.001)
|
||
break;
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
nV = 1.27 / (nRadius * nRadius) * nQ / nTmpA;
|
||
}
|
||
double nTempQ = (0.25 * nRadius * nRadius * PI) * nV * nFull;
|
||
|
||
if (nTempQ < nQ && dn < 3000 && fabs(nTempQ - nQ) > 0.01) {
|
||
dn = PlusDirtDn(dn, TRUE); //设计流量不够,管径加大一号
|
||
continue;
|
||
}
|
||
if (dn == 200)
|
||
break;
|
||
int iTempDn = PlusDirtDn(dn, FALSE);
|
||
iTempDn = PlusDirtDn(iTempDn, FALSE);
|
||
double nTempDn = (double)iTempDn / 1000;
|
||
nTempQ = (0.25 * nTempDn * nTempDn * PI) * nV * nFull;
|
||
if (nTempQ > nQ) {
|
||
dn = PlusDirtDn(dn, FALSE); //设计流量过了,管径减小一号
|
||
continue;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
return dn;
|
||
}
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 污井流量
|
||
//***************************************************************************************************
|
||
//void SetDirtWellQ()
|
||
//{
|
||
// double nQ(0);
|
||
// CString csQ;
|
||
// RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), 8, LAY_WELL_DIRT, NULL);
|
||
// PickSet ss(SS_FREE);
|
||
// PickSet ssAll(SS_FREE), ssDel(SS_FREE);
|
||
// ssAll.Get(_T("X"), NULL, NULL, rbMask);
|
||
// for(long j=0;j<ssAll.Length();j++){
|
||
// Entity ent = ssAll[j];
|
||
// csQ = GlobalFunc::ReadXdata(ent, _T("TG-DIRTWELLQ"));
|
||
// if(csQ != _T("")){
|
||
// XPoint ptLoc;
|
||
// double nScale(0);
|
||
// OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbEquipment, pEquip);
|
||
// if(pEquip){
|
||
// ptLoc = pEquip->GetLocation();
|
||
// nScale = pEquip->GetScale();
|
||
// }
|
||
// OPENOBJ_END();
|
||
// XText text(XString(_T("Q=%s(L/S)"), csQ), ptLoc, g_nTwtDimHeight * GlobalFunc::DocGetPScale(), g_nDimScale, g_csTwtDimStyle, LAY_CALC_TEXT);
|
||
// text.Draw();
|
||
// Entity entCir2;
|
||
// entCir2.GetLast();
|
||
// ssDel += entCir2;
|
||
// }
|
||
// }
|
||
//
|
||
// if(SelectEntities(_T("\n请选择污水井:<退出>"), ss, rbMask) != RTNORM){
|
||
// ssDel.Erase();
|
||
// return;
|
||
// }
|
||
// ssDel.Erase();
|
||
// long len = ss.Length();
|
||
//
|
||
// if(ads_getreal(_T("\n请给出流入污水井的流量(L/S)(注意不包括转输流量)<退出>:"), &nQ) != RTNORM)
|
||
// return;
|
||
//
|
||
// csQ.Format(_T("%.2f"), nQ);
|
||
// for(long i=0;i<len;i++){
|
||
// Entity ent = ss[i];
|
||
// WriteXdata(ent, _T("TG-DIRTWELLQ"), csQ);
|
||
// }
|
||
//}
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 小区污水
|
||
//***************************************************************************************************
|
||
|
||
//输出计算书函数
|
||
void ImportDirtWellCalcWord(DList<SDirtCalcData> &lstNode)
|
||
{
|
||
int len = lstNode.Length();
|
||
if (len < 1)
|
||
return;
|
||
|
||
//初始化
|
||
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR), vtTrue((short)TRUE), vtFalse((short)FALSE);
|
||
_Application wordApplication;
|
||
Documents wordDocuments;
|
||
_Document activeDocument;
|
||
Paragraphs wordParagraphs;
|
||
Selection wordSelection;
|
||
|
||
if (!wordApplication.CreateDispatch(_T("Word.Application")))
|
||
{
|
||
AfxMessageBox(_T("不能执行Microsoft Word 8.0!"));
|
||
return;
|
||
}
|
||
wordApplication.SetVisible(TRUE);
|
||
wordDocuments = wordApplication.GetDocuments();
|
||
activeDocument = wordDocuments.Add(vtOptional, vtOptional);
|
||
|
||
|
||
//写一行字
|
||
wordSelection = wordApplication.GetSelection();
|
||
wordParagraphs = wordSelection.GetParagraphs();
|
||
wordParagraphs.SetAlignment(0); // 0: 居左 1:居中 2:居右
|
||
|
||
wordSelection.TypeText(_T("计算原理参照《全国民用建筑工程设计技术措施2009》\n"));
|
||
wordSelection.TypeText(_T("计算结果:\n"));
|
||
Selection wSelection2 = wordApplication.GetSelection();
|
||
wSelection2.TypeParagraph();
|
||
|
||
//画表格
|
||
int rows(len + 1), columns(8);
|
||
|
||
Selection wSelection = wordApplication.GetSelection();
|
||
Range oRange = wSelection.GetRange();
|
||
Tables oTables = activeDocument.GetTables();
|
||
_Table oTable = oTables.Add(oRange, rows, columns);
|
||
// cet 2010.3.25 add
|
||
Borders oBorders = oTable.GetBorders();
|
||
oBorders.SetInsideLineStyle(1); // 设置表格线型
|
||
oBorders.SetOutsideLineStyle(1);
|
||
|
||
Columns oColumns;
|
||
Column oColumn;
|
||
oColumns = oTable.GetColumns();
|
||
oColumn = oColumns.Item(1);
|
||
oColumn.SetWidth(60, 0); // 0 = wdAdjustNone
|
||
oColumn = oColumns.Item(2);
|
||
oColumn.SetWidth(50, 0);
|
||
oColumn = oColumns.Item(3);
|
||
oColumn.SetWidth(60, 0);
|
||
oColumn = oColumns.Item(4);
|
||
oColumn.SetWidth(55, 0);
|
||
oColumn = oColumns.Item(5);
|
||
oColumn.SetWidth(60, 0);
|
||
oColumn = oColumns.Item(6);
|
||
oColumn.SetWidth(60, 0);
|
||
oColumn = oColumns.Item(7);
|
||
oColumn.SetWidth(55, 0);
|
||
oColumn = oColumns.Item(8);
|
||
oColumn.SetWidth(75, 0);
|
||
|
||
|
||
|
||
|
||
|
||
Cell oCell;
|
||
oCell = oTable.Cell(1, 1);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("管段名称"));
|
||
|
||
|
||
oCell = oTable.Cell(1, 2);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("流量L/s"));
|
||
|
||
oCell = oTable.Cell(1, 3);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("管长m"));
|
||
|
||
oCell = oTable.Cell(1, 4);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("公称直径"));
|
||
|
||
oCell = oTable.Cell(1, 5);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("坡度‰"));
|
||
|
||
oCell = oTable.Cell(1, 6);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("流速m/s"));
|
||
|
||
|
||
oCell = oTable.Cell(1, 7);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("充满度%"));
|
||
|
||
oCell = oTable.Cell(1, 8);
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(_T("管材"));
|
||
|
||
|
||
|
||
for (int i = 0; i < len; i++) {
|
||
CString csTmp;
|
||
oCell = oTable.Cell(i + 2, 1); //管段名称
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(lstNode[i]->m_csName);
|
||
|
||
|
||
csTmp.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
|
||
oCell = oTable.Cell(i + 2, 2); //管道流量L/s
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
|
||
oCell = oTable.Cell(i + 2, 3); //管长m
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
csTmp.Format(_T("%d"), lstNode[i]->m_iDn);
|
||
oCell = oTable.Cell(i + 2, 4); //管径mm
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
csTmp.Format(_T("%.2f"), lstNode[i]->m_nI);
|
||
oCell = oTable.Cell(i + 2, 5); //水力坡降mH2O/m
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
csTmp.Format(_T("%.2f"), lstNode[i]->m_nV);
|
||
oCell = oTable.Cell(i + 2, 6); //流速m/s
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
csTmp.Format(_T("%.2f"), lstNode[i]->m_nFull * 100);
|
||
oCell = oTable.Cell(i + 2, 7); //充满度
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csTmp);
|
||
|
||
|
||
int iMat(0);
|
||
OPENOBJ_BEGIN(lstNode[i]->m_ID, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
iMat = pPipe->GetMaterial();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
CString csMat = GlobalFunc::GetPipeMaterialByIdx(iMat);
|
||
oCell = oTable.Cell(i + 2, 8); //管材
|
||
oRange = oCell.GetRange();
|
||
oRange.InsertAfter(csMat);
|
||
|
||
}
|
||
|
||
COleVariant vtOptional2((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||
wordSelection = wordApplication.GetSelection();
|
||
wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine
|
||
COleVariant((short)-1), vtOptional2, vtOptional2); // -1 = wdGoToLast
|
||
|
||
wSelection = wordApplication.GetSelection();
|
||
wSelection.TypeParagraph();
|
||
|
||
}
|
||
|
||
//计算每段管的设计流量
|
||
//nQA=比流量
|
||
//pListAll->m_nV = Qd 平均日污水流量
|
||
//每段流量=nQa*本段服务面积+集中流量
|
||
//Kz 总变化系数
|
||
// 《给排水管线系统》 P205
|
||
void DoCalcDesignQ(SSearchPipeList *pListAll, double nQa)
|
||
{
|
||
if (pListAll->m_iType == 0) {
|
||
if (pListAll->m_iSpare == 0) { // 居民生活污水
|
||
double nDesignQ = nQa * (pListAll->m_nStartPress / 10000);
|
||
pListAll->m_nSpare = nDesignQ;
|
||
}
|
||
}
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
DoCalcDesignQ(pList, nQa);
|
||
pListAll->m_nSpare += pList->m_nSpare;
|
||
}
|
||
if (pListAll->m_iType == 0) {
|
||
double nDesignQ = pListAll->m_nSpare;
|
||
double nKz(0);
|
||
if (nDesignQ < 5)
|
||
nKz = 2.3;
|
||
else if (nDesignQ > 1000)
|
||
nKz = 1.3;
|
||
else
|
||
nKz = 2.7 / pow(nDesignQ, 0.11);
|
||
nDesignQ = nDesignQ * nKz;
|
||
if (nDesignQ < 0.001)
|
||
nDesignQ = 0;
|
||
pListAll->m_nPipeQ = nDesignQ;
|
||
}
|
||
}
|
||
|
||
void GetFocusQ(SSearchPipeList *pListAll, double &nRet)
|
||
{
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
if (pList->m_iType != 0) {
|
||
double nFocusQ = pList->m_bNeedCale;
|
||
nFocusQ = nFocusQ / 1000;
|
||
nRet += nFocusQ;
|
||
}
|
||
GetFocusQ(pList, nRet);
|
||
}
|
||
}
|
||
|
||
void GetIndustryQ(SSearchPipeList *pListAll, double &nRet)
|
||
{
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
if (pList->m_iType != 0) {
|
||
if (pList->m_iSpare == 1) {
|
||
double dDirtCoef = (double)pList->m_iNum / 100.0; //污水折减系数
|
||
double dWaterRation = pList->m_nDang; //给水指标
|
||
double dArea = pListAll->m_nStartPress / 10000; //公顷
|
||
double dQ = dArea * 0.01 * dDirtCoef * dWaterRation; //单位:万立方米每天
|
||
dQ = (dQ * 10000 * 1000) / (24 * 3600); //L/S
|
||
nRet += dQ;
|
||
}
|
||
|
||
}
|
||
GetIndustryQ(pList, nRet);
|
||
}
|
||
}
|
||
|
||
void AddFocusQ(SSearchPipeList *pListAll)
|
||
{
|
||
double nRet(0), nRet2(0);
|
||
GetFocusQ(pListAll, nRet);
|
||
GetIndustryQ(pListAll, nRet2);
|
||
pListAll->m_nPipeQ += nRet;
|
||
pListAll->m_nPipeQ += nRet2;
|
||
// if(pListAll->m_iType == 3){
|
||
// ads_name ent;
|
||
// acdbGetAdsName(ent, pListAll->m_ID);
|
||
// WriteXdata(ent, _T("TG-DIRTWELLQ"), XString(_T("%.2f"), pListAll->m_nPipeQ));
|
||
// }
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
AddFocusQ(pList);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
BOOL CheckWellSys(SSearchPipeList *pListAll, BOOL bChcekPool = FALSE)
|
||
{
|
||
BOOL bRet = TRUE;
|
||
if (pListAll->m_iType == 1) {
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipeNode, pNode);
|
||
if (pNode) {
|
||
if (pNode->GetInterfaceNum() > 1) {
|
||
g_Option::instance().adsout << _T("\n2管线相交之处缺少井!");
|
||
double nDist = GlobalFunc::DocGetPScale() * 20;
|
||
XPoint pt = pNode->GetLocation();
|
||
XPoint p1, p2, p3, p4;
|
||
ads_polar(pt, 0, nDist, p1);
|
||
ads_polar(p1, PI / 2, nDist, p1);
|
||
ads_polar(pt, PI, nDist, p2);
|
||
ads_polar(p2, PI / 2, -nDist, p2);
|
||
ads_grdraw(p1, p2, 2, 0);
|
||
ads_polar(pt, PI / 2, nDist, p3);
|
||
ads_polar(p3, PI, nDist, p3);
|
||
ads_polar(pt, PI / 2, -nDist, p4);
|
||
ads_polar(p4, 0, nDist, p4);
|
||
ads_grdraw(p3, p4, 2, 0);
|
||
bRet = FALSE;
|
||
return FALSE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (pListAll->m_iType == 4)
|
||
{
|
||
if (bChcekPool)
|
||
{
|
||
g_Option::instance().adsout << _T("系统不能有化粪池!");
|
||
bRet = FALSE;
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
if (!CheckWellSys(pList, bChcekPool))
|
||
bRet = FALSE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
//读取市政污水井信息
|
||
BOOL SetDirtWellInfo(SSearchPipeList *pListAll, double &nAllArea, BOOL &bInput)
|
||
{
|
||
BOOL ret = TRUE;
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
if (GlobalFunc::IsWell(id))
|
||
pListAll->m_iType = 3;
|
||
ads_name ent;
|
||
double nCurPipeLength(0);
|
||
acdbGetAdsName(ent, id);
|
||
if (pListAll->m_iType == 3) {
|
||
CString csWellName = GlobalFunc::GetWellName(ent);
|
||
CString csArea = GlobalFunc::ReadXdata(ent, _T("TG-WELLAREA"));
|
||
CString csRation = GlobalFunc::ReadXdata(ent, _T("TG-DIRTRATION"));
|
||
CString csPeople = GlobalFunc::ReadXdata(ent, _T("TG-DIRTPEOPLE"));
|
||
CString csQ = GlobalFunc::ReadXdata(ent, _T("TG-DIRTFOCUSQ"));
|
||
CString csWaterRation = GlobalFunc::ReadXdata(ent, _T("TG-WATERRATION")); // 给水指标
|
||
CString csDirtCoef = GlobalFunc::ReadXdata(ent, _T("TG-DIRTCOEF")); // 污水折减系数
|
||
|
||
|
||
if (csQ != _T("") || csArea != _T("") || csRation != _T("") || csPeople != _T("") || csWaterRation != _T("") || csDirtCoef != _T(""))
|
||
bInput = TRUE;
|
||
if (csWaterRation != _T("") && csDirtCoef != _T("")) { //工业用水
|
||
pListAll->m_iSpare = 1;
|
||
pListAll->m_iNum = int(_tstof(csDirtCoef) * 100);
|
||
pListAll->m_nDang = _tstof(csWaterRation);
|
||
}
|
||
else {
|
||
pListAll->m_iSpare = 0;
|
||
pListAll->m_iNum = _ttoi(csPeople);
|
||
pListAll->m_nDang = _tstof(csRation);
|
||
}
|
||
pListAll->m_nStartPress = _tstof(csArea);
|
||
pListAll->m_bNeedCale = _ttoi(csQ) * 1000;
|
||
if (pListAll->m_pPrevious != NULL)
|
||
pListAll->m_pPrevious->m_iSpare = pListAll->m_iSpare;
|
||
}
|
||
else if (pListAll->m_iType == 0) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
nCurPipeLength = pPipe->Length();
|
||
// if(!DocGetMeterUnitDraw())
|
||
// nCurPipeLength = nCurPipeLength/1000;
|
||
pListAll->m_nLength = nCurPipeLength;
|
||
}
|
||
OPENOBJ_END();
|
||
CString csNum1 = pListAll->m_pPrevious->m_csName;
|
||
if (!pListAll->m_pPrevious->m_pPrevious && csNum1 == _T(""))
|
||
csNum1 = _T("出口");
|
||
CString csNum2 = pListAll->m_lstNode[0]->m_csName;
|
||
if (csNum1 != _T("") && csNum2 != _T(""))
|
||
pListAll->m_csName = csNum2 + _T("-") + csNum1;
|
||
}
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
ret = SetDirtWellInfo(pList, nAllArea, bInput);
|
||
if (pListAll->m_iType == 0) {
|
||
pListAll->m_iNum = pList->m_iNum;
|
||
pListAll->m_nDang = pList->m_nDang;
|
||
pListAll->m_nStartPress = pList->m_nStartPress;
|
||
pListAll->m_bNeedCale = pList->m_bNeedCale;
|
||
if (pListAll->m_iSpare == 0) {//计算:生活污水设计流量
|
||
double nTmpQ(0);
|
||
if (pListAll->m_iNum > 0 && pListAll->m_nStartPress > 0 && pListAll->m_nDang > 0)
|
||
{
|
||
nTmpQ = pListAll->m_iNum * pListAll->m_nDang * pListAll->m_nStartPress / 10000;
|
||
nTmpQ = nTmpQ / (24 * 3600);
|
||
pListAll->m_nV = nTmpQ; //计算Qd
|
||
}
|
||
}
|
||
}
|
||
pListAll->m_nV += pList->m_nV;
|
||
if (pListAll->m_iType != 0 && pList->m_iSpare == 0) // 2009-7-13 if(pListAll->m_iType == 3)
|
||
nAllArea += pList->m_nStartPress; //这里算Qd(居民生活污水平均日流量)必须是生活的,不能带工业面积
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
//计算本节点往后共计管线长度
|
||
void CalcDirtWellQ(SSearchPipeList *pListAll, SSearchPipeList *pListFront, BOOL &bHasQ)
|
||
{
|
||
BOOL ret = TRUE;
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
ads_name ent;
|
||
double nCurPipeLength(0);
|
||
acdbGetAdsName(ent, id);
|
||
if (pListAll->m_iType == 3) {
|
||
Entity entTmp = ent;
|
||
CString csQ = GlobalFunc::ReadXdata(entTmp, _T("TG-DIRTWELLQ"));
|
||
if (csQ != _T("")) {
|
||
pListAll->m_nPipeQ = _tstof(csQ);
|
||
bHasQ = TRUE;
|
||
}
|
||
}
|
||
else if (pListAll->m_iType == 0) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
nCurPipeLength = pPipe->Length();
|
||
// if(!DocGetMeterUnitDraw())
|
||
// nCurPipeLength = nCurPipeLength/1000;
|
||
pListAll->m_nLength = nCurPipeLength;
|
||
}
|
||
OPENOBJ_END();
|
||
CString csNum1 = pListAll->m_pPrevious->m_csName;
|
||
if (!pListAll->m_pPrevious->m_pPrevious && csNum1 == _T(""))
|
||
csNum1 = _T("出口");
|
||
CString csNum2 = pListAll->m_lstNode[0]->m_csName;
|
||
if (csNum1 != _T("") && csNum2 != _T(""))
|
||
pListAll->m_csName = csNum2 + _T("-") + csNum1;
|
||
}
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
pList->m_pPrevious = pListAll;
|
||
CalcDirtWellQ(pList, pListAll, bHasQ);
|
||
pListAll->m_nPipeQ += pList->m_nPipeQ;
|
||
}
|
||
}
|
||
|
||
//小区污水主函数
|
||
void DirtWellCalc()
|
||
{
|
||
Entity entMainPipe, entLongWell;
|
||
RBList rbMaskPipe(RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_DIRT, NULL);
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择排出干管<退出>"), entMainPipe, rbMaskPipe) != RTNORM) {
|
||
return;
|
||
}
|
||
|
||
SSearchPipeList *pListAll = new SSearchPipeList();
|
||
PickSet ssAll(SS_FREE);
|
||
ssAll += entMainPipe;
|
||
if (!GlobalFunc::SearchSprinkPipeSys(entMainPipe, NULL, pListAll, ssAll)) {
|
||
AfxMessageBox(_T("污水系统有回路!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
if (!GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll)) {
|
||
AfxMessageBox(_T("污水系统没有标注管径,请先执行命令[管径标注]"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
|
||
if (pListAll->m_lstNode.Length() == 2) {
|
||
ssAll.Free();
|
||
//计算源头应为节点,而不是管线. 以下计算管线2节点哪个是源头
|
||
CalcWellNum(pListAll);
|
||
SSearchPipeList *p1 = pListAll->m_lstNode[0];
|
||
SSearchPipeList *p2 = pListAll->m_lstNode[1];
|
||
SSearchPipeList *p3 = p1->m_iNum > p2->m_iNum ? p2 : p1;
|
||
|
||
ads_name ent;
|
||
acdbGetAdsName(ent, p3->m_ID);
|
||
delete pListAll;
|
||
pListAll = new SSearchPipeList();
|
||
//重新搜索系统
|
||
if (!GlobalFunc::SearchSprinkPipeSys(ent, NULL, pListAll, ssAll)) {
|
||
AfxMessageBox(_T("污水系统有回路!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll);
|
||
pListAll->m_iType = GlobalFunc::GetNodeType(ent);
|
||
}
|
||
|
||
|
||
SSearchPipeList *pNodeLong = GlobalFunc::GetNextDimNode2(pListAll, NULL);
|
||
if (!SetWellName(pListAll)) {
|
||
AfxMessageBox(_T("没有完整输入井编号!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
BOOL bHasQ(FALSE);
|
||
CalcDirtWellQ(pListAll, NULL, bHasQ);
|
||
if (!bHasQ) {
|
||
AfxMessageBox(_T("没有输入井流量!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
CheckWellSys(pListAll);
|
||
|
||
ssAll.Redraw(3);
|
||
TCHAR szTmp[256];
|
||
int rett = ads_getstring(NULL, _T("\n需要计算的管网系统已高亮显示:<计算>"), szTmp);
|
||
if (rett == RTCAN) {
|
||
ssAll.Redraw(4);
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CCalcDirtWellDlg dlg(0);
|
||
dlg.m_ssAll += ssAll;
|
||
dlg.m_pListAll = pListAll;
|
||
if (dlg.DoModal() != IDOK) {
|
||
ssAll.Redraw(4);
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
ssAll.Redraw(4);
|
||
delete pListAll;
|
||
}
|
||
|
||
//市政污水主函数
|
||
void CivilDirtWellCalc()
|
||
{
|
||
Entity entMainPipe, entLongWell;
|
||
RBList rbMaskPipe(RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_DIRT, NULL);
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择排出干管<退出>"), entMainPipe, rbMaskPipe) != RTNORM) {
|
||
return;
|
||
}
|
||
|
||
SSearchPipeList *pListAll = new SSearchPipeList();
|
||
PickSet ssAll(SS_FREE);
|
||
ssAll += entMainPipe;
|
||
if (!GlobalFunc::SearchSprinkPipeSys(entMainPipe, NULL, pListAll, ssAll)) {
|
||
AfxMessageBox(_T("污水系统有回路!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
if (!GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll)) {
|
||
AfxMessageBox(_T("污水系统没有标注管径,请先执行命令[管径标注]"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
|
||
if (pListAll->m_lstNode.Length() == 2) {
|
||
ssAll.Free();
|
||
//计算源头应为节点,而不是管线. 以下计算管线2节点哪个是源头
|
||
CalcWellNum(pListAll);
|
||
SSearchPipeList *p1 = pListAll->m_lstNode[0];
|
||
SSearchPipeList *p2 = pListAll->m_lstNode[1];
|
||
SSearchPipeList *p3 = p1->m_iNum > p2->m_iNum ? p2 : p1;
|
||
|
||
ads_name ent;
|
||
acdbGetAdsName(ent, p3->m_ID);
|
||
delete pListAll;
|
||
pListAll = new SSearchPipeList();
|
||
//重新搜索系统
|
||
if (!GlobalFunc::SearchSprinkPipeSys(ent, NULL, pListAll, ssAll)) {
|
||
AfxMessageBox(_T("污水系统有回路!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll);
|
||
pListAll->m_iType = GlobalFunc::GetNodeType(ent);
|
||
}
|
||
|
||
|
||
SSearchPipeList *pNodeLong = GlobalFunc::GetNextDimNode2(pListAll, NULL);
|
||
if (!SetWellName(pListAll)) {
|
||
AfxMessageBox(_T("没有完整输入井编号!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
double nAllArea(0);
|
||
BOOL bInput = FALSE;
|
||
// 1.读取各个井的信息,并计算Qd(居民生活污水平均日流量)和总面积
|
||
if (!SetDirtWellInfo(pListAll, nAllArea, bInput) || !bInput) {
|
||
AfxMessageBox(_T("没有完整输入污井信息!"));
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
CheckWellSys(pListAll);
|
||
ssAll.Redraw(3);
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择主干网最远井<系统搜索>:"), entLongWell, rbMask) != RTNORM || !entLongWell.In(&ssAll)) {
|
||
AcDbObjectId id = pNodeLong->m_ID;
|
||
ads_name entTmp;
|
||
acdbGetAdsName(entTmp, id);
|
||
entLongWell = entTmp;
|
||
}
|
||
pNodeLong = GetWellNode(pListAll, entLongWell, NULL);
|
||
|
||
// 2.求比流量。Qa = Qd / ∑A 《给排水管网系统》 p211
|
||
double nQa = pListAll->m_nV / (nAllArea / 10000);
|
||
if (pListAll->m_nV < 0.00001)
|
||
nQa = 0;
|
||
|
||
// 3.根据比流量和各个管道算占的面积,计算各管道设计流量
|
||
DoCalcDesignQ(pListAll, nQa);
|
||
// 4.加上集中流量
|
||
AddFocusQ(pListAll);
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CCalcDirtWellDlg dlg(1);
|
||
dlg.m_ssAll += ssAll;
|
||
dlg.m_pListAll = pListAll;
|
||
dlg.m_pNodeLong = pNodeLong;
|
||
|
||
if (dlg.DoModal() != IDOK) {
|
||
ssAll.Redraw(4);
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
ssAll.Redraw(4);
|
||
delete pListAll;
|
||
}
|
||
|
||
|
||
|
||
TGridDirtWell::TGridDirtWell(int iType)
|
||
{
|
||
if (iType == 0) {
|
||
AppendCol(_T("编号"), 65);
|
||
AppendCol(_T("管长m"), 65);
|
||
AppendCol(_T("管径mm"), 65);
|
||
AppendCol(_T("坡度‰"), 65);
|
||
AppendCol(_T("流量L/s"), 65);
|
||
AppendCol(_T("流速m/s"), 65);
|
||
AppendCol(_T("充满度%"), 65);
|
||
SetColPosFix();
|
||
SetColFixLength();
|
||
SetNoPaste();
|
||
GetCol(2).SetComboEdit();
|
||
GetCol(3).SetComboEdit();
|
||
COLORREF color = RGB(255, 0, 0);
|
||
GetCol(2).SetTextColor(color);
|
||
GetCol(3).SetTextColor(color);
|
||
COLORREF color2 = RGB(0, 0, 255);;
|
||
GetCol(5).SetTextColor(color2);
|
||
GetCol(6).SetTextColor(color2);
|
||
}
|
||
else {
|
||
AppendCol(_T("编号"), 55); // 0
|
||
AppendCol(_T("管长m"), 55); // 1
|
||
AppendCol(_T("管径mm"), 50); // 2
|
||
AppendCol(_T("坡度‰"), 55); // 3
|
||
AppendCol(_T("面积(公顷)"), 62); // 4
|
||
//AppendCol(_T("人口密度(人/公顷)"), 52); // 5
|
||
//AppendCol(_T("污水定额(L/人天)"), 52); // 6
|
||
AppendCol(_T("集中流量L/s"), 52); // 5
|
||
AppendCol(_T("设计流量L/s"), 52); // 6
|
||
AppendCol(_T("流速m/s"), 55); // 7
|
||
AppendCol(_T("充满度%"), 55); // 8
|
||
SetColPosFix();
|
||
SetColFixLength();
|
||
SetNoPaste();
|
||
GetCol(2).SetComboEdit();
|
||
GetCol(3).SetComboEdit();
|
||
COLORREF color = RGB(255, 0, 0);
|
||
GetCol(2).SetTextColor(color);
|
||
GetCol(3).SetTextColor(color);
|
||
COLORREF color2 = RGB(0, 0, 255);;
|
||
GetCol(6).SetTextColor(color2);
|
||
GetCol(7).SetTextColor(color2);
|
||
GetCol(8).SetTextColor(color2);
|
||
}
|
||
}
|
||
|
||
void TGridDirtWell::OnCellComboString(WDGridCell&cell, CComboBox&combo)
|
||
{
|
||
if (cell.GetColIndex() == 2) {
|
||
combo.AddString(_T("200"));
|
||
combo.AddString(_T("250"));
|
||
combo.AddString(_T("300"));
|
||
combo.AddString(_T("350"));
|
||
combo.AddString(_T("400"));
|
||
combo.AddString(_T("450"));
|
||
combo.AddString(_T("500"));
|
||
combo.AddString(_T("600"));
|
||
}
|
||
else if (cell.GetColIndex() == 3) {
|
||
combo.AddString(_T("1"));
|
||
combo.AddString(_T("2"));
|
||
combo.AddString(_T("3"));
|
||
combo.AddString(_T("4"));
|
||
combo.AddString(_T("5"));
|
||
combo.AddString(_T("6"));
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CCalcDirtWellDlg dialog
|
||
|
||
|
||
CCalcDirtWellDlg::CCalcDirtWellDlg(int iType, CWnd* pParent /*=NULL*/)
|
||
: CAcUiDialog(CCalcDirtWellDlg::IDD, pParent), m_ssAll(SS_FREE), m_grid(iType)
|
||
{
|
||
m_iType = iType;
|
||
m_pNodeLong = NULL;
|
||
m_pListAll = NULL;
|
||
//{{AFX_DATA_INIT(CCalcDirtWellDlg)
|
||
//}}AFX_DATA_INIT
|
||
}
|
||
|
||
|
||
void CCalcDirtWellDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CAcUiDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CCalcDirtWellDlg)
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CCalcDirtWellDlg, CAcUiDialog)
|
||
//{{AFX_MSG_MAP(CCalcDirtWellDlg)
|
||
ON_BN_CLICKED(IDC_BUTTON_CALC, OnButtonCalc)
|
||
ON_BN_CLICKED(IDC_BUTTON_DIM, OnButtonDim)
|
||
ON_BN_CLICKED(IDC_BUTTON_WORD, OnButtonWord)
|
||
ON_BN_CLICKED(IDC_BUTTON_HIDE, OnButtonHide)
|
||
ON_BN_CLICKED(IDC_BUTTON_CALC2, OnButtonCalc2)
|
||
ON_WM_DESTROY()
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CCalcDirtWellDlg message handlers
|
||
BOOL CCalcDirtWellDlg::OnInitDialog()
|
||
{
|
||
CAcUiDialog::OnInitDialog();
|
||
if (m_iType == 1) {
|
||
SetWindowText(_T("市政污水水力计算"));
|
||
CRect rect, rect2;
|
||
this->GetWindowRect(&rect);
|
||
rect.right += 30;
|
||
this->MoveWindow(&rect);
|
||
CWnd *pWnd = GetDlgItem(IDC_LIST_PIPE);
|
||
pWnd->GetWindowRect(&rect2);
|
||
ScreenToClient(rect2);
|
||
rect2.right += 30;
|
||
pWnd->MoveWindow(&rect2);
|
||
}
|
||
m_grid.Clear();
|
||
m_grid.Create(this, IDC_LIST_PIPE);
|
||
m_grid.SetNoAppendButton(TRUE);
|
||
m_grid.SetNoDefaultMenu(true);
|
||
if (m_iType == 1)
|
||
UpdateCivilGrid();
|
||
else
|
||
UpdateGrid();
|
||
m_wndToolTip.Create(this);
|
||
m_wndToolTip.Activate(true);
|
||
m_wndToolTip.SetDelayTime(TTDT_INITIAL, 500);
|
||
CWnd *pWnd1 = GetDlgItem(IDOK);
|
||
CWnd *pWnd2 = GetDlgItem(IDC_BUTTON_CALC);
|
||
CWnd *pWnd3 = GetDlgItem(IDC_BUTTON_CALC2);
|
||
CWnd *pWnd4 = GetDlgItem(IDC_BUTTON_HIDE);
|
||
m_wndToolTip.AddTool(pWnd1, _T("初算,未知管径,未知坡度"));
|
||
m_wndToolTip.AddTool(pWnd2, _T("复算,已知管径,已知坡度"));
|
||
m_wndToolTip.AddTool(pWnd3, _T("复算,已知坡度,计算管径"));
|
||
m_wndToolTip.AddTool(pWnd4, _T("隐藏对话框"));
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
//得到下一个计算支路的起点节点 根据流速是否为0且最远
|
||
SSearchPipeList *CCalcDirtWellDlg::GetNextWell(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage, DList<SDirtCalcData> &lstData)
|
||
{
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
BOOL bFind = FALSE;
|
||
for (int j = 0; j < lstData.Length(); j++) {
|
||
if (lstData[j]->m_ID == id) {
|
||
bFind = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
double nCurPipeLength(0);
|
||
if (!bFind && pListAll->m_iType == 3) {
|
||
nCurPipeLength = pListAll->m_nLength;
|
||
if (pDisadvantage) {
|
||
if (nCurPipeLength > pDisadvantage->m_nLength)
|
||
pDisadvantage = pListAll;
|
||
}
|
||
else
|
||
pDisadvantage = pListAll; //条件3: 临时节点为空
|
||
}
|
||
int len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
pDisadvantage = GetNextWell(pList, pDisadvantage, lstData);
|
||
}
|
||
return pDisadvantage;
|
||
}
|
||
|
||
void CCalcDirtWellDlg::UpdateGrid()
|
||
{
|
||
long iCurRow = m_grid.GetCurRowIndex();
|
||
m_grid.Clear();
|
||
DList<SDirtCalcData> lstData;
|
||
DList<SDirtCalcData> lstAll;
|
||
SSearchPipeList *pNodeNext = GetNextWell(m_pListAll, NULL, lstData);
|
||
|
||
while (pNodeNext) {
|
||
SSearchPipeList *pNodeLong = pNodeNext;
|
||
while (pNodeLong) {
|
||
BOOL bFind = FALSE;
|
||
for (int j = 0; j < lstAll.Length(); j++) {
|
||
if (lstAll[j]->m_ID == pNodeLong->m_ID) {
|
||
bFind = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
SDirtCalcData *pNodeNew2 = new SDirtCalcData();
|
||
pNodeNew2->m_ID = pNodeLong->m_ID;
|
||
lstAll.Append(pNodeNew2);
|
||
|
||
if (pNodeLong->m_iType == 0 && pNodeLong->m_nLength > 0) {
|
||
SDirtCalcData *pNodeNew = new SDirtCalcData();
|
||
pNodeNew->m_iDn = pNodeLong->m_iDn;
|
||
if (pNodeLong->m_iType == 0)
|
||
pNodeNew->m_bIsWell = FALSE;
|
||
else
|
||
pNodeNew->m_bIsWell = TRUE;
|
||
pNodeNew->m_ID = pNodeLong->m_ID;
|
||
pNodeNew->m_csName = pNodeLong->m_csName;
|
||
pNodeNew->m_nLength = pNodeLong->m_nLength;
|
||
pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ;
|
||
pNodeNew->m_nI = pNodeLong->m_nI;
|
||
pNodeNew->m_nV = pNodeLong->m_nV;
|
||
pNodeNew->m_nFull = pNodeLong->m_nLost; //充满度
|
||
lstData.Append(pNodeNew);
|
||
}
|
||
if (bFind)
|
||
break;
|
||
|
||
if (pNodeLong->m_pPrevious)
|
||
pNodeLong = pNodeLong->m_pPrevious;
|
||
else
|
||
break;
|
||
}
|
||
pNodeNext = GetNextWell(m_pListAll, NULL, lstAll);
|
||
}
|
||
|
||
int idx = 0;
|
||
for (int i = 0; i < lstData.Length(); i++) {
|
||
if (!lstData[i]->m_bIsWell) { //管
|
||
m_grid.AppendRow();
|
||
int iDn = lstData[i]->m_iDn;
|
||
CString csDn, csPipeLen, csI, csV, csQ, csFull;
|
||
csDn.Format(_T("%d"), iDn);
|
||
csV.Format(_T("%.2f"), lstData[i]->m_nV);
|
||
csI.Format(_T("%.3f"), lstData[i]->m_nI);
|
||
csPipeLen.Format(_T("%.2f"), lstData[i]->m_nLength);
|
||
csQ.Format(_T("%.2f"), lstData[i]->m_nPipeQ);
|
||
csFull.Format(_T("%.2f"), lstData[i]->m_nFull);
|
||
m_grid.GetCell(idx, 0).SetText(lstData[i]->m_csName);
|
||
m_grid.GetCell(idx, 1).SetText(csPipeLen);
|
||
m_grid.GetCell(idx, 2).SetText(csDn);
|
||
m_grid.GetCell(idx, 3).SetText(csI);
|
||
m_grid.GetCell(idx, 4).SetText(csQ);
|
||
m_grid.GetCell(idx, 5).SetText(csV);
|
||
m_grid.GetCell(idx, 6).SetText(csFull);
|
||
idx++;
|
||
}
|
||
|
||
}
|
||
m_grid.SelectRow(iCurRow, TRUE);
|
||
}
|
||
|
||
void CCalcDirtWellDlg::UpdateCivilGrid()
|
||
{
|
||
long iCurRow = m_grid.GetCurRowIndex();
|
||
m_grid.Clear();
|
||
DList<SDirtCalcData> lstData;
|
||
DList<SDirtCalcData> lstAll;
|
||
// SSearchPipeList *pNodeNext = GetNextWell(m_pListAll, NULL, lstData);
|
||
SSearchPipeList *pNodeNext = m_pNodeLong;
|
||
while (pNodeNext) {
|
||
SSearchPipeList *pNodeLong = pNodeNext;
|
||
while (pNodeLong) {
|
||
BOOL bFind = FALSE;
|
||
for (int j = 0; j < lstAll.Length(); j++) {
|
||
if (lstAll[j]->m_ID == pNodeLong->m_ID) {
|
||
bFind = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
SDirtCalcData *pNodeNew2 = new SDirtCalcData();
|
||
pNodeNew2->m_ID = pNodeLong->m_ID;
|
||
lstAll.Append(pNodeNew2);
|
||
|
||
if (pNodeLong->m_iType == 0 && pNodeLong->m_nLength > 0) {
|
||
SDirtCalcData *pNodeNew = new SDirtCalcData();
|
||
pNodeNew->m_iDn = pNodeLong->m_iDn;
|
||
if (pNodeLong->m_iType == 0)
|
||
pNodeNew->m_bIsWell = FALSE;
|
||
else
|
||
pNodeNew->m_bIsWell = TRUE;
|
||
pNodeNew->m_ID = pNodeLong->m_ID;
|
||
pNodeNew->m_csName = pNodeLong->m_csName;
|
||
pNodeNew->m_nLength = pNodeLong->m_nLength;
|
||
pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ;
|
||
|
||
pNodeNew->m_nI = pNodeLong->m_nI;
|
||
pNodeNew->m_nV = pNodeLong->m_nV;
|
||
pNodeNew->m_nFull = pNodeLong->m_nLost;
|
||
pNodeNew->m_nArea = pNodeLong->m_nStartPress;
|
||
double nFocusQ = pNodeLong->m_bNeedCale; //临时用他存一下
|
||
nFocusQ = nFocusQ / 1000;
|
||
pNodeNew->m_nFocusQ = nFocusQ;
|
||
pNodeNew->m_iPeople = pNodeLong->m_iNum;
|
||
pNodeNew->m_nRation = pNodeLong->m_nDang;
|
||
pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ;
|
||
lstData.Append(pNodeNew);
|
||
}
|
||
if (bFind)
|
||
break;
|
||
|
||
if (pNodeLong->m_pPrevious)
|
||
pNodeLong = pNodeLong->m_pPrevious;
|
||
else
|
||
break;
|
||
}
|
||
pNodeNext = GetNextWell(m_pListAll, NULL, lstAll);
|
||
}
|
||
|
||
int idx = 0;
|
||
for (int i = 0; i < lstData.Length(); i++) {
|
||
if (!lstData[i]->m_bIsWell) { //管
|
||
m_grid.AppendRow();
|
||
int iDn = lstData[i]->m_iDn;
|
||
CString csDn, csPipeLen, csI, csV, csQ, csFull, csPeople, csArea;
|
||
CString csRation, csFocusQ, csDesignQ;
|
||
csDn.Format(_T("%d"), iDn);
|
||
csRation.Format(_T("%.1f"), lstData[i]->m_nRation);
|
||
csFocusQ.Format(_T("%.2f"), lstData[i]->m_nFocusQ);
|
||
csArea.Format(_T("%.2f"), lstData[i]->m_nArea / 10000);
|
||
csPeople.Format(_T("%d"), lstData[i]->m_iPeople);
|
||
csV.Format(_T("%.2f"), lstData[i]->m_nV);
|
||
csI.Format(_T("%.3f"), lstData[i]->m_nI);
|
||
csPipeLen.Format(_T("%.2f"), lstData[i]->m_nLength);
|
||
csQ.Format(_T("%.2f"), lstData[i]->m_nPipeQ);
|
||
csFull.Format(_T("%.2f"), lstData[i]->m_nFull);
|
||
m_grid.GetCell(idx, 0).SetText(lstData[i]->m_csName);
|
||
m_grid.GetCell(idx, 1).SetText(csPipeLen);
|
||
m_grid.GetCell(idx, 2).SetText(csDn);
|
||
m_grid.GetCell(idx, 3).SetText(csI);
|
||
m_grid.GetCell(idx, 4).SetText(csArea);
|
||
// m_grid.GetCell(idx, 5).SetText(csPeople);
|
||
// m_grid.GetCell(idx, 6).SetText(csRation);
|
||
m_grid.GetCell(idx, 5).SetText(csFocusQ);
|
||
m_grid.GetCell(idx, 6).SetText(csQ);
|
||
m_grid.GetCell(idx, 7).SetText(csV);
|
||
m_grid.GetCell(idx, 8).SetText(csFull);
|
||
|
||
idx++;
|
||
}
|
||
|
||
}
|
||
m_grid.SelectRow(iCurRow, TRUE);
|
||
}
|
||
|
||
|
||
//计算主模块
|
||
void CCalcDirtWellDlg::DoDirtWellCalc(SSearchPipeList *pListAll, int iMode)
|
||
{
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
ads_name ent;
|
||
double nCurPipeLength(0);
|
||
acdbGetAdsName(ent, id);
|
||
if (pListAll->m_iType == 0 && pListAll->m_nLength > 0) { //管线
|
||
int iDn(0);
|
||
double nN(0.009), nI(0), nFull(0), nV(0);//粗糙系数
|
||
BOOL bMetal = FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
CString csMat = GlobalFunc::GetPipeMaterialByIdx(pPipe->GetMaterial());
|
||
if (csMat.Find(_T("混凝土管")) > -1)
|
||
nN = 0.014;
|
||
else if (csMat.Find(_T("铸铁")) > -1) {
|
||
nN = 0.013;
|
||
bMetal = TRUE;
|
||
}
|
||
else if (csMat.Find(_T("钢")) > -1) {
|
||
nN = 0.012;
|
||
bMetal = TRUE;
|
||
}
|
||
else if (csMat.Find(_T("PVC")) > -1 || csMat.Find(_T("塑料")) > -1)
|
||
nN = 0.009;
|
||
}
|
||
OPENOBJ_END();
|
||
if (pListAll->m_nPipeQ > 0.0001) {
|
||
if (iMode == 0) {//初算
|
||
iDn = GetFirstDirtPipeDnByQ(pListAll->m_nPipeQ, nN, nI, nV, nFull, m_iType);
|
||
}
|
||
else if (iMode == 1) { //复算 已知流量,坡度,管径, 计算流速
|
||
//《给水排水管网系统》PAGE 54 2008-1-9 ywb
|
||
// 步骤1:计算q/q0 公式:q/q0 = (3.208*nN*nQ) / (pow(nRadius, 2.667) * pow(nI, 0.5))
|
||
iDn = pListAll->m_iDn;
|
||
nI = pListAll->m_nI / 1000;
|
||
double nQ = pListAll->m_nPipeQ / 1000;
|
||
double nRadius = (double)iDn / 1000;
|
||
double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
double nTmpQ = (nN * nQ) / sqrt(nTmp);
|
||
// 步骤2:根据q/q0, 查表得充满度 h/D
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
// 步骤3:根据充满度,查表得A/A0
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
// 步骤4:根据A/A0,计算得出流速V 公式:V = (1.273 * nQ) / (nRadius*nRadius * A/A0)
|
||
nV = 1.273 / (nRadius * nRadius) * nQ / nTmpA;
|
||
}
|
||
else if (iMode == 2) {//复算 已知坡度
|
||
nI = pListAll->m_nI / 1000;
|
||
iDn = GetFirstDirtPipeDnByQ2(pListAll->m_nPipeQ, nN, nI, nV, nFull);
|
||
int iDnBig(iDn);
|
||
SSearchPipeList *pList = pListAll->m_lstNode[0]; //得到后节点
|
||
//检查前管的管径是否大于本管,如果大于则本管也按大的管径
|
||
// if(pList->m_lstNode.Length() > 0){
|
||
// for(int mm=0;mm< pList->m_lstNode.Length();mm++){
|
||
// SSearchPipeList *pList4 = pList->m_lstNode[mm];
|
||
// if(pList4->m_iDn > iDnBig)
|
||
// iDnBig = pList4->m_iDn;
|
||
// }
|
||
// if(iDnBig > iDn){
|
||
// iDn = iDnBig;
|
||
// double nRadius = (double)iDn / 1000;
|
||
// double nQ2 = pListAll->m_nPipeQ / 1000;// 把L/S 转化为 M3/S
|
||
// double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
// double nTmpQ = (nN * nQ2) / sqrt(nTmp);
|
||
// nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
// double nTmpA = GetPercentAreaByFull(nFull);
|
||
// nV = 1.27/(nRadius * nRadius) * nQ2 / nTmpA;
|
||
// }
|
||
// }
|
||
|
||
}
|
||
pListAll->m_nI = nI * 1000;
|
||
pListAll->m_nLost = nFull;
|
||
pListAll->m_iDn = iDn;
|
||
pListAll->m_nV = nV;
|
||
}
|
||
}
|
||
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
DoDirtWellCalc(pList, iMode);
|
||
}
|
||
}
|
||
|
||
//计算本段前面最粗的管径
|
||
void CCalcDirtWellDlg::GetBigPipeDn(SSearchPipeList *pList, int &iBigDn)
|
||
{
|
||
if (pList->m_iType == 0) {
|
||
int iDn = pList->m_iDn;
|
||
if (iBigDn < iDn)
|
||
iBigDn = iDn;
|
||
}
|
||
long len = pList->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList2 = pList->m_lstNode[i];
|
||
GetBigPipeDn(pList2, iBigDn);
|
||
}
|
||
}
|
||
|
||
|
||
//复算模块 看看有没有前面的管线管径比本段还大的
|
||
void CCalcDirtWellDlg::DoDirtWellReCalc(SSearchPipeList *pListAll)
|
||
{
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
ads_name ent;
|
||
double nCurPipeLength(0);
|
||
acdbGetAdsName(ent, id);
|
||
if (pListAll->m_iType == 0 && pListAll->m_nLength > 0) { //管线
|
||
int iDn(0);
|
||
double nN(0.009), nI(0), nFull(0), nV(0);//粗糙系数
|
||
BOOL bMetal = FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
CString csMat = GlobalFunc::GetPipeMaterialByIdx(pPipe->GetMaterial());
|
||
if (csMat.Find(_T("混凝土管")) > -1)
|
||
nN = 0.014;
|
||
else if (csMat.Find(_T("铸铁")) > -1) {
|
||
nN = 0.013;
|
||
bMetal = TRUE;
|
||
}
|
||
else if (csMat.Find(_T("钢")) > -1) {
|
||
nN = 0.012;
|
||
bMetal = TRUE;
|
||
}
|
||
else if (csMat.Find(_T("PVC")) > -1 || csMat.Find(_T("塑料")) > -1)
|
||
nN = 0.009;
|
||
}
|
||
OPENOBJ_END();
|
||
if (pListAll->m_nPipeQ > 0.0001) {
|
||
nI = pListAll->m_nI / 1000;
|
||
iDn = GetFirstDirtPipeDnByQ2(pListAll->m_nPipeQ, nN, nI, nV, nFull);
|
||
int iDnBig(0);
|
||
GetBigPipeDn(pListAll, iDnBig);
|
||
if (iDnBig > iDn) {
|
||
iDn = iDnBig;
|
||
double nRadius = (double)iDn / 1000;
|
||
double nQ2 = pListAll->m_nPipeQ / 1000;// 把L/S 转化为 M3/S
|
||
double nTmp = nI / (10.29 / pow(nRadius, 5.333));
|
||
double nTmpQ = (nN * nQ2) / sqrt(nTmp);
|
||
nFull = GlobalFunc::GetFullByPercentQ(nTmpQ);
|
||
double nTmpA = GetPercentAreaByFull(nFull);
|
||
nV = 1.27 / (nRadius * nRadius) * nQ2 / nTmpA;
|
||
}
|
||
pListAll->m_nI = nI * 1000;
|
||
pListAll->m_nLost = nFull;
|
||
pListAll->m_iDn = iDn;
|
||
pListAll->m_nV = nV;
|
||
}
|
||
}
|
||
|
||
long len = pListAll->m_lstNode.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
DoDirtWellReCalc(pList);
|
||
}
|
||
}
|
||
|
||
|
||
//初算
|
||
void CCalcDirtWellDlg::OnOK()
|
||
{
|
||
UpdateData(TRUE);
|
||
DoDirtWellCalc(m_pListAll, 0);
|
||
if (m_iType == 1)
|
||
UpdateCivilGrid();
|
||
else
|
||
UpdateGrid();
|
||
}
|
||
|
||
//复算2
|
||
void CCalcDirtWellDlg::OnButtonCalc2()
|
||
{
|
||
UpdateData(TRUE);
|
||
for (m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()) {
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
CString csName = (LPCTSTR)(*pRow)[0].GetText();
|
||
CString csI = (LPCTSTR)(*pRow)[3].GetText();
|
||
if (csName == _T(""))
|
||
break;
|
||
SSearchPipeList *pList = GlobalFunc::GetPipeNodeByName(m_pListAll, csName, NULL);
|
||
if (pList != NULL) {
|
||
pList->m_nI = _tstof(csI);
|
||
}
|
||
}
|
||
DoDirtWellCalc(m_pListAll, 2);
|
||
DoDirtWellReCalc(m_pListAll);
|
||
if (m_iType == 1)
|
||
UpdateCivilGrid();
|
||
else
|
||
UpdateGrid();
|
||
}
|
||
|
||
void CCalcDirtWellDlg::OnButtonCalc()
|
||
{
|
||
UpdateData(TRUE);
|
||
for (m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()) {
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
CString csName = (LPCTSTR)(*pRow)[0].GetText();
|
||
CString csDn = (LPCTSTR)(*pRow)[2].GetText();
|
||
CString csI = (LPCTSTR)(*pRow)[3].GetText();
|
||
|
||
if (csName == _T(""))
|
||
break;
|
||
SSearchPipeList *pList = GlobalFunc::GetPipeNodeByName(m_pListAll, csName, NULL);
|
||
if (pList != NULL) {
|
||
pList->m_iDn = _ttoi(csDn);
|
||
pList->m_nI = _tstof(csI);
|
||
}
|
||
}
|
||
DoDirtWellCalc(m_pListAll, 1);
|
||
if (m_iType == 1)
|
||
UpdateCivilGrid();
|
||
else
|
||
UpdateGrid();
|
||
}
|
||
|
||
//extern void UpdateMultDim();
|
||
extern bool g_bPipeShow; // cet 2012.1.10 add 图面赋值控制变量
|
||
extern int g_nSelType; // cet 2012.1.10 add 图面赋值控制变量
|
||
void CCalcDirtWellDlg::OnButtonDim()
|
||
{
|
||
UpdateData(TRUE);
|
||
BeginEditorCommand();
|
||
|
||
XPoint ptLow, ptUp;
|
||
m_ssAll.GetExtend(ptLow, ptUp);
|
||
GlobalFunc::AssureInCurrentView(ptLow, ptUp);
|
||
|
||
// cet 2012.1.10 add
|
||
g_bPipeShow = false;
|
||
g_nSelType = -1;
|
||
TCHAR szTmp[32];
|
||
DimRainCalcResult(m_pListAll);
|
||
acedRedraw(0, 0); // cet 2012.1.10 add 刷新清除显示管线时的X
|
||
GlobalFunc::UpdateMultDim();
|
||
actrTransactionManager->flushGraphics(); //acad 刷新
|
||
|
||
ads_getstring(NULL, _T("\n数据已经赋回图面,n按任意键返回对话框:<返回>"), szTmp);
|
||
|
||
CompleteEditorCommand();
|
||
|
||
}
|
||
|
||
void CCalcDirtWellDlg::OnButtonWord()
|
||
{
|
||
DList<SDirtCalcData> lstData;
|
||
DList<SDirtCalcData> lstAll;
|
||
SSearchPipeList *pNodeNext = GetNextWell(m_pListAll, NULL, lstAll);
|
||
if (m_pNodeLong != NULL)
|
||
pNodeNext = m_pNodeLong;
|
||
|
||
while (pNodeNext) {
|
||
SSearchPipeList *pNodeLong = pNodeNext;
|
||
while (pNodeLong) {
|
||
BOOL bFind = FALSE;
|
||
for (int j = 0; j < lstAll.Length(); j++) {
|
||
if (lstAll[j]->m_ID == pNodeLong->m_ID) {
|
||
bFind = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
SDirtCalcData *pNodeNew2 = new SDirtCalcData();
|
||
pNodeNew2->m_ID = pNodeLong->m_ID;
|
||
lstAll.Append(pNodeNew2);
|
||
|
||
if (pNodeLong->m_iType == 0 && pNodeLong->m_nLength > 0) {
|
||
SDirtCalcData *pNodeNew = new SDirtCalcData();
|
||
pNodeNew->m_iDn = pNodeLong->m_iDn;
|
||
pNodeNew->m_ID = pNodeLong->m_ID;
|
||
pNodeNew->m_csName = pNodeLong->m_csName;
|
||
pNodeNew->m_nLength = pNodeLong->m_nLength;
|
||
pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ;
|
||
pNodeNew->m_nI = pNodeLong->m_nI;
|
||
pNodeNew->m_nV = pNodeLong->m_nV;
|
||
pNodeNew->m_nFull = pNodeLong->m_nLost; //充满度
|
||
lstData.Append(pNodeNew);
|
||
}
|
||
if (bFind)
|
||
break;
|
||
|
||
if (pNodeLong->m_pPrevious)
|
||
pNodeLong = pNodeLong->m_pPrevious;
|
||
else
|
||
break;
|
||
}
|
||
pNodeNext = GetNextWell(m_pListAll, NULL, lstAll);
|
||
}
|
||
|
||
ImportDirtWellCalcWord(lstData);
|
||
}
|
||
|
||
|
||
|
||
void CCalcDirtWellDlg::OnButtonHide()
|
||
{
|
||
long idx = m_grid.GetCurRowIndex();
|
||
CString csName1;
|
||
if (idx > -1) {
|
||
WDGridRow *pRow = &m_grid.GetRow(idx);
|
||
if (pRow)
|
||
csName1 = (*pRow)[0].GetText();
|
||
}
|
||
if (csName1 != _T("")) {
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("X"), NULL, NULL, rbMask);
|
||
long len = ss.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
CString csName = pEquip->GetWellName();
|
||
if (csName1.Find(csName) > -1) {
|
||
XPoint ptCen = pEquip->GetLocation();
|
||
GlobalFunc::ArxZoomTo(ptCen, 10 * pEquip->GetPScale(), 10 * pEquip->GetPScale());
|
||
double nDist = pEquip->GetPScale();
|
||
XPoint p1, p2, p3, p4;
|
||
ads_polar(ptCen, 0, nDist, p1);
|
||
ads_polar(p1, PI / 2, nDist, p1);
|
||
ads_polar(ptCen, PI, nDist, p2);
|
||
ads_polar(p2, PI / 2, -nDist, p2);
|
||
ads_grdraw(p1, p2, 2, 0);
|
||
ads_polar(ptCen, PI / 2, nDist, p3);
|
||
ads_polar(p3, PI, nDist, p3);
|
||
ads_polar(ptCen, PI / 2, -nDist, p4);
|
||
ads_polar(p4, 0, nDist, p4);
|
||
ads_grdraw(p3, p4, 2, 0);
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
GlobalFunc::HideDialog(this, TRUE);
|
||
TCHAR szTmp[256];
|
||
ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp);
|
||
GlobalFunc::HideDialog(this, FALSE);
|
||
}
|
||
|
||
|
||
BOOL CCalcDirtWellDlg::PreTranslateMessage(MSG* pMsg)
|
||
{
|
||
if (pMsg->message >= WM_MOUSEFIRST &&
|
||
pMsg->message <= WM_MOUSELAST)
|
||
{
|
||
MSG msg;
|
||
::CopyMemory(&msg, pMsg, sizeof(MSG));
|
||
HWND hWndParent = ::GetParent(msg.hwnd);
|
||
if (msg.hwnd)
|
||
{
|
||
m_wndToolTip.RelayEvent(&msg);
|
||
}
|
||
}
|
||
return CAcUiDialog::PreTranslateMessage(pMsg);
|
||
}
|
||
|
||
void CCalcDirtWellDlg::OnDestroy()
|
||
{
|
||
CAcUiDialog::OnDestroy();
|
||
m_wndToolTip.DestroyWindow();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|