示例#1
0
文件: main.cpp 项目: ohio813/bwh14
VOID TestFile(HWND hwndDlg)
{
    char szFile[MAX_PATH];
    HANDLE hFile;   
    
	if(g_hScanProc)
    {
        TerminateThread(g_hScanProc, 0);
        g_hScanProc = NULL;
    }

	ClearStatus(hwndDlg);

	SendDlgItemMessage(hwndDlg, IDC_FILENAME, WM_GETTEXT, MAX_PATH, (LPARAM)szFile);
    hFile = CreateFile(szFile, GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hFile);
        EnableWindow(GetDlgItem(hwndDlg, IDC_SCAN), TRUE);
    }
    else
    {
        EnableWindow(GetDlgItem(hwndDlg, IDC_SCAN), FALSE);
    }
    EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), FALSE);
}
示例#2
0
void Camera_INDIClass::serverDisconnected(int exit_code)
{
    // in case the connection lost we must reset the client socket
    Disconnect();
    // after disconnection we reset the connection status and the properties pointers
    ClearStatus();
}
示例#3
0
void
ClientsTabActive()
{  
  int maxcmdlen = 15000;
  Bool all_screens, more;

  
  XtManageChild( clients_frame );
  if( info_dpy == NULL ) return;

  XmTextClear( clients_out );

  SetWidgetCursor( tab_form, XC_watch );
  SetStatus( "Retrieving client info..." );

  all_screens = pref_db.cliPrefs[0].value;
  more = pref_db.cliPrefs[1].value;

  xlsclients( info_dpy, all_screens, more, maxcmdlen );
  
  if( XmTextGetLastPosition(clients_out) == 0 )
       SetStatus( "No clients found" );
  else {
       ClearStatus();
       XtVaSetValues( clients_out, XmNcursorPosition, 0, NULL );
  }
    
  UnsetWidgetCursor( tab_form );

}
EngineProperties
EngineMethods::GetEngineProperties()
{
    state->enginePropertiesRPC();

    // Get the reply and update the progress bar
    while (state->enginePropertiesRPC.GetStatus() == VisItRPC::incomplete ||
           state->enginePropertiesRPC.GetStatus() == VisItRPC::warning)
    {
        state->enginePropertiesRPC.RecvReply();
    }

    // Check for abort
    if (state->enginePropertiesRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }

    // Check for an error
    if (state->enginePropertiesRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->enginePropertiesRPC.GetExceptionType(),
                               state->enginePropertiesRPC.Message());
    }

    EngineProperties props(state->enginePropertiesRPC.GetReturnAtts());
    if(numNodes > props.GetNumNodes())
        props.SetNumNodes(numNodes);

    return props;
}
void
EngineMethods::GetProcInfo(ProcessAttributes &retAtts)
{
    state->procInfoRPC();

    // Get the reply and update the progress bar
    while (state->procInfoRPC.GetStatus() == VisItRPC::incomplete ||
           state->procInfoRPC.GetStatus() == VisItRPC::warning)
    {
        state->procInfoRPC.RecvReply();
    }

    // Check for abort
    if (state->procInfoRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }

    // Check for an error
    if (state->procInfoRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->procInfoRPC.GetExceptionType(),
                               state->procInfoRPC.Message());
    }

    retAtts = state->procInfoRPC.GetReturnAtts();

}
示例#6
0
void PutPropInfo( Window window ) 
{
  Bool show_type, ignore_frames;

  if( ! XtIsManaged(prop_frame) )   return;  

  SetWidgetCursor( tab_form, XC_watch );
  XmTextClear( prop_out );  

  SetStatus( "Retrieving window properties..." );

  show_type = pref_db.propPrefs[0].value;
  ignore_frames = pref_db.propPrefs[1].value;

  xprop( window, show_type, ignore_frames );

  if( XmTextGetLastPosition(prop_out) == 0 )
       XmTextPrintf( prop_out, "No properties defined for window ( 0x%x )",
		     (unsigned int)window );
       /* SetStatus( "No properties defined for window" ); */
  else XtVaSetValues( prop_out, XmNcursorPosition, 0,  NULL );

  ClearStatus();	 
  UnsetWidgetCursor( tab_form );

}
/*
 *
 * ClearStatus ()
 *
 * Recursively applies DETATCHSTATUSPTR() to status structure to destroy
 * linked list of statuses.
 *
 */
static void
ClearStatus (LALStatus *status)
{
  if (status->statusPtr)
  {
    ClearStatus      (status->statusPtr);
    DETATCHSTATUSPTR (status);
  }
}
示例#8
0
ScopeINDI::ScopeINDI() 
{
    ClearStatus();
    // load the values from the current profile
    INDIhost = pConfig->Profile.GetString("/indi/INDIhost", _T("localhost"));
    INDIport = pConfig->Profile.GetLong("/indi/INDIport", 7624);
    INDIMountName = pConfig->Profile.GetString("/indi/INDImount", _T("INDI Mount"));
    INDIMountPort = pConfig->Profile.GetString("/indi/INDImount_port",_T(""));
    m_Name = INDIMountName;
}
void
EngineMethods::Query(const std::vector<int> &nid, const QueryAttributes *atts,
                   QueryAttributes &retAtts)
{
    state->queryRPC(nid, atts);

    // Get the reply and update the progress bar
    while (state->queryRPC.GetStatus() == VisItRPC::incomplete ||
           state->queryRPC.GetStatus() == VisItRPC::warning)
    {
        state->queryRPC.RecvReply();

        // Send a warning message if the status is a warning.
        if(state->queryRPC.GetStatus() == VisItRPC::incomplete)
        {
            // Send a status message.
            Status(state->queryRPC.GetPercent(), state->queryRPC.GetCurStageNum(),
                   state->queryRPC.GetCurStageName(), state->queryRPC.GetMaxStageNum());
        }
        else if(state->queryRPC.GetStatus() == VisItRPC::warning)
        {
            debug4 << "Warning: " << state->queryRPC.Message().c_str() << endl;
            Warning(state->queryRPC.Message().c_str());
        }
    }

    // Check for abort
    if (state->queryRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }

    // Check for an error
    if (state->queryRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->queryRPC.GetExceptionType(),
                               state->queryRPC.Message());
    }
    retAtts = state->queryRPC.GetReturnAtts();
    ClearStatus();
}
示例#10
0
void ScopeINDI::serverDisconnected(int exit_code)
{
    // in case the connection lost we must reset the client socket
   Disconnect();
   if (ready) {
       ready = false;
       Scope::Disconnect();
    }
    // after disconnection we reset the connection status and the properties pointers
    ClearStatus();
}
示例#11
0
Camera_INDIClass::Camera_INDIClass() 
{
    ClearStatus();
    // load the values from the current profile
    INDIhost = pConfig->Profile.GetString("/indi/INDIhost", _T("localhost"));
    INDIport = pConfig->Profile.GetLong("/indi/INDIport", 7624);
    INDICameraName = pConfig->Profile.GetString("/indi/INDIcam", _T("INDI Camera"));
    INDICameraCCD = pConfig->Profile.GetLong("/indi/INDIcam_ccd", 0);
    INDICameraPort = pConfig->Profile.GetString("/indi/INDIcam_port",_T(""));
    Name = INDICameraName;
    SetCCDdevice();
    PropertyDialogType = PROPDLG_ANY;
    FullSize = wxSize(640,480);
    HasSubframes = true;
}
示例#12
0
文件: main.cpp 项目: ohio813/bwh14
DWORD WINAPI ScanProc(HWND hwndDlg)
{   
    char szFile[MAX_PATH];
    HANDLE hFile, hMap;
    HWND hwndList = GetDlgItem(hwndDlg, IDC_POINTERS);
	PBYTE pbFile;

	EnableWindow(GetDlgItem(hwndDlg, IDC_SCAN), FALSE);
	EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), FALSE);
	ClearStatus(hwndDlg);

    SendDlgItemMessage(hwndDlg, IDC_FILENAME, WM_GETTEXT, MAX_PATH, (LPARAM)szFile);
    hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
        if(hMap)
		{
            pbFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
			if(pbFile)
			{
				for(INT x = 0; x < ListView_GetItemCount(hwndList); x++)
				{
					ListView_EnsureVisible(hwndList, x, FALSE);
					ListView_SetItemState(hwndList, x, LVIS_SELECTED, LVIS_SELECTED);
					GetPPD(x, hwndDlg)->pfnScanProc(x, hwndDlg, pbFile);
				}
				
				HandlePointerErrors(hwndDlg);

				UnmapViewOfFile(pbFile);
			}
			else
				MessageBox(hwndDlg, "Could not gain read access to the file!", "BWH Setup", MB_ICONERROR);
			CloseHandle(hMap);
		}
		else
			MessageBox(hwndDlg, "Could not gain read access to the file!", "BWH Setup", MB_ICONERROR);
		CloseHandle(hFile);
    }
	else
		MessageBox(hwndDlg, "Could not gain read access to the file!", "BWH Setup", MB_ICONERROR);

    EnableWindow(GetDlgItem(hwndDlg, IDC_SCAN), TRUE);
    CloseHandle(g_hScanProc);
    g_hScanProc = NULL;
    return 0;
}
void FOOTPRINT_PREVIEW_WIDGET::OnStatusChange( FOOTPRINT_STATUS aStatus )
{
    switch( aStatus )
    {
    case FPS_NOT_FOUND:
        SetStatusText( _( "Footprint not found" ) );
        break;

    case FPS_LOADING:
        SetStatusText( _( "Loading..." ) );
        break;

    case FPS_READY:
        ClearStatus();
    }

    Refresh();
}
示例#14
0
void AccessTabActive()
{
    int 	nhosts, i;
    Bool 	access_enabled;
    XHostAddress	*xhosts;
    struct hostent *hp;
    struct in_addr in;

    XtManageChild( access_frame );
    if( info_dpy == NULL ) return;

    XmTextClear( access_out );
    SetStatus( "Retrieving host access list..." );
    SetWidgetCursor( tab_form, XC_watch );

    /* get the access control list */
    xhosts = XListHosts( info_dpy, &nhosts, &access_enabled );
    if( access_enabled == TRUE && nhosts > 0 ) {
        for( i=0; i<nhosts; i++ ) {
            /* need to output the net number if the hostname is not found */
            hp = gethostbyaddr( xhosts[i].address, xhosts[i].length, AF_INET );
            if( !hp->h_name )
                memcpy( &in.s_addr, hp->h_addr_list[0], sizeof(in.s_addr) );

            XmTextPrintf( access_out, "%s      %s\n",
                          hp->h_name ? hp->h_name : inet_ntoa(in),
                          Lookup(xhosts[i].family, _family_types) );
        }
    }
    else if( access_enabled == TRUE && nhosts == 0 )
        XmTextAppend( access_out, "\n-- No hosts in access list! --\n" );
    else /* access_enabled == FALSE <all host can connect to display> */
        XmTextSetString( access_out,
                         "Access control disabled, all hosts welcome.\n" );

    UnsetWidgetCursor( tab_form );
    ClearStatus();

    XFree(xhosts);
}
void
EngineMethods::BlockForNamedSelectionOperation()
{
    // Get the reply and update the progress bar
    while (state->namedSelectionRPC.GetStatus() == VisItRPC::incomplete ||
           state->namedSelectionRPC.GetStatus() == VisItRPC::warning)
    {
        state->namedSelectionRPC.RecvReply();

        // Send a warning message if the status is a warning.
        if(state->namedSelectionRPC.GetStatus() == VisItRPC::incomplete)
        {
            // Send a status message.
            Status(state->namedSelectionRPC.GetPercent(), state->namedSelectionRPC.GetCurStageNum(),
                   state->namedSelectionRPC.GetCurStageName(), state->namedSelectionRPC.GetMaxStageNum());
        }
        else if(state->namedSelectionRPC.GetStatus() == VisItRPC::warning)
        {
            debug4 << "Warning: " << state->namedSelectionRPC.Message().c_str() << endl;
            Warning(state->namedSelectionRPC.Message().c_str());
        }
    }

    ClearStatus();

    // Check for abort
    if (state->namedSelectionRPC.GetStatus() == VisItRPC::abort)
    {
        EXCEPTION0(AbortException);
    }

    if (state->namedSelectionRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->namedSelectionRPC.GetExceptionType(),
                               state->namedSelectionRPC.Message());
    }
}
示例#16
0
int AssembleString(char* str, const char* initialFilename)
{
	curFile = initialFilename;
	curLine = 1;

	ClearStatus();

	int nextLineIncr = 0;
	char* nextStr = NULL;
	for (; str; str = nextStr, curLine += nextLineIncr)
	{
		size_t len = strcspn(str, "\n");
		int linedelim = str[len];
		str[len] = 0;
		nextStr = linedelim ? (str + len + 1) : NULL;
		nextLineIncr = linedelim == '\n' ? 1 : 0;

		char* line = trim_whitespace(remove_comment(str));

		char* colonPos = NULL;
		for (;;)
		{
			colonPos = strchr(line, ':');
			if (!colonPos)
				break;
			*colonPos = 0;
			char* labelName = line;
			line = trim_whitespace(colonPos + 1);

			if (!validateIdentifier(labelName))
				return throwError("invalid label name: %s\n", labelName);

			std::pair<labelTableIter,bool> ret = g_labels.insert( std::pair<std::string,size_t>(labelName, BUF.size()) );
			if (!ret.second)
				return throwError("duplicate label: %s\n", labelName);

			//printf("Label: %s\n", labelName);
		};

		if (!*line)
			continue;

		if (*line == '#')
		{
			line = trim_whitespace(line + 1);
			nextLineIncr = 0;
			size_t pos = strcspn(line, " \t");
			line[pos] = 0;
			curLine = atoi(line);
			line = trim_whitespace(line + pos + 1);
			if (*line == '"')
			{
				line ++;
				line[strlen(line)-1] = 0;
			}
			curFile = line;
			continue;
		}

		char* tok = mystrtok_spc(line);
		safe_call(ProcessCommand(tok));
	}

	if (g_stackPos)
		return throwError("unclosed block(s)\n");

	safe_call(FixupLabelRelocations());
	
	return 0;
}
avtDataObjectReader_p
EngineMethods::Execute(bool respondWithNull, void (*waitCB)(void *), void *cbData)
{
    // Send a status message indicating that we're starting to execute
    // the pipeline.
    Status("Executing pipeline.");

    // Do it!
    state->executeRPC(respondWithNull);

    // Get the reply and update the progress bar
    while (state->executeRPC.GetStatus() == VisItRPC::incomplete ||
           state->executeRPC.GetStatus() == VisItRPC::warning)
    {
        state->executeRPC.RecvReply();

        // Send a warning message if the status is a warning.
        if(state->executeRPC.GetStatus() == VisItRPC::incomplete)
        {
            // Send a status message.
            Status(state->executeRPC.GetPercent(), state->executeRPC.GetCurStageNum(),
                   state->executeRPC.GetCurStageName(), state->executeRPC.GetMaxStageNum());
        }
        else if(state->executeRPC.GetStatus() == VisItRPC::warning)
        {
            debug4 << "Warning: " << state->executeRPC.Message().c_str() << endl;
            Warning(state->executeRPC.Message().c_str());
        }

        // If we passed a callback function, execute it.
        if(waitCB)
            waitCB(cbData);
    }

    // Check for abort
    if (state->executeRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }
    // Check for an error
    if (state->executeRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->executeRPC.GetExceptionType(),
                               state->executeRPC.Message());
    }

    // Send a status message that indicates the output of the engine is
    // being transferred across the network.
    Status("Reading engine output.");

    int readDelay = visitTimer->StartTimer();
    // Read the VTK data
    long size = state->executeRPC.GetReplyLen();
    char *buf = new char[size];

    if(engineP != NULL)
        engineP->GetReadConnection(1)->NeedsRead(true);
    else if(component != NULL)
        component->GetWriteConnection(1)->NeedsRead(true);
    visitTimer->StopTimer(readDelay, "Delay between read notification and actual read");

    int readData = visitTimer->StartTimer();
    if(engineP != NULL)
    {
        if (engineP->GetReadConnection(1)->DirectRead((unsigned char *)buf, size) < 0) 
        {
            debug1 << "Error reading VTK data!!!!\n";
        }
    }
    else if(component != NULL)
    {
        if (component->GetWriteConnection(1)->DirectRead((unsigned char *)buf, size) < 0) 
        {
            debug1 << "Error reading VTK data!!!!\n";
        }
    }

    char msg[128];
    SNPRINTF(msg, 128, "Reading %ld bytes from socket", size);
    visitTimer->StopTimer(readData, msg);
    visitTimer->DumpTimings();

    // The data object reader will clean up the memory with buf.
    avtDataObjectReader_p avtreader  = new avtDataObjectReader;
    avtreader->Read(size, buf);

    // Output a message that indicates we're done reading the engine's output.
    ClearStatus();

    // Whoever called Execute will own the reader when this is returned since
    // the reference count will be decremented when avtreader goes out of
    // scope.
    return avtreader;
}
示例#18
0
void Terminal::SetStatus(std::string status, unsigned short line) {
	ClearStatus(line);
	AppendStatus(status,line);
}
avtDataObjectReader_p
EngineMethods::Render(bool sendZBuffer, const intVector& networkIDs,
    int annotMode, int windowID, bool leftEye,
    void (*waitCB)(void *), void *cbData)
{

    // Send a status message indicating that we're starting a scalable render
    Status("Scalable Rendering.");

    // Do it!
    state->renderRPC(networkIDs, sendZBuffer, annotMode, windowID, leftEye);

    // Get the reply and update the progress bar
    while (state->renderRPC.GetStatus() == VisItRPC::incomplete ||
           state->renderRPC.GetStatus() == VisItRPC::warning)
    {
        state->renderRPC.RecvReply();

        // Send a warning message if the status is a warning.
        if(state->renderRPC.GetStatus() == VisItRPC::incomplete)
        {
            // Send a status message.
            Status(state->renderRPC.GetPercent(), state->renderRPC.GetCurStageNum(),
                   state->renderRPC.GetCurStageName(), state->renderRPC.GetMaxStageNum());
        }
        else if(state->renderRPC.GetStatus() == VisItRPC::warning)
        {
            debug4 << "Warning: " << state->renderRPC.Message().c_str() << endl;
            Warning(state->renderRPC.Message().c_str());
        }
    }

    // Check for abort
    if (state->renderRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }
    // Check for an error
    if (state->renderRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->renderRPC.GetExceptionType(),
                               state->renderRPC.Message());
    }

    // Send a status message that indicates the output of the engine is
    // being transferred across the network.
    if (sendZBuffer)
       Status("Reading engine output [with zbuffer]");
    else
       Status("Reading engine output.");

    // Read the VTK data
    long size = state->renderRPC.GetReplyLen();
    char *buf = new char[size];

    if(engineP != NULL)
    {
        if (engineP->GetReadConnection(1)->DirectRead((unsigned char *)buf, size) < 0) 
        {
            debug1 << "Error reading VTK data!!!!\n";
        }
    }
    else if(component != NULL)
    {
        if (component->GetWriteConnection(1)->DirectRead((unsigned char *)buf, size) < 0) 
        {
            debug1 << "Error reading VTK data!!!!\n";
        }
    }

    // The data object reader will clean up the memory with buf.
    avtDataObjectReader_p avtreader  = new avtDataObjectReader;
    avtreader->Read(size, buf);

    // Output a message that indicates we're done reading the engine's output.
    ClearStatus();

    // Whoever called Execute will own the reader when this is returned since
    // the reference count will be decremented when avtreader goes out of
    // scope.
    return avtreader;
}
int
main (int argc, char *argv[])
{
  static LALStatus              status;


  INT4                          i,j,k,l;

  UINT4                         numDetectors=0;
  FILE                         *fpcohSNR;
  REAL4                         theta,phi,vPlus,vMinus;
  REAL4                         x,y;

  UINT2Vector                  *detIDVec;
  DetectorVector               *detectorVec;

  CoherentInspiralInitParams   *cohInspInitParams = NULL;
  CoherentInspiralFilterParams *cohInspFilterParams = NULL;
  CoherentInspiralFilterInput  *cohInspFilterInput = NULL;
  CoherentInspiralBeamVector   *cohInspBeamVec = NULL;
  CoherentInspiralZVector      *cohInspZVec = NULL;
  InspiralTemplate             *tmplt = NULL;
  CoherentInspiralEvent        *cohInspEvent = NULL;

  char namearray[6][256] = {"0","0","0","0","0","0"};
  char namearray2[6][256] = {"0","0","0","0","0","0"};


  /*
   *
   * parse options, allocate memory, init params and set values
   *
   */

  ParseOptions (argc, argv);


  /* override numSegments if outputting coherent SNR */
  if ( cohSNROut )
    {
      numSegments = 1;
      numTmplts = 1;
      fpcohSNR = fopen ("cohSNR.dat", "w");
    }


  /* read in the network detectors */
  for (l=0;l<6;l++)
    {
      if(caseID[l] == 1)
	numDetectors++;
    }

  fprintf(stdout, "You have specified %2d  detector(s).\n",numDetectors);
  fprintf(stdout, "The caseID is: %d %d %d %d %d %d (H1,H2,L1,GEO,VIRGO,TAMA) \n",caseID[0],caseID[1],caseID[2],caseID[3],caseID[4],caseID[5]);

  if (numDetectors > 4)
    {
    fprintf(stdout, "Too many detectors specified - exiting. \n");
    goto cleanexit;
    }
  if (numDetectors == 0)
    {
      fprintf(stdout, "You must specify data filename(s) for 1 to 4 detectors - exiting. \n");
      goto cleanexit;
    }


  /*
   *
   * allocate memory to structures
   *
   */

  /* fill the init params structure */
  cohInspInitParams = (CoherentInspiralInitParams *)
    LALMalloc (sizeof(CoherentInspiralInitParams));

  cohInspInitParams->numDetectors            = numDetectors;
  cohInspInitParams->numSegments             = numSegments;
  cohInspInitParams->numPoints               = numPoints;
  cohInspInitParams->numBeamPoints           = numBeamPoints;
  cohInspInitParams->cohSNROut               = cohSNROut;

  /* Create input structure for coherent filter code */
  LALCoherentInspiralFilterInputInit (&status, &cohInspFilterInput,
					cohInspInitParams);
  TestStatus (&status, "0", 1);
  ClearStatus (&status);



  /*
   * information for calculating chirp time
   */

  /* inspiral template structure */
  tmplt = cohInspFilterInput->tmplt = (InspiralTemplate *)
    LALMalloc (sizeof(InspiralTemplate));
  memset( tmplt, 0, sizeof(InspiralTemplate) );

  /* generate dummy template parameters */
  {
    REAL4 m1 = mass;
    REAL4 m2 = mass;
    tmplt->mass1     = m1;
    tmplt->mass2     = m2;
    tmplt->totalMass = m1 + m2;
    tmplt->mu        = m1 * m2 / tmplt->totalMass;
    tmplt->eta       = tmplt->mu / tmplt->totalMass;
  }

  /* fill the params structure */
  LALCoherentInspiralFilterParamsInit (&status, &cohInspFilterParams,
				       cohInspInitParams);
  TestStatus (&status, "0", 1);
  ClearStatus (&status);

  cohInspFilterParams->numDetectors            = numDetectors;
  cohInspFilterParams->numSegments             = numSegments;
  cohInspFilterParams->numPoints               = numPoints;
  cohInspFilterParams->numBeamPoints           = numBeamPoints;
  cohInspFilterParams->deltaT                  = 1/((REAL4) sampleRate);
  cohInspFilterParams->cohSNROut               = cohSNROut;
  cohInspFilterParams->cohSNRThresh            = cohSNRThresh;
  cohInspFilterParams->numTmplts               = numTmplts;
  cohInspFilterParams->fLow                    = fLow;
  cohInspFilterParams->maximiseOverChirp       = maximiseOverChirp;

  detIDVec = cohInspFilterParams->detIDVec;

  /*assign detIDs to the coincident detectors in the network */
  for ( i=0 ; i < 6 ; i++) {
    detIDVec->data[i] = caseID[i];
  }

 /* create and fill the DetectorVector structure of detector IDs*/

  detectorVec = cohInspFilterParams->detectorVec;

  i=0;
  for ( j=0 ; j < 6 ; j++ ) {
    /*    if (((j != 5) && caseID[j++])) { */
    if ( caseID[j] ) {
      detectorVec->detector[i++] = lalCachedDetectors[j];
    }
  }

  if (caseID[5]) {
    detectorVec->detector[numDetectors-1] = lalCachedDetectors[0];
  }


  /* Now read in all the filenames and store them in arrays */
  /* This will keep the files in the order:
     H1(0), L1(1), VIRGO(2), GEO(3), TAMA(4), H2(5)*/

  if(caseID[0])
    {
    strcpy(namearray[0],H1filename);
    strcpy(namearray2[0],H1Beam);
    }

  if(caseID[1])
    {
    strcpy(namearray[1],L1filename);
    strcpy(namearray2[1],L1Beam);
    }

  if(caseID[2])
    {
    strcpy(namearray[2],VIRGOfilename);
    strcpy(namearray2[2],VIRGOBeam);
    }

  if(caseID[3])
    {
    strcpy(namearray[3],GEOfilename);
    strcpy(namearray2[3],GEOBeam);
    }

  if(caseID[4])
    {
    strcpy(namearray[4],TAMAfilename);
    strcpy(namearray2[4],TAMABeam);
    }

  if (caseID[5])
    {
    strcpy(namearray[5],H2filename);
    strcpy(namearray2[5],H2Beam);
    }



  /* create and fill the CoherentInspiralBeamVector structure of beam-patterns*/
  cohInspBeamVec = cohInspFilterInput->beamVec;

  l=0;
  for ( j=0 ; j < 6 ; j++ ) {
    if ( caseID[j] ) {
      /*      for (l=0;l<numDetectors;l++) { */

      fp2[l] = fopen(namearray2[j], "r");
      if(!fp2[l])
	{
	  fprintf(stdout,"The file %s containing the coefficients could not be found - exiting...\n",namearray2[j]);
	  goto  cleanexit;
	}
      for ( k=0 ; k<numBeamPoints ; k++)
	{
	  fscanf(fp2[l],"%f, %f, %f, %f",&theta,&phi,&vPlus,&vMinus);
	  cohInspBeamVec->detBeamArray[l].thetaPhiVs[k].data->data[0] = theta;
	  cohInspBeamVec->detBeamArray[l].thetaPhiVs[k].data->data[1] = phi;
	  cohInspBeamVec->detBeamArray[l].thetaPhiVs[k].data->data[2] = vPlus;
	  cohInspBeamVec->detBeamArray[l].thetaPhiVs[k].data->data[3] = vMinus;
	}
      fclose(fp2[l++]);
    }
  }


  /*
   * CREATE the multi-z data structure;
   * the z=x+iy data from multiple detectors was read above along with
   * the beam-pattern functions
   */
  cohInspZVec = cohInspFilterInput->multiZData;

  /* First, the files will be tested for length consistency
     and then the z-data for multiple detectors will be read in */
  l=0;
  for ( j=0 ; j < 6 ; j++ ) {
    if ( caseID[j] ) {
      fp[l] = fopen(namearray[j], "r");
      if(!fp[l])
	{
	  fprintf(stdout,"The file %s does not exist - exiting...\n",
		  namearray[j]);
	  goto cleanexit;
	}
      for (k = 0; k < numPoints; k++)
	{
	  fscanf(fp[l],"%f %f", &x, &y);
	  cohInspZVec->zData[l].data->data[k].re = x;
	  cohInspZVec->zData[l].data->data[k].im = y;
	}
      fclose(fp[l++]);
    }
  }

  /*Do the filtering and output events */
  cohInspEvent = NULL;

  LALCoherentInspiralFilterSegment (&status, &cohInspEvent, cohInspFilterInput, cohInspFilterParams);
  TestStatus (&status, "0", 1);

  if ( cohInspEvent )
	{
	  fprintf( stdout, "\nEvents found in segment!\n\n" );
	  while (cohInspEvent  )
	    {
	      CoherentInspiralEvent *thisEvent = cohInspEvent;

	      cohInspEvent = thisEvent->next;

	      fprintf( stdout, "event id                              = %d\n\n", thisEvent->eventId+1 );

	      fprintf( stdout, "coherent SNR                         = %.2f\n", thisEvent->cohSNR );

	      fprintf( stdout, "'network' timeIndex                   = %d\n", thisEvent->timeIndex );

	      fflush( stdout );

	      LALFree( thisEvent );
	    }

	}
      else
	{
	  fprintf( stdout, "\nNo events found in segment for mass = %.4f solar mass template!\n", mass );
	}
  /* outputting coherent SNR */
  if ( cohSNROut )
    {
      for ( i = 0; i < cohInspFilterParams->cohSNRVec->data->length; ++i )
	{
	  fprintf( fpcohSNR, "%d\t%e\n", i, cohInspFilterParams->cohSNRVec->data->data[i] );
	}
    }

 cleanexit:

  fclose( fpcohSNR);

  /* Destroy params structure for coherent filter code */
  LALCoherentInspiralFilterParamsFinalize (&status, &cohInspFilterParams);
  TestStatus (&status, "0", 1);
  ClearStatus (&status);

  /* Destroy input structure for coherent filter code */
  LALCoherentInspiralFilterInputFinalize (&status, &cohInspFilterInput);
  TestStatus (&status, "0", 1);
  ClearStatus (&status);


  LALCheckMemoryLeaks ();

  return 0;

} /* end main */
static void FUNC ( void )
{
  static UINT4   dims[3]    = { 1, 2, 4 };
  UINT4Vector    dimLength  = { 3, dims };
#ifndef LAL_NDEBUG
  static UINT4   dbad[3]    = { 1, 0, 4 };
  UINT4Vector    badLength1 = { 3, NULL };
  UINT4Vector    badLength2 = { 0, dims };
  UINT4Vector    badLength3 = { 3, dbad };
#endif
  static LALStatus  status;
  static VTYPE  *array;
  static VTYPE   astore;
  static TYPE    datum;


  /*
   *
   * Test ordinary behavior.
   *
   */


  CFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize up */
  /*
   * dimLength.data[0] *= 2;
   * dimLength.data[1] *= 3;
   * dimLength.data[2] *= 4;
  */
  dims[0] *= 2;
  dims[1] *= 3;
  dims[2] *= 4;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize down */
  dims[0] /= 2;
  dims[1] /= 3;
  dims[2] /= 2;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize down again */
  dims[2] /= 2;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  DFUNC ( &status, &array );
  TestStatus( &status, CODES( 0 ), 1 );

  LALCheckMemoryLeaks();


  /*
   *
   * Test error codes.
   *
   */


#ifndef LAL_NDEBUG

  if ( ! lalNoDebug )
  {
    CFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    RFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    CFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    RFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    CFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    RFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
    LALCheckMemoryLeaks();

    DFUNC ( &status, NULL );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    CFUNC ( &status, NULL, &dimLength );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    RFUNC ( &status, NULL, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );

    array = &astore;
    CFUNC ( &status, &array, &dimLength );
    TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );

    RFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);

    RFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);

    RFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);

    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );

    array->data = &datum;
    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
    ClearStatus( &status );
  }

