示例#1
0
tmrHw_INTERVAL_t tmrHw_setOneshotTimerInterval(tmrHw_ID_t timerId,	/*  [ IN ] Timer Id */
					       tmrHw_INTERVAL_t msec	/*  [ IN ] Interval in milli-second */
) {
	ResetTimer(timerId);

	/* Set timer mode oneshot */
	pTmrHw[timerId].Control |= tmrHw_CONTROL_PERIODIC;
	pTmrHw[timerId].Control |= tmrHw_CONTROL_ONESHOT;

	return SetTimerPeriod(timerId, msec);
}
bool CreatorTimer_Start(CreatorTimer self)
{
    bool result = false;
    if (self)
    {
        TimerInfo timerInfo = (TimerInfo)self;
        struct itimerspec timePeriod;
        SetTimerPeriod(timerInfo, &timePeriod);
        if (timer_settime(timerInfo->Timer, 0, &timePeriod, NULL) == 0)
        {
            result = true;
        }
    }
    return result;
}
bool CreatorTimer_SetPeriod(CreatorTimer self, uint periodInMilliseconds)
{
    bool result = false;
    if (self)
    {
        TimerInfo timerInfo = (TimerInfo)self;
        timerInfo->PeriodInMilliseconds = periodInMilliseconds;
        struct itimerspec timePeriod;
        SetTimerPeriod(timerInfo, &timePeriod);
        if (timer_settime(timerInfo->Timer, 0, &timePeriod, NULL) == 0)
        {
            result = true;
        }
    }
    return result;
}
示例#4
0
void MyApp::OnCmd(const char* pcCmd)
{
	FvRobotCfg::Result& kResult = FvRobotMainApp::Instance().DoCmd(pcCmd);

	if(kResult.empty())
		return;

	for(int i=0; i<(int)kResult.size(); ++i)
	{
		switch(kResult[i])
		{
		case FvRobotCfg::SingleMode:
			{
				m_bResetWindow4Space = true;
			}
			break;
		case FvRobotCfg::WindowSizeWidth:
			{
				m_iResetWindowSize |= 0x1;
			}
			break;
		case FvRobotCfg::WindowSizeHeight:
			{
				m_iResetWindowSize |= 0x2;
			}
			break;
		case FvRobotCfg::WindowFrameFreq:
			{
				SetFramePeriod(FvRobotCfg::Instance().GetWindowFramePeriod());
			}
			break;
		case FvRobotCfg::WindowTimerFreq:
			{
				SetTimerPeriod(FvRobotCfg::Instance().GetWindowTimerPeriod());
			}
			break;
		}
	}
}
示例#5
0
bool MyApp::Init(int argc, char* argv[])
{
	/////////////////////////////////////////////////////////////////////////////////
	Ogre::LogManager* pkLog(NULL);
	Ogre::ArchiveManager* pkArchive(NULL);
	Ogre::ResourceGroupManager* pkGroupManager(NULL);
	pkLog = OGRE_NEW Ogre::LogManager;
	pkArchive = OGRE_NEW Ogre::ArchiveManager;
	pkArchive->addArchiveFactory(OGRE_NEW Ogre::FileSystemArchiveFactory);
	pkGroupManager = OGRE_NEW Ogre::ResourceGroupManager;
#ifdef FV_SHIPPING
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../Data","FileSystem");
#else // FV_SHIPPING
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../Data","FileSystem");
#endif // !FV_SHIPPING

	/////////////////////////////////////////////////////////////////////////////////
	new FvRobotCfg();
	if(!FvRobotCfg::Instance().Init(argc, argv))
	{
		goto ERR;
	}
	SetWindowSize(FvRobotCfg::Instance().GetWindowSizeWidth(), FvRobotCfg::Instance().GetWindowSizeHeight());
	SetFramePeriod(FvRobotCfg::Instance().GetWindowFramePeriod());
	SetTimerPeriod(FvRobotCfg::Instance().GetWindowTimerPeriod());
	SetWindowTitle("RobotApp");

	/////////////////////////////////////////////////////////////////////////////////
	g_iShouldWriteToConsole = FvRobotCfg::Instance().GetShouldWriteToConsole();

	/////////////////////////////////////////////////////////////////////////////////
	{
		SYSTEMTIME nowTime;
		GetLocalTime(&nowTime);
		srand(nowTime.wMilliseconds);
		char logName[128] = {0};
		sprintf(logName, "Robot_%04d%02d%02d_%02d%02d%02d_%05u.log",
			nowTime.wYear, nowTime.wMonth, nowTime.wDay, nowTime.wHour, nowTime.wMinute, rand());
		m_pkMsgFile = new MessageFile(logName);
		m_pkMsgFile->OpenLog(FvRobotCfg::Instance().GetShouldWriteToLog());
		FvDebugFilter::Instance().AddMessageCallback(m_pkMsgFile);
	}

	/////////////////////////////////////////////////////////////////////////////////
	new FvLogicDllManager();
	if(!FvLogicDllManager::Instance().LoadDll(LOGICDLLNAME))
	{
		FV_ERROR_MSG( "main: Load dll(%s) failed.\n", LOGICDLLNAME);
		goto ERR;
	}

	/////////////////////////////////////////////////////////////////////////////////
	new FvRobotMainApp();
	new FvRobotSpaceDataManager();
	FvRobotMainApp::Instance().SetFileLog(m_pkMsgFile);
	if(!FvRobotMainApp::Instance().Init(argc, argv))
		goto ERR;

	return true;

	/////////////////////////////////////////////////////////////////////////////////
ERR:
	Clear();
	return false;
}