MAIN:
CALL INIT
jp__3:
CALL FIRST
CLR ES
MOV A,#MAIN_ON
CALL TRANS_TXD
SETB ES
JNB BIT_RESTART,$
MOV R0,#0
CLR BIT_RESTART
CLR CUT_POWER
CLR BIT_POWER
JMP jp__3

;#######################################
;//////////////////////////////////////
;////////// SERIAL PROGRAM ////////////
;//////////////////////////////////////
;#######################################
* Çíä ÒíÑ ÈÑäÇãå æÞÝå ÓÑíÇá ãí ÈÇÔÏ ßå ÇÑ åÑ ÇØáÇÚÇÊ ÓÑíÇá Èå ÏÓʐÇå æÇÑÏ ÔæÏ ÈÑäÇãå Èå Çíä ÞÓãÊ ÑÔ íÏÇ ãí ßäÏ .
SEND:
MOV ACOM,A
MOV A,SBUF
CALL DELAY
CLR RI
CJNE A,#RESTART,JP1
SETB BIT_RESTART
MOV A,ACOM
RETI
JP1:
CJNE A,#COMP_STOP,JP2
MOV R0,#100
MOV R5,#100
MOV R3,#1
CLR ES
MOV A,#MAIN_OFF ;MAIN_BOARD:OFF
CALL TRANS_TXD
SETB ES
MOV A,ACOM
RETI
JP2:
CJNE A,#RECIVE_CLOCK,JP0
MOV R4,#0
MOV A,ACOM
RETI
JP0:
CJNE R4,#0,LOAD_M01
INC R4
MOV M01,A
MOV A,ACOM
RETI
LOAD_M01:
CJNE R4,#1,LOAD_M10
INC R4
MOV M10,A
MOV A,ACOM
RETI
LOAD_M10:
CJNE R4,#2,LOAD_H01
INC R4
MOV H01,A
MOV A,ACOM
RETI
LOAD_H01:
CJNE R4,#3,LOAD_H10
INC R4
MOV H10,A
CALL TRANS_CLOCK
MOV A,ACOM
RETI
LOAD_H10:
CJNE A,#START_SAMPLE,LOAD_REG1
CALL RESET_COUNTER
RETI
LOAD_REG1:
CJNE R5,#0,LOAD_REG2
CALL LOAD_I1
RETI
LOAD_REG2:
CJNE R5,#1,LOAD_REG3
CALL LOAD_I2
RETI
LOAD_REG3:
CJNE R5,#2,LOAD_REG4
CALL LOAD_I3
RETI
LOAD_REG4:
CJNE R5,#3,LOAD_REG5
CALL LOAD_V1
RETI
LOAD_REG5:
CJNE R5,#4,LOAD_REG6
CALL LOAD_V2
RETI
LOAD_REG6:
CJNE R5,#5,LOAD_REG7
CALL LOAD_V3
RETI
LOAD_REG7:
CJNE R0,#0,TRANS_DATA_COMPUTER
MOV A,ACOM
RETI
TRANS_DATA_COMPUTER:
CJNE A,#MAIN_OFF,STEP3
CALL FIRST_BYTE
RETI
STEP3:
CJNE A,#255,ERROR
CLR ES
SETB BIT_FULL
CLR BIT_LOW
CALL TRANS_DATA
SETB ES
RETI
ERROR:
RETI
;*******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ ÌÑíÇä ÝÇÒ íß ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ .
LOAD_I1:
INC R5
MOV I1,A
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ ÌÑíÇä ÝÇÒ Ïæ ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ .
LOAD_I2:
INC R5
MOV I2,A
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ ÌÑíÇä ÝÇÒ Óå ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ .
LOAD_I3:
INC R5
MOV I3,A
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ æáÊÇŽ ÝÇÒ íß ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ .
LOAD_V1:
INC R5
MOV V1,A
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ æáÊÇŽ ÝÇÒ Ïæ ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ .
LOAD_V2:
INC R5
MOV V2,A
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ãÞÏÇÑ æáÊÇŽ ÝÇÒ Óå ÑÇ ßå ÇÒ ØÑíÞ ÓÑíÇá ÑÓíÏå ÇÓÊ ÑÝÊå æÐÎíÑå ãí ßäÏ æÓÓ Çíä ãÞÏÇÑ ÑÇ ÏÑ ÍÇÝÙå ÐÎíÑå ãí ßäÏ .
LOAD_V3:
MOV V3,A
CJNE R3,#1,JP3
MOV R3,#0
MOV A,ACOM
RET
JP3:
JNB CUT_POWER,JP__4
CPL BIT_POWER
JP__4:
INC WRITE_DATA
MOV R5,#100
CJNE R7,#1,MN
CPL BIT_FULL
CLR BIT_LOW
MOV A,WRITE_DATA
CJNE A,#TIME_SAMPLE,MN
CALL RGR
MOV WRITE_DATA,#0
MN:
CALL VOLT_TRANS
MOV A,ACOM
RET
;******************
* Çíä ÒíÑ ÈÑäÇãå ÏÑ ÒãÇä ÊÎáíå ÇØáÇÚÇÊ Çíä ãÞÇÏíÑ ÑÇ Èå ßÇãíæÊÑ ãí ÝÑÓÊÏ .
TRANS_DATA:

MOVX A,@DPTR
MOV I_O1,A
INC DPTR

MOVX A,@DPTR
MOV I_O2,A
INC DPTR

MOVX A,@DPTR
MOV I_O3,A
INC DPTR
CPL BIT_LOW
CPL BIT_FULL
MOV A,I_O1
CALL TRANS_TXD
CJNE A,#255,PP2
SETB BIT_FULL
SETB BIT_LOW
MOV A,ACOM
RET
PP2:
MOV A,I_O2
CALL TRANS_TXD
CJNE A,#255,PP3
SETB BIT_FULL
SETB BIT_LOW
MOV A,ACOM
RET
PP3:
MOV A,I_O3
CALL TRANS_TXD
CJNE A,#255,PP4
SETB BIT_FULL
SETB BIT_LOW
MOV A,ACOM
RET
PP4:
JMP TRANS_DATA
RET
;**************************
* Çíä ÒíÑ ÈÑäÇãå ãÞÇÏíÑ ÌÑíÇä Óå ÝÇÒ ÑÓíÏå ÇÒ Âí Óí ÇÕáí ÑÇ ÏÑ ÍÇÝÙå ÐÎíÑå ãí äãÇíÏ .
RGR:
MOV A,I1
MOVX @DPTR,A
INC DPTR
CALL DELAY
MOV A,I2
MOVX @DPTR,A
INC DPTR
CALL DELAY
MOV A,I3
MOVX @DPTR,A
INC DPTR
MOV A,DPH
CJNE A,#7FH,FD
SETB BIT_LOW ;PIN—->RAM LOW
CLR BIT_FULL ;PIN—->RAM FULL
MOV R7,#0
FD:
RET
;***********trans volt to computer***************
* Çíä ÒíÑ ÈÑäÇãå ÏÑ ÒãÇä ÑÓíÏä æáÊÇŽ æ ÌÑíÇä Óå ÝÇÒ ÇÒ Âí Óí ÇÕáí Çíä ãÞÇÏíÑ ÑÇ Èå ØæÑ åãÒãÇä Èå ßÇãíæÊÑ ãí ÝÑÓÊÏ ÊÇ ÏÑ äÑã ÇÝÒÇÑ äãÇíÔ ÏÇÏå ÔæÏ .
VOLT_TRANS:

