コード例 #1
0
ファイル: statdiag.cpp プロジェクト: wds315/szarp
void StatDialog::StartFetch() {
    if (m_draw == NULL) {
        wxMessageBox(_("You need to choose draw first."), _("Draw missing"), wxOK | wxICON_INFORMATION, this);
        return;
    }

    m_start_time.AdjustToPeriod();
    m_current_time = m_start_time;

    m_end_time.AdjustToPeriod();

    m_count = 0;
    m_pending = 0;
    m_tofetch = m_current_time.GetDistance(m_end_time) + 1;
    m_totalfetched = 0;

    if (m_tofetch <= 0)
        return;

    //m_progress_dialog = new wxProgressDialog(_T("Caclulating"), _T("Calculation in progress"), 100, this, wxPD_AUTO_HIDE);
    m_progress_frame = new ProgressFrame(this);
    m_progress_frame->Centre();
    m_progress_frame->Show(true);

    ProgressFetch();
}
コード例 #2
0
ファイル: xydiag.cpp プロジェクト: cyclefusion/szarp
void DataMangler::DatabaseResponse(DatabaseQuery *q) {

	for (std::vector<DatabaseQuery::ValueData::V>::iterator i = q->value_data.vv->begin();
			i != q->value_data.vv->end();
			i++) {
		DTime time = DTime(m_period, i->time);

		int index = m_start_time.GetDistance(time);

		m_draw_vals.at(index).second = time;

		ValueInfo *vi;
		vi = &m_draw_vals.at(index).first.at(q->draw_no);
		vi->state = ValueInfo::PRESENT;
		vi->val = i->response;
	}

	m_pending -= q->value_data.vv->size();
	m_fetched += q->value_data.vv->size();

	delete q;

	m_progress->SetProgress(m_fetched * 100 / m_tofetch);

	if (m_fetched == m_tofetch) {
		assert(m_pending == 0);

		XYGraph* graph = new XYGraph;

		graph->m_start = m_start_time.GetTime();
		graph->m_end = m_end_time.GetTime();
		graph->m_period = m_period;
		graph->m_di = m_di;
		graph->m_min.resize(m_di.size());
		graph->m_max.resize(m_di.size());
		graph->m_dmin.resize(m_di.size());
		graph->m_dmax.resize(m_di.size());
		graph->m_avg.resize(m_di.size());
		graph->m_standard_deviation.resize(m_di.size());
		graph->m_averaged = m_average;

		AssociateValues(graph);
		FindMaxMinRange(graph);

		if (m_average)
			AverageValues(graph);

		m_progress->Destroy();
		m_dialog->DataFromMangler(graph);
	} if (m_pending <= 100 && m_pending + m_fetched != m_tofetch) {
		ProgressFetch();
	}

}
コード例 #3
0
ファイル: xydiag.cpp プロジェクト: cyclefusion/szarp
void DataMangler::Go() {
	m_tofetch = m_draw_vals.size() * m_di.size();
	m_fetched = 0;
	m_pending = 0;

	m_progress = new ProgressFrame(m_dialog);
	m_progress->Show(true);
	m_progress->Raise();

	ProgressFetch();
}
コード例 #4
0
ファイル: statdiag.cpp プロジェクト: wds315/szarp
void StatDialog::DatabaseResponse(DatabaseQuery *q) {

    if (m_tofetch == 0) {
        delete q;
        return;
    }

    for (std::vector<DatabaseQuery::ValueData::V>::iterator i = q->value_data.vv->begin();
            i != q->value_data.vv->end();
            i++) {

        if (std::isnan(i->response))
            continue;

        if (m_count++ == 0) {
            m_max = i->response;
            m_min = i->response;
            m_sum = 0;
            m_sum2 = 0;
            m_hsum = 0;

            m_min_time = m_max_time = ToWxDateTime(i->time_second, i->time_nanosecond);
        } else {
            if (m_max < i->response) {
                m_max = i->response;
                m_max_time = ToWxDateTime(i->time_second, i->time_nanosecond);
            }

            if (m_min > i->response) {
                m_min = i->response;
                m_min_time = ToWxDateTime(i->time_second, i->time_nanosecond);
            }

        }

        m_sum += i->response;
        m_sum2 += i->response * i->response;
        m_hsum += i->sum;
    }

    m_pending -= q->value_data.vv->size();
    m_totalfetched += q->value_data.vv->size();

    delete q;

    assert(m_pending >= 0);

#if 0
    bool canceled;
    m_progress_dialog->Update(wxMin(99, int(float(m_totalfetched) / (m_tofetch + 1) * 100)), _T(""), &canceled);
#endif
    m_progress_frame->SetProgress(m_totalfetched * 100 / m_tofetch);

    if (m_totalfetched == m_tofetch) {

        assert(m_pending == 0);

        if (m_count) {
            wxString unit = m_draw->GetUnit();
            double sdev = sqrt(m_sum2 / m_count - m_sum / m_count * m_sum / m_count);

            m_min_value_text->SetLabel(wxString::Format(_T("%s %s (%s)"),
                                       m_draw->GetValueStr(m_min, _T("- -")).c_str(),
                                       unit.c_str(),
                                       FormatTime(m_min_time, m_period).c_str()));
            m_stddev_value_text->SetLabel(wxString::Format(_T("%s %s"),
                                          m_draw->GetValueStr(sdev, _T("- -")).c_str(),
                                          unit.c_str()));
            m_avg_value_text->SetLabel(wxString::Format(_T("%s %s"),
                                       m_draw->GetValueStr(m_sum / m_count, _T("- -")).c_str(),
                                       unit.c_str()));
            m_max_value_text->SetLabel(wxString::Format(_T("%s %s (%s)"),
                                       m_draw->GetValueStr(m_max, _T("- -")).c_str(),
                                       unit.c_str(),
                                       FormatTime(m_max_time, m_period).c_str()));
            if (m_draw->GetSpecial() == TDraw::HOURSUM) {
                if (unit.Replace(_T("/h"), _T("")) == 0)
                    unit += _T("h");
                m_hsum_value_text->SetLabel(wxString::Format(_T("%s %s"), m_draw->GetValueStr(m_hsum / m_draw->GetSumDivisor()).c_str(), unit.c_str()));
            }
        } else {
            m_min_value_text->SetLabel(_("no data"));
            m_avg_value_text->SetLabel(_("no data"));
            m_stddev_value_text->SetLabel(_("no data"));
            m_max_value_text->SetLabel(_("no data"));
            if (m_draw->GetSpecial() == TDraw::HOURSUM)
                m_hsum_value_text->SetLabel(_("no data"));
        }
        m_progress_frame->Destroy();

        m_tofetch = 0;

    } else if (m_pending == 0)
        ProgressFetch();
}