Projects
mass
turbina-core-mass
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 4
View file
turbina-core-mass.spec
Changed
@@ -1,7 +1,7 @@ # -# spec file for package turbina-core-mass (Version 1.10) +# spec file for package turbina-core-mass (Version 1.20) # -# Copyright (c) 2010 Matwey V. Kornilov. +# Copyright (c) 2012 Matwey V. Kornilov. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # @@ -32,7 +32,7 @@ BuildRequires: make gcc gcc-c++ rs485-devel Summary: MASS measure daemon Name: turbina-core-mass -Version: 1.10 +Version: 1.20 Release: 1 Source: %{tarname}-%{version}.tar.bz2 Source1: defnames.h @@ -118,5 +118,7 @@ %dir %attr(0755,turbina,turbina) /var/log/turbina/mass %changelog +* Fri Sep 05 2012 - matwey.kornilov@gmail.com +- version 1.20 * Wed Oct 27 2010 - matwey.kornilov@gmail.com - initial version
View file
turbina_core_m-1.10.tar.bz2/Makefile -> turbina_core_m-1.20.tar.bz2/Makefile
Changed
@@ -8,7 +8,7 @@ MASS = mass MASS_SOURCES = main.o mass.o configs.o module.o auxiliary.o channel.o bicounter.o exchange.o rs485.o astrotime.o measmode.o errlog.o rserrno.o sci.o results.o receiver.o comms.o scenario.o instrument.o socket.o server.o -VERSION = 1.10 +VERSION = 1.20 CXX = g++ INSTALL_PROGRAM = install RS485INCLUDE = $(shell for X in /usr/include/linux/rs485 /usr/src/rs485/include; do T=$$X; if -d $$X ; then break; fi done; echo $$T;)
View file
turbina_core_m-1.10.tar.bz2/auxiliary.cpp -> turbina_core_m-1.20.tar.bz2/auxiliary.cpp
Changed
@@ -1,12 +1,13 @@ #include <stdexcept> #include <iostream> #include <limits> // numeric_limits<unsigned char>::min() +#include <unistd.h> // for sleep #include "auxiliary.h" //#include "astrotime.h" #include "results.h" #include "deftypes.h" #include "defnames.h" -/* +/* æÕÎËÃÉÏÎÁÌØÎÙÅ ËÏÍÁÎÄÙ ËÏÎÔÒÏÌÌÅÒÁ: */ @@ -41,9 +42,10 @@ current_voltage = -1; current_brightness = -1; setVoltage(voltage); - setLightLevel(1.0); +// setLightLevel(1.0); setIllum(true); - + setLight(false); + int status = getStatus(); getHV(status); getIllum(status); @@ -52,7 +54,7 @@ getTemperature(); } -Auxiliary::~Auxiliary(void) { +Auxiliary::~Auxiliary() { // ôÕÔ ÎÅÌØÚÑ ÉÓËÌÀÞÅÎÉÑ ÇÅÎÅÒÉÔØ!!! Lock lock; try { @@ -99,22 +101,22 @@ else return hv_steadying; } -void Auxiliary::waitHV(void) { - if(ErrlogSingl::instance().isTest() || (hv==false)) return; +void Auxiliary::waitHV() { + if( ErrlogSingl::instance().isTest() || !hv ) return; // AstroDateTime utc; // int rest = int(ceil(hv_steadying - utc.currentSec() + hv_on_sec)); struct timeval current; gettimeofday(¤t, NULL); // int rest = int(ceil(hv_steadying - current.tv_sec + hv_on_time.tv_sec)); int rest = hv_steadying - current.tv_sec + hv_on_time.tv_sec; -// std::cerr<< "hv_steadying=" << hv_steadying << " hv_on_sec=" +// std::cerr<< "hv_steadying=" << hv_steadying << " hv_on_sec=" // << hv_on_time.tv_sec << " current=" << current.tv_sec << " rest=" // << rest << std::endl; if(rest > 0) sleep(rest); return; } -bool Auxiliary::getHV(void) { +bool Auxiliary::getHV() { return getHV(getStatus()); } @@ -124,49 +126,51 @@ return hv; } -bool Auxiliary::getIllum(void) { +bool Auxiliary::getIllum() { return getIllum(getStatus()); } bool Auxiliary::getIllum(int status) { - if(status & FLAG_ILLUM_ON) illum = true; +/* if( status&FLAG_ILLUM_ON ) illum = true; else illum = false; - return illum; + return illum;*/ + return illum = ( status & FLAG_ILLUM_ON )? true : false; } -bool Auxiliary::getLight(void) { +bool Auxiliary::getLight() { return getLight(getStatus()); } bool Auxiliary::getLight(int status) { - if(status & FLAG_LIGHT_ON) lightOn = true; +/* if(status & FLAG_LIGHT_ON) lightOn = true; else lightOn = false; - return lightOn; + return lightOn;*/ + return lightOn = (status & FLAG_LIGHT_ON ) ? true : false; } -void Auxiliary::setIllum(bool on) { - if(!on) sendSimpleCommand(ILLUM_OFF); +void Auxiliary::setIllum( bool on ) { + if(!on) sendSimpleCommand( ILLUM_OFF ); else { int i_illum = 0; double d_illum = rint(illumlevel * 15.0); // 0 - 15 if(d_illum != 0) i_illum = (unsigned char)floor(pow(2.0, (8.0*d_illum / 15.01)) + 0.5); // 0-255 - sendByteCommand(SET_ILLUM, (unsigned char)i_illum); - sendSimpleCommand(ILLUM_ON); + sendByteCommand( SET_ILLUM, (unsigned char)i_illum ); + sendSimpleCommand( ILLUM_ON ); } getIllum(); } int doubleTo255int(double val) { int int_val = int(rint(255.0 * val)); - if((int_val == 0) && (val > 0)) int_val = 1; + if((int_val == 0) && (val > 0)) int_val = 1; if(int_val < 0) int_val = 0; if(int_val > 255) int_val = 255; return int_val; } void Auxiliary::setLight(bool on) { - if(on == lightOn) return; - if(on) { + if( on == lightOn ) return; + if( on ) { gettimeofday(&light_on_time, NULL); sendSimpleCommand(LIGHT_ON); } else { @@ -176,12 +180,11 @@ } void Auxiliary::setLightLevel(double brightness) { - if(brightness == current_brightness) return; - if(brightness != 0) gettimeofday(&light_on_time, NULL); - + if( brightness == current_brightness ) return; + if( brightness != 0 ) gettimeofday(&light_on_time, NULL); int ilight = doubleTo255int(brightness); current_brightness = -1; - sendByteCommand(SET_LIGHT, (char)ilight); + sendByteCommand( SET_LIGHT, (char)ilight ); current_brightness = brightness; } @@ -198,7 +201,7 @@ sendByteCommand(SET_VAMPL, (char)ivampl); } -void Auxiliary::waitLight(void) { +void Auxiliary::waitLight() { if(ErrlogSingl::instance().isTest() || (lightOn == false)) return; struct timeval current; gettimeofday(¤t, NULL); @@ -217,7 +220,7 @@ return hv_steadying; } -std::string Auxiliary::getTemperature(void) { +std::string Auxiliary::getTemperature() { unsigned char ch_temper = askByte(GET_TEMPER); double d_temper = (2.5*(double(ch_temper)+120.0)-500.0)/10.0; std::ostringstream s;; @@ -226,31 +229,32 @@ return temperature; } -bool Auxiliary::isMirrorOnAxis(void) { +bool Auxiliary::isMirrorOnAxis() { return isMirrorOnAxis(getStatus()); } bool Auxiliary::isMirrorOnAxis(int status) { - if(status & FLAG_MIRROR) mirrorOnAxis = true; - else mirrorOnAxis = false; - return mirrorOnAxis; +/* if(status & FLAG_MIRROR) mirrorOnAxis = true; + else mirrorOnAxis = false;*/ + return mirrorOnAxis = status&FLAG_MIRROR; } -bool Auxiliary::isOverlight(void) { - return isOverlight(getStatus()); +bool Auxiliary::isOverlight() { + return isOverlight( getStatus() ); } -bool Auxiliary::isOverlight(int status) { - if(status & FLAG_OVR_LIGHT) { +bool Auxiliary::isOverlight( int status ) { +/* if( status&FLAG_OVR_LIGHT ) { return true; } - return false; + return false;*/ + return status&FLAG_OVR_LIGHT; } void Auxiliary::checkStatus() { int status = getStatus();
View file
turbina_core_m-1.10.tar.bz2/auxiliary.h -> turbina_core_m-1.20.tar.bz2/auxiliary.h
Changed
@@ -76,24 +76,24 @@ /** ëÏÎÓÔÒÕËÔÏÒ ÏÂßÅËÔÁ - ÍÏÄÕÌÑ ÕÐÒÁ×ÌÅÎÉÑ power - light @param cnf Configuration parameters tree (usually read from device.cfg) @param nm Section name containing auxiliary module parameters ("Auxiliary") - + \param cnf ÉÍÑ ÐÒÉÂÏÒÁ, ËÏÔÏÒÏÍÕ ÐÒÉÎÁÄÌÅÖÉÔ ÄÁÎÎÙÊ ÍÏÄÕÌØ Ä×ÉÇÁÔÅÌÑ \param nm ÉÍÑ ÍÏÄÕÌÑ - ÐÏÄÓÅËÃÉÉ × ÓÅËÃÉÉ \a parent ÄÅÒÅ×Á Module::cnf ("Auxiliary") - + óÎÁÞÁÌÁ ×ÙÚÙ×ÁÅÔÓÑ ËÏÎÓÔÒÕËÔÏÒ Module::Module, ÚÁÔÅÍ × ÞÁÓÔÎÙÅ ÞÌÅÎÙ-ÐÅÒÅÍÅÎÎÙÅ ÚÁÇÒÕÖÁÀÔÓÑ ÄÏÐÏÌÎÉÔÅÌØÎÙÅ ÐÁÒÁÍÅÔÒÙ ÍÏÔÏÒÁ */ Auxiliary(Config& config, RS485& rs485, const std::string& name); - ~Auxiliary(void); + ~Auxiliary(); void setVoltage(double volt); - const int setHV(bool on); // vozvrachaet dlitel'nost' vystaivaniya hv (sec) - bool getHV(void); // on/off - bool getIllum(); // on/off - bool getLight(); // on/off - bool isMirrorOnAxis(void); // yes/no - void waitHV(void); + const int setHV(bool on); // vozvrachaet dlitel'nost' vystaivaniya hv (sec) + bool getHV(); // on/off + bool getIllum(); // on/off + bool getLight(); // on/off + bool isMirrorOnAxis(); // yes/no + void waitHV(); bool currentHV() {return hv;} bool currentIllum() {return illum;} bool currentLight() {return lightOn;} @@ -103,13 +103,13 @@ std::string currentTemperature() {return temperature;} void setIllum(bool on); void setLight(bool on); - void waitLight(void); + void waitLight(); void setLightLevel(double brightness); const int lightWaiting(); const int hvWaiting(); void setVAmpl(double, double); void setVary(bool on); - std::string getTemperature(void); + std::string getTemperature(); void checkStatus(); double temperPollingTime() {return _temperPollingTime;} };
View file
turbina_core_m-1.10.tar.bz2/bicounter.cpp -> turbina_core_m-1.20.tar.bz2/bicounter.cpp
Changed
@@ -69,7 +69,7 @@ int ilevel = int(rint( 255 + c2 - level*(255.0 + c2 - c1) ) ); checkMinMax<int>(numeric_limits<unsigned char>::min(), ilevel, - numeric_limits<unsigned char>::max()); + numeric_limits<unsigned char>::max()); return (char)ilevel; } @@ -96,7 +96,7 @@ } void Bicounter::reset(void) { -// BlockCounter.reset(); +// BlockCounter.reset(); Module::reset(); } @@ -110,7 +110,7 @@ } void Bicounter::setExpos(double expos) { - int expos_code = int( rint( expos*(constants.at(2) + (constants.at(3)<<8) - 1) / 8) ); + int expos_code = int( rint( expos*( constants.at(2) + (constants.at(3)<<8) - 1 ) / 8) ); sendWordCommand(SET_EXPOS, expos_code); return; }
View file
turbina_core_m-1.10.tar.bz2/defnames.h -> turbina_core_m-1.20.tar.bz2/defnames.h
Changed
@@ -1,7 +1,7 @@ #ifndef _DEFNAMESM_H #define _DEFNAMESM_H -//const std::string program_root = "/home/victor/turbina_core_m/"; +//const std::string program_root = "./"; const std::string program_root = "/opt/mass/"; const std::string program_etc = program_root + "etc/";
View file
turbina_core_m-1.10.tar.bz2/etc/mass.cfg -> turbina_core_m-1.20.tar.bz2/etc/mass.cfg
Changed
@@ -4,14 +4,15 @@ SiteName KGO ;observatory or site na Longitude 2 50 40 ;longitude of the site: Latitude +43 44 12 ;latitude of th - EndSubSection + EndSubSection SubSection "Common" Device /dev/rs485lpt0 ; + BaudeRate 920 ; EndSubSection EndSection Section "Operations" SubSection "Normal mode" - Exposition 1 ;micro-exposition time in ms (>=1) + Exposition 1.0 ;micro-exposition time in ms (>=1) BaseTime 1 ;base time in sec. AccumTime 60 ;accumulation time in sec. MinimalStarFlux 100 ;For centering control
View file
turbina_core_m-1.10.tar.bz2/infras/exchange.cpp -> turbina_core_m-1.20.tar.bz2/infras/exchange.cpp
Changed
@@ -15,6 +15,8 @@ #include <rserrno.h> #include <exchange.h> +#include <unistd.h> // write, usleep, close + const int MAXRETRY = 2; // Maximal number of transaction attempts const int MAX_PACKET_SIZE = 32; // Maximal packet size
View file
turbina_core_m-1.10.tar.bz2/infras/module.cpp -> turbina_core_m-1.20.tar.bz2/infras/module.cpp
Changed
@@ -9,6 +9,8 @@ #include <module.h> #include <errlog.h> +#include <unistd.h> // usleep + //const char LOAD_KEY = 0x3E; //const char READ_KEY = 0xFE;
View file
turbina_core_m-1.10.tar.bz2/instrument.cpp -> turbina_core_m-1.20.tar.bz2/instrument.cpp
Changed
@@ -4,9 +4,10 @@ #include "defnames.h" Instrument::Instrument(Config& config) : - device(config.inp<std::string>( "General", "Common", "Device")), - rs485(device), - aux(config, rs485, "auxiliary"), + device( config.inp<std::string>( "General", "Common", "Device") ), + bauderate( config.inp<int>( "General", "Common", "BaudeRate") ), + rs485( device, bauderate ), + aux( config, rs485, "auxiliary"), bic1(config, rs485, "bicounter 1"), bic2(config, rs485, "bicounter 2"), channels(config, bic1, bic2), @@ -21,20 +22,13 @@ void Instrument::prepareAccumTime(double exposition, int exposNumber, double baseTime, int blockNumber) try { - - receiver.init(baseTime, blockNumber); - bic1.setLevels(); bic2.setLevels(); - -// Master: - + // Master: bic1.setInduce(false); bic1.setMaster(true); bic1.setActive(true); - -// Slave: - + // Slave: bic2.setMaster(false); bic2.setActive(false); bic2.setInductor(&bic1); @@ -44,24 +38,32 @@ bic2.setExpos(exposition); bic1.setNumber(exposNumber); bic2.setNumber(exposNumber); - + + receiver.init(baseTime, blockNumber); } catch (const std::exception &e) { ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in prepareAccumTime" ); } -unsigned int Instrument::obtainData(std::valarray<COUNT_T>* count_data, bool etest) try { - receiver.startBaseTime(count_data); - bic2.run(etest); - bic1.run(etest); - unsigned int nloss = receiver.read_data(); +void Instrument::startBaseTime( bool etest ) try { + receiver.startBaseTime(); + bic2.run( etest ); + bic1.run( etest ); +} +catch (const std::exception &e) { + ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); + ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in start basetime" ); +} + +unsigned int Instrument::obtainData( std::valarray<COUNT_T>* storage ) try { + unsigned int nloss = receiver.read_data( storage ); return nloss; } catch (const std::exception &e) { ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); - ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in obtainData" ); - return 0; // formal for debug + ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in data receiving" ); + return 0; }
View file
turbina_core_m-1.10.tar.bz2/instrument.h -> turbina_core_m-1.20.tar.bz2/instrument.h
Changed
@@ -10,8 +10,9 @@ #include "receiver.h" #include "sci.h" // COUNT_T -class Instrument { // ôÏÌØËÏ ÖÅÌÅÚÏ Ó ÜÌÅÍÅÎÔÁÒÎÙÍÉ, ÔÏÌØËÏ "ÖÅÌÅÚÎÙÍÉ" ÆÕËÃÉÑÍÉ +class Instrument { const std::string device; + const int bauderate; RS485 rs485; Auxiliary aux; Bicounter bic1; @@ -25,14 +26,15 @@ static const int getCountInBlock() {return Bicounter::getCountInBlock();} // unsigned int nBlocks(int blockNumber) const {return N_BIC*blockNumber*2;} - + void prepareAccumTime(double exposition, int exposNumber, double baseTime, int blockNumber); - unsigned int obtainData(std::valarray<COUNT_T>* count_data, bool etest=false); + void startBaseTime( bool etest=false ); + unsigned int obtainData( std::valarray<COUNT_T>* count_data ); bool isMirrorOnAxis(); // m.b. async bool currentMirror() {return aux.currentMirror();} bool getHV(); // m.b. async - bool currentHV() {return aux.currentHV();} + bool currentHV() {return aux.currentHV();} bool getIllum(); // m.b. async bool currentIllum() {return aux.currentIllum();} bool getLight(); // m.b. async @@ -43,12 +45,12 @@ std::string currentTemperature() {return aux.currentTemperature();} const int setHV(bool on) {return aux.setHV(on);} - void waitHV() {aux.waitHV();} - void waitLight() {aux.waitLight();} - const int lightWaiting() {return aux.lightWaiting();} - const int hvWaiting() {return aux.hvWaiting();} - void setIllum(bool on) {aux.setIllum(on);} - void setLight(bool on) {aux.setLight(on);} + void waitHV() { aux.waitHV(); } + void waitLight() { aux.waitLight(); } + const int lightWaiting() { return aux.lightWaiting(); } + const int hvWaiting() { return aux.hvWaiting(); } + void setIllum(bool on) { aux.setIllum(on); } + void setLight(bool on) { aux.setLight(on); } void setLightLevel(double brightness) {aux.setLightLevel(brightness);} void setVoltage(double volt=-1) {aux.setVoltage(volt);} // -1 for voltage from config-file void setVAmpl(double mod, double light) {aux.setVAmpl(mod, light);}
View file
turbina_core_m-1.10.tar.bz2/measmode.cpp -> turbina_core_m-1.20.tar.bz2/measmode.cpp
Changed
@@ -5,6 +5,8 @@ #include "astrotime.h" #include "results.h" +AstroDateTime cutc; + using namespace std; const std::string NormalModeName = "Normal mode"; @@ -31,12 +33,11 @@ // Estimate fractional "exposition number" : double exposNumber_first = S2MS * baseTime / exposition; // number of blocks should be integer and contain ALL counts: - blockNumber = int(ceil(exposNumber_first / Instrument::getCountInBlock()))-4; + blockNumber = int( ceil(exposNumber_first / Instrument::getCountInBlock()) ) - 4; // !!! Tut d.b. kratno 4-m v variante s bicounter-ami !!! exposNumber = blockNumber * Instrument::getCountInBlock(); -// ëÏÒÒÅËÔÉÒÕÅÍ baseTime // baseTime = exposNumber * exposition / S2MS; - n_run = int(ceil(accumTime / baseTime)); // ëÏÌ-×Ï ÚÁÐÕÓËÏ× basetime v accum-time + n_run = int(ceil(accumTime / baseTime)); } void MeasMode::outdata(RESULT_DATA& result_data, bool is_accum_time) { @@ -44,50 +45,55 @@ } unsigned int MeasMode::runAccumTime() { +// double s0 = cutc.currentSec(); + RESULT_DATA result_data_accum; + unsigned int n_loss = 0, err = 0; + instr.getTemperature(); - Result::instance().outmode(mname); - instr.prepareAccumTime(exposition, exposNumber, baseTime, blockNumber); bool illum = instr.getIllum(); instr.setIllum(false); + Result::instance().outmode(mname); instr.checkStatus(); instr.waitHV(); - unsigned int n_loss = 0, err = 0; - - RESULT_DATA result_data_accum; - for( unsigned int i = 0; i < n_run && further_now(); i++ ) { // base-time-cycle + instr.prepareAccumTime(exposition, exposNumber, baseTime, blockNumber); + instr.startBaseTime( false ); + for( unsigned int i = 0; i < n_run && further_now(); i++ ) { +// double s1 = cutc.currentSec(); valarray<COUNT_T> count_data( exposNumber ); - unsigned int loss = 0; - if( ( loss = instr.obtainData(&count_data, false) ) != 0 ) { + unsigned int loss = instr.obtainData( &count_data ); + instr.checkStatus(); + if( i < n_run-1 ) instr.startBaseTime( false ); + if( loss != 0 ) { ostringstream s; s << "Data loss " << loss << " packets"; ErrlogSingl::instance().warning(s.str()); n_loss++; continue; } - instr.checkStatus(); Result::instance().outcnt( count_data ); - +// pre_processing( count_data ); for n string RESULT_DATA result_data; sci::calcmom( count_data, result_data ); - - outdata(result_data, false); // out base-time data + outdata( result_data, false ); // out base-time data result_data_accum += result_data; - particular_processing(count_data, result_data); + particular_processing( count_data, result_data ); + if(result_data.m3 < minDflux) throw ErrFat( ERR_CCD_EMPTY, mname ); - } // base-time-cycle - if(n_loss == n_run) throw ErrFat(ERR_EXCHANGE, mname); // Proverit' uspeshnost' - vdrug vse base-time proval'nye? +// std::cerr << "++ " << i << " " << cutc.currentSec() - s1 << std::endl; + } // end of base-time-cycle +// std::cerr << "===== " << cutc.currentSec() - s0 << std::endl; + if( n_loss == n_run ) throw ErrFat( ERR_EXCHANGE, mname ); result_data_accum /= (double)(n_run - n_loss); - flux = result_data_accum.m; // Fix accumtime mean fluxes - outdata(result_data_accum,true); // out AccumTime data to file - if(result_data_accum.m3 < minDflux) throw ErrFat(ERR_CCD_EMPTY, mname); // Ushla zvezda Kakoj ERR generit'??? + flux = result_data_accum.m; // Fix accumtime mean fluxes + outdata( result_data_accum, true ); // out AccumTime data to file instr.setIllum(illum); return err; } -unsigned int MeasMode::testcnt(const std::valarray<COUNT_T>& counts, int exposNumber) { - COUNT_T testnumber(exposNumber, exposNumber, exposNumber, exposNumber); +unsigned int MeasMode::testcnt( const std::valarray<COUNT_T>& counts, int exposNumber) { + COUNT_T testnumber(exposNumber, exposNumber, exposNumber, exposNumber); unsigned int err = 0; for(unsigned int i=0; i<counts.size(); i++) { testnumber--; @@ -108,12 +114,6 @@ testnumber.d = countsi.d; err += std::abs( (int)derr ); } -/* - std::cerr << countsi.a << " " << countsi.b << " " - << countsi.c << " " << countsi.d << " " - << testnumber.a << " " << testnumber.b << " " << testnumber.c << " " - << testnumber.d << std::endl; -*/ } return err; } @@ -124,11 +124,8 @@ std::ostringstream s; s << std::fixed; for(unsigned int i=0; i < flux.size(); i++) { - s << fluxChan.at(i) << std::setprecision( Result::instance().prc(fluxi) ) -// << setw(8) << std::left - << fluxi; + s << fluxChan.at(i) << std::setprecision( Result::instance().prc(fluxi) ) << fluxi; } -// s << '\"'; return s.str(); } @@ -141,13 +138,28 @@ calcValues(); } -void Normal::particular_processing(valarray<COUNT_T>& count_data, RESULT_DATA& result_data) { +void Normal::pre_processing( valarray<COUNT_T>& count_data ) { + RESULT_DATA first_data; // Additional n string + sci::calcmom( count_data, first_data ); + Result::instance().outdata_pre( first_data ); + sci::binned( count_data ); +} + +void Normal::particular_processing( valarray<COUNT_T>& count_data, const RESULT_DATA& result_data) { // Binned variances const unsigned int nbin = 6; + unsigned int factor = 1; + std::vector<RESULT_DATA> binned_data; + binned_data.push_back( result_data ); for(unsigned int ibin=0; ibin<nbin; ibin++) { - sci::binned(count_data, result_data); - Result::instance().outbinn(result_data); + RESULT_DATA data; + sci::binned( count_data ); + sci::calcvar( count_data, data ); + factor *= 2; + data.binfactor = factor; + binned_data.push_back( data ); } + Result::instance().outbinn( binned_data ); } void Normal::run() { @@ -156,7 +168,7 @@ Background::Background(Config& config, Instrument& instr) : MeasMode(BackgroundModeName, instr) { - accumTime = config.inp<int>("operations", mname, "accumtime"); + accumTime = config.inp<int>("operations", mname, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); calcValues(); @@ -167,10 +179,9 @@ } - Flux::Flux(Config& config, Instrument& instr) : MeasMode(FluxModeName, instr) { - accumTime = config.inp<int>("operations", "tests", "fluxestimationtime"); + accumTime = config.inp<int>("operations", "tests", "fluxestimationtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); calcValues(); @@ -182,7 +193,7 @@ DetTest::DetTest(Config& config, Instrument& instr) : MeasMode(DetTestModeName, instr) { - accumTime = config.inp<int>("operations", "tests", "detectortesttime"); + accumTime = config.inp<int>("operations", "tests", "detectortesttime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); light = config.inp<double>("operations", "tests", "detectorlight"); @@ -211,7 +222,7 @@ StatTest::StatTest(Config& config, Instrument& instr) : MeasMode(StatTestModeName, instr) { - accumTime = config.inp<int>("operations", NormalModeName, "accumtime"); + accumTime = config.inp<int>("operations", NormalModeName, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); light = config.inp<double>("operations", "tests", "statisticlight"); @@ -231,7 +242,7 @@ ExchTest::ExchTest(Config& config, Instrument& instr)
View file
turbina_core_m-1.10.tar.bz2/measmode.h -> turbina_core_m-1.20.tar.bz2/measmode.h
Changed
@@ -24,10 +24,10 @@ unsigned int runAccumTime(); static bool further_now() {return !_stop_now;} unsigned int testcnt(const std::valarray<COUNT_T>&, int); - virtual void particular_processing(std::valarray<COUNT_T>& count_data, RESULT_DATA& result_data) {} + virtual void particular_processing(std::valarray<COUNT_T>& count_data, const RESULT_DATA& result_data) {} virtual void outdata(RESULT_DATA& result_data, bool is_accum_time); - -public: + virtual void pre_processing(std::valarray<COUNT_T>& count_data) { sci::binned( count_data ); } +public: MeasMode(const std::string& modename, Instrument& instr); virtual ~MeasMode(void) {} const std::string name() const {return mname;} @@ -62,7 +62,8 @@ }; class Normal : public MeasMode { - void particular_processing(std::valarray<COUNT_T>& count_data, RESULT_DATA& result_data); + void pre_processing(std::valarray<COUNT_T>& count_data); + void particular_processing(std::valarray<COUNT_T>& count_data, const RESULT_DATA& result_data); public: Normal(Config& config, Instrument& instr); ~Normal(void) {}
View file
turbina_core_m-1.10.tar.bz2/receiver.cpp -> turbina_core_m-1.20.tar.bz2/receiver.cpp
Changed
@@ -1,11 +1,13 @@ #include <map> #include <assert.h> +#include <unistd.h> // for sleep #include "receiver.h" #include "astrotime.h" #include "errlog.h" //#include "results_mass.h" using namespace std; +AstroDateTime utr; pthread_mutex_t Receiver::Lock::mtx = PTHREAD_MUTEX_INITIALIZER; @@ -14,8 +16,7 @@ //static count_t block2IO_BUFF_SIZE; static unsigned short block2IO_BUFF_SIZE; -Receiver::Receiver(RS485& rs, Channels& ch) //, valarray<COUNT_T>* _count_data, double _baseTime) - : rs485(rs), channels(ch) { +Receiver::Receiver(RS485& rs, Channels& ch) : rs485(rs), channels(ch) { setBlockStructure(); } @@ -38,7 +39,7 @@ // ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÏÐÔÉÞÅÓËÏÍÕ ËÁÎÁÌÕ ch (ch = 0,1,2,3, ÞÔÏ ÓÏÔ×ÅÔÓÔ×ÕÅÔ "A","B","C","D") typedef count_t(*PF)(unsigned int); PF get_count_chN_CHAN; - + typedef pair<string, PF> COUNT_FUNC_PAIR; COUNT_FUNC_PAIR count_funcN_CHAN = { COUNT_FUNC_PAIR("1a", &F_1A), @@ -68,15 +69,18 @@ // blockStructureReady = true; } -void Receiver::init(double _baseTime, int blockNumber) { +void Receiver::init( double _baseTime, int blockNumber ) { baseTime = _baseTime; n_expected = N_BIC*blockNumber*2; // kol-vo blockov b baseTime } -void Receiver::startBaseTime(valarray<COUNT_T>* _count_data) { // Kazhdiyj base-time nado delat' - count_data = _count_data; - data_actual_size = 0; // tekuchaya posiziya b bufferakh priniatykh dannykh - rs485.resetData(); // mozhet generit' RS485::ErrFatal, togda pust' provalivaetsia vyshe. +const double factor = 1.2; + +void Receiver::startBaseTime() { + // Kazhdiyj base-time nado delat' + rs485.resetData(); // mozhet generit' RS485::ErrFatal, togda pust' provalivaetsia vyshe. + data_actual_size = 0; // tekuchaya posiziya b bufferakh priniatykh dannykh + finishTime = utr.currentSec() + baseTime*factor; } void Receiver::putData(unsigned int n_count) { @@ -94,38 +98,16 @@ data_actual_size += n_count / 2; } - -/* -namespace { - bool timeout(const struct timeval& start, double maxsec) { -// AstroDateTime utc; - struct timeval current; - gettimeofday(¤t, NULL); - if((current.tv_sec - start.tv_sec) < maxsec+1) return false; -// if((utc.currentSec() - start) < maxsec) return false; -// cerr << "Timeout: " << utc.currentSec() - start << " > " << maxsec << endl; - return true; - } -// factor * baseTime = max ×ÒÅÍÑ ÏÖÉÄÁÎÉÑ ÐÒÉÈÏÄÁ ÐÏÓÌÅÄÎÅÇÏ ÂÌÏËÁ -} -*/ -const double factor = 1.5; - -unsigned int Receiver::read_data() { +unsigned int Receiver::read_data( valarray<COUNT_T>* count_stor ) { Lock lock; + count_data = count_stor; unsigned int from; unsigned int numb; -// count_t* bl = block0; - unsigned short* bl = block0; - AstroDateTime utc; - double startSec = utc.currentSec(); -// struct timeval startTime; -// gettimeofday(&startTime, NULL); - -/* */ - if(rs485.shadow()) { // Simulation - sleep(int(rint(baseTime))); - for( unsigned int i=0; i<count_data->size(); i++) { + unsigned short* next_block = block0; + + if( rs485.shadow() ) { // Simulation + sleep( int( rint(baseTime) ) ); + for( unsigned int i = 0; i < count_data->size(); i++ ) { (*count_data)i.a = 1; (*count_data)i.b = 10; (*count_data)i.c = 101; @@ -133,21 +115,21 @@ } return 0; } -/* */ + unsigned int n_received = 0; // ErrlogSingl::instance().write("receiver::read_data start"); - - while( n_received < n_expected) { - if(utc.currentSec() > startSec+baseTime*factor) { + + while( n_received < n_expected && utr.currentSec() < finishTime ) { +// if( utr.currentSec() > startSec + baseTime*factor) { // if(timeout(startTime, baseTime*factor)) { - return (n_expected - n_received); - } +// return n_expected - n_received; +// } // if(timeout(startSec, baseTime*factor)) break; // ErrlogSingl::instance().write("receiver::read_data rs485.readData start"); - int n_count = rs485.readData(from, numb, bl); + int n_count = rs485.readData( from, numb, next_block ); // from ÉÓÐÏÌØÚÏ×ÁÔØ ÔÏÌØËÏ ÄÌÑ ËÏÎÔÒÏÌÑ ÉÌÉ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ ËÁÎÁÌÁ? - if(n_count <= 0) { - usleep(10000); //!!! + if( n_count <= 0 ) { + usleep(8000); //!!! continue; } // ErrlogSingl::instance().write("receiver::read_data rs485.readData stop"); @@ -159,37 +141,14 @@ } std::cerr << std::endl; */ - if(n_received % 2) { // ÎeÞÅÔÎÙÅ ÂÌÏËÉ (1,3,5,...) - putData(n_count); - bl = block0; // ÎÁ ÓÌÅÄÕÀÝÉÊ ÞÅÔÎÙÊ ÂÌÏË (0,2,4,...) + if( n_received % 2) { // odd blocks (1,3,5,...) + putData( n_count ); + next_block = block0; // next even block (0,2,4,...) } else { - bl = block1; // ÎÁ ÓÌÅÄÕÀÝÉÊ neÞÅÔÎÙÊ ÂÌÏË + next_block = block1; // next odd block } n_received++; -//----------------------- DEBUG: - } -// ErrlogSingl::instance().write("receiver::oread_data stop"); -/* - cerr << "VALDATA:\n"; - for( unsigned int i=0; i<count_data->size(); i++) { - cerr << (*count_data)i.a << " "; - } - cerr << "----------------\n"; - for( unsigned int i=0; i<count_data->size(); i++) { - cerr << (*count_data)i.b << " "; - } - cerr << "----------------\n"; - for( unsigned int i=0; i<count_data->size(); i++) { - cerr << (*count_data)i.c << " "; } - cerr << "----------------\n"; - for( unsigned int i=0; i<count_data->size(); i++) { - cerr << (*count_data)i.d << " "; - } - cerr << "----------------\n"; -*/ - - return 0; + return n_expected - n_received; } - - \ No newline at end of file +
View file
turbina_core_m-1.10.tar.bz2/receiver.h -> turbina_core_m-1.20.tar.bz2/receiver.h
Changed
@@ -16,14 +16,13 @@ void setBlockStructure(void); void putData(unsigned int n_count); unsigned int n_expected; + double finishTime; public: Receiver(RS485& rs485, Channels& ch); void init(double _baseTime, int blockNumber); - void startBaseTime(std::valarray<COUNT_T>* _count_data); - unsigned int read_data(); + void startBaseTime(); + unsigned int read_data( std::valarray<COUNT_T>* _count_data ); -// Vnutrennij class - class-level lock -// class Lock; class Lock { Lock(const Lock&); // zapret Lock& operator=(const Lock&); // zapret @@ -43,8 +42,6 @@ pthread_mutex_unlock(&mtx); } }; - - };
View file
turbina_core_m-1.10.tar.bz2/results.cpp -> turbina_core_m-1.20.tar.bz2/results.cpp
Changed
@@ -16,8 +16,8 @@ } } -std::string ResultI::stamp(const std::string& prefix) { - utc.current(CONV); +std::string ResultI::stamp(const std::string& prefix, bool prevs ) { + if( !prevs ) utc.current(CONV); std::ostringstream comstr(prefix + utc.strDate() + ' ' + utc.strTime(0) + ' '); return comstr.str(); } @@ -102,7 +102,7 @@ } void ResultI::close(void) { - std::ostringstream outstr(comstamp() + "Parked"); + std::ostringstream outstr(comstamp() + "Parked"); file << outstr; file.close(); if(cnt_file.is_open()) cnt_file.close(); @@ -132,53 +132,70 @@ void ResultI::out_selfmeas_data(const RESULT_DATA& r, bool isaccumtime) { using namespace std; ostringstream outstr; - if(isaccumtime) outstr << stamp("C "); - else outstr << stamp("c "); - outstr << fixed << - setprecision(prc(r.m0)) << setw(6) << r.m0 << - setprecision(prc(r.m1)) << setw(8) << r.m1 << - setprecision(prc(r.m2)) << setw(8) << r.m2 << - setprecision(prc(r.m3)) << setw(8) << r.m3 << setprecision(5) + outstr << ( (isaccumtime)? stamp("C ") : stamp("c ") ) << fixed + << setprecision(prc(r.m0)) << setw(6) << r.m0 + << setprecision(prc(r.m1)) << setw(8) << r.m1 + << setprecision(prc(r.m2)) << setw(8) << r.m2 + << setprecision(prc(r.m3)) << setw(8) << r.m3 << setprecision(5) << " " << setw(8) << r.s00 << " " << setw(8) << r.s01 << " " << setw(8) << r.s02 << " " << setw(8) << r.s03 << setprecision(4) << " " << setw(8) << r.s00*r.m0 << " " << setw(8) << r.s01*r.m1 << " " << setw(8) << r.s02*r.m2 << " " << setw(8) << r.s03*r.m3; file << outstr; - if(isaccumtime) data_copy = outstr.str().substr(2, outstr.str().size()-1); + if( isaccumtime ) data_copy = outstr.str().substr(2, outstr.str().size()-1); } void ResultI::outdata(const RESULT_DATA& r, bool isaccumtime) { using namespace std; ostringstream outstr; - if(isaccumtime) outstr << datstampAccum(); - else outstr << datstampBase(); - outstr << fixed << - setprecision(prc(r.m0)) << setw(6) << r.m0 << - setprecision(prc(r.m1)) << setw(8) << r.m1 << - setprecision(prc(r.m2)) << setw(8) << r.m2 << - setprecision(prc(r.m3)) << setw(8) << r.m3 << setprecision(5) + outstr << (( isaccumtime )? datstampAccum() : datstampBase()) << fixed + << setprecision(prc(r.m0)) << setw(6) << r.m0 + << setprecision(prc(r.m1)) << setw(8) << r.m1 + << setprecision(prc(r.m2)) << setw(8) << r.m2 + << setprecision(prc(r.m3)) << setw(8) << r.m3 << setprecision(5) << " " << setw(8) << r.s00 << " " << setw(8) << r.s01 << " " << setw(8) << r.s02 << " " << setw(8) << r.s03 << " " << setw(8) << r.s04 << " " << setw(8) << r.s05 << " " << setw(8) << r.s06 << " " << setw(8) << r.s07 - << " " << setw(8) << r.s08 << " " << setw(8) << r.s09 + << " " << setw(8) << r.s08 << " " << setw(8) << r.s09 << " " << " " << setw(8) << r.s10 << " " << setw(8) << r.s11 << " " << setw(8) << r.s12 << " " << setw(8) << r.s13 << " " << setw(8) << r.s14 << " " << setw(8) << r.s15 << " " << setw(8) << r.s16 << " " << setw(8) << r.s17 - << " " << setw(8) << r.s18 << " " << setw(8) << r.s19 - << " " << setw(8) << r.s20 << " " << setw(8) << r.s21 << " " << setw(8) << r.s22 << " " << setw(8) << r.s23; + << " " << setw(8) << r.s18 << " " << setw(8) << r.s19 << " " + << " " << setw(8) << r.s20 << " " << setw(8) << r.s21 << " " << setw(8) << r.s22 << " " << setw(8) << r.s23; file << outstr; - if(isaccumtime) data_copy = outstr.str().substr(2, outstr.str().size()-1); + if( isaccumtime ) data_copy = outstr.str().substr(2, outstr.str().size()-1); } -void ResultI::outbinn(const RESULT_DATA& r, bool isaccumtime) { +void ResultI::outdata_pre(const RESULT_DATA& r) { using namespace std; ostringstream outstr; - outstr << stamp("s ") << fixed - << setprecision(prc(r.m0)) << setw(6) << r.m0 - << setprecision(prc(r.m1)) << setw(8) << r.m1 - << setprecision(prc(r.m2)) << setw(8) << r.m2 - << setprecision(prc(r.m3)) << setw(8) << r.m3 << " " - << setprecision(5) - << setw(8) << r.s00 << setw(8) << r.s01 << setw(8) << r.s02 << setw(8) << r.s03 - << setw(8) << r.s04 << setw(8) << r.s05 << setw(8) << r.s06 << setw(8) << r.s07 - << setw(8) << r.s08 << setw(8) << r.s09; + outstr << stamp("n " ) << fixed + << setprecision(prc(r.m0)) << setw(6) << r.m0 + << setprecision(prc(r.m1)) << setw(8) << r.m1 + << setprecision(prc(r.m2)) << setw(8) << r.m2 + << setprecision(prc(r.m3)) << setw(8) << r.m3 << setprecision(5) + << " " << setw(8) << r.s00 << " " << setw(8) << r.s01 << " " << setw(8) << r.s02 << " " << setw(8) << r.s03 + << " " << setw(8) << r.s04 << " " << setw(8) << r.s05 << " " << setw(8) << r.s06 << " " << setw(8) << r.s07 + << " " << setw(8) << r.s08 << " " << setw(8) << r.s09 << " " + << " " << setw(8) << r.s10 << " " << setw(8) << r.s11 << " " << setw(8) << r.s12 << " " << setw(8) << r.s13 + << " " << setw(8) << r.s14 << " " << setw(8) << r.s15 << " " << setw(8) << r.s16 << " " << setw(8) << r.s17 + << " " << setw(8) << r.s18 << " " << setw(8) << r.s19 << " " + << " " << setw(8) << r.s20 << " " << setw(8) << r.s21 << " " << setw(8) << r.s22 << " " << setw(8) << r.s23; + file << outstr; +} + +void ResultI::outbinn( const std::vector<RESULT_DATA>& r, bool isaccumtime) { + using namespace std; + ostringstream outstr; + outstr << stamp("s ", true ) << fixed + << setprecision(prc(r.at(0).m0)) << setw(6) << r.at(0).m0 + << setprecision(prc(r.at(0).m1)) << setw(8) << r.at(0).m1 + << setprecision(prc(r.at(0).m2)) << setw(8) << r.at(0).m2 + << setprecision(prc(r.at(0).m3)) << setw(8) << r.at(0).m3 + << setw(4) << r.size() << setprecision(5); + for( unsigned int i = 0; i < r.size(); i++ ) { + outstr << setw(4) << r.at(i).binfactor + << " " << setw(8) << r.at(i).s00 << " " << setw(8) << r.at(i).s01 << " " << setw(8) << r.at(i).s02 << " " << setw(8) << r.at(i).s03 + << " " << setw(8) << r.at(i).s04 << " " << setw(8) << r.at(i).s05 << " " << setw(8) << r.at(i).s06 << " " << setw(8) << r.at(i).s07 + << " " << setw(8) << r.at(i).s08 << " " << setw(8) << r.at(i).s09; + } file << outstr; }
View file
turbina_core_m-1.10.tar.bz2/results.h -> turbina_core_m-1.20.tar.bz2/results.h
Changed
@@ -15,12 +15,12 @@ std::fstream file; std::fstream cnt_file; std::string data_copy; - + std::string current_file; std::string current_cnt; ResultI(void); ~ResultI() {}; - std::string stamp(const std::string& prefix); + std::string stamp(const std::string& prefix, bool prevs=false ); std::string parstamp(); std::string comstamp(); std::string datstampBase(void); @@ -34,8 +34,9 @@ void close(); unsigned int prc(double); void outdata(const RESULT_DATA& r, bool isaccumtime=false); + void outdata_pre(const RESULT_DATA& r ); void out_selfmeas_data(const RESULT_DATA& r, bool isaccumtime=false); - void outbinn(const RESULT_DATA& r, bool isaccumtime=false); + void outbinn( const std::vector<RESULT_DATA>& r, bool isaccumtime=false); void outcnt(const std::valarray<COUNT_T>& counts); void outmode(const std::string&); void outstar(const std::string&);
View file
turbina_core_m-1.10.tar.bz2/sci.cpp -> turbina_core_m-1.20.tar.bz2/sci.cpp
Changed
@@ -2,17 +2,21 @@ #include <iostream> #include "sci.h" +#include "astrotime.h" namespace { - inline std::valarray<double>& o( COUNT_T& x, std::valarray<double>& m ) { - static std::valarray<double> v(n_chan); +/* inline std::valarray<double> o( COUNT_T& x, std::valarray<double>& m ) { + std::valarray<double> v(n_chan); v = (std::valarray<double>)x - m; return v; + }*/ + template<class T> std::valarray<T> o( COUNT_T& x, std::valarray<T>& m ) { + return (std::valarray<T>)x - m; } - inline std::valarray<double>& ov(COUNT_T& x, std::valarray<double>& m ) { - static std::valarray<double> t(n_mom); +/* inline std::valarray<double> ov(COUNT_T& x, std::valarray<double>& m ) { + std::valarray<double> t(n_mom); t0 = (double)x.a - m0; t1 = (double)x.b - m1; t2 = (double)x.c - m2; @@ -24,10 +28,27 @@ t8 = t1; t9 = t2; return t; + }*/ + template<class T> std::valarray<T> ov( COUNT_T& x, std::valarray<T>& m ) { + std::valarray<T> t(n_mom); + t4 = t5 = t6 = t0 = (double)x.a - m0; + t7 = t8 = t1 = (double)x.b - m1; + t9 = t2 = (double)x.c - m2; + t3 = (double)x.d - m3; + return t; + } + + template<class T> std::valarray<T> ou( COUNT_T& x, std::valarray<T>& m ) { + std::valarray<T> t(n_mom); + t0 = (double)x.a - m0; + t4 = t1 = (double)x.b - m1; + t7 = t5 = t2 = (double)x.c - m2; + t9 = t8 = t6 = t3 = (double)x.d - m3; + return t; } - inline std::valarray<double>& ou(COUNT_T& x, std::valarray<double>& m ) { - static std::valarray<double> u(n_mom); +/* inline std::valarray<double> ou(COUNT_T& x, std::valarray<double>& m ) { + std::valarray<double> u(n_mom); u0 = (double)x.a - m0; u1 = (double)x.b - m1; u2 = (double)x.c - m2; @@ -39,18 +60,17 @@ u8 = u3; u9 = u3; return u; - } + }*/ } -void sci::binned(std::valarray<COUNT_T>& x, RESULT_DATA& r ) { +void sci::binned(std::valarray<COUNT_T>& x ) { unsigned int n = x.size()/2; std::valarray<COUNT_T> t(n); - for(unsigned int i=0; i < n; i++ ) { + for(unsigned int i=0; i < n; i++ ) { ti = x2*i+x2*i+1; } x.resize(n); x = t; - calcmom( x, r ); } // void sci::binned(std::valarray<COUNT_T>& x, RESULT_DATA& r ) { @@ -65,37 +85,33 @@ void sci::calcmom(std::valarray<COUNT_T>& x, RESULT_DATA& r) { COUNT_T z; - COUNT_T a; - std::valarray<double> m(4); unsigned int n = x.size(); r.m = (std::valarray<double>)x.sum()/(double)n; +// std::cerr << n << " " << r.m0 << " " << r.m1 << " " << r.m2 << " " << r.m3 << std::endl; -// for(unsigned int i=0; i < n; i++) m += (std::valarray<double>)xi; -// r.m = m/(double)n; + for(unsigned int i=0; i < n; i++) r.s0 += ov(xi, r.m )*ou(xi, r.m); + for(unsigned int i=0; i < n-1; i++ ) r.s1 += ov(xi, r.m )*ou(xi+1, r.m); + for(unsigned int i=0; i < n-2; i++ ) r.s2 += o(xi, r.m )*o(xi+2, r.m); + + r.s0 = r.s0/(double)n; + r.s0 = r.s0/(ov(z,r.m)*ou(z,r.m)); +// std::cerr << n << " " << r.s00 << " " << r.s01 << " " << r.s02 << " " << r.s03 << " " << r.s04 << " " << r.s05 << " " << r.s06 << " " << r.s07 << " " << r.s08 << " " << r.s09<< std::endl; + r.s1 = r.s1/(ov(z,r.m)*ou(z,r.m))/((double)n-1); + r.s2 = r.s2/(o(z,r.m)*o(z,r.m))/((double)n-2); +} -// std::cerr << n << " " << r.m0 << " " << r.m1 << " " << r.m2 << " " << r.m3 << std::endl; - - for(unsigned int i=0; i < n; i++) r.s0 += ov(xi, r.m )*ou(xi, r.m); - for(unsigned int i=0; i < n-1; i++ ) r.s1 += ov(xi, r.m )*ou(xi+1, r.m); - for(unsigned int i=0; i < n-2; i++ ) r.s2 += o(xi, r.m )*o(xi+2, r.m); - - r.s0 = r.s0/(double)n/(ov(z,r.m)*ou(z,r.m)); - r.s1 = r.s1/(double)n/(ov(z,r.m)*ou(z,r.m)); - r.s2 = r.s2/(double)n/(o(z,r.m)*o(z,r.m)); -/* - std::cerr << r.s00 << " " << r.s01 << " " << r.s02 << " " << r.s03 << " " - << r.s04 << " " << r.s05 << " " << r.s06 << " " << r.s07 << " " - << r.s08 << " " << r.s09 << std::endl; - std::cerr << r.s10 << " " << r.s11 << " " << r.s12 << " " << r.s13 << " " - << r.s14 << " " << r.s15 << " " << r.s16 << " " << r.s17 << " " - << r.s18 << " " << r.s19 << std::endl; - std::cerr << r.s20 << " " << r.s21 << " " << r.s22 << " " << r.s23 << std::endl; -*/ +void sci::calcvar(std::valarray<COUNT_T>& x, RESULT_DATA& r) { + COUNT_T z; + unsigned int n = x.size(); + r.m = (std::valarray<double>)x.sum()/(double)n; + for(unsigned int i=0; i < n; i++) r.s0 += ov(xi, r.m )*ou(xi, r.m); + r.s0 = r.s0/(double)n; + r.s0 = r.s0/(ov(z,r.m)*ou(z,r.m)); } /* int main(int ac, char **av ) { - + COUNT_T e; e.a = 1;
View file
turbina_core_m-1.10.tar.bz2/sci.h -> turbina_core_m-1.20.tar.bz2/sci.h
Changed
@@ -31,22 +31,23 @@ COUNT_T m(r); return m += *this; } - operator std::valarray<double> () const { + operator std::valarray<double> () const { std::valarray<double> v(4); v0 = (double)a; v1 = (double)b; v2 = (double)c; v3 = (double)d; - return v; + return v; } }; struct RESULT_DATA { + int binfactor; std::valarray<double> m; std::valarray<double> s0; std::valarray<double> s1; std::valarray<double> s2; - RESULT_DATA() {m.resize(n_chan); s0.resize(n_mom); s1.resize(n_mom); s2.resize(n_chan);} + RESULT_DATA(): binfactor(1), m(0.0,n_chan), s0(0.0,n_mom), s1(0.0,n_mom), s2(0.0,n_chan) {} RESULT_DATA operator+=(const RESULT_DATA& r) {m += r.m; s0 += r.s0; s1 += r.s1; s2 += r.s2; return *this;} RESULT_DATA operator-=(const RESULT_DATA& r) {m -= r.m; s0 -= r.s0; s1 -= r.s1; s2 -= r.s2; return *this;} RESULT_DATA operator/=(double a) {m /= a; s0 /= a; s1 /= a; s2 /= a; return *this;} @@ -54,6 +55,7 @@ namespace sci { void calcmom(std::valarray<COUNT_T>&, RESULT_DATA& ); - void binned(std::valarray<COUNT_T>&, RESULT_DATA& ); + void calcvar(std::valarray<COUNT_T>&, RESULT_DATA& ); + void binned( std::valarray<COUNT_T>& ); } #endif
View file
turbina_core_m-1.10.tar.bz2/server/server.cpp -> turbina_core_m-1.20.tar.bz2/server/server.cpp
Changed
@@ -81,8 +81,7 @@ cbtable_socket.onError = &Client::onSocketError; m_socket = new ClientSocket( &cbtable_socket, this ); m_socket->connect(m_addr); - sem_init( &this->client_sem, 0, 0 ); -// std::cerr << "sem wait connect" << std::endl; + sem_init( &client_sem, 0, 0 ); waitReply( connect_timeout ); // std::cerr << "Client constructor" << std::endl; } @@ -90,7 +89,7 @@ Client::~Client(){ // std::cerr << "Client destructor" << std::endl; delete m_socket; - sem_destroy( &this->client_sem ); + sem_destroy( &client_sem ); } void Client::sendRequest( const std::string& r ) { @@ -118,8 +117,7 @@ if( errno == EINTR ) { ErrlogSingl::instance().warning( "Signal while waiting server reply" ); if( sem_timedwait( &this->client_sem, &locktime ) < 0 ) throw std::runtime_error("Server reply timeout" ); - } - else throw std::runtime_error("Server reply unknown error" ); + } else throw std::runtime_error("Server reply unknown error" ); } }
View file
turbina_core_m-1.10.tar.bz2/server/socket.cpp -> turbina_core_m-1.20.tar.bz2/server/socket.cpp
Changed
@@ -1,6 +1,6 @@ /* * socket.cpp is a part of programm carbon -* $Id: socket.cpp,v 1.2 2008/01/23 20:41:57 victor Exp $ +* $Id: socket.cpp,v 1.3 2012/07/20 14:40:03 matwey Exp $ * Copyright (C) 2005-2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify @@ -91,7 +91,7 @@ template <class SocketTraits> BasicClientSocket<SocketTraits>::BasicClientSocket( ServerSocket* serv ){ BasicSocketBase<SocketTraits>::m_pImpl=serv->popAcceptedTraits(); SocketWatcher::instance().addSocket(this); - setState(SocketBase::Connected); + this->setState(SocketBase::Connected); } template <class SocketTraits> BasicClientSocket<SocketTraits>::~BasicClientSocket(){ @@ -110,13 +110,12 @@ template <class SocketTraits> void BasicClientSocket<SocketTraits>::connect( const typename ClientSocket::AddrType& addr ){ BasicSocketBase<SocketTraits>::m_pImpl->connect( addr ); - setState( SocketBase::Connecting ); + this->setState( SocketBase::Connecting ); } template <class SocketTraits> void BasicClientSocket<SocketTraits>::close(){ -// std::cerr << "Socket close " << std::endl; BasicSocketBase<SocketTraits>::m_pImpl->close(); - setState( SocketBase::Idle ); + this->setState( SocketBase::Idle ); } template <class SocketTraits> void BasicClientSocket<SocketTraits>::read(){ @@ -145,13 +144,13 @@ template <class SocketTraits> void BasicServerSocket<SocketTraits>::listen( const typename ServerSocket::AddrType& addr, int backlog ){ BasicSocketBase<SocketTraits>::m_pImpl->bind( addr ); BasicSocketBase<SocketTraits>::m_pImpl->listen( backlog ); - setState( SocketBase::Listening ); + this->setState( SocketBase::Listening ); accept(); } template <class SocketTraits> void BasicServerSocket<SocketTraits>::close(){ BasicSocketBase<SocketTraits>::m_pImpl->close(); - setState( SocketBase::Idle ); + this->setState( SocketBase::Idle ); } template <class SocketTraits> SocketTraits* BasicServerSocket<SocketTraits>::popAcceptedTraits(){
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.