Syscont (779991), страница 4
Текст из файла (страница 4)
[211] unsigned long Interval_counted=0;
[212] /* REVERS COUNT (!!!) =Interval_ordered-Interval_counted
[213] [ look : Int_cnt() with revers */
[214] unsigned int Hint_cnt,Mint_cnt,Sint_cnt;
[215] /*---- Time PC */
[216] struct time Time_now;
[217] unsigned long Time_pc_counted=0; /* Max: 4 294 967 295 s */
[218] unsigned int H,M,S;
[219] /*---- Time ordered */
[220] unsigned int Ho,Mo,So;
[221] unsigned long Time_ordered=0; /* Max: 4 294 967 295 s */
[222] /*---- Files */
[223] FILE *Fp1,*Fp2;
[224] /*---- Tables */
[225] int Maxx,Maxy; /* Max. dimens. of the screen in the pix. */
[226] /*---- Tables 1 (Left) */
[227] int Left_x_1;
[228] int Right_x_1;
[229] int Left_y_1;
[230] int Right_y_1;
[231] /*---- Tables 2 (Right) */
[232] int Left_x_2;
[233] int Right_x_2;
[234] int Left_y_2;
[235] int Right_y_2;
[236] /*----*/
[237] int Font[8]; /* NN user characters */
[238] /*---- Texts of the Title sheet */
[239] char *Title_1=
[240] " Moscow State Academy Instrumentation & Informatics MGAPI ";
[241] char *Title_2=
[242] " S Y S T E M C O N T R O L A E S ";
[243] char *Title_3=
[244] " Student: L.V. Doronina ";
[245] char *Title_4=
[246] " Group: IS 4-94-02 (d); Code: 94505 ";
[247] char *Title_5=
[248] " Discipline: Programming and bases of algorithms (3401) ";
[249] char *Title_6=
[250] " Specialty: 2102 ";
[251] char *Title_7=
[252] " Chair Mechatronics of the systems industrial (IS-4) ";
[253] char *Title_8=
[254] " Teacher: A.E. Stefanovich ";
[255] char *Title_9=
[256] " Year: 2005 ";
[257] char *Title_10=
[258] " ( a u t o m a t i c ) ";
[259] /*----*/
[260] int Flag_ini;
[261] /*########################################### MAIN */
[262] void main()
[263] { /*------------------- Beguin Main() */
[264] /*---- Variables */
[265] /*----*/
[266] Title_sheet();
[267] Flag_ini=NOT_INI;
[268] /****************************** Work of the user */
[269] Choice_regime_work();
[270] /*=========================== Regimes hand 0 - 2 */
[271] /*---- 0. Exit
[272] Not work of the user */
[273] if(Regime_work[0]=='0') exit(EXIT_SUCCESS);
[274] /*---- 1. Hand Command
[275] Yes work of the user: Input address, command and interval */
[276] else
[277] if(Regime_work[0]=='1') Hand_order_var1();
[278] /*---- 2. Hand Time - Hand Command
[279] Yes work of the user: Input address, command and time */
[280] else
[281] if(Regime_work[0]=='2') Hand_order_var2();
[282] /*=========================== Regimes automatic 3 - 6
[283] Yes work of the user: Input name of the file entry */
[284] if((Regime_work[0]=='3') ||
[285] (Regime_work[0]=='4') ||
[286] (Regime_work[0]=='5') ||
[287] (Regime_work[0]=='6'))
[288] {
[289] Openfile_entry();
[290] Get_number_commands();
[291] }
[292] /*---- 3. Commands file with Commands. Hand Interval const.
[293] Yes work of the user: Input interval */
[294] if(Regime_work[0]=='3') Hand_order_var3();
[295] /*---- 4. Commands file with Commands and Intervals var.
[296] Not work of the user */
[297] /*---- 5. Commands file with Times and Commands.
[298] Not work of the user */
[299] /*=============================*/
[300] /*---- 6. Step by step.
[301] Yes work of the user: press "ENTER" */
[302] Black_case();
[303] /****************************** Initialis. of the windows */
[304] Graph_regime();
[305] /*---- Tables 1 (Left) */
[306] Left_x_1=0; /* Const. */
[307] Left_y_1=0; /* Variable */
[308] Right_x_1=Maxx*COMPRESSION_X; /* Const. */
[309] Right_y_1=0; /* Variable */
[310] /*---- Tables 2 (Right) */
[311] Left_x_2=(Maxx*COMPRESSION_X)+
[312] WIND_INTERVAL_X; /* Const. */
[313] Left_y_2=0; /* Variable */
[314] Right_x_2=Maxx; /* Const. */
[315] Right_y_2=0; /* Variable */
[316] /*----*/
[317] Wind_left_ini();
[318] Wind_right_ini();
[319] Flag_ini=YES_INI;
[320] /*----*/
[321] Regime();
[322] File_inp();
[323] File_out();
[324] if((Regime_work[0]=='3') ||
[325] (Regime_work[0]=='4') ||
[326] (Regime_work[0]=='5') ||
[327] (Regime_work[0]=='6'))
[328] Com_num();
[329] /**************************************** Regimes 1 - 6 */
[330] /*============================= REGIME 1
[331] Hand Command */
[332] if(Regime_work[0]=='1')
[333] {/*---- Beguin Regime 1 */
[334] Add_ord();
[335] Com_ord();
[336] Int_ord();
[337] for
[338] (Interval_counted=0;
[339] Interval_counted<Interval_ordered;
[340] Interval_counted++)
[341] {
[342] Get_time_pc_counted();
[343] Time_pc();
[344] Int_cnt();
[345] delay(1000);
[346] }
[347] /* ####### Site of the Driver() ####### */
[348] Mes_exec();
[349] Address_bus();
[350] Device_bus();
[351] Counter_commands++;
[352] Com_cnt();
[353] Black_case();
[354] STOP;
[355] End_program(); /* --> EXIT */
[356] }/*----End Regime 1 */
[357] /*============================= REGIME 2
[358] Hand Time - Hand Command */
[359] else
[360] if(Regime_work[0]=='2')
[361] {/*---- Beguin Regime 2 */
[362] Add_ord();
[363] Com_ord();
[364] Time_ord();
[365] for(;;)
[366] {
[367] Get_time_pc_counted();
[368] Time_pc();
[369] if(Time_pc_counted>=Time_ordered) break;
[370] delay(750);
[371] }
[372] /* ####### Site of the Driver() ####### */
[373] Mes_exec();
[374] Address_bus();
[375] Device_bus();
[376] Counter_commands++;
[377] Com_cnt();
[378] Black_case();
[379] STOP; STOP;
[380] End_program(); /* --> EXIT */
[381] }/*---- End Regime 2 */
[382] /*============================= REGIMES: 3,4
[383] 3. Commands file with Commands. Hand Interval constant.
[384] 4. Commands file with Commands and Intervals variable.*/
[385] else
[386] if((Regime_work[0]=='3') || (Regime_work[0]=='4'))
[387] {/*---- Beguin Regimes 3,4 */
[388] while(1)
[389] {/*----------------------------- Top while(1) */
[390] /* Input: A2,A1,A0,C2,C1,C0 */
[391] if(Regime_work[0]=='3') File_order_var3(); /* --> EXIT */
[392] /* Input: A2,A1,A0,C2,C1,C0,Intrval_ordered */
[393] else
[394] if(Regime_work[0]=='4') File_order_var4(); /* --> EXIT */
[395] Add_ord();
[396] Com_ord();
[397] for
[398] (Interval_counted=0;
[399] Interval_counted<Interval_ordered;
[400] Interval_counted++)
[401] {
[402] Get_time_pc_counted();
[403] Int_ord();
[404] Int_cnt();
[405] Time_pc();
[406] delay(1000);
[407] }
[408] /* ####### Site of the Driver() ####### */
[409] Mes_exec();
[410] Address_bus();
[411] Device_bus();
[412] Counter_commands++;
[413] Com_cnt();
[414] Black_case();
[415] }/*----------------------------- Down while(1) */
[416] }/*--- End regimes 3,4 */
[417] /*============================= REGIMES 5
[418] Commands file with Times and Commands. */
[419] else
[420] if(Regime_work[0]=='5')
[421] {/*---- Beguin Regime 5 */
[422] while(1)
[423] {/*----------------------------- Top while(1) */
[424] File_order_var5(); /* --> EXIT */
[425] Add_ord();
[426] Com_ord();
[427] Time_ord();
[428] for(;;)
[429] {
[430] Get_time_pc_counted();
[431] Time_pc();
[432] if(Time_pc_counted>=Time_ordered) break;
[433] delay(750);
[434] }
[435] /* ####### Site of the Driver() ####### */
[436] Mes_exec();
[437] Address_bus();
[438] Device_bus();
[439] Counter_commands++;
[440] Com_cnt();
[441] Black_case();
[442] }/*----------------------------- Down while(1) */
[443] }/*--- End Regime 5 */
[444] /*============================= REGIMES 6
[445] Step by step */
[446] else
[447] if(Regime_work[0]=='6')
[448] {/*---- Beguin Regime 6 */
[449] while(1)
[450] {/*----------------------------- Top while(1) */
[451] /* Input: A2,A1,A0,C2,C1,C0 */
[452] File_order_var3(); /* --> EXIT */
[453] Add_ord();
[454] Com_ord();
[455] Get_time_pc_counted();
[456] Time_pc();
[457] STOP; /* End of one step */
[458] /* ####### Site of the Driver() ####### */
[459] Mes_exec();
[460] Address_bus();
[461] Device_bus();
[462] Counter_commands++;
[463] Com_cnt();
[464] Time_pc();
[465] Black_case();
[466] }/*----------------------------- Down while(1) */
[467] }/*--- End regime 6 */
[468] } /*------------------- End main */
[469] /*##################################### SUB_PROGRAMMS */
[470] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[471] int Graph_regime()
[472] {
[473] /*---- Variables */
[474] int gdriver=DETECT,gmode,errorcode;
[475] /*---- Graph. initialisation */
[476] initgraph(&gdriver,&gmode,"C:\\TURBOC.3_0\\BGI");
[477] errorcode=graphresult();
[478] if(errorcode != grOk)
[479] {
[480] gotoxy(1,24);
[481] textattr(LIGHTRED+(BLACK<<4));
[482] cprintf
[483] ("GRAPHICS ERROR: %s\n",grapherrormsg(errorcode));
[484] STOP;
[485] exit(EXIT_SUCCESS);
[486] }
[487] Maxx=getmaxx();
[488] Maxy=getmaxy();
[489] /*---- Installuserfont */
[490] Font[0]=installuserfont("bold");
[491] Font[1]=installuserfont("euro"); /* Cyr */
[492] Font[2]=installuserfont("lcom"); /* Cyr */
[493] Font[3]=installuserfont("litt");
[494] Font[4]=installuserfont("sans");
[495] Font[5]=installuserfont("scri"); /* Cyr manuscript */
[496] Font[6]=installuserfont("simp"); /* Cyr */
[497] Font[7]=installuserfont("tscr"); /* Cyr manuscript */
[498] return 0;
[499] }
[500] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[501] Text_regime()
[502] {
[503] closegraph();
[504] restorecrtmode();
[505] textbackground(BLACK);
[506] textcolor(WHITE);
[507] return 0;
[508] }
[509] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[510] int Title_sheet()
[511] {
[512] /*---- Variables */
[513] int x,y;
[514] int kx; /* Scale of the title sheet */
[515] int ky;
[516] int col_rand;
[517] /*---- Graph. initialisation */
[518] Graph_regime();
[519] /*---- Scale of the title sheet */
[520] kx=Maxx/COL;
[521] ky=Maxy/ROW;
[522] /*---- Title 1 */
[523] setcolor(YELLOW);
[524] setbkcolor(BLACK);
[525] settextstyle(SMALL_FONT,HORIZ_DIR,5);
[526] settextjustify(CENTER_TEXT,CENTER_TEXT);
[527] x=Maxx/2;
[528] y=1*ky;
[529] outtextxy(x,y,Title_1); /* MGAPI */
[530] /*---- Frame */
[531] x=1*kx;
[532] y=2*ky;
[533] setcolor(WHITE);
[534] setlinestyle(SOLID_LINE,0,NORM_WIDTH);
[535] Rectangle2(x,y,Maxx,Maxy);
[536] setfillstyle(SOLID_FILL,BLUE);
[537] x=Maxx/2;
[538] y=Maxy/2;
[539] floodfill(x,y,WHITE);
[540] /*---- Text */
[541] settextjustify(CENTER_TEXT,CENTER_TEXT);
[542] setcolor(YELLOW);
[543] settextstyle(SMALL_FONT,HORIZ_DIR,6);
[544] x=Maxx/2;
[545] y=19*ky;
[546] outtextxy(x,y,Title_4); /* Group, Code ... */
[547]
[548] settextstyle(SMALL_FONT,HORIZ_DIR,5);
[549] x=Maxx/2;
[550] y=4*ky;
[551] outtextxy(x,y,Title_7); /* IS-4... */
[552]
[553] settextstyle(SMALL_FONT,HORIZ_DIR,5);
[554] setcolor(LIGHTGRAY);
[555] x=Maxx/2;
[556] y=21*ky;
[557] outtextxy(x,y,Title_6); /* Speciality... */
[558]
[559] x=Maxx/2;
[560] y=22*ky;
[561] outtextxy(x,y,Title_5); /* Discipline... */
[562]
[563] x=Maxx/2;
[564] y=23*ky;