bool
CorrelationTimeArcGrbcat::doParse(type::CorrelationCmdType cmd, std::list<std::string>& tokens)
{
  switch (cmd)
  {
    default:
      break;
  }

  tokens.clear();

  const Catalog* catalog = AnalysisData::instance()->getCatalogData();

  auto minEntry = std::min_element(catalog->getEntries().begin(), catalog->getEntries().end(),
                                   CompareTime());
  auto maxEntry = std::max_element(catalog->getEntries().begin(), catalog->getEntries().end(),
                                   CompareTime());

  type::Float range = std::ceil((getTime(*maxEntry) - getTime(*minEntry)) / 365.0) * 365.0;

  if (setXAxis(range, 365))
  {
    Exception exc(type::EXCEPTION_WARNING + type::EXCEPTION_MOD_NO_PREFIX,
                  "CorrelationTimeArcGrbcat failed to set correlation x axis.\n");
    throw exc;
  }
  setYAxis(M_PIl, 180);

  return true;
}
Exemplo n.º 2
0
MasterSchedulerBackend::Comparison MasterSchedulerBackend::GetBestTaskToRun(const openpal::MonotonicTimestamp& now,
                                                                            const Record& left,
                                                                            const Record& right)
{
    const auto BEST_ENABLED_STATUS = CompareEnabledStatus(left, right);

    if (BEST_ENABLED_STATUS != Comparison::SAME)
    {
        // if one task is disabled, return the other task
        return BEST_ENABLED_STATUS;
    }

    const auto BEST_BLOCKED_STATUS = CompareBlockedStatus(left, right);

    if (BEST_BLOCKED_STATUS != Comparison::SAME)
    {
        // if one task is blocked and the other isn't, return the unblocked task
        return BEST_BLOCKED_STATUS;
    }

    const auto EARLIEST_EXPIRATION = CompareTime(now, left, right);
    const auto BEST_PRIORITY = ComparePriority(left, right);

    // if the expiration times are the same, break based on priority, otherwise go with the expiration time
    return (EARLIEST_EXPIRATION == Comparison::SAME) ? BEST_PRIORITY : EARLIEST_EXPIRATION;
}
Exemplo n.º 3
0
void C_AreaEvent::PushEvent( Poco::Net::StreamSocket& sktClient, LPCTSTR pszMac )
{
	m_PushedVecMutex.lock();
	for (EventList::iterator it = m_vecPushedEvent.begin(); it != m_vecPushedEvent.end(); )
	{
		if(CompareTime((*it)->szEndTime.c_str() , GetCurrTime().c_str()) < 0)
			it = m_vecPushedEvent.erase(it);
		else
			++it;
	}
	m_PushedVecMutex.unlock();

	tstring szAreaid = m_DBOperate.GetAreaidByMac(pszMac);
	if(szAreaid.compare(_T("")) == 0)
		return;

	m_PushedVecMutex.lock();
	for (EventList::iterator itor = m_vecPushedEvent.begin(); itor != m_vecPushedEvent.end(); ++itor)
	{
		if((*itor)->szAreaId == szAreaid)
		{
			tstring szJson = GetJsonText(*itor);
			sktClient.sendBytes(szJson.c_str(), szJson.length());
		}
	}
	m_PushedVecMutex.unlock();
}
Exemplo n.º 4
0
 ///////////////////////////////////////////////////////////////////////
 // Function: CompareTimeMillisecond
 //
 //   Author: $author$
 //     Date: 6/27/2009
 ///////////////////////////////////////////////////////////////////////
 virtual int CompareTimeMillisecond
 (const EvTime& time,
  bool is12=false,
  bool isPM=false,
  bool isLocal=false,
  const EvTimezone* timezone=0) const 
 {
     int unequal = 0;
     if (!(unequal = CompareTime
         (time, is12, isPM, isLocal, timezone)))
         unequal = CompareMillisecond(time.GetMillisecond());
     return unequal;
 }
