Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Message ID: 730     Entry time: 02 Nov 2010
Author: chris pearson 
Topic: Info 
Subject: mhttpd: Extra entries on status page 
   A couple of experiments at triumf wanted certain important odb variables
displayed on their status page.  (There was already the possibility to show the
run comment)
   A new folder "/Experiment/Status Items" was created containing links to the
variables of interest, these items are show on the status page, under the run
comment (if any), in 3 columns.

the code from mhttpd.c:show_status_page()
between
   /*---- run comment ----*/
and
   /*---- Equipment list ----*/
is attached
Attachment 1: status.c  3 kB  | Hide | Hide all
   /*---- run comment ----*/

   /* Also Status items values (including run comment)               */
   /* want Run Comment to be shown first but, instead of             */
   /* storing everything and then displaying in our chosen order     */
   /* find comment first, and then show other items as they are seen */
   db_find_key(hDB,0,"/Experiment/Status Items", &hkey);
   if( hkey ){                               /* If this Directory exists ... */
      char status_data[1000];              /* same size as str defined above */
      db_find_key(hDB,0,"/Experiment/Status Items/comment", &hsubkey);
      if( hsubkey ){               /* Show Run comment before other items ...*/
         db_get_key(hDB, hsubkey, &key);
         size = sizeof(status_data);
         if( (status = db_get_data(hDB, hsubkey, status_data, &size, key.type))
	     == DB_SUCCESS && key.num_values == 1 && key.type != TID_KEY ){
            db_sprintf(str, status_data, key.item_size, 0, key.type);
            rsprintf("<tr align=center><td colspan=6 bgcolor=#E0E0FF><b>%s</b></td></tr>\n", str);
	 }
     }
     /* each key can also be a link: we want link data and original key name */
     /* => get key twice: follwing links(for data) not follow (for org name) */
     int item_count=0;                       /* Total number of things shown */
     for(i=0; ; i++){                       /* Loop over status-item subkeys */
        db_enum_key(hDB, hkey, i, &hsubkey);/*get ith key data, follow links */
        if( ! hsubkey ){ break; }                        /* (end of subkeys) */
        db_get_key(hDB, hsubkey, &key);     /*          ...                  */
        /* key data has unknown type, copy to status_data then conv -> string*/
        size = sizeof(status_data);   /* Don't try to display arrays/subdirs */
        if( (status=db_get_data(hDB,hsubkey, status_data, &size, key.type)) != 
           DB_SUCCESS || key.num_values>1 || key.type == TID_KEY ){ continue; }
        db_sprintf(str, status_data, key.item_size, 0, key.type); /*->string */

        db_enum_link(hDB, hkey, i, &hsubkey);    /* Get ith subkey link name */
        db_get_key(hDB, hsubkey, &key);          /*           ...            */
        if( strstr(key.name,"comment") ){ continue; } /* skip comment (done) */

        if( ! (item_count % 3) ){ rsprintf("<tr>"); }
        rsprintf("<td colspan=2 align=center bgcolor=#%06X>%s: <b>%s</b></td>",
           0xD0D0FF, key.name, str );
        if( ! (++item_count % 3) ){ rsprintf("</tr>\n"); }
     }
     while( (item_count % 3) ){         /* complete any partial row of 3 ... */
        rsprintf("<td colspan=2 bgcolor=#%06x></td>", 0xD0D0FF );
        if( (++item_count % 3) == 0 ){ rsprintf("</tr>\n"); }
     }
   } /* end of if existence of "status items" hkey */

   // Original Run Comment Section ...
   //   size = sizeof(str);
   //   if (db_get_value(hDB, 0, "/Experiment/Run parameters/Comment", str,
   //                    &size, TID_STRING, FALSE) == DB_SUCCESS)
   //      rsprintf("<tr align=center><td colspan=6 bgcolor=#E0E0FF><b>%s</b></td></tr>\n", str);

   /*---- Equipment list ----*/
ELOG V3.1.4-2e1708b5