Example #1
0
/**
 * PiPilot course hold slave loop
 *
 * @return void
 */
void pipilot_run_coursehold() {
	print_to_screen( "coursehold", "initializing", 0 );

	int loop_i = 1;

	while ( MODE_COURSEHOLD == get_master_mode() ) {
		print_to_screen( "coursehold", "loop iteration", loop_i );

		// Vars that go into PID
		int selected_course = get_selected_course();
		int actual_heading = get_actual_heading();
		int current_rudder_angle = get_rudder_angle();

		// PID
		int new_rudder_angle = coursehold_pid( selected_course, actual_heading, current_rudder_angle );

		// Change rudder
		set_rudder_angle( new_rudder_angle );

		// 1-second delay
		usleep( 1000000 );

		loop_i++;
	}
}
Example #2
0
/*=================================
 * trav_pre_print_tn_str -- traverse displaynode str tree,
 *  printing displaynode buffers in preorder
 * Created: 2001/04/15, Perry Rapp
 *===============================*/
static void
trav_pre_print_tn_str (DISPNODE tn, INT * row, INT gen, INT indent, CANVASDATA canvas)
{
	DISPNODE n0;
	struct node_text_print_param_s ntpp;
	ntpp.tn = tn;
	/* all display printing passes thru generic print_to_screen,
	which handles scrolling */
	print_to_screen(gen, indent, row, &tn_lineprint, &ntpp, canvas);
	for (n0=tn->firstchild; n0; n0=n0->nextsib)
		trav_pre_print_tn_str(n0, row, gen+1, indent, canvas);
}
Example #3
0
/*=================================
 * trav_pre_print_tn -- traverse displaynode tree,
 *  printing indis in preorder
 * Created: 2000/12/07, Perry Rapp
 *===============================*/
static void
trav_pre_print_tn (DISPNODE tn, INT * row, INT gen, INT indent, CANVASDATA canvas)
{
	DISPNODE n0;
	struct indi_print_param_s ipp;
	ipp.keynum = tn->keynum;
	/* all display printing passes thru generic print_to_screen,
	which handles scrolling */
	print_to_screen(gen, indent, row, &indi_lineprint, &ipp, canvas);
	for (n0=tn->firstchild; n0; n0=n0->nextsib)
		trav_pre_print_tn(n0, row, gen+1, indent, canvas);
}
Example #4
0
/*===========================================
 * trav_bin_in_print_tn -- traverse binary tree,
 *  printing indis in inorder
 * Created: 2000/12/07, Perry Rapp
 *=========================================*/
static void
trav_bin_in_print_tn (DISPNODE tn, INT * row, INT gen, INT indent, CANVASDATA canvas)
{
	struct indi_print_param_s ipp;
	ipp.keynum = tn->keynum;
	if (tn->firstchild)
		trav_bin_in_print_tn(tn->firstchild, row, gen+1, indent, canvas);
	/* all display printing passes thru generic print_to_screen,
	which handles scrolling */
	print_to_screen(gen, indent, row, &indi_lineprint, &ipp, canvas);
	if (tn->firstchild && tn->firstchild->nextsib)
		trav_bin_in_print_tn(tn->firstchild->nextsib, row, gen+1, indent, canvas);
}
Example #5
0
/*=================================
 * trav_pre_print_nod -- traverse node tree,
 *  printing nodes in preorder
 * Created: 2001/01/27, Perry Rapp
 *===============================*/
