Index: /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php	(revision 8235)
+++ /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php	(revision 8236)
@@ -442,4 +442,6 @@
          "fObjectName"                       => $fromtable . ".fObjectKEY",
          "fStatusName"                       => $fromtable . ".fStatusKEY",
+         "fBandName"                       => $fromtable . ".fBandKEY",
+         "fTelescopeName"                    => $fromtable . ".fTelescopeKEY",
         );
 
@@ -589,4 +591,6 @@
          "fObjectName"                       => "Object.fObjectName",
          "fStatusName"                       => "Status.fStatusName",
+         "fBandName"                         => "Band.fBandName",
+         "fTelescopeName"                    => "Telescope.fTelescopeName",
         );
 
Index: /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 8235)
+++ /trunk/MagicSoft/Mars/datacenter/macros/filloptical.C	(revision 8236)
@@ -89,7 +89,10 @@
     TString query;
     TString select;
-    Int_t statuskey;
-    Int_t objectkey;
-    Int_t fitsfilekey;
+    TString telescope;
+    TString telname;
+    TString ccd;
+    TString filterband;
+    TString filter;
+    TString band;
     Double_t ra=0;
     Double_t dec=0;
@@ -99,4 +102,12 @@
     TVector3 v;
 
+    cout << fname << endl;
+
+    if (fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_R[_]?[12]?[.]instr", kFALSE)).IsNull())
+    {
+        cout << "Found not valid file: " << fname << endl;
+        return 2;
+    }
+
     while (1)
     {
@@ -106,8 +117,26 @@
             break;
 
-        if (line=="KVA_Celestron_ST8  KVA_Celestron_R" || line.IsNull())
+        if (line.IsNull())
             continue;
 
         TObjArray *arr = line.Tokenize("  ");
+
+        if (line=="KVA_Celestron_ST8  KVA_Celestron_R" ||
+            line=="Tuorla_ST1001E  Tuorla_R")
+        {
+            if (arr->GetEntries()!=2)
+            {
+                cout << "WARNING: Telescopeline with less or more than 2 arguments found " << endl;
+                return 2;
+            }
+            telescope=(*arr)[0]->GetName();
+            telname=telescope(0,telescope.First('_'));
+            ccd=telescope(telescope.Last('_')+1, telescope.Length());
+            filterband=(*arr)[1]->GetName();
+            filter=filterband(0,filterband.Last('_'));
+            band=filterband(filterband.Last('_')+1, filterband.Length());
+            continue;
+        }
+
         if (!line(regexp).IsNull())
         {
@@ -131,4 +160,5 @@
             {
                 cout << "WARNING: Objectline with less or more than 8 arguments found " << endl;
+                cout << line << endl;
                 return 2;
             }
@@ -195,15 +225,22 @@
             cout << " status   : " << status    << endl << endl;
             */
-            statuskey = serv.QueryKeyOfName("Status", status.Data());
-            objectkey = serv.QueryKeyOfName("Object", object.Data());
-            fitsfilekey = serv.QueryKeyOfName("FitsFile", fitsfile.Data());
+            Int_t statuskey   = serv.QueryKeyOfName("Status", status.Data());
+            Int_t objectkey   = serv.QueryKeyOfName("Object", object.Data());
+            Int_t fitsfilekey = serv.QueryKeyOfName("FitsFile", fitsfile.Data());
+            Int_t telkey      = serv.QueryKeyOfName("Telescope", telname.Data());
+            Int_t ccdkey      = serv.QueryKeyOfName("CCD", ccd.Data());
+            Int_t bandkey     = serv.QueryKeyOfName("Band", band.Data());
+            Int_t filterkey   = serv.QueryKeyOfName("Filter", filter.Data());
+
             query=Form("fTimeStamp='%s', fExposure=%s, fFitsFileKEY=%d, "
                        "fObjectKEY=%d, fSkyLevel=%s, fFWHM=%s, "
                        "fApertureRadius=%s, fInstrumentalMag=%s, "
-                       "fInstrumentalMagErr=%s, fStatusKEY=%d, fZenithDistance=",
+                       "fInstrumentalMagErr=%s, fStatusKEY=%d, fCCDKEY=%d, "
+                       "fFilterKEY=%d, fTelescopeKEY=%d, fBandKEY=%d, "
+                       "fZenithDistance=",
                        timestamp.Data(), exposure.Data(), fitsfilekey,
                        objectkey, skylevel.Data(), fwhm.Data(),
                        aperturer.Data(), mag.Data(), magerr.Data(),
-                       statuskey);
+                       statuskey, ccdkey, filterkey, telkey, bandkey);
 
             if (ra==0 || dec==0)
@@ -219,5 +256,5 @@
     }
 
-    cout << fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_KVA_C_R.*[.]instr", kFALSE))
+    cout << fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_R[_]?[12]?[.]instr", kFALSE))
         << ": " << setw(2) << numexp << " exposures, " <<  setw(2) << numstars << " stars" << endl;
 
@@ -254,6 +291,6 @@
         return process(serv, path);
 
-    //fill entries for each runbook file
-    MDirIter Next(path, "2*_KVA_C_R*.instr", -1);
+    //fill entries for each optical data file
+    MDirIter Next(path, "20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_*_R[_]?[12]?[.]instr", -1);
     while (1)
     {