Exemplo n.º 5
0
// first	: 추교성. 2004. 11. 08
// last		: 추교성. 2004. 11. 08
// 변동이 거의 업는 정적 스케쥴 업데이트.
void MMatchScheduleMgr::UpdateStaticSchedule()
{
	MCommand* pCmd = 0;
	ScheduleVecIter it, end;

	end = m_vecStaticSchedule.end();
	for( it = m_vecStaticSchedule.begin(); it != end; ++it ){
		// 실행될 시간인가?
		if( !CompareTime((*it)) ) continue;

		pCmd = (*it)->GetCommand()->Clone();
		if( 0 != pCmd ){
			m_pMatchServer->GetCommandManager()->Post( pCmd );
		}

		// 혹시 지울 것인가?
		// 정적 스케쥴이 IsNeedDelete()이 true면 날자만 업데이트 하지 않아 실행되는것을 막음.
		if( (*it)->IsNeedDelete() ) continue;

		(*it)->GetImpl()->Reset( (*it) );
	}
}
Exemplo n.º 6
0
Arquivo: File.cpp Projeto: yagi/satori
/*----------------------------------------------------------------------
	ファイルの更新日時を比較。
	返値が正ならば前者、負ならば後者のほうが新しいファイル。
----------------------------------------------------------------------*/
int	CompareTime(LPCSTR szL, LPCSTR szR) {
    assert(szL!=NULL && szR!=NULL);

    SYSTEMTIME	stL, stR;
    BOOL		fexistL, fexistR;

    // 更新日付を得る。
    fexistL = GetLastWriteTime(szL, stL);
    fexistR	= GetLastWriteTime(szR, stR);
    // 存在しないファイルは「古い」と見なす。
    if ( fexistL ) {
        if ( !fexistR)
            return	1;
    } else {
        if ( fexistR )
            return	-1;
        else
            return	0;	// どっちもありゃしねぇ
    }

    // 最終更新日付を比較
    return	CompareTime(stL, stR);
}
Exemplo n.º 7
0
// first	: 추교성. 2004. 11. 08
// last		: 추교성. 2004. 11. 08
// 공지사항 스케쥴 업데이트.
void MMatchScheduleMgr::UpdateAnnounceSchedule()
{
	MCommand* pCmd = 0;
	ScheduleLstIter it, end;

	end = m_lstAnnounceSchedule.end();
	for( it = m_lstAnnounceSchedule.begin(); it != end; ++it ){
		if( !CompareTime((*it)) ) continue;

		pCmd = (*it)->GetCommand()->Clone();
		if( 0 != pCmd ){
			m_pMatchServer->GetCommandManager()->Post( pCmd );
		}

		// 이번이 지울 차례인가?
		if( (*it)->IsNeedDelete() ){
			m_lstAnnounceSchedule.erase( it-- );
			continue;
		}

		(*it)->GetImpl()->Reset( (*it) );
	}
}
Exemplo n.º 8
0
void C_AreaEvent::DoUpdateEventList()
{
	while (::WaitForSingleObject(m_hStopEvent, 0) != WAIT_OBJECT_0)
	{
		m_PushVecMutex.lock();
		for (EventList::iterator it = m_vecEventList.begin(); it != m_vecEventList.end();)
		{
			tstring szAreaid = (*it)->szAreaId;
			tstring szStartTime = (*it)->szStartTime;

			if(CompareTime(szStartTime.c_str(), GetCurrTime().c_str()) <= 0 )
			{
				tstring szJson = GetJsonText(*it);
				StringVector vecMacList;
				m_DBOperate.GetMacListByAreaid(vecMacList, szAreaid.c_str());

				for (StringVector::iterator itor = vecMacList.begin(); itor != vecMacList.end(); ++itor)
				{
					Poco::Net::StreamSocket* psktClient = C_ClientMac2Socket::GetInstance()->FindSocketByMacAddr((*itor).c_str());
					if (psktClient != NULL)
						psktClient->sendBytes(szJson.c_str(), szJson.length());
				}
				m_PushedVecMutex.lock();
				m_vecPushedEvent.push_back(*it);
				m_PushedVecMutex.unlock();

				it = m_vecEventList.erase(it);
			}
			else
				++it;
		}
		m_PushVecMutex.unlock();

		Sleep(10000);//10s
	}
}
Exemplo n.º 9
0
int
VerifyState(const Options &opts, const ReadUserLog::FileState &state )
{
    ReadUserLogState	rstate( state, 60 );
    const ReadUserLogState::FileState	*istate;
    ReadUserLogState::convertState( state, istate );

    const FieldData	*wdata = opts.getField( );
    if ( wdata == NULL ) {
        fprintf( stderr, "Verify: no field!\n" );
        return -1;
    }

    bool	ok;
    switch( wdata->m_field )
    {
    case FIELD_SIGNATURE:
        ok = CompareStr( opts, istate->m_signature );
        break;

    case FIELD_VERSION:
        ok = CompareInt( opts, istate->m_version );
        break;

    case FIELD_UPDATE_TIME:
        ok = CompareTime( opts, istate->m_update_time );
        break;

    case FIELD_BASE_PATH:
        ok = CompareStr( opts, istate->m_base_path );
        break;

    case FIELD_CUR_PATH:
        ok = CompareStr( opts, rstate.CurPath(state) );
        break;

    case FIELD_UNIQ_ID:
        ok = CompareStr( opts, istate->m_uniq_id );
        break;

    case FIELD_SEQUENCE:
        ok = CompareInt( opts, istate->m_sequence );
        break;

    case FIELD_MAX_ROTATION:
        ok = CompareInt( opts, istate->m_max_rotations );
        break;

    case FIELD_ROTATION:
        ok = CompareInt( opts, istate->m_rotation );
        break;

    case FIELD_OFFSET:
        ok = CompareFsize( opts, istate->m_offset.asint );
        break;

    case FIELD_EVENT_NUM:
        ok = CompareFsize( opts, istate->m_event_num.asint );
        break;

    case FIELD_GLOBAL_POSITION:
        ok = CompareFsize( opts, istate->m_log_position.asint );
        break;

    case FIELD_GLOBAL_RECORD_NUM:
        ok = CompareFsize( opts, istate->m_log_record.asint );
        break;

    case FIELD_INODE:
        ok = CompareInode( opts, istate->m_inode );
        break;

    case FIELD_CTIME:
        ok = CompareTime( opts, istate->m_ctime );
        break;

    case FIELD_SIZE:
        ok = CompareFsize( opts, istate->m_size.asint );
        break;

    default:
        return -1;
    }
    return ok ? 0 : 1;
}
Exemplo n.º 10
0
int SensorDataTime::Compare(AlgSortObj* p) {
    SensorData* temp1 = (SensorData*)obj;
    SensorData* temp2 = (SensorData*)(p->Getobj());
    int r = CompareTime(temp1->Gettime(),temp2->Gettime());
    return r;
}
Exemplo n.º 11
0
void SensorDataTime::Decreasekey(Time k) {
    if (CompareTime(((SensorData*)obj)->Gettime(),k) <= 0) return;
    else Setkey(k);
}