Beispiel #1
0
MainWindow::MainWindow()
{
	SetHandler(WM_CREATE, &MainWindow::OnCreate);
	SetHandler(WM_CLOSE, &MainWindow::OnClose);
	SetHandler(WM_COMMAND, &MainWindow::OnCommand);

	flVerticalProjection=false;
	flHorizontalProjection=false;

	nImagesIndex=-1;

	symsratio=1.4;
	nSyms=5;

	ShowState=0;
}
Beispiel #2
0
main()
{
int i,n,m;

init_IPIC();
ip = (IP_STEPPER*)IPABase;
init_stepper();
init_encoder();
//
ip->AxisCtrl1.Polarity = 0; 
ip->AxisCtrl1.Source = 0;
ip->SyncCtrl = 0;
ip->intVector = 0xF0;

//programmer timer MCchip : une it toutes les TICK mili secondes
StoreByte(MCchip_Base + General_Control_R, 0x2);	/* MIEN 	*/
StoreByte(MCchip_Base+Timer1_Control_R, 3);      	/* CEN COC 	*/
StoreLong(MCchip_Base+Timer1_Compare_R, TICK*1000);	
StoreByte(MCchip_Base+Timer1_Interrupt_R, 0x11);   	/* IEN IL=1 	*/
SetHandler(((IVBR+Timer1_IRQ)*4 + VBR), it_timer );

sti();
//start
ip->Motor1.csr = START_STOP_CMD | START_MOTION | FH1_SPEED | RAMP_UP_SPEED;

while(1) stop();
}
Beispiel #3
0
int boss::UdpHandlerBase::HandleClose()
{
    if(GetHandler() != -1)
    {
        close(GetHandler());
        SetHandler(-1);
	}

	return 0;
}
Beispiel #4
0
/*----------------------------------------------------------------------
|       TestServer::TestServer
+---------------------------------------------------------------------*/
TestServer::TestServer()
{
    // create the message queue
    m_MessageQueue = new NPT_SimpleMessageQueue();
    
    // attach to the message queue
    SetQueue(m_MessageQueue);
    SetHandler(this);
    // start the thread
    Start();
}
Beispiel #5
0
int boss::UdpHandlerBase::Open(u_int16_t uiPort, const string &sAddr)
{
    struct  sockaddr_in stAddr;

    memset(&stAddr, 0, sizeof(stAddr));

    stAddr.sin_family = AF_INET;
    stAddr.sin_port   = htons((unsigned short)uiPort);
    if("" == sAddr)
    {
        stAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    }
    else
    {
        stAddr.sin_addr.s_addr = inet_addr(sAddr.c_str());
    }

    int iSocketFD;
    if((iSocketFD = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
    {
        BOSS_ERROR("socket Error: %s", strerror(errno));
        return -1;
    }

	u_int32_t uiRecvBufSize = 40 * 100000;
	uint32_t  dwLen = sizeof(uiRecvBufSize);
	if (setsockopt(iSocketFD, SOL_SOCKET, SO_RCVBUF, (int *)&uiRecvBufSize, dwLen) == -1)
	{
		BOSS_ERROR("setsockopt Error: %s", strerror(errno));
		close(iSocketFD);
		return -1;
	}

	int iFlags;

	iFlags = fcntl(iSocketFD, F_GETFL, 0);
	iFlags |= O_NONBLOCK;
	iFlags |= O_NDELAY;
	fcntl(iSocketFD, F_SETFL, iFlags);

    if(bind(iSocketFD, (struct sockaddr*)&stAddr, sizeof(stAddr)) < 0)
    {
        BOSS_ERROR("bind Error: %s", strerror(errno));

        close(iSocketFD);
        return -1;
    }

    SetHandler(iSocketFD);

    GetReactor()->RegisterHandler(this, MASK_INPUT);

    return 0;
}
Beispiel #6
0
/*----------------------------------------------------------------------
|       TestClient::TestClient
+---------------------------------------------------------------------*/
TestClient::TestClient(TestServer* server, int id) :
    m_Server(server), m_Id(id)
{
    // set ourself as the message handler
    SetHandler(this);
    
    // send commands to server
    server->DoTestCommand(this, 1);
    server->DoTestCommand(this, 2);
    server->DoTestCommand(this, 3);
    server->DoTestCommand(this, 4);
}
Beispiel #7
0
main()
{
char s[20];
///////////////////////////////////////////
////INITIALISATION DE LA CARTE
//////////////////////////////////////////
/*
 * configurer le MCchip
 */
n_htos(0xFFFFFFFF,s);
print (s);
StoreByte(MCchip_Base + General_Control_R, 0x2);	/* MIEN */
StoreByte(MCchip_Base + SCC_Interrupt_R,   0x12);   	/* IEN it z85230 niveau 2 */

/* 
 * le numero du vecteur d'it du timer 
 * est (InterruptVectorBaseR) + Timer1_IRQ 
 * son adresse est 4 fois plus loin
 * on garde IVBR (MCchip) de 162Bug
 */
#define IVBR	80
StoreByte(MCchip_Base+Interrupt_Vector_Base_R, IVBR);


SetHandler(((IVBR+Timer1_IRQ)*4 + VBR), schedule );

//programmer timer MCchip
StoreByte(MCchip_Base+Timer1_Control_R, 3);      	/*CEN COC*/
/* une it toutes les TICK mili secondes */
StoreLong(MCchip_Base+Timer1_Compare_R, TICK*1000);	
StoreByte(MCchip_Base+Timer1_Interrupt_R, 0x11);   	/*IEN  IL=1*/

////////////////////////////////////////////
//// INITIALISATION POUR LE NOYAU
///////////////////////////////////////////
print("init hard ok");
init_mode_S(); 		//init en mode S

//démasquer les it
//sti();
// GO !

//démarrer les process utilisateurs. Ils n'accèdent aux primitives noyau que par trap
//ils sont compilés avec une édition de liens indépendante de celle du noyau
//lance un shell de debug. Il peut accéder aux structures de données internes du noyau
//init();  	
//asm("jsr ___init");	//init en mode U

//idle
while (1) {
   //halt();  //pour libérer le bus 
   }
}
Beispiel #8
0
void TrapInts()
{
  SetHandler(SIGHUP, SighupHandler);
  /*SetHandler(SIGINT, SigintHandler);*/
  /*SetHandler(SIGQUIT, SigquitHandler);*/
  SetHandler(SIGILL, SigillHandler);
  SetHandler(SIGABRT, SigabrtHandler);
  SetHandler(SIGFPE, SigfpeHandler);
  SetHandler(SIGBUS, SigbusHandler);
  SetHandler(SIGSEGV, SigsegvHandler);
#ifdef SIGSYS
  SetHandler(SIGSYS, SigsysHandler);
#endif
  SetHandler(SIGPIPE, SigpipeHandler);
}
/*----------------------------------------------------------------------
|    BLT_DecoderServer::BLT_DecoderServer
+---------------------------------------------------------------------*/
BLT_DecoderServer::BLT_DecoderServer(NPT_MessageReceiver* client) :
    m_Decoder(NULL),
    m_Client(client),
    m_TimeStampUpdateQuantum(1000),
    m_PositionUpdateRange(BLT_DECODER_SERVER_DEFAULT_POSITION_UPDATE_RANGE),
    m_State(STATE_STOPPED)
{
    // create a queue to receive messages
    m_MessageQueue = new NPT_SimpleMessageQueue();

    // attach the queue as the receiving queue
    SetQueue(m_MessageQueue);
    
    // register ourselves as the message handler
    SetHandler(this);

    // reset some fields
    m_DecoderStatus.position.range  = m_PositionUpdateRange;
    m_DecoderStatus.position.offset = 0;

    // setup our event listener interface
    m_EventListener.outer = this;
    ATX_SET_INTERFACE(&m_EventListener, 
                      BLT_DecoderServer_EventListenerWrapper, 
                      BLT_EventListener);

    // setup our core property listener interface
    m_CorePropertyListener.scope = BLT_PROPERTY_SCOPE_CORE;
    m_CorePropertyListener.source = NULL;
    m_CorePropertyListener.outer = this;
    ATX_SET_INTERFACE(&m_CorePropertyListener, 
                      BLT_DecoderServer_PropertyListenerWrapper, 
                      ATX_PropertyListener);

    // setup our stream property listener interface
    m_StreamPropertyListener.scope = BLT_PROPERTY_SCOPE_STREAM;
    m_StreamPropertyListener.source = NULL;
    m_StreamPropertyListener.outer = this;
    ATX_SET_INTERFACE(&m_StreamPropertyListener, 
                      BLT_DecoderServer_PropertyListenerWrapper, 
                      ATX_PropertyListener);

    // start the thread
    Start();
}
Beispiel #10
0
void SDSTerminate(void)
{
  TRACEENTER();

  if(LastStatus != -3) WriteLog("SDS termination request received");
  LastStatus = -3;

  if(OrigHandler)
  {
    SetHandler(0xef00, OrigHandler, NULL);
    OrigHandler = NULL;
    if(LastStatus != -9) WriteLog("SDS has been deactivated");
    LastStatus = -9;
  }
  HookHandlerState = HHS_Exit;

  TRACEEXIT();
}
Beispiel #11
0
bool CAutoTracker::Init(uint32 uAttackerID, uint32 uTargetID, float fReachGridDist, IAutoTrackerHandler* pHandler, bool bIsNormalAttackTracker)
{
	//if(fReachGridDist < GetDistAdjustment())
	//{
	//	fReachGridDist = GetDistAdjustment() + 0.5f;
	//}

	CEntityClient* pAttacker = CEntityClientManager::GetEntityByID(uAttackerID);
	CCharacterDirector* pCharAttacker = class_cast<CCharacterDirector*>(pAttacker);
	if(!pCharAttacker || pCharAttacker->CppGetCtrlState(eFCS_ForbitAutoTrack))
		return false;

	CEntityClient* pTarget = CEntityClientManager::GetEntityByID(uTargetID);
	if (pTarget->GetGameEntityType() == eGET_CharacterFollower)
	{
		CCharacterFollower* pCharTarget = class_cast<CCharacterFollower*>(pTarget);
		CRelationMgrClient& relationMgr = CRelationMgrClient::Inst();
		if (relationMgr.GetRelationType(pAttacker->GetFighter(), pCharTarget->GetFighter()) == eRT_DuelTargetWrong)
		{
			pCharAttacker->OnMagicCondFail(eDSR_DuelTargetWrong);
			return false;
		}
	}

	m_uAttackerID = uAttackerID;
	m_uTargetID = uTargetID;
	m_fReachGridDist = fReachGridDist;
	SetHandler(pHandler);
	m_bIsAutoTracking = true;
	m_bIsNormalAttackTracker = bIsNormalAttackTracker;
	m_posDest = CFPos(0.0f, 0.0f);
	//cout << "CAutoTracker::Init" << endl;
	pAttacker->RegistDistortedTick(this, GetTickTime());
	this->OnTick();
	return true;
}
Beispiel #12
0
static void MapTaskHandler(void)
{
#define SetHandler(NAME, HANDLER) self.handlers[LCUI_WTASK_##NAME] = HANDLER
	SetHandler(VISIBLE, Widget_UpdateVisibility);
	SetHandler(POSITION, Widget_UpdatePosition);
	SetHandler(RESIZE, Widget_UpdateSize);
	SetHandler(RESIZE_WITH_SURFACE, Widget_UpdateSizeWithSurface);
	SetHandler(SHADOW, Widget_UpdateBoxShadow);
	SetHandler(BORDER, Widget_UpdateBorder);
	SetHandler(OPACITY, Widget_UpdateOpacity);
	SetHandler(MARGIN, Widget_UpdateMargin);
	SetHandler(BODY, HandleBody);
	SetHandler(TITLE, HandleSetTitle);
	SetHandler(REFRESH, HandleRefresh);
	SetHandler(UPDATE_STYLE, HandleUpdateStyle);
	SetHandler(REFRESH_STYLE, HandleRefreshStyle);
	SetHandler(BACKGROUND, Widget_UpdateBackground);
	SetHandler(LAYOUT, Widget_ExecUpdateLayout);
	SetHandler(ZINDEX, Widget_ExecUpdateZIndex);
	SetHandler(DISPLAY, Widget_UpdateDisplay);
	SetHandler(PROPS, Widget_UpdateProps);
}
Beispiel #13
0
ECode CSAXResult::constructor(
    /* [in] */ IContentHandler* handler)
{
    return SetHandler(handler);
}
Beispiel #14
0
bool SDS(void)
{
  TRACEENTER();

  static dword              Timeout = 0;
  static tHookHandlerState  LastHHS = HHS_Exit;
  static dword              EF00FilterTimeout = 0;

  if(LastHHS != HookHandlerState)
  {
    switch(HookHandlerState)
    {
      case HHS_Init:                WriteLog("HHS_Init"); break;
      case HHS_Idle:                WriteLog("HHS_Idle"); break;
      case HHS_EF00Received:        WriteLog("HHS_EF00Received"); break;
      case HHS_PowerOffCancel:      WriteLog("HHS_PowerOffCancel"); break;
      case HHS_ShutdownTimerDiags:  WriteLog("HHS_ShutdownTimerDiags"); break;
      case HHS_Shutdown:            WriteLog("HHS_Shutdown"); break;
      case HHS_Exit:                WriteLog("HHS_Exit"); break;
    }
    LastHHS = HookHandlerState;
  }

  switch(HookHandlerState)
  {
    case HHS_Init:
    {
      char             *TAPFileName;
      tTAPInfo          TAPInfo;

      CreateRootDir();

      //Init some firmware routines
      if(!__DevFront_PowerOffReply)
      {
        __DevFront_PowerOffReply = (void*)FIS_fwDevFront_PowerOffReply();
        if(!__DevFront_PowerOffReply)
        {
          if(LastStatus != -1) WriteLog("Failed to resolve DevFront_PowerOffReply()");
          LastStatus = -1;
          HookHandlerState = HHS_Exit;

          TRACEEXIT();
          return FALSE;
        }
      }

      if(!__DevFront_PowerOffCancel)
      {
        __DevFront_PowerOffCancel = (void*)FIS_fwDevFront_PowerOffCancel();
        if(!__DevFront_PowerOffCancel)
        {
          if(LastStatus != -2) WriteLog("Failed to resolve DevFront_PowerOffCancel()");
          LastStatus = -2;
          HookHandlerState = HHS_Exit;

          TRACEEXIT();
          return FALSE;
        }
      }

      //Modify the handler pointer of the ef00 event queue
      if(!SetHandler(0xef00, Hooked_ApplEvent_CallHandler, (void*)&OrigHandler))
      {
        TRACEEXIT();
        return FALSE;
      }

      if(!LibInitialized && !InitTAPex())
      {
        TRACEEXIT();
        return FALSE;
      }

      if(HDD_TAP_GetFileNameByIndex(TAP_TableIndex, &TAPFileName))
      {
        if(!HDD_TAP_GetInfo(TAPFileName, &TAPInfo)) strcpy(TAPInfo.TAPName, "???");
      }
      else
        strcpy(TAPInfo.TAPName, "???");
      TAP_SPrint(Log, "SDS has been activated by '%s'", TAPInfo.TAPName);
      WriteLog(Log);

      HookHandlerState = HHS_Idle;
      break;
    }

    case HHS_Idle:
    {
      if(EF00FilterTimeout && TAP_GetTick() > EF00FilterTimeout) EF00FilterTimeout = 0;

      if(ShutdownHooked)
      {
        HookHandlerState = HHS_EF00Received;
        ShutdownHooked = FALSE;
      }
      break;
    }

    case HHS_EF00Received:
    {
      __DevFront_PowerOffReply();

      if(EF00FilterTimeout)
      {
        Timeout = TAP_GetTick() + 50;
        HookHandlerState = HHS_PowerOffCancel;
      }
      else
      {
        dword ret = HDD_TAP_SendEvent(0, TRUE, EVT_STOP, 2, 0);
        if(ret == 0)
        {
          if(LastStatus != -4) WriteLog("A TAP has intercepted the shutdown notfication");
          LastStatus = -4;
          Timeout = TAP_GetTick() + 50;
          HookHandlerState = HHS_PowerOffCancel;
        }
        else
        {
          HookHandlerState = HHS_ShutdownTimerDiags;
        }
      }

      break;
    }

    case HHS_PowerOffCancel:
    {
      if(TAP_GetTick() > Timeout)
      {
        if(LastStatus != -5) WriteLog("The shutdown has been canceled");
        LastStatus = -5;
        __DevFront_PowerOffCancel();
        EF00FilterTimeout = TAP_GetTick() + 200;
        HookHandlerState = HHS_Idle;
      }
      break;
    }

    case HHS_ShutdownTimerDiags:
    {
      if(LastStatus != -6) WriteLog("Notifiying TimerDiags about the shutdown");
      LastStatus = -6;
      HDD_TAP_SendEvent(0x8E0A4224, FALSE, EVT_STOP, 0, 0);
      Timeout = TAP_GetTick() + 200;
      HookHandlerState = HHS_Shutdown;
      break;
    }

    case HHS_Shutdown:
    {
      if(TAP_GetTick() > Timeout)
      {
        if(OrigHandler)
        {
          SetHandler(0xef00, OrigHandler, NULL);
          OrigHandler = NULL;
        }
        if(LastStatus != -7) WriteLog("Notifiying all TAPs about the shutdown");
        LastStatus = -7;
        HDD_TAP_SendEvent(0, FALSE, EVT_STOP, 0, 0);
        //TAP_Exit();
        if(LastStatus != -8) WriteLog("Enqueuing the shutdown event");
        LastStatus = -8;
        Shutdown(TaskPower);
        HookHandlerState = HHS_Exit;
      }
      break;
    }

    case HHS_Exit:
    {
      if(OrigHandler)
      {
        SetHandler(0xef00, OrigHandler, NULL);
        OrigHandler = NULL;
        if(LastStatus != -9) WriteLog("SDS has been deactivated");
        LastStatus = -9;
      }

      TRACEEXIT();
      return FALSE;
    }
  }

  TRACEEXIT();
  return TRUE;
}
Beispiel #15
0
main()
{
SetHandler(VBR+36*4,msg_S);//trap 4
SetHandler(VBR+37*4,msg_U);//trap 5

asm ("
    /* Transparent Translation Register
     * doc Motorola 3.1.3
     *
     * FFxxxxxx transparent
     * Enable
     * FC2 ignored (ok pour accès S ou U)
     * CM non cachable, serialized
     * R/W
     */
    move.l #0xff00c040,%d0
    movec.l %d0,%itt1
    movec.l %d0,%dtt1
    
    /* 
     * bloc 00xxxxxxxx transparent pour le mode S uniquement
     */
    move.l #0x0000a040,%d0
    movec.l %d0,%dtt0
    movec.l %d0,%itt0
    ");
    
    /*
     * table des descripteurs en 0x200000
     * 		- pour une seule page de 4 k à partir de 0x10000 : code + pile
     * 		(c'est la page n° 0,0,16)
     *		- pour la pile : une page avant 0x300000
     *		(c'est la page n° 0,11,63)
     */
InstallDescr(0,0,16);  
//InstallDescr(0,0,17);  
InstallDescr(0,11,63);  
//n m p
//p = (n°page % 8192) % 64 (si page de 4k)	0...63
//m = (n°page % 8192) / 64			0...127
//n = n°page / 8192				0...127
    asm("
    |instr. cache on, data cache on
    move.l #0x80008000,%a0
    movec.l %a0,%cacr
    move.l #0x200000,%a0
    movec.l %a0,%urp
    |vm Enable, page de 4k
    move.w #0x8000,%d0
    movec.l %d0,%tcr
    pflusha"
    );

test_S();
//passer en mode U
asm("
   move.l #0x300000,%a0
   |exemple avec une seule page
   |move.l #0x10000+4096,%a0
   move.l %a0,%usp
   move.w #0,%sr
   ");
   
test_U();
//il faudrait restorer le mode S pour terminer correctement
}
Beispiel #16
0
	void SetUp() override
	{
		SetHandler(&LogHandler);
	}
 Dialog(HelpHandler* h, Topic t = NO_HELP_TOPIC) 
        : Widget(0) 
 {
     SetHandler(h, t);
 }
Beispiel #18
0
Dialog::Dialog (HelpHandler* h,  Topic t) : Widget(0) {
    SetHandler(h, t);
}
Beispiel #19
0
void GTKToolButton::SetOnClicked(void *OnClickFunc, void *data)
{
	SetHandler("clicked", OnClickFunc, (data == NULL ? this : data));
}
Beispiel #20
0
void LuaEngine::Init(const char* main_script_file)
{
    Fini();
    int ret = 0;

    // TODO: 定时器个数采用宏配置
    heap_timer_ = new HeapTimer(1024);
    CHECK(heap_timer_ != NULL)
        << "timer heap init error!";

    master_state_ = luaL_newstate();
    CHECK(master_state_ != NULL)
        << "luaL_newstate error!";

    luaL_openlibs(master_state_);
    lua_tinker::init(master_state_);
    lua_tinker::init_s64(master_state_);
    lua_tinker::init_u64(master_state_);

    // 将script_main.lua所在文件夹路径加入require路径搜索
    char script_path[256] = {0};
    realpath(main_script_file, script_path);
    strncpy(script_path, dirname(script_path), 256);

    AddRequirePath(script_path);
    AddRequireCPath(script_path);

    // package.path 处理
    std::ostringstream oss_require;
    oss_require
        << "package.path = \"" << oss_require_path_.str() << "\"";

    ret = luaL_dostring(master_state_, oss_require.str().c_str());
    LOG(INFO) << "luaL_dostring [" << oss_require.str().c_str() << "]";
    CHECK(ret == 0)
        << "luaL_dostring [" << oss_require.str().c_str()
        << "] error!";

    oss_require.str("");
    oss_require_path_.str("");

    // package.cpath 处理
    oss_require
        << "package.cpath = \"" << oss_require_cpath_.str() << "\"";

    ret = luaL_dostring(master_state_, oss_require.str().c_str());
    LOG(INFO) << "luaL_dostring [" << oss_require.str().c_str() << "]";
    CHECK(ret == 0)
        << "luaL_dostring [" << oss_require.str().c_str()
        << "] error!";

    oss_require.str("");
    oss_require_cpath_.str("");

    // 设置LUA_SCRIPT_PATH
    SetGlobal("LUA_SCRIPT_PATH", script_path);

    // 注册log函数
    RegFunc("C_LOG_INFO", &LuaEngine::LogInfo);
    RegFunc("C_LOG_ERROR", &LuaEngine::LogError);
    // lua_tinker中日志函数
    RegFunc("_ALERT", &LuaEngine::LogInfo);

    ret = luaL_dofile(master_state_, main_script_file);
    if (ret != 0) {
        LOG(ERROR) << lua_tostring(master_state_, -1);
    }
    CHECK(ret == 0)
        << "luaL_dofile error!";

    // 第一次加载模块
    Reload();

    // 设置检查信号宏
    SetGlobal<int>("CHECK_SIG_OK", CHECK_SIG_OK);
    SetGlobal<int>("CHECK_SIG_TIMEOUT", CHECK_SIG_TIMEOUT);

    // 设置定时器
    SetHandler(this, &LuaEngine::OnTimer);
}