#else
  array = &astore;
  array->data = &datum;
#endif

  LALCheckMemoryLeaks();
  printf( "PASS: tests of %s, %s, and %s\n", STRING(CFUNC), STRING(RFUNC), STRING(DFUNC));

  return;
}
示例#22
0
int
main (int argc, char *argv[])
{
  static LALStatus  status;
  SFindRootIn    sinput;
  DFindRootIn    dinput;
  REAL4          y_0;
  REAL4          sroot;
  REAL8          yy0;
  REAL8          droot;


  /*
   *
   * Parse the command line options
   *
   */


  ParseOptions (argc, argv);


  /*
   *
   * Set up input structure and function parameter y_0.
   *
   */


  y_0             = -1;
  sinput.function = F;
  sinput.xmin     = 1e-3;
  sinput.xmax     = 2e-3;
  sinput.xacc     = 1e-6;
  yy0             = -1;
  dinput.function = FF;
  dinput.xmin     = 1e-3;
  dinput.xmax     = 2e-3;
  dinput.xacc     = 1e-15;


  /*
   *
   * Check to see if bracketing and root finding work.
   *
   */


  if (verbose)
  {
    printf ("\n===== Check Root Finding =====\n\n");
  }

  if (verbose)
  {
    printf ("Initial domain: [%e,%e]\n", dinput.xmin, dinput.xmax);
  }

  LALSBracketRoot (&status, &sinput, &y_0);
  TestStatus (&status, CODES(0), 1);

  if (verbose)
  {
    printf ("Bracket domain: [%e,%e]\n", sinput.xmin, sinput.xmax);
  }

  if (sinput.xmin > 1 || sinput.xmax < 1)
  {
    fprintf (stderr, "Root not bracketed correctly\n");
    return 1;
  }

  LALDBracketRoot (&status, &dinput, &yy0);
  TestStatus (&status, CODES(0), 1);

  if (verbose)
  {
    printf ("Bracket domain: [%e,%e]\n", dinput.xmin, dinput.xmax);
  }

  if (dinput.xmin > 1 || dinput.xmax < 1)
  {
    fprintf (stderr, "Root not bracketed correctly\n");
    return 1;
  }


  LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0);
  TestStatus (&status, CODES(0), 1);

  if (verbose)
  {
    printf ("Root = %e (acc = %e)\n", sroot, sinput.xacc);
  }

  if (fabs(sroot - 1) > sinput.xacc)
  {
    fprintf (stderr, "Root not found to correct accuracy\n");
    return 1;
  }


  LALDBisectionFindRoot (&status, &droot, &dinput, &yy0);
  TestStatus (&status, CODES(0), 1);

  if (verbose)
  {
    printf ("Root = %.15e (acc = %e)\n", droot, dinput.xacc);
  }

  if (fabs(droot - 1) > dinput.xacc)
  {
    fprintf (stderr, "Root not found to correct accuracy\n");
    return 1;
  }


  /*
   *
   * Check to make sure that correct error codes are generated.
   *
   */

