Index: /trunk/FACT++/src/smartfact.cc
===================================================================
--- /trunk/FACT++/src/smartfact.cc	(revision 14039)
+++ /trunk/FACT++/src/smartfact.cc	(revision 14040)
@@ -471,4 +471,20 @@
     // -------------------------------------------------------------------
 
+    string GetDir(const double angle)
+    {
+        static const char *dir[] =
+        {
+            "N", "NNE", "NE", "ENE",
+            "E", "ESE", "SE", "SSE",
+            "S", "SSW", "SW", "WSW",
+            "W", "WNW", "NW", "NNW"
+        };
+
+        const uint16_t idx = uint16_t(floor(angle/22.5+16.5))%16;
+        return dir[idx];
+    }
+
+    // -------------------------------------------------------------------
+
     bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false)
     {
@@ -713,16 +729,4 @@
         }
 
-        static const char *dir[] =
-        {
-            "N", "NNE", "NE", "ENE",
-            "E", "ESE", "SE", "SSE",
-            "S", "SSW", "SW", "WSW",
-            "W", "WNW", "NW", "NNW"
-        };
-
-
-        const uint16_t idx = uint16_t(floor(fMagicWeatherHist[kDir].back()/22.5+16.5))%16;
-        //const uint16_t idx = uint16_t(floor(fmod(fMagicWeatherHist[kDir].back()/22.5+360+11.25, 360)/22.5))%16;
-
         ostringstream out;
         out << d.GetJavaDate() << '\n';
@@ -738,5 +742,5 @@
         for (int i=0; i<6; i++)
             out << HTML::kWhite << '\t' << fMagicWeatherHist[i].back() << '\n';
-        out << HTML::kWhite << '\t' << dir[idx] << '\n';
+        out << HTML::kWhite << '\t' << GetDir(fMagicWeatherHist[kDir].back()) << '\n';
         out << HTML::kWhite << '\t';
         if (fTngWeatherDustHist.size()>0)
@@ -791,14 +795,5 @@
         const double az = d.Get<double>(8);
 
-        static const char *dir[] =
-        {
-            "N", "NNE", "NE", "ENE",
-            "E", "ESE", "SE", "SSE",
-            "S", "SSW", "SW", "WSW",
-            "W", "WNW", "NW", "NNW"
-        };
-
-        const uint16_t idx = uint16_t(floor(az/22.5+16.5))%16;
-        fDriveControlPointingAz = dir[idx];
+        fDriveControlPointingAz = GetDir(az);
 
         ostringstream out;
@@ -1664,12 +1659,15 @@
     void UpdateAstronomy()
     {
+        const double lon = -(17.+53./60+26.525/3600);
+        const double lat =   28.+45./60+42.462/3600;
+
         Time now;
 
-        fSun  = Sun (-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600);
-        fMoon = Moon(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600);
+        fSun  = Sun (lon, lat, now);
+        fMoon = Moon(lon, lat, now);
 
         ostringstream out;
         out << setprecision(3);
-        out << fSun.time.JavaDate() << '\n';
+        out << now.JavaDate() << '\n';
         out << HTML::kWhite << '\t' << fSun.fSunRiseDarkTime.GetAsStr("%H:%M") << '\n';
         out << HTML::kWhite << '\t' << fSun.fSunRiseAstronomical.GetAsStr("%H:%M") << '\n';
@@ -1682,7 +1680,14 @@
         out << HTML::kWhite << '\t' << fSun.fSunSetDarkTime.GetAsStr("%H:%M") << '\n';
 
+        ofstream(fPath+"/sun.data") << out.str();
+
+        out.str("");
+        out << now.JavaDate() << '\n';
+
         out << HTML::kWhite << '\t' << fMoon.fMoonRise.GetAsStr("%H:%M") << '\n';
         out << HTML::kWhite << '\t' << fMoon.fMoonTransit.GetAsStr("%H:%M") << '\n';
         out << HTML::kWhite << '\t' << fMoon.fMoonSet.GetAsStr("%H:%M") << '\n';
+
+        out << (fSun.visible?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n';
 
         if (!fMoon.visible)
@@ -1698,16 +1703,12 @@
         }
 
-        out << fMoon.color  << '\t' << fMoon.description << '\n';
+        ostringstream out2;
+        out2 << setprecision(3);
+        out2 << now.JavaDate() << '\n';
 
 #ifdef HAVE_SQL
         try
         {
-            //static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))?");
             static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))");
