Exemplo n.º 1
0
/**
 Successive calls to Execute, but only one per RunL in order for
 the scheduler/ server to remain responsive.
 */
void CSsmCmdListExecutor::RunL()
	{
	if( iStatus != KErrNone )
		{
		// If a command (or the timer) has completed with an error code, terminate list 
		// processing and supply the error code to the server.
		iRunning = EFalse;
		//cancel all remaining commands
		for (; iCommandIndex < iCommandCount; iCommandIndex++)
			{
			iCommandList->ExecuteCancel(iCommandIndex);
			}
		iObserver.ListExecutionComplete( iStatus.Int(), iSessionIndex, iCommandList->Severity(iCommandIndex-1) );
		}
	else if( iCommandIndex < iCommandCount )
		{
		DoExecute();
		}
	else
		{
		// The last command must have completed.
		iRunning = EFalse;
		iObserver.ListExecutionComplete( iStatus.Int(), iSessionIndex, iCommandList->Severity(iCommandIndex-1) );
		}
	}
Exemplo n.º 2
0
/**
 * Execute our process and any executors
 */
void Process::Execute(unsigned year, const string& time_step_label) {
  for (auto executor : executors_[year][time_step_label])
    executor->PreExecute();

  DoExecute();

  for (auto executor : executors_[year][time_step_label])
    executor->Execute();
}
Exemplo n.º 3
0
void ThreadedDevice::Execute(Task* task, int thrid) {
  PreExecute();
#ifndef NDEBUG
  WallTimer memory_timer;
  memory_timer.Start();
#endif
  DataList input_shards;
  for (auto& i : task->inputs) {
    auto& input_data = i.physical_data;
    if (input_data.device_id == device_id_) {  // Input is local
      DLOG(INFO) << Name() << " input task data #" << i.id << " is local";
      CHECK_EQ(local_data_.Count(input_data.data_id), 1);
    } else {
      lock_guard<mutex> lck(copy_locks_[input_data.data_id]);
      if (!remote_data_.Count(input_data.data_id)) {  // Input is remote and not copied
        DLOG(INFO) << Name() << " input task data #" << i.id << " is remote and not copied";
        size_t size = input_data.size.Prod() * sizeof(float);
        auto ptr = data_store_->CreateData(input_data.data_id, size);
        DoCopyRemoteData(ptr, MinervaSystem::Instance().GetPtr(input_data.device_id, input_data.data_id).second, size, thrid);
        CHECK(remote_data_.Insert(input_data.data_id));
      }
    }
    input_shards.emplace_back(data_store_->GetData(input_data.data_id), input_data.size);
  }
  DataList output_shards;
  for (auto& i : task->outputs) {
    size_t size = i.physical_data.size.Prod() * sizeof(float);
    DLOG(INFO) << Name() << " create output for task data #" << i.id;
    auto ptr = data_store_->CreateData(i.physical_data.data_id, size);
    CHECK(local_data_.Insert(i.physical_data.data_id));
    output_shards.emplace_back(ptr, i.physical_data.size);
  }
  auto& op = task->op;
  CHECK(op.compute_fn);
  if(!FLAGS_no_execute) {
#ifndef NDEBUG
    Barrier(thrid);
    memory_timer.Stop();
    MinervaSystem::Instance().profiler().RecordTime(TimerType::kMemory, op.compute_fn->Name(), memory_timer);
    WallTimer calculate_timer;
    calculate_timer.Start();
#endif
    DLOG(INFO) << Name() << " execute task #" << task->id << ": " << op.compute_fn->Name();
    DoExecute(input_shards, output_shards, op, thrid);
    DLOG(INFO) << Name() << " finished execute task #" << task->id << ": " << op.compute_fn->Name();
#ifndef NDEBUG
    calculate_timer.Stop();
    MinervaSystem::Instance().profiler().RecordTime(TimerType::kCalculation, op.compute_fn->Name(), calculate_timer);
#endif
  }
  listener_->OnOperationComplete(task);
}
Exemplo n.º 4
0
void SchedulerBySeconds::Add(TimedObject *o, bool initialExecute) {
   cMutexLock lock(&schedulerMutex);
   list.push_back(o);
   havingObjects=true;
   o->SetExecutingTime();

   if (initialExecute)
      DoExecute(o);

   if (!running) {
      running=true;
      Start();
   } else
      sleepVar.Broadcast();
}
Exemplo n.º 5
0
//
/// Without displaying a dialog box, GetDefaultPrinter gets the device mode and name
/// that are initialized for the system default printer.
//
bool
TPrintDialog::GetDefaultPrinter()
{
  Pd.Flags |= PD_RETURNDEFAULT;
#if(WINVER >= 0x0500)
  int flags = Pde.Flags;
  Pde.Flags = PD_RETURNDEFAULT;
#endif
  Data.ClearDevMode();
  Data.ClearDevNames();
  int result = DoExecute();
#if(WINVER >= 0x0500)
  Pde.Flags = flags;
#endif
  return result == IDOK;
}
Exemplo n.º 6
0
void SchedulerBySeconds::Action() {
   while (running) {
   
      cMutexLock lock(&schedulerMutex);
      
      for (std::list<TimedObject *>::iterator it=list.begin(); it != list.end(); ++it) {
         if ((*it)->Check()) {
            (*it)->SetExecutingTime();
            DoExecute(*it);
         }
      }
      
      for (int i=0; (i<granularity) && running && havingObjects; i++)
         sleepVar.TimedWait(schedulerMutex, 1000);
      
      //suspend thread if no objects are scheduled
      if (!havingObjects)
         sleepVar.Wait(schedulerMutex);
   
   }
}
Exemplo n.º 7
0
bool	DumpRunner::Execute(Dumper* dumper, DumpLevel level,
							HANDLE process, DWORD processId,
							HANDLE thread, DWORD threadId,
							EXCEPTION_POINTERS* exception, const char* expression,
							const char* function, const char* file, unsigned int line)
{
	if (dumper == nullptr || exception == nullptr)
	{
		return false;
	}

	if (level == DumpLevel::DUMP_LEVEL_NONE)
	{
		return true;
	}

	bool outOfProcess = (::GetCurrentProcessId() == processId) ? false : true;
	if (outOfProcess == false)
	{
		bool stopSearch = false;
		if (dumpRunnerImpl.doExecuteThread(dumper, level,
										process, processId,
										thread, threadId,
										outOfProcess,
										exception, expression,
										function, file, line,
										&stopSearch) == true)
		{
			return stopSearch;
		}
	}

	return DoExecute(dumper, level,
					process, processId,
					thread, threadId,
					outOfProcess,
					exception, expression,
					function, file, line);
}
Exemplo n.º 8
0
bool SMFac :: Execute(const int iGroupIdx, const uint64_t llInstanceID, const std::string & sPaxosValue, SMCtx * poSMCtx)
{
    if (sPaxosValue.size() < sizeof(int))
    {
        PLErr("Value wrong, instanceid %lu size %zu", llInstanceID, sPaxosValue.size());
        //need do nothing, just skip
        return true;
    }

    int iSMID = 0;
    memcpy(&iSMID, sPaxosValue.data(), sizeof(int));

    if (iSMID == 0)
    {
        PLImp("Value no need to do sm, just skip, instanceid %lu", llInstanceID);
        return true;
    }

    if (m_vecSMList.size() == 0)
    {
        PLImp("No any sm, need wait sm, instanceid %lu", llInstanceID);
        return false;
    }

    for (auto & poSM : m_vecSMList)
    {
        if (poSM->SMID() == iSMID)
        {
            return DoExecute(poSM, iGroupIdx, llInstanceID, sPaxosValue, poSMCtx);
        }
    }

    PLErr("Unknown smid %d instanceid %lu", iSMID, llInstanceID);

    return false;
}
	DatabaseResultSPtr CDatabaseStatementOdbc::DoExecuteSelect()
	{
		DatabaseResultSPtr rs;
		DoExecute( rs );
		return rs;
	}
	bool CDatabaseStatementOdbc::DoExecuteUpdate()
	{
		DatabaseResultSPtr rs;
		return DoExecute( rs ) == EErrorType_NONE;
	}