#ifndef LAL_NDEBUG

  if ( ! lalNoDebug )
  {

    if (verbose || lalDebugLevel)
    {
      printf ("\n===== Check Errors =====\n");
    }

    /* recursive error from an error occurring in the function */

    if (verbose)
    {
      printf ("\n----- Recursive Error: Code -1 (2 times)\n");
    }

    LALSBracketRoot (&status, &sinput, NULL);
    TestStatus  (&status, CODES(-1), 1);
    ClearStatus (&status);
    LALDBracketRoot (&status, &dinput, NULL);
    TestStatus  (&status, CODES(-1), 1);
    ClearStatus (&status);

    /* one of the arguments is a null pointer */

    if (verbose)
    {
      printf ("\n----- Null Pointer Error: Code 1 (10 times)\n");
    }

    LALSBracketRoot (&status, NULL, &y_0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);
    LALDBracketRoot (&status, NULL, &yy0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);

    LALSBisectionFindRoot (&status, NULL, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);
    LALDBisectionFindRoot (&status, NULL, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);

    LALSBisectionFindRoot (&status, &sroot, NULL, &y_0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);
    LALDBisectionFindRoot (&status, &droot, NULL, &yy0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);

    sinput.function = NULL;
    dinput.function = NULL;

    LALSBracketRoot (&status, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);
    LALDBracketRoot (&status, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);

    LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);
    LALDBisectionFindRoot (&status, &droot, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_ENULL), 1);

    /* invalid initial domain error for BracketRoot() */

    if (verbose)
    {
      printf ("\n----- Invalid Initial Domain: Code 2 (2 times)\n");
    }

    sinput.function = F;
    sinput.xmin     = 5;
    sinput.xmax     = 5;
    dinput.function = FF;
    dinput.xmin     = 5;
    dinput.xmax     = 5;

    LALSBracketRoot (&status, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_EIDOM), 1);
    LALDBracketRoot (&status, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_EIDOM), 1);

    /* maximum iterations exceeded error */

    if (verbose)
    {
      printf ("\n----- Maximum Iteration Exceeded: Code 4 (4 times)\n");
    }

    y_0             = 1; /* there is no root when y_0 > 0 */
    sinput.xmin     = -1e-18;
    sinput.xmax     = 1e-18;
    yy0             = 1; /* there is no root when y_0 > 0 */
    dinput.xmin     = -1e-18;
    dinput.xmax     = 1e-18;

    LALSBracketRoot (&status, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_EMXIT), 1);
    LALDBracketRoot (&status, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_EMXIT), 1);

    y_0             = -1;
    sinput.xmin     = 0;
    sinput.xmax     = 1e19;
    sinput.xacc     = 2e-38;
    yy0             = -1;
    dinput.xmin     = 0;
    dinput.xmax     = 1e19;
    dinput.xacc     = 2e-38;

    LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_EMXIT), 1);
    LALDBisectionFindRoot (&status, &droot, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_EMXIT), 1);

    /* root not bracketed error in BisectionFindRoot() */

    if (verbose)
    {
      printf ("\n----- Root Not Bracketed: Code 8 (2 times)\n");
    }

    sinput.xmin     = -5;
    sinput.xmax     = -3;
    sinput.xacc     = 1e-6;
    dinput.xmin     = -5;
    dinput.xmax     = -3;
    dinput.xacc     = 1e-6;

    LALSBisectionFindRoot (&status, &sroot, &sinput, &y_0);
    TestStatus (&status, CODES(FINDROOTH_EBRKT), 1);
    LALDBisectionFindRoot (&status, &droot, &dinput, &yy0);
    TestStatus (&status, CODES(FINDROOTH_EBRKT), 1);

  }

#endif

  return 0;
}
示例#23
0
void ClearWindows(void) {
    ClearMap();
    ClearUserSelection();
    ClearStatus();
    ClearCommand();
}