예제 #1
0
int main(int argc, char **argv)
{
	if (access("train_input.csv" , F_OK ) != -1 ) { 
		//FILE* stream = fopen("train_input.csv", "r");
	} else {
		printf("Input file does not exist. This program expects train_input.csv in the same folder\n");
		return 0;
	}
	//SCADE reset function call
	Amsterdam_Utrecht_reset_US_Integration_June();
	
	FILE* stream = fopen("train_input.csv", "r");
	char line[1024];
	int cycle = 0;
	while (fgets(line, 1024, stream))
	{
		cycle++;
		printf("Cycle %d : ", cycle);
        	char* tmp = strdup(line); //strok trashes line, hence repeated tmp use for each call to getfield 
		TrainPos = atof( getfield(tmp, 1) );
		printf("Train_pos %f : ", TrainPos);
        	tmp = strdup(line); //strok trashes line, hence repeated tmp use  for each call to getfield
		Trigger_in = atoi( getfield(tmp, 2) );
		printf("Trigger_in %d\n", Trigger_in);
		Amsterdam_Utrecht_US_Integration_June();
        	free(tmp);
	}
	printf("Execution of %d cycles complete\n" , cycle);
	return 0;
}
/*******************************
 * Cyclic function encapsulation
 *******************************/
int SimStep(void) {
#ifdef EXTENDED_SIM
	if (GraphicalInputsConnected)
		BeforeSimStep();
#endif /* EXTENDED_SIM */
	_SCSIM_ExecuteInterface();
	Amsterdam_Utrecht_US_Integration_June();
#ifdef EXTENDED_SIM
	AfterSimStep();
#endif /* EXTENDED_SIM */
	return 1;
}