-            // 2: user
-            // 4: pass
-            // 5: server
-            // 7: port
-            // 9: db
 
             boost::smatch what;
@@ -1723,17 +1724,5 @@
             const string db     = what[9];
             const int port      = atoi(string(what[7]).c_str());
-            /*
-             ostringstream out;
-             out << "Connecting to '";
-             if (!user.empty())
-             out << user << "@";
-             out << server;
-             if (port)
-             out << ":" << port;
-             if (!db.empty())
-             out << "/" << db;
-
-             T::Message(out);
-             */
+
             mysqlpp::Connection conn(db.c_str(), server.c_str(), user.c_str(), passwd.c_str(), port);
 
@@ -1741,5 +1730,6 @@
                 conn.query("SELECT fSourceName, fRightAscension, fDeclination FROM source").store();
 
-            out << HTML::kWhite << '\t';
+            out  << HTML::kWhite << '\t';
+            out2 << HTML::kWhite << '\t';
 
             for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++)
@@ -1748,5 +1738,36 @@
                 const double ra   = (*v)[1];
                 const double dec  = (*v)[2];
-
+#ifdef HAVE_NOVA
+                ln_lnlat_posn observer;
+                observer.lng = lon;
+                observer.lat = lat;
+
+                ln_hrz_posn hrz;
+                ln_equ_posn pos;
+                pos.ra  = ra*15;
+                pos.dec = dec;
+
+                ln_get_hrz_from_equ(&pos, &observer, now.JD(), &hrz);
+                //az =    hrz.az;
+
+                string col = HTML::kWhite;
+                if (hrz.alt>5)
+                    col = HTML::kRed;
+                if (hrz.alt>25)
+                    col = HTML::kYellow;
+                if (hrz.alt>60)
+                    col = HTML::kGreen;
+
+                out2 << "<tr bgcolor='" << col << "'>";
+                out2 << "<td>" << name << "</td>";
+                if (hrz.alt>5)
+                {
+                    out2 << "<td>" << 90-hrz.alt << "&deg;</td>";
+                    out2 << "<td>" << GetDir(hrz.az) << "</td>";
+                }
+                else
+                    out2 << "<td/><td/>";
+                out2 << "</tr>";
+#endif
                 const int32_t angle = fMoon.Angle(ra, dec);
 
@@ -1756,15 +1777,20 @@
                 out << "</tr>";
             }
-            out << '\n';
-            out << HTML::kWhite << '\t' << Time()-now << '\n';
+            out  << '\n';
+            out2 << '\n';
+            out  << HTML::kWhite << '\t' << Time()-now << '\n';
+            out2 << HTML::kWhite << '\t' << Time()-now << '\n';
         }
         catch (const exception &e)
         {
-            out << '\n';
-            out << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
+            out  << '\n';
+            out2 << '\n';
+            out  << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
+            out2 << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
         }
 #endif
 
-        ofstream(fPath+"/astro.data") << out.str();
+        ofstream(fPath+"/moon.data") << out.str();
+        ofstream(fPath+"/source-list.data") << out2.str();
     }
 
Index: /trunk/FACT++/www/smartfact/index.css
===================================================================
--- /trunk/FACT++/www/smartfact/index.css	(revision 14039)
+++ /trunk/FACT++/www/smartfact/index.css	(revision 14040)
@@ -238,2 +238,7 @@
         margin:0;
 }
+.astro td:nth-child(3) {
+	text-align:center;
+        padding:0px 5px 0px 0px;
+        margin:0;
+}
