[Kst] branches/work/kst/portto4/kst

Barth Netterfield netterfield at astro.utoronto.ca
Thu Apr 26 14:16:06 UTC 2012


SVN commit 1291978 by netterfield:

data vectors from dirfile sources properly restart if the file writer is
restarted.

change dirfile_maker to provide periods of invalid dirfiles during
startup to help look for bugs.


 M  +5 -3      src/datasources/dirfilesource/dirfilesource.cpp  
 M  +1 -0      src/datasources/dirfilesource/dirfilesource.h  
 M  +6 -3      tests/dirfile_maker/dirfile_maker.c  


--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1291977:1291978
@@ -192,7 +192,8 @@
 
 DirFileSource::DirFileSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e) :
     Kst::DataSource(store, cfg, filename, type), _config(0L),
-    iv(new DataInterfaceDirFileVector(*this)), ix(new DataInterfaceDirFileScalar(*this)), is(new DataInterfaceDirFileString(*this))
+  iv(new DataInterfaceDirFileVector(*this)), ix(new DataInterfaceDirFileScalar(*this)),
+  is(new DataInterfaceDirFileString(*this)), _resetNeeded(false)
 {
   setInterface(iv);
   setInterface(ix);
@@ -288,11 +289,12 @@
 Kst::Object::UpdateType DirFileSource::internalDataSourceUpdate() {
   int newNF = _dirfile->NFrames();
   bool isnew = newNF != _frameCount;
-  bool isNewFile = (_frameCount>newNF);
+  _resetNeeded |= (_frameCount>newNF);
 
   _frameCount = newNF;
 
-  if (isNewFile) {
+  if (_resetNeeded && newNF>0) {
+    _resetNeeded = false;
     reset();
   }
   return (isnew ? Updated : NoChange);
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.h #1291977:1291978
@@ -95,6 +95,7 @@
     friend class DataInterfaceDirFileVector;
     friend class DataInterfaceDirFileScalar;
     friend class DataInterfaceDirFileString;
+    bool _resetNeeded;
 };
 
 
--- branches/work/kst/portto4/kst/tests/dirfile_maker/dirfile_maker.c #1291977:1291978
@@ -67,9 +67,15 @@
   sprintf(tmpstr,"%s/format", dirfilename);
 
   fpf = fopen(tmpstr,"w");
+  /* make curfile */
+  unlink("dm.lnk");
+  symlink(dirfilename, "dm.lnk");
   
+  sleep(1);
   for (i=0; i<NDF; i++) {
     fprintf(fpf,"%s RAW %c %d\n", df[i].field, df[i].type, df[i].spf);
+    fflush(fpf);
+    usleep(100000);
     sprintf(tmpstr,"%s/%s", dirfilename, df[i].field);
     df[i].fp = open(tmpstr, O_WRONLY|O_CREAT, 00644);
   }
@@ -82,9 +88,6 @@
   fprintf(fpf, "cos/units STRING ^o\ncos/quantity STRING Angle\n");
   fclose(fpf);
 
-  /* make curfile */
-  unlink("dm.lnk");
-  symlink(dirfilename, "dm.lnk");
 
   printf("starting loop\n");
   while (1) {


More information about the Kst mailing list