?? fuzzy2004view.cpp
字號(hào):
// fuzzy2004View.cpp : implementation of the CFuzzy2004View class
//
#include "stdafx.h"
#include "fuzzy2004.h"
#include "fuzzy2004Set.h"
#include "fuzzy2004Doc.h"
#include "fuzzy2004View.h"
//數(shù)據(jù)庫頭文件
#include "Rain.h"
#include "Provide.h"
#include "Despoit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View
IMPLEMENT_DYNCREATE(CFuzzy2004View, CRecordView)
BEGIN_MESSAGE_MAP(CFuzzy2004View, CRecordView)
//{{AFX_MSG_MAP(CFuzzy2004View)
ON_BN_CLICKED(IDC_BUTTON_GET1, OnButtonGet1)
ON_BN_CLICKED(IDC_BUTTON_READ, OnButtonRead)
ON_BN_CLICKED(IDC_BUTTON_COUNT, OnButtonCount)
ON_BN_CLICKED(IDC_BUTTON_EXIT, OnButtonExit)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_TIMER()
ON_WM_CANCELMODE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View construction/destruction
CFuzzy2004View::CFuzzy2004View()
: CRecordView(CFuzzy2004View::IDD)
{
//{{AFX_DATA_INIT(CFuzzy2004View)
// NOTE: the ClassWizard will add member initialization here
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CFuzzy2004View::~CFuzzy2004View()
{
}
void CFuzzy2004View::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFuzzy2004View)
DDX_Control(pDX, IDC_BUTTON_COUNT, m_count);
DDX_Control(pDX, IDC_BUTTON_GET1, m_get);
DDX_Control(pDX, IDC_BUTTON_READ, m_read);
//}}AFX_DATA_MAP
}
BOOL CFuzzy2004View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CFuzzy2004View::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_fuzzy2004Set;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
//先失效以下三個(gè)按鈕
this->m_read.EnableWindow(FALSE);
this->m_count.EnableWindow(FALSE);
SetTimer(1, 750, NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View printing
BOOL CFuzzy2004View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CFuzzy2004View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CFuzzy2004View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View diagnostics
#ifdef _DEBUG
void CFuzzy2004View::AssertValid() const
{
CRecordView::AssertValid();
}
void CFuzzy2004View::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CFuzzy2004Doc* CFuzzy2004View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFuzzy2004Doc)));
return (CFuzzy2004Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View database support
CRecordset* CFuzzy2004View::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CFuzzy2004View message handlers
void CFuzzy2004View::OnButtonGet1()
{
// TODO: Add your control notification handler code here
SYSTEMTIME st;
GetLocalTime(&st);
WORD entmonth,entday;
//entmonth.Format("%d",st.wMonth);
//entday.Format("%d",st.wDay);
//將年份和日期轉(zhuǎn)換為整數(shù)xxkwh
CString data1;
data1.Format("%u年%u月%u日 %u:%u:%u",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
CEdit* data2=(CEdit*)GetDlgItem(IDC_EDITDATA);
data2->SetWindowText(data1);
entmonth=st.wMonth;
entday=st.wDay;
//進(jìn)入返青期控制
if(entmonth==6)
{
//注意判斷語句的括號(hào)不能少,否則條件判斷不對(duì)
//此語句有問題!!xxkwh2004.8.15
if(((entday>=22)&&(entday<=28)))
{
//MessageBox("現(xiàn)在進(jìn)入返青期節(jié)水控制!");
CEdit* time1=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui1=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("-0.02mm");
time1->SetWindowText("返青期");
haoshui1->SetWindowText("47.8mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=-0.02;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=0;
this->m_read.EnableWindow(TRUE);
}
else
if(((entday>=29)&&(entday<=30)))
{
CEdit* time2=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui2=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("-0.02mm");
time2->SetWindowText("分蘗期");
haoshui2->SetWindowText("230.2mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=-0.02;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=1;
this->m_read.EnableWindow(TRUE);
}
else
{
MessageBox("對(duì)不起!現(xiàn)在不在節(jié)水控制!");
//先失效以下三個(gè)按鈕
this->m_read.EnableWindow(FALSE);
this->m_count.EnableWindow(FALSE);
}
}
//進(jìn)入分蘗期判斷
if((entmonth>6)&&(entmonth<8))
{
MessageBox("現(xiàn)在進(jìn)入分蘗期節(jié)水控制");
CEdit* time2=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui2=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.33mm");
time2->SetWindowText("分蘗期");
haoshui2->SetWindowText("230.2mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.33;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=1;
this->m_read.EnableWindow(TRUE);
}
//進(jìn)入拔節(jié)期和抽惠開花期
if(entmonth==8)
{
if(((entday>=1)&&(entday<=14)))
{
CEdit* time3=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui3=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.33mm");
time3->SetWindowText("拔節(jié)期");
haoshui3->SetWindowText("106.8mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.33;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=2;
this->m_read.EnableWindow(TRUE);
}
else
{
CEdit* time4=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui4=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.78mm");
time4->SetWindowText("抽惠開花期");
haoshui4->SetWindowText("186.9mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.78;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=3;
this->m_read.EnableWindow(TRUE);
}
}
//進(jìn)入抽惠開花期和乳熟期
if(entmonth==9)
{
if(((entday>=1)&&(entday<=4)))
{
CEdit* time4=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui4=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.78mm");
time4->SetWindowText("抽惠開花期");
haoshui4->SetWindowText("186.9mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.78;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=3;
this->m_read.EnableWindow(TRUE);
}
else
if(((entday>=15)&&(entday<=26)))
{
CEdit* time5=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui5=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.63mm");
//me5->Clear;
time5->SetWindowText("乳熟期");
haoshui5->SetWindowText("137.1mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.63;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=4;
this->m_read.EnableWindow(TRUE);
}
else
{
CEdit* time6=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui6=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.63mm");
time6->SetWindowText("黃熟期");
haoshui6->SetWindowText("74.6mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.63;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=5;
this->m_read.EnableWindow(TRUE);
}
}
if(entmonth==10)
{
if(((entday>=1)&&(entday<=16)))
{
CEdit* time6=(CEdit*)GetDlgItem(IDC_EDIT1);
CEdit* haoshui6=(CEdit*)GetDlgItem(IDC_EDIT2);
CEdit* shuiwei1=(CEdit*)GetDlgItem(IDC_EDIT3);
shuiwei1->SetWindowText("0.63mm");
time6->SetWindowText("黃熟期");
haoshui6->SetWindowText("74.6mm(毫米)");
//設(shè)置田間標(biāo)準(zhǔn)水位
m_biaozhun=0.63;
//設(shè)置水稻生長(zhǎng)時(shí)期
timeorder=5;
this->m_read.EnableWindow(TRUE);
}
else
{
MessageBox("對(duì)不起,現(xiàn)在不在水位控制期!");
//先失效以下三個(gè)按鈕
this->m_read.EnableWindow(FALSE);
this->m_count.EnableWindow(FALSE);
}
}
if((entmonth<6)||(entmonth>10))
//if (entmonth==5)
MessageBox("對(duì)不起,現(xiàn)在不在水位控制期!");
//先顯示按鈕
// this->m_read.EnableWindow(TRUE);
// this->m_count.EnableWindow(TRUE);
}
void CFuzzy2004View::OnButtonRead()
{
// TODO: Add your control notification handler code here
//讀取田間水位和降雨量信息,并根據(jù)讀取的水位信息進(jìn)行比較提示要供水還是排水警告信息。
//訪問本地?cái)?shù)據(jù)庫利用ODBC連接
//xxkwh2004.8.15
//<=0.22
//0.26
//0.30
//0.34
//>=0.38
//
//
//if(m_shuiwei<=0.22);
id=2;
//////////////////////////////////////////////////////////////////
//先失效以下三個(gè)按鈕
// this->m_read.EnableWindow(FALSE);
this->m_count.EnableWindow(TRUE);
}
void CFuzzy2004View::OnButtonCount()
{
// TODO: Add your control notification handler code here
//根據(jù)求得的模糊矩陣和當(dāng)前田間水位進(jìn)行計(jì)算,得到當(dāng)前最佳供水量
////////////////////////////////////////////////////////////
//數(shù)據(jù)庫中讀取數(shù)據(jù)到數(shù)組中
float rarry[5][3],darry[5][5],parry[5][3];
//循環(huán)變量
int i,j,k,m,p;
//存放第一次計(jì)算的模糊矩陣,用三維數(shù)組存放15個(gè)5行5列的矩陣
float res1[5][5][15];
///存放第二次計(jì)算的模糊矩陣和最后取大處理后的模糊矩陣
float result[5][5][15],temp,reslast[5][5];
float putout,sum;
CString str1;//存放最后結(jié)果
CString strout;
///////////////////////////////////////////
//從數(shù)據(jù)庫中獲取數(shù)據(jù)存放到數(shù)組中
//降雨量
CRain m_rain;
CDespoit m_despoit;
//////////////////////////////////////////
m_rain.Open();
m_rain.MoveFirst();
rarry[0][0]=m_rain.m_rainneg2min;
rarry[0][1]=m_rain.m_rainpos2mid;
rarry[0][2]=m_rain.m_rainneg2max;
rarry[1][0]=m_rain.m_rainneg1min;
rarry[1][1]=m_rain.m_rainneg1mid;
rarry[1][2]=m_rain.m_rainneg1max;
rarry[2][0]=m_rain.m_rainzeromin;
rarry[2][1]=m_rain.m_rainzeromid;
rarry[2][2]=m_rain.m_rainzeromax;
rarry[3][0]=m_rain.m_rainpos1min;
rarry[3][1]=m_rain.m_rainpos1mid;
rarry[3][2]=m_rain.m_rainpos1max;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -