Пример #1
0
//
// idlTransferCameraListEx
//
// Transfer the information on a specified camera from
// the list populated by idlPvCameraListEx
//
// command line arguments
// argv[0]: IN/FLAG debug
// argv[1]: IN camera: index to retrieve
// argv[2]: OUT version of the structure
// argv[3]: OUT unique id of the camera
// argv[4]: OUT camera name
// argv[5]: OUT model name
// argv[6]: OUT part number
// argv[7]: OUT serial number
// argv[8]: OUT firmware version
// argv[9]: OUT PermittedAccess flags
// argv[10]: OUT interface ID
// argv[11]: OUT interface type
int idlTransferCameraListEx (int argc, char *argv[])
{
  unsigned long camera;
  tPvCameraInfoEx *thiscamera;

  debug = *(IDL_INT *) argv[0];
  camera = *(unsigned long *) argv[1];

  CHECKINDEX(camera);

  thiscamera = &info[camera];

  *argv[2] = (IDL_ULONG) thiscamera->StructVer;
  *argv[3] = (IDL_ULONG) thiscamera->UniqueId;
  IDL_StrStore((IDL_STRING *) argv[4], thiscamera->CameraName);
  IDL_StrStore((IDL_STRING *) argv[5], thiscamera->ModelName);
  IDL_StrStore((IDL_STRING *) argv[6], thiscamera->PartNumber);
  IDL_StrStore((IDL_STRING *) argv[7], thiscamera->SerialNumber);
  IDL_StrStore((IDL_STRING *) argv[8], thiscamera->FirmwareVersion);
  *argv[9] = (IDL_ULONG) thiscamera->PermittedAccess;
  *argv[10] = (IDL_ULONG) thiscamera->InterfaceId;
  *argv[11] = (IDL_ULONG) thiscamera->InterfaceType;
  
  return 0;
}
Пример #2
0
//
// idlPvAttrList
//
// List all the attributes applicable to a camera.
//
// command line arguments
// argv[0]: IN/FLAG debug
// argv[1]: IN camera index
// argv[2]: OUT array of attribute names
int idlPvAttrList (int argc, char *argv[])
{
  unsigned long n;
  unsigned long err;
  unsigned long count;
  tPvAttrListPtr list;
  IDL_STRING *idllist;
  int i;

  debug = *(IDL_INT *) argv[0];
  n = *(unsigned long *) argv[1];
  idllist = (IDL_STRING *) argv[2];

  CHECKINDEX(n);

  err = PvAttrList(camera[n], &list, &count);

  if (err == ePvErrSuccess) {
    for (i = 0; i < count; i++) {
      IDL_StrStore(&idllist[i], (char *) list[i]);
    }
  }

  return idlPvErrCode(err);
}
Пример #3
0
void fillStringArray(char *mem, IDL_STRING *array)
{

    char *memptr;
    IDL_STRING *arrptr;
    int i, n_elements, elsize;

    memptr = mem;
    arrptr = array;

    /* skip some elements to get to data */
    memptr += 3*SIZE32;

    /* get number of elements */
    n_elements = ntohl( *(int32 *) memptr );
    memptr += 2*SIZE32;

    for(i=0; i<n_elements; i++){

        /* Size of this array element */

        elsize = ntohl( *(int32 *) memptr );
        memptr += SIZE32;

        IDL_StrStore(arrptr, memptr);

        /* next element */
        memptr += elsize;
        arrptr++;

    }
}
Пример #4
0
void pgsql_copy_info(field_info *fi) 

{

    int i;

    /* For storing field info */
    IDL_VPTR fieldNamesVptr;
    IDL_STRING *namesPtr;
    IDL_VPTR fieldTypesVptr;
    IDL_LONG *typesPtr;
    IDL_VPTR fieldLengthsVptr;
    IDL_LONG *lengthsPtr;

    if (kw.field_names_there) 
    {
        namesPtr = (IDL_STRING *) 
            IDL_MakeTempVector(IDL_TYP_STRING, fi->nFields, 
                    IDL_ARR_INI_ZERO, &fieldNamesVptr);
        for (i=0; i<fi->nFields; i++)
            IDL_StrStore(&namesPtr[i], fi->field_names[i]);

        IDL_VarCopy(fieldNamesVptr, kw.field_names);
    }

    if (kw.field_types_there)
    {
        typesPtr = (IDL_LONG *) 
            IDL_MakeTempVector(IDL_TYP_ULONG, fi->nFields, 
                    IDL_ARR_INI_ZERO, &fieldTypesVptr);

        for (i=0; i<fi->nFields; i++)
            typesPtr[i] = fi->field_types[i];

        IDL_VarCopy(fieldTypesVptr, kw.field_types);
    }

    if (kw.field_lengths_there)
    {
        lengthsPtr = (IDL_LONG *) 
            IDL_MakeTempVector(IDL_TYP_LONG, fi->nFields, 
                    IDL_ARR_INI_ZERO, &fieldLengthsVptr);

        for (i=0; i<fi->nFields; i++)
            lengthsPtr[i] = fi->field_lengths[i];

        IDL_VarCopy(fieldLengthsVptr, kw.field_lengths);
    }

    if (kw.nrows_there)
        kw.nrows->value.ul64 = fi->nTuples;

}
Пример #5
0
/* Functions I used with the old ascii retrieval */
void pgsql_store_ascii(int idlType, UCHAR *tptr, char *value)
{

    /* Note, not all types can be converted from atoi directly, 
       I am doing the conversion in those cases, hope it works
       */

    switch(idlType)
    {
        case IDL_TYP_FLOAT: 
            /* atof actually returns double */
            *(float *)tptr = (float) atof(value);
            break;
        case IDL_TYP_DOUBLE:
            *(double *)tptr = atof(value);
            break;
        case IDL_TYP_BYTE:
            *(UCHAR *)tptr = (UCHAR) atoi(value);
            break;
        case IDL_TYP_INT:
            *(short *)tptr = (short) atoi(value);
            break;
        case IDL_TYP_UINT:
            *(unsigned short *)tptr = (unsigned short ) atoi(value);
            break;
        case IDL_TYP_LONG:
            *(IDL_LONG *)tptr = (IDL_LONG) atoi(value);
            break;
        case IDL_TYP_ULONG:
            *(IDL_ULONG *)tptr = (IDL_ULONG) atoi(value);
            break;
        case IDL_TYP_LONG64:
            *(IDL_LONG64 *)tptr = (IDL_LONG64) atoll(value);
            break;
        case IDL_TYP_ULONG64:
            *(IDL_ULONG64 *)tptr = (IDL_ULONG64) atoll(value);
            break;
        case IDL_TYP_STRING:
            IDL_StrStore( (IDL_STRING *) tptr, value);
            break;
        default: 
            printf("Unsupported type %d found\n", idlType);
            fflush(stdout);
            break;
    }

}
Пример #6
0
//
// idlpgr_GetCameraInfo
//
// Returns a subset of the fc2CameraInfo structure
//
IDL_VPTR IDL_CDECL idlpgr_GetCameraInfo(int argc, IDL_VPTR argv[])
{
  fc2Error error;
  fc2Context context;
  fc2CameraInfo camerainfo;
  IDL_StructDefPtr sdef;
  char *pd;
  IDL_MEMINT one = 1;
  IDL_VPTR idl_camerainfo;

  context = (fc2Context) IDL_ULong64Scalar(argv[0]);

  error = fc2GetCameraInfo(context, &camerainfo);
  if (error) 
    IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP,
			 "Could not read camera info",
			 error);

  static IDL_STRUCT_TAG_DEF tags[] = {
    { "SERIALNUMBER",     0, (void *) IDL_TYP_ULONG },
    { "ISCOLORCAMERA",    0, (void *) IDL_TYP_LONG },
    { "MODELNAME",        0, (void *) IDL_TYP_STRING },
    { "VENDORNAME",       0, (void *) IDL_TYP_STRING },
    { "SENSORINFO",       0, (void *) IDL_TYP_STRING },
    { "SENSORRESOLUTION", 0, (void *) IDL_TYP_STRING },
    { "DRIVERNAME",       0, (void *) IDL_TYP_STRING },
    { "FIRMWAREVERSION",  0, (void *) IDL_TYP_STRING },
    { 0 }
  };
  sdef = IDL_MakeStruct("fc2CameraInfo", tags);
  pd = IDL_MakeTempStruct(sdef, 1, &one, &idl_camerainfo, TRUE);
  *(IDL_ULONG *) pd      = camerainfo.serialNumber;
  pd += sizeof(IDL_ULONG);
  *(IDL_LONG *) pd = camerainfo.isColorCamera;
  pd += sizeof(IDL_LONG);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.modelName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.vendorName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorInfo);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorResolution);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.driverName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.firmwareVersion);
  
  return idl_camerainfo;
}
Пример #7
0
//
// idlPvAttrStringGet
//
// Get the value of a string attribute
//
// command line arguments
// argv[0]: IN/FLAG debug
// argv[1]: IN camera index
// argv[2]: IN attribute name
// argv[3]: OUT attribute value
int idlPvAttrStringGet (int argc, char *argv[])
{
  unsigned long n;
  unsigned long err;
  IDL_STRING *name;
  IDL_STRING *value;

  debug = *(IDL_INT *) argv[0];
  n = *(unsigned long *) argv[1];
  name = (IDL_STRING *) argv[2];
  value = (IDL_STRING *) argv[3];

  CHECKINDEX(n);

  err = PvAttrStringGet(camera[n],
			(const char *) IDL_STRING_STR(name),
			buffer, STRBUFFERSIZE, (unsigned long *) NULL);

  IDL_StrStore(value, buffer);
		      
  return idlPvErrCode(err);
}
Пример #8
0
/**
 * Get the names of all the data elements which are children of the primary raster element.
 *
 * @param[in] WINDOW @opt
 *            The name of the window. Defaults to the active window.
 * @return An array of data element names or the string "failure" if an error occurred.
 * @usage names = get_data_element_names()
 * @endusage
 */
