Changeset 3644


Ignore:
Timestamp:
May 10, 2013 3:31:17 PM (7 years ago)
Author:
gah
Message:
 
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/zoo/image/tool.xml

    r1715 r3644  
    11<?xml version="1.0"?>
    22<run>
    3 <tool>
    4   <title>image</title>
    5   <about>Example of a Rappture &lt;image&gt; object.
     3    <tool>
     4        <about>Press Simulate to view results.</about>
     5        <command>matlab -nodisplay -r infile='@driver',path('@tool',path),imagei</command>
     6    </tool>
     7    <input>
     8        <number id="temperature">
     9            <about>
     10                <label>Ambient temperature</label>
     11                <description>Temperature of the environment.</description>
     12            </about>
     13            <units>K</units>
     14            <min>0K</min>
     15            <max>500K</max>
     16            <default>300K</default>
     17            <preset>
     18                <value>300K</value>
     19                <label>300K (room temperature)</label>
     20            </preset>
     21            <preset>
     22                <value>77K</value>
     23                <label>77K (liquid nitrogen)</label>
     24            </preset>
     25            <preset>
     26                <value>4.2K</value>
     27                <label>4.2K (liquid helium)</label>
     28            </preset>
     29        </number>
     30        <number id="Ef">
     31            <about>
     32                <label>Fermi Level</label>
     33                <description>Energy at center of distribution.</description>
     34            </about>
     35            <units>eV</units>
     36            <min>-10eV</min>
     37            <max>10eV</max>
     38            <default>0eV</default>
     39        </number>
     40    </input>
     41</run>
    642
    7 Images are used to decorate input and show output.
    8 
    9 When you click the Simulate button, the input image will be rotated to produce the output image.
    10   </about>
    11   <command>
    12     tclsh @tool/image.tcl @driver
    13   </command>
    14 </tool>
    15 <input>
    16   <loader>
    17     <about>
    18       <label>Image</label>
    19       <description>Use this to load different images.</description>
    20     </about>
    21     <example>*.xml</example>
    22     <default>nanohub.xml</default>
    23   </loader>
    24   <image>
    25     <about>
    26       <label>Image</label>
    27       <description>Input image that gets rotated.</description>
    28       <diffs>ignore</diffs>
    29     </about>
    30     <convert>bmp</convert>
    31   </image>
    32   <number id="angle">
    33     <about>
    34       <label>Rotate</label>
    35       <description>Rotate image by this amount in degrees.</description>
    36     </about>
    37     <units>deg</units>
    38     <min>0deg</min>
    39     <max>360deg</max>
    40     <default>0deg</default>
    41   </number>
    42 </input>
    43 </run>
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r3412 r3644  
    8787typedef struct {
    8888    pid_t child;                /* Child process. */
    89     size_t nFrames;             /* # of frames sent to client. */
    90     size_t nBytes;              /* # of bytes for all frames. */
    91     size_t nCommands;           /* # of commands executed */
     89    size_t numFrames;           /* # of frames sent to client. */
     90    size_t numBytes;            /* # of bytes for all frames. */
     91    size_t numCommands;         /* # of commands executed */
    9292    double cmdTime;             /* Elapsed time spend executing commands. */
    9393    struct timeval start;       /* Start of elapsed time. */
     
    115115                                         * most recently received image from
    116116                                         * the pymol server to the least. */
    117     ssize_t nWritten;                   /* Number of bytes of image data
     117    ssize_t numWritten;                 /* Number of bytes of image data
    118118                                         * already delivered.*/
    119119    size_t bytesLeft;                   /* Number of bytes of image data left
     
    335335 *      If insufficient data is in the buffer, then the channel is
    336336 *      read for more data.  If reading the channel results in a
    337  *      short read, NULL is returned and *nBytesPtr is set to
     337 *      short read, NULL is returned and *numBytesPtr is set to
    338338 *      BUFFER_CONTINUE.
    339339 */
    340340static char *
    341 NextLine(ReadBuffer *readPtr, int *nBytesPtr)
     341NextLine(ReadBuffer *readPtr, int *numBytesPtr)
    342342{
    343343    int i;
     
    361361                p = readPtr->bytes + readPtr->mark;
    362362                i++;                    /* Include the newline. */
    363                 *nBytesPtr = i - readPtr->mark;
     363                *numBytesPtr = i - readPtr->mark;
    364364                readPtr->mark = i;
    365365#if READTRACE
    366                 Debug("Leaving NextLine(%.*s)\n", *nBytesPtr, p);
     366                Debug("Leaving NextLine(%.*s)\n", *numBytesPtr, p);
    367367#endif
    368368                return p;
     
    372372         * more. Check first that last read wasn't a short read. */
    373373        if (status == BUFFER_CONTINUE) {
    374             *nBytesPtr = BUFFER_CONTINUE;  /* No complete line just yet. */
     374            *numBytesPtr = BUFFER_CONTINUE;  /* No complete line just yet. */
    375375            return NULL;
    376376        }
     
    378378        status = FillBuffer(readPtr);
    379379        if (status == BUFFER_ERROR) {
    380             *nBytesPtr = BUFFER_ERROR;
     380            *numBytesPtr = BUFFER_ERROR;
    381381            return NULL;        /* EOF or error on read. */
    382382        }
     
    386386    Debug("Leaving NextLine failed to read line\n");
    387387#endif
    388     *nBytesPtr = BUFFER_CONTINUE;
     388    *numBytesPtr = BUFFER_CONTINUE;
    389389    return NULL;
    390390}
     
    398398 */
    399399static int
    400 ReadFollowingData(ReadBuffer *readPtr, char *out, int nBytes)
     400ReadFollowingData(ReadBuffer *readPtr, char *out, int numBytes)
    401401{
    402402#if READTRACE
    403     Debug("Entering ReadFollowingData(%d)\n", nBytes);
     403    Debug("Entering ReadFollowingData(%d)\n", numBytes);
    404404#endif
    405     while (nBytes > 0) {
     405    while (numBytes > 0) {
    406406        int bytesLeft;
    407407        int status;
     
    412412
    413413            /* Pull bytes out of the buffer, updating the mark. */
    414             size = (bytesLeft >  nBytes) ? nBytes : bytesLeft;
     414            size = (bytesLeft >  numBytes) ? numBytes : bytesLeft;
    415415            memcpy(out, readPtr->bytes + readPtr->mark, size);
    416416            readPtr->mark += size;
    417             nBytes -= size;
     417            numBytes -= size;
    418418            out += size;
    419419        }
    420         if (nBytes == 0) {
     420        if (numBytes == 0) {
    421421            /* Received requested # bytes. */
    422422#if READTRACE
    423             Debug("Leaving ReadFollowingData(%d)\n", nBytes);
     423            Debug("Leaving ReadFollowingData(%d)\n", numBytes);
    424424#endif
    425425            return BUFFER_OK;
     
    436436    }
    437437#if READTRACE
    438     Debug("Leaving ReadFollowingData(%d)\n", nBytes);
     438    Debug("Leaving ReadFollowingData(%d)\n", numBytes);
    439439#endif
    440440    return BUFFER_OK;
     
    463463    length = strlen(match);
    464464    for (;;) {
    465         int nBytes;
     465        int numBytes;
    466466        char *line;
    467467
    468         line = NextLine(&proxyPtr->server, &nBytes);
     468        line = NextLine(&proxyPtr->server, &numBytes);
    469469        if (line != NULL) {
    470470#if EXPECTTRACE
    471             Debug("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);
     471            Debug("pymol says (read %d bytes):%.*s", numBytes, numBytes, line);
    472472#endif
    473473            if ((c == line[0]) && (strncmp(line, match, length) == 0)) {
    474                 if (maxSize < nBytes) {
    475                     nBytes = maxSize;
     474                if (maxSize < numBytes) {
     475                    numBytes = maxSize;
    476476                }
    477                 memcpy(out, line, nBytes);
     477                memcpy(out, line, numBytes);
    478478                clear_error(proxyPtr);
    479479#if EXPECTTRACE
    480                 Debug("Leaving Expect: got (%.*s)\n", nBytes, out);
     480                Debug("Leaving Expect: got (%.*s)\n", numBytes, out);
    481481#endif
    482482                return TCL_OK;
     
    484484            continue;
    485485        }
    486         if (nBytes == BUFFER_ERROR) {
     486        if (numBytes == BUFFER_ERROR) {
    487487            Tcl_AppendResult(proxyPtr->interp,
    488488                "error reading server to find match for \"", match, "\": ",
     
    548548    sprintf(buf, "pid=\"%d\" ", pid);
    549549    Tcl_DStringAppend(&ds, buf, -1);
    550     sprintf(buf, "num_frames=\"%lu\" ", (unsigned long int)stats.nFrames);
     550    sprintf(buf, "num_frames=\"%lu\" ", (unsigned long int)stats.numFrames);
    551551    Tcl_DStringAppend(&ds, buf, -1);
    552     sprintf(buf, "frame_bytes=\"%lu\" ", (unsigned long int)stats.nBytes);
     552    sprintf(buf, "frame_bytes=\"%lu\" ", (unsigned long int)stats.numBytes);
    553553    Tcl_DStringAppend(&ds, buf, -1);
    554     sprintf(buf, "num_commands=\"%lu\" ", (unsigned long int)stats.nCommands);
     554    sprintf(buf, "num_commands=\"%lu\" ", (unsigned long int)stats.numCommands);
    555555    Tcl_DStringAppend(&ds, buf, -1);
    556556    sprintf(buf, "cmd_time=\"%g\" ", stats.cmdTime);
     
    637637
    638638    stats.cmdTime += finish - start;
    639     stats.nCommands++;
     639    stats.numCommands++;
    640640    return result;
    641641}
     
    662662    }
    663663    proxyPtr->headPtr = imgPtr;
    664     imgPtr->nWritten = 0;
     664    imgPtr->numWritten = 0;
    665665    return imgPtr;
    666666}
     
    691691#endif
    692692        for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
    693             ssize_t nWritten;
     693            ssize_t numWritten;
    694694#if WRITETRACE
    695695            Debug("WriteImage: try to write %d bytes.", bytesLeft);
    696696#endif
    697             nWritten = write(fd, imgPtr->data + imgPtr->nWritten, bytesLeft);
     697            numWritten = write(fd, imgPtr->data + imgPtr->numWritten, bytesLeft);
    698698#if WRITETRACE
    699             Debug("WriteImage: wrote %d bytes.", nWritten);
     699            Debug("WriteImage: wrote %d bytes.", numWritten);
    700700#endif
    701             if (nWritten < 0) {
     701            if (numWritten < 0) {
    702702                ERROR("Error writing fd=%d, %s", fd, strerror(errno));
    703703                return;
    704704            }
    705             bytesLeft -= nWritten;
     705            bytesLeft -= numWritten;
    706706            if (bytesLeft > 0) {
    707707                /* Wrote a short buffer, means we would block. */
    708                 imgPtr->nWritten += nWritten;
     708                imgPtr->numWritten += numWritten;
    709709                imgPtr->bytesLeft = bytesLeft;
    710710                return;
    711711            }
    712             imgPtr->nWritten += nWritten;
     712            imgPtr->numWritten += numWritten;
    713713        }
    714714        /* Check if image is on the head.  */
     
    729729    char expect[BUFSIZ];
    730730    int result;
    731     ssize_t nWritten;
     731    ssize_t numWritten;
    732732    size_t length;
    733733    char *p;
     
    747747    /* Write the command out to the server. */
    748748    length = strlen(buffer);
    749     nWritten = write(proxyPtr->sin, buffer, length);
    750     if (nWritten != length) {
     749    numWritten = write(proxyPtr->sin, buffer, length);
     750    if (numWritten != length) {
    751751        ERROR("short write to pymol (wrote=%d, should have been %d): %s",
    752               nWritten, length, strerror(errno));
     752              numWritten, length, strerror(errno));
    753753    }
    754754    for (p = buffer; *p != '\0'; p++) {
     
    11001100    PymolProxy *proxyPtr = clientData;
    11011101    int state, defer, push;
    1102     int nBytes;
     1102    int numBytes;
    11031103    int i, j;
    11041104
     
    11231123    if (argc < 4) {
    11241124        Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
    1125                          " <data>|follows <model> <state> ?<nBytes>?\"",
     1125                         " <data>|follows <model> <state> ?<numBytes>?\"",
    11261126                         (char *)NULL);
    11271127        return TCL_ERROR;
     
    11321132        return TCL_ERROR;
    11331133    }
    1134     nBytes = -1;
     1134    numBytes = -1;
    11351135    if (strcmp(data, "follows") == 0) {
    11361136        if (argc != 5) {
    11371137            Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
    1138                          " follows <model> <state> <nBytes>\"", (char *)NULL);
     1138                         " follows <model> <state> <numBytes>\"", (char *)NULL);
    11391139            return TCL_ERROR;
    11401140        }
    1141         if (Tcl_GetInt(interp, argv[4], &nBytes) != TCL_OK) {
     1141        if (Tcl_GetInt(interp, argv[4], &numBytes) != TCL_OK) {
    11421142            return TCL_ERROR;
    11431143        }
    1144         if (nBytes < 0) {
     1144        if (numBytes < 0) {
    11451145            Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
    11461146                         "\"", (char *)NULL);
     
    11581158
    11591159    allocated = NULL;
    1160     if (nBytes >= 0) {
    1161         allocated = malloc(sizeof(char) * nBytes);
     1160    if (numBytes >= 0) {
     1161        allocated = malloc(sizeof(char) * numBytes);
    11621162        if (allocated == NULL) {
    11631163            Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
     
    11651165            return TCL_ERROR;
    11661166        }
    1167         if (ReadFollowingData(&proxyPtr->client, allocated, nBytes)
     1167        if (ReadFollowingData(&proxyPtr->client, allocated, numBytes)
    11681168            != BUFFER_OK) {
    11691169            Tcl_AppendResult(interp, "can't read pdbdata from client.",
     
    11741174        data = allocated;
    11751175    } else {
    1176         nBytes = strlen(data);
     1176        numBytes = strlen(data);
    11771177    }
    11781178    {
    11791179        int f;
    1180         ssize_t nWritten;
     1180        ssize_t numWritten;
    11811181        char fileName[200];
    11821182
     
    11891189            goto error;
    11901190        }
    1191         nWritten = write(f, data, nBytes);
    1192         if (nBytes != nWritten) {
     1191        numWritten = write(f, data, numBytes);
     1192        if (numBytes != numWritten) {
    11931193            Tcl_AppendResult(interp, "can't write PDB data to \"",
    11941194                             fileName, "\": ", Tcl_PosixError(interp),
     
    12961296{
    12971297    char buffer[BUFSIZ];
    1298     int nBytes=0;
     1298    int numBytes=0;
    12991299    PymolProxy *proxyPtr = clientData;
    13001300    size_t length;
     
    13101310        return TCL_ERROR;
    13111311    }
    1312     if (sscanf(buffer, "png image follows: %d\n", &nBytes) != 1) {
     1312    if (sscanf(buffer, "png image follows: %d\n", &numBytes) != 1) {
    13131313        Tcl_AppendResult(interp, "can't get # bytes from \"", buffer, "\"",
    13141314                         (char *)NULL);
    13151315        return TCL_ERROR;
    13161316    }
    1317     sprintf(buffer, "nv>image %d %d %d %d\n", nBytes, proxyPtr->cacheId,
     1317    sprintf(buffer, "nv>image %d %d %d %d\n", numBytes, proxyPtr->cacheId,
    13181318            proxyPtr->frame, proxyPtr->rockOffset);
    13191319    length = strlen(buffer);
    1320     imgPtr = NewImage(proxyPtr, nBytes + length);
     1320    imgPtr = NewImage(proxyPtr, numBytes + length);
    13211321    strcpy(imgPtr->data, buffer);
    1322     if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, nBytes)
     1322    if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, numBytes)
    13231323        != BUFFER_OK) {
    1324         ERROR("can't read %d bytes for \"image follows\" buffer: %s", nBytes,
     1324        ERROR("can't read %d bytes for \"image follows\" buffer: %s", numBytes,
    13251325              strerror(errno));
    13261326        return  TCL_ERROR;
     
    13291329        return TCL_ERROR;
    13301330    }
    1331     stats.nFrames++;
    1332     stats.nBytes += nBytes;
     1331    stats.numFrames++;
     1332    stats.numBytes += numBytes;
    13331333    return proxyPtr->status;
    13341334}
     
    13391339{
    13401340    char buffer[BUFSIZ];
    1341     int nBytes=0;
     1341    int numBytes=0;
    13421342    PymolProxy *proxyPtr = clientData;
    13431343    size_t length;
     
    13531353        return TCL_ERROR;
    13541354    }
    1355     if (sscanf(buffer, "ppm image follows: %d\n", &nBytes) != 1) {
     1355    if (sscanf(buffer, "ppm image follows: %d\n", &numBytes) != 1) {
    13561356        Tcl_AppendResult(interp, "can't get # bytes from \"", buffer, "\"",
    13571357                         (char *)NULL);
    13581358        return TCL_ERROR;
    13591359    }
    1360     sprintf(buffer, "nv>image %d %d %d %d\n", nBytes, proxyPtr->cacheId,
     1360    sprintf(buffer, "nv>image %d %d %d %d\n", numBytes, proxyPtr->cacheId,
    13611361            proxyPtr->frame, proxyPtr->rockOffset);
    13621362    length = strlen(buffer);
    1363     imgPtr = NewImage(proxyPtr, nBytes + length);
     1363    imgPtr = NewImage(proxyPtr, numBytes + length);
    13641364    strcpy(imgPtr->data, buffer);
    1365     if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, nBytes)
     1365    if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, numBytes)
    13661366        != BUFFER_OK) {
    1367         ERROR("can't read %d bytes for \"image follows\" buffer: %s", nBytes,
     1367        ERROR("can't read %d bytes for \"image follows\" buffer: %s", numBytes,
    13681368              strerror(errno));
    13691369        return  TCL_ERROR;
     
    13741374    }
    13751375#endif
    1376     stats.nFrames++;
    1377     stats.nBytes += nBytes;
     1376    stats.numFrames++;
     1377    stats.numBytes += numBytes;
    13781378    return proxyPtr->status;
    13791379}
     
    13851385{
    13861386    char buffer[800];
    1387     int nBytes=0;
     1387    int numBytes=0;
    13881388    PymolProxy *proxyPtr = clientData;
    13891389    size_t length;
     
    14251425    }
    14261426
    1427     if (sscanf(buffer, "png image follows: %d\n", &nBytes) != 1) {
     1427    if (sscanf(buffer, "png image follows: %d\n", &numBytes) != 1) {
    14281428        Tcl_AppendResult(interp, "can't get # bytes from \"", buffer, "\"",
    14291429                         (char *)NULL);
    14301430        return TCL_ERROR;
    14311431    }
    1432     sprintf(buffer, "nv>image %d print \"%s\" %d\n", nBytes, token,
     1432    sprintf(buffer, "nv>image %d print \"%s\" %d\n", numBytes, token,
    14331433            proxyPtr->rockOffset);
    14341434    Debug("header is png is (%s)\n", buffer);
    14351435    length = strlen(buffer);
    1436     imgPtr = NewImage(proxyPtr, nBytes + length);
     1436    imgPtr = NewImage(proxyPtr, numBytes + length);
    14371437    strcpy(imgPtr->data, buffer);
    1438     if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, nBytes)
     1438    if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, numBytes)
    14391439        != BUFFER_OK) {
    1440         ERROR("can't read %d bytes for \"image follows\" buffer: %s", nBytes,
     1440        ERROR("can't read %d bytes for \"image follows\" buffer: %s", numBytes,
    14411441              strerror(errno));
    14421442        return  TCL_ERROR;
     
    14461446    }
    14471447
    1448     stats.nFrames++;
    1449     stats.nBytes += nBytes;
     1448    stats.numFrames++;
     1449    stats.numBytes += numBytes;
    14501450    return proxyPtr->status;
    14511451}
     
    21952195         */
    21962196        if (pollFd[1].revents & POLLIN) { /* Server stdout */
    2197             int nBytes;
     2197            int numBytes;
    21982198            char *line;
    21992199           
     
    22012201            /* Don't care what's in the server output buffer. */
    22022202            FlushBuffer(&proxyPtr->server);
    2203             line = NextLine(&proxyPtr->server, &nBytes);
     2203            line = NextLine(&proxyPtr->server, &numBytes);
    22042204            if (line != NULL) {
    2205                 Debug("STDOUT>%.*s", nBytes, line);
    2206                 INFO("Garbage found from pymol server: %.%s", nBytes, line);
    2207             } else if (nBytes == BUFFER_CONTINUE) {
     2205                Debug("STDOUT>%.*s", numBytes, line);
     2206                INFO("Garbage found from pymol server: %.%s", numBytes, line);
     2207            } else if (numBytes == BUFFER_CONTINUE) {
    22082208                Debug("No data found on pymol stdout\n");
    22092209                continue;
    22102210            } else {
    2211                 ERROR("can't read pymol stdout (nBytes=%d): %s\n", nBytes,
     2211                ERROR("can't read pymol stdout (numBytes=%d): %s\n", numBytes,
    22122212                      strerror(errno));
    22132213                goto error;             /* Get out on EOF or error. */
     
    22192219            Debug("Reading client stdout\n");
    22202220            for (;;) {
    2221                 int nBytes;
     2221                int numBytes;
    22222222                char *line;
    22232223               
    2224                 line = NextLine(&proxyPtr->client, &nBytes);
     2224                line = NextLine(&proxyPtr->client, &numBytes);
    22252225                if (line != NULL) {
    22262226                    const char *cmd;
    22272227
    2228                     Tcl_DStringAppend(&clientCmds, line, nBytes);
     2228                    Tcl_DStringAppend(&clientCmds, line, numBytes);
    22292229                    cmd = Tcl_DStringValue(&clientCmds);
    22302230                    if (Tcl_CommandComplete(cmd)) {
     
    22442244                    continue;
    22452245                }
    2246                 if (nBytes == BUFFER_CONTINUE) {
     2246                if (numBytes == BUFFER_CONTINUE) {
    22472247                    break;
    22482248                }
    2249                 ERROR("can't read client stdout (nBytes=%d): %s\n", nBytes,
     2249                ERROR("can't read client stdout (numBytes=%d): %s\n", numBytes,
    22502250                      strerror(errno));
    22512251                goto error;             /* Get out on EOF or error. */
Note: See TracChangeset for help on using the changeset viewer.