示例#1
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void Test::StartTest(void)
{
	IedDb.TestState = T_INIT;
	SuspendTask(TASK_MANUAL);
	SuspendTask(TASK_METAGE);
	ActiveTask(TASK_TEST,PRIOD_TEST);
}
示例#2
0
文件: Timer.cpp 项目: lilothar/walle
bool Timer::insert(TimerTask* task)
{
  _loop->assertInLoopThread();
  assert(_tasks.size() == _activeTasks.size());
  bool earliestChanged = false;
  Time when = task->expiration();
  TaskList::iterator it = _tasks.begin();
  if (it == _tasks.end() || when < it->first)
  {
    earliestChanged = true;
  }
  {
    std::pair<TaskList::iterator, bool> result
      = _tasks.insert(Entry(when, task));
    assert(result.second); (void)result;
  }
  {
    std::pair<ActiveTaskSet::iterator, bool> result
      = _activeTasks.insert(ActiveTask(task, task->sequence()));
    assert(result.second); (void)result;
  }

  assert(_tasks.size() == _activeTasks.size());
  return earliestChanged;
}
示例#3
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void ResetSystem(void)
{ 
    LowTempStove.SetMinRunTimer();
    LeftHighTempStove.SetMaxRunTimer();
    RightHighTempStove.SetMaxRunTimer(); 
    IedDb.ResetState    = REST_START;	
    IedDb.MetageState   = Metage::M_INIT;
    ActiveTask(TASK_RESET,100L); 	//系统复位
} 
示例#4
0
CGameTask*	CGameTaskManager::GiveGameTaskToActor(CGameTask* t, u32 timeToComplete, bool bCheckExisting)
{
	if(bCheckExisting && HasGameTask(t->m_ID)) return NULL;
	m_flags.set					(eChanged, TRUE);

	GameTasks().push_back				(SGameTaskKey(t->m_ID) );
	GameTasks().back().game_task			= t;
	t->m_ReceiveTime				= Level().GetGameTime();
	t->m_TimeToComplete				= t->m_ReceiveTime + timeToComplete;

	
	std::sort						(GameTasks().begin(), GameTasks().end(), task_prio_pred);

	ARTICLE_VECTOR& article_vector = Actor()->encyclopedia_registry->registry().objects();


	SGameTaskObjective	*obj = NULL;
	for (u32 i = 0; i < t->m_Objectives.size(); ++i){
		obj = &t->m_Objectives[i];
		if(obj->article_id.size()){
		FindArticleByIDPred pred(obj->article_id);
		if( std::find_if(article_vector.begin(), article_vector.end(), pred) == article_vector.end() ){
			CEncyclopediaArticle article;
			article.Load(obj->article_id);
			article_vector.push_back(ARTICLE_DATA(obj->article_id, Level().GetGameTime(), article.data()->articleType));
			}
		}

		if(obj->object_id!=u16(-1) && obj->map_location.size() && obj->def_location_enabled){
			CMapLocation* ml =	Level().MapManager().AddMapLocation(obj->map_location, obj->object_id);
			if(obj->map_hint.size())	ml->SetHint(obj->map_hint);
			ml->DisablePointer			();
			ml->SetSerializable			(true);
		}
	}
	CGameTask* _at = ActiveTask();
	if	( (NULL==_at) || (_at->m_priority > t->m_priority) )
	{
		SetActiveTask(t->m_ID, 1);
	}


	//установить флажок необходимости прочтения тасков в PDA
	if(HUD().GetUI()){
		CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
		if(pGameSP) 
			pGameSP->PdaMenu->PdaContentsChanged	(pda_section::quests);
	}
	if(true /*t->m_ID!="user_task"*/)
		t->Objective(0).ChangeStateCallback();

	return t;
}
示例#5
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void TaskReset(void)
{ 

	switch(IedDb.ResetState)
	{
		case REST_START:								 
			SuspendTask(TASK_MANUAL);		  	////停止手动进位任务
			CtrlOxygenValve(false);				//关闭气阀
            CtrlNitrogenValve(false);
			StopAllFan(); 
			StepMotor[0].StopMotor();
			LowTempStove.StopStoveBar();
			LeftHighTempStove.StopStoveBar();
			RightHighTempStove.StopStoveBar();
			////////////////////////////////////////////////////////////
			//将左右炉移动至底位,样盘上升至称样位																		 
			LowTempStove.MoveStoveBar(LowVertStoveBar::POS_TOP);
			LeftHighTempStove.MoveStoveBar(HighVertStoveBar::POS_BOT);
			RightHighTempStove.MoveStoveBar(HighVertStoveBar::POS_BOT);
			//
		   	IedDb.ResetState = REST_SAMPLEDISH;
			break;
		case REST_SAMPLEDISH:
			if( //中间炉子到位
                //(LowTempStove.m_StovePos==VertStoveBar::POS_TOP)
                (LowTempStove.GetTopOpto() == 0)
                &&(LowTempStove.GetBotOpto() == 1))
                {
                    if((IedDb.DownloadWorkParam.m_szSystemType==G5000)
                        ||((LeftHighTempStove.m_StovePos==HighVertStoveBar::POS_BOT)
                    &&(RightHighTempStove.m_StovePos==HighVertStoveBar::POS_BOT)))
                    {
                        StepMotor[0].MoveStepMotor(1);
                        IedDb.ResetState = REST_END;
                    } 
				}
			break;
		case REST_END:
			if(IedDb.MtrState.CurSamplePos==1)
			{
				SuspendTask(TASK_RESET);		
	            ActiveTask(TASK_MANUAL,20L);       //启动手动进位
			}
			break;
		default:
			IedDb.ResetState = REST_START;
			break;
	}
}
示例#6
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void Metage::StartMetage(METAGE_TYPE type,METAGE_SPEED speed)
{
	metagType 	= type;
	metagSpeed  = speed;
	
    if(type==T_POT)
    {
        ClearMetageFlag ();
        IedDb.TestState = Test::T_INIT;
    }
	m_cSchedule = &IedDb.MetageState;
	*m_cSchedule = M_INIT;
	MAX_SAMPLE	= &IedDb.DownloadWorkParam.m_btMaxSampleCnt;
	ActiveTask(TASK_METAGE,1000L);
	
}
示例#7
0
void CGameTaskManager::SetTaskState(CGameTask* t, u16 objective_num, ETaskState state)
{
	m_flags.set						(eChanged, TRUE);
	bool isRoot =					(objective_num==0);
	SGameTaskObjective* o			= &t->Objective(objective_num);

	CMapLocation* ml				= o->LinkedMapLocation();
	bool bActive					= ActiveObjective()==o;

	if(((state==eTaskStateFail)||(state==eTaskStateCompleted)) && ml ){
		Level().MapManager().RemoveMapLocation(o->map_location, o->object_id);
		o->map_location				= NULL;
		o->object_id				= u16(-1);
	}

	o->SetTaskState					(state);
	
	//highlight next objective if needed
	if( (isRoot || !t->HasInProgressObjective()) && (ActiveTask()==t) )
	{
		SetActiveTask					("", 1 );
	}else
		if(!isRoot && bActive && objective_num != (t->m_Objectives.size()-1) ){//not last
			SetActiveTask					(t->m_ID, objective_num+1 );
		}


	if(isRoot){//setState for task and all sub-tasks
		
		for(u16 i=0; i<t->m_Objectives.size();++i)
			if( t->Objective(i).TaskState()==eTaskStateInProgress )
				SetTaskState(t,i,state);
	}
	
	if(0 == objective_num && eTaskStateCompleted == state || eTaskStateFail == state)
		t->m_FinishTime = Level().GetGameTime();


	CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
	if(pGameSP) {
		pGameSP->PdaMenu->PdaContentsChanged	(pda_section::quests);
	}

}
示例#8
0
SGameTaskObjective* CGameTaskManager::ActiveObjective()
{
	CGameTask*		t			= ActiveTask();
	
	return (t)?&t->Objective(g_active_task_objective_id):NULL;
}
示例#9
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void Metage::TaskMetage(void)
{   
	long l;
	IED_DATABASE::YP_DATA *Sample = &IedDb.Sample1[0];	   
	MetagePtr = &Sample[m_cPos-1].UQuality.Q[metagType];
		
	int MetageBit = MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lMPot?S_WEIGHT_POT:  //置当前状态:正在称坩埚或称样
					MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lM0?S_WEIGHT_SAMPLE:
					MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lM1?S_TEST_WATER:
					MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lMPotSample2?S_WEIGHT_COVER:
					MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lM2?S_TEST_VOL:
					MetagePtr==&Sample[m_cPos-1].UQuality.SQuality.lM3?S_TEST_ASH:S_TEST_ASH+1;

	gcKey=GetKey();
	
    switch(*m_cSchedule)
    {
    case M_INIT:    //初始化
		ResetSystem();
        m_cMDelay=0;   
        m_cPos=1;
        *m_cSchedule=M_POS;
        break;
 
    case M_POS:     //移动炉子到称样位
		SuspendTask(TASK_MANUAL);       //停止手动进位
        if((m_cPos==IedDb.MtrState.CurSamplePos) &&
			(0==IedDb.MtrState.bRun)&& 
			(LowTempStove.m_StovePos==LowVertStoveBar::POS_TOP)&&
            ((IedDb.DownloadWorkParam.m_szSystemType==G5000)||
			((LeftHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT)&&
			(RightHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT))))//判位置			
        {
            //if(IedDb.Sample1[m_cPos-1].cSta>S_NULL)   //有样
			if(Sample[m_cPos-1].cSta&(1<<MetageBit))
            { 
                m_cMDelay	= 0;
				m_cDelayCnt	= 0;
				MTBalan.ZeroWeight();		//清0
                *m_cSchedule=M_TARE;		
				//TODO:清除目标位置重量数据
            }
            else
            {                                //无样
                *m_cSchedule=M_NEXTPOS;
            }
        }
        break;	    
    case M_TARE:
        l=MTBalan.GetBalanceAvr();
        if((l>-BALANCE_ZERO && l<BALANCE_ZERO)||m_cDelayCnt>MAX_WEIGHTING_CNT)	 //除皮成功或者除皮次数超过规定次数
        {											  
			LowTempStove.MoveStoveBar(LowVertStoveBar::POS_BOT); //移动炉子到称样位置
			*m_cSchedule=M_METAGE;
			m_cDelayCnt = 0;
            m_cMDelay=0;
        }
        else if(m_cMDelay++>TARE_DELAY)	  //不稳定,再次清零
        { 						 
            BeepBalErr();               //除皮不稳定,提醒一次	
			MTBalan.ZeroWeight();		//清0
			m_cMDelay=0;
			m_cDelayCnt ++;
        }
        break;
		
    case M_METAGE:  //称量
        if((LowTempStove.m_StovePos==LOW_POS_BOT)&&
            ((IedDb.DownloadWorkParam.m_szSystemType==G5000)||
			((LeftHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT)&&
			(RightHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT))))//判位置
        {		
			//称的不是样重,或者快速称样,或者确认,进入保存重量环节 	  	
            if(((metagType==T_SAMPLE)&&(gcKey==KEY_ENT))||(T_QUICK==metagSpeed)||(metagType!=T_SAMPLE))
			{
                *m_cSchedule=M_SAVE;		   
				if(KEY_ENT==gcKey)
				{ 
                    m_cMDelay = M_DELAY;
                    BeepOK();
				}
			}
			m_cMDelay ++;
			//TODO:增加称样时到达重量范围内的提示音
        }
        break;
	case M_SAVE:
	    if(m_cMDelay++>M_DELAY)              //延时M_DELAY后存数
		{
			m_cMDelay=M_DELAY-2;
			m_cDelayCnt++;
            if((MTBalan.BalanceMaxErr(METAGE_MAXERR))||m_cDelayCnt>MAX_WEIGHTING_CNT)		//增加称样超时
            {						
                *MetagePtr= MTBalan.GetBalanceAvr(); //存坩埚质量	
				if(m_cDelayCnt>MAX_WEIGHTING_CNT)	
				{   
                    BeepBalErr(); 
					//*MetagePtr= IedDb.buf.CurrWeight; //存坩埚不稳定质量
				}					    
								
				LowTempStove.MoveStoveBar(LOW_POS_BOT); //移动炉子到放样位置	  
                m_cDelayCnt = 0;       	

				setbit(Sample[m_cPos-1].cCSta,MetageBit);		 
				*m_cSchedule=M_NEXTPOS;
			}
        }
		break;	
    case M_NEXTPOS: //转到下一个样位
      if((LowTempStove.m_StovePos==LOW_POS_TOP)&&
            ((IedDb.DownloadWorkParam.m_szSystemType==G5000)||
			((LeftHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT)&&
			(RightHighTempStove.m_StovePos==LowVertStoveBar::POS_BOT))))//判位置
        {										 
			while(m_cPos<*MAX_SAMPLE)
            {										
                //有坩埚,该位有上位机下载下来,只要有一个实验项目就会有	    					  
                // 是否称量该重量,由是否做该实验决定	  
				if(Sample[m_cPos].cSta&(1<<MetageBit))
                {
					m_cPos++;
					m_cMDelay = 0;
                    StepMotor[0].MoveStepMotor(m_cPos);     //转到下个样位	   
                    *m_cSchedule=M_POS;
                    return;
                }
				m_cPos++;
            }
			
            StepMotor[0].MoveStepMotor(1);           //转到1st样位
            *m_cSchedule=M_END;
			__NOP();
        }
        break;
		
    case M_END:
        m_cPos=1;                    //完成,复位 
        SuspendTask(TASK_METAGE);                   //停止“称量”任务
        ActiveTask(TASK_MANUAL,100L);               //启动手动进位
        beep.beep(2,1000L);                         //称量完毕,提示音            
        break;	 
    }	  
}
示例#10
0
文件: TEST.CPP 项目: eseawind/Gyfxy
void Test::BurnSample(BURN_SAMPLE_TYPE sampleType)
{    
    m_burnState     = B_INIT  ;    //烧样品状态;
    m_burnType      = sampleType;     //烧样类型
    ActiveTask(TASK_BURN,1000L);
}