IDL_VPTR get_data_element_names(int argc, IDL_VPTR pArgv[], char* pArgk)
{
   typedef struct
   {
      IDL_KW_RESULT_FIRST_FIELD;
      int windowExists;
      IDL_STRING windowName;
   } KW_RESULT;

   //IDL_KW_FAST_SCAN is the type of scan we are using, following it is the
   //name of the keyword, followed by the type, the mask(which should be 1),
   //flags, a boolean whether the value was populated and finally the value itself
   static IDL_KW_PAR kw_pars[] = {
      IDL_KW_FAST_SCAN,
      {"WINDOW", IDL_TYP_STRING, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(windowExists)),
         reinterpret_cast<char*>(IDL_KW_OFFSETOF(windowName))},
      {NULL}
   };

   IdlFunctions::IdlKwResource<KW_RESULT> kw(argc, pArgv, pArgk, kw_pars, 0, 1);
   std::string windowName;
   std::string name;
   bool bSuccess = false;
   IDL_VPTR idlPtr;
   unsigned int total = 0;
   IDL_STRING* pStrarr = NULL;

   if (kw->windowExists)
   {
      windowName = IDL_STRING_STR(&kw->windowName);
   }

   SpatialDataWindow* pWindow = NULL;
   if (windowName.empty())
   {
      pWindow = dynamic_cast<SpatialDataWindow*>(Service<DesktopServices>()->getCurrentWorkspaceWindow());
   }
   else
   {
      pWindow = dynamic_cast<SpatialDataWindow*>(
         Service<DesktopServices>()->getWindow(windowName, SPATIAL_DATA_WINDOW));
   }
   if (pWindow != NULL)
   {
      SpatialDataView* pView = pWindow->getSpatialDataView();
      if (pView != NULL)
      {
         LayerList* pList = pView->getLayerList();
         if (pList != NULL)
         {
            RasterElement* pElement = pList->getPrimaryRasterElement();
            if (pElement != NULL)
            {
               std::vector<std::string> names = Service<ModelServices>()->getElementNames(pElement, "");
               total = names.size();
               if (total > 0)
               {
                  pStrarr = reinterpret_cast<IDL_STRING*>(malloc(total * sizeof(IDL_STRING)));
                  for (unsigned int i=0; i < total; ++i)
                  {
                     IDL_StrStore(&(pStrarr[i]), const_cast<char*>(names[i].c_str()));
                  }
                  bSuccess = true;
               }
            }
         }
      }
   }
   else if (windowName == "all")
   {
      std::vector<std::string> names = Service<ModelServices>()->getElementNames("RasterElement");
      total = names.size();
      if (total > 0)
      {
         pStrarr = reinterpret_cast<IDL_STRING*>(malloc(total* sizeof(IDL_STRING)));
         for (unsigned int i=0; i < total; ++i)
         {
            IDL_StrStore(&(pStrarr[i]), const_cast<char*>(names[i].c_str()));
         }
         bSuccess = true;
      }
   }
   if (!bSuccess)
   {
      IDL_Message(IDL_M_GENERIC, IDL_MSG_RET, "No elements matched.");
      return IDL_StrToSTRING("failure");
   }
   IDL_MEMINT dims[] = {total};
   idlPtr = IDL_ImportArray(1, dims, IDL_TYP_STRING, reinterpret_cast<UCHAR*>(pStrarr),
      reinterpret_cast<IDL_ARRAY_FREE_CB>(free), NULL);
   return idlPtr;
}
Пример #9
0
void idlprimfill( HDSLoc *cloc, IDL_VPTR datav, void *datptr, int *status ) {

int j;                  /* loop counters */
UCHAR idltype;            /* The IDL type */
char type[DAT__SZTYP+1];  /* Type in which to to map HDS data */
int bpix;                 /* Number of bytes/value */
int defined;              /* If HDS value defined */
void *cpntr;              /* True C pointer to mapped data */
size_t nels;              /* Number of mapped elements */
int nels_i;
size_t nbytes;            /* Number of bytes in array */
int flen;                 /* length of HDS strings */
int clen;                 /* length of corresponding C string */
char *chars;              /* pointer to imported characters */
IDL_STRING *strings;      /* pointer to array of string structures */
IDL_VPTR chptr;           /* Scratch variable pointer */

if ( *status != SAI__OK ) return;

/* check type compatibility */
/* Get the number of bytes per element */
/* and the HDS type in which to  map the data */
   idltype = datav->type;

   switch (idltype) {
   case IDL_TYP_FLOAT:
      strcpy( type, "_REAL" );
      bpix = 4;
      break;
   case IDL_TYP_LONG:
      strcpy( type, "_INTEGER" );
      bpix = 4;
      break;
   case IDL_TYP_INT:
      strcpy( type, "_WORD" );
      bpix = 2;
      break;
   case IDL_TYP_DOUBLE:
      strcpy( type, "_DOUBLE" );
      bpix = 8;
      break;
   case IDL_TYP_BYTE:
      strcpy( type, "_UBYTE" );
      bpix = 1;
      break;
   case IDL_TYP_STRING:
      datType( cloc, type, status);
      bpix = 1;
      break;
   default:
/* flag no data to copy */
      bpix = 0;
      *status = SAI__ERROR;
      emsSeti( "TYPE", idltype );
      emsRep( " ", "Illegal IDL type ^TYPE", status );
      break;
   } /* end of case */

   if ( (*status == SAI__OK ) && bpix ) {
/* Map the data as if a vector - provided it is defined */
      datState( cloc, &defined, status );
      if ( defined ) {
         datMapV( cloc, type, "READ", &cpntr, &nels, status );
         if ( *status != SAI__OK ) {
            emsRep(" ", "Failed to map HDS component", status );
         } else {
            if ( idltype == IDL_TYP_STRING ) {
               flen = atoi( type + 6 );
               clen = flen + 1;

/* Import the Fortran strings to C */
               nels_i = (int)nels;
               chars = IDL_GetScratch( &chptr, nels_i, clen );
               cnfImprta( cpntr, flen, chars, clen, 1, &nels_i );

/* set strings to be a pointer to the IDL_STRING structure(s) */
               strings = (IDL_STRING *)datptr;

/* store the imported strings into the STRING structures */
               for ( j=0; j<nels; j++ )
                  IDL_StrStore( strings+j, &chars[j*clen] );
               IDL_Deltmp( chptr );

            } else {
/* Type other than string */
               if ( datav->flags & IDL_V_ARR ) {
/* Number Array */
/* copy the data to the array */
                  nbytes = bpix * nels;
                  memcpy( datptr, cpntr, nbytes );
               } else {
/* Number Scalar */
                  switch (idltype) {
                  case IDL_TYP_FLOAT:
                     ((IDL_ALLTYPES *)datptr)->f = *(float *)cpntr;
                     break;
                  case IDL_TYP_LONG:
                     ((IDL_ALLTYPES *)datptr)->l = *(int *)cpntr;
                     break;
                  case IDL_TYP_INT:
                     ((IDL_ALLTYPES *)datptr)->i = *(short *)cpntr;
                     break;
                  case IDL_TYP_DOUBLE:
                     ((IDL_ALLTYPES *)datptr)->d = *(double *)cpntr;
                     break;
                  case IDL_TYP_BYTE:
                     ((IDL_ALLTYPES *)datptr)->c = *(UCHAR *)cpntr;
                     break;
                  } /* end of case */
               } /* end of if array */
            } /* end if string */
            datUnmap( cloc, status );
         } /* end of mapped data */
      } /* end of if defined */
   } /* end of bpix non-zero */

   return;

}
Пример #10
0
int32 OldFitIDLRead(int argc,char *argv[]) {

  int n;

  struct OldFitIDLFp *idlfitfp;
  struct OldFitFp fitfp;
  char combftmp[COMBF_SIZE+1];
  struct RadarIDLParm *idlprm;
  struct FitIDLData *idlfit;
  struct RadarParm prm;
  struct FitData fit;

  IDL_FILE_STAT stat;
  FILE *ffp=NULL,*ifp=NULL;
  int s;

  /* zero out the data structures */

  memset(&prm,0,sizeof(struct RadarParm));
  memset(&fit,0,sizeof(struct FitData));
  memset(&combftmp,0,COMBF_SIZE+1);
  
  idlfitfp=(struct OldFitIDLFp *) argv[0];
  
  IDL_FileStat(idlfitfp->fitunit,&stat);
 
  /* Find the file pointer */

  ffp=stat.fptr; 

  fflush(ffp);
  
  if (ffp==NULL) return -1;

  if (idlfitfp->inxunit !=-1) {
    IDL_FileStat(idlfitfp->inxunit,&stat);
    ifp=stat.fptr;
  }

  if (ifp !=NULL) fflush(ifp);

  fitfp.fitfp=fileno(ffp);
  if (ifp !=NULL) fitfp.inxfp=fileno(ifp);
  else fitfp.inxfp=-1;
 
  

  OldFitIDLToFitFp(idlfitfp,&fitfp);

  s=OldFitRead(&fitfp,&prm,&fit);

  OldFitFitFpToIDL(&fitfp,idlfitfp);

  if (s==-1) return -1;
   
  /* get the structure pointers */

  idlprm=(struct RadarIDLParm *) argv[1];
  idlfit=(struct FitIDLData *) argv[2];

  /* load up the structures.
   *
   * Note: We do not do a direct memcpy as the possibility
   * exists that the IDL data structure is different from 
   * the C data structure.
   *
   */

  idlprm->revision.major=prm.revision.major;
  idlprm->revision.minor=prm.revision.minor;
  idlprm->origin.code=prm.origin.code;
  IDL_StrDelete(&idlprm->origin.time,1);
  IDL_StrDelete(&idlprm->origin.command,1);
  idlprm->cp=prm.cp;
  idlprm->stid=prm.stid;
  idlprm->time.yr=prm.time.yr;
  idlprm->time.mo=prm.time.mo;
  idlprm->time.dy=prm.time.dy;
  idlprm->time.hr=prm.time.hr;
  idlprm->time.mt=prm.time.mt;
  idlprm->time.sc=prm.time.sc;
  idlprm->time.us=prm.time.us;
  idlprm->txpow=prm.txpow;
  idlprm->nave=prm.nave;
  idlprm->atten=prm.atten;
  idlprm->lagfr=prm.lagfr;
  idlprm->smsep=prm.smsep;
  idlprm->ercod=prm.ercod;
  idlprm->stat.agc=prm.stat.agc;
  idlprm->stat.lopwr=prm.stat.lopwr;
  idlprm->noise.search=prm.noise.search;
  idlprm->noise.mean=prm.noise.mean;
  idlprm->channel=prm.channel;
  idlprm->bmnum=prm.bmnum;
  idlprm->bmazm=prm.bmazm;
  idlprm->scan=prm.scan;
  idlprm->rxrise=prm.rxrise;
  idlprm->intt.sc=prm.intt.sc;
  idlprm->intt.us=prm.intt.us;
  idlprm->txpl=prm.txpl;
  idlprm->mpinc=prm.mpinc;
  idlprm->mppul=prm.mppul;
  idlprm->mplgs=prm.mplgs;
  idlprm->nrang=prm.nrang;
  idlprm->frang=prm.frang;
  idlprm->rsep=prm.rsep;
  idlprm->xcf=prm.xcf;
  idlprm->tfreq=prm.tfreq;
  idlprm->offset=prm.offset;
  idlprm->mxpwr=prm.mxpwr;
  idlprm->lvmax=prm.lvmax;

  for (n=0;n<prm.mppul;n++) idlprm->pulse[n]=prm.pulse[n];
  for (n=0;n<prm.mplgs;n++) {
    idlprm->lag[n]=prm.lag[n][0];
    idlprm->lag[LAG_SIZE+n]=prm.lag[n][1];
  }

  strncpy(combftmp,prm.combf,COMBF_SIZE);

  IDL_StrDelete(&idlprm->combf,1);
  IDL_StrStore(&idlprm->combf,combftmp);
  
  idlfit->revision.major=fit.revision.major;
  idlfit->revision.minor=fit.revision.minor;
  idlfit->noise.sky=fit.noise.skynoise;
  idlfit->noise.lag0=fit.noise.lag0;
  idlfit->noise.vel=fit.noise.vel;
  for (n=0;n<prm.nrang;n++) {
    idlfit->pwr0[n]=fit.rng[n].p_0;
    idlfit->nlag[n]=fit.rng[n].nump;
    idlfit->qflg[n]=fit.rng[n].qflg;
    idlfit->gflg[n]=fit.rng[n].gsct;
    idlfit->p_l[n]=fit.rng[n].p_l;
    idlfit->p_l_e[n]=fit.rng[n].p_l_err;
    idlfit->p_s[n]=fit.rng[n].p_s;
    idlfit->p_s_e[n]=fit.rng[n].p_s_err;
    idlfit->v[n]=fit.rng[n].v;
    idlfit->v_e[n]=fit.rng[n].v_err;
    idlfit->w_l[n]=fit.rng[n].w_l;
    idlfit->w_l_e[n]=fit.rng[n].w_l_err;
    idlfit->w_s[n]=fit.rng[n].w_s;
    idlfit->w_s_e[n]=fit.rng[n].w_s_err;
    idlfit->sd_l[n]=fit.rng[n].sdev_l;
    idlfit->sd_s[n]=fit.rng[n].sdev_s;
    idlfit->sd_phi[n]=fit.rng[n].sdev_phi;
    if (prm.xcf !=0) {
      idlfit->elv_low[n]=fit.elv[n].low;
      idlfit->elv[n]=fit.elv[n].normal;
      idlfit->elv_high[n]=fit.elv[n].high;
      idlfit->x_qflg[n]=fit.xrng[n].qflg;
      idlfit->x_gflg[n]=fit.xrng[n].gsct;
      idlfit->x_p_l[n]=fit.xrng[n].p_l;
      idlfit->x_p_l_e[n]=fit.xrng[n].p_l_err;
      idlfit->x_p_s[n]=fit.xrng[n].p_s;
      idlfit->x_p_s_e[n]=fit.xrng[n].p_s_err;
      idlfit->x_v[n]=fit.xrng[n].v;
      idlfit->x_v_e[n]=fit.xrng[n].v_err;
      idlfit->x_w_l[n]=fit.xrng[n].w_l;
      idlfit->x_w_l_e[n]=fit.xrng[n].w_l_err;
      idlfit->x_w_s[n]=fit.xrng[n].w_s;
      idlfit->x_w_s_e[n]=fit.xrng[n].w_s_err;
      idlfit->x_sd_l[n]=fit.xrng[n].sdev_l;
      idlfit->x_sd_s[n]=fit.xrng[n].sdev_s;
      idlfit->x_sd_phi[n]=fit.xrng[n].sdev_phi;
      idlfit->phi0[n]=fit.xrng[n].phi0;
      idlfit->phi0_e[n]=fit.xrng[n].phi0_err;
    }
  }
  return s;

}
Пример #11
0
int32 OldRawIDLRead(int argc,char *argv[]) {

  int n;
  int x;

  struct OldRawIDLFp *idlrawfp;
  struct OldRawFp rawfp;
  char combftmp[COMBF_SIZE+1];
  struct RadarIDLParm *idlprm;
  struct RawIDLData *idlraw;
  struct RadarParm prm;
  struct RawData raw;

  IDL_FILE_STAT stat;
  FILE *fp;
  int s;

  /* zero out the data structures */

  memset(&prm,0,sizeof(struct RadarParm));
  memset(&raw,0,sizeof(struct RawData));
  memset(&combftmp,0,COMBF_SIZE+1);
  
  idlrawfp=(struct OldRawIDLFp *) argv[0];
  
  IDL_FileStat(idlrawfp->rawunit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr; 
  
  if (fp==NULL) return -1;

  fflush(fp);
   
  rawfp.rawfp=fileno(fp);
  rawfp.inxfp=0;
 
  OldRawIDLToRawFp(idlrawfp,&rawfp);

  s=OldRawRead(&rawfp,&prm,&raw);

  OldRawRawFpToIDL(&rawfp,idlrawfp);

  if (s==-1) return -1;
   
  /* get the structure pointers */

  idlprm=(struct RadarIDLParm *) argv[1];
  idlraw=(struct RawIDLData *) argv[2];

  /* load up the structures.
   *
   * Note: We do not do a direct memcpy as the possibility
   * exists that the IDL data structure is different from 
   * the C data structure.
   *
   */

  idlprm->revision.major=prm.revision.major;
  idlprm->revision.minor=prm.revision.minor;
  idlprm->origin.code=prm.origin.code;
  IDL_StrDelete(&idlprm->origin.time,1);
  IDL_StrDelete(&idlprm->origin.command,1);
  idlprm->cp=prm.cp;
  idlprm->stid=prm.stid;
  idlprm->time.yr=prm.time.yr;
  idlprm->time.mo=prm.time.mo;
  idlprm->time.dy=prm.time.dy;
  idlprm->time.hr=prm.time.hr;
  idlprm->time.mt=prm.time.mt;
  idlprm->time.sc=prm.time.sc;
  idlprm->time.us=prm.time.us;
  idlprm->txpow=prm.txpow;
  idlprm->nave=prm.nave;
  idlprm->atten=prm.atten;
  idlprm->lagfr=prm.lagfr;
  idlprm->smsep=prm.smsep;
  idlprm->ercod=prm.ercod;
  idlprm->stat.agc=prm.stat.agc;
  idlprm->stat.lopwr=prm.stat.lopwr;
  idlprm->noise.search=prm.noise.search;
  idlprm->noise.mean=prm.noise.mean;
  idlprm->channel=prm.channel;
  idlprm->bmnum=prm.bmnum;
  idlprm->bmazm=prm.bmazm;
  idlprm->scan=prm.scan;
  idlprm->rxrise=prm.rxrise;
  idlprm->intt.sc=prm.intt.sc;
  idlprm->intt.us=prm.intt.us;
  idlprm->txpl=prm.txpl;
  idlprm->mpinc=prm.mpinc;
  idlprm->mppul=prm.mppul;
  idlprm->mplgs=prm.mplgs;
  idlprm->nrang=prm.nrang;
  idlprm->frang=prm.frang;
  idlprm->rsep=prm.rsep;
  idlprm->xcf=prm.xcf;
  idlprm->tfreq=prm.tfreq;
  idlprm->offset=prm.offset;
  idlprm->mxpwr=prm.mxpwr;
  idlprm->lvmax=prm.lvmax;

  for (n=0;n<prm.mppul;n++) idlprm->pulse[n]=prm.pulse[n];
  for (n=0;n<prm.mplgs;n++) {
    idlprm->lag[n]=prm.lag[n][0];
    idlprm->lag[LAG_SIZE+n]=prm.lag[n][1];
  }

  strncpy(combftmp,prm.combf,COMBF_SIZE);

  IDL_StrDelete(&idlprm->combf,1);
  IDL_StrStore(&idlprm->combf,combftmp);
  
  idlraw->revision.major=raw.revision.major;
  idlraw->revision.minor=raw.revision.minor;
  idlraw->thr=raw.thr;

  for (n=0;n<prm.nrang;n++) {
    idlraw->pwr0[n]=raw.pwr0[n];
    for (x=0;x<prm.mplgs;x++) {
      idlraw->acfd[x*MAX_RANGE+n]=raw.acfd[n][x][0];
      idlraw->acfd[LAG_SIZE*MAX_RANGE+MAX_RANGE*x+n]=raw.acfd[n][x][1];
      if (prm.xcf !=0) {
        idlraw->xcfd[x*MAX_RANGE+n]=raw.xcfd[n][x][0];
        idlraw->xcfd[LAG_SIZE*MAX_RANGE+MAX_RANGE*x+n]=raw.xcfd[n][x][1];
      }
    }
  } 
  return s;
}
Пример #12
0
// MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
static IDL_VPTR IDL_mg_mysql_fetch_field(int argc, IDL_VPTR *argv) {
    static IDL_MEMINT nfields = 1;
    MYSQL_FIELD *field = mysql_fetch_field((MYSQL_RES *)argv[0]->value.ptrint);
    typedef struct field {
        IDL_STRING name;
        IDL_STRING org_name;
        IDL_STRING table;
        IDL_STRING org_table;
        IDL_STRING db;
        IDL_STRING catalog;
        IDL_STRING def;
        IDL_ULONG64 length;
        IDL_ULONG64 max_length;
        IDL_ULONG name_length;
        IDL_ULONG org_name_length;
        IDL_ULONG table_length;
        IDL_ULONG org_table_length;
        IDL_ULONG db_length;
        IDL_ULONG catalog_length;
        IDL_ULONG def_length;
        IDL_ULONG flags;
        IDL_ULONG decimals;
        IDL_ULONG charsetnr;
        IDL_ULONG type;
#if MYSQL_VERSION_ID >= 50100
        IDL_PTRINT extension;
#endif
    } MG_Field;
    MG_Field *mg_field_data = (MG_Field *) calloc(nfields, sizeof(MG_Field));
    void *idl_field_data;

    IDL_StrStore(&mg_field_data->name, field->name);
    IDL_StrStore(&mg_field_data->org_name, field->org_name);
    IDL_StrStore(&mg_field_data->table, field->table);
    IDL_StrStore(&mg_field_data->org_table, field->org_table);
    IDL_StrStore(&mg_field_data->db, field->db);
    IDL_StrStore(&mg_field_data->catalog, field->catalog);
    IDL_StrStore(&mg_field_data->def, field->def);

    mg_field_data->length = field->length;
    mg_field_data->max_length = field->max_length;

    mg_field_data->name_length = field->name_length;
    mg_field_data->org_name_length = field->org_name_length;
    mg_field_data->table_length = field->table_length;
    mg_field_data->org_table_length = field->org_table_length;
    mg_field_data->db_length = field->db_length;
    mg_field_data->catalog_length = field->catalog_length;
    mg_field_data->def_length = field->def_length;
    mg_field_data->flags = field->flags;
    mg_field_data->decimals = field->decimals;
    mg_field_data->charsetnr = field->charsetnr;
    mg_field_data->type = field->type;

#if MYSQL_VERSION_ID >= 50100
    mg_field_data->extension = (IDL_PTRINT)field->extension;
#endif

    idl_field_data = IDL_MakeStruct(0, mg_mysql_field);
    IDL_VPTR result = IDL_ImportArray(1,
                                      &nfields,
                                      IDL_TYP_STRUCT,
                                      (UCHAR *) mg_field_data,
                                      0,
                                      idl_field_data);
    return result;
}
Пример #13
0
void pgsql_store_binary(int32 idlType, 
        int16 isarray, 
        char *input, 
        UCHAR *output)
{

    switch(idlType)
    {
        case IDL_TYP_FLOAT: 
            /* atof actually returns double */
            if (isarray)
                fillNumArray(input, output, 4);
            else
                NTOH32(input, output);
            break;

        case IDL_TYP_DOUBLE:
            if (isarray)
                fillNumArray(input, output, 8);
            else
                NTOH64(input, output);
            break;

        case IDL_TYP_BYTE:
            if (isarray)
                fillNumArray(input, output, 1);
            else
                *(UCHAR *) output = *(UCHAR *) input;
            break;

        case IDL_TYP_INT:
            if (isarray)
                fillNumArray(input, output, 2);
            else
                NTOH16(input, output);
            break;
        case IDL_TYP_UINT:
            if (isarray)
                fillNumArray(input, output, 2);
            else
                NTOH16(input, output);
            break;

        case IDL_TYP_LONG:
            if (isarray)
                fillNumArray(input, output, 4);
            else
                NTOH32(input, output);
            break;
        case IDL_TYP_ULONG:
            if (isarray)
                fillNumArray(input, output, 4);
            else
                NTOH32(input, output);
            break;

        case IDL_TYP_LONG64:
            if (isarray)
                fillNumArray(input, output, 8);
            else
                NTOH64(input, output);
            break;
        case IDL_TYP_ULONG64:
            if (isarray)
                fillNumArray(input, output, 8);
            else
                NTOH64(input, output);
            break;


        case IDL_TYP_STRING:
            if (isarray)
                fillStringArray(input, (IDL_STRING *) output);
            else
                IDL_StrStore( (IDL_STRING *) output, input);
            break;


        default: 
            printf("Unsupported type %d found\n", idlType);
            fflush(stdout);
            break;
    }

}
Пример #14
0
int32 OldCnvMapIDLDecode(int argc,char *argv[]) {
  int n;
  int yr,mo,dy,hr,mt;
  double sc;
  unsigned char *ptr;
  struct CnvMapIDLPrm *prm;
  struct GridIDLStVec *stvec;
  struct GridIDLGVec *gvec;
  struct CnvMapData *map;
  struct GridData *grd;
  struct GridIDLGVec *mvec;
  double *coef;
  struct CnvMapIDLBnd *bnd;
  char tmp[257];
  
  memset(tmp,0,257);

  ptr=((IDL_STRING *) argv[0])->s;
  grd=(struct GridData *) (ptr);
  ptr+=sizeof(struct GridData);
  grd->sdata=(struct GridSVec *) (ptr);
  ptr+=grd->stnum*sizeof(struct GridSVec);
  grd->data=(struct GridGVec *) (ptr);
  ptr+=grd->vcnum*sizeof(struct GridGVec);
  map=(struct CnvMapData *) (ptr);
  ptr+=sizeof(struct CnvMapData);
  map->model=(struct GridGVec *) (ptr);
  ptr+=map->num_model*sizeof(struct GridGVec);
  map->coef=(double *) (ptr);
  ptr+=map->num_coef*4*sizeof(double);
  map->bnd_lat=(double *) (ptr);
  ptr+=map->num_bnd*sizeof(double);
  map->bnd_lon=(double *) (ptr);

  prm=(struct CnvMapIDLPrm *) argv[1];
  stvec=(struct GridIDLStVec *) argv[2];
  gvec=(struct GridIDLGVec *) argv[3];
  mvec=(struct GridIDLGVec *) argv[4];
  coef=(double *) argv[5];
  bnd=(struct CnvMapIDLBnd *) argv[6];


  prm->stnum=grd->stnum;
  prm->vcnum=grd->vcnum;
  prm->xtd=grd->xtd;
  TimeEpochToYMDHMS(grd->st_time,&yr,&mo,
                    &dy,&hr,&mt,
                    &sc);
  prm->start.yr=yr;
  prm->start.mo=mo;
  prm->start.dy=dy;
  prm->start.hr=hr;
  prm->start.mt=mt;
  prm->start.sc=sc;

  TimeEpochToYMDHMS(grd->ed_time,&yr,&mo,
                    &dy,&hr,&mt,
                    &sc);

  prm->end.yr=yr;
  prm->end.mo=mo;
  prm->end.dy=dy;
  prm->end.hr=hr;
  prm->end.mt=mt;
  prm->end.sc=sc;


  prm->major_rev=map->major_rev;
  prm->minor_rev=map->minor_rev;

  IDL_StrDelete(&prm->source,1);
  if (map->source !=NULL) {
    strncpy(tmp,map->source,256);
    IDL_StrStore(&prm->source,tmp);
  }

  prm->modnum=map->num_model;
  prm->doping_level=map->doping_level;
  prm->model_wt=map->model_wt;
  prm->error_wt=map->error_wt;
  prm->imf_flag=map->imf_flag;
  prm->imf_delay=map->imf_delay;
  prm->Bx=map->Bx;
  prm->By=map->By;
  prm->Bz=map->Bz;
  
  IDL_StrDelete(&prm->model[0],1);
  if (map->imf_model[0] !=NULL) {
     strncpy(tmp,map->imf_model[0],64);
     IDL_StrStore(&prm->model[0],tmp);
  }
  IDL_StrDelete(&prm->model[1],1);
  if (map->imf_model[1] !=NULL) {
    strncpy(tmp,map->imf_model[1],64);
    IDL_StrStore(&prm->model[1],tmp);
 }

  prm->hemisphere=map->hemisphere;
  prm->fit_order=map->fit_order;
  prm->latmin=map->latmin;
  prm->coefnum=map->num_coef;
  prm->chi_sqr=map->chi_sqr;
  prm->chi_sqr_dat=map->chi_sqr_dat;
  prm->rms_err=map->rms_err;
  prm->lon_shft=map->lon_shft;
  prm->lat_shft=map->lat_shft;
  prm->mlt.st=map->mlt.start;
  prm->mlt.ed=map->mlt.end;
  prm->mlt.av=map->mlt.av;
  prm->pot_drop=map->pot_drop;
  prm->pot_drop_err=map->pot_drop_err;
  prm->pot_max=map->pot_max;
  prm->pot_max_err=map->pot_max_err;
  prm->pot_min=map->pot_min;
  prm->pot_min_err=map->pot_min_err;
  prm->bndnum=map->num_bnd;

  for (n=0;n<grd->stnum;n++) {
    stvec[n].stid=grd->sdata[n].st_id;
    stvec[n].chn=grd->sdata[n].chn;
    stvec[n].npnt=grd->sdata[n].npnt;
    stvec[n].freq=grd->sdata[n].freq0;
    stvec[n].major_revision=grd->sdata[n].major_revision;
    stvec[n].minor_revision=grd->sdata[n].minor_revision;
    stvec[n].prog_id=grd->sdata[n].prog_id;
    stvec[n].gsct=grd->sdata[n].gsct;
    stvec[n].noise.mean=grd->sdata[n].noise.mean;
    stvec[n].noise.sd=grd->sdata[n].noise.sd;
    stvec[n].vel.min=grd->sdata[n].vel.min;
    stvec[n].vel.max=grd->sdata[n].vel.max;
    stvec[n].pwr.min=grd->sdata[n].pwr.min;
    stvec[n].pwr.max=grd->sdata[n].pwr.max;
    stvec[n].wdt.min=grd->sdata[n].wdt.min;
    stvec[n].wdt.max=grd->sdata[n].wdt.max;
    stvec[n].verr.min=grd->sdata[n].verr.min;
    stvec[n].verr.max=grd->sdata[n].verr.max;
  }

  for (n=0;n<grd->vcnum;n++) {
     gvec[n].stid=grd->data[n].st_id;
     gvec[n].chn=grd->data[n].chn;
     gvec[n].index=grd->data[n].index;
     gvec[n].mlat=grd->data[n].mlat;
     gvec[n].mlon=grd->data[n].mlon;
     gvec[n].azm=grd->data[n].azm;
     gvec[n].vel.median=grd->data[n].vel.median;
     gvec[n].vel.sd=grd->data[n].vel.sd;
     if (grd->xtd !=0) {
       gvec[n].pwr.median=grd->data[n].pwr.median;
       gvec[n].pwr.sd=grd->data[n].pwr.sd;
       gvec[n].wdt.median=grd->data[n].wdt.median;
       gvec[n].wdt.sd=grd->data[n].wdt.sd;
     }
  }

  for (n=0;n<map->num_model;n++) {
    mvec[n].mlat=map->model[n].mlat;
    mvec[n].mlon=map->model[n].mlon;
    mvec[n].azm=map->model[n].azm;
    mvec[n].vel.median=map->model[n].vel.median;
  } 

  for (n=0;n<map->num_coef;n++) {
     coef[n]=map->coef[4*n];
     coef[map->num_coef+n]=map->coef[4*n+1];
     coef[2*map->num_coef+n]=map->coef[4*n+2];
     coef[3*map->num_coef+n]=map->coef[4*n+3];
  }
 

  for (n=0;n<map->num_bnd;n++) {
    bnd[n].lat=map->bnd_lat[n];
    bnd[n].lon=map->bnd_lon[n];
 
  } 


  return 0;

}