Index: trunk/MagicSoft/Mars/datacenter/macros/filloptical.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 9130)
+++ trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 9131)
@@ -38,4 +38,7 @@
 // Returns 2 in case of invalid file or line in file.
 // Returns 3 in case of a missing object name in the database.
+// Returns 4 in case of a telescope line with more or less than 2 arguments
+// Returns 5 in case of a timestamp line with more or less than 4 arguments
+// Returns 6 in case of a object line with more or less than 10 arguments
 //
 ///////////////////////////////////////////////////////////////////////////
@@ -84,4 +87,6 @@
     TString skylevel;
     TString fwhm;
+    TString ellipticity;
+    TString posangle;
     TString aperturer;
     TString mag;
@@ -130,6 +135,8 @@
             if (arr->GetEntries()!=2)
             {
-                cout << "WARNING: Telescopeline with less or more than 2 arguments found " << endl;
-                return 2;
+                cout << "WARNING: Telescopeline with less or more than 2 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 4;
             }
             telescope=(*arr)[0]->GetName();
@@ -146,6 +153,8 @@
             if (arr->GetEntries()!=4)
             {
-                cout << "WARNING: Timestampline with less or more than 4 arguments found " << endl;
-                return 2;
+                cout << "WARNING: Timestampline with less or more than 4 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 5;
             }
             numexp+=1;
@@ -162,9 +171,10 @@
         else
         {
-            if (arr->GetEntries()!=8)
+            if (arr->GetEntries()!=10)
             {
-                cout << "WARNING: Objectline with less or more than 8 arguments found " << endl;
-                cout << line << endl;
-                return 2;
+                cout << "WARNING: Objectline with less or more than 10 arguments found in file " <<
+                    fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)) << endl;
+                cout << "Line: " << line << endl;
+                return 6;
             }
 
@@ -197,16 +207,22 @@
             }
 
-            object    = Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
-            skylevel  = (*arr)[2]->GetName();
-            fwhm      = (*arr)[3]->GetName();
-            aperturer = (*arr)[4]->GetName();
-            mag       = (*arr)[5]->GetName();
-            magerr    = (*arr)[6]->GetName();
-            status    = (*arr)[7]->GetName();
+            object      = Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
+            skylevel    = (*arr)[2]->GetName();
+            fwhm        = (*arr)[3]->GetName();
+            ellipticity = (*arr)[4]->GetName();
+            posangle    = (*arr)[5]->GetName();
+            aperturer   = (*arr)[6]->GetName();
+            mag         = (*arr)[7]->GetName();
+            magerr      = (*arr)[8]->GetName();
+            status      = (*arr)[9]->GetName();
             //make sure that no nonsense values enter the db
             if (skylevel.Contains("-"))
                 skylevel = "NULL";
+            if (ellipticity.Contains("-"))
+                ellipticity = "NULL";
             if (fwhm.Contains("-") || !fwhm.IsFloat())
                 fwhm     = "NULL";
+            if (posangle.EndsWith("-"))
+                posangle     = "NULL";
             if (!mag.IsFloat())
                 mag      = "NULL";
@@ -221,14 +237,17 @@
             /*
             cout << numexp << "th exposure: star # " << numstars << endl;
-            cout << " timestamp: " << timestamp << endl;
-            cout << " exposure : " << exposure  << endl;
-            cout << " fitsfile : " << fitsfile  << endl;
-            cout << " object   : " << object << endl;
-            cout << " skylevel : " << skylevel  << endl;
-            cout << " fwhm     : " << fwhm      << endl;
-            cout << " aperturer: " << aperturer << endl;
-            cout << " mag      : " << mag << " +/- " << magerr << endl;
-            cout << " status   : " << status    << endl << endl;
+            cout << " timestamp  : " << timestamp   << endl;
+            cout << " exposure   : " << exposure    << endl;
+            cout << " fitsfile   : " << fitsfile    << endl;
+            cout << " object     : " << object      << endl;
+            cout << " skylevel   : " << skylevel    << endl;
+            cout << " fwhm       : " << fwhm        << endl;
+            cout << " ellipticity: " << ellipticity << endl;
+            cout << " posangle   : " << posangle    << endl;
+            cout << " aperturer  : " << aperturer   << endl;
+            cout << " mag        : " << mag << " +/- " << magerr << endl;
+            cout << " status     : " << status      << endl << endl;
             */
+
             Int_t statuskey   = serv.QueryKeyOfName("Status", status.Data());
             Int_t objectkey   = serv.QueryKeyOfName("Object", object.Data());
