📄 exceptiondatatest.cpp
字号:
// ExceptionDataTest.cpp : implementation file
//
#include "stdafx.h"
#include "CBA_SYSTEM.h"
#include "ExceptionDataTest.h"
#include "Neural_NetWork.h"
#include "CBADlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CCBADlg *ptempDlg;
/////////////////////////////////////////////////////////////////////////////
// CExceptionDataTest dialog
CExceptionDataTest::CExceptionDataTest(CWnd* pParent /*=NULL*/)
: CDialog(CExceptionDataTest::IDD, pParent)
{
//{{AFX_DATA_INIT(CExceptionDataTest)
m_cardid = _T("");
m_cy = _T("");
m_pq = _T("");
m_sm = 0.0f;
m_spcode = _T("");
m_sptype = 0;
m_time = _T("");
m_timestep = 0;
m_ty = 0;
m_id = _T("");
m_shtype = 0;
//}}AFX_DATA_INIT
}
CExceptionDataTest::~CExceptionDataTest()
{
}
void CExceptionDataTest::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExceptionDataTest)
DDX_Text(pDX, IDC_CARDID_EDIT, m_cardid);
DDX_Text(pDX, IDC_CY_EDIT, m_cy);
DDX_Text(pDX, IDC_PQ_EDIT, m_pq);
DDX_Text(pDX, IDC_SM_EDIT, m_sm);
DDX_Text(pDX, IDC_SPCODE_EDIT, m_spcode);
DDX_Text(pDX, IDC_SPTYPE_EDIT, m_sptype);
DDX_Text(pDX, IDC_TIME_EDIT, m_time);
DDX_Text(pDX, IDC_TIME_STEP_EDIT, m_timestep);
DDX_Text(pDX, IDC_TY_EDIT, m_ty);
DDX_Text(pDX, IDC_ID_EDIT, m_id);
DDX_Control(pDX,IDC_DATATESTBUTTON,m_test);
DDX_Text(pDX, IDC_SHTYPE_EDIT, m_shtype);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExceptionDataTest, CDialog)
//{{AFX_MSG_MAP(CExceptionDataTest)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_DATATESTBUTTON, OnDatatestbutton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExceptionDataTest message handlers
void CExceptionDataTest::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(255,255,255)); //设置为白色背景
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CExceptionDataTest::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HBRUSH CExceptionDataTest::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STATIC)
{
// Set the text color to red
hbr = CreateSolidBrush(RGB(255,255,255));
pDC->SetTextColor(RGB(0, 0, 0));
// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object
//hbr = m_brush;
}
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CExceptionDataTest::OnDatatestbutton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString ID,CardID,Spcode,Shtype,Cy,Pq,Ti,Sm,Ty,Sptype,Time_step;
ID = m_id;
CardID= m_cardid;
Spcode = m_spcode;
Shtype.Format("%d",m_shtype);
Cy = m_cy;
Pq = m_pq;
//Ti = m_time;
Sm.Format("%f",m_sm);
Ty.Format("%d",m_ty);
Sptype.Format("%d",m_sptype);
Time_step.Format("%d",m_timestep);
Ti="to_date('"+m_time+"'"+","+"'yyyy-MM-dd hh24:mi:ss')";
if(ado.ReadConfigFile("DataConfig.txt"))
{
if(ado.OnInitADOConn())
{
_bstr_t str_SQL;
str_SQL = (_bstr_t)(LPCTSTR)("insert into testdata values("+ID+","+CardID+",'"+Spcode+"',"+Shtype+",'"+Cy+"','"+Pq+"',"+Ti+","+Sm+","+Ty+","+Sptype+","+Time_step+")");
ado.ExecuteSQL(str_SQL);
ado.GetData(data,"select * from testdatazxd");
ado.ExecuteSQL("delete from testdatazxd");
ado.ExecuteSQL("delete from testdata");
ado.ExitConnect();
RunNetWork();
}
else
{
MessageBox("初始化数据库连接失败,请检查配置!",NULL,MB_OK|MB_ICONINFORMATION);
return;
}
}
else
{
MessageBox("数据库连接失败,请检查配置!",NULL,MB_OK|MB_ICONINFORMATION);
return;
}
}
void CExceptionDataTest::RunNetWork()
{
//CCBADlg tempDlg;
CString tempstr="";
float reslut;
CNeural_NetWork Network(ptempDlg->GetNumberofHlayer());
NumberofIlayerNode = Network.ReadFromSaveFile("NumOfIlayerNodes.txt");
NumberofOlayerNode = Network.ReadFromSaveFile("NumOfOlayerNodes.txt");
p_num_HNodes = Network.ReadPHFromSaveFile("NumOfHlayerNodes.txt");
p_num_HNodesPy = Network.ReadPFromSaveFile("HlayesBas.txt");
p_num_INodesPy = Network.ReadPFromSaveFile("OlayesBas.txt");
m_wp = Network.ReadWFromSaveFile("w.txt");
Network.InitNeural_NetWork(NumberofIlayerNode,NumberofOlayerNode,p_num_HNodes,p_num_HNodesPy,p_num_INodesPy,m_wp);
reslut = Network.GetOvalue(data);
tempstr.Format("%f",reslut);
delete []p_num_HNodes;
delete []p_num_HNodesPy;
delete []p_num_INodesPy;
delete []m_wp;
MessageBox(tempstr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -