Giáo trình hình thành phân mạch ứng dụng điều chế thiết bị bán dẫn chứa các mạch logic điện tử p9

7 9 0
Giáo trình hình thành phân mạch ứng dụng điều chế thiết bị bán dẫn chứa các mạch logic điện tử p9

Đang tải... (xem toàn văn)

Thông tin tài liệu

Ñeå söû duïng chöông trình DowLoad, tröôùc tieân phaûi veà maøn hình Dos (vì chöông trình ñöôïc vieát trong moâi tröông Dos, khoâng quaûn lyù ñöôïc caùc chöông trình ñieàu khieån thieá[r]

(1)

LUÂÄN VĂN TỐT NGHIỆP 87 }

else

flushall(); }

if(lpEvent->Msg==1) {

if(lpEvent->Posx>=Cx1&&lpEvent->Posx<=Cx2&&lpEvent->Posy>=Cy1&&lpEvent->Posy<=Cy2)

{

OK=0;

goto CompleteCancel; }

if(lpEvent->Posx>=Ox1&&lpEvent->Posx<=Ox2&&lpEvent->Posy>=Oy1&&lpEvent->Posy<=Oy2)

{

OK=1;

goto CompleteOk; }

}

ShowMouse(); }while(1); }

XII CLASS SEND.HPP #include <stdio.h> #include <conio.h> #include <dos.h> #include <MATH.H> #include <COMPLEX.H> #include <PROCESS.H> #include <string.h> #if !defined SEND #define SEND class SEND

{

private:

char OutFile[100]; public:

char *CatFile(char St_add[],char End_add[],char InFile[]); int Out();

int DeleteFile();//se del OutFile };

#endif

extern int Esc(); XIII MODULE SEND.CPP #include "screen.h" #include "send.hpp" #define data 0x378 #define sta 0x379 #define ctr 0x37a

char *SEND::CatFile(char St_add[],char End_add[],char InFile[]) {

char

KyTu_Hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E ','F','a','b','c','d','e','f'};

int

Gtri_Dec[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15}; unsigned int i,DemSpace;

(2)

LUÂÄN VĂN TỐT NGHIỆP 88 unsigned int Value1=0,Value2=0;

char FindPos,FindValue; int Thoigian=0;

FILE *f,*f1;

char t,t1,t2,t3,t4;

// char St_add[]="0000 Hex",End_add[]="000F Hex"; int end_line;

strcpy(OutFile,InFile); i=strlen(OutFile);

{

OutFile[i]='\0';

}while(OutFile[ i]!='.');

strcat(OutFile,"tmp");//dat ten cho file se tao for (FindPos=3;FindPos>=0;FindPos )

for(FindValue=0;FindValue<22;FindValue++) if(St_add[FindPos]==KyTu_Hex[FindValue])

Value1+=pow(16,(3-FindPos))*Gtri_Dec[FindValue]; for (FindPos=3;FindPos>=0;FindPos )

for(FindValue=0;FindValue<22;FindValue++) if(End_add[FindPos]==KyTu_Hex[FindValue])

Value2+=pow(16,(3-FindPos))*Gtri_Dec[FindValue]; f=fopen(InFile,"rt");

f1=fopen(OutFile,"w+t"); fwrite(St_add,4,1,f1); fwrite(End_add,4,1,f1);

{ {

fread(&t1,1,1,f);

}while(t1!='\'');//ngay sau dia chi cua lenh

{

fread(&t1,1,1,f);

}while(t1==' ');//den lenh end_line=0;

{

fread(&t2,1,1,f); Value1++;

DemSpace=0;

{

fread(&t,1,1,f); DemSpace++;

}while(t==' '&&DemSpace<3);//con la lenh hoac dia chi hay da cham dut mot lenh

if(DemSpace>=2)//la ma lenh hoac da ket thuc mot dong lenh {

(3)

LUÂÄN VĂN TỐT NGHIỆP 89 t1=t;

}

if(DemSpace==1) {

t3=t;

fread(&t4,1,1,f); Value1++;

fwrite(&t3,1,1,f1); fwrite(&t4,1,1,f1); fwrite(&t1,1,1,f1); fwrite(&t2,1,1,f1); DemSpace=0;

{

fread(&t,1,1,f); if(t==' ')

DemSpace++;

}while((t=='\''||t==' ')&&DemSpace<3);//con la lenh hoac dia chi hay da cham dut mot lenh

if(DemSpace==2) t1=t;

}

if(DemSpace>2) {

end_line=1; }

}while(end_line==0); }while(Value1<=Value2); fcloseall();

return OutFile; }

// - int SEND::Out()

{

int result,Temp; FILE *f;

char value; int n,dem=0; int Stop=0;

char

KyTu_Hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E ','F','a','b','c','d','e','f'};

int

Gtri_Dec[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15};

if ( (f = fopen(OutFile,"rt")) == NULL) {

OutError("Cannot open input file."); return dem;

}

while(!feof(f)) {

{

result=inportb(sta); result=result & 0x80; Stop=Esc();

}while(result !=0x80&&Stop!=1);//doc busy cho toi !busy = if(Stop==1)

return -1;

(4)

LUÂÄN VĂN TỐT NGHIEÄP 90 if(n==0)

return dem;

for(int z=0;z<22;z++)//doi ky tu gia tri Dec de goi di if(value==KyTu_Hex[z])//nible cao

{

Temp=Gtri_Dec[z]*16; z=22;

}

fread(&value,1,1,f);

for(z=0;z<22;z++)//nible thap if(value==KyTu_Hex[z])

{

Temp=Gtri_Dec[z]+Temp; z=22;

}

outportb(data,Temp);//pow(2,i));//xuat du lieu ghi du lieu

outportb(ctr,0x00);// cho strobe = de bao cho phan thu biet da goi du lieu ghi du lieu

dem++;

{

result=inportb(sta); result=result & 0xC0; Stop=Esc();

}while(result!=0x40&&Stop!=1);//doc ack cho den ack = if(Stop==1)

return -1;

outportb(ctr,0x01);// cho strobe = de bao cho phan thu biet da goi xong mot byte du lieu ghi du lieu

}

return 0; }

// - int SEND::DeleteFile()

{

return remove(OutFile); }

// - int Esc()

{

if(kbhit())//nhan Esc de thoat {

if(getch()==27) {

OutError("Task is not complete !!!"); }

else

flushall(); return 1; }

return 0; }

XIV.CLASS TEXTBOX.HPP #include <string.h> #if !defined TEXTBOX #define TEXTBOX class TEXTBOX

{

private:

(5)

LUÂÄN VĂN TỐT NGHIỆP 91 int Color,Color1;

char S[100],S1[100];

char Dri[100],Path_var[100],Name[100],TenFile[100],SubFile[100]; int chiso;

public:

TEXTBOX() {S[0]='\0';}//S1="Duong dan";}

void InitTextBox(int x1,int y1,int x2,int y2,int color,int color1,char s[]);

void Path();

void PressTextBox(); void OutTextBox(); int Left(){return l;} int Top(){return t;} int Right(){return r;} int Bottom(){return b;}

void DelChar(int length);//,int xoa);//de xoa ky tu gap phim del tai texbox

void InsertChar(char c);

void GetS(char s[]){strcpy(s,S);}; void GetS_in(char s[]){strcpy(S,s);} int DuongDan(char s[]);

void Get_path(char s[]){strcpy(s,Path_var);}; void Get_name();

}; #endif

XV.MODULE TEXTBOX.CPP #include <dir.h> #include <stdio.h> #include <conio.h> #include <graphics.h> #include <string.h> #include <dos.h> #include <ctype.h> #include "textbox.hpp" #include "mouse.h"

// -

void TEXTBOX::InitTextBox(int x1,int y1,int x2,int y2,int color,int color1,char s[])

{

char buffer[MAXPATH]; l=x1;t=y1;r=x2;b=y2; Color=color;

Color1=color1; strcpy(S1,s);

getcwd(buffer, MAXPATH); strcpy(S,buffer);

strcat(S,"\\"); }

// - void TEXTBOX::OutTextBox()

{

setfillstyle(SOLID_FILL,Color); bar(l,t,r,b);

setcolor(WHITE); line(l,b,r,b); line(r,t,r,b);

(6)

LUÂÄN VĂN TỐT NGHIỆP 95 C SỬ DỤNG CHƯƠNG TRÌNH DOWNLOAD

Để sử dụng chương trình DowLoad, trước tiên phải hình Dos (vì chương trình viết môi trương Dos, không quản lý chương trình điều khiển thiết bị sẳn có máy, thoát Dos để tránh xung đột chương trình)

Gọi tên Demo.exe, lúc hình lên sau:

Để chọn file cách gõ phím, click chuột vào Open File

Nếu nhắp nút pulldown chọn file theo kiểu click chuột (hình sau) Chọn ổ đĩa, chọn loại file, chọn tên file click OK để chọn file

Nuùt pulldown

(7)

LUÂÄN VĂN TỐT NGHIỆP 96

Sau chọn xong file bảng “Free memory request” xuất địa đầu cuối, dung lượng nhớ sử dụng

Sau click Send để gởi liệu

Ngày đăng: 01/04/2021, 18:08

Tài liệu cùng người dùng

Tài liệu liên quan