1. Trang chủ
  2. » Giáo án - Bài giảng

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 11 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 333,02 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Ñ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]

Trang 1

}

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;

Trang 2

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);

do

{

OutFile[i]='\0';

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

strcat(OutFile,"tmp");//dat ten cho file se tao ra

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);

do

{

do

{

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

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

do

{

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

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

end_line=0;

do

{

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

Value1++;

DemSpace=0;

do

{

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 {

fwrite(&t1,1,1,f1);

fwrite(&t2,1,1,f1);

Trang 3

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;

do

{

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))

{

do

{

result=inportb(sta);

result=result & 0x80;

Stop=Esc();

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

return -1;

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

Trang 4

if(n==0)

return dem;

for(int z=0;z<22;z++)//doi ky tu ra 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 ra thanh ghi du lieu

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

dem++;

do

{

result=inportb(sta);

result=result & 0xC0;

Stop=Esc();

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

return -1;

outportb(ctr,0x01);// cho strobe = 0 de bao cho phan thu biet da goi xong mot byte du lieu ra thanh 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:

int l,t,r,b;

Trang 5

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 khi 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);

setcolor(BLACK);

line(l,t,r,t);

line(l,t,l,b);

Trang 6

C SỬ DỤNG CHƯƠNG TRÌNH DOWNLOAD

Để sử dụng chương trình DowLoad, trước tiên phải về màn hình Dos (vì

chương trình được viết trong môi trương Dos, không quản lý được các chương trình điều khiển thiết bị sẳn có trong máy, thoát về Dos để tránh những xung đột chương trình)

Gọi tên Demo.exe, lúc đó màn hình sẽ hiện lên như sau:

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

Nếu nhắp nút pulldown thì sẽ 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 và click OK để chọn file

Nút pulldown

Ô nhập text

Trang 7

Sau khi chọn xong file thì trong bảng “Free memory request” xuất hiện các địa chỉ đầu cuối, và dung lượng bộ nhớ sẽ sử dụng

Sau đó click Send để gởi dữ liệu đi

Khi quá trình truyền file kết thúc thì xuất hiện thông báo “Task is complete.”

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

🧩 Sản phẩm bạn có thể quan tâm

w