Ejemplo n.º 1
0
void C_Custom::Setup(long ID,short Type,short NumCtrls)
{
	short i;

	SetID(ID);
	SetType(Type);
	SetDefaultFlags();

	if(Count_)
		return;

	SetReady(0);

	if(NumCtrls > 0 && NumCtrls < _CUSTOM_MAX_CTRLS_)
	{
		Count_=NumCtrls;
		Items_=new O_Output[Count_];
#ifdef USE_SH_POOLS
		ItemValues_=(long*)MemAllocPtr(UI_Pools[UI_GENERAL_POOL],sizeof(long)*(Count_),FALSE);
#else
		ItemValues_=new long[Count_];
#endif

		for(i=0;i<Count_;i++)
		{
			Items_[i].SetOwner(this);
			ItemValues_[i]=0;
		}
		SetReady(1);
	}
}
Ejemplo n.º 2
0
void C_Tile::SetImage(long ID)
{
	SetReady(0);
	if(Image_ == NULL)
	{
		Image_=new O_Output;
		Image_->SetOwner(this);
	}

	Image_->SetFlags(GetFlags());
	Image_->SetImage(ID);

	if(Image_->GetW() && Image_->GetH())
		SetReady(1);
}
Ejemplo n.º 3
0
void C_Bitmap::SetImage(long ID)
{
	SetReady(0);
	if(Image_ == NULL)
	{
		Image_=new O_Output;
		Image_->SetOwner(this);
	}

	Image_->SetFlags(GetFlags());
	Image_->SetImage(ID);

	SetWH(Image_->GetW(),Image_->GetH());
	SetReady(1);
}
Ejemplo n.º 4
0
void C_ListBox::SetRoot(LISTBOX *NewRoot)
{
	LISTBOX *cur;
	short i;

	Root_=NewRoot;

	if(NewRoot == NULL){
		SetFlagBitOn(C_BIT_REMOVE);
		Count_=0;
		return;
	}

	cur=Root_;
	Count_=0;
	i=0;
	while(cur){
		cur->Label_->SetSubParents(Parent_);
		if(LabelVal_ == cur->Label_->GetID()){
			Label_->SetText(cur->Label_->GetText(C_STATE_0));
			i=1;
		}
		Count_++;
		cur=cur->Next;
	}
	if(!i && Root_){
		LabelVal_=Root_->Label_->GetID();
		Label_->SetText(Root_->Label_->GetText(C_STATE_0));
	}
	SetFlagBitOff(C_BIT_REMOVE);
	SetReady(1);
}
Ejemplo n.º 5
0
void C_Fill::Setup(long ID,short Type)
{
	SetID(ID);
	SetType(Type);
	SetDefaultFlags();
	SetReady(1);
}
Ejemplo n.º 6
0
void C_Mission::Setup(long ID,short Type)
{
	SetID(ID);
	SetType(Type);
	SetDefaultFlags();
	SetReady(1);

	TakeOff_=new O_Output;
	TakeOff_->SetOwner(this);
	TakeOff_->SetFont(Font_);
	TakeOff_->SetTextWidth(10);
	Mission_=new O_Output;
	Mission_->SetOwner(this);
	Mission_->SetFont(Font_);
	Package_=new O_Output;
	Package_->SetOwner(this);
	Package_->SetFont(Font_);
	Package_->SetTextWidth(6);
	Status_=new O_Output;
	Status_->SetOwner(this);
	Status_->SetFont(Font_);
	Priority_=new O_Output;
	Priority_->SetOwner(this);
	Priority_->SetFont(Font_);
	Priority_->SetTextWidth(4);
}
Ejemplo n.º 7
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF31,ScopeOn);  // activate grader and set system clock to 80 MHz
  PortF_Init();                            // Init port PF4 PF3 PF1    
  EnableInterrupts();                      // enable interrupts for the grader  
  while(1){  
     SetReady();
		WaitForASLow();
		ClearReady();
		Delay1ms(10);
		WaitForASHigh();
		Delay1ms(250);
		SetVT();
		Delay1ms(250);
		ClearVT();
      		
		// Follows the nine steps list above
    // a) Ready signal goes high
    // b) wait for switch to be pressed
    // c) Ready signal goes low
    // d) wait 10ms
    // e) wait for switch to be released
    // f) wait 250ms
    // g) VT signal goes high
    // h) wait 250ms
    // i) VT signal goes low
  }
}
Ejemplo n.º 8
0
C_Tile::C_Tile() : C_Base()
{
	Image_=NULL;
	_SetCType_(_CNTL_TILE_);
	SetReady(0);
	DefaultFlags_=C_BIT_ENABLED|C_BIT_REMOVE;
}
Ejemplo n.º 9
0
void Wiimote::ThreadFunc()
{
	Common::SetCurrentThreadName("Wiimote Device Thread");

	bool ok = ConnectInternal();

	SetReady();

	if (!ok)
	{
		return;
	}

	// main loop
	while (IsConnected() && m_run_thread)
	{
		if (m_need_prepare)
		{
			m_need_prepare = false;
			if (!PrepareOnThread())
			{
				ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed.  Disconnecting Wiimote %d.", index + 1);
				break;
			}
		}
		Write();
		Read();
	}

	DisconnectInternal();
}
Ejemplo n.º 10
0
C_Anim::C_Anim() : C_Base()
{
	Anim_=NULL;
	_SetCType_(_CNTL_ANIMATION_);
	SetReady(0);
	DefaultFlags_=C_BIT_ENABLED|C_BIT_REMOVE|C_BIT_TIMER;
}
Ejemplo n.º 11
0
C_Bitmap::C_Bitmap() : C_Base()
{
	Image_=NULL;
	TimerCallback_=NULL;
	_SetCType_(_CNTL_BITMAP_);
	SetReady(0);
	DefaultFlags_=C_BIT_ENABLED|C_BIT_REMOVE;
}
Ejemplo n.º 12
0
void C_Anim::SetAnim(long ID)
{
	SetReady(0);
	if(Anim_ == NULL)
	{
		Anim_=new O_Output;
		Anim_->SetOwner(this);
	}

	Anim_->SetFlags(GetFlags());
	Anim_->SetAnim(ID);

	if(Anim_->Ready())
	{
		SetWH(Anim_->GetW(),Anim_->GetH());
		SetReady(1);
	}
}
Ejemplo n.º 13
0
C_TimerHook::C_TimerHook() : C_Base()
{
	UpdateCallback_=NULL;
	RefreshCallback_=NULL;
	DrawCallback_=NULL;
	_SetCType_(_CNTL_TIMERHOOK_);
	SetReady(0);
	DefaultFlags_=C_BIT_ENABLED|C_BIT_TIMER|C_BIT_REMOVE;
}
Ejemplo n.º 14
0
void InterruptHandler::Run()
{
	StartTrace(InterruptHandler.Run);

	// the just wait for the signal to happen
	Trace("Thread: " << Thread::MyId());
	Trace("Pid: " << (long)coast::system::getpid());
	Trace("Server [" << (fServer ? (const char *)(fServer->fName) : "no-name") << "]");

	if ( fServer ) {
		fServer->WritePIDFile(coast::system::getpid());
	}

	sigset_t set;
	int isignal;
	// setup the signal set that catches control-c
	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGTERM);
	sigaddset(&set, SIGHUP);

