00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu) 00006 University of Massachusetts at Lowell, 00007 Laboratory for Artificial Intelligence and Robotics 00008 00009 This file is part of Phission. 00010 00011 ---------------------------------------------------------------------------*/ 00012 #include <NetDisplayTest.h> 00013 #include <phission.h> 00014 00015 /* ------------------------------------------------------------------------ */ 00016 int usage () 00017 { 00018 printf("\n\nUsage:\n"); 00019 printf("\t--help Display usage\n"); 00020 printf("\t--test <value> Sleep 'value' seconds and then close test\n"); 00021 printf("\n\n"); 00022 exit(1); 00023 } 00024 00025 /* ------------------------------------------------------------------------ */ 00026 int main(int argc, char *argv[] ) 00027 { 00028 phFUNCTION("main") 00029 00030 int displaysOpen= 1; 00031 /* Utility class to ease the starting and stopping of displays, captures and 00032 * pipelines */ 00033 phSystem system; 00034 00035 NetDisplay display(320,240,"NetDisplayTest"); 00036 00037 /* Remove the code below when using this code as an example. 00038 * 00039 * This just checks whether "--test" has been specified with 00040 * a time value argument. It's for testing all the examples 00041 * without the need for human intervention. */ 00042 int test = 0; 00043 00044 phArgTable *arg_parser = new phArgTable(); 00045 00046 /* Setup and parse all the arguments */ 00047 rc = arg_parser->add("--test", &test, phARG_INT); 00048 phCHECK_RC(rc,NULL,"arg_parser->add"); 00049 rc = arg_parser->add("--help",(void *)&usage, phARG_FUNC); 00050 phCHECK_RC(rc,NULL,"arg_parser->add"); 00051 00052 rc = arg_parser->parse(argc,argv); 00053 phCHECK_RC(rc,NULL,"arg_parser->parse"); 00054 00055 00056 rc = system.addDisplay(&display); 00057 phPRINT_RC(rc,NULL,"system.addDisplay(&display)"); 00058 00059 00060 00061 /* 1.) Open and close test */ 00062 phPROGRESS("1.) Open & Close Test\n"); 00063 00064 rc = system.startup(); 00065 phPRINT_RC(rc,NULL,"system.startup()"); 00066 00067 phMSleep(1000); /* 1 second */ 00068 00069 rc = system.shutdown(); 00070 phPRINT_RC(rc,NULL,"system.shutdown()"); 00071 00072 00073 00074 /* 2.) Open and wait for user to close... test */ 00075 phPROGRESS("2.) Open & Wait for user to close Test\n"); 00076 00077 /* Display startup */ 00078 rc = system.startup(); 00079 phPRINT_RC(rc,NULL,"system.startup()"); 00080 00081 while (displaysOpen) 00082 { 00083 /* Sleep a while, don't loop tightly */ 00084 00085 phMSleep(100); 00086 00087 /* Yielding is optional. This gives up the thread's timeslice 00088 * to prevent slow response in other threads. It consumes more 00089 * CPU cycles than sleeping. Use it instead of sleeping if 00090 * this loop is processing anything */ 00091 00092 /* phYield(); */ 00093 00094 if (display.isOpen()) 00095 { 00096 displaysOpen = 1; 00097 } 00098 00099 /* Remove this if block when using this code as an example */ 00100 /* Set the loop control value to end the loop when testing */ 00101 if (test > 0) 00102 { 00103 displaysOpen = 0; 00104 phSleep(test); /* test's value should be a time (in secs) value > 0*/ 00105 } 00106 } 00107 00108 /* Display shutdown */ 00109 rc = system.shutdown(); 00110 phPRINT_RC(rc,NULL,"system.shutdown()"); 00111 00112 00113 error: 00114 phDelete(arg_parser); 00115 00116 return phSUCCESS; 00117 }
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |