Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
25:57b2627fe756
Parent:
21:ce51bb0ba4a5
Child:
28:484943132bb0
--- a/SnStatusFrame.h	Tue Oct 23 20:58:29 2012 +0000
+++ b/SnStatusFrame.h	Tue Oct 30 05:23:57 2012 +0000
@@ -9,6 +9,8 @@
 #include "SnEventFrame.h"
 #include "SnSDUtils.h"
 
+//#define ST_DEBUG
+
 struct SnStatusFrame {
     //
     // A simple struct (everything public) to function like namespace.
@@ -34,6 +36,12 @@
             kMaxSizeOfV2 + sizeof(uint32_t) + sizeof(float);
     static const uint32_t   kMaxSizeOf   = kMaxSizeOfV1;
     
+ public:
+    static bool             fgRecalcFiles;
+ private:
+    static uint32_t         fgNfiles;
+    static float            fgTotKbytes;
+ public:
     static
     uint32_t    GetMaxSizeOf(const uint8_t rv) {
         if (rv==1) {
@@ -75,19 +83,19 @@
         x = SnBitUtils::WriteTo(x, thmrate);
         x = SnBitUtils::WriteTo(x, evtrate);
         // file info
-        uint32_t nfiles(0);
-        float totbytes(0);
-        SnSDUtils::GetDirProps(SnSDUtils::kSDdir, nfiles, totbytes);
-        if (strcmp(SnSDUtils::kSDdir, SnSDUtils::kSDsubDir)!=0) {
-            uint32_t sf(0);
-            float sb(0);
-            SnSDUtils::GetDirProps(SnSDUtils::kSDsubDir, sf, sb);
-            nfiles   += sf;
-            totbytes += sb;
+        if (fgRecalcFiles) {
+#ifdef ST_DEBUG
+            printf("Calling GetDirProps for %s\r\n",SnSDUtils::kSDdir);
+#endif
+            SnSDUtils::GetDirProps(SnSDUtils::kSDdir, fgNfiles, fgTotKbytes);
+            fgTotKbytes /= 1e3; // KB
+#ifdef ST_DEBUG
+            printf("nfiles=%u, tb=%g kb\r\n",fgNfiles,fgTotKbytes);
+#endif
+            fgRecalcFiles = false;
         }
-        totbytes /= 1000; // KB
-        x = SnBitUtils::WriteTo(x, nfiles);
-        x = SnBitUtils::WriteTo(x, totbytes);
+        x = SnBitUtils::WriteTo(x, fgNfiles);
+        x = SnBitUtils::WriteTo(x, fgTotKbytes);
         
         return SnCommWin::kOkMsgSent;
     }