Changes between Initial Version and Version 1 of Old/Documentation/OTG/FuncSpec/UserInterface


Ignore:
Timestamp:
Sep 26, 2005, 3:56:18 PM (19 years ago)
Author:
zhibinwu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/Documentation/OTG/FuncSpec/UserInterface

    v1 v1  
     1[wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/FuncSpec Function Specifications] > User Interface
     2
     3= Function Specification: User Interface Design =
     4
     5User Interace provides a command shell to users. User can specify important program arguments in a standard command line format. "--option <arg>".
     6
     7== Design Requirement ==
     8The following principles of the design should be respected:
     9 * User only need to give command-line options once to start the program. A step-by-step configuraton tends to be confusing, error-prone and complicates fault-handling.
     10 * Configuration file shall not be used. (difficult to maintain)
     11 * Run-time argument change must be supported whenever possible.
     12 * In the run-time, user comamnd inputs can only change one parameter a time. (multiple changes at the same time might lead mutual conflicting)
     13
     14== Brief introduction abou using POPT ==
     15
     16The OTG software uses POPT library to simplify the design of user interface. To use POPT,
     17An "options" structure has to be defined first.
     18{{{
     19struct poptOption options[] = {
     20  POPT_AUTOHELP
     21  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "Port" },
     22  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "Generator" },
     23  { "protocol", '\0', POPT_ARG_STRING, NULL, 0, "Name of protocol"},
     24  { "generator", '\0', POPT_ARG_STRING, NULL, 0, "Name of generator"},
     25  { "debuglog", '\0', POPT_ARG_STRING, NULL, 0, "Filename of Measurements Log"},
     26  { "exit", '\0', POPT_ARG_NONE, NULL, 1, "Stop the generator and exit" },
     27  { "pause", '\0', POPT_ARG_NONE, NULL, 2, "pause the generator and exit" },
     28  { "resume", '\0', POPT_ARG_NONE, NULL, 3, "resume the generator" },
     29  { NULL, 0, 0, NULL, 0 }
     30};
     31}}}
     32
     33then, use a while loop to parse all given option arguments. Whenever an option name matches one of the options defined in the options array, the "poptGetNextOpt" fucntion call will return a value. Different options return differnt valuse. This occurs repetitively until the value returns -1. So, In "case" of differnt value, different handling routing should be proceeded.
     34{{{
     35  int rc;
     36  while ((rc = poptGetNextOpt(optCon)) > 0) {
     37
     38        if (rc == 1) {// Stop
     39          str->exitStream();
     40          exit(0);  //exit terminate process and all its threads
     41        }
     42        else if (rc == 2)
     43        {
     44          str->pauseStream();         
     45        }
     46        else if (rc==3)
     47        {
     48          str->resumeStream();
     49        }     
     50  };
     51  if (rc < -1) {
     52    cerr << "ERROR: " << poptBadOption(optCon, POPT_BADOPTION_NOALIAS)
     53         << " (" << poptStrerror(rc) << ")" << endl;
     54  }
     55  poptFreeContext(optCon);
     56  return rc;   
     57}}}
     58
     59== OTG User Interface ==
     60
     61In OTG program, first-tier options are following
     62 * protocol, generator, debuglog
     63"protocol" and "generator" must be parsed correctly before other arguements related to them can be understood. "debuglog" is used only for turning on the local logging of measurements. Because first-tier options are pivotal and governing 2nd-tier options in the program, run-time changes for them are impossible.
     64
     65Correspondingly, three fucntions are used in parsing options:
     66 * parseOptionsPhase1
     67 * parseOptionsPhase2
     68 * parseRuntimeOptions
     69
     70''parseOptionsPhase1'' is used to set values for variables corresponding to first-tier arguments
     71Because both Port and Generator are vitual base class, a certain type of Port and Generator objects will be created based on those variables.
     72Second-tier options are parsed by ''parseOptionsPhase2''. Certain properties of newly created Port and Generator objects will be set.
     73Finally, ''parseRuntimeOptions'' will parse run-time user input to change a certain set of parameters.
     74For initial shell user inputs, ''argc'' and ''argv'' are automatically provided by standard C. So, we pass them to POPT function directly.
     75But for run-time user inputs, a special char* variable ''msg'' is taken as the parameter. The msg contain the setting for only one options and either in "--option <arg>" format or without leading hyphons.
     76
     77== OTR User Interface ==
     78In OTR program, first-tier options are following
     79 * protocol, debuglog
     80"protocol" must be parsed correctly before other arguements relating to receiving functions could be understood. "debuglog" is used only for turning on the local logging of measurements. Because first-tier options are pivotal and governing 2nd-tier options in the program, run-time changes for them are impossible.
     81
     82Correspondingly, three fucntions are used in parsing options:
     83 * parseOptionsPhase1
     84 * parseOptionsPhase2
     85 * parseRuntimeOptions
     86
     87''parseOptionsPhase1'' is used to set values for variable corresponding to first-tier arguments
     88Because Gate is a virtual base class, a certain type of Gate object will be created based on ''prootcol_name''  variable.
     89Second-tier options are parsed by ''parseOptionsPhase2''. Certain properties of newly created Gate object will be set.
     90Finally, ''parseRuntimeOptions'' will parse run-time user input to change a certain set of parameters.
     91For initial shell user inputs, ''argc'' and ''argv'' are automatically provided by standard C. So, we pass them to POPT function directly.
     92But for run-time user inputs, a special char* variable ''msg'' is taken as the parameter. The msg contain the setting for only one options and either in "--option <arg>" format or without leading hyphons.
     93
     94== Difference between OTG and OTR user interface design
     95
     96As can be seen, the deisng for OTG and OTR user interfaces are quite similar, but there are two major differnce:
     97 * Gate does not need "generator" related options
     98 * Gate does not support run-time pause and resume options.
     99
     100== Discussion ==
     101
     102A major shortcoming of current design is the "--help" option does not disclose the full scale of option structure. Only first-tier options are showed.