📄 gas.cpp
字号:
// Gas.cpp : implementation file
//
#include "stdafx.h"
#include "HtacBall.h"
#include "Gas.h"
#include "Comb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGas dialog
CGas::CGas(CWnd* pParent /*=NULL*/)
: CDialog(CGas::IDD, pParent)
{
//{{AFX_DATA_INIT(CGas)
m_airdemand = 0.0f;
m_airfactor = 0.0f;
m_C2H4 = 0.0f;
m_CH4 = 0.0f;
m_CO = 0.0f;
m_CO2 = 0.0f;
m_consumption = 0.0f;
m_fume = 0.0f;
m_H2 = 0.0f;
m_N2 = 0.0f;
m_O2 = 0.0f;
m_ratio = 0.0f;
m_tem = 0.0f;
m_heatvalue = 0.0f;
m_BurnerP = 0.0f;
//}}AFX_DATA_INIT
}
void CGas::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGas)
DDX_Control(pDX, IDC_LIST1, m_list1);
DDX_Text(pDX, IDC_GAS_AIRDEMAND, m_airdemand);
DDX_Text(pDX, IDC_GAS_AIRFACTOR, m_airfactor);
DDX_Text(pDX, IDC_GAS_C2H4, m_C2H4);
DDX_Text(pDX, IDC_GAS_CH4, m_CH4);
DDX_Text(pDX, IDC_GAS_CO, m_CO);
DDX_Text(pDX, IDC_GAS_CO2, m_CO2);
DDX_Text(pDX, IDC_GAS_CONSUMPTION, m_consumption);
DDX_Text(pDX, IDC_GAS_FUME, m_fume);
DDX_Text(pDX, IDC_GAS_H2, m_H2);
DDX_Text(pDX, IDC_GAS_N2, m_N2);
DDX_Text(pDX, IDC_GAS_O2, m_O2);
DDX_Text(pDX, IDC_GAS_RATIO, m_ratio);
DDX_Text(pDX, IDC_GAS_TEM, m_tem);
DDX_Text(pDX, IDC_GAS_HEATVALUE, m_heatvalue);
DDX_Text(pDX, IDC_BurnerP, m_BurnerP);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGas, CDialog)
//{{AFX_MSG_MAP(CGas)
ON_BN_CLICKED(IDCOMPUTE, OnCompute)
ON_BN_CLICKED(ID_FILE_OPEN, OnFileOpen)
ON_BN_CLICKED(ID_FILE_SAVE_AS, OnFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGas message handlers
void CGas::OnCompute()
{
float n,cf[9],gan;
//float CO2,H2O,N2;
CString str;
char O2[100];
Comb comb1;
UpdateData(TRUE); //燃料燃烧计算模块
cf[0]=m_CO2;
cf[1]=m_CO;
cf[2]=m_N2;
cf[3]=m_O2;
cf[4]=m_H2;
cf[5]=m_CH4;
cf[6]=m_C2H4;
cf[7]=0;
cf[8]=0;
gan=comb1.InputTemp(m_tem); //输入了煤气的温度
comb1.InputChengfen(cf); //输入了煤气成分
comb1.FKH2O(gan); //空气中的水分含量计算
comb1.Convert(); //将空气干成分转化为湿成分
n=m_airfactor;//空气消耗系数
m_airdemand=float(int(comb1.FLn(n)*100))/100;//实际空气需要量
m_heatvalue=float(int(comb1.Rezhi()*100))/100; //煤气发热量KJ/m^3
comb1.FVo2(n);
m_fume=float(int(comb1.FVn()*100))/100;
//烟气生成量
m_BurnerP=m_heatvalue*m_consumption;
//燃烧器功率=煤气发热量、煤气消耗量kW
m_list1.InitStorage(10,4);
m_list1.ResetContent();
sprintf(O2,"%0.2f ",float(int(100*comb1.O2()*100))/100);
strcat(O2," :O2");
m_list1.AddString(O2);
m_fume_o2=100*comb1.O2();
sprintf(O2,"%0.2f ",float(int(100*comb1.N2()*100))/100);
strcat(O2," :N2");
m_list1.AddString(O2);
m_fume_n2=100*comb1.N2();
sprintf(O2,"%0.2f ",float(int(100*comb1.CO2()*100))/100);
strcat(O2," :CO2");
m_list1.AddString(O2);
m_fume_co2=100*comb1.CO2();
sprintf(O2,"%0.2f ",float(int(100*comb1.SO2()*100))/100);
strcat(O2," :SO2");
m_list1.AddString(O2);
m_fume_so2=100*comb1.SO2();
sprintf(O2,"%0.2f ",float(int(100*comb1.FH2O()*100))/100);
strcat(O2," :H2O");
m_list1.AddString(O2);
m_fume_h2o=100*comb1.FH2O();
UpdateData(FALSE);
}
void CGas::OnFileOpen()
{
CFileDialog OpenDialog(TRUE, // Open...
"hbg", // default filename extension
NULL, // initial filename
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, // options
"Data Files(*.hbg)|*.hbg|All Files(*.*)|*.*||", // two filters for modules
this);
CString sz;
CFile file;
if ( OpenDialog.DoModal() == IDOK )
{
sz=OpenDialog.GetFileName();
file.Open(sz,CFile::modeRead);
float pbuf[15];
int byte=file.Read(pbuf,15*sizeof(float));
m_CO2=pbuf[0];
m_CO=pbuf[1];
m_O2=pbuf[2];
m_N2=pbuf[3];
m_H2=pbuf[4];
m_CH4=pbuf[5];
m_C2H4=pbuf[6];
m_tem=pbuf[7];
m_consumption=pbuf[8];
m_airfactor=pbuf[9];
//m_heatvalue=pbuf[10];
//m_airdemand=pbuf[11];
//m_list1=pbuf[4];
// m_fume=pbuf[12];
m_ratio=pbuf[13];
// m_BurnerP=pbuf[14];
UpdateData(false);
file.Close();
}
}
void CGas::OnFileSaveAs()
{
CFileDialog SaveDialog(FALSE, // Open...
"hbg", // default filename extension
NULL, // initial filename
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, // options
"Data Files(*.hbg)|*.hbg|All Files(*.*)|*.*||", // two filters for modules
this);
CString sz;
CFile file;
if (SaveDialog.DoModal() == IDOK)
{
sz=SaveDialog.GetFileName();
file.Open(sz,CFile::modeCreate|CFile::modeWrite);
float pbuf[15];
UpdateData(true);
pbuf[0]=m_CO2;
pbuf[1]=m_CO;
pbuf[2]=m_O2;
pbuf[3]=m_N2;
pbuf[4]=m_H2;
pbuf[5]=m_CH4;
pbuf[6]=m_C2H4;
pbuf[7]=m_tem;
pbuf[8]=m_consumption;
pbuf[9]=m_airfactor;
pbuf[10]=m_heatvalue;
pbuf[11]=m_airdemand;
//m_list1=pbuf[4];
pbuf[12]=m_fume;
pbuf[13]=m_ratio;
pbuf[14]=m_BurnerP;
file.Write(pbuf,15*sizeof(float));
file.Close();
}
}
void CGas::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -