Beispiel #1
0
/*
 * Manual page at process.def
 */
INT16 CGEN_PUBLIC CProcess::Status()
{
  CData* d;
  char   s[L_INPUTLINE];
  INT32   i;

  printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());               // Protocol
  printf("\n   Status of instance");                                            // Protocol
  printf("\n   process %s",BASEINST(_this)->m_lpInstanceName);                  // Protocol
  printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());               // Protocol
  printf("\n   State       : 0x%04X",m_nState);                                 // Protocol
  if (m_nState!=0)                                                              // In any but the maiden state
  {                                                                             // >>
    BOOL b = 0;                                                                 //   Comma flag
    printf(" (");                                                               //   Protocol
    if (m_nState&PRC_DATASENT    ) { if(b) printf(", "); printf("data sent"    ); b=1; }//...
    if (m_nState&PRC_RUNNING     ) { if(b) printf(", "); printf("running"      ); b=1; }//...
    if (m_nState&PRC_COMPLETE    ) { if(b) printf(", "); printf("complete"     ); b=1; }//...
    if (m_nState&PRC_KILLED      ) { if(b) printf(", "); printf("killed"       ); b=1; }//...
    if (m_nState&PRC_DATARECEIVED) { if(b) printf(", "); printf("data received"); b=1; }//...
    printf(")");                                                                //   Protocol
  }                                                                             // <<
  printf("\n   Return value: %ld",(long)m_nRetVal  );                           // Protocol
  if (dlp_strlen(m_psTmpFile)) printf("\n   Temp. files : %s*",m_psTmpFile);    // Protocol
  dlp_strcpy(s,m_psCmdLine); dlp_strreplace(s,m_psTmpFile,"<tmpfile>");         // Abbreviate command line
  if (dlp_strlen(m_psCmdLine)) printf("\n   Command line: %s" ,s);              // Protocol

  // Show transferred data                                                      // ------------------------------------
  if (m_iDto)                                                                   // Have data transfer object
  {                                                                             // >>
    printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());             //   Protocol
    printf("\n   Transferred data");                                            //   Protocol
    d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDSIGN,NULL);          //   Get signature table
    printf("\n   - function  : %s",(char*)CData_XAddr(d,0,0));                  //   Protocol (job function name)
    for (i=1; i<CData_GetNRecs(d); i++)                                         //   Loop over function arguemnts
      printf("\n   %13s %s",i==1?"- arguments :":"",(char*)CData_XAddr(d,i,0)); //     Protocol (job function arg.)
    d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDGLOB,NULL);          //   Get list of global instances
    if (d)                                                                      //   Have one
      for (i=0; i<CData_GetNRecs(d); i++)                                       //     Loop over entries
        printf("\n   %13s %-8s %s",i==0?"- globals   :":"",                     //       Protocol (global instance)
          (char*)CData_XAddr(d,i,0),(char*)CData_XAddr(d,i,1));                 //       |
    printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());             //   Protocol
    printf("\n   Transferred program");                                         //   Protocol
    for (i=0; dlp_strlen(__sSlaveScript[i]); i++)                               //   Loop over slave script lines
    {                                                                           //   >>
      dlp_strcpy(s,__sSlaveScript[i]);                                          //     Get a line
      if (strstr(s,"##"))*(strstr(s,"##"))='\0';                                //     Truncate at comment
      printf("\n     (%02ld) %s",i,dlp_strtrimright(s));                        //     Protocol (script line)
    }                                                                           //   <<
  }                                                                             // <<

  printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); printf("\n"); // Protocol
  return O_K;                                                                   // All done
}
Beispiel #2
0
/**
 * Prints the instance in text mode (exactly one component of type 1).
 */
INT16 CGEN_PRIVATE CData_PrintText(CData* _this)
{
  INT32  nR   = 0;                                                               /* Current record                    */
  INT32  nXR  = 0;                                                               /* Number of records                 */
  char* tx   = NULL;                                                            /* Auxilary char pointer #1          */
  char* tx0  = NULL;                                                            /* Pointer to string                 */
  char* ty   = NULL;                                                            /* Auxilary char pointer #2          */
  char* ty0  = NULL;                                                            /* Pointer to last white space       */
  INT32  nCtr = 0;                                                               /* Line counter                      */
  char  sBuf[255];                                                              /* Printing buffer                   */

  /* Initialize */                                                              /* --------------------------------- */
  nXR = CData_GetNRecs(_this);                                                  /* Get number of records             */

  /* Print data contents as text */                                             /* --------------------------------- */
  DLPASSERT(FMSG("ALPHA: String mode not tested yet"));                         /* TODO: Remove after debugging      */
  printf("\n  String Mode"); dlp_inc_printlines(1);                             /* Protocol                          */
  tx0=tx=(char*)CData_XAddr(_this,0,0);                                         /* Initialize char pointers          */
  if (!*tx)                                                                     /* Empty string                      */
  {                                                                             /* >>                                */
    printf("\n  [empty]");                                                      /*   Protocol                        */
    dlp_inc_printlines(1);                                                      /*   Adjust no. of printed lines     */
  }                                                                             /* <<                                */
  else while (*tx)                                                              /* Loop over characters              */
  {                                                                             /* >>                                */
    /* Make line breaks */                                                      /*   - - - - - - - - - - - - - - - - */
    for (ty=tx,ty0=NULL; *ty && ty<tx0+nXR; )                                   /*   Do until end of string          */
    {                                                                           /*   >>                              */
      while (*ty && ty<tx0+nXR && !iswspace(*ty)) ty++;                         /*     Seek next white space         */
      while (*ty && ty<tx0+nXR &&  iswspace(*ty)) ty++;                         /*     Skip following white spaces   */
      ty0=ty;                                                                   /*     Remember previous white spc.  */
      if (ty>tx+dlp_maxprintcols()-16) break;                                   /*     Line full                     */
    }                                                                           /*   <<                              */
    if (ty0) ty=ty0;                                                            /*   Go back to last white space     */

    /* Print one line */                                                        /*   - - - - - - - - - - - - - - - - */
    dlp_memset(sBuf,0,255);                                                     /*   Clear printing buffer           */
    dlp_memmove(sBuf,tx,ty-tx);                                                 /*   Copy characters in              */
    printf("\n  %4d(%06d): %s",(int)nCtr,(int)(tx-tx0),sBuf);                   /*   Print 'em                       */
    dlp_inc_printlines(1);                                                      /*   Adjust no. of printed lines     */
    if (dlp_if_printstop()) break;                                              /*   Break listing                   */

    /* End-of-line actions */                                                   /*   - - - - - - - - - - - - - - - - */
    DLPASSERT(ty>tx);                                                           /*   Should have made some progress  */
    tx=ty;                                                                      /*   Move to end of printed line     */
    nCtr++;                                                                     /*   Increment line counter          */
  }                                                                             /* <<                                */
  if (nR>=nXR) printf("\n  No more data - Stop.");                              /* Protocol                          */
  else         printf("\n  Cancelled - Stop.");                                 /* Protocol                          */
  return O_K;                                                                   /* Ok                                */
}
Beispiel #3
0
/**
 * Prints the instance in vector mode (standard).
 * @param _this
 *          Pointer to data instance
 * @return <code>O_K</code> if successfull, a (negative) errorcode otherwise
 */
INT16 CGEN_PUBLIC CData_PrintVectors(CData* _this)
{
  INT32 i   = 0;                                                                /* Universal loop counter            */
  INT32 nB  = 0;                                                                /* Current block index               */
  INT32 nL  = 0;                                                                /* Number of recently printed lines  */
  INT32 nXL = 0;                                                                /* Total number of printed lines     */
  char sBuf[L_SSTR+1];                                                          /* String buffer                     */

  if (CData_GetNBlocks(_this)<=1)                                               /* No blocks                         */
    return (INT16)CData_PrintVectors_Block(_this,-1);                           /*   Print all records at once       */
  else for (nB=0; nB<CData_GetNBlocks(_this); )                                 /* Else loop over blocks             */
  {                                                                             /* >>                                */
    nL = CData_PrintVectors_Block(_this,nB);                                    /*   Print blocks separately         */
    if (nL<0) { printf("\n   Cancelled"); return O_K; }                         /*   Cancelled by user               */
    if (nB<CData_GetNBlocks(_this)-1)                                           /*   Not the last block              */
      { printf("\n"); for (i=0; i<dlp_maxprintcols(); i+=2) printf(" -"); }     /*     Print a nice separator        */
    nXL += nL;                                                                  /*   Count printed lines             */
    if                                                                          /*   Next block won't fit on screen  */
    (                                                                           /*   |                               */
      nXL+nL>dlp_maxprintlines() ||                                             /*   | if it is as long as the last  */
      CData_GetNRecsPerBlock(_this)>dlp_maxprintlines()                         /*   | because it has too many recs. */
    )                                                                           /*   |                               */
    {                                                                           /*   >>                              */
      if (nB==CData_GetNBlocks(_this))                                          /*     This was the last block       */
        { printf("\n"); for (i=0; i<dlp_maxprintcols(); i+=2) printf(" -"); }   /*       Separator not yet printed   */
      dlp_inc_printlines(dlp_maxprintlines());                                  /*     Do stop right here            */
      sprintf(sBuf,"block (0..%ld)",(long)CData_GetNBlocks(_this)-1);           /*     Make user hint                */
      if ((nB=dlp_printstop_nix(nB,sBuf,NULL))==-1) break;                      /*     Break listing                 */
      if (nB< -2 ) nB=0;                                                        /*     Bad user reply -> start over  */
      if (nB>=CData_GetNBlocks(_this)) break;                                   /*     No more blocks -> break       */
      nXL=0;                                                                    /*     Reset line counter            */
    }                                                                           /*   <<                              */
    else nB++;                                                                  /*   No list break -> next block     */
  }                                                                             /* <<                                */
  return O_K;                                                                   /* Ok                                */
}
Beispiel #4
0
/*
 * Manual page at statistics.def
 */
INT16 CGEN_PUBLIC CStatistics_Pool
(
  CStatistics* _this,
  CStatistics* iSrc,
  CData*       idMap
)
{
  INT32   i          = 0;                                                        /* Current component index           */
  INT32   nC         = 0;                                                        /* Current pooled statistics class   */
  INT32   nCs        = 0;                                                        /* Current source class index        */
  INT32   nXC        = 0;                                                        /* Number of pooled classes          */
  INT32   nRpb       = 0;                                                        /* Statistics raw data block size    */
  INT16  nCheckSave = 0;                                                        /* Saved check level                 */
  CData* idAux      = NULL;                                                     /* Auxilary data instance #1         */
  CData* idPmp      = NULL;                                                     /* Pooling map                       */
  CData* idPcd      = NULL;                                                     /* Pooled class raw data buffer      */

  /* Initialize */                                                              /* --------------------------------- */
  CHECK_THIS_RV(0);                                                             /* Check this instance               */
  IF_NOK(CStatistics_Check(iSrc))                                               /* Check source statistics           */
    return IERROR(_this,ERR_INVALARG,"iSrc",0,0);                               /* ...                               */
  nCheckSave = _this->m_nCheck;                                                 /* Save check level                  */
  CStatistics_Reset(BASEINST(_this),TRUE);                                      /* Reset destination                 */
  _this->m_nCheck = nCheckSave;                                                 /* Restore check level               */
  IFIELD_RESET(CData,"dat");                                                    /* Create pool raw stats. data inst. */

  /* Protocol */                                                                /* --------------------------------- */
  IFCHECK                                                                       /* On verbose level 1                */
  {                                                                             /* >>                                */
    printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());             /*   Print protocol header           */
    printf("\n   statistics -pool");                                            /*   ...                             */
    printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());printf("\n");/*   ...                             */
  }                                                                             /* <<                                */

  /* No map --> pool all classes */                                             /* --------------------------------- */
  if (CData_IsEmpty(idMap))                                                     /* NULL or empty map instance        */
  {                                                                             /* >>                                */
    IFCHECK printf("\n   Empty pooling map --> pool all classes");              /*   Protocol (verbose level 1)      */
    CStatistics_PoolInt(_this->m_idDat,iSrc->m_idDat,0);                        /*   Pool sum data                   */
    CStatistics_PoolInt(_this->m_idDat,iSrc->m_idDat,1);                        /*   Pool min data                   */
    CStatistics_PoolInt(_this->m_idDat,iSrc->m_idDat,2);                        /*   Pool max data                   */
    STA_PROTOCOL_FOOTER(1,"done");                                              /*   Print protocol footer           */
    return O_K;                                                                 /*   That's it                       */
  }

  IFCHECK printf("\n   Pooling by map");                                        /* Protocol (verbose level 1)        */
  ICREATEEX(CData,idAux,"CStatistics_Pool.~idAux",NULL);                        /* Create auxilary data instance #1  */
  ICREATEEX(CData,idPmp,"CStatistics_Pool.~idPmp",NULL);                        /* Create pooling map                */
  ICREATEEX(CData,idPcd,"CStatistics_Pool.~idPcs",NULL);                        /* Create pooled raw stats.data inst.*/

  /* Find and copy map component (pooled class) */                              /* --------------------------------- */
  for (i=0; i<CData_GetNComps(idMap); i++)                                      /* Loop over components of idMap     */
    if (dlp_is_numeric_type_code(CData_GetCompType(idMap,i)))                   /*   Is current component numeric?   */
    {                                                                           /*   >> (Yes)                        */
      CData_SelectComps(idPmp,idMap,i,1);                                       /*     Copy component                */
      break;                                                                    /*     Have ready :)                 */
    }                                                                           /*   <<                              */
  if (CData_IsEmpty(idPmp))                                                     /* Have not got map component        */
  {                                                                             /* >>                                */
    IERROR(_this,STA_BADCOMP,"map",BASEINST(idMap)->m_lpInstanceName,"numeric");/*   Error message                   */
    DLPTHROW(STA_BADCOMP);                                                      /*   Throw exception                 */
  }                                                                             /* <<                                */

  /* Create source class component */                                           /* --------------------------------- */
  CData_AddComp(idPmp,"srcc",T_LONG);                                           /* Add source class index component  */
  for (i=0; i<CData_GetNRecs(idPmp); i++) CData_Dstore(idPmp,i,i,1);            /* Fill it                           */

  /* Finish pooling map and initialize pooling */                               /* --------------------------------- */
  CData_Sortup(idPmp,idPmp,0);                                                  /* Sort map by pooled class index    */
  nXC = (INT32)CData_Dfetch(idPmp,CData_GetNRecs(idPmp)-1,0)+1;                 /* Get greatest pooled class index   */
  IFCHECK printf("\n   Pooling %ld statistics classes",(long)nXC);              /* Protocol (verbose level 1)        */
  IFCHECKEX(3) CData_Print(idPmp);                                              /* Print pooling map (verbose lvl.3) */
  nRpb = CData_GetNRecsPerBlock(iSrc->m_idDat);                                 /* Get block size                    */

  /* Prepare pooled statistics */                                               /* --------------------------------- */
  CData_Scopy(_this->m_idDat,iSrc->m_idDat);                                    /* Create target raw data components */
  CData_Allocate(_this->m_idDat,nRpb*nXC);                                      /* Allocate target raw data          */
  CData_SetNBlocks(_this->m_idDat,nXC);                                         /* Set target statistics block number*/

  /* Pooling loop */                                                            /* --------------------------------- */
  for (i=0; i<CData_GetNRecs(idPmp); )                                          /* Loop over pooling map             */
  {                                                                             /* >>                                */
    /* - Copy raw statistics data of one pooled class */                        /*   - - - - - - - - - - - - - - - - */
    nC = (INT32)CData_Dfetch(idPmp,0,0);                                         /*   Get pooled class index          */
    IFCHECK printf("\n     Pooled class %3ld");                                 /*   Protocol (verbose level 1)      */
    for (i=0; i<CData_GetNRecs(idPmp); i++)                                     /*   Loop over partition of pool.map */
    {                                                                           /*   >>                              */
      if (nC != (INT32)CData_Dfetch(idPmp,0,0)) break;                           /*     Not the current class anymore */
      nCs = (INT32)CData_Dfetch(idPmp,i,1);                                      /*     Get source class index        */
      IFCHECK printf("\n     - Source class %3ld",nCs);                         /*     Protocol (verbose level 1)    */
      CData_SelectBlocks(idAux,iSrc->m_idDat,nCs,1);                            /*     Copy raw stats. data block    */
      CData_Cat(idPcd,idAux);                                                   /*     Append to buffer              */
    }                                                                           /*   <<                              */

    /* - Pool data */                                                           /*   - - - - - - - - - - - - - - - - */
    CData_SetNBlocks(idPcd,CData_GetNRecs(idPcd)/nRpb);                         /*   Set block count of aggr. buffer */
    IFCHECK                                                                     /*   Protocol (verbose level 1)      */
      printf("\n     - Aggregating %ld statistics classes",                     /*   |                               */
      (long)CData_GetNBlocks(idPcd));                                           /*   |                               */
    CStatistics_PoolInt(idAux,idPcd,0);                                         /*   Pool sum data                   */
    CStatistics_PoolInt(idAux,idPcd,1);                                         /*   Pool min data                   */
    CStatistics_PoolInt(idAux,idPcd,2);                                         /*   Pool max data                   */

    /* - Store pooled raw statistics data block */                              /*   - - - - - - - - - - - - - - - - */
    dlp_memmove                                                                 /*   Copy pooled raw stats. data     */
    (                                                                           /*   |                               */
      CData_XAddr(_this->m_idDat,nC*nRpb,0),                                    /*   | To target statistics block    */
      CData_XAddr(idAux,0,0),                                                   /*   | From aggregation buffer       */
      CData_GetNRecs(idAux)*CData_GetRecLen(idAux)                              /*   | Length of aggregation buffer  */
    );                                                                          /*   |                               */

    /* - Clean up auxilary instances */                                         /*   - - - - - - - - - - - - - - - - */
    CData_Reset(idPcd,TRUE);                                                    /*   Clear aggregation buffer        */
  }

  /* Clean up */                                                                /* --------------------------------- */
  IDESTROY(idAux);                                                              /* Destroy auxilary data instance #1 */
  IDESTROY(idPmp);                                                              /* Destroy pooling map               */
  IDESTROY(idPcd);                                                              /* Destroy pooled cls. raw data inst.*/
  STA_PROTOCOL_FOOTER(1,"done");                                                /* Print protocol footer             */
  return O_K;                                                                   /* Ok                                */

DLPCATCH(STA_BADCOMP)                                                           /* == Catch STA_BADCOMP exception    */
  IDESTROY(idAux);                                                              /* Destroy auxilary data instance #1 */
  IDESTROY(idPmp);                                                              /* Destroy pooling map               */
  IDESTROY(idPcd);                                                              /* Destroy pooled cls. raw data inst.*/
  STA_PROTOCOL_FOOTER(1,"FAILED");                                              /* Print protocol footer             */
  return NOT_EXEC;                                                              /* Not ok                            */
}
Beispiel #5
0
/**
 * Prints one block of the instance in vector mode (standard).
 */
INT32 CGEN_PRIVATE CData_PrintVectors_Block
(
  CData* _this,                                                                 /* Pointer to data instance          */
  INT32   nBlock                                                                 /* Block index (<0: ignore blocks)   */
)                                                                               /* Returns number of lines printed   */
{
  INT32 i      = 0;                                                              /* Universal loop counter            */
  INT32 nR     = 0;                                                              /* Current record                    */
  INT32 nR_    = 0;                                                              /* First record to be printed        */
  INT32 nR0    = 0;                                                              /* First record of current page      */
  INT32 nSR    = 0;                                                              /* Number of records of currenr page */
  INT32 nXR    = 0;                                                              /* Last record to print plus one     */
  INT32 nC     = 0;                                                              /* Current component                 */
  INT32 nXC    = 0;                                                              /* Number of components              */
  INT32 nWI    = 0;                                                              /* Component index column width      */
  INT32 nW0    = 0;                                                              /* Head column width                 */
  INT32 nW     = 0;                                                              /* Column width                      */
  INT32 nP     = 0;                                                              /* Current page                      */
  INT32 nPps   = 0;                                                              /* Pages per screen                  */
  INT32 nL     = 0;                                                              /* Line counter                      */
  BOOL bPur   = FALSE;                                                          /* Print physical record unit flag   */
  BOOL bPuc   = FALSE;                                                          /* Print physical component unit flg.*/
  FLOAT64 nBuf = 0.;                                                             /* Double buffer                     */
  char   sBuf[L_SSTR+1];                                                        /* String buffer                     */

  /* Validate */                                                                /* --------------------------------- */
  if (nBlock>=CData_GetNBlocks(_this)) return 0;                                /* Requested block does not exist    */

  /* Initialize */                                                              /* --------------------------------- */
  nR_ = nBlock>=0 ? CData_GetNRecsPerBlock(_this)*nBlock : 0;                   /* Get first record to print         */
  nXR = nBlock>=0 ? nR_+CData_GetNRecsPerBlock(_this) : CData_GetNRecs(_this);  /* Get number of records             */
  nXC = CData_GetNComps(_this);                                                 /* Get number of components          */
  bPur = _this->m_lpTable->m_fsr!=1. && _this->m_lpTable->m_fsr!=0.;            /* Displaying physical record units? */
  bPuc = _this->m_nCinc!=1. && _this->m_nCinc!=0.;                              /* Displaying physical comp. units?  */
  nPps = dlp_maxprintlines()/(nXC+4);                                           /* Compute no. of pages per sceeen   */

  /* Print vectors */                                                           /* --------------------------------- */
  if (nBlock>=0)                                                                /* Printing blockwise?               */
  {                                                                             /* >>                                */
    printf("\n   Block %ld (offset %ld)",(long)nBlock,(long)nR_);               /*   Show current block index        */
    dlp_inc_printlines(1);  nL++;                                               /*   Adjust number of printed lines  */
  }                                                                             /* <<                                */
  for (nR0=nR_; nR0<nXR; )                                                      /* Loop over records                 */
  {                                                                             /* >>                                */
    CData_PrintVectors_GetColWidth(_this,nR0,0,&nWI,&nW0,&nW);                  /*   Comp. head and data col. widths */
    nSR = (dlp_maxprintcols()-nWI-nW0-4)/(nW+1);                                /*   Number of columns to print      */
    if (nR0+nSR>nXR) nSR = nXR-nR0;                                             /*   No more than there are records! */

    /* Print record header */                                                   /*   - - - - - - - - - - - - - - - - */
    if (bPur)                                                                   /*   Display physical record units?  */
    {                                                                           /*   >>                              */
      printf("\n %s ->",__pad(strcpy(sBuf,_this->m_lpRunit),nW0+nWI,'r'));      /*     Print name of physical unit   */
      for (nR=nR0; nR<nR0+nSR; nR++)                                            /*     Loop over remaining records   */
      {                                                                         /*     >>                            */
        nBuf = _this->m_lpTable->m_ofs + (nR-nR_)*_this->m_lpTable->m_fsr;      /*       Compute abscissa value      */
        __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                         /*       Print to a string           */
        printf("%s ",__pad(sBuf,nW,'r'));                                       /*       Format and print to screen  */
      }                                                                         /*     <<                            */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/
    }                                                                           /*   <<                              */
    sBuf[0]='\0';                                                               /*   Clear string buffer             */
    if (bPuc) sprintf(sBuf,"%s| ",_this->m_lpCunit);                            /*   Print phys. comp. unit name...  */
    printf("\n %s",__pad(sBuf,nW0+nWI+3,'r'));                                  /*   ... or empty string             */
    for (nR=nR0; nR<nR0+nSR; nR++)                                              /*   Loop over remaining records     */
    {                                                                           /*   >>                              */
      i=nR-nR_; __sprintx(sBuf,&i,T_INT,_this->m_bExact);                       /*     Print record index to a str.  */
      printf("%s%c",__pad(sBuf,nW,'r'),CData_RecIsMarked(_this,nR)?'*':' ');    /*     Format and print to screen    */
    }                                                                           /*   <<                              */
    sBuf[0]='\0';                                                               /*   Clear string buffer             */
    if (bPuc) sprintf(sBuf,"%c ",bPuc?'v':' ');                                 /*   Print down arrow ...            */
    printf("\n %s",__pad(sBuf,nW0+nWI+3,'r'));                                  /*   ... or empty string             */
    sBuf[0]='\0'; for (i=0; i<nW; i++) sBuf[i]='.'; sBuf[i]='\0';               /*   Make horizonal delimiter        */
    for (nR=nR0; nR<nR0+nSR; nR++) printf("%s ",sBuf);                          /*   Print one per vector            */
    dlp_inc_printlines(2);  nL+=2;                                              /*   Adjust number of printed lines  */

    /* Print data */                                                            /*   - - - - - - - - - - - - - - - - */
    for (nC=0; nC<nXC; )                                                        /*   Loop over components            */
    {                                                                           /*   >>                              */
      __sprintx(sBuf,&nC,T_INT,_this->m_bExact);                                /*     Print comp. index to a string */
      printf("\n%c%s ",                                                         /*     Format and print to screen    */
        CData_CompIsMarked(_this,nC)?'*':' ',__pad(sBuf,nWI,'r'));              /*     | (incl. "*" for "marked")    */
      if (bPuc && dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))        /*     Display ordinate value?       */
      {                                                                         /*     >>                            */
        nBuf = _this->m_nCofs + nC*_this->m_nCinc;                              /*       Compute it                  */
        __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                         /*       Print it to a string        */
      }                                                                         /*     <<                            */
      else strcpy(sBuf,CData_GetCname(_this,nC));                               /*     else display component name   */
      printf("%s: ",__pad(dlp_strtrimleft(dlp_strtrimright(sBuf)),nW0,'r'));    /*     Format and print to screen    */
      for (nR=nR0; nR<nR0+nSR; nR++)                                            /*     Loop over remaining records   */
      {                                                                         /*     >>                            */
        __sprintx(sBuf,CData_XAddr(_this,nR,nC),                                /*       Print cell value to a str.  */
            CData_GetCompType(_this,nC),_this->m_bExact);                       /*         |                         */
        if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC)))             /*       Is string value             */
          if ((INT32)dlp_strlen(sBuf)>nW)                                        /*         Will not fit in column    */
            dlp_strabbrv(sBuf,sBuf,nW);                                         /*           Abbreviate it           */
        if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))              /*       Is numeric value            */
          if (_this->m_bNz && CMPLX_EQUAL(CData_Cfetch(_this,nR,nC),CMPLX(0.)))
            dlp_strcpy(sBuf,"-");
        printf("%s%c",__pad(sBuf,nW,'r'),                                       /*       Format and print to screen  */
          CData_CellIsMarked(_this,nR*CData_GetNComps(_this)+nC)?'*':' ');      /*       | (incl. "*" for "marked")  */
      }                                                                         /*     <<                            */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/

      /* Break component listing */                                             /*     - - - - - - - - - - - - - - - */
      if (nPps==0)                                                              /*     Not all comps. fit on screen  */
      {                                                                         /*     >>                            */
        sprintf(sBuf,"component (0..%ld), cancel -3",(long)nXC-1);              /*       Make user hint              */
        if ((nC=dlp_printstop_nix(nC,sBuf,NULL))==-1) break;                    /*       Break listing               */
        if (nC< -2 ) return -1;                                                 /*       Cancelled by user           */
        if (nC>=nXC) break;                                                     /*       No more components -> break */
      }                                                                         /*     <<                            */
      else nC++;                                                                /*     No breaking -> count comps.   */
    }                                                                           /*   <<                              */
    nR0+=nSR;                                                                   /*   First record on next page       */
    nP++;                                                                       /*   Count pages                     */
    if (nR0<nXR)                                                                /*   There are more records          */
    {                                                                           /*   >>                              */
      printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());           /*     Print a separator             */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/
    }                                                                           /*   <<                              */

    /* Break record listing */                                                  /*   - - - - - - - - - - - - - - - - */
    if (((nPps>0 && nP>=nPps) || nPps==0) && nR0<nXR)                           /*   Complicated break condition :)  */
    {                                                                           /*   >>                              */
      dlp_inc_printlines(dlp_maxprintlines());                                  /*     Do stop right here            */
        sprintf(sBuf,"record (%ld..%ld)%s",(long)nR_,(long)nXR-1,               /*     Make user hint                */
          nBlock>=0?", cancel -3":"");                                          /*     |                             */
      if ((nR0=dlp_printstop_nix(--nR0,sBuf,NULL))==-1) break;                  /*     Break listing                 */
      if (nR0< -2 ) return -1;                                                  /*     Cancelled by user             */
      if (nR0< nR_) nR0=nR_;                                                    /*     No previous blocks, please!   */
      if (nR0>=nXR) break;                                                      /*     No more records -> break      */
      nP=0;                                                                     /*     Reset page counter            */
    }                                                                           /*   <<                              */
  }                                                                             /* <<                                */

  return nL;                                                                    /* Return number of printed lines    */
}
Beispiel #6
0
/**
 * Computes the print widths of the head column and one data vector.
 */
