コード例 #1
0
ファイル: tp1.c プロジェクト: ohasanliUW/TrainControlSystem
void idle_code() {
	volatile int i = 0;
	int runtime;
	while(1) {
		if(!((i++)%400000)){
			runtime = RunTime();
			Printf(COM2, "\033[s\033[%d;%dH%d.%d%d%% \033[u", IDLE_ROW, IDLE_COL, runtime/100, (runtime%100)/10, (runtime%100)%10);
		}
	}
	Warning(0,"Unexpected Exit() at idle_code\n\r");
	Exit();
	Warning(0,"Unexpected return from Exit() at idle_code\n\r");
}
コード例 #2
0
int main( int argc, char *argv[] )
{
    char        *err;
    unsigned    len;

#ifdef __WINDOWS__
    Instance = *_MainWindowData;
#endif
    err = RemoteLink( ( argc > 1 ) ? argv[1] : "", TRUE );
    if( err != 0 ) {
        printf( "%s\n", err );
        return( 1 );
    }
    printf( "server running\n" );
    for( ;; ) {
        NothingToDo();
#if defined(__WATCOMC__)
        // How to do the equivalent of kbhit()?
        if( kbhit() && getch() == 'q' )
            break;
#endif
        if( RemoteConnect() ) {
            printf( "\nCONNECT\n" );
            for( ;; ) {
                len = RemoteGet( (byte *)&Data, sizeof( Data ) );
                if( len == -1 ) {
                    printf( "\nlink broken\n" );
                    break;
                }
                if( Data[0] == TEST_OVER )
                    break;
                if( Data[0] == TEST_STRING ) {
                    printf( "'%s' - %d bytes\n", &Data[1], len );
                    RemotePut( (byte *)&Data, len );
                } else {
                    RunTime();
                }
            }
            RemoteDisco();
            printf( "\nDISCO\n" );
        }
    }
    RemoteUnLink();
    return( 0 );
}
コード例 #3
0
ファイル: fixture.cpp プロジェクト: falkoschumann/fit4qt
void Fixture::doTables(Parse *tables)
{
    summary.insert("run date", QDateTime());
    QVariant runTime;
    runTime.setValue(RunTime());
    summary.insert("run elapsed time", runTime);
    if (tables) {
        Parse *fixtureName = getFixtureName(tables);
        if (fixtureName) {
            try {
                Fixture *fixture = getLinkedFixtureWithArgs(tables);
                fixture->interpretTables(tables);
            } catch (const std::exception &e) {
                exception(fixtureName, e);
                interpretFollowingTables(tables);
            }
        }
    }
}
コード例 #4
0
ファイル: pc.c プロジェクト: gap-packages/nq
/*
**    InitPcPres() initializes those parts of pc-presentation which are
**    not initialized in elimMap().
*/
void    InitPcPres(void) {

	long i, j, t = 0;

	if (Verbose) t = RunTime();

	Class = 1;

	Generators = (word*)malloc((2 * NrCenGens + 1) * sizeof(word));
	if (Generators == (word*)0) {
		perror("InitPcPres(), Generators");
		exit(2);
	}
	Generators += NrCenGens;
	for (i = -NrCenGens; i <= NrCenGens; i++) {
		if (i == 0) continue;
		Generators[i] = (word)malloc(2 * sizeof(gpower));
		if (Generators[i] == (word)0) {
			perror("InitPcPres(), Generators[]");
			exit(2);
		}
		Generators[i][0].g = i;
		Generators[i][0].e = (expo)1;
		Generators[i][1].g = EOW;
		Generators[i][1].e = (expo)0;
	}
	PcGenName = (char **)Allocate((NrCenGens + 1) * sizeof(char *));

	Dimension = (int*)malloc((Class + 1) * sizeof(int));
	if (Dimension == (int*)0) {
		perror("InitPcPres(), Dimension");
		exit(2);
	}
	Dimension[Class] = NrCenGens;

	Conjugate = (word**)malloc((2 * NrCenGens + 1) * sizeof(word*));
	if (Conjugate == (word**)0) {
		perror("InitPcPres(), Conjugate");
		exit(2);
	}
	Conjugate += NrCenGens;
	for (j = 1; j <= NrCenGens; j++) {
		/* the length of Conjugate[j] is 2*(j-1)+1 */
		Conjugate[j] = (word*)malloc((2 * j - 1) * sizeof(word));
		if (Conjugate[j] == (word*)0) {
			perror("InitPcPres(), Conjugate[]");
			exit(2);
		}
		Conjugate[j] += j - 1;
		for (i = -(j - 1); i <= j - 1; i++)
			Conjugate[j][i] = Generators[j];
		if (Exponent[j] == (expo)0) {
			Conjugate[-j] = (word*)malloc((2 * j - 1) * sizeof(word));
			if (Conjugate[-j] == (word*)0) {
				perror("InitPcPres(), Conjugate[]");
				exit(2);
			}
			Conjugate[-j] += j - 1;
			for (i = -(j - 1); i <= j - 1; i++)
				Conjugate[-j][i] = Generators[-j];
		}
	}

	/* Here central generators change their status to pc-generators. */
	NrPcGens += NrCenGens;
	NrCenGens = 0;

	if (Verbose)
		printf("#    Initialized pc-presentation (%ld msec).\n", RunTime() - t);
}
コード例 #5
0
ファイル: pc.c プロジェクト: gap-packages/nq
void    ExtPcPres(void) {

	long i, j, c, N, oldsize, newsize, t = 0;
	word *tmp, **ttmp;

	if (Verbose) t = RunTime();

	Class++;

	Weight = (int *)realloc(Weight, (NrPcGens + NrCenGens + 1) * sizeof(int));
	if (Weight == (int *)0) {
		perror("InitPcPres, Weight");
		exit(2);
	}

	tmp = (word*)malloc((2 * (NrPcGens + NrCenGens) + 1) * sizeof(word));
	if (tmp == (word *)0) {
		perror("InitPcPres(), tmp");
		exit(2);
	}
	tmp += NrPcGens + NrCenGens;

	for (i = -(NrPcGens + NrCenGens); i <= (NrPcGens + NrCenGens); i++) {
		if (i == 0) continue;
		if (i > NrPcGens) Weight[i] = Class;
		if (i < -NrPcGens || i > NrPcGens) {
			tmp[i] = (word)malloc(2 * sizeof(gpower));
			if (tmp[i] == (word)0) {
				perror("InitPcPres(), tmp[]");
				exit(2);
			}
			tmp[i][0].g = i;
			tmp[i][0].e = (expo)1;
			tmp[i][1].g = EOW;
			tmp[i][1].e = (expo)0;
		} else
			tmp[i] = Generators[i];
	}
	free(Generators - NrPcGens);
	Generators = tmp;

	Dimension = (int*)realloc(Dimension, (Class + 1) * sizeof(int));
	if (Dimension == (int*)0) {
		perror("InitPcPres(), Dimension");
		exit(2);
	}
	Dimension[Class] = NrCenGens;


	/* Now Conjugate[] has to be enlarged. */
	ttmp = (word**)malloc((2 * (NrPcGens + NrCenGens) + 1) * sizeof(word*));
	if (ttmp == (word**)0) {
		perror("extPcPres(), tmp");
		exit(2);
	}
	ttmp += NrPcGens + NrCenGens;
	/* The contents of Conjugate[] must be copied to the new array. */
	for (i = -NrPcGens; i <= NrPcGens; i++)
		ttmp[i] = Conjugate[i];

	free(Conjugate - NrPcGens);
	Conjugate = ttmp;

	/*
	** The next nilpotency class to be calculated is Class+1. Therefore
	** commutators of weight Class+1, which are currently trivial, will
	** get new generators and tails. For the corresponding conjugates
	** space must be created in the array Conjugate[].
	**
	** Only those entries in Conjugate[] which do not have exceeded their
	** maximal length yet must be enlarged. This business is a little
	** bit tricky because the amount by which Conjugate[N], for a
	** generator N, has to be enlarged depends on the class of N.
	** The generators of highest class do not yet have any conjugates. They
	** will get a conjugate relation for each generator of weight 1,
	** therefore the size of the array for those generators is
	** 2*Dimension[1]+1. The array for generators of Class-1 has to be
	** enlarged by 2*Dimension[2] and so on.
	*/
	N = NrPcGens + NrCenGens;
	newsize = 0;
	for (c = Class; c > Class - c; c--) {
		oldsize = newsize;
		/* Compute the new size of the array for generators of class c.
		** Those generators get a new conjugate relation for each generator
		** of weight Class-c+1. */
		newsize += Dimension[ Class - c + 1 ];
		for (i = 1; i <= Dimension[c]; i++) {
			tmp = (word*)malloc((2 * min(N - 1, newsize) + 1) * sizeof(word));
			if (tmp == (word*)0) {
				perror("extPcPres(), tmp");
				exit(2);
			}
			tmp += min(N - 1, newsize);
			if (c < Class) {
				/* Copy the contents to the new array. */
				for (j = -oldsize; j <= oldsize; j++)
					tmp[j] = Conjugate[N][j];
				free(Conjugate[N] - oldsize);
			}
			Conjugate[N] = tmp;
			/* Initialise the new space. */
			for (j = oldsize + 1; j <= min(N - 1, newsize); j++)
				Conjugate[N][j] = Conjugate[N][-j] = Generators[N];

			if (Exponent[ N ] != (expo)0) { N--; continue; }
			/* If the generator N is of infinite order, it also has
			** conjugate relations `on the other side'. All that has to
			** be done is exactly the same as before just for negative N.
			*/
			tmp = (word*)malloc((2 * min(N - 1, newsize) + 1) * sizeof(word));
			if (tmp == (word*)0) {
				perror("extPcPres(), tmp");
				exit(2);
			}
			tmp += min(N - 1, newsize);
			if (c < Class) {
				for (j = -oldsize; j <= oldsize; j++)
					tmp[j] = Conjugate[-N][j];
				free(Conjugate[-N] - oldsize);
			}
			Conjugate[-N] = tmp;
			for (j = oldsize + 1; j <= min(N - 1, newsize); j++)
				Conjugate[-N][j] = Conjugate[-N][-j] = Generators[-N];
			N--;
		}
	}

	/* Now the central generators have conjugate relations and so they
	** change their status to pc-generators. */
	NrPcGens += NrCenGens;
	NrCenGens = 0;

	if (Verbose)
		printf("#    Extended pc-presentation (%ld msec).\n", RunTime() - t);
}