imiaDPd (780151), страница 4
Текст из файла (страница 4)
outtextxy(20*kx,3*ky,"Cnt_com.>");
outtextxy(20*kx,4*ky,"Reg_wrk.>");
outtextxy(32*kx,3*ky,"Time_ordre>");
outtextxy(32*kx,4*ky,"Time_pc___>");
outtextxy(2*kx,5*ky,"Nx");
outtextxy(4*kx,5*ky,"Ex");
/*----------------------------- Devices */
settextjustify(CENTER_TEXT,CENTER_TEXT);
settextstyle(SMALL_FONT,HORIZ_DIR,6);
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
setcolor(WHITE);
/*------------- Invertors */ /* <=### CHANGE ### */
/* invertor 1 */
rectangle(38*kx,9*ky,40*kx,13*ky);
circle(39*kx,13*ky,3);
setcolor(YELLOW);
outtextxy(39*kx,10*ky,"1");
setcolor(LIGHTGRAY);
outtextxy(39*kx,12*ky,"1");
/* invertor 2 */
rectangle(42*kx,9*ky,44*kx,13*ky);
circle(43*kx,13*ky,3);
setcolor(YELLOW);
outtextxy(43*kx,10*ky,"1");
setcolor(LIGHTGRAY);
outtextxy(43*kx,12*ky,"2");
/* invertor 3 */
rectangle(46*kx,9*ky,48*kx,13*ky);
circle(47*kx,13*ky,3);
setcolor(YELLOW);
outtextxy(47*kx,10*ky,"1");
setcolor(LIGHTGRAY);
outtextxy(47*kx,12*ky,"3");
/*------------- Devices of the 1 range */
/* AND 1 */
rectangle(4*kx,19*ky,8*kx,23*ky);
setcolor(YELLOW);
outtextxy(6*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(6*kx,22*ky,"1");
/* AND 2 */
rectangle(9*kx,19*ky,13*kx,23*ky);
setcolor(YELLOW);
outtextxy(11*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(11*kx,22*ky,"2");
/* AND 3 */
rectangle(14*kx,19*ky,18*kx,23*ky);
setcolor(YELLOW);
outtextxy(16*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(16*kx,22*ky,"3");
/* AND 4 */
rectangle(19*kx,19*ky,23*kx,23*ky);
setcolor(YELLOW);
outtextxy(21*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(21*kx,22*ky,"4");
/* AND 5 */
rectangle(25*kx,19*ky,28*kx,23*ky);
setcolor(YELLOW);
outtextxy(27*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(27*kx,22*ky,"5");
/* AND 6 */
rectangle(30*kx,19*ky,33*kx,23*ky);
setcolor(YELLOW);
outtextxy(32*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(32*kx,22*ky,"6");
/* AND 7 */
rectangle(35*kx,19*ky,38*kx,23*ky);
setcolor(YELLOW);
outtextxy(37*kx,20*ky,"&");
setcolor(LIGHTGRAY);
outtextxy(37*kx,22*ky,"7");
/*------------- Devices of the 2 range */
/* OR 1 */
rectangle(4*kx,25*ky,23*kx,28*ky);
setcolor(YELLOW);
outtextxy(22*kx,26*ky,"1");
setcolor(LIGHTGRAY);
outtextxy(14*kx,27*ky,"1");
/* OR 2 */
rectangle(25*kx,25*ky,38*kx,28*ky);
setcolor(YELLOW);
outtextxy(37*kx,26*ky,"1");
setcolor(LIGHTGRAY);
outtextxy(32*kx,27*ky,"2");
/*----------------------------- Entrances */
setcolor(LIGHTGREEN);
settextstyle(SMALL_FONT,HORIZ_DIR,6);
outtextxy(1*kx,6*ky,"X1");
outtextxy(1*kx,7*ky,"X2");
outtextxy(1*kx,8*ky,"X3");
/*----------------------------- Invert. Entrances */
outtextxy(1*kx,14*ky,"Y3");
outtextxy(1*kx,15*ky,"Y2");
outtextxy(1*kx,16*ky,"Y1");
/*----------------------------- Exits */
setcolor(LIGHTGREEN);
settextstyle(SMALL_FONT,HORIZ_DIR,6);
outtextxy(14*kx,31*ky,"Z1");
outtextxy(32*kx,31*ky,"Z2");
setcolor(CYAN);
outtextxy(25*kx,33*ky,title_10); /* Z1=... */
outtextxy(25*kx,35*ky,title_11); /* Z2=... */
/*----------------------------- Wire */
setcolor(WHITE);
/* X1 */
line(5*kx,6*ky,47*kx,6*ky);
circle(47*kx,6*ky,2);
line(47*kx,6*ky,47*kx,9*ky);
/* X2 */
line(5*kx,7*ky,43*kx,7*ky);
circle(43*kx,7*ky,2);
line(43*kx,7*ky,43*kx,9*ky);
/* X3 */
line(5*kx,8*ky,39*kx,8*ky);
circle(39*kx,8*ky,2);
line(39*kx,8*ky,39*kx,9*ky);
/* Y1 */
line(5*kx,16*ky,47*kx,16*ky);
circle(47*kx,16*ky,2);
line(39*kx,13*ky,39*kx,14*ky);
/* Y2 */
line(5*kx,15*ky,43*kx,15*ky);
circle(43*kx,15*ky,2);
line(43*kx,13*ky,43*kx,15*ky);
/* Y3 */
line(5*kx,14*ky,39*kx,14*ky);
circle(39*kx,14*ky,2);
line(47*kx,13*ky,47*kx,16*ky);
/*------------- To AND 1 */
line(5*kx,15*ky,5*kx,19*ky);
circle(5*kx,15*ky,2);
line(6*kx,16*ky,6*kx,19*ky);
circle(6*kx,16*ky,2);
line(7*kx,8*ky,7*kx,19*ky);
circle(7*kx,8*ky,2);
/*------------- To AND 2 */
line(10*kx,16*ky,10*kx,19*ky);
circle(10*kx,16*ky,2);
line(11*kx,14*ky,11*kx,19*ky);
circle(11*kx,14*ky,2);
line(12*kx,7*ky,12*kx,19*ky);
circle(12*kx,7*ky,2);
/*------------- To AND 3 */
line(15*kx,14*ky,15*kx,19*ky);
circle(15*kx,14*ky,2);
line(16*kx,15*ky,16*kx,19*ky);
circle(16*kx,15*ky,2);
line(17*kx,6*ky,17*kx,19*ky);
circle(17*kx,6*ky,2);
/*------------- To AND 4 */
line(20*kx,6*ky,20*kx,19*ky);
circle(20*kx,6*ky,2);
line(21*kx,7*ky,21*kx,19*ky);
circle(21*kx,7*ky,2);
line(22*kx,8*ky,22*kx,19*ky);
circle(22*kx,8*ky,2);
/*------------- To AND 5 */
line(26*kx,8*ky,26*kx,19*ky);
circle(26*kx,8*ky,2);
line(27*kx,7*ky,27*kx,19*ky);
circle(27*kx,7*ky,2);
/*------------- To AND 6 */
line(31*kx,8*ky,31*kx,19*ky);
circle(31*kx,8*ky,2);
line(32*kx,6*ky,32*kx,19*ky);
circle(32*kx,6*ky,2);
/*------------- To AND 7 */
line(36*kx,7*ky,36*kx,19*ky);
circle(36*kx,7*ky,2);
line(37*kx,6*ky,37*kx,19*ky);
circle(37*kx,6*ky,2);
/*------------- To OR 1 */
line( 6*kx,23*ky, 6*kx,25*ky);
line(11*kx,23*ky,11*kx,25*ky);
line(16*kx,23*ky,16*kx,25*ky);
line(21*kx,23*ky,21*kx,25*ky);
/*------------- To OR 2 */
line(27*kx,23*ky,27*kx,25*ky);
line(32*kx,23*ky,32*kx,25*ky);
line(37*kx,23*ky,37*kx,25*ky);
/*------------- To EXIT */
line(14*kx,28*ky,14*kx,30*ky);
line(32*kx,28*ky,32*kx,30*ky);
/* */
return 0;
}
/*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
logic_0() /* <=### CHANGE ### */
{
/*------------- Devices inventors 1-3 */
Y1=~X1&1;
Y2=~X2&1;
Y3=~X3&1;
/*------------- Devices of the 1 range */
And1=Y2 & Y1 & X3;
And2=Y1 & Y3 & X2;
And3=Y3 & Y2 & X1;
And4=X1 & X2 & X3;
And5=X3 & X2;
And6=X3 & X1;
And7=X2 & X1;
/*------------- Devices of the 2 range */
Or1=And1|And2|And3|And4;
Or2=And5|And6|And7;
/* */
return 0;
}
/*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
int bit(int x,int y,int bit)
/* 0 or 1 on the wire */
{
settextstyle(SMALL_FONT,HORIZ_DIR,5);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setbkcolor(BLACK);
if(bit==0)
{
if(!Flag_bit) setcolor(BLACK);
else setcolor(LIGHTBLUE);
outtextxy(x,y,"0");
}
else
{
if(!Flag_bit) setcolor(BLACK);
else setcolor(LIGHTRED);
outtextxy(x,y,"1");
}
/* */
return 0;
}
/*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
int all_bit_0() /* <=### CHANGE ### */
{
/*------------- Variables */
static int x1,x2,x3,
y1,y2,y3,
and1,and2,and3,and4,and5,and6,and7,
or1,or2;
int kx; /* Scale of the draft */
int ky;
/*-------------*/
kx=Maxx/COL_D;
ky=Maxy/ROW_D;
/*----------------------------- Erase preceding entranse */
Flag_bit=0;
bit(4*kx,6*ky,x1); /* bit X1 */
bit(4*kx,7*ky,x2); /* bit X2 */
bit(4*kx,8*ky,x3); /* bit X3 */
/*------------- Devices inventors 1-3 */
bit(4*kx,14*ky,y3); /* bit Y3 */
bit(4*kx,15*ky,y2); /* bit Y2 */
bit(4*kx,16*ky,y1); /* bit Y1 */
/*------------- Devices of the 1 range */
bit( 7*kx,24*ky,and1); /* AND 1 */
bit(12*kx,24*ky,and2); /* AND 2 */
bit(17*kx,24*ky,and3); /* AND 3 */
bit(22*kx,24*ky,and4); /* AND 4 */
bit(28*kx,24*ky,and5); /* AND 5 */
bit(33*kx,24*ky,and6); /* AND 6 */
bit(38*kx,24*ky,and7); /* AND 7 */
/*------------- Devices of the 2 range */
bit(15*kx,29*ky,or1); /* AND 1 */
bit(33*kx,29*ky,or2); /* AND 2 */
/*----------------------------- Display next entrance now */
Flag_bit=1;
bit(4*kx,6*ky,X1); /* bit X1 */
bit(4*kx,7*ky,X2); /* bit X2 */
bit(4*kx,8*ky,X3); /* bit X3 */
/*------------- Devices inventors 1-3 */
bit(4*kx,14*ky,Y3); /* bit Y3 */
bit(4*kx,15*ky,Y2); /* bit Y2 */
bit(4*kx,16*ky,Y1); /* bit Y1 */
/*------------- Devices of the 1 range */
bit( 7*kx,24*ky,And1); /* AND 1 */
bit(12*kx,24*ky,And2); /* AND 2 */
bit(17*kx,24*ky,And3); /* AND 3 */
bit(22*kx,24*ky,And4); /* AND 4 */
bit(28*kx,24*ky,And5); /* AND 5 */
bit(33*kx,24*ky,And6); /* AND 6 */
bit(38*kx,24*ky,And7); /* AND 7 */
/*------------- Devices of the 2 range */
bit(15*kx,29*ky,Or1); /* AND 1 */
bit(33*kx,29*ky,Or2); /* AND 2 */
/*------------- Keep in mind */
x1=X1; x2=X2; x3=X3;
y1=Y1; y2=Y2; y3=Y3;
and1=And1; and2=And2; and3=And3;
and4=And4; and4=And4; and5=And5;
and6=And6; and7=And7;
or1=Or1; or2=Or2;
/* */
return 0;
}
/*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
int hand_order_var0() /* <=### CHANGE ### */
{
char ch[2];
/* Order of the commands */
for(;;)
{
BELL;
cputs("\n\r Command X1 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X1=1; break;}
if(ch[0]=='0') {X1=0; break;}
}
for(;;)
{
BELL;
cputs("\n\r Command X2 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X2=1; break;}
if(ch[0]=='0') {X2=0; break;}
}
for(;;)
{
BELL;
cputs("\n\r Command X3 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X3=1; break;}
if(ch[0]=='0') {X3=0; break;}
}
/* */
return 0;
}
/*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
int hand_order_var1() /* <=### CHANGE ### */
{
char ch[3];
/* Order of the commands */
for(;;)
{
BELL;
cputs("\n\r Command X1 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X1=1; break;}
if(ch[0]=='0') {X1=0; break;}
}
for(;;)
{
BELL;
cputs("\n\r Command X2 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X2=1; break;}
if(ch[0]=='0') {X2=0; break;}
}
for(;;)
{
BELL;
cputs("\n\r Command X3 (0 or 1) --> ");
cscanf("%1s",&ch);
if(ch[0]=='1') {X3=1; break;}
if(ch[0]=='0') {X3=0; break;}
}
/* Order of the times */
for(;;)
{
BELL;
cputs("\n\r Time Hour (0-24) --> ");
cscanf("%2s",&ch);
if((isdigit(ch[0]))&&(isdigit(ch[1]))&&(ch[2]=='\0')||
(isdigit(ch[0]))&&(ch[1]=='\0'))
Ho=atoi(ch);
else continue;
if(Ho<=24) break;
else continue;
}
for(;;)
{
BELL;
cputs("\n\r Time Min. (0-60) --> ");
cscanf("%2s",&ch);
if((isdigit(ch[0]))&&(isdigit(ch[1]))&&(ch[2]=='\0')||
(isdigit(ch[0]))&&(ch[1]=='\0'))
Mo=atoi(ch);
else continue;
if(Mo<=60) break;
else continue;
}
for(;;)
{
BELL;
cputs("\n\r Time Sec. (0-60) --> ");
cscanf("%2s",&ch);
if((isdigit(ch[0]))&&(isdigit(ch[1]))&&(ch[2]=='\0')||
(isdigit(ch[0]))&&(ch[1]=='\0'))
So=atoi(ch);
else continue;