Exemplo n.º 11
0
void SvnConsole::Execute(const wxString& cmd, const wxString& workingDirectory, SvnCommandHandler* handler, bool printProcessOutput)
{
    DoExecute(cmd, handler, workingDirectory, printProcessOutput);
}
Exemplo n.º 12
0
void SchedulerBySeconds::ExecuteNow(TimedObject *o) {
   cMutexLock lock(&schedulerMutex);
   o->SetExecutingTime();
   DoExecute(o);
}
Exemplo n.º 13
0
bool BusCalling_Process(uint16_t lenght)
{
  uint8_t pBuf[300];
  uint8_t result;
  
  //  if(Flag_Uart_Recv == 0) 
  //    return 1;
  
  if(Flag_Uart_Recv > RX_BUFSIZE)  //收到串口数据
    return false;
  
  memcpy(pBuf, RxBuffer, lenght);
  Flag_Uart_Recv = 0;
  
  //是否是启动定时发送命令
  if(lenght == 6)
  {
    if((pBuf[0]==0x4c) && (pBuf[1]==0x54))
      Begin_AI_Send = 1;
    
    memset(RxBuffer, 0, lenght);
    return true;
  }   
  
  //常规数据报文
  if(!HEADCHECK(RxBuffer[0], RxBuffer[1]))
    return false;
  
  if(!check_CRC(pBuf, lenght))
    return false;    
  
  //tyh:20150629 处理接收到的数据
  switch(pBuf[2])
  {
  case DO_EXE:  //遥控
    result = DoExecute(pBuf[3]);
    break;    
    
  case AI_COF:  //通道系数校准
    result = AiCoefProcess(pBuf[3]);
    break;
    
  case AI_CALB: //通全道系数自动校准
    result = AiCalibration();
    break;
    
  case AI_TIME: //对时
    result = TimeCalibration(&(pBuf[4]));
    break;    
    
  default:
    result = false;
    break;	          
  }
  
/* //tyh:后续需修改执行过程  hack 
  if(result)  //执行成功,回复'确认'
  {
    
  }
  else  //执行不成功,回复'否认'
  {
    
  }
*/  
  memset(RxBuffer, 0, lenght);
  
  return result;
}
Exemplo n.º 14
0
uint32_t CmdPwdAsserted(char *outputstr,T_MESSAGE *message)
{
  char *p;
  uint16_t bak_dr = 0;
  
  p=outputstr;  
  
  switch(message->m_type)
  {
  case CMD_DO:
    if( DoExecute((unsigned char)(message->m_intdata[0])) )  //执行成功
    {
#if LINGUA == EN  
      sprintf(outputstr,"DO Executed!Please Check the Di Change\r\n");
      p+=strlen("DO Executed!Please Check the Di Change\r\n");
#endif
      
#if LINGUA == CH  
      sprintf(outputstr,"遥控已操作,请查看遥信状态\r\n");
      p+=strlen("遥控已操作,请查看遥信状态\r\n");
#endif
    }
    else
    {     
      sprintf(outputstr,"总线状态异常,遥控执行失败!\r\n");
      p+=strlen("总线状态异常,遥控执行失败!\r\n");      
    }
    
    Shell_State=INIT;
    message->m_type=CMD_NULL;
    break;
    
  case CMD_SET:
  case CMD_COEF:
#if LINGUA == EN
    sprintf(outputstr,"Please Enter Item Resetting Parameter\r\n");     
    p+=strlen("Please Enter Item Resetting Parameter\r\n");
#endif 
#if LINGUA == CH
    sprintf(outputstr,"输入“通道序号 系数”\r\n");     
    p+=strlen("输入“通道序号 系数”\r\n");
#endif
    
    Shell_State=ENTER_DATA;
    break;
    
  case CMD_ADDR:
#if LINGUA == EN
    sprintf(outputstr,"Please Enter IP address\r\n");     
    p+=strlen("Please Enter IP address\r\n");
#endif
#if LINGUA == CH
    sprintf(outputstr,"输入IP地址\r\n");     
    p+=strlen("输入IP地址\r\n");
#endif
    
    Shell_State=ENTER_ADDR;
    break;  
    
  case CMD_CALB:
    Calibration();
    
#if LINGUA == EN  
    sprintf(outputstr,"Please Check the result of calibration\r\n");
    p+=strlen("Please Check the result of calibration\r\n");
#endif
#if LINGUA == CH  
    sprintf(outputstr,"校准完毕,核对遥测值\r\n");
    p+=strlen("校准完毕,核对遥测值\r\n");
#endif
    
    Shell_State=INIT;
    message->m_type=CMD_NULL;
    break;   
    
  case CMD_DCCAL:
    Can_Ticalib(CAN1);
    
#if LINGUA == EN  
    sprintf(outputstr,"Please Check the result of calibration\r\n");
    p+=strlen("Please Check the result of calibration\r\n");
#endif
#if LINGUA == CH  
    sprintf(outputstr,"标准源校准完毕,核对直流量\r\n");
    p+=strlen("标准源校准完毕,核对直流量\r\n");
#endif
    
    Shell_State=INIT;
    message->m_type=CMD_NULL;
    break;
    
  case CMD_PARA:
#if LINGUA == EN
    sprintf(outputstr,"Please Enter communiation settings\r\n");     
    p+=strlen("Please Enter communiation settings\r\n");
#endif
#if LINGUA == CH
    sprintf(outputstr,"输入通讯参数\r\n");     
    p+=strlen("输入通讯参数\r\n");
#endif
    
    Shell_State=ENTER_ADDR;
    break; 
    
    //TYH:添加恢復默认IP 
  case CMD_RESTOREIP:
    //infoNum = ShowInfo(outputstr, strRestoIP);   
    //p+=infoNum;
    sprintf(outputstr,"是否确认恢复默认IP, 确认请按<Y>, 按其它键返回\r\n");     
    p+=strlen("是否确认恢复默认IP, 确认请按<Y>, 按其它键返回\r\n");
    
    Shell_State=ENTER_RESTOREADDR;
    break;
    
    //TYH:20130508 恢复以太网 
  case CMD_RESET_ETH:
    //复位以太网
    Ethernet_HWRST();
    
    sprintf(outputstr,"是开始重置设备以太网,请等待.......\r\n");     
    p+=strlen("开始重置设备以太网,请等待.......\r\n");    
    
    Shell_State=INIT;
    message->m_type=CMD_NULL;
    break;
    
    //TYH:20130508 设置固件升级 
  case CMD_UPDATE_FIRMWARE:  
    //写备份寄存器 'KP_DR10', 用于启动升级固件
    bak_dr = BKP_ReadBackupRegister(BKP_DR10);
    if(bak_dr != 0x0707)
      BKP_WriteBackupRegister(BKP_DR10, 0x0707);    
    
    sprintf(outputstr,"bak_dr=0x%4x 设置固件升级, 请重启设备启动升级!\r\n", bak_dr);     
    p+=strlen("bak_dr=0xffff 设置固件升级, 请重启设备启动升级!\r\n");  
    
    Shell_State=INIT;
    message->m_type=CMD_NULL;    
    break;
    
    //TYH:20130530 设置以太网状态判断时间  
  case CMD_ETH_LINK_TIME:
  case CMD_ETH_RECV_TIME:
    sprintf(outputstr,"输入以太网判断时间参数\r\n");     
    p+=strlen("输入以太网判断时间参数\r\n");
    
    Shell_State=SET_ETH_TIME;
    break;    
    
  default:
    break;  
    
  }
  return (p-outputstr);	  
}
Exemplo n.º 15
0
void Di_PostWork(void)
{
  uint8_t i;
  
#ifdef SPECIALDITRIP
  for(i=0; i<NonElectro_Nbr; i++) //非电量跳闸
  {		 
    if(2 == DiStatus_DI[NonElectr_TripDi[i]-1].Value)
    {
      if(Trip_turnned[i]==0)
      {      
        if( DoExecute(NonElectr_TripMap[i]))
        {          
          //printlog("input%d occur",i-7);
          turnned[i]=1;
        }        
      }		  
    }
    else
    {
      Trip_turnned[i]=0;
    }
  }
/*  
  for(i=0;i<16;i++)
  {
    if(ON==DiStatus_DI[i].Value)
    {
      if(turnned[i]==OFF)
      {
        //soe_engine(i,ON);
        turnned[i]=ON;
      }		  
    }
    else if(OFF==DiStatus_DI[i].Value)
    {
      if(turnned[i]==ON)
      {
        //soe_engine(i,OFF);
        turnned[i]=OFF;
      }	
    }
  }
*/
#endif
  
//#ifdef FRONTDITRIP
//  for(i=0;i<NonElectro_Nbr;i++)
//  {
//    if(1==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==0)
//      {
//        if( DoExecute(NonElectr_TripMap[i]))
//        {          
//          //printlog("input%d occur",i-7);
//          turnned[i]=1;
//        }
//      }		  
//    }
//    else
//    {
//      turnned[i]=0;
//    }
//  }
//  
//  for(i=NonElectro_Nbr;i<16;i++)
//  {
//    if(ON==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==OFF)
//      {
//        //soe_engine(i,ON);
//        turnned[i]=ON;
//      }		  
//    }
//    else if(OFF==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==ON)
//      {
//        //soe_engine(i,OFF);
//        turnned[i]=OFF;
//      }	
//    }
//  }
//#endif
//  
//#ifdef REARDITRIP
//  for(i=16-NonElectro_Nbr;i<16;i++)
//  {
//    if(1==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==0)
//      {
//        if( DoExecute(NonElectr_TripMap[i]) )
//        {
//          //printlog("input%d occur",i-7);
//          turnned[i]=1;
//        }
//      }		  
//    }
//    else
//    {
//      turnned[i]=0;
//    }
//  }
//  for(i=0;i<16-NonElectro_Nbr;i++)
//  {
//    if(ON==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==OFF)
//      {
//        //soe_engine(i,ON);
//        turnned[i]=ON;
//      }		  
//    }
//    else if(OFF==DiStatus_DI[i].Value)
//    {
//      if(turnned[i]==ON)
//      {
//        //soe_engine(i,OFF);
//        turnned[i]=OFF;
//      }	
//    }
//  }
//#endif
}
Exemplo n.º 16
0
DLLExport MACPASCAL void PluginMain (const int16 selector,
						             PISelectionParams *selectionParamBlock,
						             intptr_t *data,
						             int16 *result)
{

	try {

	//---------------------------------------------------------------------------
	//	(1) Check for about box request.
	//
	// 	The about box is a special request; the parameter block is not filled
	// 	out, none of the callbacks or standard data is available.  Instead,
	// 	the parameter block points to an AboutRecord, which is used
	// 	on Windows.
	//---------------------------------------------------------------------------

	if (selector == selectionSelectorAbout)
	{
		sSPBasic = ((AboutRecordPtr)selectionParamBlock)->sSPBasic;
		DoAbout((AboutRecordPtr)selectionParamBlock);
	}
	else
	{ // do the rest of the process as normal:

		sSPBasic = ((PISelectionParams*)selectionParamBlock)->sSPBasic;

		Ptr globalPtr = NULL;		// Pointer for global structure
		GPtr globals = NULL; 		// actual globals

		//-----------------------------------------------------------------------
		//	(2) Allocate and initalize globals.
		//
		// 	AllocateGlobals requires the pointer to result, the pointer to the
		// 	parameter block, a pointer to the handle procs, the size of our local
		// 	"Globals" structure, a pointer to the long *data, a Function
		// 	Proc (FProcP) to the InitGlobals routine.  It automatically sets-up,
		// 	initializes the globals (if necessary), results result to 0, and
		// 	returns with a valid pointer to the locked globals handle or NULL.
		//-----------------------------------------------------------------------
		
		globalPtr = AllocateGlobals (result,
									 selectionParamBlock,
									 selectionParamBlock->handleProcs,
									 sizeof(Globals),
						 			 data,
						 			 InitGlobals);
		
		if (globalPtr == NULL)
		{ // Something bad happened if we couldn't allocate our pointer.
		  // Fortunately, everything's already been cleaned up,
		  // so all we have to do is report an error.
		  
		  *result = memFullErr;
		  return;
		}
		
		// Get our "globals" variable assigned as a Global Pointer struct with the
		// data we've returned:
		globals = (GPtr)globalPtr;

		//-----------------------------------------------------------------------
		//	(3) Dispatch selector.
		//-----------------------------------------------------------------------

		DoExecute(globals);
			
		//-----------------------------------------------------------------------
		//	(4) Unlock data, and exit resource.
		//
		//	Result is automatically returned in *result, which is
		//	pointed to by gResult.
		//-----------------------------------------------------------------------	
		
		// unlock handle pointing to parameter block and data so it can move
		// if memory gets shuffled:
		if ((Handle)*data != NULL)
			PIUnlockHandle((Handle)*data);
	
	} // about selector special		
	
	} // end try

	catch(...)
	{
		if (NULL != result)
		{
			*result = -1;
		}
	}

} // end PluginMain
Exemplo n.º 17
0
void SvnConsole::ExecuteURL(const wxString& cmd, const wxString& url, SvnCommandHandler* handler, bool printProcessOutput)
{
    DoExecute(cmd, handler, wxT(""), printProcessOutput);
    m_url = url;
}