示例#1
0
int XttVideoMgmAimetis::check_session()
{
  pwr_tTime current;
  pwr_tDeltaTime timeout = {300,0};
  pwr_tDeltaTime dt;
  int sts = 1;

  // Check that current session hasn't timed out
  time_GetTime( &current);
  time_Adiff_NE( &dt, &current, &m_last_auth); 
  if ( time_Dcomp( &dt, &timeout) == 1)
    sts = authorize( m_op->User, m_op->Password);

  return sts;
}
示例#2
0
void sev_valuecache_double::add( void *value, pwr_tTime *t)
{
  double val = *(double *)value;
  double time;
  pwr_tDeltaTime dt;

  time_Adiff_NE( &dt, t, &m_start_time);
  time = time_DToFloat64( 0, &dt);

  // Store optimized write index before adding
  m_last_opt_write = get_optimal_write();

  bool update_k = m_length < m_size;
  if ( !m_length) {
    m_val[0].val = val;
    m_val[0].time = time;
    m_length++;
  }
  else {
    if ( ++m_last >= m_size)
      m_last -= m_size;
    m_val[m_last].val = val;
    m_val[m_last].time = time;
    m_length++;
    if ( m_last == m_first) {
      m_first++;
      if ( m_first >= m_size)
	m_first -= m_size;	 
      m_length--;
    }
  }
  if ( !m_inited) {
    write( 0);
    m_inited = true;
    return;
  }

  if ( update_k) {
    calculate_k();
    // Update epsilon for all data
    calculate_epsilon();
  }
  else 
    calculate_epsilon(0);
}