A TC2.0 Writing Technical Station Monitoring

xiaoxiao2021-03-06  26

8 years ago, I accidentally discovered it, I saw it, I still feel very interesting. When you are here, you will see the people who are interested in, remember that the boss of the Advanhua PCL812, hoping to relive the feelings of the year. The main functions are available, 8 channels, 32 points, retain history records, real-time curves, historical curves, line colors, screen protection. The following is the source code, you can also download at http://edsoncy.512j.com/tar/hps.rar. It's going to post two pictures, it is not straight! By the way, Alt X exits twice for two consecutive times, or the mouse click to take the corner square twice.

#include #include #include #include #include #include #include

/ * =================== mouse start ==================================================================================================================================================================================================================== * / int mouse_there INT mouse_visible; union regs mregs;

Void reset_mouse (void) {mouse_there = 0; mouse_visible = 0;

IF (getVect (0x33)! = 0L) {mregs.x.ax = 0; int86 (0x33, & mregs, & mregs); if (mregs.x.ax! = 0) mouse_there = 1;}}

Void pascal set_mouse_position (int x, int y) {if (mouse_there) {mregs.x.ax = 4; mregs.x.cx = x; mregs.x.dx = y; int86 (0x33, & mregs, & mregs); }

Void pascal set_mouse_limits (int x1, int y1, int x2, int y2) {if (mouse_there) {mregs.x.ax = 7; mregs.x.cx = x1; mregs.x.dx = x2; int86 (0x33, & mregs, & mregs); MREGS.X.AX = 8; Mregs.x.cx = Y1; MREGS.X.DX = Y2; INT86 (0x33, & Mregs, & Mregs);}}

Void pascal get_mouse_button (unsigned char * rbutton, int * x, int * y) {if (mouse_there) {mregs.x.ax = 3; int86 (0x33, & mregs, & mregs);

* lbutton = (mregs.x.bx == 1)? 1: 0; * rbutton = (mregs.x.bx == 2)? 1: 0; if (mregs.x.bx == 3) * lbutton = * rbutton = 1; * x = mregs.x.cx; * y = mregs.x.dx;}} / * =================== mouse over == ====================== * /

#define _debug

/ * Define Data.dat Point Num * / # iFNDef_Debug #define filemax 0x3fffff # else #include "math.h" #define pi 3.14159265758 #define filemax 0xfff # ENDIF

#define SCRMAX 600 / * define keyboard * / # define ALT_U 150 # define ALT_D 160 # define ALT_N 177 # define ALT_X 173 # define ALT_T 148 # define ALT_E 146 # define ALT_C 174 # define ALT_M 178 # define ALT_1 248 # define ALT_2 249 #define alt_3 250 # Define alt_4 251 # Define alt_5 252 # define alt_6 253 # Define up 200 # define down 208 # define left 203 # define Right 205 # define enter 13

/ * ============================================================================================================================================================= 2, scr_num = 10, axis = 1; static int tim, intrate, nokeytime, ticker; static int color [16], color_t [16]; static int colume, mousespeed_t, freescreen_t; static long unsigned fpt, ​​fpt_t; static unsigned int Drawpt; static unsigned char Draw_data [scrMax] [16]; unsigned char C [SCRMAX 1] [16]; char * Unit [3] = {"deg.c", "mpa", "kmph"}; char * Port [6] = {"Entra_t", "Entra_P", "Entra_f", "EXIT_T", "EXIT_P", "EXIT_F"};

Time_t Ti, Cur_ti; File * fdata, * fpoint;

Struct Datum {float hi; / * high alarm value * / float lo; / * low alarm value * / float span_lo; / * instruction traffic limited * / float span_hi; / * instruction traffic h h; / * INT VAL; / * 12 bit true value * / float fval; / * after culation * / char strval [10]; / * str value * /} Data [8] [6]; # ifndef _debugextern PCL812 (int, unsigned int *); unsigned int Param [60]; unsigned int pCLDATA [800]; UNSIGNED INT FAR * PCLDAT; #ELSEunsigned int TimeNum; # endif / * ======================= ========== * / void cursor (int stat; Void Draw_3 (int Startx, Int Starty, INT X, INT Y)

Void Interrupt (* Oldtimer) (Void) = NULL; Void Interrupt NewTimer (Void); Void Install (* INT_ADD) (), int tent_num);

INT get_char (void); Void KeyBroad (Void);

Void HeadsCr (void); void head_bar (void); Void Eachline_BacksCr (Void); Void Curve_BacksCr (Void); Void Color_BacksCr (Void); Void FrontsCr (Void);