INT16 CGEN_PRIVATE CData_PrintVectors_GetColWidth
(
  CData* _this,                                                                 /* Pointer to data instance          */
  INT32   nR0,                                                                   /* First record to be printed        */
  INT32   nC0,                                                                   /* First component to be printed     */
  INT32*  lpnWI,                                                                 /* Print width of comp.idx.col.(ret) */
  INT32*  lpnW0,                                                                 /* Print width of head column (ret)  */
  INT32*  lpnW                                                                   /* Print width of data column (ret)  */
)                                                                               /* Returns O_K or (neg.) error code  */
{
  INT32   nR   = 0;                                                              /* Current record                    */
  INT32   nXR  = 0;                                                              /* Number of records                 */
  INT32   nC   = 0;                                                              /* Current component                 */
  INT32   nXC  = 0;                                                              /* Number of components              */
  INT32   nWn  = 0;                                                              /* Widest number in cols. of screen  */
  INT32   nWs  = 0;                                                              /* Widest string in cols. of screen  */
  FLOAT64 nBuf = 0.;                                                             /* Double buffer                     */
  char   sBuf[L_SSTR+1];                                                        /* String buffer                     */
  UINT64 nTime = 0;

  /* Initialize */                                                              /* --------------------------------- */
  *lpnW  = 0;                                                                   /* Data column width                 */
  *lpnWI = 0;                                                                   /* Component index column width      */
  *lpnW0 = 0;                                                                   /* Head column width                 */
  nXR    = CData_GetNRecs(_this);                                               /* Get number of records             */
  nXC    = CData_GetNComps(_this);                                              /* Get number of components          */

  /* Compute head column print width */                                         /* --------------------------------- */
  for (*lpnW0=0,nC=nC0; nC<nXC; nC++)                                           /* Loop over remaining components    */
  {                                                                             /* >>                                */
    if                                                                          /*   Displaying physical units?      */
    (                                                                           /*   |                               */
      dlp_is_numeric_type_code(CData_GetCompType(_this,nC)) &&                  /*   | Numeric component             */
      dlp_strlen(_this->m_lpCunit) && _this->m_nCinc!=0.                        /*   | Physical units specified      */
    )                                                                           /*   |                               */
    {                                                                           /*   >>                              */
      nBuf = _this->m_nCofs + nC*_this->m_nCinc;                                /*     The physical coordinate       */
      __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                           /*     Print to a string             */
    }                                                                           /*   <<                              */
    else                                                                        /*   String comp. or no phys. units  */
      __sprintx(sBuf,CData_GetCname(_this,nC),10,_this->m_bExact);              /*     Print component name to str.  */
    *lpnW0 = MAX(*lpnW0,(INT32)dlp_strlen(sBuf));                               /*   Get length of phys. unit / name */
  }                                                                             /* <<                                */

  /* Compute component index column print width */                              /* --------------------------------- */
  nC--;                                                                         /* Last component to be printed      */
  __sprintx(sBuf,&nC,T_INT,_this->m_bExact);                                    /* Print greatest comp. index to str.*/
  *lpnWI = (INT32)dlp_strlen(sBuf);                                             /* Get length of component index col.*/

  /* Compute data vector print width */                                         /* --------------------------------- */
  nTime = dlp_time();
  for (*lpnW=0,nR=nR0; nR<nXR; nR++)                                            /* Loop over remaining records       */
  {                                                                             /* >>                                */
    /* Determine width of physical unit */                                      /*   - - - - - - - - - - - - - - - - */
    if (dlp_strlen(_this->m_lpRunit) && _this->m_lpTable->m_fsr!=0.)            /*   Displaying physical units?      */
    {                                                                           /*   >>                              */
      nBuf = _this->m_lpTable->m_ofs + nR*_this->m_lpTable->m_fsr;              /*     The physical coordinate       */
      __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                           /*     Print to a string             */
      *lpnW = MAX((INT32)dlp_strlen(sBuf),*lpnW);                               /*     Aggregate actual print width  */
    }                                                                           /*   <<                              */

    /* Determine width of record index */                                       /*   - - - - - - - - - - - - - - - - */
    __sprintx(sBuf,&nR,T_INT,_this->m_bExact);                                  /*   Print record index to a string  */
    *lpnW = MAX((INT32)dlp_strlen(sBuf),*lpnW);                                 /*     Aggregate actual print width  */

    /* Determine greatest component width */                                    /*   - - - - - - - - - - - - - - - - */
    for (nC=nC0; nC<nXC; nC++)                                                  /*   Loop over remaining components  */
    {                                                                           /*   >>                              */
      __sprintx(sBuf,CData_XAddr(_this,nR,nC),                                  /*     Print cell value to a string  */
          CData_GetCompType(_this,nC),_this->m_bExact);                         /*       |                           */
      if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))                /*     It is a number                */
        nWn = MAX((INT32)dlp_strlen(sBuf),nWn);                                 /*       Aggr. number print width    */
      else if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC)))          /*     It is a string                */
        nWs = MAX((INT32)dlp_strlen(sBuf),nWs);                                  /*       Aggr. string print width    */
      if (dlp_time()-nTime>__TIMEOUT) break;                                    /*      Takes too long -> forget it! */
    }                                                                           /*   <<                              */

    if (dlp_time()-nTime>__TIMEOUT) break;                                      /*    Takes too long -> forget it!   */
    if ((nR-nR0+2)*((*lpnW)+1)>dlp_maxprintcols()-*lpnWI-*lpnW0-3) break;       /*    Next vec. would not fit anymore*/
  }                                                                             /*  <<                               */

  /* If computing data vector print width timed out ... */                      /* --------------------------------- */
  if (dlp_time()-nTime>__TIMEOUT)                                               /* There was a time out              */
    for (nC=nC0; nC<nXC; nC++)                                                  /*   Loop over remaining components  */
      if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))                /*     It is a number                */
        nWn = MAX(dlp_printlen(CData_GetCompType(_this,nC)),nWn);               /*       Use standard print width    */
      else if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC)))          /*     It is a string                */
        nWs = MAX(dlp_printlen(CData_GetCompType(_this,nC)),nWs);               /*       Also use std. print width   */

  /* Aftermath */                                                               /* --------------------------------- */
  if (nWs>dlp_maxprintcols()-(*lpnW0)-(*lpnWI)-3)                               /* Limit string width to line length */
    nWs=dlp_maxprintcols()-(*lpnW0)-(*lpnWI)-3;                                 /* ...                               */
  if (nWn<=0) *lpnW = MAX(nWs,*lpnW);                                           /* No numbers -> complete strings    */
  else *lpnW = MAX(nWn,*lpnW);                                                  /* Minimal space req. for numbers    */
  /*if (nWn>0 && *lpnW+3<nWs) (*lpnW) += 3;*/                                       /* Print a little more of the strs.  */
  if (nWn>0 && *lpnW<nWs) *lpnW = MIN(16,nWs);                                  /* Print max. 16 chars. of strings   */
  return O_K;                                                                   /* Ok                                */
}
Beispiel #7
0
/**
 * Prints the content of one record formatted as columns. If printing requires
 * more than <a href="dlp_base.html#cfn_dlp_maxprintcols">dlp_maxprintcols</a>
 * characters the listing will be continued on the next line(s).</p>
 *
 * @param _this
 *          Pointer to data instance
 * @param nRec
 *          Index of record to print
 * @param nIcFirst
 *          Index of first component to print
 * @param nComps
 *          Number of components to print
 * @param nIndent
 *          Indentation (spaces) at beginning of lines (<b>Note</b>: the first
 *          line will <em>not</em> be indented!)
 * @return The number of lines printed
 */
INT16 CGEN_PUBLIC CData_PrintRec
(
  CData* _this,
  INT32    nRec,
  INT32    nIcFirst,
  INT32    nComps,
  INT16   nIndent
)
{
  INT16 nLines = 1;
  INT16 nCol   = nIndent;
  INT32  nXC    = 0;
  INT32  nC     = 0;
  INT16 i      = 0;
  INT16 I      = 0;
  char  sBuf[L_SSTR+1];

  nXC = CData_GetNComps(_this);

  if (nIcFirst<0 || nIcFirst>=nXC) return 1; /* NOTE: This is still one line! */
  if (nIcFirst+nComps>nXC) nComps=nXC-nIcFirst;
  if (nRec>=CData_GetNRecs(_this)) return 0;

  for (nC=nIcFirst,nCol=nIndent; nC<nIcFirst+nComps; nC++)
  {
    if (nRec<0)
    {
      /* Heading */
      I=dlp_printlen(CData_GetCompType(_this,nC));
      strcpy(sBuf," ");
      for (i=I-(INT16)dlp_strlen(CData_GetCname(_this,nC))-1; i>0; i--) strcat(sBuf," ");
      if(CData_CompIsMarked(_this,nC)) sBuf[dlp_strlen(sBuf)-2]='*';
      strcat(sBuf,CData_GetCname(_this,nC));
      nCol+=dlp_printlen(CData_GetCompType(_this,nC)); /* Count standard width (!) */
      printf(sBuf);
    }
    else
    {
      /* Print values */
      dlp_sprintx(sBuf,(char*)CData_XAddr(_this,nRec,nC),CData_GetCompType(_this,nC),_this->m_bExact);
      nCol+=dlp_printlen(CData_GetCompType(_this,nC)); /* Count standard width (!) */
      dlp_strconvert(SC_PRC_ESCAPE,sBuf,sBuf);
      dlp_strreplace(sBuf,"\n","\\n");
      dlp_strreplace(sBuf,"\r","\\r");
      dlp_strreplace(sBuf,"\t","\\t");
      printf(sBuf);
    }

    if ((nC<nIcFirst+nComps-1)                                               &&
        (nCol+dlp_printlen(CData_GetCompType(_this,nC+1))>dlp_maxprintcols()) )
    {
      /* Line break */
      strcpy(sBuf,"\n");
      for (i=nIndent-(nIndent>7?7:0); i>0;i--) strcat(sBuf," ");
      printf(sBuf);
      if (nIndent>7) printf("%5ld  ",(long)(nC+1));
      nCol=nIndent;
      nLines++;
    }
  }

  return nLines;
}
Beispiel #8
0
/*
 * Manual page at var.def
 */
