Example #1
0
void loadTrackStructure(char track) {
    // draw track
    drawTrackLayoutGraph(track);
    if(track == 'a') {
        init_tracka(g_track);
        setTurnout(5, 'c');
    }
    else {
        init_trackb(g_track);
    }
}
void command_track( struct char_buffer* cbuff, int* track, struct track_node * track_data ) {
	char str_arg1[CONFIG_CLI_MAX_CHARACTERS];
	char str_arg2[CONFIG_CLI_MAX_CHARACTERS];

	if(
		next_token( cbuff, str_arg1 ) == 0 ||
		str_arg1[0] == '\0' ||
		str_arg1[1] != '\0' ||
		next_token( cbuff, str_arg2 ) != 0 ) {
		CommandOutput( "[TRACK]\tInvalid Arguments" );
		return;
	}

	//check the switch state
	if( str_arg1[0] != 'a' && str_arg1[0] != 'b' ) {
		CommandOutput( "[TRACK]\tInvalid track designation" );
		return;
	}

	if( *track != TRACK_UNINITIALIZED ) {
		CommandOutput( "[TRACK]\tTrack Already Selected" );
		return;
	}

	if( str_arg1[0] == 'a' ) {
		*track = TRACK_A;
		CommandOutput( "[TRACK]\tSelecting Track A" );
		init_tracka( track_data );
	} else {
		*track = TRACK_B;
		CommandOutput( "[TRACK]\tSelecting Track B" );
		init_trackb( track_data );
	}

	//Send a message to the route server, telling them which track should be used
	struct number_message msg, rpl;
	int tid = WhoIs( "routeserv" );
	while( tid < 0 ) {
		tid = WhoIs( "routeserv" );
	}
	msg.message_type = ROUTE_SERVER_INIT_MESSAGE;
	msg.num = *track;
	Send( tid, (char *)&msg, sizeof (msg), (char *)&rpl, sizeof (msg) );
}
// Initialize track data structures
static void track_init() {
#if TRACK_TYPE == TRACK_TYPE_A
	init_tracka(track);
#else
	init_trackb(track);
#endif

	// Initialize the switch table
	int switch_tid = WhoIs(SWITCH_SERVER);
	int i;
	for (i = 1; i <= 18; i++) {

		switch_table[i] = (char)SwitchGetDirection(i, switch_tid);
	}

	switch_table[0x99] = (char)SwitchGetDirection(0x99, switch_tid);
	switch_table[0x9A] = (char)SwitchGetDirection(0x9A, switch_tid);
	switch_table[0x9B] = (char)SwitchGetDirection(0x9B, switch_tid);
	switch_table[0x9C] = (char)SwitchGetDirection(0x9C, switch_tid);
}
Example #4
0
void init(void) {
#ifdef TRACKA
	init_tracka(track);
#else
	init_trackb(track);
#endif

	start_servers();

#if CALIBRATE
	calibratesrv_start();
#else
	tracksrv_start();
	displaysrv_start();
	commandsrv_start();
	trains_start();
	routesrv_start();
	heartbeat_start();
#endif
	sensorsrv_start();
}