CLR ES
MOV A,#TRANS_COM
CALL TRANS_TXD
MOV A,I1
CALL TRANS_TXD
MOV A,I2
CALL TRANS_TXD
MOV A,I3
CALL TRANS_TXD
MOV A,V1
CALL TRANS_TXD
MOV A,V2
CALL TRANS_TXD
MOV A,V3
CALL TRANS_TXD
MOV A,DPH
CALL TRANS_TXD
SETB ES
RET
;********************
* ÈÑÇí ÇÑÓÇá ÓÑíÇá ÇØáÇÚÇÊ ÇÒ ØÑíÞ ÓÑíÇá ÇÒ Çíä ÒíÑ ÈÑäÇãå ÇÓÊÝÇÏå ãí ÔæÏ .
TRANS_TXD:
CJNE A,#0,JP_1
MOV A,#1
JP_1:
MOV SBUF,A
JNB TI,$
CALL DELAY
CLR TI
RET
;********************
* Çíä ÒíÑ ÈÑäÇãå ÏÑ áÍÙå ÇÈÊÏÇí äãæäå íÑí ÂÏÑÓ ÍÇÝÙå ÑÇ ÕÝÑ ãí ßäÏ .
INIT_RAM:
MOV A,#00H
MOV DPL,A
MOV DPH,A
RET
;*****************INIT SET
* Çíä ÒíÑ ÈÑäÇãå ÏÑ ÇÈÊÏÇí ÑÇå ÇäÏÇÒí Âí Óí ÝÑÇÎæÇäí ãí ÔæÏ æ ãÞÇÏíÑ Çæáíå Èå ãÊÛíÑåÇ ãí ÏåÏ .
INIT:
CALL DELAY0
CLR BIT_POWER
SETB CUT_POWER
MOV WRITE_DATA,#TIME_SAMPLE-1
MOV COUNT,#0
MOV R6,#0
MOV R5,#100
CLR BIT_RESTART
MOV R7,#1
MOV R3,#0
MOV R0,#0
MOV R4,#100
MOV M_S,#0
MOV S01,#0
CLR TI
CLR RI
CLR P1.0
SETB BIT_STOP
MOV TMOD,#20H ;TIM1 MOD2,TIM0 MOD1
MOV TH1,#0FDH ;BOUD RATE=9600
MOV TCON,#00H
MOV SCON,#50H
MOV IE,#90H
SETB TR1
RET
;++++++++++++++++++++++DELAY TIME++++++++++
* Çíä ÒíÑ ÈÑäÇãå åÇ ÈÑÇí ÊÇÎíÑ ÒãÇäí ÇÓÊÝÇÏå ãí ÔæÏ .
DELAY:
MOV R1,#50
DJNZ R1,$
RET
;,,,,,,,,,,,,,,,,,,,,,,,
DELAY2:
MOV R1,#30
DJNZ R1,$
RET
;,,,,,,,,,,,,,,,,,,,,,,,
DELAY0:
MOV R1,#255
K3: MOV R2,#255
DJNZ R2,$
DJNZ R1,K3
RET
;””””””””””””
END
3-äÑã ÇÝÒÇÑ ÊÍÊ æíäÏæÒ äæÔÊå ÔÏå ÈÇ Visual C++ :
//////////////////////////////////////////////////////////////
* Çíä ÒíÑ ÈÑäÇãå ÏÑ ÇÈÊÏÇí ÇÌÑÇí ÈÑäÇãå ÝÑÇÎæÇäí ãí ÔæÏ æ íß ÓÑí ÊäÙíãÇÊ Çæáíå ÇÌÑÇ ãí ÔæÏ .
void CAnalyzerView::OnInitialUpdate()
{
int out_file;
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_led=1;
if (!m_commctrl.Create(NULL,0,CRect(0,0,0,0),this,ID_MS))
{
MessageBox(” Not Found Communiction System —-> Mscomm32.ocx ??? “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
m_commctrl.SetRThreshold(1);
out_file=f.Open(“systemsystem.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
f.Close();
}else
{
MessageBox(” Invalid System.cfg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
out_file=f.Open(“systemInit.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
f.Close();
}else
{
MessageBox(” Invalid Init.cfg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
out_file=f.Open(“systemPrice.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
f.Close();
}else
{
MessageBox(” Invalid Price.cfg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
SetTimer(ID_CLOCK,1,NULL);
m_prog.SetRange(0,32);
m_prog.SetStep(1);
s_prog.SetRange(0,8);
s_prog.SetStep(1);
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
m_text1=”Invalid”;
m_text2=”Invalid”;
m_text3=”Invalid”;
s_prog.SetPos(0);
m_info=”No Data”;
UpdateData(FALSE);
Read_init();
if(Auto==1 || Auto==2)
{
m_auto=TRUE;
SetTimer(ID_LED,300,NULL);
}
switch(trans)
{
case 1:
GetDlgItem(IDC_CLICK1)->EnableWindow(TRUE);
m_250=FALSE;
zarib=1;
UpdateData(FALSE);
break;
case 2:
GetDlgItem(IDC_CLICK2)->EnableWindow(TRUE);
m_500=FALSE;
zarib=2;
UpdateData(FALSE);
break;
case 3:
GetDlgItem(IDC_CLICK3)->EnableWindow(TRUE);
m_750=FALSE;
zarib=3;
UpdateData(FALSE);
break;
case 4:
GetDlgItem(IDC_CLICK4)->EnableWindow(TRUE);
m_1000=FALSE;
zarib=4;
UpdateData(FALSE);
break;
case 6:
GetDlgItem(IDC_CLICK5)->EnableWindow(TRUE);
m_1500=FALSE;
zarib=6;
UpdateData(FALSE);
break;
case 8:
GetDlgItem(IDC_CLICK6)->EnableWindow(TRUE);
m_2000=FALSE;
zarib=8;
UpdateData(FALSE);
break;
case 9:
GetDlgItem(IDC_CLICK7)->EnableWindow(TRUE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(TRUE);
m_trans=FALSE;
zarib=m_val_trans/250;
UpdateData(FALSE);
break;
}
switch(PORT)
{
case 1016:
m_com1=FALSE;
m_commctrl.SetCommPort(1);
UpdateData(FALSE);
break;
case 760:
m_com2=FALSE;
m_commctrl.SetCommPort(2);
UpdateData(FALSE);
break;
}
if(Auto==1 || Auto==2)
{
Off();
SetTimer(ID_AUTO1,10000,NULL);
}else
{
SetTimer(ID_LED_OFF,5000,NULL);
}
ChangLable();
}
///////////////
* Çíä ÒíÑ ÈÑäÇãå ÏÑ ÇÈÊÏÇí ÇÌÑÇí ÈÑäÇãå ÝÑÇÎæÇäí ãí ÔæÏ æ ÚßÓ åÇ æ ÑäåÇí Òãíäå ÏÑ Çíä ÞÓãÊ ÇÌÑÇ ãí ÔæÏ .
void CAnalyzerView::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class

CBitmap bmap;
BITMAP bm;
CDC dcmem;
bmap.LoadBitmap(IDB_BITMAP5);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold5=dcmem.SelectObject(&bmap);
pDC->BitBlt(0,0,800,600,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP6);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold6=dcmem.SelectObject(&bmap);
pDC->BitBlt(340,80,550,350,&dcmem,0,0,SRCCOPY);
bmap.LoadBitmap(IDB_BITMAP7);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold7=dcmem.SelectObject(&bmap);
pDC->BitBlt(28,445,550,350,&dcmem,0,0,SRCCOPY);
bmap.LoadBitmap(IDB_BITMAP8);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold8=dcmem.SelectObject(&bmap);
pDC->BitBlt(26,390,550,350,&dcmem,0,0,SRCCOPY);
bmap.LoadBitmap(IDB_BITMAP9);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold9=dcmem.SelectObject(&bmap);
pDC->BitBlt(353,448,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP10);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold10=dcmem.SelectObject(&bmap);
pDC->BitBlt(340,13,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP11);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold11=dcmem.SelectObject(&bmap);
pDC->BitBlt(550,13,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP12);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold12=dcmem.SelectObject(&bmap);
pDC->BitBlt(25,10,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP13);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold13=dcmem.SelectObject(&bmap);
pDC->BitBlt(111,10,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP14);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold14=dcmem.SelectObject(&bmap);
pDC->BitBlt(110,5,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP15);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold15=dcmem.SelectObject(&bmap);
pDC->BitBlt(25,5,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP16);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold16=dcmem.SelectObject(&bmap);
pDC->BitBlt(335,5,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP17);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold17=dcmem.SelectObject(&bmap);
pDC->BitBlt(337,73,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP18);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold18=dcmem.SelectObject(&bmap);
pDC->BitBlt(353,340,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP19);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold19=dcmem.SelectObject(&bmap);
pDC->BitBlt(351,442,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP20);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold20=dcmem.SelectObject(&bmap);
pDC->BitBlt(24,60,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP4);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold4=dcmem.SelectObject(&bmap);
pDC->BitBlt(25,68,550,350,&dcmem,0,0,SRCCOPY);
bmap.LoadBitmap(IDB_BITMAP3);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold=dcmem.SelectObject(&bmap);
pDC->BitBlt(355,350,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP2);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold2=dcmem.SelectObject(&bmap);
pDC->BitBlt(662,257,550,350,&dcmem,0,0,SRCCOPY);
bmap.LoadBitmap(IDB_BITMAP1);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold3=dcmem.SelectObject(&bmap);
pDC->BitBlt(378,255,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP21);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold21=dcmem.SelectObject(&bmap);
pDC->BitBlt(24,382,550,350,&dcmem,0,0,SRCCOPY);

bmap.LoadBitmap(IDB_BITMAP22);
bmap.GetObject(sizeof(BITMAP),&bm);
dcmem.CreateCompatibleDC(pDC);
CBitmap * pbmold22=dcmem.SelectObject(&bmap);
pDC->BitBlt(24,438,550,350,&dcmem,0,0,SRCCOPY);
}
/****************************************************/
* Çíä ÒíÑ ÈÑäÇãå ÞÓãÊ ÊÇíãÑåÇ ãÎÊáÝ ÇÓÊ ßå ÒãÇä ÇÌÑÇí åÑ ÊÇíãÑ ÔÏ ÈÑäÇãå Èå Çíä ÞÓãÊ Èå ÕæÑÊ æÞÝå ÑÔ ãí ßäÏ .
void CAnalyzerView::OnTimer(UINT nIDEvent)
{
UpdateData(TRUE);
switch(nIDEvent)
{
case ID_CLOCK:
{
KillTimer(ID_CLOCK);
SetTimer(ID_CLOCK,60000,NULL);
CTime curTime=CTime::GetCurrentTime();
m_sTime.Format(” %d : %d “,curTime.GetHour(),
curTime.GetMinute());
UpdateData(FALSE);
return;
break;
}
case ID_COM:
{
OnCommEvent();
return;
break;
}
case ID_COM_MONITORING:
{
OnCommEventMonitoring();
return;
break;
}
case ID_LINK:
{
show1.out=1;
ComClose();
m_enable=FALSE;
UpdateData(FALSE);
KillTimer(ID_COM_MONITORING);
KillTimer(ID_COM);
KillTimer(ID_LINK);
if(Auto==0)
{
MessageBox(” No Data Please Check —-> [ COM & CABLE ] “,”ERORR”,MB_OK | MB_ICONSTOP);
On();
}else
{
OnRestart();
if(Auto==1 || Auto==2){
Shut_down();
}
Exit_prog();
}
return;
break;
}
case ID_AUTO1:
{
KillTimer(ID_LED);
KillTimer(ID_AUTO1);
Led_Red();
GetDlgItem(IDC_AUTO)->EnableWindow(FALSE);
OnClick6();
return;
break;
}
case ID_AUTO2:
{
KillTimer(ID_AUTO2);
OnRestart();
return;
break;
}
case ID_AUTO3:
{
KillTimer(ID_AUTO3);
OnButton8();
return;
break;
}
case ID_LED:
{
if(m_led==1)
{
Led_Green();
m_led=0;
}else
{
Led_Off();
m_led=1;
}
return;
break;
}
case ID_LED_OFF:
{
KillTimer(ID_LED_OFF);
Led_Off();
return;
break;
}
}
CFormView::OnTimer(nIDEvent);
}
/****************************************************/
* æÞÊíßå ãÇ ÏÑ äÑã ÇÝÒÇÑ ßáíÏ Start New Sample ÑÇ ÝÔÇÑ ãí Ïåíã ÈÑäÇãå Çíä ÒíÑ ÈÑäÇãå ÑÇ ÇÌÑÇ ãí ßäÏ æ íß ÓÑí ßÏ åÇí ÎÇÕ Èå ÏÓʐÇå ãí ÝÑÓÊÏ ÊÇ Úãá äãæäå íÑí ãÌÏÏ ÇäÌÇã ÔæÏ .
void CAnalyzerView::OnRestart()
{
int go;
KillTimer(ID_COM_MONITORING);
KillTimer(ID_LINK);
ComClose();
m_enable=FALSE;
UpdateData(FALSE);
for(counter_recive=0;counter_recive<=50000;counter_recive++)
{
recive_com[counter_recive]=0;
}
for(z=0;z<3000;z++)
{
t[z]=” “;
}
for(z=0;z<3000;z++)
{
size_len[z]=0;
}
GetDlgItem(IDC_RESTART)->EnableWindow(FALSE);
if(Auto==0)
{
go = MessageBox(“Are You Sure Restart Memory ?”,”Warning”,MB_YESNOCANCEL | MB_ICONEXCLAMATION);
switch(go)
{
case IDYES:
UpdateData(TRUE);
Get_Clock();
ComOpen();
send_data=250;
Send_Port();
ComClose();
UpdateData(TRUE);
m_enable=TRUE;
UpdateData(FALSE);
GetDlgItem(IDC_RESTART)->EnableWindow(TRUE);
ComOpen();
l_monitoring=0;
SetTimer(ID_COM_MONITORING,500,NULL);
SetTimer(ID_LINK,5000,NULL);
return;
break;
case IDNO:
GetDlgItem(IDC_RESTART)->EnableWindow(TRUE);
return;
break;
case IDCANCEL:
GetDlgItem(IDC_RESTART)->EnableWindow(TRUE);
return;
break;
default:
return;
}
}else
{
Get_Clock();
ComOpen();
send_data=250;
Send_Port();
ComClose();
SetTimer(ID_AUTO3,3000,NULL);
}
}
/****************************************************/
* Çíä ÒíÑ ÈÑäÇãå æÞÊí ÇÌÑÇ ãí ÔæÏ ßå ãÇ ÏÑ äÑã ÇÝÒÇÑ ßáíÏ ÊÎáíå 800 ———->5 ÑÇ ãí Òäíã æ íß ÓÑí ßÏ åÇí ÎÇÕ Èå ÏÓʐÇå ãíÝÑÓÊÏ ÊÇ Úãá ÊÎáíå ÇäÌÇã ÔæÏ .
void CAnalyzerView::OnClick6()
{
show1.out=0;
if(Auto==0)
{
Off();
go = MessageBox(“Are You Sure DownLoad Memory ?”,”Warning”,MB_YESNOCANCEL | MB_ICONEXCLAMATION);
switch(go)
{
case IDYES:
{
m_enable=FALSE;
OnCheck1();
Read_init();
enter_date.DoModal();
DATE=enter_date.m_date;
Write_init();
file_date.Format(“%d”,enter_date.m_date);
count_pos=0;
locate_pos=0;
ComOpen();
send_data=247;
Send_Port();
ComClose();
ComOpen();
send_data=0xfc;
Send_Port();
ComClose();
ComOpen();
send_data=255;
Send_Port();
init_port();
SetTimer(ID_LINK,5000,NULL);
show1.DoModal();
return;
break;
}
case IDNO:
{
On();
return;
break;
}
case IDCANCEL:
{
On();
return;
break;
}
default:
return;
}
}else
{
OnCheck1();
Cal_Date();
count_pos=0;
locate_pos=0;
ComOpen();
send_data=247;
Send_Port();
ComClose();
ComOpen();
send_data=0xfc;
Send_Port();
ComClose();
ComOpen();
send_data=255;
Send_Port();
init_port();
show1.DoModal();
}
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå æÞÊí ÇÌÑÇ ãí ÔæÏ ßå ãÇ ÏÑ ÞÓãÊ ÊÑÇäÓ íß ÚÏÏ ÞÑÇÑ Ïåíã .
void CAnalyzerView::OnTrans1()
{
Read_init();
UpdateData(TRUE);
m_500=TRUE;
m_1500=TRUE;
m_1000=TRUE;
m_750=TRUE;
m_2000=TRUE;
m_250=TRUE;
m_trans=FALSE;
trans=9;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(TRUE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(TRUE);
UpdateData(FALSE);
zarib=m_val_trans/250;
Write_init();
ChangLable();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 2000 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio2000()
{
Read_init();
m_2000=FALSE;
m_1500=TRUE;
m_1000=TRUE;
m_750=TRUE;
m_500=TRUE;
m_250=TRUE;
m_trans=TRUE;
trans=8;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=8;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 1500 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio1500()
{
Read_init();
m_1500=FALSE;
m_2000=TRUE;
m_1000=TRUE;
m_750=TRUE;
m_500=TRUE;
m_250=TRUE;
m_trans=TRUE;
trans=6;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=6;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 1000 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio1000()
{
Read_init();
m_1000=FALSE;
m_1500=TRUE;
m_2000=TRUE;
m_750=TRUE;
m_500=TRUE;
m_250=TRUE;
m_trans=TRUE;
trans=4;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=4;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 750 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio750()
{
Read_init();
m_750=FALSE;
m_1500=TRUE;
m_1000=TRUE;
m_2000=TRUE;
m_500=TRUE;
m_250=TRUE;
m_trans=TRUE;
trans=3;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=3;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 500 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio500()
{
Read_init();
m_500=FALSE;
m_1500=TRUE;
m_1000=TRUE;
m_750=TRUE;
m_2000=TRUE;
m_250=TRUE;
m_trans=TRUE;
trans=2;
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=2;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÝÑÇÎæÇäí ãí ÔæÏ ßå ãÇ ÊÑÇäÓ ÑÇ ÏÑ ÍÇáÊ 250 ÞÑÇÑ Ïåíã æÏÑ Çíä ÍÇáÊ ÖÑíÈ ÊÑÇäÓ ÊÛííÑ ÎæÇåÏ ßÑÏ .
void CAnalyzerView::OnRadio250()
{
Read_init();
m_250=FALSE;
m_1500=TRUE;
m_1000=TRUE;
m_750=TRUE;
m_500=TRUE;
m_2000=TRUE;
m_trans=TRUE;
trans=1;
GetDlgItem(IDC_CLICK1)->EnableWindow(TRUE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
UpdateData(FALSE);
zarib=1;
Write_init();
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå æÑÊ ÑÇ ÈÑÇí ÇÑÊÈÇØ ÓÑíÇá ÂãÇÏå ãí ßäÏ .
void CAnalyzerView::init_port()
{
m_enable=FALSE;
UpdateData(FALSE);
KillTimer(ID_COM_MONITORING);
counter_recive=0;
l=0;
SetTimer(ID_COM,50,NULL);
SetTimer(ID_LINK,5000,NULL);
}
/****************************************/
* æÞÊíßå ÏÑ äÑã ÇÝÒÇÑ æÑÊ íß ÑÇ ÇäÊÎÇÈ ãí ßäíã Çíä ÒíÑ ÈÑäÇãå ÇÌÑÇ ãí ÔæÏ æ æÑÊ ÑÇ ÏÑ ÍÇáÊ ßÇã íß ÞÑÇÑ ãí ÏåÏ .
void CAnalyzerView::OnCom1()
{
Read_init();
m_commctrl.SetCommPort(1);
m_com1=FALSE;
m_com2=TRUE;
UpdateData(FALSE);
PORT=0x3f8;
COMBASE=0x3f0;
Write_init();
}
/****************************************/
* æÞÊíßå ÏÑ äÑã ÇÝÒÇÑ æÑÊ Ïæ ÑÇ ÇäÊÎÇÈ ãí ßäíã Çíä ÒíÑ ÈÑäÇãå ÇÌÑÇ ãí ÔæÏ æ æÑÊ ÑÇ ÏÑ ÍÇáÊ ßÇã Ïæ ÞÑÇÑ ãí ÏåÏ .
void CAnalyzerView::OnCom2()
{
Read_init();
m_commctrl.SetCommPort(2);
m_com2=FALSE;
m_com1=TRUE;
UpdateData(FALSE);
PORT=0x2f8;
COMBASE=0x2f0;
Write_init();
}
/****************************************/
* æÞÊíßå ÏÑ äÑã ÇÝÒÇÑ ßáíÏ File Convert ÝÔÇÑ ÏÇÏå ãí ÔæÏ Çíä ÒíÑ ÈÑäÇãå ÇÌÑÇ ãí ÔæÏ .
void CAnalyzerView::OnButton8()
{
int in_pass;
int minute;
int hour;
int second;
int y=0;
int out_file;
long int j;
int convert_int;
p=0;
if(Auto==1)
{
Led_Green();
Sleep(1000);
Shut_down();
Exit_prog();
}
if(Auto==0)
{
enter_pass.m_pass=1111;
enter_pass.m_date=file_date;
enter_pass.DoModal();
file_date=enter_pass.m_date;
in_pass=enter_pass.out_pass;
if(in_pass==1)
{
MessageBox(” You Need Super Password _ Please Contact With Us “,”Converting”,MB_OK | MB_ICONSTOP);
}
if(in_pass==2)
{
out_file=f.Open(“Analyz”+file_date+”.Meg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(recive_com,150000);
hour=recive_com[0];
minute=recive_com[1];
second=recive_com[2];
f.Close();
}else
{
MessageBox(” Invalid *.Meg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
in=fopen(“Analyz”+file_date+”.txt”,”w”);
for(j=3;j<32292;j++)
{
if(recive_com[j]==0)
{
convert_int=recive_com[j]*zarib;
file_contor[p]=convert_int;
p++;
fprintf(in,”%d”,convert_int);
y++;
}else
{
convert_int=(recive_com[j]-1234)*zarib;
file_contor[p]=convert_int;
p++;
fprintf(in,”%d”,convert_int);
y++;
}
if(y==3)
{
file_contor[p]=hour;
p++;
putc(‘t’,in);
fprintf(in,”%d”,hour);
putc(‘:’,in);
fprintf(in,”%d”,minute);
putc(‘:’,in);
fprintf(in,”%d”,second);
second=second+8;
if(second>=60)
{
second=second-60;
minute=minute+1;
if(minute==60)
{
minute=0;
hour=hour+1;
if(hour==25)
{
hour=1;
}
}
}
y=0;
putc(‘n’,in);
}
else
{
putc(‘t’,in);
}
}
fclose(in);
f.Open(“Price”+file_date+”.con”,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
f.Write(file_contor,250000);
f.Close();
remove(“Analyz”+file_date+”.Meg”);
MessageBox(” Converting File For Analyz “,”Converting”);
}
if(in_pass==0)
{
MessageBox(” Don’t Converting “,”Converting”,MB_OK | MB_ICONSTOP);
}
}
if(Auto==2)
{
out_file=f.Open(“Analyz”+file_date+”.Meg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(recive_com,150000);
hour=recive_com[0];
minute=recive_com[1];
second=recive_com[2];
f.Close();
}
in=fopen(“Analyz”+file_date+”.txt”,”w”);
for(j=3;j<32292;j++)
{
if(recive_com[j]==0)
{
convert_int=recive_com[j]*zarib;
file_contor[p]=convert_int;
p++;
fprintf(in,”%d”,convert_int);
y++;
}else
{
convert_int=(recive_com[j]-1234)*zarib;
file_contor[p]=convert_int;
p++;
fprintf(in,”%d”,convert_int);
y++;
}
if(y==3)
{
file_contor[p]=hour;
p++;
putc(‘t’,in);
fprintf(in,”%d”,hour);
putc(‘:’,in);
fprintf(in,”%d”,minute);
putc(‘:’,in);
fprintf(in,”%d”,second);
second=second+8;
if(second>=60)
{
second=second-60;
minute=minute+1;
if(minute==60)
{
minute=0;
hour=hour+1;
if(hour==25)
{
hour=1;
}
}
}
y=0;
putc(‘n’,in);
}
else
{
putc(‘t’,in);
}
}
fclose(in);
f.Open(“Price”+file_date+”.con”,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
f.Write(file_contor,250000);
f.Close();
remove(“Analyz”+file_date+”.Meg”);
Led_Green();
Sleep(1000);
Shut_down();
Exit_prog();
}
}
/****************************************/
* Çíä ÒíÑ ÈÑäÇãå ÈÑÇí ßÇÑßÑÏä ÈÇ æÑÊ ÓÑíÇá ßÇãíæÊÑ ãæÑÏ ÇÓÊÝÇÏå ÞÑÇÑ ãííÑÏ.
void CAnalyzerView::OnCommEvent()
{
switch(m_commctrl.GetCommEvent())
{
case 1: // vbMSCommEvSend:
MessageBox(“send”);
break;
case 2: // vbMSCommEvReceive:
KillTimer(ID_LINK);
VariantInit(&var);
var=m_commctrl.GetInput();
var.vt = VT_BSTR;
t[l]=var.bstrVal;
size_len[l]=t[l].GetLength();
Save();
t[l]=” “;
SysFreeString(var.bstrVal);
l++;
VariantClear(&var);
return;
break;
case 3: // vbMSCommEvCTS:
MessageBox(“error”);
break;
case 4: // vbMSCommEvDSR:
MessageBox(“error”);
break;
case 5: // vbMSCommEvCD:
MessageBox(“error”);
break;
case 6: // vbMSCommEvRing:
MessageBox(“error”);
break;
case 7: // vbMSCommEvEOF:
MessageBox(“error”);
break;
case 1001: // vbMSCommErBreak:
MessageBox(“error”);
break;
case 1002: // vbMSCommErCTSTO:
MessageBox(“error”);
break;
case 1003: // vbMSCommErDSRTO:
MessageBox(“error”);
break;
case 1004: // vbMSCommErFrame:
MessageBox(“error”);
break;
case 1006: // vbMSCommErOverrun:
MessageBox(“error”);
break;
case 1007: // vbMSCommErCDTO:
MessageBox(“error”);
break;
case 1008: // vbMSCommErRxOver:
MessageBox(“error”);
break;
case 1009: // vbMSCommErRxParity:
MessageBox(“error”);
break;
case 1010: // vbMSCommErTxFull:
MessageBox(“error”);
break;
}
}
/*******************************************/
* ßÇÑ Çíä ÒíÑ ÈÑäÇãå Çíä ÇÓÊ ßå ÇØáÇÚÇÊ ÐÎíÑå ÔÏå ÏÑ ÈÇÝÑ ÓÑíÇá æÑÊ ÑÇ ÊÎáíå ãí ßäÏ æ ÏÑ íß ãÊÛíÑ äåÏÇÑí ãí ßäÏ .

void CAnalyzerView::Save()
{
int out_file;
for(z=0;z<size_len[l];z++)
{
int b=t[l][z];
if(b<0)
{
b=256+b;
}
if(b==1)
{
b=0;
}
recive_com[counter_recive]=b+1234;
if(recive_com[counter_recive]-1234==255)
{
recive_com[counter_recive]=0;
KillTimer(ID_COM);
show1.out=1;
out_file=f.Open(“systemsystem.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
f.Close();
recive_com[0]=init[1];
recive_com[1]=init[2];
recive_com[2]=init[3];
}else
{
MessageBox(” Invalid System.cfg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
f.Open(“Analyz”+file_date+”.Meg”,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
f.Write(recive_com,150000);
f.Close();
ComClose();
recive_com[0,150000]=0;
if(Auto==1 || Auto==2)
{
SetTimer(ID_AUTO2,3000,NULL);
m_prog.SetPos(0);
}else
{
MessageBox(“*** Finish *** “,”FINISH”,MB_OK | MB_ICONQUESTION);
m_prog.SetPos(0);
On();
}
}
counter_recive++;
count_pos++;
if(count_pos==1000)
{
count_pos=0;
locate_pos++;
m_prog.SetPos(locate_pos);
}
}
}
/*************************************************/
* Çíä ÒíÑ ÈÑäÇãå ÈÑÇí ÝÑÓÊÇÏä ÇØáÇÚÇÊ Èå æÑÊ ãæÑÏ ÇÓÊÝÇÏå ÞÑÇÑ ãí íÑÏ
void CAnalyzerView::Send_Port()
{
if (m_commctrl.GetPortOpen())
{
VariantInit(&var);
var.vt = VT_BSTR;
var.bstrVal =send_data.AllocSysString();
m_commctrl.SetOutput(var);
VariantClear(&var);
}else
{
MessageBox(“Port Is Close”);
}
}
/******************************************/
* Çíä ÒíÑ ÈÑäÇãå ßÇã ÓÑíÇá ÑÇ ÏÑ ÇÎÊíÇÑ äÑã ÇÝÒÇÑ ÞÑÇÑ ãí ÏåÏ .

void CAnalyzerView::ComOpen()
{
if (!m_commctrl.GetPortOpen())
{
m_commctrl.SetPortOpen(TRUE);
}
}
/*******************************************/
* Çíä ÒíÑ ÈÑäÇãå ßÇã ÓÑíÇá ÑÇ ÇÒ äÑã ÇÝÒÇÑ ãí íÑÏ æ ÏÑ ÇÎÊíÇÑ æíäÏæÒ ÞÑÇÑ ãíÏåÏ
void CAnalyzerView::ComClose()
{
if (m_commctrl.GetPortOpen())
{
m_commctrl.SetPortOpen(FALSE);
}
}
/*******************************************/
* Çíä ÒíÑ ÈÑäÇãå ÊãÇãí ßäÊÑáåÇí ãæÌæÏ ÏÑ äÑã ÇÝÒÇÑ ÑÇ ÝÚÇá ãí äãÇíÏ .

void CAnalyzerView::On()
{
UpdateData(TRUE);
switch(trans)
{
case 1:
GetDlgItem(IDC_CLICK1)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 2:
GetDlgItem(IDC_CLICK2)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 3:
GetDlgItem(IDC_CLICK3)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 4:
GetDlgItem(IDC_CLICK4)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 6:
GetDlgItem(IDC_CLICK5)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 8:
GetDlgItem(IDC_CLICK6)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
case 9:
GetDlgItem(IDC_CLICK7)->EnableWindow(TRUE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(TRUE);
UpdateData(FALSE);
break;
}
GetDlgItem(IDC_RESTART)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON8)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO2000)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO1500)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO1000)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO750)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO500)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO250)->EnableWindow(TRUE);
GetDlgItem(IDC_TRANS)->EnableWindow(TRUE);
GetDlgItem(IDC_COM1)->EnableWindow(TRUE);
GetDlgItem(IDC_COM2)->EnableWindow(TRUE);
UpdateData(FALSE);
}
/*******************************************/
* Çíä ÒíÑ ÈÑäÇãå ÊãÇãí ßäÊÑáåÇí ãæÌæÏ ÏÑ äÑã ÇÝÒÇÑ ÑÇ ÛíÑÝÚÇá ãí äãÇíÏ .
void CAnalyzerView::Off()
{
UpdateData(TRUE);
GetDlgItem(IDC_CLICK1)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK2)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK3)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK4)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK5)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK6)->EnableWindow(FALSE);
GetDlgItem(IDC_RESTART)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON8)->EnableWindow(FALSE);
GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO2000)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO1500)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO1000)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO750)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO500)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO250)->EnableWindow(FALSE);
GetDlgItem(IDC_CLICK7)->EnableWindow(FALSE);
GetDlgItem(IDC_VAL_TRANS)->EnableWindow(FALSE);
GetDlgItem(IDC_TRANS)->EnableWindow(FALSE);
GetDlgItem(IDC_COM1)->EnableWindow(FALSE);
GetDlgItem(IDC_COM2)->EnableWindow(FALSE);
UpdateData(FALSE);
}
/*******************************************/
* Çíä ÒíÑ ÈÑäÇãå ÊÇÑíÎ ÔãÓí ÑÇ ãÍÇÓÈå æ ÈÑÇí ÝÇíáåÇ ÞÑÇÑ ãí ÏåÏ .

void CAnalyzerView::Cal_Date()
{
CString day;
CString mount;
CString year;
int year_int1;
int mount_int1;
int day_int1;
Read_init();
year_int1=DATE/100;
day_int1=DATE % 100;
mount_int1=year_int1 % 100;
year_int1=year_int1/100;
day_int1++;
if(mount_int1>=1 && mount_int1<=6)
{
if(day_int1==32)
{
day_int1=1;
mount_int1++;
}
}
if(mount_int1>=7 && mount_int1<=11)
{
if(day_int1==31)
{
day_int1=1;
mount_int1++;
}

}
if(mount_int1==12)
{
if(day_int1==30)
{
day_int1=1;
mount_int1=1;
year_int1++;
}
}
if(year_int1<10)
{
year.Format(“0%d”,year_int1);
}else
{
year.Format(“%d”,year_int1);
}
if(mount_int1<10)
{
mount.Format(“0%d”,mount_int1);
}else
{
mount.Format(“%d”,mount_int1);
}
if(day_int1<10)
{
day.Format(“0%d”,day_int1);
}else
{
day.Format(“%d”,day_int1);
}
file_date.Format(“%s%s%s”,year,mount,day);
DATE=atol(file_date);
Write_init();
}
/*******************************************/
* Çíä ÒíÑ ÈÑäÇãå ÝÇíá init . cfg ÑÇ ÈÇ ãÞÇÏíÑ ãÑÈæØå Ñ ãí ßäÏ æ ÏÑ Âä ÝÇíá ÐÎíÑå ãí äãÇíÏ.
void CAnalyzerView::Read_init()
{
int out_file;
out_file=f.Open(“systeminit.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
f.Close();
}else
{
MessageBox(” Invalid Init.cfg “,”Error”,MB_OK | MB_ICONSTOP);
Exit_prog();
}
trans=init[0];
PORT=init[1];
COMBASE=init[2];
Auto=init[3];
DATE=init[4];
HOUR_OFF=init[5];
MINUTE_OFF=init[6];
m_val_trans=init[7];
}
/*******************************************/
* ÏÑÇíä ÒíÑ ÈÑäÇãå ÈÑäÇãå Shut Down.exe ÝÑÇÎæÇäí ãí ÔæÏ .

void CAnalyzerView::Shut_down()
{
int h_shut=100,m_shut=100;
Read_init();
CTime curTime=CTime::GetCurrentTime();
h_shut=curTime.GetHour();
m_shut=curTime.GetMinute();
m_shut=m_shut-MINUTE_OFF;
if(HOUR_OFF==h_shut){
if(m_shut<=5 && m_shut>=0){
ShellExecute( NULL, NULL, “Shutdown.exe”, NULL, NULL, SW_SHOWNORMAL);
}
}

}
//*************************************
* Çíä ÒíÑ ÈÑäÇãå ÈÑÇí äãÇíÔ áÍÙå Çí æáÊÇŽ æ ÌÑíÇä ÏÑ äÑã ÇÝÒÇÑ ãæÑÏ ÇÓÊÝÇÏå ÞÑÇÑ ãí íÑÏ .
void CAnalyzerView::OnCommEventMonitoring()
{
switch(m_commctrl.GetCommEvent())
{
case 1: // vbMSCommEvSend:
MessageBox(“send”);
break;
case 2: // vbMSCommEvReceive:
KillTimer(ID_LINK);
VariantInit(&var_monitoring);
var_monitoring=m_commctrl.GetInput();
var_monitoring.vt = VT_BSTR;
t_monitoring[l_monitoring]=var_monitoring.bstrVal;
size_len_monitoring[l_monitoring]=t_monitoring[l_monitoring].GetLength();
SaveMonitoring();
t_monitoring[l_monitoring]=” “;
SysFreeString(var_monitoring.bstrVal);
l_monitoring++;
VariantClear(&var_monitoring);
return;
break;
case 3: // vbMSCommEvCTS:
MessageBox(“error”);
break;
case 4: // vbMSCommEvDSR:
MessageBox(“error”);
break;
case 5: // vbMSCommEvCD:
MessageBox(“error”);
break;
case 6: // vbMSCommEvRing:
MessageBox(“error”);
break;
case 7: // vbMSCommEvEOF:
MessageBox(“error”);
break;
case 1001: // vbMSCommErBreak:
MessageBox(“error”);
break;
case 1002: // vbMSCommErCTSTO:
MessageBox(“error”);
break;
case 1003: // vbMSCommErDSRTO:
MessageBox(“error”);
break;
case 1004: // vbMSCommErFrame:
MessageBox(“error”);
break;
case 1006: // vbMSCommErOverrun:
MessageBox(“error”);
break;
case 1007: // vbMSCommErCDTO:
MessageBox(“error”);
break;
case 1008: // vbMSCommErRxOver:
MessageBox(“error”);
break;
case 1009: // vbMSCommErRxParity:
MessageBox(“error”);
break;
case 1010: // vbMSCommErTxFull:
MessageBox(“error”);
break;
}
}
//*************************************
* Çíä ÒíÑ ÈÑäÇãå ãÞÇÏíÑ æáÊÇŽ æ ÌÑíÇä ÑÇ ÇÒ æÑÊ ÑÝÊå æ ÏÑ Ñæí ÕÝÍå äÔÇä ãí ÏåÏ .
void CAnalyzerView::SaveMonitoring()
{
int b_monitoring;

در این سایت فقط تکه هایی از این مطلب با شماره بندی انتهای صفحه درج می شود که ممکن است هنگام انتقال از فایل ورد به داخل سایت کلمات به هم بریزد یا شکل ها درج نشود

شما می توانید تکه های دیگری از این مطلب را با جستجو در همین سایت بخوانید

ولی برای دانلود فایل اصلی با فرمت ورد حاوی تمامی قسمت ها با منابع کامل

اینجا کلیک کنید

for(z_monitoring=0;z_monitoring<size_len_monitoring[l_monitoring];z_monitoring++)
{
b_monitoring=t_monitoring[l_monitoring][z_monitoring];
counter_monitoring++;
if(b_monitoring<0)
{

b_monitoring=256+b_monitoring;
}
if(b_monitoring==1)
{
b_monitoring=0;
}
if(b_monitoring==254){
counter_monitoring=0;
}
switch(counter_monitoring)
{
case 1:
m_amp1=b_monitoring*zarib;
break;
case 2:
m_amp2=b_monitoring*zarib;
break;
case 3:
m_amp3=b_monitoring*zarib;
break;
case 4:
m_vol1=b_monitoring;
break;
case 5:
m_vol2=b_monitoring;
break;
case 6:
m_vol3=b_monitoring;
break;
case 7:
level=b_monitoring;
DisLevel();
break;
}
}
UpdateData(FALSE);
}
//*************************************
* Çíä ÒíÑ ÈÑäÇãå ÈÑÇí äãÇíÔ ÓØÍ ÍÇÝÙå ÏÓʐÇå ÏÑ ÏÇÎá äÑã ÇÝÒÇÑ ãæÑÏ ÇÓÊÝÇÏå ÞÑÇÑ ãí íÑÏ .
void CAnalyzerView::DisLevel()
{
if(level>=0x0 && level<0x11){
s_prog.SetPos(1);
m_info=”Low”;
UpdateData(FALSE);
return;
}
if(level>=0x11 && level<0x22){
m_info=”Low”;
s_prog.SetPos(2);
UpdateData(FALSE);
return;
}
if(level>=0x22 && level<0x33){
m_info=”Low”;
s_prog.SetPos(3);
UpdateData(FALSE);
return;
}
if(level>=0x33 && level<0x44){
m_info=”Medium”;
s_prog.SetPos(4);
UpdateData(FALSE);
return;
}
if(level>=0x44 && level<0x55){
m_info=”Medium”;
s_prog.SetPos(5);
UpdateData(FALSE);
return;
}
if(level>=0x55 && level<0x66){
m_info=”Medium”;
s_prog.SetPos(6);
UpdateData(FALSE);
return;
}
if(level>=0x66 && level<0x77){
m_info=”Medium”;
s_prog.SetPos(7);
UpdateData(FALSE);
return;
}
if(level>=0x77 && level<=0x7f){
m_info=”Medium”;
if(level==0x7f){
m_info=”Full”;
}
s_prog.SetPos(8);
UpdateData(FALSE);
return;
}
}
/************************************/
Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÇÌÑÇ ãí ÔæÏ ßå ÕÝÍå ÑÝÊä ßáãå ÑãÒ ÇÌÑÇ ãí ÔæÏ æ íß ßáãå ÑãÒ ÚÈæÑ ÇÒ ßÇÑÈÑ ãí íÑÏ .
void CMsg1View::OnOK()
{
int password,super_pass,out_file;
CFile f;
int init[50];
UpdateData(TRUE);
out_file=f.Open(“systemsystem.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
password=init[0]-4321;
super_pass=init[4]-4321;
f.Close();
}else
{
MessageBox(” Invalid System.cfg “,”Error”,MB_OK | MB_ICONSTOP);
exit(1);
}
if(m_pass==super_pass)
{
out_pass=2;
}
if(m_pass==password)
{
out_pass=1;
}
if(m_pass!=password && m_pass!=super_pass)
{
out_pass=0;
MessageBox(” Invalid Password “,”Password”,MB_OK | MB_ICONSTOP);
}

CDialog::OnOK();
}
void CMsg1View::OnCancel()
{

out_pass=0;
CDialog::OnCancel();
}
//////////////////////////////////////////////////////
* Çíä ÒíÑ ÈÑäÇãå ÈÑÇí ÚæÖ ßÑÏä ßáãå ÑãÒ ÓíÓÊã ãæÑÏ ÇÓÊÝÇÏå ÞÑÇÑ ãí íÑÏ .
void CMsg1View::OnChang()
{
chang_pass.m_old_pass=2222;
chang_pass.m_new_pass=3333;
chang_pass.m_confrim_pass=4444;
chang_pass.m_super_old_pass=5555;
chang_pass.m_super_new_pass=6666;
chang_pass.m_super_confrim_pass=7777;
chang_pass.DoModal();

}
//////////////////////////////////////////////////////////////
// CMsg2View message handlers
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäíßå äÌÑå ÊÚæíÖ ßáãå ÑãÒ ÇÌÑÇ ãí ÔæÏ Çíä ÒíÑ ÈÑäÇãå ÝÑÇÎæÇäí ãí ÔæÏ .
void CMsg2View::OnOK()
{
CFile f;
int password,super_pass,out_file;
int hour;
int minute;
int second;
int init[50];
UpdateData(TRUE);
out_file=f.Open(“systemsystem.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
password=init[0]-4321;
hour=init[1];
minute=init[2];
second=init[3];
super_pass=init[4]-4321;
f.Close();
}else
{
MessageBox(” Invalid System.cfg “,”Error”,MB_OK | MB_ICONSTOP);
exit(1);
}
if(m_old_pass==password)
{
if(m_new_pass==m_confrim_pass)
{
f.Open(“systemsystem.cfg”,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
init[0]=m_new_pass+4321;
init[1]=hour;
init[2]=minute;
init[3]=second;
init[4]=super_pass+4321;
f.Write(init,50);
f.Close();
}
else
{
MessageBox(” Confrim Password —–> is Mistake “,”Password”,MB_OK | MB_ICONSTOP);
}
}
else
{
MessageBox(” OLd Password —–> is Mistake “,”Password”,MB_OK | MB_ICONSTOP);
}
CDialog::OnOK();
}
void CMsg2View::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CMsg2View::OnOk2()
{
CFile f;
int password,super_pass,out_file;
int hour;
int minute;
int second;
int init[50];
UpdateData(TRUE);
out_file=f.Open(“systemsystem.cfg”,CFile::modeRead | CFile::typeBinary);
if(out_file==1)
{
f.Read(init,50);
password=init[0]-4321;
hour=init[1];
minute=init[2];
second=init[3];
super_pass=init[4]-4321;
f.Close();
}else
{
MessageBox(” Invalid System.cfg “,”Error”,MB_OK | MB_ICONSTOP);
exit(1);
}
if(m_super_old_pass==super_pass)
{
if(m_super_new_pass==m_super_confrim_pass)
{
f.Open(“systemsystem.cfg”,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
init[0]=password+4321;
init[1]=hour;
init[2]=minute;
init[3]=second;
init[4]=m_super_new_pass+4321;
f.Write(init,50);
f.Close();
}
else
{
MessageBox(” Confrim Super Password —–> is Mistake “,”Password”,MB_OK | MB_ICONSTOP);
}
}
else
{
MessageBox(” OLd Super Password —–> is Mistake “,”Password”,MB_OK | MB_ICONSTOP);
}
CDialog::OnOK();
}
//////////////////////////////////////////////////////////////
// CMsg4View message handlers
* Çíä ÒíÑ ÈÑäÇãå ÒãÇäí ÇÌÑÇ ãí ÔæÏ ßå äÌÑå ãÑÈæØ Èå ãÍÇÓÈå ÈåÇí ÇäÑŽí æßíáæ æÇÊ ãÕÑÝí ÝÑÇÎæÇäí ãí ÔæÏ .
void CMsg4View::OnCalculate()
{
FILE *in;
int price_full=0;
int kw_aoj_full=0;
int kw_adi_full=0;
int kw_kam_full=0;
UpdateData(TRUE);
year_int1=m_date1/100;
day_int1=m_date1 % 100;
mount_int1=year_int1 % 100;
year_int1=year_int1/100;
year_int2=m_date2/100;
day_int2=m_date2 % 100;
mount_int2=year_int2 % 100;
year_int2=year_int2/100;
remove(“out.txt”);
while(year_int1!=year_int2 || mount_int1!=mount_int2 || day_int1!=day_int2)
{
int_string();
calculate_kw();
price_full=price_full+m_adi+m_aoj+m_kam;
kw_adi_full=kw_adi_full+kw_adi;
kw_aoj_full=kw_aoj_full+kw_aoj;
kw_kam_full=kw_kam_full+kw_kam;
day_int1++;
if(mount_int1>=1 && mount_int1<=6)
{
if(day_int1==32)
{
day_int1=1;
mount_int1++;
}
}
if(mount_int1>=7 && mount_int1<=11)
{
if(day_int1==31)
{
day_int1=1;
mount_int1++;
}

}
if(mount_int1==12)
{
if(day_int1==30)
{
day_int1=1;
mount_int1=1;
year_int1++;
}
}
}//end of while

دسته بندی : پایان نامه ها

دیدگاهتان را بنویسید