The following commit has been merged in the master branch:
commit 6c8a981e0a0443238ce101910b283c8f22c099ed
Author: Andrei Zavada <[email protected]>
Date:   Thu Jun 27 02:51:55 2013 +0300

    WIP

diff --git a/src/common/subject_id.cc b/src/common/subject_id.cc
index dc999a4..93518d3 100644
--- a/src/common/subject_id.cc
+++ b/src/common/subject_id.cc
@@ -139,12 +139,15 @@ str_to_dob( const string& s)
 
 string
 SSubjectId::
-str_to_dob( const time_t t_)
+dob_to_str( const time_t t_)
 {
        struct tm t;
-       memset( &t, '\0', sizeof (t));
-
-       
+       gmtime_r( &t_, &t);
+       return agh::str::sasprintf(
+               "%02d-%s-%02d",
+               t.tm_mday,
+               english_month_to_str(t.tm_mon),
+               t.tm_year % 100);
 }
 
 
diff --git a/src/common/subject_id.hh b/src/common/subject_id.hh
index 75fd3c3..ff1442a 100644
--- a/src/common/subject_id.hh
+++ b/src/common/subject_id.hh
@@ -61,6 +61,13 @@ struct SSubjectId {
                        gender = rv.gender;
                }
 
+       void operator=( const SSubjectId& rv)
+               {
+                       id = rv.id;
+                       name = rv.name;
+                       dob = rv.dob;
+                       gender = rv.gender;
+               }
 
        char gender_sign() const
                { return gender_sign(gender); }
@@ -79,7 +86,7 @@ struct SSubjectId {
                {
                        return agh::str::sasprintf(
                                "%s %c %s %s",
-                               id.c_str(), gender_sign(), dob_to_str(),
+                               id.c_str(), gender_sign(), dob_to_str().c_str(),
                                name.c_str());
                }
 
diff --git a/src/libsigfile/edf.cc b/src/libsigfile/edf.cc
index f7d6b07..392794c 100644
--- a/src/libsigfile/edf.cc
+++ b/src/libsigfile/edf.cc
@@ -228,7 +228,7 @@ CEDFFile (const string& fname_, const TSubtype subtype_, 
const int flags_,
 
        strncpy( header.version_number, version_string, 8);
 
-       _subject {"Fafa_1", "Mr. Fafa"};
+       _subject = {"Fafa_1", "Mr. Fafa"};
        set_patient_id( _subject.make_recording_id());
 
        set_recording_id( "Zzz");
diff --git a/src/libsigfile/tsv.cc b/src/libsigfile/tsv.cc
index b241515..c6283a7 100644
--- a/src/libsigfile/tsv.cc
+++ b/src/libsigfile/tsv.cc
@@ -99,66 +99,19 @@ CTSVFile (const string& fname_, const TSubtype subtype_, 
const int flags_,
       // fill out some essential header fields
        resize_seconds( recording_time_);
 
-       _subject.id = "Fafa_1";
+       _subject = {"Fafa_1", "Mr. Fafa"};
        set_recording_id( "Zzz");
        set_comment( fname_);
        set_start_time( time(NULL));
 
-       strncpy( header.header_length,          pad( to_string(header_length),  
  8).c_str(), 8);
-       strncpy( header.data_record_size,       pad( 
to_string(data_record_size), 8).c_str(), 8);
-       strncpy( header.n_data_records,         pad( to_string(n_data_records), 
  8).c_str(), 8);
-       strncpy( header.n_channels,             pad( 
to_string(channels_.size()), 4).c_str(), 4);
-
-       _total_samples_per_record = 0;
        size_t hi = 0;
        for ( auto& h : channels_ ) {
                auto& H = channels[hi];
-
-               H.ucd = h.first;
-               strncpy( H.header.label,
-                        pad( H.ucd.name(), 16).c_str(), 16);
-
-               strncpy( H.header.transducer_type,
-                        pad( H.transducer_type = "no transducer info", 
80).c_str(), 80);
-               strncpy( H.header.physical_dim,
-                        pad( H.physical_dim = "mV", 8).c_str(), 8);
-
-               H.set_physical_range( -20, 20); // expecting these to be reset 
before put_signal
-               H.set_digital_range( INT16_MIN, INT16_MAX);
-               H.scale = (H.physical_max - H.physical_min) /
-                       (H.digital_max - H.digital_min );
-
-               strncpy( H.header.filtering_info,
-                        pad( H.filtering_info = "raw", 80).c_str(), 80);
-               strncpy( H.header.samples_per_record,
-                        pad( to_string( H.samples_per_record = h.second * 
data_record_size), 8).c_str(), 8);
-
-               H._at = _total_samples_per_record;
-               _total_samples_per_record += H.samples_per_record;
-
-               ++hi;
+               H.ucd = h;
        }
 }
 
 
-void
-CTSVFile::SSignal::
-set_physical_range( const double m, const double M)
-{
-       strncpy( header.physical_min, pad( to_string( physical_min = m), 
8).c_str(), 8);
-       strncpy( header.physical_max, pad( to_string( physical_max = M), 
8).c_str(), 8);
-}
-
-
-void
-CTSVFile::SSignal::
-set_digital_range( const int16_t m, const int16_t M)
-{
-       strncpy( header.digital_min, pad( to_string( digital_min = m), 
8).c_str(), 8);
-       strncpy( header.digital_max, pad( to_string( digital_max = M), 
8).c_str(), 8);
-}
-
-
 
 
 // uncomment on demand (also un-dnl AC_CHECK_FUNCS(mremap,,) in configure.ac)
@@ -238,11 +191,10 @@ CTSVFile (CTSVFile&& rv)
 CTSVFile::
 ~CTSVFile ()
 {
-       if ( _mmapping != (void*)-1 ) {
-               munmap( _mmapping, _fsize);
+       if ( _fd != -1 ) {
                close( _fd);
 
-               if ( not (flags() & sigfile::CTypedSource::no_ancillary_files) )
+               if ( not (flags() & sigfile::CSource::no_ancillary_files) )
                        write_ancillary_files();
        }
 }
@@ -251,44 +203,6 @@ CTSVFile::
 
 
 
-
-void
-CTSVFile::
-write_ancillary_files()
-{
-       for ( auto &I : channels ) {
-               if ( not I.artifacts().empty() ) {
-                       ofstream thomas (make_fname_artifacts( I.ucd), 
ios_base::trunc);
-                       if ( thomas.good() )
-                               for ( auto &A : I.artifacts() )
-                                       thomas << A.a << ' ' << A.z << endl;
-               } else
-                       if ( unlink( make_fname_artifacts( I.ucd).c_str()) ) {}
-
-               if ( not I.annotations.empty() ) {
-                       ofstream thomas (make_fname_annotations( I.ucd), 
ios_base::trunc);
-                       for ( auto &A : I.annotations )
-                               thomas << (int)A.type << ' ' << A.span.a << ' ' 
<< A.span.z << ' ' << A.label << EOA << endl;
-               } else
-                       if ( unlink( make_fname_annotations( I.ucd).c_str()) ) 
{}
-       }
-       ofstream thomas (make_fname_filters( filename()), ios_base::trunc);
-       if ( thomas.good() )
-               for ( auto &I : channels )
-                       thomas << I.filters.low_pass_cutoff << ' ' << 
I.filters.low_pass_order << ' '
-                              << I.filters.high_pass_cutoff << ' ' << 
I.filters.high_pass_order << ' '
-                              << (int)I.filters.notch_filter << endl;
-}
-
-
-
-
-
-
-
-
-
-
 int
 CTSVFile::
 _parse_header()

-- 
Sleep experiment manager

_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to