@@ -241,12 +260,13 @@
             query=Form("fTimeStamp='%s', fExposure=%s, fFitsFileKEY=%d, "
                        "fObjectKEY=%d, fSkyLevel=%s, fFWHM=%s, "
-                       "fApertureRadius=%s, fInstrumentalMag=%s, "
-                       "fInstrumentalMagErr=%s, fStatusKEY=%d, fCCDKEY=%d, "
-                       "fFilterKEY=%d, fTelescopeKEY=%d, fBandKEY=%d, "
-                       "fZenithDistance=%.1f ",
+                       "fEllipticity=%s, fPosAngle=%s, fApertureRadius=%s, "
+                       "fInstrumentalMag=%s, fInstrumentalMagErr=%s, "
+                       "fStatusKEY=%d, fCCDKEY=%d, fFilterKEY=%d, "
+                       "fTelescopeKEY=%d, fBandKEY=%d, fZenithDistance=%.1f ",
                        timestamp.Data(), exposure.Data(), fitsfilekey,
                        objectkey, skylevel.Data(), fwhm.Data(),
-                       aperturer.Data(), mag.Data(), magerr.Data(),
-                       statuskey, ccdkey, filterkey, telkey, bandkey, zd);
+                       ellipticity.Data(), posangle.Data(), aperturer.Data(),
+                       mag.Data(), magerr.Data(), statuskey, ccdkey,
+                       filterkey, telkey, bandkey, zd);
 
             /*
Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 9130)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 9131)
@@ -216,5 +216,5 @@
 #moving the files
 file=""
-opticalfiles=`find $transdir/optical -name '*.instr'`
+opticalfiles=`find $transdir/optical -regextype posix-egrep -regex '^$transdir/optical/20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr$'`
 for opticalfile in $opticalfiles
 do
@@ -243,12 +243,19 @@
          fi
          ;;
-      3) echo " checkfilloptical=$checkfilloptical - Error: position of one object is missing in the database" >> $scriptlog 2>&1 
-         printprocesslog "ERROR filloptical.C failed for $opticalfile because the position of one object is missing in the database"
-         continue
-         ;;
-      *) echo " checkfilloptical=$checkfilloptical - Error -> go on with next file" >> $scriptlog 2>&1 
-         printprocesslog "ERROR filloptical.C failed for $opticalfile"
-         continue
-         ;;
+      3) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: position of one object is missing in the database" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: position of one object is missing in the database"
+         continue ;;
+      4) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: telescope line with more or less than 2 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: telescope line with more or less than 2 arguments"
+         continue ;;
+      5) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: timestamp line with more or less than 4 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: timestamp line with more or less than 4 arguments"
+         continue ;;
+      6) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile: object line with more or less than 8 arguments" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile: object line with more or less than 8 arguments"
+         continue ;;
+      *) echo " checkfilloptical=$checkfilloptical - ERROR filloptical.C failed for $opticalfile -> go on with next file" >> $scriptlog 2>&1 
+         printprocesslog "ERROR filloptical.C failed for $opticalfile (returned $checkfilloptical)"
+         continue ;;
    esac
 done
Index: trunk/MagicSoft/Mars/datacenter/scripts/dbchk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9130)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dbchk	(revision 9131)
@@ -161,5 +161,5 @@
 # CHECK 2
 echo "Checking if all sequences in Sequences have a corresponding sequence files" >> $scriptlog 2>&1
-sequences=`echo SELECT fSequenceFirst FROM Sequences | mymysql`
+sequences=`echo SELECT fSequenceFirst FROM Sequences left join SequenceProcessStatus using (fSequenceFirst,fTelescopeNumber) where not isnull(fSequenceFileWritten) | mymysql`
 for sequence in $sequences
 do
Index: trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C	(revision 9130)
+++ trunk/MagicSoft/Mars/datacenter/tools/fillobjects.C	(revision 9131)
@@ -118,7 +118,8 @@
 
         query+=Form(", fObjectName='%s/%s'", (*arr)[0]->GetName(), (*arr)[1]->GetName());
+        where=Form(" fObjectName='%s/%s'", (*arr)[0]->GetName(), (*arr)[1]->GetName());
         delete arr;
 
-        if (serv.Insert("Object", query)==kFALSE)
+        if (serv.InsertUpdate("Object", query, where)==kFALSE)
             return 2;
         num +=1;
Index: trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C	(revision 9130)
+++ trunk/MagicSoft/Mars/datacenter/tools/fillobjects2.C	(revision 9131)
@@ -118,6 +118,7 @@
 
         query+=Form(", fObjectName='%s'", object.Data());
+        where=Form(" fObjectName='%s'", object.Data());
 
-        if (serv.Insert("Object", query)==kFALSE)
+        if (serv.InsertUpdate("Object", query, where)==kFALSE)
             return 2;
         num +=1;
