Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.naic.edu/~phil/hardware/vertex/sharemegsvertex/klausdec08/v2_3/more
Дата изменения: Fri Jan 1 07:02:02 1988
Дата индексирования: Thu Jan 15 08:48:04 2009
Кодировка:
/* MAIN1.C LCU/CP581 S1095034L-2.0 15.09.1997
*modification history:
*31dec99 bc630.c -->Save/bc630.c
* new version tests the validity of hour,min,sec
* if error, just increment old time by 10 ms.
* putmcs - fblock. statout. last 12 bytes now
* badTm array
*/
#ifdef SUN
#include
typedef void(*VOIDFUNCPTR) (void);
VOIDFUNCPTR old0a;
#else
void (_interrupt _far *old0a) ();
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include "prog.h"
#include "common.c"
#include "netzwerk.h"
FILE *datei4, *datei1, *datei2, *datei3, *datei5, *datei6;
/*int i,mil,mil1,axisfree; mil->common.c i,axis->loc, mil1->del*/
char v1,chputb[512]; /* allocation for putb */

int main(void) {
time_t ltime; /* pjp001 moved to local */
int htime,start3_flg,start2_flg;
unsigned int c,zaehl;
int axisfree,i; /* axisfree moved global to local*/
time(<ime);
alarm = -1;
putb = chputb;
ser_out_buf = (char*) &time_ms;
dtime = 0;
auxm = 0;
zaehl = 0;
alarm = -1;
ser_out_cnt = 0;
event_no = 0;
timeold = 0;
timeold1 = 0;
locked =0; /* pjp001. was used in keypass. and tested below but
keypass was deleted long ago...*/
dtime2 = 0;
gestdr_old = 0;
system("cls");
printf("\n VERTEX ANTENNENTECHNIK GMBH, DUISBURG, GERMANY ");
printf("\n GREGORIAN DOME DRIVE SYSTEM ");
printf("\n LAN INTERFACE SOFTWARE ");
printf("\n VERSION: 2.2 ");
printf("\n S1095034L-2.2 ");
printf("\n %s",ctime(<ime));
printf("\n");
printf("\n ");
bc630ini(); /* Init. Real Time Clock BC630AT */
settime();
do {
c =inp(0x2f8); /* readout of serial interface */
} while ((inp(0x2fd)&0x01) == 0x01);

for (c=0;c<100;c++) ser_in_buf[c] = 0;

_disable();
old0a = _dos_getvect((unsigned) 0x0b);
_dos_setvect(0x0b,ocuread);
c = inp(0x21);
c = c&0xf7;
outp(0x21,c);
_enable();

outp(0x2f9,0x01); /*Interrupt Enable */
outp(0x2fc,0x08); /*Interrupt Enable */

/********** START UP CONDITIONS *********/
mode_sel[0] = 0x0004; /* OCU-CONTROL */
mode_sel[2] = 0x0004; /* OCU-CONTROL */
mode_sel[4] = 0x0004; /* OCU-CONTROL */
dev_name = 0x0002; /* Local Control Panel */

screen();
startkey();

datei1 = fopen("e:\\cpu1\\db221.s5b","rb+");
datei2 = fopen("e:\\cpu1\\db222.s5b","rb+");
datei3 = fopen("e:\\cpu1\\db223.s5b","rb+");
datei4 = fopen("c:\\param.dat","rb+");

/*===============================================================*/

schreib(8); /* Watchdog 4 sec. */
command = 0x0200; /* RESET after new start */
schreib(4); /* */
lesen();
mode_sel[1] = stat1[1]; /* AUX. Mode */
mode_sel[3] = stat1[7];
mode_sel[5] = stat1[13];

schreib(5); /* Set Mode */
waitl(1);
lesen();

if ((stat1[0]&0x0040)==0x0040) mode_sel[0] = 0x0002; /* Local only switch*/
if ((stat1[6]&0x0040)==0x0040) mode_sel[2] = 0x0002; /* Local only switch*/
if ((stat1[12]&0x0040)==0x0040) mode_sel[4] = 0x0002; /* Local only switch*/
schreib(5); /* Set new Mode */
/*===============================================================*/

neustart = 0;
ser_in_cnt = 0;
mil = 0;
sta:event = 0;
errschr = 0;
net_error = 0;
/********** LOAD PARAMETER *********/
fseek(datei4,0L,0);
fread(paramet,sizeof(paramet[0]),6,datei4);
fread(¶met1,sizeof(paramet1),1,datei4);
htime = paramet1;
dreh2((char*)&htime);
time_n = (long) htime*1000;
start2_flg = 0;
start3_flg = 0;
cpos(0,0);
//startkey();
schreib(1);
/*===============================================================*/
netopen(); /* Network open */
int_flag = 0;
/*===============================================================*/
dtime = 0;

// MAIN LOOP
/*===============================================================*/
l1:
if (itaste > 0) { /*PASSWORD */
if (itaste == 118 && v1 == 0) { v1 = 1; goto bi; } /* v */
else { if(itaste != 118 && v1 == 0) v1 = 0; }
if (itaste == 101 && v1 == 1) { v1 = 2; goto bi; } /* e */
else { if(itaste != 101 && v1 == 1) v1 = 0; }
if (itaste == 114 && v1 == 2) { v1 = 3; goto bi; } /* r */
else { if(itaste != 114 && v1 == 2) v1 = 0; }
if (itaste == 116 && v1 == 3) { v1 = 4; goto bi; } /* t */
else { if(itaste != 116 && v1 == 3) v1 = 0; }
if (itaste == 101 && v1 == 4) { v1 = 5; goto bi; } /* e */
else { if(itaste != 101 && v1 == 4) v1 = 0; }
if (itaste == 120 && v1 == 5) { v1 = 6; goto bi; } /* x */
else { if(itaste != 120 && v1 == 5) v1 = 0; }
bi: if (v1 > 0) itaste = -1;
}
if (v1 == 6){
stopkey();
goto E;
}

taste(); /* PLC,MCS and OCU communication, real time clock
readout, keyboard buffer readout, (fix timing) */

if (itaste == 82) {
command = 0x0200;
schreib(4);
}

/*===============================================================*/
moni(); /* Monitoring actual status */
net_error = neterrno;
if (net_error!= NET_NOERR && net_error != NET_ERR_WOULD_BLOCK)
errschr = (-1);
/*===============================================================*/
eventm(); /* Test Events */
if (event == 1){ /* Event flag */
dat2.gen_stat = dat2.gen_stat | 0x4000; /* Event Messages*/
event = 0; /* Set flag to zero */
}
/*===============================================================*/
/* HOST TIMEOUT */
if (start2_flg > 0) time_n = (time_n- dtime);
start2_flg = 1;
if (time_n <= 0 || errschr < 0) {
errschr = (-1);
schreib(9);
neustart = 0;
time_n = 0;
if ((mode_sel[0]&0x0008) == 0x0008 && (mode_sel[0]&0x0f00) > 0){
to_err = to_err | 1;
mode_sel[0] = mode_sel[0]&0x80ff; schreib(5);
}
if ((mode_sel[2]&0x0008) == 0x0008 && (mode_sel[2]&0x0f00) > 0){
to_err = to_err | 2;
mode_sel[2] = mode_sel[2]&0x80ff; schreib(5);
}
if ((mode_sel[4]&0x0008) == 0x0008 && (mode_sel[4]&0x0f00) > 0){
to_err = to_err | 4;
mode_sel[4] = mode_sel[4]&0x80ff; schreib(5);
}
} else {
to_err = 0;
}
/*===============================================================*/
switch(keyein) {
case 0x01: /* F1 */
if (axis == 0){
axis = 7;
hmenue = 0;
outram(20,20,1,80,0x1c00,0,1,"д");
outram(21,21,1,80,0x1f00,0,1," ");
outram(21,21,32,32,0x1f00,0,15,"A L L A X E S");
keymode();
keyein = 0x0000;
}
break;
case 0x02: /* F2 */
if(axis == 0) {
axis = 1;
hmenue = 0;
outram(20,20,1,80,0x1c00,0,1,"д");
outram(21,21,1,80,0x1f00,0,1," ");
outram(21,21,31,31,0x1f00,0,15," A Z I M U T H");
keymode();
keyein = 0x0000;
}
break;
case 0x03: /* F3 */
if(axis == 0) {
axis = 2;
hmenue = 0;
outram(20,20,1,80,0x1c00,0,1,"д");
outram(21,21,1,80,0x1f00,0,1," ");
outram(21,21,26,26,0x1f00,0,27,"G R E G O R I A N D O M E");
keymode();
keyein = 0x0000;
}
break;
case 0x04: /* F4 */
if(axis == 0) {
axis = 4;
hmenue = 0;
outram(20,20,1,80,0x1c00,0,1,"д");
outram(21,21,1,80,0x1f00,0,1," ");
outram(21,21,26,26,0x1f00,0,27,"C A R R I A G E H O U S E");
keymode();
keyein = 0x0000;
}
break;
case 0x05: /* F5 */
if(axis == 0) {
axis = 3;
hmenue = 0;
outram(20,20,1,80,0x1c00,0,1,"д");
outram(21,21,1,80,0x1f00,0,1," ");
outram(21,21,18,18,0x1f00,0,43,
"A Z I M U T H + G R E G O R I A N D O M E");
keymode();
keyein = 0x0000;
}
break;
case 0x06: /* F6 */
hmenue = 0;
if(axis == 0) {
moni1();
screen();
keyein = 0x0000;
}
break;
case 0x07: /* F7 */
hmenue = 0;
if(axis == 0) {
status();
screen();
keyein = 0x0000;
}
break;
case 0x08: /* F8 */
hmenue = 0;
if(axis == 0) {
param();
screen();
putocu(2);
ocuwrite();
keyein = 0x0000;
}
break;
}

if(itaste == 27){ /* Taste ESC */
hmenue = 1; axis = 0; keyenter = 0x0000; keyein=0x0000;
outram(20,25,1,80,0x1100,0x0010,1," ");
screen();
for (i = 0; i < 6; i++) keypar[i] = 0;
goto l1;
}

/* determine allowed commands for the selected axis or axes */

axisfree = 0;
if (axis == 1 && ((stat1[0] & 0x000f) != 0x0001)
&& ((mode_sel[0] & 0x000f) == 0x0002)) axisfree = 1;
if (axis == 2 && ((stat1[6] & 0x000f) != 0x0001)
&& ((mode_sel[2] & 0x000f) == 0x0002)) axisfree = 1;
if (axis == 4 && ((stat1[12] & 0x000f) != 0x0001)
&& ((mode_sel[4] & 0x000f) == 0x0002)) axisfree = 1;
if ((axis == 3) && ((stat1[0] & 0x000f) != 0x0001) &&
((stat1[6]&0x000f) != 0x0001) && ((mode_sel[0] & 0x000f) == 0x0002) &&
((mode_sel[2] & 0x000f) == 0x0002))
axisfree = 1;

if ((axis == 7) && ((stat1[0] & 0x000f) != 0x0001) &&
((stat1[6]&0x000f) != 0x0001) && ((mode_sel[0] & 0x000f) == 0x0002) &&
((mode_sel[2] & 0x000f) == 0x0002) &&
((mode_sel[4] & 0x000f) == 0x0002) && ((stat1[12] & 0x000f) != 0x0002))
/* pjp001 this is a bug 0002. should be 0001*/
axisfree = 1;

/***************************************************************/
if(axis > 0 && keyein==0x0001) {/* F1 STOP*/
hmenue = 0;
stopmode();
hmenue = 1;
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if(axis > 0 && keyein == 0x0002) { // F2 PRESET
hmenue = 0;
if (axisfree == 1) preset();
hmenue = 1;
keyaxis();
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if(axis > 0 && keyein==0x0003) { // F3 STOWPOSITION
hmenue = 0;
if (axisfree == 1) stowmode();
hmenue = 1;
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if(axis > 0 && keyein==0x0004) { // F4 PROGRAM TRACK
hmenue = 0;
n_ist = 0;
hmenue = 1;
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if(axis > 0 && keyein == 0x0005){ // F5 RATE
hmenue = 0;
if (axisfree == 1) rate();
hmenue = 1;
keyaxis();
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if( axis > 0 && keyein == 0x0006) { // F6 AUX
hmenue = 0;
auxmode();
hmenue = 1;
keyaxis();
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if (keyenter==0x0070) goto l1; /* ESC */
/***************************************************************/
if( axis > 0 && keyein==0x0007) { // F7 CONTROL
controlm();
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/
if(axis > 0 && keyein==0x0008){ // F8
axis = 0;
keyenter = 0x0000;
keyein=0x0000;
screen();
goto l1;
}
/***************************************************************/

keyenter = 0x0000;

if (errschr< 0) { /* Network alarm */
errschr = 0;
schreib(10);
netclose();
neustart = 0;
goto l2; /* Start of init. and netopen */
}
goto l1;
l2:
time(<ime);
goto sta;
E:
fclose(datei1);
fclose(datei2);
fclose(datei3);
fclose(datei4);
_disable();
_dos_setvect((unsigned)0x0b,old0a);
_enable();
netclose();
//fil(); // write monitored Program Track data to file
return(0); /* pjp001 return 0 since int*/
}