Files
envi-code/SourceCode/Code2026/tg_shs/shs_TwtCalc/HydrantCalcDlg.cpp
T

428 lines
9.9 KiB
C++
Raw Normal View History

2026-09-28 15:28:50 +08:00
// HydrantCalcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HydrantCalcDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHydrantCalcDlg dialog
void HydrantCalc()
{
CTemporaryResourceOverride vTemp;
CHydrantCalcDlg dlg;
dlg.DoModal();
}
CHydrantCalcDlg::CHydrantCalcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHydrantCalcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHydrantCalcDlg)
m_iGun = 2;
m_iLen = 1;
m_iMat = 1;
m_csQ = _T("5");
m_iRaius = 1;
m_csWaterLen = _T("10");
m_iWant = 0;
m_csRetPress = _T("");
m_csRet = _T("");
m_csRetRadius = _T("");
//}}AFX_DATA_INIT
}
void CHydrantCalcDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHydrantCalcDlg)
DDX_CBIndex(pDX, IDC_COMBO_GUN, m_iGun);
DDX_CBIndex(pDX, IDC_COMBO_LEN, m_iLen);
DDX_CBIndex(pDX, IDC_COMBO_MAT, m_iMat);
DDX_CBString(pDX, IDC_COMBO_Q, m_csQ);
DDX_CBIndex(pDX, IDC_COMBO_RADIUS, m_iRaius);
DDX_CBString(pDX, IDC_COMBO_WATER_LEN, m_csWaterLen);
DDX_Radio(pDX, IDC_RADIO_WANT1, m_iWant);
DDX_Text(pDX, IDC_EDIT_RET_PRESS, m_csRetPress);
DDX_Text(pDX, IDC_EDIT_RET, m_csRet);
DDX_Text(pDX, IDC_EDIT_RADIUS, m_csRetRadius);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHydrantCalcDlg, CDialog)
//{{AFX_MSG_MAP(CHydrantCalcDlg)
ON_BN_CLICKED(IDC_RADIO_WANT1, OnRadioWant1)
ON_BN_CLICKED(IDC_RADIO_WANT2, OnRadioWant2)
ON_CBN_SELCHANGE(IDC_COMBO_GUN, OnSelchangeComboGun)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHydrantCalcDlg message handlers
BOOL CHydrantCalcDlg::OnInitDialog()
{
CDialog::OnInitDialog();
OnRadioWant1();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
double GetWaterLenByTable(int iRadius, double nQxh)
{//<<白手册>> P75
if(iRadius == 0){ //13
if(nQxh <= 1.7)
return 6;
else if(nQxh>1.7 && nQxh<=1.8)
return 7;
else if(nQxh>1.8 && nQxh<=2.0)
return 8;
else if(nQxh>2.0 && nQxh<=2.1)
return 9;
else if(nQxh>2.1 && nQxh<=2.3)
return 10;
else if(nQxh>2.3 && nQxh<=2.4)
return 11;
else if(nQxh>2.4 && nQxh<=2.5)
return 11.5;
else if(nQxh>2.5 && nQxh<=2.6)
return 12;
else if(nQxh>2.6 && nQxh<=2.7)
return 12.5;
else if(nQxh>2.7 && nQxh<=2.9)
return 13;
else if(nQxh>2.9 && nQxh<=3.0)
return 13.5;
else if(nQxh>3.0 && nQxh<=3.2)
return 14;
else if(nQxh>3.2 && nQxh<=3.4)
return 15;
else if(nQxh>3.4 && nQxh<=3.6)
return 15.5;
// cet 2012.11.30 modify
// else if(nQxh>3.6)
// return 16;
else if (nQxh > 3.6 && nQxh <= 3.8)
return 16;
else if (nQxh > 3.8)
return 17;
}
else if(iRadius == 1){//16
if(nQxh <= 2.5)
return 6;
else if(nQxh>2.5 && nQxh<=2.7)
return 7;
else if(nQxh>2.7 && nQxh<=2.9)
return 8;
else if(nQxh>2.9 && nQxh<=3.1)
return 9;
else if(nQxh>3.1 && nQxh<=3.3)
return 10;
else if(nQxh>3.3 && nQxh<=3.5)
return 11;
else if(nQxh>3.5 && nQxh<=3.8)
return 12;
else if(nQxh>3.8 && nQxh<=4.0)
return 12.5;
else if(nQxh>4.0 && nQxh<=4.2)
return 13;
else if(nQxh>4.2 && nQxh<=4.4)
return 13.5;
else if(nQxh>4.4 && nQxh<=4.6)
return 14;
else if(nQxh>4.6 && nQxh<=4.8)
return 15;
else if(nQxh>4.8 && nQxh<=5.1)
return 15.5;
// cet 2012.11.30 modify
// else if(nQxh>5.1)
// return 16;
else if (nQxh > 5.1 && nQxh <= 5.3)
return 16;
else if (nQxh > 5.3)
return 17;
}
else if(iRadius == 2){//19
if(nQxh <= 3.5)
return 6;
else if(nQxh>3.5 && nQxh<=3.8)
return 7;
else if(nQxh>3.8 && nQxh<=4.1)
return 8;
else if(nQxh>4.1 && nQxh<=4.3)
return 9;
else if(nQxh>4.3 && nQxh<=4.6)
return 10;
else if(nQxh>4.6 && nQxh<=4.9)
return 11;
else if(nQxh>4.9 && nQxh<=5.0)
return 11.3;
else if(nQxh>5.0 && nQxh<=5.2)
return 12;
else if(nQxh>5.2 && nQxh<=5.4)
return 12.5;
else if(nQxh>5.4 && nQxh<=5.7)
return 13;
else if(nQxh>5.7 && nQxh<=6.0)
return 13.5;
else if(nQxh>6.0 && nQxh<=6.2)
return 14;
else if(nQxh>6.2 && nQxh<=6.5)
return 15;
else if(nQxh>6.5 && nQxh<=6.8)
return 15.5;
// cet 2012.11.30 modify
// else if(nQxh>5.8)
// return 16;
else if (nQxh > 6.8 && nQxh <= 7.1)
return 16;
else if (nQxh > 7.1)
return 17;
}
else if(iRadius == 3){ // 22 cet 2012.11.30 add 数据来源zj
if(nQxh <= 4.6)
return 6;
else if(nQxh>4.6 && nQxh<=5.0)
return 7;
else if(nQxh>5.0 && nQxh<=5.4)
return 8;
else if(nQxh>5.4 && nQxh<=5.7)
return 9;
else if(nQxh>5.7 && nQxh<=6.1)
return 10;
else if(nQxh>6.1 && nQxh<=6.4)
return 11;
else if(nQxh>6.4 && nQxh<=6.8)
return 12;
else if(nQxh>6.8 && nQxh<=7.0)
return 12.5;
else if(nQxh>7.0 && nQxh<=7.1)
return 13;
else if(nQxh>7.1 && nQxh<=7.3)
return 13.5;
else if(nQxh>7.3 && nQxh<=7.5)
return 14;
else if(nQxh>7.5 && nQxh<=7.8)
return 15;
else if(nQxh>7.8 && nQxh<=8.0)
return 15.5;
else if (nQxh > 8.0 && nQxh <= 8.1)
return 16;
else if (nQxh > 8.1)
return 17;
}
else if(iRadius == 4){ // 25 cet 2012.11.30 add 数据来源zj
if(nQxh <= 6.0)
return 6;
else if(nQxh>6.0 && nQxh<=6.4)
return 7;
else if(nQxh>6.4 && nQxh<=6.9)
return 8;
else if(nQxh>6.9 && nQxh<=7.4)
return 9;
else if(nQxh>7.4 && nQxh<=7.8)
return 10;
else if(nQxh>7.8 && nQxh<=8.2)
return 11;
else if(nQxh>8.2 && nQxh<=8.6)
return 12;
else if(nQxh>8.6 && nQxh<=8.8)
return 12.5;
else if(nQxh>8.8 && nQxh<=9.1)
return 13;
else if(nQxh>9.1 && nQxh<=9.3)
return 13.5;
else if(nQxh>9.3 && nQxh<=9.5)
return 14;
else if(nQxh>9.5 && nQxh<=9.9)
return 15;
else if(nQxh>9.9 && nQxh<=10.1)
return 15.5;
else if (nQxh > 10.1 && nQxh <= 10.3)
return 16;
else if (nQxh > 10.3)
return 17;
}
return 0;
}
void CHydrantCalcDlg::OnOK()
{
UpdateData();
double nHq(0), nOutQ(0), B(0), nHd(0), nAz(0), nLen(0), nFactor(0), nAf(0), nHm(0);
if(m_iGun == 0){ //水枪喷嘴13
B = 0.346;
nFactor = 0.0165;
}
else if(m_iGun == 1){ //水枪喷嘴16
B = 0.793;
nFactor = 0.0124;
}
else if(m_iGun == 2){ //水枪喷嘴19
B = 1.577;
nFactor = 0.0097;
}
else if (m_iGun == 3) //水枪喷嘴22 cet 2012.11.30 add
{
B = 2.834;
nFactor = 0.00766;
}
else if (m_iGun == 4) //水枪喷嘴25 cet 2012.11.30 add
{
B = 4.727;
nFactor = 0.00615;
}
if(m_iMat == 0){ //衬胶
if(m_iRaius == 0) // 水龙带直径50
nAz = 0.00677;
else if (m_iRaius == 2) // 水龙带直径80 cet 2012.11.30 add
{
nAz = 0.00075;
}
else
nAz = 0.00172;// 水龙带直径65
}
else{ //麻织
if(m_iRaius == 0) // 水龙带直径50
nAz = 0.01501;
else if (m_iRaius == 2) // 水龙带直径80 cet 2012.11.30 add
{
nAz = 0.0015;
}
else
nAz = 0.0043; // 水龙带直径65
}
// cet 2012.11.30 modify
// if(m_iLen == 0)
// nLen = 25;
// else
// nLen = 20;
if (m_iLen == 0)
{
nLen = 15;
}
else if (m_iLen == 1)
{
nLen = 20;
}
else if (m_iLen == 2)
{
nLen = 25;
}
else if (m_iLen == 3)
{
nLen = 30;
}
if(m_iWant == 0){ //已知消火栓出水量算:水柱长度+栓口压力
//公式:Hxh = Hd + Hq = Ad*Ld*q^2+ q^2/B 白手册 P79
nOutQ = _tstof(m_csQ);
if(nOutQ > 11 || (m_iGun == 1 && nOutQ > 6) || (m_iGun == 0 && nOutQ > 4)
|| (m_iGun == 2 && nOutQ > 7.5) || (m_iGun == 3 && nOutQ > 8.5)){
MessageBox(_T("消火栓出水量太大"));
return;
}
nHq = nOutQ * nOutQ / B;
nHd = nAz * nLen * nOutQ * nOutQ;
nHd += nHq;
nHd += 2;//<<技术措施>> P165 消火栓栓口水头损失 0.02MPa
m_csRetPress.Format(_T("%.2f"), nHd);
//虽然要求Hm充实水柱长度,但Af也需要这个值,只好先查表, 沈睿 2005-2-2
double nTmpWaterLen = GetWaterLenByTable(m_iGun, nOutQ);
nAf = 1.19 + 80*(0.01*nTmpWaterLen)*(0.01*nTmpWaterLen)*(0.01*nTmpWaterLen)*(0.01*nTmpWaterLen);
double nTemp = nAf*nFactor;
//注意:公式中单位是kPa, 这里全是m
nTemp = nTemp*nHq + nAf;
nHm = nHq/nTemp;
m_csRet.Format(_T("%.2f"), nHm);
}
else{ //已知消火栓水柱长度算:出水量+栓口压力
nHm = _tstof(m_csWaterLen);
nAf = 1.19 + 80*(0.01*nHm)*(0.01*nHm)*(0.01*nHm)*(0.01*nHm);
nHq = nAf*nHm*10/(1- nFactor*nAf*nHm);
nHq = nHq / 10; // kPa -> m
nOutQ = sqrt(B*nHq);
m_csRet.Format(_T("%.2f"), nOutQ);
nHd = nAz * nLen * nOutQ * nOutQ;
nHd += nHq;
nHd += 2;//<<技术措施>> P165 消火栓栓口水头损失 0.02MPa
m_csRetPress.Format(_T("%.2f"), nHd);
}
//计算消火栓保护半径 R = C*Ld + h
//C = 0.8 ~ 0.9
//Ld 水带长度
//h = Hm * sin(45) Hm 充实水柱长度
double nRadius(0);
nRadius = 0.8*nLen + nHm * sin(45.0 / 180.0 * PI);
m_csRetRadius.Format(_T("%.2f"), nRadius);
UpdateData(FALSE);
}
void CHydrantCalcDlg::OnRadioWant1()
{
UpdateData();
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_Q);
CWnd *pWnd2 = GetDlgItem(IDC_COMBO_WATER_LEN);
CWnd *pWnd3 = GetDlgItem(IDC_STATIC_RET);
if(m_iWant == 0){
pWnd1->EnableWindow(TRUE);
pWnd2->EnableWindow(FALSE);
pWnd3->SetWindowText(_T("充实水柱长度(m):"));
}
else{
pWnd1->EnableWindow(FALSE);
pWnd2->EnableWindow(TRUE);
pWnd3->SetWindowText(_T("消火栓出水量(L/S):"));
}
}
void CHydrantCalcDlg::OnRadioWant2()
{
UpdateData();
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_Q);
CWnd *pWnd2 = GetDlgItem(IDC_COMBO_WATER_LEN);
CWnd *pWnd3 = GetDlgItem(IDC_STATIC_RET);
if(m_iWant == 0){
pWnd1->EnableWindow(TRUE);
pWnd2->EnableWindow(FALSE);
pWnd3->SetWindowText(_T("充实水柱长度(m):"));
}
else{
pWnd1->EnableWindow(FALSE);
pWnd2->EnableWindow(TRUE);
pWnd3->SetWindowText(_T("消火栓出水量(L/S):"));
}
}
void CHydrantCalcDlg::OnSelchangeComboGun()
{
int nGun = m_iGun; // 前一选择值 cet 2012.11.30 add
UpdateData();
if(m_iGun == 0) //水枪喷嘴13
m_iRaius = 0;
else if(m_iGun == 2) //水枪喷嘴16
m_iRaius = 1;
else if (m_iGun == 3 || m_iGun == 4) //水枪喷嘴22\25 cet 2012.11.30 add
{
m_iRaius = 2;
}
else if (m_iGun == 1) //水枪喷嘴16 cet 2012.11.30 add
{
if (m_iRaius == 2)
{
m_iRaius = 0;
}
}
UpdateData(FALSE);
}