![]() Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
Процедура генерирования HTML-кода ответа на поступивший запрос ⇐ ПредыдущаяСтр 3 из 3
/* Prepare HTTP content - " Auto-Correlation" Page: */ bool Prepare_HTTP_Content_AutoCorrelation( const map< wstring, wstring> & mapParams, // Request params vector< char> & vecContent, // [out] content (HTML, JPEG, etc.) string& strContentType, // [out] content type (' text/html', etc.) wstring& strErr ) { using namespace nsUtilities;
wostringstream wos; { // HTML (entire page): const WriteTag tagHTML(wos, L" < html> ", L" < /html> "); // Head: { const WriteTag tagHead(wos, L" < head> ", L" < /head> "); // Title: { const WriteTag tagTitle(wos, L" < title> ", L" < /title> "); wos < < L" Auto-Correlation"; } } // Body: const WriteTag tagBody(wos, L" < body> ", L" < /body> "); // Div: const WriteTag tagDiv(wos, L" < div> ", L" < /div> "); wos < < L" < h2> Вычисление авто-корреляции сигнала< /h2> "; wos < < L" < br /> ";
// Read input: // ---- Input signal: wstring strInputSignal; // values for input signal samples GetInputParam_String(mapParams, L" InputSignal", strInputSignal);
// Give sample, if user didn't enter data: if (strInputSignal.empty()) strInputSignal = L" 0 0.12 -0.09 0.68 0.32 0.71 0.02 -0.06 0.11 -0.18 0.2 0.01 " L" -0.07 0.1392 -0.0999 0.7752 0.3136 0.71 0.023 -0.0636 0.1034 -0.1674 0.232 0.0101 -0.0819";
// Parse input signal: vector< double> vecInputSignal; // values for input signal samples ParseValsWS(strInputSignal, vecInputSignal);
// --- // Minumum period (number of samples): UINT minPeriod = 5; // default value GetInputParam_NumericT(mapParams, L" minPeriod", minPeriod);
// Form: { const WriteTag tagForm(wos, L" < form action=\" AutoCorrelation.htm\" > ", L" < /form> ");
// Table: { const WriteTag tagTable(wos, L" < table> ", L" < /table> "); // Row: { const WriteTag tagRow(wos, L" < tr> ", L" < /tr> "); // --- Input Signal: { const WriteTag tagCol(wos, L" < td> ", L" < /td> ");
// ------ Input Signal: wos < < L" Входной сигнал (введите отсчёты через пробел): "; wos < < L" < br /> "; wos < < L" < input type=\" text\" name=\" InputSignal\" style=\" width: 500px\" value=\" " < < GetStr_ValsWS(vecInputSignal) < < L" \" /> "; wos < < L" < br /> ";
// --- // Paint chart for 'Input Signal' into 'canvas' tag: wos < < GetHTML_Chart_bySamples(L" Chart_InputSignal", 500, 300, vecInputSignal); }
// ---: { const WriteTag tagCol(wos, L" < td> ", L" < /td> ");
wos < < L" Нижняя граница поиска периода (кол-во отсчётов): ";
wos < < L" < input type=\" text\" name=\" minPeriod\" value=\" " < < ToStrW(minPeriod) < < L" \" /> "; } } // end Row } // End Table
wos < < L" < hr> ";
wos < < L" < input type=\" submit\" value=\" Вычислить\" /> ";
// ---- Result:
wos < < L" < hr> ";
wos < < L" < b> Результат - авто-корреляция< /b> "; wos < < L" < br /> ";
/* Calculate auto-correlation: */ vector< double> vecAutoCorrelation; Calc_Correlation( vecInputSignal, // values for input signal samples vecInputSignal, // sample signal (the same as input signal for auto-correlation) vecAutoCorrelation // [out] - correlation );
// Paint chart for 'Correlation' into 'canvas' tag: wos < < GetHTML_Chart_bySamples(L" Chart_AutoCorrelation", 500, 300, vecAutoCorrelation);
/* Find period by auto-correlation function (as number of samples): */ const UINT period = GetPeriod(vecAutoCorrelation, minPeriod);
wos < < L" < br /> "; wos < < L" Период (кол-во отсчётов): " < < period;
} // form
wos < < L" < hr> ";
} // body
const string strContent = nsUtilities:: wstring_to_string(wos.str()); vecContent.assign(strContent.begin(), strContent.end());
strContentType = " text/html";
return true; }
|