Void Data_Pro (Void); Void F_init (Void); INT f_fun (int key); void f_write (int offset); void driver_init (void); void span_init (void); / * ========== Move cursor from _old to _cur ======== * / static int curX, cury, oldx, oldy, line_old; static char curbuf [210]; unsigned char mouse_lbutt_press_in_this_time_int;

Void Cursor (int stat (int stat) {Int Shape; if (status! = 0) Putimage (Oldx, Oldy, Curbuf, Copy_put); GetImage (CURX, Cury, Curx 16, Cury 16, Curbuf; * s = curX; s ; * s = Cury; s ; * s = CURX 16; s ; * s = Cury 8; s ; * s = CURX 10; s ; * s = Cury 10 ; S ; * s = CURX 8; s ; * s = Cury 16; s ; * s = curX; s ; * s = Cury; setColue); setFillStyle (Solid_Fill, LightBlue); FillPoly (4, Shape ); SetFillStyle (Solid_Fill, LightGray); Oldx = CURX; Oldy = Cury; Return;} Void Draw_3 (int startX, int start, int x, int y) {int shape [8], * s = shape; * s = STARTX; S ; * s = starty; s ; * s = startX x; s ; * s = start y; s ; * s = startX x; s ; * s = starty-y; s ; * s = STARTX; S ; * s = starty; fillpoly (3, shape);

/ * ========== interrupt function ================= * /

Void Install (* INT_ADD) (), INT INT_NUM) {Disable (); setVect (int_num, int_add); Enable (); Return;}

/ * ------- Interrupt ------- * / void Interrupt NewTimer (Void)

{(* oldtimer) (); if (ticker == 0) / * ----------------------------- * / {ticker = (((TIM% 5) == 0)? 19:18); if ( TIM == 5) TIM = 0; Run_Program = 2; mouse_lbutt_press_in_this_time_int = 0; if (NOKEYTIME <= FREESCREEN) NOKEYTIME ; intRate- -; IF (intRate == 0) {INT_OK ; intrate = intrate;} / * ----------------------------- - * /} --phicker;

Return;}

/ * ============== kybroad fast ==========================================================================================00 INT C; while (1) {rg.h.ah = 1; int86 (0x16, & rg, & rg); if (rg.x.flags & 0x40) {INT86 (0x28, & rg, & rg); Break;} rg. H.ah = 0; int86 (0x16, & rg, & rg); if (rg.h.al == 0) c = rg.h.ah | 128; ELSE C = rg.h.al; Break;} Return C ;} / * ----------------------------------------- * / void keybroad (void) {int key; unsigned char rbutton, lbutton = 0; if (MOUSE_THERE) {oldx = curx; oldy = cury; get_mouse_button (& lbutton, & rbutton, & curx, & cury); if (lbutton) if (mouse_lbutt_press_in_this_time_int) lbutton = 0; Else Mouse_lbutt_press_in_this_time_int = 1;}

Key = GET_CHAR (); if (SCR_NUM <10) {if (key == Enter || lbutton) {IF (CURX> 0 && Curx <24) KEY = Alt_X; Else IF (CURX> 26 && Curx <134 && Cury> 0 && Cury <24) key = ALT_T; else if (curx> 136 && curx <244 && cury> 0 && cury <24) key = ALT_E; else if (curx> 246 && curx <354 && cury> 0 && cury <24) key = ALT_C; else if (curx> 366 && cury> 0 && Curx <639 && Cury <24) Key = Alt_m; Else IF (SCR_NUM <8 && Curx> 540 && Cury> 28 && Curx <639 && Cury <55) Key = Alt_N; Else IF (SCR_NUM == 9 && Cury> 29 && Cury <63 && CURX> 407) Key = alt_1 (CURX-407) / 39; Else IF (SCR_NUM == 9 && Curx> 365 && Cury> 34 && Curx <390 && Cury <46) Key = Alt_u; Else IF (SCR_NUM == 9 && Curx> 365 && Cury> 49 && Curx <390 && Cury <61) Key = Alt_D; Else IF (SCR_NUM == 9 && Cury> 454 && Cury <479 && CURX> 32 && Curx <634) Key = -1; Else } Switch (key) {case alt_n: IF (SCR_NUM <8) {char S [2] = "1"; SCR_NUM ; IF (SCR_NUM> 7) SCR_NUM = 0; (* S) = SCR_NUM; setTextStyle (Triplex_Font , Horiz_Dir, 8); setColor (White); BAR (570, 115, 610, 180); Outtextxy (570, 100, s); s Etcolor (Blue); setTextStyle (default_font, horiz_dir, 1);} Break; Case Alt_x: Run_Program--; Break;

Case alt_t: Table_Backscr (); Break;

Case alt_e: Eachline_backscr (); Break;

Case alt_c: curve_backscr (); break;

Case alt_m: color_backscr (); break; case up: CURY- = mouseespeed; if (Cury <0) Cury = 0; set_mouse_position (curxi); CURSOR (1); Break;

Case Down: Cury = MouseSpeed; if (Cury> 479) Cury = 479; Set_Mouse_Position (CURX, CURY); CURSOR (1); Break;

Case Left: curX- = mouseespeed; if (CURX <0) CURX = 4; set_mouse_position (curX, cury); Cursor (1); Break;

Case Right: CURX = MouseSpeed; if (CURX> 623) CURX = 623; set_mouse_position (curX, cury); Cursor (1); Break;

Case Alt_1: IF (SCR_NUM == 9) {fpt_t = fpt SCRMAX * AXIS; CUR_TI = Ti- (Filemax-Scrmax * Axis) * intrate; f_fun (key);} Break;

CASE ALT_2: IF (SCR_NUM == 9) {fpt_t - = (SCRMAX * AXIS / 2); CUR_TI - = (SCRMAX * AXIS * INTRATE / 2); f_fun (key);} Break;

Case Alt_3: IF (SCR_NUM == 9) {fpt_t- = axis; cur_ti- = axis * intrate; f_fun (key);} Break;

CASE ALT_4: IF (SCR_NUM == 9) {fpt_t = axis; cur_ti = axis * intrate; f_fun (key);} Break

CASE ALT_5: IF (SCR_NUM == 9) {fpt_t = (SCRMAX * AXIS / 2); CUR_TI = (SCRMAX * AXIS * INTRATE / 2); f_fun (key);} Break;

Case alt_6: IF (SCR_NUM == 9) {fpt_t = fpt; cur_ti = ti; f_fun (key);} Break;

Case alt_u: IF (SCR_NUM == 9) {char * s = null; INT I; AXIS << = 1; if (AXIS> 16) AXIS = 1; setColor (RED); BAR (330, 43, 355, 51); Outtextxy (330, 43, ITOA (AXIS, S, 10)); BAR (1,455,633,478); setColor (White); setFillStyle (Solid_Fill, Blue); for (i = 1; i <11; i ) {OutTextxy (626- I * 60, 465, ITOA (i * intrate * axis, s, 10)); OutTextxy (642-i * 60, 465, "m"); BAR (633-i * 60, 455, 635-i * 60, 462);} f_fun (alt_2); } Break; case alt_d: IF (SCR_NUM == 9) {char * s = null; INT I; AXIS >> = 1; IF (AXIS == 0) AXIS = 16; BAR (330, 43, 355, 51); setColor (Red); OutTextxy (330, 43, ITOA (AXIS, S, 10)); Bar (1,455,633,478); setColor (White); setFillStyle; for (i = 1; i <11; i ) { OutTextxy (626-i * 60, 465, ITOA (i * intrate * Axis, s, 10)); OutTextxy (642-i * 60, 465, "m"); bar (633-i * 60, 455, 635-i * 60, 462);}

f_fun (alt_2);} Break;

Case -1: f_write (634-curx); Break;

Default: key = 0; IF (Oldx! = CURX || Oldy! = Cury) Cursor (1); Break;}}

IF (SCR_NUM == 10) {char STR [2]; STR [0] = 16; STR [1] = '/ x0'; switch (key) {copy enter: IF (color <16) { color_t [ colume]; color_t [colume] & = 0x0f; setfillstyle (SOLID_FILL, color_t [colume]); bar (360,123 colume * 15,400,125 colume * 15); setfillstyle (SOLID_FILL, LIGHTGRAY);} else if (colume == 16) {char str [4]; mousespeed_t ; if (mousespeed_t> 20) mousespeed_t = 1; bar (360,360,382,368); itoa (mousespeed_t, str, 10); setcolor (WHITE); outtextxy (360,360, str);} else if (colume == 17) {Char STR [4]; free "_t * = 2; if (FreeScreen_t> 480) Freescreen_t = 60; BAR (360, 375, 382, ​​383); ITOA (FreeScreen_T, STR, 10); setColor (White); Outtextxy (360, 375, STR) } El =; for (i = 0; i <16; i ) color [i] = color_t [i]; mouseespeed = mouseespeed_t; freescreen = freespeed_t; curve_backscr ();} Else curve_backscr ();

CASE UP: BAR (245, 128 Colume * 15, 252, 128 Colume * 15); Colume--; if (Colume <0) Colume = 19; setColor (White); OutTextxy (245, 120 colume * 15, str); break;

Case Down: BAR (245, 128 Colume * 15, 252, 128 Colume * 15); Colume ; if (Colume> 19) Colume = 0; SetColor (White); Outtextxy (245, 120 Colume * 15, Str); BREAK;

DEFAULT: key = 0; Break;}}

IF (key) {if (nokeytime> freescreen {scr_num = 0; Eachline_backscr ();} nokeytime = 0;} return;} / * =================== =================================================== * ----- Draw Head bar ----- - * / void head_bar (void) {setFillStyle (Solid_fill, Black); bar (0, 0, 639, 479);

SetTextStyle (Triplex_Font, Horiz_Dir, 1); SetFillStyle (Solid_Fill, LightGray); SetColor (White);

BAR3D (0,0,24,24,0,0); BAR3D (7, 11, 17, 13, 0); BAR3D (26, 0, 134, 24, 0); Outtextxy (35, 3, " "); BAR3D (136, 0, 244, 24, 0); Outtextxy (150, 3," Each line "); BAR3D (246, 0, 364, 24, 0); Outtextxy (255, 3," Total Curve "); BAR3D (366, 0, 639, 24, 0); Outtextxy (415, 3," The Mis for HPS ");

SetColor (RED); if (SCR_NUM <8) Outtextxy (150, 3, "Each Line"); ELSE IF (SCR_NUM == 8) OutTextxy (35, 3, "Total Table"); Else IF (SCR_NUM == 9 OutTextxy (255, 3, "total curve); else if (SCR_NUM == 10) Outtextxy (415, 3," The Mis for HPS "); setColor (White);

Return;}

/ * -------- Head screen function -------- * / void head_scr (void) {head_bar (); bar3d (150, 150, 489, 320, 4, 4); setColor (blue); Outtextxy (175, 180 "The manage information system"; Outtextxy (175, 215, "for the hps of"); Outtextxy (175, 250, "The pan factory"); OutTextxy (285, 280, "1998.05");

SetTextStyle (default_font, horiz_dir, 1); return;}

/ * ----------- Total Table Back Screen Function: SCR = 8 ------- * / void Table_Backscr (Void) {Register Int i, J; Char S [5]; SCR_NUM = 8; Head_bar ();

/ * MAKE MARKS * / for (i = 0; i <6; i ) {bar3d (i * 100 40, 30, i * 100 135, 50, 3, 3); OutTextxy (i * 100 55, 30, Port [I]);

/ * make line number * / settextStyle (Triplex_Font, Vert_Dir, 1); STRCPY (S, "No.1"); for (i = 0; i <8; i ) {bar3d (0, i * 50 55, 35, i * 50 100, 3, 3); Outtextxy (8, i * 50 58, s); (* (S 3)) ;}

/ * DRAW THE UP_LEFT BOX * / BAR3D (0, 30, 35, 50, 3, 3);

/ * Make 48 indecate boxes * / for (i = 0; i <8; i ) for (j = 0; j <6; j ) bar3d (j * 100 40, i * 50 55, j * 100 135, i * 50 100, 3, 3);

/ * Make Units Boxes * / Bar3d (0, 455, 35, 479, 3); setTextStyle (default_font, horiz_dir, 1); for (i = 0; i <6; i ) {setColor (White); bar3d (i * 100 40, 455, I * 100 135, 479, 3, 3); SetColor (RED); OUTTEXTXY (i * 100 70, 462, Unit [I% 3]);}

Cursor (0); Return;}

/ * ------- Each Line Back Screen Function: SCR = 0 - 7 ------ * / Void Eachline_Backscr (Void) {Register Int i, J; Char S [10];

SCR_NUM = 0; Head_bar ();

/ * make 6 indecate boxes * / for (i = 0; i <6; i ) {bar3d (i * 90, 29, i * 90 85, 184, 3, 3); OutTextxy (i * 90 10, 35, Port [I]);

/ * make 'next' cursor table * / bar3d (540, 28, 639, 55, 0); OutTextxy (570, 31, "Next");

/ * Make a Indecate Box for Time * / BAR3D (540, 60, 634, 85, 3, 3);

/ * Make Line Number Box * / BAR3D (540, 90, 634, 184, 3, 3); Outtextxy (545, 95, "LINE_NUM"); s [0] = '1'; S [1] = '/ x0'; setTextStyle (Triplex_Font, Horiz_Dir, 8); OutTextxy (570, 100, s);

settextstyle (DEFAULT_FONT, HORIZ_DIR, 1); / * make rullor and draw window * / bar3d (0,189,25,447,3,3); bar3d (32,189,634,447,3,3); bar3d (0,454,634,479,3,3); setfillstyle (SOLID_FILL , Blue; for (i = 1; i <4; i ) {OUTTEXTXY (2,186 64 * i, ITOA (25 * (4-i), s, 10); OutTextxy (10, 196 64 * i, " % "); Bar (20, 189 64 * i);} for (i = 1; i <11; i ) {OutTextxy (626-i * 60, 465, ITOA (i * intRate, S, 10 ))); OUTTEXTXY (642-i * 60, 465, "m"); BAR (633-i * 60, 455, 635-i * 60, 462);} setColor (red); for (i = 0; i <6; i ) OutTextxy (i * 90 40, 90, Unit [I% 3]);

BAR (10, 60, 75, 63); setfillstyle (Solid_Fill, RED); BAR (100, 60, 165, 63);

Cursor (0); Return;}

/ * -------- Curve Back Screen Function: Scr = 9 -------- * / Void Curve_Backscr (Void) {Register Int i, J; Char S [5];

SCR_NUM = 9; CUR_TI = Ti; FPT_T = FPT;

HEAD_BAR ();

/ * DRAW DIRECTORY TABLE * / for (i = 0; i <6; i ) BAR3D (407 i * 39, 29, 442 i * 39, 63, 0); setFillStyle (Solid_Fill, Blue); Draw_3 (410 47, 12, 12); Draw_3 (423, 47, 12, 12); DRAW_3 (451, 47, 12, 12); BAR3D (468, 35, 473, 59, 0); Draw_3 (490, 47, 24) 12); DRAW_3 (554, 47, -24, 12); BAR3D (570, 35, 575, 59, 0); Draw_3 (593, 47, -12, 12); DRAW_3 (621, 47, -12, 12); DRAW_3 (634, 47, -12, 12);

SetFillStyle (Solid_Fill, LightGray); SetTextStyle (default_font, horiz_dir, 1);

/ * DRAW TIME BOX * / BAR3D (0, 31, 235, 63, 3, 3); / * Draw Axis Box and Table * / BAR3D (242, 31, 400, 63, 3, 3); BAR3D (365, 34, 390, 46, 0, 0); BAR3D (365, 49, 390, 61, 0); OUTTEXTXY (370, 37, "UP"); Outtextxy (370, 52, "DN"); / * Write Time and Axis * / setColor Blue); OutTextxy (17, 43, CTIME (& Cur_ti)); Outtextxy (250, 43, "Time Axis:"); setColor (red); Outtextxy (330, 43, ITOA (Axis, S, 10)); setColor (WHITE); BAR3D (0, 70, 634, 182, 3, 3); struct (s, "t1:"); for (i = 0; i <8; i ) {setColor (White); OUTTEXTXY (10 I / 4 * 320, 85 i% 4 * 25, s); s [1] ; setColor (red); OutTextxy (110 I / 4 * 320, 85 i% 4 * 25, Unit [0]); }

STRCPY (S, "P1:"); for (i = 0; i <8; i ) {setColor (White); Outtextxy (170 I / 4 * 320, 85 I% 4 * 25, s); s [1] ; setColor (red); Outtextxy (270 I / 4 * 320, 85 i% 4 * 25, Unit [1]);

For (i = 0; i <16; i ) {setFillStyle (Solid_Fill, Color [I]); bar (10 i% 4 * 160, 96 I / 4 * 25, 150 i% 4 * 160, 97 i / 4 * 25);}

SetColor (White); setFillStyle (Solid_Fill, LightGray); BAR3D (0,189,25,447,3,3); BAR3D (32, 189, 634, 447, 3, 3); BAR3D (0,452,636,479,0,0); setFillStyle (Solid_Fill, Blue);

For (i = 1; i <4; i ) {OUTTEXTXY (2,186 64 * i, ITOA (25 * (4-i), s, 10)); OUTTEXTXY (10, 196 64 * i, "%"); BAR (20,189 64 * i, 24, 191 64 * i);} for (i = 1; i <11; i ) {OutTextxy (626-i * 60, 465, ITOA (i * intrate * Axis, s, 10)) OutTextxy (642-i * 60, 465, "m"); bar (633-i * 60, 455, 635-i * 60, 462);}

f_fun (alt_4); cursor (0); return;

/ * ---- Color Options Back Screen: SCR = 10 Key --- * / Void Color_BacksCr (Void) {Int i, Y; Char S [6] [15] = {"Line 1 - T:", " LINE 1 - P: "," MouseSpeed: "," Free Screen: "," << OK >> "," << Cancel >> "}; char STR [10]; SCR_NUM = 10; colume = 0; Head_bar (); BAR3D (200, 70, 439, 430, 3, 3); Outtextxy (250, 80, "System Options"); OutTextxy (250, 95, "============"); setTextStyle Default_Font, Horiz_Dir, 1);

For (i = 0, y = 120; i <16; i , y = 15) {OUTTEXTXY (260, Y, S [I% 2]); (* (S [I% 2] 5)) OutTextxy (260, Y, S [2]); Y = 15; OUTTEXTXY (260, Y, S [3]); Y = 15; OutTextxy (260, Y, S [4]); y = 15; Outtextxy (260, y, s [5]);

STR [0] = 16; STR [1] = '/ x0'; OUTTEXTXY (245, 120, STR);

For (i = 0; i <16; i ) {color_t [i] = color [i]; setFillStyle (Solid_Fill, Color_T [i]); bar (360, 123 i * 15, 400, 125 i * 15);} setfillStyle (Solid_Fill , LIGHTGRAY); mousespeed_t = mousespeed; itoa (mousespeed_t, str, 10); outtextxy (360,360, str); freescreen_t = freescreen; itoa (freescreen_t, str, 10); outtextxy (360,375, str); return;} / * = ========= DO front screen ============================= * / void FrontsCR (void) {Register Int i, j; int DEC Char * s = ""; / * -------- Screen Protect ------ * / if (Nokeytime> = FreeScreen) {setFillStyle (Solid_Fill, Black); BAR (0, 0, 639, 479); setTextStyle (Random (10) 1, Horiz_Dir, Random (4) 1); SetColor (Random (15) 1); OutTextxy (Random (480), Random (480), "The Program Is Running."); setColor (Random (15) 1); Outtextxy (Random (480), Random (480), "Press Arrow Key to Return!"); setFillStyle (SOLID_FILL, LIGHTGRAY); setTextStyle (default_font, horiz_dir, 1);} / * -------- Draw Zmt Front ----- * / else if (SCR_NUM == 8) {setColor (Blue); for (j = 0; j <6; j ) {for (i = 0; i <8; I ) {BAR (j * 100 55, i * 50 70, j * 100 120, i * 50 90); Outtextxy (j * 100 70, i * 50 70, data [i] [ J] .strval);}}} / * ---------- Draw Zht Front ------- * / else if (SCR_NUM <8) {setColor (Blue); for (i = 0; I <6; i ) {BAR (i * 90 10, 73, i * 90 75, 8); Outtextxy (i * 90 10, 73, data [scR_num] [i] .strval); } BAR (555, 70, 618, 77); s = ctime (& Ti); s = 11; (* (S 8)) = '/ 0'; OUTTEXTXY (555, 70, s);

BAR (33, 190, 633, 446); J = DRAWPT 1; For (i = 33; I = SCRMAX) J- = SCRMAX; PUTPIEL (I, 190 Draw_Data [J] [SCR_NUM * 2], Blue); PUTPEL (I, 191 Draw_Data [J] [J], Blue); PUTPIEL (I, 190 Draw_Data [J] [SCR_NUM * 2 1], Red); PUTPIXEL (I, 191 Draw_Data [J], RED);}} Return;} / * =============== File Funtion ====== ============------- Input and process data -------- * / void data_pro (void) {Register INT I, J; Struct Datum * Data_pt; INT DEC, SIGN; CHAR SDEC [10] = ". 0000", s [10]; / * get data * / # ifndef _debug pCL812 (5, param); if (param [45]! = 0) {Printf "A / D Software Data Transfer Failed!"); Exit (1);} #ENDIF

For (i = 0; i <16; i ) {data_pt = & data [I / 2] [I% 2]; # ifndef _debug for (j = 0; j <50; j ) {data_pt-> val = PCLData [i 16 * j]; DATA_PT-> VAL >> = 1;} #Else / * Data Are Simulate Severl Sinusoids 1024 Is Middle Value 20, And 20 IS Used To amplifier Changing Sinusoids * / DATA_PT-> VAL = SIN (Timenum * pi / 6553.2) pi * I / 16.0) * 0x400 0x3ff; TimeNum ; # endif if (data_pt-> val> 0xfff) DATA_PT-> VAL = 0xFFF; DATA_PT-> VAL & = 0x7ff; Data_Pt-> Fval = (float) DATA_PT-> VAL / 2048; DATA_PT-> FVAL = DATA_PT-> SPAN_LO (DATA_PT-> SPAN_LO) * DATA_PT-> FVAL; STRCPY (Data_Pt-> Strval, FCVT (Data_PT- > FVAL, 2, & DEC, & SIGN); STRCPY (SDEC 1, DATA_PT-> STRVAL DEC); STRCPY (DATA_PT-> STRVAL DEC, SDEC);}

/ * ----- Get Time ----- * / Time (& Ti); / * ---- Save for Draw and ----- * / Drawpt ; if (Drawpt> = SCRMAX) DRAWPT = 0 ; For (i = 0; i <16; i ) Draw_data [DRAWPT] [i] = ~ (Data [I / 2] [I% 2] .val >> 3); / * ------ SAVE For file ------ * / fseek (fdata, fpt * 16, seek_set); FWRITE (Draw_Data [Drawpt], 16, 1, FDATA); FPT ; FPT & = FileMax; Rewind (fpoint); FPOINT, "% LD,% LD,% S", FPT, TI, CTIME (& Ti)); Return;}

/ * -------- File Inti ----- * / void f_inti (void) {char C [16]; for (fpt_t = 0; fpt_t <16; fpt_t ) c [fpt_t] = 0xff ;

FPOINT = FOPEN ("Point.dat", "R"); fdata = fopen ("DATA.DAT", "R");

IF (fpoint! = null && fdata! = null) {fscanf (fpoint, "% ld,% ld", & fpt_t, & cur_ti; time (& ti); if (ti - cur_ti Intrate) {for (; cur_ti <= ti; cur_ti = intrate, fpt_t = fpt_t & filemax) {fseek (fdata, fpt_t * 16, seek_set); fwrite (C, 16, 1, fdata);} TIME (& Ti); } Fpt = ftell (fdata) / 16; fpt_t = fpt; while (cur_ti-ti> 1) Time (& Ti);} else {fpoint = null; fdata = null;}}

IF (fpoint == null || fdata == null) {fclose (fpoint); fclose (fdata); fpoint = fopen ("point.dat", "wt"); fdata = fopen ("data.dat", " WB "); for (fpt_t = 0; fpt_t <= filemax; fpt_t ) FWRITE (C, 16, 1, FDATA); REWIND (fdata);} return;} / * ------- File Write Data - ---- * / void f_write (int offset) {INT DEC, SIGN, I; UNSIGNED Char * Ch; Struct Datum * Da; FLOAT F; Char Str [10] = "0.0", strDec [10] = ". 000 "; Time_t Temp; CH = & C [599-Offset] [0]; setColor (blue); setFillStyle (SOLID_FILL, LIGHTGRAY); setTextStyle (default_font, horiz_dir, 1); for (i = 0, da = & data [i / 2] [I% 2]; I <16; i , CH , DA ) {f = 1.0 - (float) * CH / 256; f = da-> span_lo (DA-> span_hi-da-> span_lo) * F; STRCPY (STR, FCVT (F, 2, & Dec, & Sign); STRCPY (STRDEC 1, STR DEC); STRCPY (STR DEC, STRDEC); BAR (50 i% 4 * 160, 85 I / 4 * 25, 100 I% 4 * 160, 93 I / 4 * 25); Outtextxy (50 i% 4 * 160, 85 I / 4 * 25, STR);} bar (17, 43, 220, 51); Temp = CUR_TI-AXIS * OFFSET * INTRATE; OUTTEXTXY (17, 43, CTIME (& TEMP));

SetColor (LightGray); Line (Line_old, 190, Line_OLD, 446); CH = & C [line_old-33] [0]; for (i = 0; i <16; i , ch ) {PUTPIEL (Line_old, 190 * CH, Color [I]); PUTPIEL (LINE_OLD, 191 * CH, Color [I]);} line_old = curX; setColor (Green); Line (Curx, 190, Curx, 446);

Return;}

/ * -------- File Input Data ----- * / int f_fun (int key) {Register INT I, J; INT Color_t; unsigned long int Fi; unsigned char * ch;

FPT_T & = FileMax; FI = (FPT SCRMAX * AXIS) & FileMax; IF ((FPT Fi && (FPT = 0; i -, fi = (FI-axis) & filemax) {fseek (fdata, fi * 16, seek_set); FREAD (C [i], 16, 1, fdata (} F_write (0);

BAR (33, 190, 633, 446); for (i = 0; i <16; i ) IF (color [i]! = lightgray) {ch = & c [0] [i]; j = 0; color_t = color [I]; while (j

Void driver_init (void) {# iFNDef _debug INT I; PCLDAT = PCLDATA; param [0] = 0; / * Board Number * / param [1] = 0x300; / * base I / o address * / param [5] = 10; / * PACER RATE = 2M / (10 * 10) = 20 kHz * / param [6] = 10; param [7] = 0; / * Trigger Mode, 0: PACER TRIGGER * / PARAM [10] = fp_off (PCLDAT); / * Offset of a / d data buffer a * / param [11] = fp_seg (pCLDAT); / * segment of a / d data buffer a * / param [12] = 0; / * Data Buffer B Address, IF Not Used, * / param [13] = 0; / * must set to 0. * / param [14] = 800; / * a / d conversion Number * / param [15] = 0; / * a / D conversion start channel channel * / param [16] = 15; / * a / d conversion stop channel channel * / param [17] = 1; / * Overalll Gain code, 0: /- 2.5V * / PCL812 (3, Param); IF (param [45]! = 0) {Prin TF ("Driver Initialization Failed!"); exit (1);

PCL812 (4, Param); IF (Param [45]! = 0) {Printf ("A / D Initialization!"); exit (1);} #ENDIF}

/ * ----------------------------------- * / void span_init (void) {INT I; Struct Datum * da; intrate = 2; for (i = 0; i <16; i ) color [i] = i; freescreen = 60; mouseespeed = 10;

Data [0] [0] .SPAN_LO = 0; DATA [0] [1] .SPAN_HI = 0; DATA [1] [0] .SPAN_LO = 0; DATA [1] [1] .SPAN_HI = 0; Data [ 2] [0] .SPAN_LO = 0; DATA [2] [1] .SPAN_HI = 0; DATA [3] [0] .SPAN_LO = 0; Data [3] [1] .SPAN_HI = 0; Data [4] [0] .SPAN_LO = 0; DATA [4] [1] .SPAN_HI = 0; Data [5] [0] .SPAN_LO = 0; Data [5] [1] .SPAN_HI = 0; Data [6] [0 ] .SPAN_LO = 0; DATA [6] [1] .SPAN_HI = 0; DATA [7] [0] .SPAN_LO = 0; Data [7] [1] .SPAN_HI = 0; for (i = 0, Da = & Data [I / 2] [I% 2]; I <16; I , DA ) {DA-> span_lo = 0.0; DA-> span_hi = 250.0;} / * now, channel 0 is T1 and Channel 1 IS P1; The Same, Channel 2 IS T2 and Channel 3 IS P2; ... ...

THE GAIN IS-2.5V to 2.5V EQU THE INTVAL IS 0 to 4095, And -2.5 TO 0 is Omitted. If You Want To Change The Gain, You Must To Modify Param [17] .do your best, you will be right ! * / Return;

/ * ============= ======================== * / void error_registerbgi (int erroorcode) {if (ErrorCode <0) {Printf ("Graphics Error:% S / N", GrapherrorMSG (ErrorCode)); Printf ("Press any key to halt:"); exit (1);}}

void installbgi (void) {int gdriver = VGA, gmode = VGAHI, i; error_registerbgi (registerbgifont (triplex_font)); error_registerbgi (registerbgifont (small_font)); / * error_registerbgi (registerbgifont (sansserif_font)); error_registerbgi (registerbgifont (gothic_font)) ; * / / * initialize graphics and local variables * / error_registerbgi (registerbgidriver (EGAVGA_driver)); initgraph (& gdriver, & gmode, ""); error_registerbgi (graphresult ());} / * ========== ==== Main futness ================ * / void main (void) {int keynum; driver_init (); installbgi (); hEAD_SCR (); span_init (); f_inti (); Eachline_Backscr (); reset_mouse (); set_mouse_limits (4, 0, 623, 479); intrate = intrate; OldTimer = getVect (0x1c); Install (NewTimer, 0x1c);

While (Run_Program) {keybroad (); if (int_ok) {int_ok--; data_pro (); frontscr ();}}

Install (Oldtimer, 0x1c); Fclose (fdata); fclose (fpoint); closegraph (); return;}

转载请注明原文地址:https://www.9cbs.com/read-81566.html

New Post(0)