INT16 CGEN_PUBLIC CVar_Status(CVar *_this)
{
  char lpsBuf[255];
  
  CVar_PopOwnValue(_this);
  printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());
  printf("\n   Status of instance");
  printf("\n   var %s\n",BASEINST(_this)->m_lpInstanceName);
  dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());

  switch (_this->m_nType)
  {
    case T_BOOL:
      printf("\n   Type : boolean");
      printf("\n   Value: %d",(int)_this->m_bBVal);
      break;
    case T_DOUBLE:
      dlp_sprintc(lpsBuf,_this->m_nNVal,FALSE);
      printf("\n   Type : double");
      printf("\n   Value: %s", lpsBuf);
      break;
    case T_COMPLEX:
      dlp_sprintc(lpsBuf,_this->m_nNVal,FALSE);
      printf("\n   Type : complex");
      printf("\n   Value: %s", lpsBuf);
      break;
    case T_STRING:
      printf("\n   Type : string");
      printf("\n   Value: \"%s\"",_this->m_lpsSVal?_this->m_lpsSVal:"(null)");
      break;
    case T_INSTANCE:
      printf("\n   Type : instance");
      printf("\n   Value: %s",CDlpObject_GetFQName(BASEINST(_this)->m_iAliasInst,lpsBuf,255));
      break;
    case T_RDOUBLE:
      printf("\n   Type             : double random" );
      printf("\n   Low boundary     : %8lg", (double)_this->m_nLow    );
      printf("\n   High boundary    : %8lg", (double)_this->m_nHi     );
      printf("\n   Step size        : %8lg", (double)_this->m_nDelta  );
      printf("\n   Most recent value: %8lg", (double)_this->m_nNVal.x );
      break;
    case T_RDDATA:
      printf("\n   Type             : numeric random data selector");
      printf("\n   Data table       : %s",CDlpObject_GetFQName(_this->m_idRndSet,lpsBuf,255));
      printf("\n   Component index  : %5ld",(long)_this->m_nInd );
      printf("\n   Component type   : %5ld",(long)_this->m_nType);
      printf("\n   Most recent value: %8lg",(double)_this->m_nNVal.x);
      break;
    case T_RSDATA:
      printf("\n   Type             : string random data selector");
      printf("\n   Data table       : %s",CDlpObject_GetFQName(_this->m_idRndSet,lpsBuf,255));
      printf("\n   Component index  : %5ld", (long)_this->m_nInd );
      printf("\n   Component type   : %5ld", (long)_this->m_nType);
      printf("\n   Most recent value: %s",_this->m_lpsSVal?_this->m_lpsSVal:"(null)");
    default:
      DLPASSERT(FMSG("Unknown variable type"));
  }

  printf("\n");
  dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());
  printf("\n");

  return O_K;
}