int main (int argc, char *argv[]) { int choix = -1; int SimuChargee = 0; int SimuCalculee = 0; PtrSimulation simulation = NULL; gtk_init (&argc, &argv); while (choix != 0) { choix = menu (SimuChargee, SimuCalculee); switch (choix) { case 1 : simulation = LoadSimu (&SimuChargee); SimuCalculee = 0; break; case 2 : CalculerSimu (simulation); SimuCalculee = 1; break; case 3 : if(SimuCalculee == 1) SaveImage (simulation); break; case 4: if(SimuCalculee == 1) PrintReport (simulation); case 0 : break; default : break; } } return 0; }
//--------------------------------------------------------------------------- void __fastcall TFormClientRep::sSpeedButton1Click(TObject *Sender) { switch (GetComponentTag(Sender)) { case 1: ProcRefreshPage(); break; case 4: ProcSelAllStd(*WrkGData, NULL); break; case 5: ClearSums(); ProcUnsAllStd(*WrkGData, NULL); break; case 6: frxReport1->Print(); break; case 7: PrintReport(); break; case 8: ProcHistory(false); break; case 31: ShowMonth(-3); break; case 32: ShowMonth(-2); break; case 33: ShowMonth(-1); break; case 34: ShowMonth(0); break; case 35: ShowMonth(1); break; } }
void OwnshipReceiver::ReceiveReport(ClientSocket &client_socket) { OwnshipReport ownship_report; client_socket >> ownship_report; _report_receiver.ReceiveOwnship(ownship_report); #ifdef DEBUG PrintReport(ownship_report); #endif }
static void CountSteps(void) { steps++; intervalSteps++; int32_t now = clock_systimer(); int32_t elapsed = now - intervalStart; int32_t milliseconds = elapsed / (TICK_PER_SEC / 1000); if (milliseconds > intervalLength) { PrintReport(); intervalStart = now; intervalSteps = 0; } }
BOOL PrintReportToPrinter( IN HWND hWnd, IN LPREPORT_LINE lpReportHead, IN HDC PrinterDC ) /*++ Routine Description: PrintReportToPrinter sets up print and calls PrintReport. Arguments: hWnd - Handle to window lpReportHead - Head pointer of report PrinterDC - Handle to the printer Return Value: BOOL - True if report was printed successfully, FALSE otherwise. --*/ { BOOL Success; // // Print the report. // Success = PrintReport( hWnd, PrinterDC, lpReportHead ); // // Delete the printer DC. // DeleteDC( PrinterDC ); return Success; }
bool ReportCommand::Run(const std::vector<std::string>& args) { // 1. Parse options. if (!ParseOptions(args)) { return false; } // 2. Read record file and build SampleTree. record_file_reader_ = RecordFileReader::CreateInstance(record_filename_); if (record_file_reader_ == nullptr) { return false; } if (!ReadEventAttrFromRecordFile()) { return false; } ReadSampleTreeFromRecordFile(); ReadFeaturesFromRecordFile(); // 3. Show collected information. PrintReport(); return true; }
/** * unchanged from SimpleDemo: * * Runs the motors under driver control with either tank or arcade * steering selected by a jumper in DS Digin 0. * * added for vision: * * Adjusts the servo gimbal based on the color tracked. Driving the * robot or operating an arm based on color input from gimbal-mounted * camera is currently left as an exercise for the teams. */ void OperatorControl(void) { char funcName[] = "OperatorControl"; DPRINTF(LOG_DEBUG, "OperatorControl"); //GetWatchdog().Feed(); TrackingThreshold td = GetTrackingData(GREEN, FLUORESCENT); /* for controlling loop execution time */ float loopTime = 0.05; double currentTime = GetTime(); double lastTime = currentTime; double savedImageTimestamp = 0.0; bool foundColor = false; bool staleImage = false; while (IsOperatorControl()) { setServoPositions(rightStick->GetX(), rightStick->GetY()); /* calculate gimbal position based on color found */ if (FindColor (IMAQ_HSL, &td.hue, &td.saturation, &td.luminance, &par, &cReport)) { foundColor = true; if (par.imageTimestamp == savedImageTimestamp) { // This image has been processed already, // so don't do anything for this loop staleImage = true; } else { staleImage = false; savedImageTimestamp = par.imageTimestamp; // compute final H & V destination horizontalDestination = par.center_mass_x_normalized; verticalDestination = par.center_mass_y_normalized; } } else { foundColor = false; } PrintReport(&cReport); if (!staleImage) { if (foundColor) { /* Move the servo a bit each loop toward the * destination. Alternative ways to task servos are * to move immediately vs. incrementally toward the * final destination. Incremental method reduces the * need for calibration of the servo movement while * moving toward the target. */ ShowActivity ("** %s found: Servo: x: %f y: %f", td.name, horizontalDestination, verticalDestination); } else { ShowActivity("** %s not found", td.name); } } dashboardData.UpdateAndSend(); // sleep to keep loop at constant rate // elapsed time can vary significantly due to debug printout currentTime = GetTime(); lastTime = currentTime; if (loopTime > ElapsedTime(lastTime)) { Wait(loopTime - ElapsedTime(lastTime)); } } while (IsOperatorControl()) { // determine if tank or arcade mode; default with no jumper is // for tank drive if (ds->GetDigitalIn(ARCADE_MODE) == 0) { // drive with tank style myRobot->TankDrive(leftStick, rightStick); } else { // drive with arcade style (use right stick) myRobot->ArcadeDrive(rightStick); } } } // end operator control
void Autonomous(void) { char funcName[] = "Autonomous"; DPRINTF(LOG_DEBUG, "start VisionDemo autonomous"); //GetWatchdog().Feed(); // image data for tracking ColorMode mode = IMAQ_HSL; // RGB or HSL // TrackingThreshold td = GetTrackingData(RED, FLUORESCENT); TrackingThreshold td = GetTrackingData(GREEN, FLUORESCENT); int panIncrement = 0; // pan needs a 1-up number for each call DPRINTF(LOG_DEBUG, "SERVO - looking for COLOR %s ", td.name); /* initialize position and destination variables * position settings range from -1 to 1 * setServoPositions is a wrapper that handles the conversion to * range for servo */ horizontalDestination = 0.0; // final destination range -1.0 to +1.0 verticalDestination = 0.0; // current position range -1.0 to +1.0 horizontalPosition = RangeToNormalized(horizontalServo->Get(), 1); verticalPosition = RangeToNormalized(verticalServo->Get(), 1); // incremental tasking toward dest (-1.0 to 1.0) float incrementH, incrementV; // set servos to start at center position setServoPositions(horizontalDestination, verticalDestination); /* for controlling loop execution time */ float loopTime = 0.05; double currentTime = GetTime(); double lastTime = currentTime; double savedImageTimestamp = 0.0; bool foundColor = false; bool staleImage = false; while (IsAutonomous()) { /* calculate gimbal position based on color found */ if (FindColor (mode, &td.hue, &td.saturation, &td.luminance, &par, &cReport)) { foundColor = true; panIncrement = 0; // reset pan if (par.imageTimestamp == savedImageTimestamp) { // This image has been processed already, // so don't do anything for this loop staleImage = true; } else { staleImage = false; savedImageTimestamp = par.imageTimestamp; // compute final H & V destination horizontalDestination = par.center_mass_x_normalized; verticalDestination = par.center_mass_y_normalized; } // ShowActivity("Found color "); } else { // need to pan foundColor = false; // ShowActivity("No color found"); } PrintReport(&cReport); if (foundColor && !staleImage) { /* Move the servo a bit each loop toward the destination. * Alternative ways to task servos are to move immediately * vs. incrementally toward the final * destination. Incremental method reduces the need for * calibration of the servo movement while moving toward * the target. */ incrementH = horizontalDestination - horizontalPosition; incrementV = verticalPosition - verticalDestination; adjustServoPositions(incrementH, -incrementV); ShowActivity ("** %s found: Servo: x: %f y: %f increment: %f y: %f ", td.name, horizontalDestination, verticalDestination, incrementH, incrementV); } else if (!staleImage) { /* pan to find color after a short wait to settle servos * panning must start directly after panInit or timing * will be off */ // adjust sine wave for panning based on last movement // direction if (horizontalDestination > 0.0) { sinStart = PI / 2.0; } else { sinStart = -PI / 2.0; } if (panIncrement == 3) { panInit(); } else if (panIncrement > 3) { panForTarget(horizontalServo, sinStart); /* Vertical action: center the vertical after several * loops searching */ if (panIncrement == 20) { verticalServo->Set(0.5); } } panIncrement++; } // end if found color dashboardData.UpdateAndSend(); // sleep to keep loop at constant rate // elapsed time can vary significantly due to debug printout currentTime = GetTime(); lastTime = currentTime; if (loopTime > ElapsedTime(lastTime)) { Wait(loopTime - ElapsedTime(lastTime)); } } // end while myRobot->Drive(0.0, 0.0); // stop robot DPRINTF(LOG_DEBUG, "end autonomous"); ShowActivity ("Autonomous end "); } // end autonomous
//------------------------------------------------------------------------------ int main(int argc, char * const argv[]) { Options opt = GetOptions(argc, argv); // Log in SpreadsheetService service(opt.user, opt.password, "xeckollc-thirteen-" + VERSION); // Get the spreadsheet we are interested in Spreadsheet spreadsheet; if(opt.spreadsheet_id.size()) { spreadsheet = service.GetSpreadsheet(opt.spreadsheet_id); } else { vector<Spreadsheet> sheets = service.GetSpreadsheets(); int report_index = -1; for (int i=0; i < sheets.size(); ++i) { if(sheets[i].GetTitle() == opt.spreadsheet_name) { report_index = i; break; } } if(report_index < 0) { cerr << format("No spreadsheet named [%1%] found") % opt.spreadsheet_name << endl; return 1; } spreadsheet = sheets[report_index]; } // Get the worksheet we are interested in. If we didn't specify one, // use the first one in the spreadsheet Worksheet worksheet; if(opt.worksheet_id.size()) { worksheet = spreadsheet.GetWorksheet(opt.worksheet_id); } else { vector<Worksheet> sheets = spreadsheet.GetWorksheets(); if(opt.worksheet_name.size()) { int report_index = -1; for (int i=0; i < sheets.size(); ++i) { if(sheets[i].GetTitle() == opt.worksheet_name) { report_index = i; break; } } if(report_index < 0) { cerr << format("No worksheet named [%1%] found") % opt.worksheet_name << endl; return 1; } worksheet = sheets[report_index]; } else { worksheet = sheets[0]; } } // Get 2 columns of Cells from selected worksheet CellRange cells = worksheet.GetColumns(1, 2); // Parse the cells for the data map<string, int> on_air, off_air; State state = NONE; for (int row=cells.GetFirstRow(); row <= cells.GetLastRow(); ++row) { Cell *label_cell = cells.GetCell(row, 1); if(label_cell == NULL) { state = NONE; continue; } string label = label_cell->GetContent(); if(!label.size()) { state = NONE; continue; } if(label == ON_AIR_HEADER) { state = ONAIR; continue; } if(label == OFF_AIR_HEADER) { state = OFFAIR; continue; } Cell *value_cell = cells.GetCell(row, 2); if(value_cell == NULL) { continue; } string value = value_cell->GetContent(); int ivalue; try { ivalue = lexical_cast<int>(value.c_str()); } catch(bad_lexical_cast &) { ivalue = 0; } switch (state) { case ONAIR: if(ivalue) { on_air[label] = ivalue; } break; case OFFAIR: if(ivalue) { off_air[label] = ivalue; } break; case NONE: break; } } // Figure the start and stop dates from the worksheet name string name = worksheet.GetTitle(); re::sregex rex = re::sregex::compile("(.+) +(.+)"); re::smatch matches; if(!re::regex_match(name, matches, rex)) { cerr << format("Worksheet name [%1%] does not look like a month and year") % name << endl; return 1; } string mon, yr; int month, year; mon = matches[1]; yr = matches[2]; year = lexical_cast<int>(yr.c_str()); if(year < 2000) { year += 2000; } month = 0; string months[] = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; for (int i=0; i<12; ++i) { if (iequals(mon, months[i])) { month=i+1; break; } } if(month < 1) { cerr << format("Worksheet name [%1%] does not contain a valid month") % name << endl; return 1; } date start_date(year, month, 1); date stop_date = start_date.end_of_month(); stringstream start, stop; date_facet *facet = new date_facet("%d %b"); start.imbue(locale(cout.getloc(), facet)); start << start_date; opt.start_date = to_upper_copy(start.str()); facet = new date_facet("%d %b %Y"); stop.imbue(locale(cout.getloc(), facet)); stop << stop_date; opt.stop_date = to_upper_copy(stop.str()); // Print the report PrintReport(cout, opt, on_air, off_air); return 0; }