Projects
mass
turbina-core-mass
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 7
View file
turbina-core-mass.changes
Added
@@ -0,0 +1,15 @@ +------------------------------------------------------------------- +Thu Jun 16 17:10:53 UTC 2016 - matwey@sai.msu.ru + +- Version 1.27 + +------------------------------------------------------------------- +Thu Jun 16 17:00:40 UTC 2016 - matwey@sai.msu.ru + +- Version 1.26 + +------------------------------------------------------------------- +Thu Jun 16 11:54:46 UTC 2016 - matwey@sai.msu.ru + +- Add systemd support for turbina-core-mass +
View file
turbina-core-mass.spec
Changed
@@ -1,14 +1,16 @@ # -# spec file for package turbina-core-mass (Version 1.20) +# spec file for package turbina-core-mass # # 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. # -# Please submit bug fixes or comments to matwey.kornilov@gmail.com -# - -# norootforbuild +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} # Emulate SUSE stuff for RedHat @@ -36,19 +38,18 @@ %define tarname turbina_core_m -BuildRequires: make gcc gcc-c++ rs485-devel -Summary: MASS measure daemon +Summary: MASS measuring daemon +License: GPL-2.0 +Group: Productivity/Scientific/Astronomy Name: turbina-core-mass -Version: 1.20 -Release: 1 +Version: 1.27 +Release: 0 +Url: http://curl.sai.msu.ru/hg/turbina_core_m Source: %{tarname}-%{version}.tar.bz2 Source1: defnames.h Source2: rcmass Source3: rcmass.redhat -License: GPL -Group: Productivity/Scientific/Astronomy -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -Autoreqprov: on +Source4: %{name}.service Requires(pre): turbina-core /usr/bin/getent /usr/sbin/usermod %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} # RedHat @@ -62,6 +63,17 @@ Requires(postun): %insserv_prereq %endif Requires: turbina-core +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: make +BuildRequires: rs485-devel +BuildRequires: boost-devel +%if 0%{?suse_version} > 1230 +BuildRequires: systemd-rpm-macros +%{?systemd_requires} +%define have_systemd 1 +%endif +BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -69,6 +81,16 @@ -------- Victor G. Kornilov <victor@sai.msu.ru> +%package -n prephot +Summary: MASS photometry data processing tool +Group: Productivity/Scientific/Astronomy + +%description -n prephot + +Authors: +-------- + Victor G. Kornilov <victor@sai.msu.ru> + %prep %setup -n %{tarname}-%{version} @@ -86,36 +108,62 @@ make prefix=/usr %install -make prefix=/usr install-strip DESTDIR=$RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT/var/lib/turbina/mass -mkdir -p $RPM_BUILD_ROOT/var/log/turbina/mass -mkdir -p $RPM_BUILD_ROOT/etc/turbina -install etc/mass.cfg $RPM_BUILD_ROOT/etc/turbina/mass.cfg -mkdir -p $RPM_BUILD_ROOT%{_initddir} -install -m 755 rcmass $RPM_BUILD_ROOT%{_initddir}/turbina-core-mass +make prefix=/usr install DESTDIR=%{buildroot} +mkdir -p %{buildroot}/var/lib/turbina/mass +mkdir -p %{buildroot}/var/log/turbina/mass +mkdir -p %{buildroot}/etc/turbina +install etc/mass.cfg %{buildroot}/etc/turbina/mass.cfg + +%if 0%{?have_systemd} +install -D -m 0644 %{S:4} %{buildroot}%{_unitdir}/%{name}.service +%else +install -D -m 0755 rcmass %{buildroot}%{_initddir}/turbina-core-mass +%endif %if 0%{?suse_version} -mkdir -p $RPM_BUILD_ROOT%{_sbindir} -ln -sf %{_initddir}/turbina-core-mass $RPM_BUILD_ROOT%{_sbindir}/rcturbina-core-mass +mkdir -p %{buildroot}%{_sbindir} +%if 0%{?have_systemd} +ln -s /sbin/service %{buildroot}%{_sbindir}/rcturbina-core-mass +%else +ln -s %{_initddir}/turbina-core-mass %{buildroot}%{_sbindir}/rcturbina-core-mass +%endif %endif %clean -rm -rf $RPM_BUILD_ROOT +rm -rf %{buildroot} %pre getent passwd turbina >/dev/null && %usermod_A uucp turbina +%if 0%{?have_systemd} +%service_add_pre turbina-core-mass.service +%endif %post +%if 0%{?have_systemd} +%service_add_post turbina-core-mass.service +%else %{fillup_and_insserv turbina-core-mass} +%endif %preun +%if 0%{?have_systemd} +%service_del_preun turbina-core-mass.service +%else %stop_on_removal turbina-core-mass +%endif %postun +%if 0%{?have_systemd} +%service_del_postun turbina-core-mass.service +%else %restart_on_update turbina-core-mass %insserv_cleanup +%endif %files %defattr(-,root,root,0755) +%if 0%{?have_systemd} +%{_unitdir}/turbina-core-mass.service +%else %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} # RedHat %{_initddir}/turbina-core-mass @@ -123,6 +171,7 @@ # SUSE %config %{_initddir}/turbina-core-mass %endif +%endif %if 0%{?suse_version} %attr(0755,root,root) %{_sbindir}/rcturbina-core-mass %endif @@ -131,8 +180,8 @@ %dir %attr(0755,turbina,turbina) /var/lib/turbina/mass %dir %attr(0755,turbina,turbina) /var/log/turbina/mass +%files -n prephot +%defattr(-,root,root,0755) +%attr(755,root,root) %{_bindir}/prephot + %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-mass.service
Added
@@ -0,0 +1,17 @@ +Unit +Description=Turbina core MASS daemon +After=syslog.target network.target time-sync.target + +Service +Type=simple +StandardOutput=journal +StandardError=journal +Restart=on-failure +ExecStart=/usr/bin/mass $MASS_ARGS +User=turbina +Group=turbina +CPUSchedulingPolicy=rr +CPUSchedulingPriority=50 + +Install +WantedBy=multi-user.target
View file
turbina_core_m-1.20.tar.bz2/.
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/data
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/data/log
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/data/out
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/etc
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/infras
Deleted
-(directory)
View file
turbina_core_m-1.20.tar.bz2/server
Deleted
-(directory)
View file
turbina_core_m-1.27.tar.bz2/.hg_archival.txt
Added
@@ -0,0 +1,5 @@ +repo: 63489118e731e35c38269c30a1c34351c8991554 +node: 96d782fd2a7b681978338f3deab72968c2058be8 +branch: default +latesttag: 1.27 +latesttagdistance: 1
View file
turbina_core_m-1.27.tar.bz2/.hgsub
Added
@@ -0,0 +1,2 @@ +infras = infras +server = server
View file
turbina_core_m-1.27.tar.bz2/.hgsubstate
Added
@@ -0,0 +1,2 @@ +309a30754f90b3329ad0c0c71691988a912ad850 infras +5e6da4aab2bdc0d21f0885409c1f938ff7fb587e server
View file
turbina_core_m-1.27.tar.bz2/.hgtags
Added
@@ -0,0 +1,5 @@ +3c48b99d2acb9119149d81d98e0e83cc359b4a82 0.2 +3ff530057cf8c5c11ea80879de78e0789fc6a59c 1.20 +89cb84822a2deb003646237e08fe2c47576d0ec5 0.1 +08874596d5cbd36a71ea4de3472e6723dcf7a11b 1.26 +9ad288a77b9277969ff405979b79ee40d31ed31d 1.27
View file
turbina_core_m-1.20.tar.bz2/Makefile -> turbina_core_m-1.27.tar.bz2/Makefile
Changed
@@ -8,18 +8,24 @@ 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.20 +PREPHOT = prephot +PREPHOT_SOURCES = prephot.o parameter_set.o processing.o coordinates.o astrotime.o +VERSION = 1.27 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;) -CXXFLAGS += -Wall -O2 -DVERSION=\"$(VERSION)\" -I./infras -I./server -I$(RS485INCLUDE) +CXXFLAGS += -std=c++98 -Wall -O2 -DVERSION=\"$(VERSION)\" -I./infras -I./server -I$(RS485INCLUDE) LDFLAGS += -lpthread -all: $(MASS) +all: $(MASS) $(PREPHOT) mass: $(MASS_SOURCES) $(CXX) $+ -o $@ $(LDFLAGS) +prephot: $(PREPHOT_SOURCES) + $(CXX) $+ -o $@ + + vpath %.cpp ./ ./infras ./server %.d : %.cpp @@ -29,6 +35,7 @@ rm -f $@.$$$$ -include $(MASS_SOURCES:.o=.d) +-include $(PREPHOT_SOURCES:.o=.d) %.o : %.cpp $(CXX) -c $(CXXFLAGS) $< -o $@ @@ -40,6 +47,7 @@ install: $(INSTALL_PROGRAM) -D -m 0755 $(MASS) $(DESTDIR)$(bindir)/$(MASS) + $(INSTALL_PROGRAM) -D -m 0755 $(PREPHOT) $(DESTDIR)$(bindir)/$(PREPHOT) install-strip: $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
View file
turbina_core_m-1.20.tar.bz2/auxiliary.cpp -> turbina_core_m-1.27.tar.bz2/auxiliary.cpp
Changed
@@ -41,16 +41,16 @@ readConst(); current_voltage = -1; current_brightness = -1; - setVoltage(voltage); -// setLightLevel(1.0); - setIllum(true); - setLight(false); + setVoltage( voltage ); +// setLightLevel( 0.5 ); +// setIllum (true ); + setLight( false ); int status = getStatus(); - getHV(status); - getIllum(status); - getLight(status); - isMirrorOnAxis(status); + getHV( status ); + getIllum( status ); + getLight( status ); + isMirrorOnAxis( status ); getTemperature(); } @@ -59,10 +59,10 @@ Lock lock; try { setHV(false); -// setIllum(false); // Ostavliaem podsvetku dlia prof. rabot +// setIllum(false); // Ostavliaem podsvetku dlia prof. rabot setLight(false); } - catch (const std::exception& e ) { // Park! Nado dodelat' vo chto by to ni stalo!!! + catch (const std::exception& e ) { // Park! Nado dodelat' vo chto by to ni stalo!!! ErrlogSingl::instance().write(e); } catch (...) { ErrlogSingl::instance().write(ERR_UKN_EXCP, " Auxiliary::Park"); @@ -84,34 +84,27 @@ return; } -const int Auxiliary::setHV(bool on) { +const int Auxiliary::setHV( bool on ) { hv = false; - if(!on) { - sendSimpleCommand(HIGH_OFF); + if( !on ) { + sendSimpleCommand( HIGH_OFF ); return 0; } - gettimeofday(&hv_on_time, NULL); -// hv_on_sec = utc.currentSec(); - sendSimpleCommand(HIGH_ON); - if(isOverlight()) { + gettimeofday( &hv_on_time, NULL ); + sendSimpleCommand( HIGH_ON ); + if( isOverlight() ) { ErrlogSingl::instance().wthrow(ERR_DEV_FUNC, "Overlight"); } hv = true; - if(ErrlogSingl::instance().isTest()) return 0; + if( ErrlogSingl::instance().isTest() ) return 0; else return hv_steadying; } 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=" -// << hv_on_time.tv_sec << " current=" << current.tv_sec << " rest=" -// << rest << std::endl; if(rest > 0) sleep(rest); return; } @@ -169,7 +162,7 @@ } void Auxiliary::setLight(bool on) { - if( on == lightOn ) return; +// if( on == lightOn ) return; if( on ) { gettimeofday(&light_on_time, NULL); sendSimpleCommand(LIGHT_ON);
View file
turbina_core_m-1.20.tar.bz2/bicounter.cpp -> turbina_core_m-1.27.tar.bz2/bicounter.cpp
Changed
@@ -1,28 +1,20 @@ #include <stdexcept> #include <iostream> -#include <math.h> // rint -#include <limits> // numeric_limits<unsigned char>::min() +#include <math.h> +#include <limits> #include "bicounter.h" #include "deftypes.h" #include "defnames.h" -//int _count_in_block = 16; -/* - const char block_size = 16; - const int byte_per_count = 2; - const int count_in_block = block_size / byte_per_count; -*/ -/* - æÕÎËÃÉÏÎÁÌØÎÙÅ ËÏÍÁÎÄÙ ËÏÎÔÒÏÌÌÅÒÁ: -*/ +// Counter operational commands const SByte Bicounter::SET_LEVEL_A = 0x41; const SByte Bicounter::SET_LEVEL_B = 0x42; const SWord Bicounter::SET_EXPOS = 0x54; const SWord Bicounter::SET_NUMBER = 0x36; const SByte Bicounter::SET_BLSIZE = 0x28; const SByte Bicounter::SET_INDUC = 0x29; -const SComm Bicounter::RUN = 0x80; // 0x80 +const SComm Bicounter::RUN = 0x80; const SComm Bicounter::STOP = 0x81; const SComm Bicounter::MASTER_OFF = 0x82; const SComm Bicounter::MASTER_ON = 0x83; @@ -32,33 +24,9 @@ const SComm Bicounter::INDUCE_ON = 0x8A; const SComm Bicounter::INDUCE_OFF = 0x8B; -/* - const char block_size = 16; - const int byte_per_count = 2; - const int count_in_block = block_size / byte_per_count; -*/ -/* äÉÁÐÁÚÏÎÙ ÄÏÐÕÓÔÉÍÙÈ ÚÎÁÞÅÎÉÊ ÐÁÒÁÍÅÔÒÏ× ÂÉËÁÕÎÔÅÒÁ */ -// const int MIN_BLOCK_SIZE = 1; -// const int MAX_BLOCK_SIZE = 16; -// const int MAX_DATA = 1000; - -/* æÌÁÇÉ ÓÏÓÔÏÑÎÉÑ ËÏÎÔÒÏÌÌÅÒÁ: */ -// const int FLAG_ACTIVE = 0x01; // active_on -// const int FLAG_INDUCE = 0x02; // induce_on -// const int FLAG_SHORT = 0x04; // 1-byte data -// const int FLAG_SLAVE = 0x08; // slave - 1, master - 0 -// const int FLAG_SHUTTER = 0x10; // shutter_on -// const int FLAG_TEST = 0x20; // test -// const int FLAG_COUNT = 0x80; // Integration in process -//} - using namespace std; -Bicounter::Bicounter(Config& config, RS485& rs485, const std::string& name) - : Module(config, rs485, name) { - -// cerr << "Constructor of Bicounter " << name << "\n"; - +Bicounter::Bicounter(Config& config, RS485& rs485, const std::string& name) : Module(config, rs485, name) { readConst(); sendByteCommand(SET_BLSIZE, block_size); _levelA = config.inp<double>(sect_device, name, "discriminationa"); @@ -66,8 +34,7 @@ } inline char codeLevel(double level, unsigned char c1, unsigned char c2) { - int ilevel = int(rint( 255 + c2 - - level*(255.0 + c2 - c1) ) ); + int ilevel = int(rint( 255 + c2 - level*(255.0 + c2 - c1) ) ); checkMinMax<int>(numeric_limits<unsigned char>::min(), ilevel, numeric_limits<unsigned char>::max()); return (char)ilevel; @@ -75,32 +42,31 @@ void Bicounter::setLevelA(double level) { level = level ? level : _levelA; - sendByteCommand(SET_LEVEL_A, codeLevel(level, constants.at(0), constants.at(1))); + sendByteCommand( SET_LEVEL_A, codeLevel( level, constants.at(0), constants.at(1) ) ); return; } void Bicounter::setLevelB(double level) { level = level ? level : _levelB; - sendByteCommand(SET_LEVEL_B, codeLevel(level, constants.at(0), constants.at(1))); + sendByteCommand( SET_LEVEL_B, codeLevel( level, constants.at(0), constants.at(1) ) ); return; } -const int Bicounter::getCountInBlock(void) { +const int Bicounter::getCountInBlock() { return count_in_block; } -Bicounter::~Bicounter(void) { +Bicounter::~Bicounter() { // Lock lock; // parking = true; // cerr << "~Bicounter " << name() << "\n"; } -void Bicounter::reset(void) { -// BlockCounter.reset(); +void Bicounter::reset() { Module::reset(); } -void Bicounter::stop(void) { +void Bicounter::stop() { sendSimpleCommand(STOP); } @@ -110,7 +76,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; } @@ -138,8 +104,6 @@ return; } -// òÁÂÏÔÁ Ó ÁËÔÉ×ÎÙÍÉ ÄÁÎÎÙÍÉ - void Bicounter::run(bool etest) { if(!etest) sendSimpleCommand(RUN); else sendSimpleCommand(RUN_TEST);
View file
turbina_core_m-1.20.tar.bz2/bicounter.h -> turbina_core_m-1.27.tar.bz2/bicounter.h
Changed
@@ -7,9 +7,9 @@ */ class Bicounter : public Module { - static const char block_size = 16; + static const char block_size = 32; static const int byte_per_count = 2; - static const int count_in_block = block_size / byte_per_count; + static const int count_in_block = block_size/byte_per_count; static const SByte SET_LEVEL_A; static const SByte SET_LEVEL_B; @@ -43,24 +43,22 @@ @param cnf Configuration parameters tree (usually read from device.cfg) @param nm ÉÍÑ ÍÏÄÕÌÑ - ÐÏÄÓÅËÃÉÉ × ÓÅËÃÉÉ \a parent ÄÅÒÅ×Á Module::cnf ("Bicounter 1" ÉÌÉ "Bicounter 2") */ - - Bicounter(Config& config, RS485& rs485, const std::string& name); - ~Bicounter(void); - - void reset(void); - void setNumber(int exposNumber); // õÓÔÁÎÏ×ËÁ ËÏÌÉÞÅÓÔ×Á ÍÉËÒÏÜËÓÐÏÚÉÃÉÊ × ÚÁÐÕÓËÅ - void setExpos(double expos); // õÓÔÁÎÏ×ËÁ ÍÉËÒÏÜËÓÐÏÚÉÃÉÉ × ÍÉËÒÏÓÅËÕÎÄÁÈ - void setMaster(bool on); - void setActive(bool on); - void setInduce(bool on); - void setInductor(Module* module); - void setLevelA(double level=0); // po umolchaniyu - iz Configa - void setLevelB(double level=0); // --''-- - void setLevels() {setLevelA(0); setLevelB(0);} - void run(bool etest=false); - int runTest(void); - void stop(void); - static const int getCountInBlock(void); + Bicounter(Config& config, RS485& rs485, const std::string& name); + ~Bicounter(); + void reset(); + void setNumber(int exposNumber); // Number of microexposures in serie + void setExpos(double expos); // Microexposure set in microsec + void setMaster(bool on); + void setActive(bool on); + void setInduce(bool on); + void setInductor(Module* module); + void setLevelA(double level=0); // default from configuration not 0 + void setLevelB(double level=0); // default from configuration not 0 + void setLevels() {setLevelA(0); setLevelB(0);} + void run(bool etest=false); + int runTest(); + void stop(); + static const int getCountInBlock(); }; #endif
View file
turbina_core_m-1.20.tar.bz2/channel.h -> turbina_core_m-1.27.tar.bz2/channel.h
Changed
@@ -10,7 +10,7 @@ class OneChannel { private: Bicounter* bic; - std::string _code; // 1a, 2a, 1b or 2b + std::string _code; // 1a, 2a, 1b or 2b public: void init(Bicounter* _bic, std::string& _code_);
View file
turbina_core_m-1.20.tar.bz2/etc/mass.cfg -> turbina_core_m-1.27.tar.bz2/etc/mass.cfg
Changed
@@ -1,18 +1,18 @@ Section "General" SubSection "Site" - DeviceNumber MD09 ;device serial number - SiteName KGO ;observatory or site na - Longitude 2 50 40 ;longitude of the site: - Latitude +43 44 12 ;latitude of th - EndSubSection + DeviceNumber MD41 ;device serial number + SiteName KGO ;observatory or site name + Longitude 2 50 40 ;longitude of the site + Latitude +43 44 12 ;latitude of the site + EndSubSection SubSection "Common" - Device /dev/rs485lpt0 ; + Device /dev/ttyUSB0 ; BaudeRate 920 ; EndSubSection EndSection Section "Operations" SubSection "Normal mode" - Exposition 1.0 ;micro-exposition time in ms (>=1) + Exposition 0.5 ;micro-exposition time in ms (>=1) BaseTime 1 ;base time in sec. AccumTime 60 ;accumulation time in sec. MinimalStarFlux 100 ;For centering control @@ -21,16 +21,16 @@ AccumTime 10 ;full time of the measurement EndSubSection SubSection "Tests" - FluxEstimationTime 4 ;sec - ExchangeTestTime 10 ;exchange test duration in sec - DetectorTestTime 8 ; - DetectorLight 0.23 ;reference light level for detector test - TestCounts 70 120 300 700 ;reference counts into channels - FluxTolerance 0.2 ;allowed tolerance for real counts - NonPoisTolerance 0.2 ;allowed tolerance for non - StatisticLight 0.5 ;light levels for statistical test - Modulation 0.1 ;modulation amplitude for statisti - CountingLight 0.5 ; + FluxEstimationTime 4 ; sec + ExchangeTestTime 4 ; exchange test duration in sec + DetectorTestTime 8 ; + DetectorLight 0.1 ; reference light level for detector test + TestCounts 1266 838 729 663 ; reference counts into channels + FluxTolerance 0.1 ; allowed tolerance for real counts + NonPoisTolerance 0.1 ; allowed tolerance for non + StatisticLight 0.1 ; light levels for statistical test + Modulation 0.1 ; modulation amplitude for statisti + CountingLight 0.06 ; EndSubSection EndSection Section "Devices" @@ -38,32 +38,32 @@ Module 0x01 ;module unique address PMTNumberA AJ4384 ;PMT serial number PMTNumberB AJ4573 ;PMT serial number - Identification 0x01 0x06 0x6B 0x07 + Identification 0x01 0x06 0x9d 0x03 ; DiscriminationA 0.4 ; DiscriminationB 0.4 ; - NonLinearityA 18.0 ; - NonLinearityB 18.0 ; - NonPoissonA 1.028 ; - NonPoissonB 1.039 ; + NonLinearityA 16.6 ; + NonLinearityB 17.7 ; + NonPoissonA 1.033 ; + NonPoissonB 1.016 ; EndSubSection SubSection "Bicounter 2" Module 0x02 PMTNumberA AH7806 PMTNumberB AJ4567 ;PMT serial number - Identification 0x01 0x06 0x6B 0x07 + Identification 0x01 0x06 0x9d 0x03 DiscriminationA 0.4 ; - DiscriminationB 0.5 ; - NonLinearityA 18.0 ; - NonLinearityB 17.0 ; - NonPoissonA 1.027 ; - NonPoissonB 1.038 ; + DiscriminationB 0.4 ; + NonLinearityA 19.9 ; + NonLinearityB 16.5 ; + NonPoissonA 1.017 ; + NonPoissonB 1.014 ; EndSubSection SubSection "Auxiliary" Module 0x10 - Identification 0x01 0x08 0x2a 0x07 - HighVoltage 725 ;default high voltage level, V + Identification 0x01 0x08 0x03 0x09; + HighVoltage 750 ;default high voltage level, V PollingTime 100 ;temperature polling period in s - IlluminationLevel 0.5 ;default illumination level + IlluminationLevel 0.2 ;default illumination leve HVsteadying 20 ;sec LightSteadying 5 ;sec EndSubSection @@ -78,7 +78,7 @@ EndSection Section "Optics" SubSection "Common" - Magnification 16.20 ;magnification factor of the device + Magnification 15.20 ;magnification factor of the device EndSubSection SubSection "Segment A" Inner 0.00 ;
View file
turbina_core_m-1.27.tar.bz2/etc/mass_md09.cfg
Added
@@ -0,0 +1,99 @@ +Section "General" + SubSection "Site" + DeviceNumber MD09 ;device serial number + SiteName KGO ;observatory or site name + Longitude 2 50 40 ;longitude of the site + Latitude +43 44 12 ;latitude of the site + EndSubSection + SubSection "Common" + Device /dev/rs485lpt0 ; + BaudeRate 920 ; + EndSubSection +EndSection +Section "Operations" + SubSection "Normal mode" + Exposition 0.5 ;micro-exposition time in ms (>=1) + BaseTime 1 ;base time in sec. + AccumTime 60 ;accumulation time in sec. + MinimalStarFlux 80 ;For centering control + EndSubSection + SubSection "Background measurement" + AccumTime 10 ;full time of the measurement + EndSubSection + SubSection "Tests" + FluxEstimationTime 4 ;sec + ExchangeTestTime 10 ;exchange test duration in sec + DetectorTestTime 8 ; + DetectorLight 0.25 ;reference light level for detector test + TestCounts 1195 3063 4274 1291 ;reference counts into channels + FluxTolerance 0.2 ;allowed tolerance for real counts + NonPoisTolerance 0.2 ;allowed tolerance for non + StatisticLight 0.1 ;light levels for statistical test + Modulation 0.1 ;modulation amplitude for statisti + CountingLight 0.07 ; + EndSubSection +EndSection +Section "Devices" + SubSection "Bicounter 1" + Module 0x01 ;module unique address + PMTNumberA AJ4384 ;PMT serial number + PMTNumberB AJ4573 ;PMT serial number + Identification 0x01 0x06 0x9d 0x03 + DiscriminationA 1.0 ; 0.45 ; + DiscriminationB 1.0 ; 0.45 ; + NonLinearityA 18.0 ; + NonLinearityB 18.0 ; + NonPoissonA 1.028 ; + NonPoissonB 1.039 ; + EndSubSection + SubSection "Bicounter 2" + Module 0x02 + PMTNumberA AH7806 + PMTNumberB AJ4567 ;PMT serial number + Identification 0x01 0x06 0x5b 0x1a + DiscriminationA 1.0 ; 0.45 ; + DiscriminationB 1.0 ; 0.55 ; + NonLinearityA 18.0 ; + NonLinearityB 17.0 ; + NonPoissonA 1.027 ; + NonPoissonB 1.038 ; + EndSubSection + SubSection "Auxiliary" + Module 0x10 + Identification 0x19 0x08 0x03 0x09 + HighVoltage 750 ;default high voltage level, V + PollingTime 100 ;temperature polling period in s + IlluminationLevel 0.5 ;default illumination leve + HVsteadying 20 ;sec + LightSteadying 5 ;sec + EndSubSection +EndSection +Section "Channels" + SubSection "Configuration" + ChannelA Counter 2A ;counter for Channel A + ChannelB Counter 2B ;counter for Channel B + ChannelC Counter 1A ;counter for Channel C + ChannelD Counter 1B ;counter for Channel D + EndSubSection +EndSection +Section "Optics" + SubSection "Common" + Magnification 16.20 ;magnification factor of the device + EndSubSection + SubSection "Segment A" + Inner 0.00 ; + Outer 1.27 ;outer diameter of A mirror, mm + EndSubSection + SubSection "Segment B" + Inner 1.30 ;inner diameter of B mirror, mm + Outer 2.15 ;outer diameter of B mirror, mm + EndSubSection + SubSection "Segment C" + Inner 2.20 ;inner diameter of C mirror, mm + Outer 3.85 ;outer diameter of C mirror, mm + EndSubSection + SubSection "Segment D" + Inner 3.90 ;inner diameter of D mirror, mm + Outer 5.50 ;outer diameter of D mirror, mm + EndSubSection +EndSection
View file
turbina_core_m-1.27.tar.bz2/etc/mass_md41.cfg
Added
@@ -0,0 +1,99 @@ +Section "General" + SubSection "Site" + DeviceNumber MD41 ;device serial number + SiteName KGO ;observatory or site name + Longitude 2 50 40 ;longitude of the site + Latitude +43 44 12 ;latitude of the site + EndSubSection + SubSection "Common" + Device /dev/ttyUSB0 ; + BaudeRate 920 ; + EndSubSection +EndSection +Section "Operations" + SubSection "Normal mode" + Exposition 0.5 ;micro-exposition time in ms (>=1) + BaseTime 1 ;base time in sec. + AccumTime 60 ;accumulation time in sec. + MinimalStarFlux 100 ;For centering control + EndSubSection + SubSection "Background measurement" + AccumTime 10 ;full time of the measurement + EndSubSection + SubSection "Tests" + FluxEstimationTime 4 ; sec + ExchangeTestTime 4 ; exchange test duration in sec + DetectorTestTime 8 ; + DetectorLight 0.1 ; reference light level for detector test + TestCounts 1266 838 729 663 ; reference counts into channels + FluxTolerance 0.1 ; allowed tolerance for real counts + NonPoisTolerance 0.1 ; allowed tolerance for non + StatisticLight 0.1 ; light levels for statistical test + Modulation 0.1 ; modulation amplitude for statisti + CountingLight 0.06 ; + EndSubSection +EndSection +Section "Devices" + SubSection "Bicounter 1" + Module 0x01 ;module unique address + PMTNumberA AJ4384 ;PMT serial number + PMTNumberB AJ4573 ;PMT serial number + Identification 0x01 0x06 0x9d 0x03 ; + DiscriminationA 0.2 ; + DiscriminationB 0.2 ; + NonLinearityA 16.6 ; + NonLinearityB 17.7 ; + NonPoissonA 1.033 ; + NonPoissonB 1.016 ; + EndSubSection + SubSection "Bicounter 2" + Module 0x02 + PMTNumberA AH7806 + PMTNumberB AJ4567 ;PMT serial number + Identification 0x01 0x06 0x9d 0x03 + DiscriminationA 0.2 ; + DiscriminationB 0.2 ; + NonLinearityA 19.9 ; + NonLinearityB 16.5 ; + NonPoissonA 1.017 ; + NonPoissonB 1.014 ; + EndSubSection + SubSection "Auxiliary" + Module 0x10 + Identification 0x01 0x08 0x28 0x1f; 01 08 28 1f + HighVoltage 750 ;default high voltage level, V + PollingTime 100 ;temperature polling period in s + IlluminationLevel 0.2 ;default illumination leve + HVsteadying 20 ;sec + LightSteadying 5 ;sec + EndSubSection +EndSection +Section "Channels" + SubSection "Configuration" + ChannelA Counter 2A ;counter for Channel A + ChannelB Counter 2B ;counter for Channel B + ChannelC Counter 1A ;counter for Channel C + ChannelD Counter 1B ;counter for Channel D + EndSubSection +EndSection +Section "Optics" + SubSection "Common" + Magnification 15.20 ;magnification factor of the device + EndSubSection + SubSection "Segment A" + Inner 0.00 ; + Outer 1.27 ;outer diameter of A mirror, mm + EndSubSection + SubSection "Segment B" + Inner 1.30 ;inner diameter of B mirror, mm + Outer 2.15 ;outer diameter of B mirror, mm + EndSubSection + SubSection "Segment C" + Inner 2.20 ;inner diameter of C mirror, mm + Outer 3.85 ;outer diameter of C mirror, mm + EndSubSection + SubSection "Segment D" + Inner 3.90 ;inner diameter of D mirror, mm + Outer 5.50 ;outer diameter of D mirror, mm + EndSubSection +EndSection
View file
turbina_core_m-1.27.tar.bz2/infras/.hgtags
Added
@@ -0,0 +1,32 @@ +01e464286edc36ad99fb10a2d4c994cd6fe408f2 ameba-0_58 +01e464286edc36ad99fb10a2d4c994cd6fe408f2 dome-1_23 +01e464286edc36ad99fb10a2d4c994cd6fe408f2 mokko-v1 +01e464286edc36ad99fb10a2d4c994cd6fe408f2 monitor-1_29 +2ba85c63ef00b7e14a329248c4194c551d15c960 ameba-0-49 +31f3e4725f5de92e8a8e9cb768c883ad992e46d8 ameba-0_21 +3b70b4af4eac10e493bb52242698fe983707bcdb dome-1_01 +498eca265f129013c09828f58c9a80087a572cb3 dimm-2_11 +4f6471d0b795ab6afab2dacf69b1dcdf67294d2d tlsp-0_20 +5433368217003ff8568b1952e217d5e5804ffd6e turb-0_2 +5f2bc6b675a1b282d79c9d18c54ae3342df932ad tlsp-0_15 +619ddedc25fdbbdd896eb398b421ed6d14aa4870 begin +64bb84845b2799cd72cbf384d8c9fc2e24704ebe ameba-0_57 +64bb84845b2799cd72cbf384d8c9fc2e24704ebe dimm-2_33 +6d962bd1c2cd184bf39ed96aac0c1ff2444054c3 dimm-2_26 +6d962bd1c2cd184bf39ed96aac0c1ff2444054c3 dome-1_19 +6d962bd1c2cd184bf39ed96aac0c1ff2444054c3 monitor-1_07 +72e27a05f3e9b9782b9e757788074403df1f1cd2 monitor-1_31 +72e27a05f3e9b9782b9e757788074403df1f1cd2 monitor-1_32 +7dd7c2a765f9be0ccd6436ebbecfb341a4994b1b dome-1_03 +819f0950d6a58e68902cf37bef9011826095ae61 tlsp-0_13 +8609d5073806cfdd04aaf380553cc5499fae53e6 ameba-0_40 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff ameba-0_59 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff ameba-0_60 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff ameba-0_61 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff ameba-0_62 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff dimm-2_45 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff dimm-2_46 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff dome-1_24 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff monitor-1_30 +d2fadec4b7b176044ac4431c5ad1ec2e41fd28ff turbina_core_m-1_20 +ecb66a74160bc8bcc9ece732712a929c7a7ff91f ameba-0_12
View file
turbina_core_m-1.20.tar.bz2/infras/comms.cpp -> turbina_core_m-1.27.tar.bz2/infras/comms.cpp
Changed
@@ -268,7 +268,7 @@ return id + " OK WAIT=" + wait.str(); } -void setting( std::vector<std::string>& s, std::string& k ) { +void setting( std::vector<std::string>& s ) { std::string::size_type i; for( unsigned int j = 0; j < s.size(); j++ ) { if( (i = s.at(j).find("=",0)) != std::string::npos ) { @@ -276,14 +276,17 @@ std::string val = s.at(j).substr( i+1 ); DEVICE::device_ptr()->set(key,val); s.at(j).erase(i); - } else k += " " + s.at(j); + } else{ +// DEVICE::device_ptr()->set(s.at(j) ); Fo +// k += " " + s.at(j); + } } } -void setting( std::vector<std::string>& s ) { - std::string t; - setting( s, t ); -} +// void setting( std::vector<std::string>& s ) { +// std::string t; +// setting( s, t ); +// } std::string Comm::run( std::auto_ptr<TASK> ts ) { std::string id = ts->id; @@ -303,9 +306,9 @@ std::string Comm::set( std::auto_ptr<TASK> ts ) { Lock lock; - std::string monkey; - setting( ts->params, monkey ); - if( !monkey.empty() ) throw ErrSyn( ERR_PROT_NOVAL, monkey ); +// std::string monkey; + setting( ts->params ); +// if( !monkey.empty() ) throw ErrSyn( ERR_PROT_NOVAL, monkey ); return ts->id + ok_stat_ready; } @@ -354,6 +357,7 @@ std::string id = ts->id; if( !DEVICE::exist() ) return ts->id + ok_stat_parked; Argums argums( std::auto_ptr<Lock>( new Lock() ), ts, (TFUNC)&DEVICE::destroy ); + setting(argums.ptr_task.get()->params); std::ostringstream wait; wait << DEVICE::parkLife(); Thread::create( &argums );
View file
turbina_core_m-1.20.tar.bz2/infras/coordinates.cpp -> turbina_core_m-1.27.tar.bz2/infras/coordinates.cpp
Changed
@@ -20,7 +20,7 @@ double x = Hour::R*nint(hh); char sep = stm.iword(separ_index)? ':' : ' '; stm << std::setw(2) << std::setfill('0') << (int)x << sep << std::setw(2) << (int)fmod( 60*x, 60 ) - << sep << std::setw(2) << (int)fmod( fmod( 3600*x, 3600 ), 60 ) << std::setfill(' '); + << sep << std::setw(2) << (int)fmod( rint( fmod( rint(3600*x), 3600 ) ), 60 ) << std::setfill(' '); return stm; } @@ -29,8 +29,8 @@ double x = stm.iword(format_index)? Degree::R*nint(dd) : Degree::R*sint(dd); if( stm.iword(format_index) ) { stm << std::setw(3); stm.iword(format_index) = false; } else stm << std::setw(0) << ((x > 0) ? '+' : '-' ) << std::setw(2); - stm << std::setfill('0') << (int)fabs(x) << ' ' << std::setw(2) << (int)fmod( 60*fabs(x), 60 ) - << ' ' << std::setw(2) << (int)fmod( fmod( 3600*fabs(x), 3600 ), 60 ) << std::setfill(' '); + stm << std::setfill('0') << (int)fabs(x) << ' ' << std::setw(2) << (int)fmod( rint(60*fabs(x)), 60 ) + << ' ' << std::setw(2) << (int)fmod( fmod( rint(3600*fabs(x)), 3600 ), 60 ) << std::setfill(' '); return stm; }
View file
turbina_core_m-1.20.tar.bz2/infras/exchange.cpp -> turbina_core_m-1.27.tar.bz2/infras/exchange.cpp
Changed
@@ -1,6 +1,10 @@ #include <sys/ioctl.h> +#include <sys/poll.h> #include <fcntl.h> +#include <unistd.h> +#include <algorithm> #include <sstream> +#include <cassert> #include <cerrno> #include <cstring> #include <sys/time.h> @@ -11,14 +15,35 @@ #include <signal.h> #include <cmath> -#include <mcua.h> -#include <rserrno.h> +#ifndef NO_RS485_LEGACY +#include <linux/rs485/mcua.h> +#include <linux/rs485/rserrno.h> +#else +#define SignalPKL 0x81 +#define SignalPBO 0x82 +#define SignalEER 0x83 +#define SignalDSC 0x84 +#define SignalCOL 0x86 +#define SignalUND 0x90 +#define SignalACK 0x87 +#define SignalNAK 0x96 +#define SignalNOD 0xA5 +#define SignalACN 0xB4 +#define SignalACY 0xC3 +#define SignalACW 0xD2 +#define SignalSINC 0xE1 +#define SignalDNG 0xF0 +#endif // NO_RS485_LEGACY + #include <exchange.h> -#include <unistd.h> // write, usleep, close +#include <unistd.h> // write, usleep, close -const int MAXRETRY = 2; // Maximal number of transaction attempts -const int MAX_PACKET_SIZE = 32; // Maximal packet size +const int MAXRETRY = 3; // Maximal number of transaction attempts +const int MAX_PACKET_SIZE = 32; // Maximal packet size +const unsigned char MASK_CNT_PACKET = 0x60; +const unsigned char MASK_ADR_PACKET = 0x1f; +const int SIGNAL_BASE = 0x80; const int ACK = SignalACK; const int NAK = SignalNAK; @@ -35,6 +60,20 @@ const int EER = SignalEER; const int UND = SignalUND; +const int END = 0xC0 ; // indicates end of frame +const int ESC = 0xDB ; // indicates byte stuffing +const int ESC_END = 0xDC ; // ESC ESC_END means END 'data' +const int ESC_ESC = 0xDD ; // ESC ESC_ESC means ESC 'data' + +namespace { + inline unsigned char low(short i) { + return (unsigned char)(i&0x00ff); + } + inline unsigned char high(short i) { + return (unsigned char)((i&0xff00)>>8); + } +} + enum { INFO_SIG, LOOP_SIG }; struct Signl { @@ -79,6 +118,7 @@ } namespace { +#ifndef NO_RS485_LEGACY const std::string RS_strerror(int errnum) { switch(errnum) { case ERSNODEVICE : @@ -98,178 +138,178 @@ return "Unknown RS485 error"; } } -} - -/* - int micro_delay( int mks ) { - struct timeval moms; - struct timeval mome; - int mksd = 0; - int secd = 0; - gettimeofday( &moms, NULL ); - while( mksd < mks ) { - gettimeofday( &mome, NULL ); - secd = mome.tv_sec - moms.tv_sec; - mksd = mome.tv_usec - moms.tv_usec; - if( secd < 0 || secd > 1 ) return( -1); - if( secd > 0 ) mksd += 1000*1000; - } - return( 0 ); - } - - int micro_wait( int mks ) { - static struct timeval moms; - struct timeval mome; - int mksd = 0; - int secd = 0; - if( mks == 0 ){ - gettimeofday( &moms, NULL ); - return( 0 ); - } - while( mksd < mks ) { - gettimeofday( &mome, NULL ); - secd = mome.tv_sec - moms.tv_sec; - mksd = mome.tv_usec - moms.tv_usec; - if( secd < 0 || secd > 1 ) return( -1); - if( secd > 0 ) mksd += 1000*1000; - } - return( 0 ); - } - -*/ - -RS485impl::RS485log::RS485log( const unsigned char *inp, const int nbyte, RS485impl* ptr ) : ptr_up(ptr) { - s << std::hex << std::fixed << std::setfill('0'); - for( int i=0; i < nbyte; i++ ) s << std::setw(2) << (int)inpi << " "; - s << "<- "; -} - -RS485impl::RS485log::~RS485log() { - ptr_up->logstr = "-> " + s.str(); -} +#endif // NO_RS485_LEGACY -void RS485impl::RS485log::log( const std::string& t ) { - s << t << " "; -} + long baudrate_flag( int r ) { + long flags = 0; + switch( (int)(115200*rint(r/115.200)) ) { + case 115200: + flags = B115200; + break; + case 230400: + flags = B230400; + break; + case 460800: + flags = B460800; + break; + case 921600: + flags = B921600; + break; + default: + flags = -1; + } + return flags; + } -void RS485impl::RS485log::log( unsigned char *out, const int n ) { - for( int i=0; i < n; i++ ) s << std::setw(2) << (int)outi << " "; -} + unsigned char crc(const unsigned char *buf, size_t size) { + // calculation of the control sum (crc), return crc, + // *buf - poiter to data, size - buffer size + const unsigned short divisor = 0x700; + unsigned short acc = 0; + while (size--) { + acc |= *(buf++); + for (size_t i = 0; i < 8; i++) + acc = acc & 0x8000 ? (acc << 1)^divisor : acc << 1; + } + for (size_t i = 0; i < 8; i++) + acc = acc & 0x8000 ? (acc << 1)^divisor : acc << 1; + acc = acc >> 8; + return (unsigned char)acc; + } -int RS485impl::transaction(const unsigned char *buffi, const int nbyte, unsigned char *buffo) { - int reply = 0; - char temporalIO_BUFF_SIZE; - int attempt = MAXRETRY; - packet_number++; - if( nbyte > MAX_PACKET_SIZE ) throw ErrFatal( "Too long command. Why??" ); - RS485log scr( buffi, nbyte, this ); - RSTimer time = RSTimer( 1.0 ); // 0.5 -/* if( packet_number%17 == 0 ) { // RS Timer debug - timespec a; - a.tv_sec = (long)2; - a.tv_nsec = (long)rint(0.5e+9); - if( nanosleep( &a, NULL ) < 0 ) std::cerr << "Nanosleep - Action was interrupted" << std::endl; - scr.log( Signal::abbrev(EER)); - return EER; - }*/ - while( attempt-- ) { - memcpy( temporal, buffi, nbyte ); - reply = write( id_mcua, temporal, nbyte ); - if( time.out() ) throw ErrDriver( "RS driver timeout" ); - if( reply < 0 ) { - errors_number++; - scr.log(RS_strerror(errno)); - if( attempt == 0 ) { - throw ErrDriver( RS_strerror(errno) ); + int slip_esc( const unsigned char *s, unsigned char *d, int len ) { + unsigned char* ptr; + unsigned char c; + ptr = d; + // For each byte in the packet, send the appropriate character + // sequence, according to the SLIP protocol. + while ( len-- > 0) { + switch ( c = *s++ ) { + case END: + *ptr++ = ESC; + *ptr++ = ESC_END; + break; + case ESC: + *ptr++ = ESC; + *ptr++ = ESC_ESC; + break; + default: + *ptr++ = c; + break; } - usleep(10000); // ×ÓÔÁ×ÉÔØ × RESET - ioctl( id_mcua, RS_RESET ); - scr.log( " RESET " ); - continue; - } - if( reply <= MAX_PACKET_SIZE) { // data, no Signal - memcpy( buffo, temporal+1, --reply ); - scr.log( buffo, reply ); - return reply; } - if( Signal::type(reply) == INFO_SIG ) { // info Signal - scr.log( Signal::abbrev(reply)); - return reply; + *ptr++ = END; + return ptr - d; + } + + int slip_unesc( unsigned char *s, unsigned char *d, int len ) { + unsigned char* ptr = d; + unsigned char c; + int was_esc = 0; + ptr = d; + while ( len-- > 0 ) { + switch( c = *s++ ) { + case END: +// break; Checked with repeatetive packets + return ptr - d; + case ESC: + was_esc = 1; + break; + case ESC_ESC: + if( was_esc ) { + *ptr++ = ESC; + was_esc = 0; + } else *ptr++ = c; + break; + case ESC_END: + if( was_esc ) { + *ptr++ = END; + was_esc = 0; + } else *ptr++ = c; + break; + default: + *ptr++ = c; + } } - errors_number++; - scr.log( Signal::abbrev(reply)); - usleep(1000); - } // loop Signal - return reply; + return ptr - d; + } } -RS485impl::RS485impl( const std::string& d, int r ) : packet_number(0), errors_number(0), extranum(0), device(d) { - char vers32; - if( (id_mcua = open( d.c_str(), O_RDWR )) < 0 ) { - throw ErrFatal( RS_strerror(errno) ); - } - if( ioctl( id_mcua, RS_GET_VERS, vers ) < 0 ) { - close( id_mcua ); - throw ErrFatal( RS_strerror(errno) ); - } - if( r != 0 && ioctl( id_mcua, RS_SET_BAUDRATE, r ) < 0) { - close( id_mcua ); - throw ErrFatal( "Unsupported exchange rate" ); - } - logstr = std::string("Driver version ") + std::string(vers); +BaseRS485::RS485log::RS485log( const unsigned char *inp, const int nbyte, BaseRS485* ptr ): ptr_(ptr) { + s << std::hex << std::fixed << std::setfill('0'); + for( int i=0; i < nbyte; i++ ) s << std::setw(2) << (int)inpi << " "; + s << "<- "; +} +BaseRS485::RS485log::~RS485log() { + set_logstr(ptr_, std::string("-> ") + s.str()); +} +void BaseRS485::RS485log::log( const std::string& t ) { + s << t << " "; +} +void BaseRS485::RS485log::log( unsigned char *out, const int n ) { + for( int i=0; i < n; i++ ) s << std::setw(2) << (int)outi << " "; +} +void BaseRS485::RS485log::set_logstr(BaseRS485* ptr, const std::string& str) { + ptr->logstr_ = str; } -RS485impl::~RS485impl(void) { - close( id_mcua ); +BaseRS485::BaseRS485(): packet_number(0), errors_number(0), extranum(0), cycl_prevs(0), rsize(0) { +} +BaseRS485::~BaseRS485() { +} +void BaseRS485::resetData() { + extranum = 0; + cycl_prevs = 0; + rsize = 0; } -int RS485impl::askByte( unsigned int module, const AByte command ) { +int BaseRS485::askByte( unsigned int module, const AByte command ) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; - int ret = transaction(strcomm, nsent, strread); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( ret != 1 ) throw ErrSignal( Signal::abbrev(ret) ); return (int)(*strread); } -int RS485impl::askWord( unsigned int module, const AWord command ) { +int BaseRS485::askWord( unsigned int module, const AWord command ) { int nsent = 0; int avalue = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; - int ret = transaction(strcomm, nsent, strread); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( ret != 2 ) throw ErrSignal( Signal::abbrev(ret) ); memcpy( (char*)&avalue, strread, 2 ); return avalue ; } -int RS485impl::askLong( unsigned int module, const ALong command ) { +int BaseRS485::askLong( unsigned int module, const ALong command ) { int nsent = 0; int avalue = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( ret != 3 ) throw ErrSignal( Signal::abbrev(ret) ); strread3 = ((char)strread2 < 0 ? 0xff : 0 ); memcpy( (char*)&avalue, strread, 4 ); return avalue; } -std::vector<unsigned char> RS485impl::askData( unsigned int module, const AData command ) { +std::vector<unsigned char> BaseRS485::askData( unsigned int module, const AData command ) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( ret < MAX_PACKET_SIZE ) return std::vector<unsigned char>( strread, strread+ret ); if( ret != NOD ) throw ErrSignal( Signal::abbrev(ret) ); - return std::vector<unsigned char>(); // ðÕÓÔÏÊ ×ÅËÔÏÒ - ÎÅÔ ÄÁÎÎÙÈ + return std::vector<unsigned char>(); } -BaseRS485::com_stat RS485impl::sendSimpleCommand( unsigned int module, const SComm command) { +BaseRS485::com_stat BaseRS485::sendSimpleCommand( unsigned int module, const SComm command) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( (ret == ACY) || (ret == ACK) ) return DONE; if( ret != ACW ) { throw ErrSignal( Signal::abbrev(ret) ); @@ -277,92 +317,305 @@ return BUSY; } -BaseRS485::com_stat RS485impl::sendByteCommand( unsigned int module, const SByte command, char arg) { +BaseRS485::com_stat BaseRS485::sendByteCommand( unsigned int module, const SByte command, char arg) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; strcommnsent++ = arg; - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( (ret == ACY) || (ret == ACK) ) return DONE; if( ret != ACW) throw ErrSignal( Signal::abbrev(ret) ); return BUSY; } -BaseRS485::com_stat RS485impl::sendWordCommand( unsigned int module, const SWord command, short arg) { +BaseRS485::com_stat BaseRS485::sendWordCommand( unsigned int module, const SWord command, short arg) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)command; strcommnsent++ = low( arg ); strcommnsent++ = high( arg ); - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( (ret == ACY) || (ret == ACK) ) return DONE; if(ret != ACW) throw ErrSignal( Signal::abbrev(ret) ); return BUSY; } -BaseRS485::com_stat RS485impl::sendData( unsigned int module, const SData length, const std::vector<unsigned char>& data) { +BaseRS485::com_stat BaseRS485::sendData( unsigned int module, const SData length, const std::vector<unsigned char>& data) { int nsent = 0; strcommnsent++ = (char)module; strcommnsent++ = (char)length; memcpy(strcomm+2, &data0, length ); nsent = length+2; - int ret = transaction( strcomm, nsent, strread ); + int ret = transaction(strcomm, nsent, strread, sizeof(strread)); if( (ret == ACY) || (ret == ACK) ) return DONE; if(ret != ACW) throw ErrSignal( Signal::abbrev(ret) ); return BUSY; } - -int RS485impl::sendVoid(const unsigned char *buff, const int length, unsigned char *data) { - int nsent = length; - memcpy( strcomm, buff, length ); - int ret = transaction( strcomm, nsent, strread ); - if( ret <= MAX_PACKET_SIZE ) {// data - memcpy( data, strread, ret ); - } else strcpy( (char*)data, Signal::abbrev(ret).c_str()); - return ret; +#ifndef NO_RS485_LEGACY +int RS485LegacyImpl::transaction( const unsigned char *buffi, std::size_t nbyte, unsigned char *buffo, std::size_t) { + int reply = 0; + unsigned char temporalIO_BUFF_SIZE; + int attempt = MAXRETRY; + packet_number++; + if( nbyte > MAX_PACKET_SIZE ) throw ErrFatal( "Too long command. Why??" ); + RS485log scr( buffi, nbyte, this ); + RSTimer time = RSTimer( 1.0 ); + usleep(2000); + while( attempt-- ) { + memcpy( temporal, buffi, nbyte ); + reply = write( fd_, temporal, nbyte ); + if( time.out() ) throw ErrDriver( "RS driver timeout" ); + if( reply < 0 ) { + errors_number++; + scr.log(RS_strerror(errno)); + if( attempt == 0 ) throw ErrDriver( RS_strerror(errno) ); + usleep(4000); + ioctl( fd_, RS_RESET ); + scr.log( " RESET " ); + continue; + } + if( reply <= MAX_PACKET_SIZE) { // data, no Signal + memcpy( buffo, temporal+1, --reply ); + scr.log( buffo, reply ); + return reply; + } + if( Signal::type(reply) == INFO_SIG ) { // info Signal + scr.log( Signal::abbrev(reply)); + return reply; + } + errors_number++; + scr.log( Signal::abbrev(reply)); + usleep(2000); + } // loop Signal + return reply; } - -// ôÏÖÅ ÎÅÂÅÚÏÐÁÓÎÏ, ÎÅ ÚÎÁÅÍ ÄÌÉÎÙ ÍÁÓÓÉ×Á data. -// íÏÖÅÔ, ÐÏÒÁ ÕÖÅ ÉÓÐÏÌØÚÏ×ÁÔØ Ë-ÎÉÂÕÄØ ËÏÎÔÅÊÎÅÒ? - -const int headlen = 4; - -int RS485impl::readData( unsigned char *head, unsigned char *data) { +RS485LegacyImpl::RS485LegacyImpl(int fd, int baudrate): BaseRS485(), fd_(fd) { + char vers32; + if(ioctl(fd_, RS_GET_VERS, vers) < 0) { + close(fd_); + throw ErrFatal(RS_strerror(errno)); + } + if(baudrate != 0 && ioctl(fd_, RS_SET_BAUDRATE, baudrate) < 0) { + close(fd_); + throw ErrFatal( "Unsupported exchange rate" ); + } + logstr_ = std::string("Driver version ") + std::string(vers); +} +RS485LegacyImpl::~RS485LegacyImpl() { + close(fd_); +} +std::string RS485LegacyImpl::protocol() { + return "Legacy"; +} +int RS485LegacyImpl::readData(unsigned int& from, unsigned int& numb, unsigned short *data, std::size_t) { + static const int headlen = 4; int n_read_data = 0; int ret = 0; - if( (n_read_data = read(id_mcua, strdata, IO_BUFF_SIZE )) ) { - if(n_read_data < 0) throw ErrFatal(RS_strerror(errno)); - if(n_read_data > headlen ) { // header - ret = n_read_data-headlen; - memcpy( head, strdata+1, headlen ); - memcpy( data, strdata+headlen+1, n_read_data-headlen ); + unsigned short pnum; + if( ( n_read_data = read(fd_, strdata, IO_BUFF_SIZE ) ) ) { + if( n_read_data < 0) throw ErrFatal( RS_strerror(errno) ); + if( n_read_data > headlen && !(( n_read_data - headlen )%2)) { + ret = ( n_read_data - headlen )/2; // The number of short words + from = (unsigned int)(*(strdata+2)); // Sender address + memcpy( &pnum, strdata + 3, 2 ); // The current packet number + numb = pnum + extranum; + if( pnum == 0xFFFF ) extranum += 0x10000; + memcpy( data, strdata + headlen + 1, n_read_data - headlen ); } } return ret; } +void RS485LegacyImpl::resetData() { + BaseRS485::resetData(); + if(ioctl(fd_, RS_FIFO_FLUSH) < 0) { + ErrFatal(RS_strerror(errno)); + } + if(ioctl(fd_, RS_BLNUMBER_RESET) < 0) { + ErrFatal(RS_strerror(errno)); + } +} +#endif // NO_RS485_LEGACY + +int RS485TTYImpl::transaction(const unsigned char *buffi, std::size_t nbyte, unsigned char *buffo, std::size_t buflen) { + assert(2*MAX_PACKET_SIZE + 1 <= IO_BUFF_SIZE); + assert(nbyte < MAX_PACKET_SIZE); + + const int recv_timeout = 10; // ms + int ret = 0; + RS485log scr(buffi, nbyte, this); + unsigned char tmp_bufIO_BUFF_SIZE; + size_t tmp_buf_len = 0; + unsigned char icrc = crc(buffi, nbyte); + tmp_buf_len = slip_esc(buffi, tmp_buf, nbyte); + tmp_buf_len += slip_esc(&icrc, tmp_buf + tmp_buf_len - 1, 1) - 1; + + if (tcflush(fd_, TCIFLUSH) < 0) + throw ErrFatal(strerror(errno)); + if (write(fd_, tmp_buf, tmp_buf_len) < 0) + throw ErrFatal(strerror(errno)); + if (tcdrain(fd_) < 0) + throw ErrFatal(strerror(errno)); + packet_number++; -int RS485impl::readData( unsigned int& from, unsigned int& numb, unsigned short *data) { + tmp_buf_len = 0; + struct pollfd p; + p.fd = fd_; + p.events = POLLIN; + while ((ret = poll(&p, 1, recv_timeout)) > 0) { + if (!(p.revents & POLLIN)) + throw ErrFatal("An unknown error occured during receive"); + int ret2 = read(fd_, tmp_buf + tmp_buf_len, IO_BUFF_SIZE - tmp_buf_len); + if (ret2 < 0) + throw ErrFatal(strerror(errno)); + + // skip single END (empty frame) + while (tmp_buf_len == 0 && ret2 > 0 && *tmp_buf == (unsigned char)END) { + memmove(tmp_buf, tmp_buf+1, --ret2); + } + + unsigned char* ptrend = std::find(tmp_buf + tmp_buf_len, tmp_buf + tmp_buf_len + ret2, (unsigned char)END); + if (ptrend == tmp_buf + tmp_buf_len + ret2) + tmp_buf_len += ret2; + else { + tmp_buf_len = ptrend - tmp_buf + 1; + break; + } + if (tmp_buf_len >= IO_BUFF_SIZE) { + scr.log( Signal::abbrev(EER)); + errors_number++; + return EER; + } + } + if (ret < 0) + throw ErrFatal(strerror(errno)); + else if (ret == 0) { + scr.log( Signal::abbrev(DSC)); + errors_number++; + return DSC; + } + + tmp_buf_len = slip_unesc(tmp_buf, tmp_buf, tmp_buf_len); + assert(tmp_buf_len > 0); + + if (tmp_buf_len == 1 && *tmp_buf > SIGNAL_BASE) { + scr.log( Signal::abbrev(*tmp_buf)); + return *tmp_buf; + } + if (crc(tmp_buf, tmp_buf_len) != 0) { + scr.log( Signal::abbrev(EER)); + errors_number++; + return EER; + } + tmp_buf_len -= 3; + memcpy(buffo, tmp_buf+2, buflen < tmp_buf_len ? buflen : tmp_buf_len); + scr.log(buffo, tmp_buf_len); + return tmp_buf_len; +} +RS485TTYImpl::RS485TTYImpl(int fd, int baudrate): BaseRS485(), fd_(fd) { + struct termios new_termios; + if(fcntl(fd_, F_SETFL, 0) < 0) { + close(fd_); + throw ErrFatal(strerror(errno)); + } + if(tcgetattr(fd_, &old_termios_) < 0) { + close(fd_); + throw ErrFatal(strerror(errno)); + }; + memset(&new_termios,0,sizeof(new_termios)); + cfmakeraw(&new_termios); + if(cfsetspeed(&new_termios, baudrate_flag(baudrate)) < 0) { + close(fd_); + throw ErrFatal("Unsupported exchange rate"); + } + new_termios.c_ccVMIN = 0; + new_termios.c_ccVTIME = 0; + if(tcsetattr(fd_, TCSANOW, &new_termios) < 0) { + close(fd_); + throw ErrFatal(strerror(errno)); + } +} +RS485TTYImpl::~RS485TTYImpl() { + tcsetattr(fd_, TCSANOW, &old_termios_); + close(fd_); +} +std::string RS485TTYImpl::protocol() { + return "SLIP/TTY"; +} +int RS485TTYImpl::readData(unsigned int& from, unsigned int& numb, unsigned short *data, std::size_t buflen) { int n_read_data = 0; int ret = 0; - unsigned short pnum; - if( (n_read_data = read( id_mcua, strdata, IO_BUFF_SIZE )) ) { - if(n_read_data < 0) throw ErrFatal(RS_strerror(errno)); - if( n_read_data > headlen && !((n_read_data-headlen)%2)) { - ret = (n_read_data-headlen)/2; - from = (unsigned int)(*(strdata+2)); - memcpy( &pnum, strdata+3, 2 ); - numb = pnum + extranum; - if( pnum == 0xFFFF ) extranum += 0x10000; - memcpy( data, strdata+headlen+1, n_read_data-headlen ); + int data_length = 0; + ssize_t res = 0; + unsigned char* pend; + while( (res = read( fd_, strdata+rsize, sizeof(strdata)-rsize )) > 0 ) { + if( res < 0 ) throw ErrFatal( strerror( errno ) ); + rsize += res; + if( rsize > (unsigned int)MAX_PACKET_SIZE ) break; + } + if( rsize > 0 ) { + for( pend = strdata+1; pend < strdata+rsize; pend++ ) { + if( *pend == END ) { + n_read_data = pend - strdata + 1; + data_length = slip_unesc( strdata, strread, n_read_data ); + rsize = rsize - n_read_data; + if( rsize > 0 ) memmove( strdata, pend+1, rsize ); + if( crc( strread, data_length ) != 0 ) { + ret = EER; // For log Only + break; + } + ret = data_length - 3; + from = (unsigned int) (*strread & MASK_ADR_PACKET); + unsigned int cycl_num = (unsigned int) ((*strread & MASK_CNT_PACKET )/0x20); + extranum += (cycl_num < cycl_prevs )? (cycl_num+4) - cycl_prevs : cycl_num - cycl_prevs; +// std::cerr << "cn= " << cycl_num << " cn-cp= " << cycl_prevs << " en= " << extranum << std::endl; + cycl_prevs = cycl_num; + numb = extranum; + memcpy(data, strread+2, (unsigned int)ret < buflen ? ret : buflen); + ret = ret/2; + break; + } } } return ret; } -void RS485impl::resetData( void ) { - extranum = 0; - if((ioctl( id_mcua, RS_FIFO_FLUSH ) < 0) || (ioctl(id_mcua, RS_BLNUMBER_RESET) < 0)) - throw ErrFatal( RS_strerror(errno) ); +RS485ImplFactory::RS485ImplFactory(const std::string& device, int baudrate): device_(device), baudrate_(baudrate) { +} +#ifndef NO_RS485_LEGACY +bool RS485ImplFactory::is_legacy(int fd) { + /* Check for legacy: ask rs485 specific ioctl */ + char vers32; + if(ioctl(fd, RS_GET_VERS, vers) < 0) { + return false; + } + return true; +} +#endif // NO_RS485_LEGACY +bool RS485ImplFactory::is_tty(int fd) { + /* Check for tty: ask tcgetattr */ + struct termios tmp_termios; + if(tcgetattr(fd, &tmp_termios) < 0) { + return false; + } + return true; +} +BaseRS485* RS485ImplFactory::create() const { + int fd = open(device_.c_str(), O_RDWR|O_NOCTTY); + if(fd < 0) { + throw BaseRS485::ErrFatal(strerror(errno)); + } +#ifndef NO_RS485_LEGACY + if(is_legacy(fd)) { + return new RS485LegacyImpl(fd, baudrate_); + } else +#endif // NO_RS485_LEGACY + if(is_tty(fd)) { + return new RS485TTYImpl(fd, baudrate_); + } else { + close(fd); + throw std::runtime_error("Device file is neither tty nor legacy rs485 device"); + } + return 0; } bool RSTimer::expired = false;
View file
turbina_core_m-1.20.tar.bz2/infras/exchange.h -> turbina_core_m-1.27.tar.bz2/infras/exchange.h
Changed
@@ -3,8 +3,9 @@ #include <stdexcept> #include <sstream> #include <sys/time.h> +#include <termios.h> -const unsigned int IO_BUFF_SIZE = 64; // user/system buffer size +const unsigned int IO_BUFF_SIZE = 128; // user/system buffer size class RS485command { protected: @@ -57,13 +58,20 @@ class BaseRS485 { protected: - std::string estr; + unsigned char strcommIO_BUFF_SIZE; + unsigned char strreadIO_BUFF_SIZE; + unsigned char strdataIO_BUFF_SIZE; + unsigned int packet_number; + unsigned int errors_number; + unsigned int extranum; + unsigned int cycl_prevs; + size_t rsize; + std::string logstr_; private: - static const int IVAL = -1; BaseRS485(const BaseRS485&); BaseRS485& operator=(const BaseRS485&); public: - enum com_stat {DONE, BUSY, NONE=0 }; + enum com_stat {DONE, BUSY, NONE }; class ErrFatal : public std::runtime_error { public: ErrFatal( const std::string& mess ) : std::runtime_error(mess) {} @@ -76,68 +84,82 @@ public: ErrSignal( const std::string& mess ) : std::runtime_error(mess) {} }; -public: - BaseRS485() {} // std::cerr << "RS485 Base" << std::endl; } - virtual ~BaseRS485() { } //std::cerr << "~RS485 Base" << std::endl;} - virtual bool shadow() {return true;} - virtual int askByte( unsigned int, const AByte) {return NONE;} - virtual int askWord( unsigned int, const AWord) {return NONE;} - virtual int askLong( unsigned int, const ALong) {return NONE;} - virtual std::vector<unsigned char> askData( unsigned int, const AData) { return std::vector<unsigned char>(); } - virtual com_stat sendSimpleCommand( unsigned int, const SComm) { return NONE; } - virtual com_stat sendByteCommand( unsigned int, const SByte, char b) { return NONE; } - virtual com_stat sendWordCommand( unsigned int, const SWord, short w) { return NONE; } - virtual com_stat sendData( unsigned int, const SData, const std::vector<unsigned char>& ){ return NONE; } - virtual unsigned int stat_packets(){ return 0; } - virtual unsigned int stat_errors(){ return 0; } - virtual std::string& protocol() { return estr; } - virtual int readData( unsigned char*, unsigned char* ) { return 0; } - virtual int readData( unsigned int&, unsigned int&, unsigned short* ) { return 0; } - virtual void resetData() {}; -}; - -class RS485impl : public BaseRS485 { -private: - int id_mcua; - unsigned char strcommIO_BUFF_SIZE; - unsigned char strreadIO_BUFF_SIZE; - unsigned char strdataIO_BUFF_SIZE; - unsigned int packet_number; - unsigned int errors_number; - unsigned int extranum; - std::string device; - int transaction(const unsigned char*, const int, unsigned char*); - unsigned char low( short i) { return (unsigned char)(i&0x00ff); } - unsigned char high( short i){ return (unsigned char)((i&0xff00)>>8); } - std::string logstr; +protected: class RS485log { + private: std::ostringstream s; - RS485impl* ptr_up; + BaseRS485* ptr_; + private: + friend class BaseRS485; + static void set_logstr(BaseRS485* ptr, const std::string& str); public: - RS485log( const unsigned char *inp, const int nbyte, RS485impl* ptr ); + RS485log(const unsigned char *inp, const int nbyte, BaseRS485* ptr); ~RS485log(); - void log( const std::string& t ); - void log( unsigned char *out, const int n ); + void log(const std::string& t); + void log(unsigned char *out, const int n); }; + friend void RS485log::set_logstr(BaseRS485* ptr, const std::string& str); +private: + virtual int transaction(const unsigned char*, std::size_t, unsigned char*, std::size_t) = 0; +public: + BaseRS485(); + virtual ~BaseRS485() = 0; + int askByte( unsigned int, const AByte); + int askWord( unsigned int, const AWord); + int askLong( unsigned int, const ALong); + std::vector<unsigned char> askData( unsigned int, const AData); + com_stat sendSimpleCommand( unsigned int, const SComm); + com_stat sendByteCommand( unsigned int, const SByte, char b); + com_stat sendWordCommand( unsigned int, const SWord, short w); + com_stat sendData( unsigned int, const SData, const std::vector<unsigned char>& ); + inline unsigned int stat_packets() const { return packet_number; } + inline unsigned int stat_errors() const { return errors_number; } + virtual std::string protocol() = 0; + virtual int readData(unsigned int&, unsigned int&, unsigned short*, std::size_t) = 0; + virtual void resetData(); + inline const std::string& logstr() const { return logstr_; } +}; + +#ifndef NO_RS485_LEGACY +class RS485LegacyImpl: public BaseRS485 { +private: + int fd_; +private: + virtual int transaction(const unsigned char*, std::size_t, unsigned char*, std::size_t); +public: + RS485LegacyImpl(int fd, int baudrate); + ~RS485LegacyImpl(); + virtual std::string protocol(); + virtual int readData(unsigned int&, unsigned int&, unsigned short*, std::size_t); + virtual void resetData(); +}; +#endif // NO_RS485_LEGACY + +class RS485TTYImpl: public BaseRS485 { +private: + struct termios old_termios_; + int fd_; +private: + virtual int transaction(const unsigned char*, std::size_t, unsigned char*, std::size_t); +public: + RS485TTYImpl(int fd, int baudrate); + ~RS485TTYImpl(); + virtual std::string protocol(); + virtual int readData(unsigned int&, unsigned int&, unsigned short*, std::size_t); +}; + +class RS485ImplFactory { +private: + std::string device_; + int baudrate_; +private: +#ifndef NO_RS485_LEGACY + static bool is_legacy(int fd); +#endif // NO_RS485_LEGACY + static bool is_tty(int fd); public: - RS485impl( const std::string&, int r = 0 ); - ~RS485impl(); - bool shadow() {return false;} - int askByte( unsigned int, const AByte ); - int askWord( unsigned int, const AWord ); - int askLong( unsigned int, const ALong ); - std::vector<unsigned char> askData( unsigned int, const AData ); - com_stat sendSimpleCommand( unsigned int, const SComm c); - com_stat sendByteCommand( unsigned int, const SByte c, char b); - com_stat sendWordCommand( unsigned int, const SWord c, short w); - com_stat sendData( unsigned int, const SData c, const std::vector<unsigned char>& d ); - int sendVoid( const unsigned char* in, const int length, unsigned char* out); - int readData( unsigned char*, unsigned char* ); - int readData( unsigned int& , unsigned int&, unsigned short* ); - unsigned int stat_packets(){ return packet_number; } - unsigned int stat_errors(){ return errors_number; } - std::string& protocol() { return logstr; } - void resetData(); + RS485ImplFactory(const std::string& device, int baudrate = 0); + BaseRS485* create() const; }; class RSTimer {
View file
turbina_core_m-1.20.tar.bz2/infras/module.cpp -> turbina_core_m-1.27.tar.bz2/infras/module.cpp
Changed
@@ -2,6 +2,7 @@ #include <fstream> #include <string> #include <map> +#include <unistd.h> #include <iomanip> #include <time.h> #include <math.h> @@ -92,7 +93,7 @@ void Module::reset() { sendSimpleCommand( RESET ); - usleep(2000); + usleep(4000); } void Module::signal_handler( RS485::ErrSignal& e ) { @@ -104,27 +105,28 @@ if( signal == "NAK" ) status = " NAK signal"; if( signal == "EER" ) status = " exchange error"; try { + usleep(10000); verification(); ErrlogSingl::instance().write( "Module " + mod_name + " connects again" ); - return; // OK! + return; } - catch ( const std::exception& e ) { -// std::cerr << "Ne OK! disconnected...\n"; - } - if( mod_connected ) { // úÁÍÅÎÉÔØ ÄÉÁÇÎÏÓÔÉËÕ, ÐÏÓËÏÌØËÕ ÒÅÁÌØÎÏ ÒÁÚÂÏÒ ÎÅ ÉÓÐÏÌØÚÕÅÔÓÑ - mod_connected = false; - pthread_create( &Conn_thread, NULL, &Module::thread, (void*)this ); - if( status.empty() ) { - throw RS485::ErrFatal( "Module " + mod_name + " " + signal ); - } else { - throw RS485::ErrFatal( "Module " + mod_name + status ); - } + catch ( RS485::ErrSignal & e ) { + ErrlogSingl::instance().wthrow( ERR_EXCHANGE, "Module " + mod_name + ": signal " + signal ); } - throw RS485::ErrFatal( "Module " + mod_name + " not connected" ); +// if( mod_connected ) { // úÁÍÅÎÉÔØ ÄÉÁÇÎÏÓÔÉËÕ, ÐÏÓËÏÌØËÕ ÒÅÁÌØÎÏ ÒÁÚÂÏÒ ÎÅ ÉÓÐÏÌØÚÕÅÔÓÑ +// mod_connected = false; +// pthread_create( &Conn_thread, NULL, &Module::thread, (void*)this ); +// if( status.empty() ) { +// throw RS485::ErrFatal( "Module " + mod_name + " " + signal ); +// } else { +// throw RS485::ErrFatal( "Module " + mod_name + status ); +// } +// } +// throw RS485::ErrFatal( "Module " + mod_name + " not connected" ); // throw std::exception(); } -const unsigned int CONN_TMOUT = 100; // sec +const unsigned int CONN_TMOUT = 10; // sec void *Module::thread( void* a ) { Module* ptr = (Module*)a; for( unsigned int i = 0; i < CONN_TMOUT && !parking ; i++ ) { @@ -141,7 +143,7 @@ catch ( RS485::ErrDriver& e ) { // std::cerr << "Conn_check............." << std::endl; } - nsleep(1); // ðÅÒÉÏÄ ÐÏÄËÌÀÞÅÎÉÑ + usleep(1000000); // ðÅÒÉÏÄ ÐÏÄËÌÀÞÅÎÉÑ } pthread_detach( ptr->Conn_thread ); return 0; @@ -152,6 +154,7 @@ if( real_ident.size() != 4 ) { usleep(1000); rs.sendSimpleCommand( mod_address, RESET ); + usleep(2000); real_ident = rs.askData( mod_address, GET_IDENT ); } std::string mess = mod_name + " initialization";
View file
turbina_core_m-1.20.tar.bz2/infras/module.h -> turbina_core_m-1.27.tar.bz2/infras/module.h
Changed
@@ -62,7 +62,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return askByte(c); + return rs.askByte( mod_address, c ); +// return askByte(c); // return -1; } @@ -71,7 +72,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return askWord(c); + return rs.askWord( mod_address, c ); +// return askWord(c); // return -1; } @@ -80,7 +82,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return askLong(c); + return rs.askLong( mod_address, c ); +// return askLong(c); // return -1; } @@ -89,7 +92,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return askData(c); + return rs.askData( mod_address, c ); +// return askData(c); // return std::vector<unsigned char>(); } @@ -98,7 +102,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return sendSimpleCommand(c); + return rs.sendSimpleCommand( mod_address, c); +// return sendSimpleCommand(c); // return -1; } @@ -107,7 +112,7 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return sendByteCommand(c,b); + return rs.sendByteCommand( mod_address, c, b); // return -1; } @@ -116,7 +121,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return sendWordCommand(c, w); + return rs.sendWordCommand( mod_address, c, w); +// return sendWordCommand(c, w); // return -1; } @@ -125,7 +131,8 @@ } catch ( RS485::ErrSignal& e ) { signal_handler( e ); - return sendData(d); + return rs.sendData( mod_address, d.size(), d ); +// return sendData(d); // return -1; }
View file
turbina_core_m-1.20.tar.bz2/infras/rs485.cpp -> turbina_core_m-1.27.tar.bz2/infras/rs485.cpp
Changed
@@ -3,19 +3,10 @@ #include "rs485.h" -RS485::RS485(const std::string& d, int r) : device(d), baudrate(r) { - Lock lock; - try { - ptrs = std::auto_ptr<RS485impl>(new RS485impl(device, baudrate)); - } - catch (ErrFatal& e) { - ErrlogSingl::instance().wthrow( ERR_EXC_STAT, e.what() ); - ptrs = std::auto_ptr<BaseRS485>(new BaseRS485()); - } - catch (std::exception& e) { - throw ErrFat(ERR_STD_EXCP, e.what() ); - } - if( ptrs->protocol().size() ) ErrlogSingl::instance().write( "RS485 initialization with " + ptrs->protocol() ); +RS485::RS485(const std::string& d, int r) : impl_factory_(d,r) { + Lock lock; + reset(); + if( ptrs->protocol().size() ) ErrlogSingl::instance().write( "RS485 initialization with " + ptrs->protocol() ); } RS485::~RS485() { @@ -25,17 +16,11 @@ } void RS485::reset() { - ptrs.reset(); - try { - ptrs = std::auto_ptr<RS485impl>( new RS485impl( device, baudrate) ); - } - catch( ErrFatal& e) { - ErrlogSingl::instance().wthrow( ERR_EXC_STAT, e.what() ); - ptrs = std::auto_ptr<BaseRS485>(new BaseRS485()); - } - catch (std::exception& e) { - throw ErrFat(ERR_STD_EXCP, e.what() ); - } + try { + ptrs.reset(impl_factory_.create()); + } catch (const std::exception& e) { // wrap std exception + throw ErrFat(ERR_STD_EXCP, e.what()); + } } void RS485::error_handler( RS485::ErrDriver& e ) {
View file
turbina_core_m-1.20.tar.bz2/infras/rs485.h -> turbina_core_m-1.27.tar.bz2/infras/rs485.h
Changed
@@ -7,15 +7,18 @@ #include <exchange.h> #include <errlog.h> -class RS485 : public BaseRS485 { +class RS485 { std::auto_ptr<BaseRS485> ptrs; - std::string device; - int baudrate; + RS485ImplFactory impl_factory_; private: RS485(const RS485&); RS485& operator=(RS485&); void reset(); void error_handler( BaseRS485::ErrDriver& e ); +public: + typedef BaseRS485::ErrFatal ErrFatal; + typedef BaseRS485::ErrDriver ErrDriver; + typedef BaseRS485::ErrSignal ErrSignal; private: class Lock { static pthread_mutex_t mtx; @@ -41,13 +44,12 @@ BaseRS485* ptr; public: Protocol( BaseRS485* p ) : ptr(p) {} - ~Protocol() { ErrlogSingl::instance().write_if_test( ptr->protocol() ); } + ~Protocol() { ErrlogSingl::instance().write_if_test( ptr->logstr() ); } }; public: RS485(const std::string&, int baud = 0 ); ~RS485(); - bool shadow() {return ptrs->shadow();} int askByte(unsigned int m_address, AByte c) try { Lock lock; Protocol p( ptrs.get() ); @@ -84,54 +86,49 @@ error_handler( e ); return std::vector<unsigned char>(); } - com_stat sendSimpleCommand(unsigned int m_address, SComm c) try { + BaseRS485::com_stat sendSimpleCommand(unsigned int m_address, SComm c) try { Lock lock; Protocol p( ptrs.get() ); return ptrs->sendSimpleCommand(m_address, c); } catch( ErrDriver& e) { error_handler( e ); - return RS485::NONE; + return BaseRS485::NONE; } - com_stat sendByteCommand(unsigned int m_address, SByte c, char b) try { + BaseRS485::com_stat sendByteCommand(unsigned int m_address, SByte c, char b) try { Lock lock; Protocol p( ptrs.get() ); return ptrs->sendByteCommand(m_address, c, b); } catch( ErrDriver& e) { error_handler( e ); - return RS485::NONE; + return BaseRS485::NONE; } - com_stat sendWordCommand(unsigned int m_address, SWord c, short w) try { + BaseRS485::com_stat sendWordCommand(unsigned int m_address, SWord c, short w) try { Lock lock; Protocol p( ptrs.get() ); return ptrs->sendWordCommand(m_address, c, w); } catch( ErrDriver& e) { error_handler( e ); - return RS485::NONE; + return BaseRS485::NONE; } - com_stat sendData(unsigned int m_address, const SData length, const std::vector<unsigned char> &d) try { + BaseRS485::com_stat sendData(unsigned int m_address, const SData length, const std::vector<unsigned char> &d) try { Lock lock; Protocol p( ptrs.get() ); return ptrs->sendData(m_address, d.size(), d); } catch( ErrDriver& e) { error_handler( e ); - return RS485::NONE; + return BaseRS485::NONE; } void statistics() { std::cerr << ptrs->stat_packets() << "/" << ptrs->stat_errors() << std::endl; } - int readData(unsigned char* head, unsigned char* data ) { - Lock lock; - return ptrs->readData( head, data ); - } - - int readData(unsigned int& addr, unsigned int& packnum, unsigned short* data ) { + int readData(unsigned int& addr, unsigned int& packnum, unsigned short* data, std::size_t datalen) { Lock lock; - return ptrs->readData( addr, packnum, data ); + return ptrs->readData(addr, packnum, data, datalen); } void resetData() {
View file
turbina_core_m-1.20.tar.bz2/instrument.cpp -> turbina_core_m-1.27.tar.bz2/instrument.cpp
Changed
@@ -1,35 +1,40 @@ #include "instrument.h" -//#include "astrotime.h" #include "results.h" #include "defnames.h" Instrument::Instrument(Config& config) : - 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), - receiver(rs485, channels) -{ - fixTemperTime.tv_sec = 0; -// temperPolling = config.inp<double>(sect_device, "auxiliary", "pollingtime"); + 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), receiver(rs485, channels) { + fixTemperTime.tv_sec = 0; + master_address = bic1.address(); + slave_address = bic2.address(); } -Instrument::~Instrument() { // = PARK -} +Instrument::~Instrument() {} void Instrument::prepareAccumTime(double exposition, int exposNumber, double baseTime, int blockNumber) try { - bic1.setLevels(); - bic2.setLevels(); - // Master: + bic1.setLevels(); + bic2.setLevels(); + // Master: +// bic1.setInduce(false); +// bic1.setMaster(true); +// bic1.setActive(true); + // Slave: +// bic2.setMaster(false); +// bic2.setActive(false); +// bic2.setInductor(&bic1); +// bic2.setInduce(true); + + // Master: bic1.setInduce(false); - bic1.setMaster(true); + bic1.setMaster(false); bic1.setActive(true); - // Slave: - bic2.setMaster(false); + // Slave: + bic2.setMaster(true); bic2.setActive(false); bic2.setInductor(&bic1); bic2.setInduce(true); @@ -39,21 +44,25 @@ bic1.setNumber(exposNumber); bic2.setNumber(exposNumber); - receiver.init(baseTime, blockNumber); + receiver.init( baseTime, blockNumber, master_address, slave_address ); } catch (const std::exception &e) { + bic1.reset(); + bic2.reset(); ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in prepareAccumTime" ); } void Instrument::startBaseTime( bool etest ) try { receiver.startBaseTime(); - bic2.run( etest ); bic1.run( etest ); + bic2.run( etest ); } catch (const std::exception &e) { + bic2.stop(); + bic1.stop(); ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); - ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in start basetime" ); + ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in basetime start" ); } unsigned int Instrument::obtainData( std::valarray<COUNT_T>* storage ) try { @@ -61,14 +70,14 @@ return nloss; } catch (const std::exception &e) { + bic2.stop(); + bic1.stop(); ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in data receiving" ); - return 0; + return 0; // ???? } - std::string Instrument::getTemperature() try { -// AstroDateTime utc; struct timeval current; gettimeofday(¤t,NULL); if((current.tv_sec - fixTemperTime.tv_sec) > aux.temperPollingTime()) { @@ -132,14 +141,3 @@ ErrlogSingl::instance().write( ERR_STD_EXCP, e.what() ); ErrlogSingl::instance().wthrow( ERR_DEV_FUNC, "Problems in checkStatus" ); } - -/* -void Instrument::checkMirror() { - if(!aux.isMirrorOnAxis()) { - Result::instance().outcomment("Mirror on Axis"); - if(Cfg::instance().debug == false) { - throw ErrFat(ERR_MIRROR, "checkMirror"); - } - } -} -*/
View file
turbina_core_m-1.20.tar.bz2/instrument.h -> turbina_core_m-1.27.tar.bz2/instrument.h
Changed
@@ -20,30 +20,29 @@ Channels channels; Receiver receiver; struct timeval fixTemperTime; + unsigned int master_address; + unsigned int slave_address; public: Instrument(Config& config); ~Instrument(); 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); void startBaseTime( bool etest=false ); unsigned int obtainData( std::valarray<COUNT_T>* count_data ); - bool isMirrorOnAxis(); // m.b. async + bool isMirrorOnAxis(); // m.b. async bool currentMirror() {return aux.currentMirror();} - bool getHV(); // m.b. async + bool getHV(); // m.b. async bool currentHV() {return aux.currentHV();} - bool getIllum(); // m.b. async + bool getIllum(); // m.b. async bool currentIllum() {return aux.currentIllum();} - bool getLight(); // m.b. async + bool getLight(); // m.b. async bool currentLight() {return aux.currentLight();} double currentLightLevel() {return aux.currentLightLevel();} double currentVoltage() {return aux.currentVoltage();} - std::string getTemperature(); // m.b. async + std::string getTemperature(); // m.b. async std::string currentTemperature() {return aux.currentTemperature();} - const int setHV(bool on) {return aux.setHV(on);} void waitHV() { aux.waitHV(); } void waitLight() { aux.waitLight(); } @@ -52,12 +51,10 @@ 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 setVoltage(double volt=-1) {aux.setVoltage(volt);} // -1 for voltage from config-file void setVAmpl(double mod, double light) {aux.setVAmpl(mod, light);} void setVary(bool on) {aux.setVary(on);} - -// void checkMirror(); - void checkStatus(); // m.b async + void checkStatus(); // m.b async }; #endif
View file
turbina_core_m-1.20.tar.bz2/mass.cpp -> turbina_core_m-1.27.tar.bz2/mass.cpp
Changed
@@ -111,13 +111,11 @@ } const int MASS::checkHV(void) { - if(instr.getHV() == true) return 0; - if(cmd.test_mode) { + if( instr.getHV() == true ) return 0; + if( cmd.test_mode ) { ErrlogSingl::instance().warning("HV is off"); -// Result::instance().outcomment("HV is off"); return 0; } -// std::cerr << "HV is OFF\n"; return instr.setHV(true); } @@ -152,6 +150,10 @@ return MeasMode::getFlux(); } +std::string MASS::vars(void) { + return MeasMode::getVars(); +} + std::string MASS::hv(void) { bool on = false; if(cmd.test_mode) on = instr.getHV(); @@ -264,6 +266,7 @@ GET_PAIR get_kwd = { GET_PAIR ("temperature", &MASS::temperature), GET_PAIR ("flux", &MASS::flux), + GET_PAIR ("vars", &MASS::vars), GET_PAIR ("hv", &MASS::hv), GET_PAIR ("illum", &MASS::illum), GET_PAIR ("light", &MASS::light),
View file
turbina_core_m-1.20.tar.bz2/mass.h -> turbina_core_m-1.27.tar.bz2/mass.h
Changed
@@ -71,6 +71,7 @@ std::string temperature(); std::string flux(); + std::string vars(); std::string hv(); std::string illum(); std::string light(); @@ -85,10 +86,10 @@ void setCnt(const std::string& str); void setObject(const std::string& str); - int specify(const std::vector<std::string>& params); // ÄÏÂÁ×ÉÔØ ËÁÖÄÏÍÕ base-timÕ + int specify(const std::vector<std::string>& params); // ÄÏÂÁ×ÉÔØ ËÁÖÄÏÍÕ base-timÕ int stop( const std::vector<std::string>& params); int quit( const std::vector<std::string>& ) { return 0; } - void set(const std::string& key, const std::string& val); + void set(const std::string& key, const std::string& val = "-"); std::string get(const std::string& key); static bool works() { return true; } };
View file
turbina_core_m-1.20.tar.bz2/measmode.cpp -> turbina_core_m-1.27.tar.bz2/measmode.cpp
Changed
@@ -5,7 +5,7 @@ #include "astrotime.h" #include "results.h" -AstroDateTime cutc; +//AstroDateTime cutc; using namespace std; @@ -18,26 +18,13 @@ const std::string StatMeasModeName = "Statistic measurement"; const std::string CountMeasModeName = "Counting measurement"; - -MeasMode::MeasMode(const std::string& modename, Instrument& instr_) - : mname(modename), instr(instr_), minDflux(0) { +MeasMode::MeasMode(const std::string& modename, Instrument& instr_) : mname(modename), instr(instr_), minDflux(0) { } -void MeasMode::calcValues(void) { -// baseTime: sec -// exposition: ms -// aim: compute number of blocks which contain all required counts and -// ask the device to produce more counts if needed: last block may thus -// contain a few "excessive" counts - -// 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; -// !!! Tut d.b. kratno 4-m v variante s bicounter-ami !!! - exposNumber = blockNumber * Instrument::getCountInBlock(); -// baseTime = exposNumber * exposition / S2MS; - n_run = int(ceil(accumTime / baseTime)); +void MeasMode::calcValues() { + blockNumber = (int)floor( S2MS*baseTime/exposition/Instrument::getCountInBlock()); + exposNumber = blockNumber*Instrument::getCountInBlock(); + n_run = (int)floor( accumTime/baseTime ); } void MeasMode::outdata(RESULT_DATA& result_data, bool is_accum_time) { @@ -55,39 +42,38 @@ Result::instance().outmode(mname); instr.checkStatus(); instr.waitHV(); - instr.prepareAccumTime(exposition, exposNumber, baseTime, blockNumber); - instr.startBaseTime( false ); for( unsigned int i = 0; i < n_run && further_now(); i++ ) { -// double s1 = cutc.currentSec(); + instr.startBaseTime( false ); valarray<COUNT_T> count_data( exposNumber ); - 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()); + RESULT_DATA result_data; + if( instr.obtainData( &count_data ) > 0 ) { n_loss++; + ErrlogSingl::instance().warning( "Measurement: skip base time", (int)i ); continue; } - Result::instance().outcnt( count_data ); -// pre_processing( count_data ); for n string - RESULT_DATA result_data; +// instr.checkStatus(); sci::calcmom( count_data, result_data ); - outdata( result_data, false ); // out base-time data + Result::instance().outcnt( count_data ); + if(result_data.m3 < minDflux*exposition) { + n_loss++; + ErrlogSingl::instance().warning( "Measurement: low fluxes", (int)i ); + continue; +// flux = result_data.m/exposition; +// vars = result_data.s0*exposition; +// throw ErrFat( ERR_CCD_EMPTY, mname ); + } +// pre_processing( count_data ); // for n string set half of exposure + outdata( result_data, false ); // output base-time data result_data_accum += result_data; - particular_processing( count_data, result_data ); - if(result_data.m3 < minDflux) throw ErrFat( ERR_CCD_EMPTY, mname ); - -// std::cerr << "++ " << i << " " << cutc.currentSec() - s1 << std::endl; - } // end of base-time-cycle -// std::cerr << "===== " << cutc.currentSec() - s0 << std::endl; + particular_processing( count_data, result_data ); // for s strings + } // end of base-time-cycle 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 + flux = result_data_accum.m/exposition; // store accumtime mean fluxes + vars = result_data_accum.s0*exposition; // store accumtime vaiances + outdata( result_data_accum, true ); // output AccumTime data to file instr.setIllum(illum); return err; } @@ -119,18 +105,27 @@ } std::string MeasMode::getFlux() { - const char* flCh = {"Flux_A=", " Flux_B=", " Flux_C=", " Flux_D="}; - std::vector<std::string> fluxChan( flCh, flCh + sizeof(flCh)/sizeof(flCh0) ); + char channame4 = { 'A', 'B', 'C', 'D' }; + std::ostringstream s; + s << std::fixed; + for(unsigned int i=0; i < flux.size(); i++) { + s << "Flux_" << channamei << "=" << std::setprecision( Result::instance().prc(fluxi ) ) << fluxi << " "; + } + return s.str(); +} + +std::string MeasMode::getVars() { + char channame4 = { 'A', 'B', 'C', 'D' }; 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) ) << fluxi; + varsi = std::isnan(varsi)? 0.0 : varsi; + s << "Vars_" << channamei << "=" << std::setprecision(3) << varsi << " "; } return s.str(); } -Normal::Normal(Config& config, Instrument& instr) - : MeasMode(NormalModeName, instr) { +Normal::Normal(Config& config, Instrument& instr) : MeasMode(NormalModeName, instr) { accumTime = config.inp<int>("operations", mname, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -166,8 +161,7 @@ runAccumTime(); } -Background::Background(Config& config, Instrument& instr) - : MeasMode(BackgroundModeName, instr) { +Background::Background(Config& config, Instrument& instr) : MeasMode(BackgroundModeName, instr) { accumTime = config.inp<int>("operations", mname, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -178,9 +172,7 @@ runAccumTime(); } - -Flux::Flux(Config& config, Instrument& instr) - : MeasMode(FluxModeName, instr) { +Flux::Flux(Config& config, Instrument& instr) : MeasMode(FluxModeName, instr) { accumTime = config.inp<int>("operations", "tests", "fluxestimationtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -191,8 +183,7 @@ runAccumTime(); } -DetTest::DetTest(Config& config, Instrument& instr) - : MeasMode(DetTestModeName, instr) { +DetTest::DetTest(Config& config, Instrument& instr) : MeasMode(DetTestModeName, instr) { accumTime = config.inp<int>("operations", "tests", "detectortesttime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -205,14 +196,11 @@ void DetTest::run() { - Ambience ambience(this); // setLight... - + Ambience ambience(this); instr.waitLight(); runAccumTime(); - for(unsigned int i=0; i<flux.size(); i++) { - if( fabs(testCountsi - fluxi) > - tolerance * (testCountsi+fluxi)/2 ) { + if( fabs(testCountsi - fluxi) > tolerance*testCountsi ) { Result::instance().outcomment("Detector test failed"); throw ErrFat(ERR_TEST, mname); } @@ -220,8 +208,7 @@ Result::instance().outcomment("Detector Test: It's OK"); } -StatTest::StatTest(Config& config, Instrument& instr) - : MeasMode(StatTestModeName, instr) { +StatTest::StatTest(Config& config, Instrument& instr) : MeasMode(StatTestModeName, instr) { accumTime = config.inp<int>("operations", NormalModeName, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -240,8 +227,7 @@ runAccumTime(); } -ExchTest::ExchTest(Config& config, Instrument& instr) - : MeasMode(ExchTestModeName, instr) { +ExchTest::ExchTest(Config& config, Instrument& instr) : MeasMode(ExchTestModeName, instr) { accumTime = config.inp<int>("operations", "tests", "exchangetesttime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -252,27 +238,20 @@ instr.getTemperature(); Result::instance().outmode(mname); instr.prepareAccumTime(exposition, exposNumber, baseTime, blockNumber); - unsigned int n_loss = 0, err = 0; + unsigned int n_loss = 0; + unsigned int err = 0; + unsigned int loss = 0; for( unsigned int i = 0; i < n_run && further_now(); i++ ) { // base-time-cycle - valarray<COUNT_T> count_data( exposNumber ); instr.startBaseTime( true ); - unsigned int loss = 0; - if( ( loss = instr.obtainData( &count_data ) ) != 0 ) { - ostringstream s; - s << "Data loss " << loss << " packets"; - ErrlogSingl::instance().warning(s.str()); - n_loss++; - continue; - } - instr.checkStatus(); + if( ( loss = instr.obtainData( &count_data ) ) > 0 ) n_loss += loss; Result::instance().outcnt( count_data ); err += testcnt(count_data, exposNumber); + instr.checkStatus(); } - - if(n_loss == n_run) throw ErrFat(ERR_EXCHANGE, mname); // Proverit' uspeshnost' - vdrug vse base-time proval'nye? - return err; +// if(n_loss == n_run) throw ErrFat(ERR_EXCHANGE, mname); // Proverit' uspeshnost' - vdrug vse base-time proval'nye? + return n_loss; } void ExchTest::run() { @@ -280,17 +259,16 @@ if(!err) { Result::instance().outcomment("Exchange Test: It's OK"); } else { - double percentage = err * 100.0; - if( exposNumber && n_run) percentage = percentage / exposNumber / n_run; + double percentage = 100*err; + if( blockNumber && n_run) percentage = percentage / ( 4*blockNumber*n_run ); std::ostringstream s; - s << "Exchange test failed. Fault = " << percentage << "per cent" << std::endl; + s << "Exchange test failed. Fault = " << std::fixed << std::setprecision(1) << percentage << "%" << std::endl; Result::instance().outcomment(s.str()); throw ErrFat(ERR_TEST, mname); } } -StatMeas::StatMeas( Config& config, Instrument& instr ) - : MeasMode( StatMeasModeName, instr ) { +StatMeas::StatMeas( Config& config, Instrument& instr ) : MeasMode( StatMeasModeName, instr ) { accumTime = config.inp<int>("operations", NormalModeName, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -310,8 +288,7 @@ runAccumTime(); } -CountMeas::CountMeas( Config& config, Instrument& instr ) - : MeasMode( CountMeasModeName, instr ) { +CountMeas::CountMeas( Config& config, Instrument& instr ) : MeasMode( CountMeasModeName, instr ) { accumTime = config.inp<int>("operations", NormalModeName, "accumtime"); baseTime = config.inp<int>("operations", NormalModeName, "basetime"); exposition = config.inp<double>("operations", NormalModeName, "exposition"); @@ -335,3 +312,4 @@ bool MeasMode::_stop_now = false; pthread_mutex_t MeasMode::Lock::mtx = PTHREAD_MUTEX_INITIALIZER; std::valarray<double> MeasMode::flux(N_CHAN); +std::valarray<double> MeasMode::vars(n_mom);
View file
turbina_core_m-1.20.tar.bz2/measmode.h -> turbina_core_m-1.27.tar.bz2/measmode.h
Changed
@@ -11,15 +11,16 @@ Instrument& instr; double exposition; double baseTime; - double minDflux; // 0 for all modes except normal + double minDflux; // 0 for all modes except normal int accumTime; unsigned int n_run; int exposNumber; int blockNumber; static std::valarray<double> flux; + static std::valarray<double> vars; static bool _stop_now; - void calcValues(void); // ×ÙÞÉÓÌÅÎÉÅ É ÕÔÏÞÎÅÎÉÅ ×ÓÑËÉÈ ÐÁÒÁÍÅÔÒÏ× ÎÁËÏÐÌÅÎÉÑ + void calcValues(); void monitorTemperature(); unsigned int runAccumTime(); static bool further_now() {return !_stop_now;} @@ -29,16 +30,15 @@ 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) {} + virtual ~MeasMode() {} const std::string name() const {return mname;} - virtual void run(void) = 0; + virtual void run() = 0; virtual bool empty() const {return false;} virtual int life() const {return accumTime;} - virtual int rest() const {return accumTime;} // äÌÑ scenario - ÐÅÒÅÇÒÕÚÉÔØ + virtual int rest() const {return accumTime;} static std::string getFlux(); -// static std::string getTemperature() {return currentTemperature;} + static std::string getVars(); -// static void stop() {_stop = true;} class Lock { Lock(const Lock&); Lock& operator=(const Lock&); @@ -66,7 +66,7 @@ void particular_processing(std::valarray<COUNT_T>& count_data, const RESULT_DATA& result_data); public: Normal(Config& config, Instrument& instr); - ~Normal(void) {} + ~Normal() {} void run(); }; @@ -94,7 +94,6 @@ ~DetTest() {} virtual int life() const {return accumTime + instr.lightWaiting();} void run(); - class Ambience; friend class Ambience; class Ambience { @@ -108,7 +107,12 @@ mode->instr.setLight(true); } ~Ambience() { - mode->instr.setLight(false); + try { + mode->instr.setLight(false); + } + catch( const std::exception& err ) { + ErrlogSingl::instance().write("Unable to turn off control light"); + } } }; }; @@ -138,8 +142,13 @@ mode->instr.setLight(true); } ~Ambience() { - mode->instr.setVary(false); - mode->instr.setLight(false); + try { + mode->instr.setVary(false); + mode->instr.setLight(false); + } + catch( const std::exception& err ) { + ErrlogSingl::instance().write("Unable to turn off control light"); + } } }; }; @@ -173,7 +182,12 @@ mode->instr.setLight(true); } ~Ambience() { - mode->instr.setLight(false); + try { + mode->instr.setLight(false); + } + catch( const std::exception& err ) { + ErrlogSingl::instance().write("Unable to turn off control light"); + } } }; }; @@ -200,8 +214,13 @@ mode->instr.setLight(true); } ~Ambience() { - mode->instr.setLight(false); - mode->instr.setVoltage(); // restore config-values + try { + mode->instr.setLight(false); + mode->instr.setVoltage(); // restore config-values + } + catch( const std::exception& err ) { + ErrlogSingl::instance().write("Unable to turn off control light and restore cofiguration voltage"); + } } }; };
View file
turbina_core_m-1.27.tar.bz2/parameter_set.cpp
Added
@@ -0,0 +1,156 @@ +#include <math.h> +#include <string> +#include <iostream> +#include <sstream> +#include <iomanip> +#include <map> +#include <cmath> +#include <fstream> +#include <numeric> + +//#include <boost/numeric/ublas/matrix.hpp> +//#include <boost/numeric/ublas/vector.hpp> +//#include <boost/numeric/ublas/vector_proxy.hpp> + +//#include <coordinates.h> +#include "parameter_set.h" +#include "defnames.h" + +//using namespace boost::numeric::ublas; + +template<typename T> T& get( std::map<T,T>& ps, const T& k ){ + std::map<std::string,std::string>::iterator pos = ps.find( k ); + if( pos == ps.end() || pos->second.empty() ) throw std::runtime_error( "Parameter " + k + " missed" ); + return pos->second; +} + +namespace parameters { + std::map<std::string,std::string> rPs; + double dimm_base = 0.2; + double aperture = 0.1; + double scale = 2.9670597216e-06; + std::vector< point<double> > crv; + vector< double > tau( 4 ); + double exposure = 1.0; + double basetime = 1; + double nacctime = 60; + double bacctime = 10; + double instrumental_constant = 9.0; + std::string file_history_name = "constant.dat"; + bool parm_is_set = false; +} + +// std::vector< point<double> >& parameters::ccd(){ +// if( crv.size() == 0 ) { +// // input( program_dat + "ccd.crv", crv ); +// input( "ccd.crv", crv ); +// if( crv.size() == 0 ) throw std::ios_base::failure( "No CCD response" ); +// } +// return crv; +// } + +double parameters::accumtime() { + return nacctime; +} + +double parameters::accumtime_background() { + return bacctime; +} + +double parameters::base_time() { + return basetime; +} + +double parameters::aperture2() { + return aperture*aperture; +} + +double parameters::expos() { + return exposure; +} + +double parameters::scale2() { + return scale*scale; +} + +Geo* parameters::coordinates() { + static std::string lon_key("general/site/longitude"); + static std::string lat_key("general/site/latitude"); + static Geo* site = new Geo( Hour( ::get( rPs, lon_key ) ), Degree( ::get( rPs, lat_key ) ) ); // á ËÏÒÒÅËÃÉÑ ËÏÏÒÄÉÎÁÔ × ÔÅÞÅÎÉÅ ÎÏÞÉ?? + return site; +} + +bool parameters::mass_set() { + if( parm_is_set ) return true; + static std::string expos_key("operations/normal mode/exposition"); + static std::string btime_key("operations/normal mode/basetime"); + static std::string atime_key("operations/normal mode/accumtime"); + static std::string batime_key("operations/background measurement/accumtime"); + static std::string nonlin_a_key("devices/bicounter 2/nonlinearitya"); + static std::string nonlin_b_key("devices/bicounter 2/nonlinearityb"); + static std::string nonlin_c_key("devices/bicounter 1/nonlinearitya"); + static std::string nonlin_d_key("devices/bicounter 1/nonlinearityb"); + exposure = get<double>( ::get( rPs, expos_key ) ); + basetime = get<double>( ::get( rPs, btime_key ) ); + nacctime = get<double>( ::get( rPs, atime_key ) ); + bacctime = get<double>( ::get( rPs, batime_key ) ); + tau(0) = get<double>( ::get( rPs, nonlin_a_key ) )/1e6; + tau(1) = get<double>( ::get( rPs, nonlin_b_key ) )/1e6; + tau(2) = get<double>( ::get( rPs, nonlin_c_key ) )/1e6; + tau(3) = get<double>( ::get( rPs, nonlin_d_key ) )/1e6; +// std::cerr << "Exp " << exposure << " Bt " << basetime << " NA " << nacctime << " BA " << bacctime << std::endl; + parm_is_set = true; + return parm_is_set; +} + +vector <double>& parameters::const_tau() { + return tau; +} + +void parameters::P_line_parse( const std::string& p, const std::string& s ){ + std::string::size_type i = 0; + std::string params; + std::string value; + if( (i = s.find( "=", 0 )) != std::string::npos ) { + params.resize(i-1); + std::transform( s.begin(), s.begin()+i-1, params.begin(), std::ptr_fun(::tolower) ); + value = s.substr(i+1); + rPsparams = value; + } + parm_is_set = false; +} + +double parameters::instrument_constant() { + return instrumental_constant; +} + +double parameters::instrument_constant( double back ) { + instrumental_constant = 0.9*instrumental_constant + 0.1*back; + return instrumental_constant; +} + +void parameters::last_instrument_constant() { + std::string time; + std::string date; + std::string parm; + double val; + std::ifstream history; +// file_history_name = program_etc + "history" + extension_history; + + history.open( file_history_name.c_str(), std::ios::in ); + if( !history )throw std::ios_base::failure( "No constant.dat file: " ); + std::string str; + while( getline( history, str ) ){ + std::istringstream is(str); + is >> date >> time >> val; + } + instrumental_constant = val; +} + +void parameters::new_instrument_constant( Date& date, Time& time ) { + std::ofstream history; + std::ostringstream outstr; + history.open( file_history_name.c_str(), std::ios::app ); + history << date << ' ' << time << ' ' << " \t" << std::fixed << std::setprecision(3) << instrumental_constant << std::endl; + history.close(); +}
View file
turbina_core_m-1.27.tar.bz2/parameter_set.h
Added
@@ -0,0 +1,60 @@ +#ifndef _PARAMETERS_H +#define _PARAMETERS_H +#include <string> +#include <vector> +#include <fstream> + +#include <astrotime.h> +#include <coordinates.h> + +#include <boost/numeric/ublas/matrix.hpp> +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/vector_proxy.hpp> +using namespace boost::numeric::ublas; + +namespace parameters { + Geo* coordinates(); + void last_instrument_constant(); + void new_instrument_constant( Date&, Time& ); + double instrument_constant(); + double instrument_constant( double ); + bool mass_set(); + double accumtime(); + double accumtime_background(); + vector <double>& const_tau(); + double expos(); + double base_time(); + +// void init_keys(); + void P_line_parse( const std::string&, const std::string& ); + double aperture2(); + double scale2(); + template<typename T > T get( const std::string val ){ + T x; + std::istringstream istr( val ); + istr >> x; + return x; + } + template<typename T, int r > T get( const std::string val ){ + T x(r); + std::istringstream istr( val ); + istr >> x; + return x; + } +} + +template<typename T> void input( const std::string& fname, std::vector< T >& sed ) { + std::ifstream spfile( fname.c_str() ); + if( spfile.fail() ) throw std::ios_base::failure( "Input file problem: " ); + std::string co; + T dummy; + while( getline( spfile, co ) ) { + if( co.size() < 1 || co.at(0) == '#' ) continue; + std::istringstream is(co); + is >> dummy; + sed.push_back( dummy ); + } +} + +#endif +
View file
turbina_core_m-1.27.tar.bz2/prephot.cpp
Added
@@ -0,0 +1,159 @@ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <iostream> +#include <iomanip> +#include <sys/stat.h> +#include <sys/types.h> +#include <sstream> +#include <string> +#include <fstream> +#include <map> + +#include <astrotime.h> +#include <errlog.h> + +#include "deftypes.h" + +#include "processing.h" +#include "parameter_set.h" + +const unsigned int data_begin = 22; +const unsigned int time_begin = 2; + +unsigned int basetime_number = 0; + +double mean_mz = 0.0; +double mjd_first = 0.0; +double mjd_last = 0.0; + +Date dc_normal_mode; +Time ut_normal_mode; + +std::string mode = "Normal"; +std::string previose_mode; + +double mz = -1; + +void P_line( const std::string& s ) { +// basetime_number = processing::run_background(); +// basetime_number = processing::run_star(); + parameters::P_line_parse( s.substr( 0, data_begin ), s.substr( data_begin ) ); +} + +void M_line( const std::string& s ) { + Date dc; + Time ut; + previose_mode = mode; + std::istringstream mode_inp( s.substr( time_begin ) ); + mode_inp >> dc >> ut >> mode; +// if( ( mjd_last - mjd_first )*24 > parameters::accumtime()/3600 && basetime_number > 0 ) { +// basetime_number = processing::run( mean_mz/basetime_number, 0.5*(mjd_first + mjd_last) ); +// } + if( mode == "Normal" && previose_mode != mode ) { + dc_normal_mode = dc; + ut_normal_mode = ut; + basetime_number = processing::run_background(); + } + if( mode == "Background" && previose_mode != mode ) { + basetime_number = processing::run_star(); + } +} + +void O_line( const std::string& s ) { + basetime_number = processing::run_background(); + basetime_number = processing::run_star(); + std::istringstream tst( s.substr( data_begin ) ); + std::vector<std::string> items; + tst >> items; + if( items.size() < 11 ) throw std::runtime_error( "O Format error " ); + std::cout << "O " << s.substr( time_begin, data_begin-time_begin-1 ) << std::setw(5) << items.at(0); + for( unsigned int i = 1; i < items.size() ; i++ ) std::cout << ' ' << items.at(i); + std::cout << std::endl ; + processing::object( items ); +} + +void m_line( const std::string& s ) { + if( s.size() > 512 ) return; + Date dc; + Time ut; + std::istringstream stm_inp( s.substr( time_begin ) ); + stm_inp >> dc >> ut; + mjd_last = (int)dc + ut/24.0; + if( basetime_number == 0 ) mjd_first = mjd_last; + if( basetime_number == 0 ) mean_mz = 0.0; + mean_mz += processing::object_Mz( dc, ut ); + basetime_number++; +} + +void s_line( const std::string& s ) { +// std::cout << s << std::endl; +} + +void C_line( const std::string& s ) { +// std::cout << s << std::endl; +} + +void A_line( const std::string& s ) { + if( mode == "Background" ) { + processing::add_background( s.substr( data_begin ), mean_mz/basetime_number, 0.5*(mjd_first + mjd_last) ); + } + if( mode == "Normal" ){ + processing::add_data( s.substr( data_begin ), mean_mz/basetime_number, 0.5*(mjd_first + mjd_last) ); + } + basetime_number = 0; +} + + +namespace { + typedef void(*CALLF_T)( const std::string& ); + typedef std::pair< char, CALLF_T> cfpair; + cfpair file_line = { + cfpair( 'P', &P_line ), + cfpair( 'M', &M_line ), + cfpair( 'O', &O_line ), + cfpair( 'm', &m_line ), + cfpair( 's', &s_line ), + cfpair( 'A', &A_line ), + cfpair( 'C', &C_line ), + cfpair( '#', &C_line ), + cfpair( 'c', &C_line ) + }; +} + +static std::map< char, CALLF_T > func( file_line, file_line + sizeof(file_line)/sizeof(file_line0)); + +int main( int argc, char **argv ) { + std::string dimm_line; + int line_number = 0; + try { + +// if( parameters::comand_line_parse( argc, argv ) < 0 ) return -1; + std::cout << "#" << "Prephot Vers." << "1.00" << " Compiled " << __TIME__ << " " << __DATE__<< std::endl; +// parameters::init_keys(); + parameters::last_instrument_constant(); + while( getline( std::cin, dimm_line ) ) { + try { + line_number++; + if( func.find( dimm_line.at(0)) == func.end() ) continue; +// std::cerr << "Processing " << dimm_line.at(0) << " " << line_number << std::endl; + (*funcdimm_line.at(0))(dimm_line); + } + catch (const std::ios_base::failure& e ) { + std::cerr << dimm_line.at(0) << "-line: " << e.what() << " at " << line_number << ". Skipped" << std::endl; + } + catch (const std::exception& e ) { + throw std::domain_error( std::string("Fatal error: ") + e.what() ); + } + } + basetime_number = processing::run_background(); + basetime_number = processing::run_star(); + } + catch (const std::exception& e ) { + std::cerr << e.what() << ". Line " << line_number << std::endl; + } + parameters::new_instrument_constant( dc_normal_mode, ut_normal_mode ); + return 0; +} +
View file
turbina_core_m-1.27.tar.bz2/processing.cpp
Added
@@ -0,0 +1,225 @@ +#include <math.h> +#include <string> +#include <iostream> +#include <sstream> +#include <iomanip> +#include <map> +#include <cmath> +#include <fstream> +#include <numeric> + +#include <boost/numeric/ublas/matrix.hpp> +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/vector_proxy.hpp> + +#include "processing.h" +#include "parameter_set.h" +#include "defnames.h" + +using namespace boost::numeric::ublas; + +// To do: ËÏÎÔÒÏÌØ ÄÌÉÎÎÙ ××ÏÄÉÍÏÊ ÓÔÒÏËÉ d ÎÁ ÐÒÅÄÍÅÔ ÎÅÆÏÒÍÁÔÎÏÇÏ ××ÏÄÁ +// ×ËÌÁÄ ÎÉÚËÏÊ ÞÁÓÔÏÔÙ ÐÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÙÍ ÒÁÚÎÏÓÔÑÍ Ó ËÏÎÔÒÏÌÅÍ ×ÅÌÉÞÉÎÙ +// ÄÌÑ ÉÓËÌÀÞÅÎÉÑ ÐÅÒÅÆÏËÕÓÉÒÏ×ËÉ. + +const double aperture_factor = 11.5; +const unsigned int window = 2; +const double mindelta = 0.25; +const double mintime = 6.0/60.0/24.0 ; +struct photo { + std::string name; + double MASS_mag; + double moment; + double mz; + double flux; + photo() { MASS_mag = 0; moment = 0; mz = 0; flux = 0;}; +}; + + + +namespace processing { + Coord<equ> star; + double MASS_mag; + std::string star_name; + photo prevs_star; + double current_background; + std::vector< double > back_fluxes; + std::vector< double > star_fluxes; + std::vector< double > back_time; + std::vector< double > star_time; + std::vector< double > back_mass; + std::vector< double > star_mass; + double extinct = 0.2; + bool star_is = false; +} + +unsigned int processing::add_background( const std::string& s, double mz, double moment ) { + std::istringstream istr( s ); + vector< double > fluxes( 4 ); + vector< double > vars( 4 ); + istr >> fluxes >> vars; + if( istr.eof() || istr.fail() ) throw std::ios_base::failure( "Background moments input fail" ); + // verification + + // c+d apertures + double flux = fluxes(2) + fluxes(3); + back_fluxes.push_back(flux); + back_mass.push_back(mz); + back_time.push_back(moment); +// std::cerr << fluxes << " " << vars << " total " << back_fluxes.size() <<std::endl; + return 0; +} + + +unsigned int processing::run_background() { + unsigned int numb = 0; + double moment = 0; + double mz = 0; + std::ostringstream bstr; + if( ( numb = back_fluxes.size() ) == 0 || star_is == false ) return numb; + moment = std::accumulate( back_time.begin(), back_time.end(), moment )/numb; + mz = std::accumulate( back_mass.begin(), back_mass.end(), mz )/numb; + double flux = *std::min_element(back_fluxes.begin(), back_fluxes.end() ); + current_background = flux; + double mag = parameters::instrument_constant() + magnitude( flux ) + aperture_factor; + bstr << "B " << Date( floor(moment)) << ' ' << Time( 24*(moment-floor(moment)) ) << " " + << std::fixed << std::setprecision(3) << mag << " " << mz << " " << extinct; + back_fluxes.clear(); + back_time.clear(); + back_mass.clear(); + std::cout << bstr.str() << std::endl; + return 0; +} + +unsigned int processing::add_data( const std::string& s, double mz, double moment ) { + std::istringstream istr( s ); + std::ostringstream estr; + vector< double > fluxes( 4 ); + vector< double > vars( 4 ); + istr >> fluxes >> vars; + if( istr.eof() || istr.fail() ) throw std::ios_base::failure( "Star moments input fail" ); + parameters::mass_set(); + // verification + // Nonlinearity + vector< double > tau(parameters::const_tau()/parameters::expos()); + vector< double> corr = element_prod( tau, fluxes ); + fluxes = fluxes + element_prod( fluxes, corr ); + //background + double flux = fluxes(2) + fluxes(3) - current_background; + star_fluxes.push_back(flux); + star_mass.push_back(mz); + star_time.push_back(moment); + extinct = ( parameters::instrument_constant() - MASS_mag + magnitude( flux ) )/mz; + estr << "E " << Date( floor(moment)) << ' ' << Time( 24*(moment-floor(moment)) ) << " " + << std::fixed << std::setprecision(3) << extinct << " " << mz; + std::cout << estr.str() << std::endl; + return 0; +} + + +unsigned int processing::run_star() { + // static bool optics_are_set = parameters::mass_set(); + unsigned int numb = 0; + photo now; + if( (numb = star_fluxes.size()) == 0 ) return 0; + unsigned int nwide = std::min( numb, window ); + now.moment = std::accumulate( star_time.begin(), star_time.begin() + nwide, now.moment )/nwide; + now.mz = std::accumulate( star_mass.begin(), star_mass.begin() + nwide, now.mz )/nwide; + now.flux = std::accumulate( star_fluxes.begin(), star_fluxes.begin() + nwide, now.flux )/nwide; + now.MASS_mag = MASS_mag; + now.name = star_name; + // Check the firmass of prevs_star + double deltamz = std::abs( prevs_star.mz - now.mz ); + if( deltamz > mindelta && now.moment - prevs_star.moment < mintime) { + std::ostringstream rstr; + double ext_est = std::abs( prevs_star.MASS_mag - magnitude( prevs_star.flux ) - now.MASS_mag + magnitude( now.flux ) )/deltamz; + double rconst = ( now.mz < prevs_star.mz )? now.MASS_mag - magnitude( now.flux ) + now.mz*ext_est : + prevs_star.MASS_mag - magnitude( prevs_star.flux ) + prevs_star.mz*ext_est ; +// std::cerr << Date( floor(now.moment)) << ' ' << Time( 24*(now.moment-floor(now.moment)) ) +// << " " << prevs_star.name << " " << now.name << " Ext " +// << ext_est << " DeltaMz " << prevs_star.mz - now.mz << " R " << rconst << std::endl; + if( std::abs( ext_est - extinct ) < 0.05 ) parameters::instrument_constant( rconst ); + rstr << "R " << Date( floor(now.moment)) << ' ' << Time( 24*(now.moment-floor(now.moment)) ) << " " + << std::fixed << std::setprecision(3) << ext_est << " " << now.mz << " " << rconst << " " << parameters::instrument_constant(); + std::cout << rstr.str() << std::endl; + } + prevs_star = now; + if( numb > nwide ) { + photo now; + now.moment = std::accumulate( star_time.end() - nwide, star_time.end(), now.moment )/nwide; + now.mz = std::accumulate( star_mass.end() - nwide, star_mass.end(), now.mz )/nwide; + now.flux = std::accumulate( star_fluxes.end() - nwide, star_fluxes.end(), now.flux )/nwide; + now.MASS_mag = MASS_mag; + now.name = star_name; + prevs_star = now; + } + star_fluxes.clear(); + star_time.clear(); + star_mass.clear(); + return 0; +} + +template<class T> class plus { +public: + T operator()( T& e, T a) { return a += e; } +}; + +template<class T> class mule { +public: + T operator()( const T& e, const T& a) { return T(element_prod( e, a )); } +}; + +template<class T> class int2 { +public: + T operator()( const T& e1, const T& e2 ) { return T(e1.y()*e2.y(), e1.y()*e2.y()/e1.x()/e2.x() ); } +}; + +double processing::stat_calculations( const std::vector< vector< double > >& motion, vector<double>& means, vector<double>& vars ) { + std::vector< vector< double> > diff(motion.size()); + vector<double> dvar = zero_vector<double>( 4 ); + means = std::accumulate( motion.begin(), motion.end(), means )/ motion.size(); +// vector< double > maxm = + vars = std::inner_product( motion.begin(), motion.end(), motion.begin(), vars, plus< vector<double> >(), mule< vector<double> >() ); + vars = vars/motion.size() - element_prod( means, means ); + std::adjacent_difference( motion.begin(), motion.end(), diff.begin() ); + dvar = std::inner_product( diff.begin()+1, diff.end(), diff.begin()+1, dvar, plus< vector<double> >(), mule< vector<double> >() ); + vars(0) = dvar(0)/(2*(motion.size()-1)); + return means(1); +} + +double processing::object_Mz( Date& dc, Time& ut ) { + return (star_is)? star.Mz( dc, ut ) : 1.0 ; +} + +void processing::object( std::vector<std::string>& items ) { + static std::string current_type; + int cdi = ( items.at(1).size() < 4 )? 3 : 2; + star_name = items.at(1); + std::string ra(items.at(cdi+0)+' '+items.at(cdi+1)+' '+items.at(cdi+2)); + std::string dec(items.at(cdi+3)+' '+items.at(cdi+4)+' '+items.at(cdi+5)); + star = Coord<equ>( Hour(ra), Degree(dec), parameters::coordinates() ); + std::istringstream istr( items.at(cdi+6) ); + istr >> MASS_mag; + std::string spectral_type = items.at(cdi+8); + std::transform( spectral_type.begin(), spectral_type.end(), spectral_type.begin(), std::ptr_fun(::tolower) ); + star_is = true; + if( spectral_type == current_type ) return; + spectra( spectral_type ); + current_type = spectral_type; +} + + +void processing::spectra( const std::string& stype ) { + std::vector< point<double> > sed; +// input( program_spe + stype + ".sp", sed ); +// input( stype + ".sp", sed ); +// if( sed.size() == 0 ) throw std::ios_base::failure( "No spectral distribution" ); +// point<double> norm; +// norm = std::inner_product( sed.begin(), sed.end(), parameters::ccd().begin(), norm, plus< point<double> >(), int2< point<double> >()); +// leff2 = 1e-18*norm.x()/norm.y(); // in meters +// theors = M_PI/4.0*parameters::aperture2()/leff2*parameters::scale2(); +} + +double processing::magnitude( double fl ) { + return -1.08573620476*log( fl ); +} \ No newline at end of file
View file
turbina_core_m-1.27.tar.bz2/processing.h
Added
@@ -0,0 +1,44 @@ +#ifndef _PROCESSING_H +#define _PROCESSING_H +#include <string> +#include <vector> +#include <fstream> + +#include <astrotime.h> +#include <coordinates.h> +#include <boost/numeric/ublas/matrix.hpp> +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/io.hpp> +using namespace boost::numeric::ublas; + +namespace processing { + unsigned int add_data( const std::string&, double, double ); + unsigned int add_background( const std::string&, double, double ); + unsigned int run_star(); + unsigned int run_background(); + + double stat_calculations( const std::vector< vector< double > >&, vector<double>&, vector<double>& ); + double object_Mz( Date&, Time& ); + void object( std::vector<std::string>& ); + void spectra( const std::string& ); + double magnitude( double ); +// void input( const std::string& fname, std::vector< point<double> >& sed ) +} + +namespace std { + template<class T> std::istringstream& operator>>( std::istringstream& stm, std::vector<T>& x ) { + T a; + while( stm >> a ) x.push_back( a ); + return stm; + } + template<class T> std::istringstream& operator>>( std::istringstream& stm, boost::numeric::ublas::vector<T>& x ) { + T a; + unsigned int i = 0; + while( i < x.size() && stm >> a ) x(i++) = a; + return stm; + } +} + + +#endif +
View file
turbina_core_m-1.20.tar.bz2/receiver.cpp -> turbina_core_m-1.27.tar.bz2/receiver.cpp
Changed
@@ -1,10 +1,10 @@ #include <map> #include <assert.h> -#include <unistd.h> // for sleep +#include <string.h> +#include <unistd.h> #include "receiver.h" #include "astrotime.h" #include "errlog.h" -//#include "results_mass.h" using namespace std; AstroDateTime utr; @@ -12,8 +12,6 @@ pthread_mutex_t Receiver::Lock::mtx = PTHREAD_MUTEX_INITIALIZER; //bool Receiver::blockStructureReady = false; -// ÷ ÂÕÆÅÒÅ block ÎÁËÁÐÌÉ×ÁÀÔÓÑ Ä×Á ÂÌÏËÁ - ÏÔÓÞÅÔÙ ÏÔ ÏÂÏÉÈ ÂÉËÁÕÎÔÅÒÏ×: -//static count_t block2IO_BUFF_SIZE; static unsigned short block2IO_BUFF_SIZE; Receiver::Receiver(RS485& rs, Channels& ch) : rs485(rs), channels(ch) { @@ -40,7 +38,7 @@ typedef count_t(*PF)(unsigned int); PF get_count_chN_CHAN; -typedef pair<string, PF> COUNT_FUNC_PAIR; +typedef pair<std::string, PF> COUNT_FUNC_PAIR; COUNT_FUNC_PAIR count_funcN_CHAN = { COUNT_FUNC_PAIR("1a", &F_1A), COUNT_FUNC_PAIR("1b", &F_1B), @@ -57,98 +55,115 @@ // 2a 2b 2a 2b... // ÉÎÉÃÉÁÌÉÚÁÃÉÑ ÍÁÓÓÉ×ÏÍ ÐÁÒ count_func Ó ÐÅÒ×ÏÇÏ ÐÏ ÐÏÓÌÅÄÎÉÊ ÞÌÅÎ: - map<string, PF, Cmpi> map_count_func(count_func, &(count_funcN_CHAN)); - for(unsigned int i=0; i<channels.size(); i++) { + map<std::string, PF, Cmpi> map_count_func(count_func, &(count_funcN_CHAN)); + for(unsigned int i = 0; i < channels.size(); i++ ) { get_count_chi = map_count_funcchannels.code(i); // code = "1a", "2b"... } -// åÓÌÉ code ÎÏ×ÙÊ ÏËÁÚÁÌÓÑ - ÓÏÚÄÁÓÔÓÑ ÎÏ×ÙÊ ÜÌÅÍÅÎÔ ÁÓÓÏÃ. ÍÁÓÓÉ×Á... -// if(map_count_func.size() != N_CHAN) { assert(map_count_func.size() == N_CHAN); -// throw ErrFat(ERR_ALG,"Receiver::setBlockStructure"); -// } -// blockStructureReady = true; } -void Receiver::init( double _baseTime, int blockNumber ) { +void Receiver::init( double _baseTime, int blockNumber, unsigned int f, unsigned int s ) { baseTime = _baseTime; - n_expected = N_BIC*blockNumber*2; // kol-vo blockov b baseTime + n_expected = N_BIC*blockNumber*2; // Whole number of the packets in the basetime run + first = f; + second = s; } 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 + rs485.resetData(); + data_actual_size = 0; finishTime = utr.currentSec() + baseTime*factor; } -void Receiver::putData(unsigned int n_count) { - if((data_actual_size + n_count/2) > count_data->size()) { - n_count = (count_data->size() - data_actual_size) * 2; +void Receiver::putData( unsigned int n_count ) { + if( (data_actual_size + n_count/2) > count_data->size() ) { + n_count = (count_data->size() - data_actual_size)*2; ErrlogSingl::instance().warning("Receiver::putData: overflow!"); } - for( unsigned int i=0; i<n_count; i+=2) { -// òÁÓËÉÄÙ×ÁÅÍ ÏÔÓÞÅÔÙ ÐÏ ÏÐÔÉÞÅÓËÉÍ ËÁÎÁÌÁÍ: + for( unsigned int i = 0; i < n_count; i += 2) { (*count_data)data_actual_size+i/2.a = get_count_ch0(i); (*count_data)data_actual_size+i/2.b = get_count_ch1(i); (*count_data)data_actual_size+i/2.c = get_count_ch2(i); (*count_data)data_actual_size+i/2.d = get_count_ch3(i); } - data_actual_size += n_count / 2; + data_actual_size += n_count/2; +} + +unsigned int qunum = 0; + +int Receiver::quasi_read( unsigned int& addr, unsigned int& count, unsigned short* data_block ) { + static unsigned short packet28 = { { 10, 20, 10, 20, 10, 20, 10, 20}, + { 60, 80, 60, 80, 60, 80, 60, 80} }; + unsigned int l = 8; + if( qunum == 166 || qunum == 168 ) { + qunum++; + return 0; + } + if( qunum % 2 == 0 ) { + addr = 1; + memcpy( data_block, packet1, 2*l ); + } else { + addr = 2; + memcpy( data_block, packet0, 2*l ); + } + count = qunum/2; + qunum++; + return l; } unsigned int Receiver::read_data( valarray<COUNT_T>* count_stor ) { Lock lock; count_data = count_stor; - unsigned int from; + unsigned int from = 0; unsigned int numb; - 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; - (*count_data)i.d = 1001; - } - return 0; - } + unsigned int current = 0; + unsigned short *next_block = block0; + qunum = 0; unsigned int n_received = 0; -// ErrlogSingl::instance().write("receiver::read_data start"); - - while( n_received < n_expected && utr.currentSec() < finishTime ) { -// if( utr.currentSec() > startSec + baseTime*factor) { -// if(timeout(startTime, baseTime*factor)) { -// 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, next_block ); -// from ÉÓÐÏÌØÚÏ×ÁÔØ ÔÏÌØËÏ ÄÌÑ ËÏÎÔÒÏÌÑ ÉÌÉ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ ËÁÎÁÌÁ? - if( n_count <= 0 ) { - usleep(8000); //!!! - continue; - } -// ErrlogSingl::instance().write("receiver::read_data rs485.readData stop"); -// Result::instance().outcnt(n_count, from, numb, bl); -/* - std::cerr << "n_count=" << n_count << " " << from << " " << numb << " | "; - for(int i=0; i<n_count; i++) { - std::cerr << bli << " "; - } - std::cerr << std::endl; -*/ - if( n_received % 2) { // odd blocks (1,3,5,...) - putData( n_count ); - next_block = block0; // next even block (0,2,4,...) - } else { - next_block = block1; // next odd block - } - n_received++; + unsigned int n_lost = 0; +// ErrlogSingl::instance().warning("Number of expected packets", (int)n_expected ); +// usleep(2000); + + while( n_received < n_expected && utr.currentSec() < finishTime ) { + int n_count = rs485.readData( from, numb, next_block, IO_BUFF_SIZE ); +// if( n_count == 0 && rs485.shadow() ) n_count = quasi_read( from, numb, next_block ); + if( n_count <= 0 ) { + usleep(400); + continue; + } + if( n_count > (int)IO_BUFF_SIZE ) { + ErrlogSingl::instance().warning("Receiver: signal EER!", (int)n_received ); + n_received++ ; + n_lost++ ; + continue; + } + if( from != first && from != second ) { + ErrlogSingl::instance().warning("Receiver: wrong module!", (int)from ); + n_received++ ; + n_lost++ ; + continue; + } + current = 2*numb + (first - from == 0)? 0 : 1 ; +// std::cerr << n_count << " " << numb << " " << current << " " << from << std::endl; + if( n_received < current ) { + ErrlogSingl::instance().warning("Receiver: Packets was skipped", (int)current ); + n_received++ ; + n_lost++ ; + } + if( n_received % 2) { // odd blocks (1,3,5,...) + putData( n_count ); + next_block = block0; // next even block (0,2,4,...) + } else { + next_block = block1; // next odd block + } + n_received++; } - return n_expected - n_received; + if( n_lost > 0 ) ErrlogSingl::instance().warning( "Receiver: Packets was lost", (int)n_lost ); + if( n_received < n_expected ) ErrlogSingl::instance().warning("Receive: total number", (int)n_received ); +// usleep(10000); // To prevent overlapping + return n_lost; }
View file
turbina_core_m-1.20.tar.bz2/receiver.h -> turbina_core_m-1.27.tar.bz2/receiver.h
Changed
@@ -16,21 +16,24 @@ void setBlockStructure(void); void putData(unsigned int n_count); unsigned int n_expected; + unsigned int first; + unsigned int second; double finishTime; + int quasi_read( unsigned int& addr, unsigned int& count, unsigned short* data_block ); public: Receiver(RS485& rs485, Channels& ch); - void init(double _baseTime, int blockNumber); + void init(double _baseTime, int blockNumber, unsigned int first, unsigned int second ); void startBaseTime(); unsigned int read_data( std::valarray<COUNT_T>* _count_data ); class Lock { - Lock(const Lock&); // zapret - Lock& operator=(const Lock&); // zapret + Lock(const Lock&); + Lock& operator=(const Lock&); static pthread_mutex_t mtx; struct timespec locktime; public: Lock() { - locktime.tv_sec = time(0)+5; + locktime.tv_sec = time(0) + 5; locktime.tv_nsec = 0; int err; if((err=pthread_mutex_timedlock(&mtx, &locktime)) != 0) {
View file
turbina_core_m-1.20.tar.bz2/sci.cpp -> turbina_core_m-1.27.tar.bz2/sci.cpp
Changed
@@ -6,29 +6,10 @@ namespace { -/* 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 ) { + template<class T> std::valarray<T> oc( 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 ) { - std::valarray<double> t(n_mom); - t0 = (double)x.a - m0; - t1 = (double)x.b - m1; - t2 = (double)x.c - m2; - t3 = (double)x.d - m3; - t4 = t0; - t5 = t0; - t6 = t0; - t7 = t1; - 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; @@ -47,20 +28,6 @@ return t; } -/* 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; - u3 = (double)x.d - m3; - u4 = u1; - u5 = u2; - u6 = u3; - u7 = u2; - u8 = u3; - u9 = u3; - return u; - }*/ } void sci::binned(std::valarray<COUNT_T>& x ) { @@ -73,56 +40,22 @@ x = t; } -// void sci::binned(std::valarray<COUNT_T>& x, RESULT_DATA& r ) { -// unsigned int n = x.size()/2; -// std::valarray<COUNT_T> t(n); -// t = std::valarray<COUNT_T>(xstd::slice(0,n,2)); -// t += std::valarray<COUNT_T>(xstd::slice(1,n,2)); -// x.resize(n); -// x = t; -// calcmom( x, r ); -// } - -void sci::calcmom(std::valarray<COUNT_T>& x, RESULT_DATA& r) { +void sci::calcmom(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; -// 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; - 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; + for(unsigned int i = 0; i < n-0; i++ ) r.s0 += ov(xi, r.m )*ou(xi+0, 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 += oc(xi, r.m )*oc(xi+2, r.m); + r.s0 = r.s0/(ov(z,r.m)*ou(z,r.m))/((double)n-1); 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); + r.s2 = r.s2/(oc(z,r.m)*oc(z,r.m))/((double)n-2); } 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; - e.b = 2; - e.c = 3; - e.d = 4; - int n = 100000; - std::valarray<COUNT_T> x(e,n); - - sci::calcmom(x); - - exit(0); + for(unsigned int i = 0; i < n; i++ ) r.s0 += ov(xi, r.m )*ou(xi, r.m); + r.s0 = r.s0/(ov(z,r.m)*ou(z,r.m))/((double)n-1); } -*/
View file
turbina_core_m-1.20.tar.bz2/sci.h -> turbina_core_m-1.27.tar.bz2/sci.h
Changed
@@ -4,9 +4,7 @@ #include <sys/types.h> #include <stdint.h> #include <valarray> -//#include <exchange.h> // count_t -//typedef uint16_t count_t; //in exchange.h typedef unsigned int count_t; //in exchange.h const int n_chan = 4;
View file
turbina_core_m-1.27.tar.bz2/server/.hgtags
Added
@@ -0,0 +1,32 @@ +135764085dd15a107663c0a9154f36b809dc1923 dimm-2_11 +223e2569e1e84bdfc59542ae6e0931095f7437c2 mokko-v1 +560beaa379df8f40a7938bf59bbdefcf1ea4069c ameba-0_40 +68283fd7395f38c1d558df678859fcae41deaa7e dimm-2_26 +68283fd7395f38c1d558df678859fcae41deaa7e dome-1_19 +68283fd7395f38c1d558df678859fcae41deaa7e monitor-1_07 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc ameba-0_59 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc ameba-0_60 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc ameba-0_61 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc ameba-0_62 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc dimm-2_45 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc dimm-2_46 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc dome-1_24 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc monitor-1_30 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc monitor-1_31 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc monitor-1_32 +6c17fce2bf56e1dc148198c3e3e587fc7a1be9bc turbina_core_m-1_20 +863e6af94a47c115b3d827cfaf005cd8e752d204 ameba-0_58 +863e6af94a47c115b3d827cfaf005cd8e752d204 dome-1_23 +863e6af94a47c115b3d827cfaf005cd8e752d204 monitor-1_29 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 dome-1_01 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 dome-1_03 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 start +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 tlsp-0_13 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 tlsp-0_15 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 tlsp-0_20 +9ad9ff9be3b2de132db5dfd288f7e1a924fdeb92 turb-0_2 +c0176904c8f0c48296e12e38241ef8736845ae78 ameba-0_57 +c0176904c8f0c48296e12e38241ef8736845ae78 dimm-2_33 +f1364cffaebd1d89de39da4ec627748e59eb3193 ameba-0-49 +f4d1b12c5ecf742b786ee57c4ae78b0e39f9bf6a ameba-0_12 +f4d1b12c5ecf742b786ee57c4ae78b0e39f9bf6a ameba-0_21
View file
turbina_core_m-1.20.tar.bz2/server/callback.cpp -> turbina_core_m-1.27.tar.bz2/server/callback.cpp
Changed
@@ -1,6 +1,6 @@ /* * socket/event.cpp is a part of programm carbon -* $Id: callback.cpp,v 1.1.1.1 2007/09/09 16:50:18 matwey Exp $ +* $Id$ * Copyright (C) 2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
View file
turbina_core_m-1.20.tar.bz2/server/callback.h -> turbina_core_m-1.27.tar.bz2/server/callback.h
Changed
@@ -3,7 +3,7 @@ /* * socket/event.h is a part of programm carbon -* $Id: callback.h,v 1.1.1.1 2007/09/09 16:50:18 matwey Exp $ +* $Id$ * Copyright (C) 2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
View file
turbina_core_m-1.20.tar.bz2/server/linux.cpp -> turbina_core_m-1.27.tar.bz2/server/linux.cpp
Changed
@@ -1,6 +1,6 @@ /* * socket/linux.cpp is a part of programm carbon -* $Id: linux.cpp,v 1.4 2008/08/07 17:49:16 victor Exp $ +* $Id$ * Copyright (C) 2005-2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
View file
turbina_core_m-1.20.tar.bz2/server/linux.h -> turbina_core_m-1.27.tar.bz2/server/linux.h
Changed
@@ -3,7 +3,7 @@ /* * socket/linux.h is a part of programm carbon -* $Id: linux.h,v 1.2 2007/12/18 20:02:21 victor Exp $ +* $Id$ * Copyright (C) 2005-2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
View file
turbina_core_m-1.20.tar.bz2/server/socket.cpp -> turbina_core_m-1.27.tar.bz2/server/socket.cpp
Changed
@@ -1,6 +1,6 @@ /* * socket.cpp is a part of programm carbon -* $Id: socket.cpp,v 1.3 2012/07/20 14:40:03 matwey Exp $ +* $Id$ * Copyright (C) 2005-2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
View file
turbina_core_m-1.20.tar.bz2/server/socket.h -> turbina_core_m-1.27.tar.bz2/server/socket.h
Changed
@@ -3,7 +3,7 @@ /* * socket.h is a part of programm carbon -* $Id: socket.h,v 1.1.1.1 2007/09/09 16:50:21 matwey Exp $ +* $Id$ * Copyright (C) 2005-2006 Matwey V. Kornilov * * This program is free software; you can redistribute it and/or modify
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
.