static void
trav_pre_print_nod (NODE node, INT * row, INT gen, INT indent,
	CANVASDATA canvas, INT gdvw)
{
	NODE child;
	struct node_print_param_s npp;
	npp.node = node;
	npp.gdvw = gdvw;
	/* all display printing passes thru generic print_to_screen,
	which handles scrolling */
	print_to_screen(gen, indent, row, &node_lineprint, &npp, canvas);
	for (child=nchild(node); child; child=nsibling(child))
		trav_pre_print_nod(child, row, gen+1, indent, canvas, gdvw);
}
Example #6
0
void
start(void)
{

	// EXERCISE 4A/B code
	sys_priority(PROCESS_PRIORITY);
	sys_share(PROCESS_SHARE);

	// EXERCISE 7 code
	sys_lottery(PROCESS_SHARE);

	// EXERCISE 4A/B code
	sys_yield();

	int i;

	for (i = 0; i < RUNCOUNT; i++) {
		// Write characters to the console, yielding after each one.

		// EXERCISE 6 and EXERCISE 8
		print_to_screen(&cursorpos, PRINTCHAR);

		/*
		skeleton code that was given
		*cursorpos++ = PRINTCHAR;
		*/

		sys_yield();
	}


	// EXERCISE 2 Code
	// exit process when done
	sys_exit(0);

	// Skeleton code
	// Yield forever.
	while (1)
		sys_yield();
}
Example #7
0
int main(int ac, char **av) {
    int val = 0;
    int i;
    wctproblem problem;
    wctproblem_init(&problem);
    CCcheck_val(val, "Failed in wctproblem_init");
    wctparms *parms = &(problem.parms);
    wctdata *pd = &(problem.root_pd);
    val = program_header(ac, av);
    CCcheck_val(val, "Failed in programheader");
    CCutil_start_timer(&(problem.tot_cputime));
    double start_time = CCutil_zeit();
    wctdata_init(pd);
    pd->id = 0;
    problem.nwctdata = 1;
    val = parseargs(ac, av, parms);
    problem.real_time = getRealTime();

    if (val) {
        goto CLEAN;
    }

    get_problem_name(pd->pname, parms->jobfile);

    if (dbg_lvl() > 1) {
        printf("Debugging turned on\n");
    }

    fflush(stdout);
    /** Reading and preprocessing the data */
    val  = read_problem(parms->jobfile, &(pd->njobs), &(problem.duration),
                        &(problem.weight));
    pd->nmachines = parms->nmachines;
    CCcheck_val(val, "read_adjlist failed");
    pd->orig_node_ids = (int *)CC_SAFE_MALLOC(pd->njobs, int);
    CCcheck_NULL_2(pd->orig_node_ids, "No memory to allocated orig_node_ids\n");

    for (i = 0; i < pd->njobs; i++) {
        pd->orig_node_ids[i] = i;
    }

    Preprocessdata(&problem, pd);
    printf("Reading and preprocessing of the data took %f seconds\n",
           CCutil_zeit() - start_time);
    /** Computing initial lowerbound */
    CCutil_start_timer(&(problem.tot_lb));
    problem.global_lower_bound = lowerbound_eei(pd->jobarray, pd->njobs,
                                 pd->nmachines);
    problem.global_lower_bound = CC_MAX(problem.global_lower_bound,
                                        lowerbound_cp(pd->jobarray, pd->njobs, pd->nmachines));
    problem.global_lower_bound = CC_MAX(problem.global_lower_bound,
                                        lowerbound_cw(pd->jobarray, pd->njobs, pd->nmachines));
    CCutil_stop_timer(&(problem.tot_lb), 0);
    printf("Computing lowerbound EEI, CP and CW took %f seconds\n",
           problem.tot_lb.cum_zeit);
    /** Construction Pricersolver at the root node */
    CCutil_start_resume_time(&(problem.tot_build_dd));
    pd->solver = newSolver(pd->duration, pd->weights, pd->releasetime, pd->duetime,
                           pd->njobs, pd->H_min, pd->H_max);
    CCutil_suspend_timer(&(problem.tot_build_dd));

    /** Construct Feasible solutions */
    if (parms->nb_feas_sol > 0) {
        construct_feasible_solutions(&problem);
    }

    /** Compute Schedule with Branch and Price */
    compute_schedule(&problem);

    problem.real_time = getRealTime() - problem.real_time;
    CCutil_stop_timer(&(problem.tot_cputime), 0);
    /** Print all the information to screen and csv */
    if (problem.parms.print) {
        print_to_csv(&problem);
    }

    print_to_screen(&problem);

CLEAN:
    wctproblem_free(&problem);
    return val;
}