handlesignal:
	SetWorking();
	Trace("calling sigwait");
	sigwait(&set, &isignal);
	SetReady();

	Trace("got signal: " << (long)isignal);
	if (fServer) {
		String sigName;
		sigName << (long)isignal;
		if ( isignal == SIGHUP ) {
			SYSINFO("caught SIGHUP, resetting server");
			int retVal = fServer->GlobalReinit();
			if ( retVal == 0 ) {
				// everything ok, wait on next signal
				goto handlesignal;
			}
			sigName = "SIGHUP";
			// shutdown if any mishap happens
			SYSERROR("GlobalReinit failed, shutting down...");
		} else if ( isignal == SIGINT ) {
			sigName = "SIGINT";
		} else if ( isignal == SIGTERM ) {
			sigName = "SIGTERM";
		} else {
			SYSINFO("caught unknown signal " << sigName << " ...ignoring!");
			goto handlesignal;
		}
		SYSINFO("caught " << sigName << " shutting down server");
		// prepare the server for shutdown
		// by causing him to leave the accept-loop
		fServer->PrepareShutdown();
	}
	// the job is done, just die...
}
Ejemplo n.º 15
0
void C_ATO_Package::InitPackage(C_Handler *)
{
    Title_=new O_Output;
    Title_->SetOwner(this);
    Title_->SetFlags(Flags_);
    ShowWP_=new O_Output;
    ShowWP_->SetOwner(this);
    ShowWP_->SetFlags(Flags_);
    SetReady(1);
}
Ejemplo n.º 16
0
void C_DrawList::Setup(long ID,short Type)
{
	SetID(ID);
	SetType(Type);
	SetDefaultFlags();
	SetReady(1);
	Root_=new C_Hash;
	Root_->Setup(5);
	SetMenu(0);
}
Ejemplo n.º 17
0
// ----------------------------------------------------------------------------------------------
void Texture::Set(ID3D11Texture2D* tex, ID3D11ShaderResourceView* view)
{
    SAFE_RELEASE(m_tex);
    SAFE_RELEASE(m_view);
    m_tex = tex;
    m_view = view;
    if((NULL != m_tex) && (NULL != m_view))
    {
        SetReady();
    }
}
Ejemplo n.º 18
0
// This will ONLY Get Calle
void C_TimerHook::Draw(SCREEN *,UI95_RECT *cliprect)
{
	if(!Ready() || (GetFlags() & C_BIT_INVISIBLE))
		return;

	if(GetFlags() & C_BIT_TIMER)
		SetReady(0);

	if(DrawCallback_)
	{
		if(!(cliprect->left > (GetX()+GetW()) || cliprect->top > (GetY()+GetH()) || cliprect->right < GetX() || cliprect->bottom < GetY()))
			(*DrawCallback_)(GetID(),C_TYPE_TIMER,this);
	}
}
Ejemplo n.º 19
0
C_ListBox *C_ListBox::AddItem(long ID,short,_TCHAR *Str)
{
	LISTBOX *newitem,*cur;

	if(!ID) return(NULL);

	if(Str == NULL) return(NULL);

	if(!(GetFlags() & C_BIT_REMOVE)) // Using premade list ... don't add to it
		return(NULL);

	if(FindID(ID))
		return(NULL);

	newitem=new LISTBOX;
	newitem->Label_=new C_Button;
	newitem->Label_->Setup(ID,C_TYPE_RADIO,0,0);
	newitem->Label_->SetText(C_STATE_0,Str);
	newitem->Label_->SetText(C_STATE_1,Str);
	newitem->Label_->SetColor(C_STATE_0,NormalColor_);
	newitem->Label_->SetColor(C_STATE_1,SelColor_);
	newitem->Label_->SetGroup(5551212);
	newitem->Label_->SetFont(Font_);
	newitem->Label_->SetFlags((GetFlags() & ~(C_BIT_INVISIBLE|C_BIT_ABSOLUTE|C_BIT_USEBGFILL|C_BIT_REMOVE)));
	newitem->Label_->SetOwner(this);
	newitem->Label_->SetParent(Parent_);
	newitem->Next=NULL;

	if(Root_ == NULL){
		Root_=newitem;
		Count_=1;
		Root_->Label_->SetState(C_STATE_1);
		Label_->SetText(Root_->Label_->GetText(C_STATE_0));
		LabelVal_=Root_->Label_->GetID();
	}
	else {
		cur=Root_;
		while(cur->Next){
			cur=cur->Next;
		}
		cur->Next=newitem;
		Count_++;
	}
	newitem->Label_->SetXY(5,(Count_-1)*gFontList->GetHeight(Font_));
	if(Root_ && Root_->Label_ && Root_->Label_->Ready()){
		SetReady(1);
	}
	return(this);
}
Ejemplo n.º 20
0
void O_Output::SetInfo()
{
	switch(_GetOType_())
	{
		case _OUT_FILL_:
			SetReady(1);
			if(flags_ & C_BIT_HCENTER)
				x_=(origx_ - (w_ >> 1));
			else if(flags_ & C_BIT_RIGHT)
				x_=(origx_ - w_);
			else
				x_=(origx_);

			if(flags_ & C_BIT_VCENTER)
				y_=(origy_ - (h_ >> 1));
			else
Ejemplo n.º 21
0
void C_Tile::SetImage(IMAGE_RSC *tmp)
{
	if(tmp == NULL)
		return;

	if(Image_ == NULL)
	{
		Image_=new O_Output;
		Image_->SetOwner(this);
	}

	Image_->SetFlags(GetFlags());
	Image_->SetImage(tmp);

	if(Image_->GetW() && Image_->GetH())
		SetReady(1);
}
Ejemplo n.º 22
0
bool CIVConnection::RequestData()
{
	SetReady (false);	
	PostThreadMessage (WM_POST_REQUEST, 0, 0);

	HANDLE hEvtReady = m_evtReady;
	
	while ( MsgWaitForMultipleObjects (1, & hEvtReady, FALSE, INFINITE, QS_ALLEVENTS) != WAIT_OBJECT_0 )
	{
		MSG msg;
		while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
			AfxGetThread()->PumpMessage();
	}

	if (m_bStopped  ||  m_bError )
		return false;
	else
		return true;
}
Ejemplo n.º 23
0
void C_Slider::Setup(long ID,short Type)
{
	SetReady(0);
	SetID(ID);
	SetType(Type);
	SetDefaultFlags();
	SetGroup(0);

	BGX_=0;
	BGY_=0;
	SX_=0;
	SY_=0;
	Steps_=0;
	BgImage_=NULL;
	Slider_=NULL;
	MinPos_=0;
	MaxPos_=1;

	Callback_=NULL;
}
Ejemplo n.º 24
0
void Servo::run()
{
	if(mode == Servo::JOG){

		//ジョグモードの場合は単発で目的位置へ移動
		CPhidgetAdvancedServo_setPosition (*servo, index, position);

	}else if(mode == Servo::PREDEFINED){

		//プリディファインドモードの場合は制御ベクトルに従ってそれぞれ移動
		if(to == 0){
			SetReady();
		}else if(to == 1){
			SetContact();
		}else if(to == 2){
			SetHome();
		}

	}

	//// エンゲージ

	/*
	if(mode == Servo::JOG){
		std::cout << "[ サーボモーター制御スレッド ] モータID : " << index << " > エンゲージ(ジョグ)" << std::endl;
		Engage(true);
	}else if(mode == Servo::KNOCK){
		std::cout << "[ サーボモーター制御スレッド ] モータID : " << index << " > エンゲージ(電磁弁)" << std::endl;
		CPhidgetAdvancedServo_setPosition (*servo, index, knockPosition);
	}
	*/

	//// ディスエンゲージ動作は行わない

	//電磁弁的動作処理時間(0.5秒)
	//Sleep(500);
	//
	//ディスエンゲージ
	//std::cout << "ディスエンゲージ" << std::endl;
	//CPhidgetAdvancedServo_setEngaged(*servo, index, 0);
}
Ejemplo n.º 25
0
void O_Output::Cleanup()
{
	if(Label_)
	{
		if(flags_ & C_BIT_FIXEDSIZE)
#ifdef USE_SH_POOLS
			MemFreePtr(Label_);
#else
			delete Label_;
#endif
		Label_=NULL;
		SetReady(0);
	}
	if(Image_)
		Image_=NULL;

	if(Rows_)
	{
#ifdef USE_SH_POOLS
			MemFreePtr(Rows_);
#else
			delete Rows_;
#endif
		Rows_=NULL;
	}
	if(Cols_)
	{
#ifdef USE_SH_POOLS
			MemFreePtr(Cols_);
#else
			delete Cols_;
#endif
		Cols_=NULL;
	}
	WWCount_=0;
	if(Wrap_)
	{
		delete Wrap_;
		Wrap_=NULL;
	}
}
Ejemplo n.º 26
0
void CIVConnection::OnPostRequest	(WPARAM wParam, LPARAM lParam)
{
	ASSERT (!m_strRequest.IsEmpty());
	try
	{
		InitSession();

		CString strSID = Login();

		CString strRequest;
		strRequest.Format (m_strRequest, (LPCTSTR) strSID );

		GetHTTPData (strRequest, m_strResult);
	}
	catch (CException * e )
	{
		e->Delete();
	}

	CloseSession();
	SetReady (true);	
}
Ejemplo n.º 27
0
void Wiimote::ThreadFunc()
{
  Common::SetCurrentThreadName("Wiimote Device Thread");

  bool ok = ConnectInternal();

  if (!ok)
  {
    // try again, it might take a moment to settle
    Common::SleepCurrentThread(100);
    ok = ConnectInternal();
  }

  SetReady();

  if (!ok)
  {
    return;
  }

  // main loop
  while (IsConnected() && m_run_thread.load())
  {
    if (m_need_prepare.load())
    {
      m_need_prepare.store(false);
      if (!PrepareOnThread())
      {
        ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed.  Disconnecting Wiimote %d.",
                  m_index + 1);
        break;
      }
    }
    Write();
    Read();
  }

  DisconnectInternal();
}
Ejemplo n.º 28
0
void C_Slider::SetSliderImage(long SliderID)
{
	Slider_=gImageMgr->GetImage(SliderID);
	SetReady(1);
}
Ejemplo n.º 29
0
void C_Slider::Cleanup()
{
	BgImage_=NULL;
	Slider_=NULL;
	SetReady(0);
}
Ejemplo n.º 30
0
void C_ServerItem::Setup(IGame *_pGame, C_TreeList *pParent)
{
	if(!_pGame || !pParent)
		return;

	GNETCORELib::IGamePtr pGame(_pGame);

	m_dwIP = GNETCORELib::IHostPtr(pGame)->GetIP();
	m_nPing = GNETCORELib::IHostPtr(pGame)->GetPing();	// remember for quick sorting
	m_nPlayers = pGame->GetNumPlayers();	// remember for quick sorting

	char buf[0x10];
	_bstr_t str;
	int x, n;

	SetID((long) pGame);
	SetType(0);
	SetDefaultFlags();
	SetReady(1);

	m_arrOutput[0] = new O_Output;
	if(!m_arrOutput[0]) throw _com_error(E_OUTOFMEMORY);
	m_arrOutput[0]->SetOwner(this);
	m_arrOutput[0]->SetFont(Font_);
	m_arrOutput[0]->SetXY(pParent->GetUserNumber(C_STATE_0), 0);
	str = pGame->GetServerName();
	n = TrimString(str, pParent->GetUserNumber(C_STATE_1) - pParent->GetUserNumber(C_STATE_0));
	m_arrOutput[0]->SetTextWidth(n + 1);
	m_arrOutput[0]->SetText(str);

	m_arrOutput[1] = new O_Output;
	if(!m_arrOutput[1]) throw _com_error(E_OUTOFMEMORY);
	m_arrOutput[1]->SetOwner(this);
	m_arrOutput[1]->SetFont(Font_);
	m_arrOutput[1]->SetTextWidth(sprintf(buf, "%4d", GNETCORELib::IHostPtr(pGame)->GetPing()) + 1);
	// Center
	//x = ((pParent->GetUserNumber(C_STATE_2) - pParent->GetUserNumber(C_STATE_1)) - gFontList->StrWidth(Font_, buf, strlen(buf))) / 2;
	x = pParent->GetUserNumber(C_STATE_1);
	m_arrOutput[1]->SetXY(x, 0);
	m_arrOutput[1]->SetText(buf);

	m_arrOutput[2] = new O_Output;
	if(!m_arrOutput[2]) throw _com_error(E_OUTOFMEMORY);
	m_arrOutput[2]->SetOwner(this);
	m_arrOutput[2]->SetFont(Font_);
	str = pGame->GetType();
	n = TrimString(str, pParent->GetUserNumber(C_STATE_3) - pParent->GetUserNumber(C_STATE_2));
	m_arrOutput[2]->SetTextWidth(n + 1);
	m_arrOutput[2]->SetXY(pParent->GetUserNumber(C_STATE_2), 0);
	m_arrOutput[2]->SetText(str);

	m_arrOutput[3] = new O_Output;
	if(!m_arrOutput[3]) throw _com_error(E_OUTOFMEMORY);
	m_arrOutput[3]->SetOwner(this);
	m_arrOutput[3]->SetFont(Font_);
	m_arrOutput[3]->SetTextWidth(sprintf(buf, "%2d/%2d", pGame->GetNumPlayers(), pGame->GetMaxPlayers()) + 1);
	// Center
	//x = ((pParent->GetUserNumber(C_STATE_4) - pParent->GetUserNumber(C_STATE_3)) - gFontList->StrWidth(Font_, (char *) str, str.length())) / 2;
	x = pParent->GetUserNumber(C_STATE_3);
	m_arrOutput[3]->SetXY(x, 0);
	m_arrOutput[3]->SetText(buf);

	m_arrOutput[4] = new O_Output;
	if(!m_arrOutput[4]) throw _com_error(E_OUTOFMEMORY);
	m_arrOutput[4]->SetOwner(this);
	m_arrOutput[4]->SetFont(Font_);
	m_arrOutput[4]->SetXY(pParent->GetUserNumber(C_STATE_4), 0);
	str = pGame->GetLocation();
	m_arrOutput[4]->SetTextWidth(str.length() + 1);
	m_arrOutput[4]->SetText(str);
}