float Plan::getETA(void) const { if (m_progress >= 0.0) return getTotalDuration() * (1.0 - 0.01 * m_progress); else return -1.0; }
int CacheHttp_GetBuffedTime(void * handle) { if(!handle) return AVERROR(EIO); CacheHttpContext * s = (CacheHttpContext *)handle; int64_t buffed_time=0; //av_log(NULL, AV_LOG_ERROR, "---------- 000 CacheHttp_GetBufferedTime s->item_size=%lld", s->item_size); if(s->item_duration>= 0 && s->item_size > 0) { buffed_time = s->item_starttime+s->item_pos*s->item_duration/s->item_size; // av_log(NULL, AV_LOG_ERROR, "----------CacheHttp_GetBufferedTime buffed_time=%lld", buffed_time); } else { buffed_time = s->item_starttime; if(s->finish_flag>0) { int64_t full_time = getTotalDuration(NULL); buffed_time = full_time; } } return buffed_time; }
float Plan::progress(const IMC::ManeuverControlState* mcs) { if (!m_compute_progress) return -1.0; // Compute only if linear and durations exists if (!isLinear() || !m_profiles->size()) return -1.0; // If calibration has not started yet, but will later if (m_calib->notStarted()) return -1.0; float total_duration = getTotalDuration(); float exec_duration = getExecutionDuration(); // Check if its calibrating if (m_calib->inProgress()) { float time_left = m_calib->getRemaining() + exec_duration; m_progress = 100.0 * trimValue(1.0 - time_left / total_duration, 0.0, 1.0); return m_progress; } // If it's not executing, do not compute if (mcs->state != IMC::ManeuverControlState::MCS_EXECUTING || mcs->eta == 0) return m_progress; TimeProfile::const_iterator itr; itr = m_profiles->find(getCurrentId()); // If not found if (itr == m_profiles->end()) { // If beyond the last maneuver with valid duration if (m_beyond_dur) { m_progress = 100.0; return m_progress; } else { return -1.0; } } // If durations vector for this maneuver is empty if (!itr->second.durations.size()) return m_progress; IMC::Message* man = m_graph.find(getCurrentId())->second.pman->data.get(); // Get execution progress float exec_prog = Progress::compute(man, mcs, itr->second.durations, exec_duration); float prog = 100.0 - getExecutionPercentage() * (1.0 - exec_prog / 100.0); // If negative, then unable to compute // But keep last value of progress if it is not invalid if (prog < 0.0) { if (m_progress < 0.0) return -1.0; else return m_progress; } // Never output shorter than previous m_progress = prog > m_progress ? prog : m_progress; return m_progress; }