Beispiel #1
0
//---------------------------------------------------------------------------
// The message handlers
//---------------------------------------------------------------------------
void __fastcall TConfDlg::ThreadExit(TMessage &Message) {
    if(Message.Msg==REFRESH_FINISH) {
		HostBox->Cursor=crDefault;
    	AddBtn->Enabled=true;
    	RefreshButton->Enabled=true;
        HostBox->Enabled = true;
        if(Incomplete) {
            HostBox->Clear();
        	Servers->EnumData(Handle);
        } else {
        	RemoveInvalidHosts();
            if(UpdateSelState) {
	            UpdateSelState = false;
                UpdateParams();
            }
        }
    } else {
    	Incomplete=false;
        RemoveInvalidHosts();
        if(UpdateSelState) {
	    	UpdateSelState = false;
            UpdateParams();
        }
    }
   	if(HostBox->Items->Count) HostBox->Selected[0]=true;

}
Beispiel #2
0
void Pass::View::SwitchAndUpdateParams(CommitContext& context) {
	context.renderContext->SwitchPass(context, this);
	if (frameNumber != context.frameNumber) {
		UpdateParams(context, ParameterContext::CTX_FRAME, context.frameNumber);
		frameNumber = context.frameNumber;
	}
	if (viewNumber != context.viewNumber) {
		UpdateParams(context, ParameterContext::CTX_VIEW, context.viewNumber);
		viewNumber = context.viewNumber;
	}
	//if (passNumber != context.passNumber)
	{
		UpdateParams(context, ParameterContext::CTX_PASS, context.passNumber);
		passNumber = context.passNumber;
	}
}
Beispiel #3
0
//---------------------------------------------------------------------------
void __fastcall TConfDlg::AddBtnClick(TObject *Sender)
{
   int i,lastSelected=-1,nextSelected = -1;
   HostData *actHost;
   for (i=0;i<HostBox->Items->Count;i++) {
     if(HostBox->Selected[i]) {
        actHost=(*Servers)[HostBox->Items->Strings[i].c_str()]; //get Host with Name c_str()
    	if(!actHost||!actHost->Alive||!(actHost->State) ||!(actHost->State->Valid))
           	return;
        lastSelected=i;
        HostBox->Selected[i]=false;
        SelectedBox->Items->AddObject(HostBox->Items->Strings[i],new CHostRef(CopyHost(0,actHost)));
     }
   }

  //if(lastSelected==i-1) lastSelected=-1;
  //HostBox->Selected[lastSelected+1]=true;

  	 //set next valid host as selected
     i = lastSelected;
     do {
          i = (i + 1) % HostBox->Items->Count;
          actHost=(*Servers)[HostBox->Items->Strings[i].c_str()]; //get Host with Name c_str()
    	  if(actHost&&actHost->Alive&&(actHost->State) &&(actHost->State->Valid))
           	nextSelected = i;
     } while (nextSelected == -1);
     HostBox->Selected[nextSelected]=true;
  
  UpdateParams();
}
Beispiel #4
0
void __fastcall TConfDlg::OnPluginChange(TMessage &Message) {
	int i;
    CHostRef *Host;
	ActivePlugin = PluginManager.GetActualPlugin();

    FreeContext(&GlobalConfig);
    //if(Message.WParam) {
	    for(i=0;i<SelectedBox->Items->Count;++i) {
    		Host = (CHostRef *)SelectedBox->Items->Objects[i];
        	FreeContext(*Host);
    	}

    	for(i=0;i<LastList->Count;++i) {
    		Host = (CHostRef *)LastList->Objects[i];
        	FreeContext(*Host);
    	}
    //}

    if(Message.WParam) {
    	UpdateSelState = true;
    	RefreshButtonClick(0);
    } else  {
    	Servers->EnumData(Handle);
        UpdateParams();
        HostBox->Refresh();
    }

}
Beispiel #5
0
void CStereoGRView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();

    // Update the document
    GetDocument()->Initialize();

    
    // Now initialize the view
    UpdateParams();

    // Initialize the parent's data
    ((CChildFrame*)GetParent())->m_view = this;
    ((CMainFrame*)AfxGetMainWnd())->AddView(this);

    // Initialize OpenGL
    switch(GetDocument()->GetDocType())
    {
	case PT_POINTCLOUD_IMAGE:
	case GR_MAGICCUBE:
        InitGL();
		break;
    }

	UpdatePosition();

    m_wasInitialized = TRUE;
}
Beispiel #6
0
int main(int argc, const char *argv[])
{
  srand((unsigned)time(NULL));
  double ret[ITE_N+10];
  memset(ret, 0, sizeof(ret));
  for (int i=0; i<30; i++) {
    cur_n=0;
    RandInitofSwarm();             //初始化粒子群
    while(cur_n++ != ITE_N)
    {
      ret[cur_n] += UpdatePandGbest();    //更新个体历史最优解P和全局最优解GBest
      UpdateofVandX();        //速度和位置更新,即飞翔
      UpdateParams();
      debug();
    }
    for (int j=1; j<ITE_N; j++) {
      printf("%lf %lf %d %lf\n", W_FUN, MC1, i, ret[j]/(i + 1)); 
    }
    //usleep(900000);
  }
  /*
     for (int i=0; i<ITE_N; i++) {
     printf("%f ", ret[i]/30.0);
     }
     printf("\n\n");
     */

  return 0;
}
void CTRCalibration::Calibrate()
{
	double error_prev = 1e10;
	double max_error = 0.0;
	double error = ComputeErrorOnTrainingSet(max_error);
	int iter = 0;
	double init_Step = 0.0001;
	double step = init_Step;

	double error_val = 0;
	double error_val_max = 0;
	int id;

	// start timer
	Tic();
	::std::cout << "Calibration started" << ::std::endl;
	while( ::std::abs(error - error_prev) > m_tol && iter < m_maxIter )
	{
		error_prev = error;

		// update parameters
		max_error = 0.0;
		error = UpdateParams(step, max_error);

		error_val = this->ComputeErrorOnValidationSet(error_val_max, id);
		// update stepsize
		if (error > error_prev)
			step = ::std::max(0.95*step, 0.5*init_Step);

		// update iter
		iter++;

		// print intermadiate results
		if (iter % 10 == 0)
			PrintOnConsole(error, max_error, iter, step, error_val);

		if (iter % 50 == 0)
			PrintInFile(error, max_error, error_val);
	}
	m_stream.close();

	// print result
	::std::cout << "Calibrated model parameters:" << m_params.transpose() << ::std::endl;  

	// builed calibrated ctr
	m_calibratedCTR = CTRFactory::buildCTR("");
	SetParamsToCTR(m_calibratedCTR, m_params);
}
Beispiel #8
0
void TConfDlg::RemoveInvalidHosts() {
	int i=0,count;
    HostData* actData;
    count = SelectedBox->Items->Count;
    while(i<SelectedBox->Items->Count) {
    	actData=(*Servers)[SelectedBox->Items->Strings[i].c_str()];
        if(!actData||!actData->Alive||!(actData->State)||!actData->State->Valid) {
        	RemoveSelHost(i,true);
        }
        else i++;
    }
    // Probably we changed the selected hosts.
    // So refresh the information for the plugin...
    if(count != SelectedBox->Items->Count) {
    	UpdateParams();
        UpdateSelState = false;
    }
}
Beispiel #9
0
//---------------------------------------------------------------------------
void __fastcall TConfDlg::RemoveBtnClick(TObject *Sender)
{
   int i=0,LastRemoved=0;
   SelectedBox->Items->BeginUpdate();
   while(SelectedBox->SelCount) {
        if(SelectedBox->Selected[i]) {
           RemoveSelHost(i,false);
           LastRemoved = i;
        } else i++;
   }

   if(SelectedBox->Items->Count<=LastRemoved)
   	LastRemoved=0;
   if(SelectedBox->Items->Count>0)
   		SelectedBox->Selected[LastRemoved] = true;
   SelectedBox->Items->EndUpdate();
   UpdateParams();
   Servers->EnumData(Handle);
}
Beispiel #10
0
bool CParticle::Update(float deltaTime)
{
	m_Time +=deltaTime;
	Vect3f l_gravity = Vect3f(0.0f, 0.0f, 0.0f);
	if(m_bGravity)
		l_gravity = Vect3f(0.0f, -9.8f, 0.0f);
	if(m_Time < m_TimeToLive)
	{
		UpdateParams(deltaTime);
		//pos = (a*t^2)/2 + V0*t + pos0
		//Vect3f l_oldPos = GetPos();
		Vect3f l_oldPos = GetFirstPos();
		SetPos(l_oldPos + m_Dir * m_Time + ((m_Acel + l_gravity) * (m_Time*m_Time))/2);
		//CBillboard::Update(camera, 0.0);
		CBillboard::Update();
		return true;
	}

	return false;
}
Beispiel #11
0
bool CHHMRInst::CreateInstrument(void)
{
//	TRACE("CHHMRInst::CreateInstrument()\n");
//	ASSERT(m_pName != NULL);
//	ASSERT(m_pButton != NULL);

	BOOL result = FALSE;

	//find if port exists if it doesn't return false;
	if (!UpdateParams(false))
		return false;

	//char port[32];
	//bool bCameraDo = false;

	//create CHHMRInst object -- we won't actually have a window
	//the window will be in a non-modal dialog box 

	CString cs = AfxRegisterWndClass(NULL, NULL, NULL, NULL);

	result = CreateEx(
			0,               //DWORD dwExStyle, 
			(LPCTSTR)cs,     //LPCTSTR lpszClassName, 
			m_pName,         //LPCTSTR lpszWindowName, 
			0,               //DWORD dwStyle, 
			CRect(0,0,0,0),  //const RECT& rect, 
			NULL,            //CWnd* pParentWnd, 
			0                //UINT nID, 
			);

	bool bParallelPortSetupStatusOK = true;

	if (result) 
	{
		//HHMRs don't have bbm so don't display numeric
		//Don't care on the radix input....
		m_pButton->put_DisplayNumericString(VARIANT_FALSE,0);
		m_pButton->put_FaceColor(COLOR_PAUSE);
		m_pButton->put_Flash(VARIANT_FALSE);

		//no time flag status for HHMR

		//get the other flag status
		m_iFlagOthr = GetPrivateProfileInt(m_pName,FLAGOTHR,-1,m_szIniFile);
		if (m_iFlagOthr == 1)
			m_pButton->ShowIcon_Frown(VARIANT_TRUE);

		//get the comm flag status
		m_iFlagComm = GetPrivateProfileInt(m_pName,FLAGCOMM,-1,m_szIniFile);
		if (m_iFlagComm == 1)
			m_pButton->ShowIcon_Error(VARIANT_TRUE);

		//create each of the pages we'll need in the property sheet
		m_pSummaryPage     = new CHHMRSummary(IDD_HHMRSUMMARY, this);
		m_pDataStatus      = new CHHMRDataStat(IDD_HHMRDATASTATUS_PAGE, this);//m_szIniFile);
		m_pModParams       = new CHHMRModParam(IDD_HHMRMODPARAMS_PAGE,this);
		m_pLegend		   = new CLegend();
		m_pCamera		   = new CHHMRConfig2(IDD_HHMRCONFIG,this);

		//create the user interface dialog box for this instrument
		m_pPropertySheet   = new CHHMRPropertySheet(LPCTSTR(m_pName),this, m_szIniFile);

		m_pPropertySheet->AddPage(m_pSummaryPage);
		m_pPropertySheet->AddPage(m_pDataStatus);
		m_pPropertySheet->AddPage(m_pModParams);
		m_pPropertySheet->AddPage(m_pCamera);
		m_pPropertySheet->AddPage(m_pLegend);

		DWORD dwStyle = 
			WS_POPUP | WS_CAPTION | DS_MODALFRAME |
			WS_MINIMIZEBOX|WS_OVERLAPPED|WS_SYSMENU;

		m_pPropertySheet->Create(this,dwStyle,0);

		m_pPropertySheet->RestartAutoCloseTimer();

		m_pSummaryPage->SetPropertySheet(m_pPropertySheet);
		m_pDataStatus->SetPropertySheet(m_pPropertySheet);
		m_pModParams->SetPropertySheet((CHHMRPropertySheet*)m_pPropertySheet);
		m_pCamera->SetPropertySheet(m_pPropertySheet,false);

		//necessary because PropertySheet doesn't creat a page until 
		//  it needs to display it.  So force it to create them all
		for (int i = m_pPropertySheet->GetPageCount();i>=0;i--)
			m_pPropertySheet->SetActivePage(i-1);

		char szTemp[MAX_PATH];
		GetModuleFileName(AfxGetInstanceHandle(),szTemp,sizeof(szTemp));
		char *c = strrchr(szTemp,'\\');//find the last "\"
		*c = '\0';						//make it null
		strcat(szTemp,"\\");
		
		CString cTemp(szTemp);
		cTemp += m_pName;
		cTemp += ".rtf";
		if (_access(cTemp,4))
		{
			cTemp = szTemp;
			cTemp += "HHMR.rtf";
			if (_access(cTemp,4))
			{
				cTemp = 
				"Instrument Button Colors...\n"
				"GREEN_ICON\nNormal state.\n"
				"---------------------------\n"
				"YELLOW_ICON\nA command has been sent from MIC to the instrument and MIC is waiting for a response.\n"
				"---------------------------\n"
				"RED_ICON\nCommunications Failure! A command has been sent and resent but no acceptable response has been received back from the instrument.\n"
				"---------------------------\n"
				"WHITE_ICON\nFLASHING to previous color. The disk is full or the instrument has a failure which is causing data loss\n"
				"---------------------------\n"
				"GRAY_ICON\nMIC has been instructed not to talk to the instrument.  In all cases this state will eventuall revert to a normal operational state.\n"
				"===========================\n"
				"\n"
				"Instrument Button ICONs...\n"
				"SQUARE_ICON Square: One or more of the tabbed pages have a data item out of tolerance or a configuration mismatch.\n"
				"---------------------------\n"
				"CLOCK_ICON Clock: The difference between MIC's time and the instrument's time is greater than the user set tolerance.\n"
				"---------------------------\n"
				"FLAG_ICON Flag:  MIC has sent and resent a command with no acceptable response and consequently commanded a long break reset in an attempt to reinitialize the instrument or a Hard Checksum Error occurred.\n"
				"---------------------------\n"
				"BELL_ICON Bell: The instrument is currently reporting a \"Measurement Interval of Interest\" or equivalent.\n"	
				"---------------------------\n"
				"FACE_ICON Face: The instrument has reported either a power problem or a battery backed up memory problem.\n"	
				"---------------------------\n"
				"FLOPPY_ICON Floppy Disk & Flashing: MIC has stopped writing to disk and talking to the instrument.  This can be caused by the hard drive being too full, the maximum use of the hard drive set too low, or disk write failure.\n"
				"---------------------------\n"
				"SKULL_ICON Skull and Cross Bones: The instrument has repeatedly failed to respond to commands and long break resets.  MIC will attempt to reset it every 15 minutes or instrument is in a state which is causing DATA LOSS.\n"
				"---------------------------\n"
				"BOMB_ICON Bomb: Configuration Error.  MIC is not configured correctly. Edit the MIC.INI file or delete the instrument object and recreate it to correct this problem.\n";
			}
		}
		m_pLegend->SetText((LPSTR)LPCSTR(cTemp));


		UpdateStrings();

		//set the time to start data collecting 
		SetTimer(TIMER_PAUSE,m_iPauseMax,NULL);

		char port[32];
		bool bCameraDo = false;
		GetPrivateProfileString(m_pName,"CAMERA_PORT","NONE",port,sizeof(port),m_szIniFile);
		for (unsigned int ui = 0; ui < strlen(port); ui++)
				port[ui]=(char)toupper(port[ui]);

		m_pPropertySheet->SetLimits(
				m_lRealThresh,
				m_lTotalThresh,
				m_lTotal1Thresh,
				m_lTotalLThresh,
				m_lSigmaThresh,
				m_dMaxCompress,
				m_dCountTimeUnit,
//				m_dCountTimeExp,
				m_dHighV,
				m_dGateWidth,
				m_dPreDelay,
				m_dHighVoltH, m_dHighVoltL,
				m_cCameraRealorTotals,
//				m_lCameraThreshold,
				bCameraDo = (port[0] == 'P'),
				m_pID);

			//reset the mod params page
			m_pModParams->OnModparamsReset();

		m_dCurrent_State = 1000;
		m_dTick_Count = 0;
		m_dTickToInquire = 0;

		bParallelPortSetupStatusOK = SetupParallelPort(true);

		//register this instument with the com object 
		//note that the DIALOGBOX gets registered -- so that it will receive 
		//the data coming from the port.  We may want to change this to a 
		//separate CWndThread window later on if the interface gets sluggish

		VARIANT_BOOL vbResult;

		m_pComm->RegisterISO(
			(ULONG)m_pPropertySheet->m_hWnd,
			m_iNode,
			STANDARD_ISO,
			VARIANT_FALSE,  //not OOB
			&vbResult);

		m_bGoodRegister = (vbResult == VARIANT_TRUE);

		m_dRetransmit		= 0;		//no retransmitions yet
		m_dLongBreak		= 0;		//not in long break

		//SCR 118
		//EstablishVersionString();

		//tell the files that mic is starting for this instrument
		m_pPropertySheet->WriteToFile(
			TO_CEV | TO_PFM, 
			(m_bNormalShutdown)?TYPE_START:TYPE_ABNORMAL);

	}  //if(result)
	
	return (m_bGoodRegister && bParallelPortSetupStatusOK);
}