package org.TexasTorque.TorqueLib.util;

import java.util.Enumeration;
import java.util.Hashtable;

public class TorqueLogging extends Thread
{
    
    private static TorqueLogging instance;
    private Hashtable logTable;
    private static String fileName = "TorqueLog.txt";
    private static boolean logToDashboard = false;
    private static boolean writeNow = false;
    
    public static void setFileName(String fileNm)
    {
        fileName = fileNm;
    }
    
    public static void setDashboardLogging(boolean log)
    {
        logToDashboard = log;
    }
    
    public static TorqueLogging getInstance()
    {
        return (instance == null) ? instance = new TorqueLogging() : instance;
    }
    
    public TorqueLogging()
    {
        logTable = new Hashtable();
        
    }
    
    public void start()
    {
        
    }
    
    public void run()
    {
        
    }
    
    public void writeKeys()
    {
        if(!logTable.isEmpty())
        {
            String logLine = "";
            Enumeration keys = logTable.keys();
            while(keys.hasMoreElements())
            {
                String key = (String)keys.nextElement();
                Object value = logTable.get(key);
                
            }
        }
    }
    
    public void writeValues()
    {
        if(!logTable.isEmpty())
        {
            String logLine = "";
            Enumeration keys = logTable.keys();
            while(keys.hasMoreElements())
            {
                String key = (String)keys.nextElement();
                Object value = logTable.get(key);
                
            }
        }
    }
    
    public void writeToDashboard()
    {
        
    }
    
    
}

@@ -38,38 +38,8 @@
 l;%0A%0A
-import java.util.Enumeration;%0A
 impo
@@ -159,40 +159,8 @@
 ce;%0A
-    private Hashtable logTable;%0A
     
@@ -276,39 +276,102 @@
 ate 
-static boolean writeNow = false
+Hashtable table;%0A    private String keys;%0A    private String values;%0A    private int numValues
 ;%0A  
@@ -577,24 +577,37 @@
 %0A    public 
+synchronized 
 static Torqu
@@ -766,20 +766,17 @@
         
-logT
+t
 able = n
@@ -791,32 +791,46 @@
 able();%0A        
+numValues = 0;
 %0A    %7D%0A    %0A    
@@ -938,61 +938,99 @@
 lic 
-void writeKeys()%0A    %7B%0A        if(!logTable.isEmpty()
+synchronized void logValue(String name, int value)%0A    %7B%0A        if(table.get(name) == null
 )%0A  
@@ -1049,35 +1049,28 @@
         
-String logLine = %22%22
+keys += name
 ;%0A      
@@ -1079,98 +1079,159 @@
     
-E
 num
-eration keys = logTable.keys(
+Values++;%0A        %7D%0A        table.put(name, %22%22 + value
 );%0A    
+%7D%0A
     
+%0A
     
-while(keys.hasMoreElements()
+public synchronized void logValue(String name, boolean value
 )%0A    
+%7B%0A
         
 %7B%0A  
@@ -1222,32 +1222,62 @@
   %7B%0A        
-%7B
+if(table.get(name) == null)
 %0A      
+  %7B%0A
           St
@@ -1278,98 +1278,213 @@
     
-String key = (String)keys.nextElement(
+  keys += name;%0A            numValues++;%0A        %7D%0A        table.put(name, %22%22 + value
 );%0A    
+%7D%0A
     
+%0A
     
-    Object value = logTable.get(key);
+public synchronized void logValue(String name, double value)%0A    %7B%0A        if(table.get(name) == null)
 %0A   
@@ -1484,32 +1484,34 @@
 ll)%0A        
+%7B%0A
         
 %0A           
@@ -1490,32 +1490,49 @@
       %7B%0A        
+    keys += name;
 %0A            %7D%0A 
@@ -1520,33 +1520,44 @@
 me;%0A            
-%7D
+numValues++;
 %0A        %7D%0A    %7D
@@ -1559,43 +1559,115 @@
     
-%7D%0A    %0A    public void writeV
+    table.put(name, %22%22 + value);%0A    %7D%0A    %0A    public synchronized void logValue(String name, String v
 alue
-s(
 )%0A  
@@ -1685,27 +1685,31 @@
  if(
-!logTable.isEmpty()
+table.get(name) == null
 )%0A  
@@ -1732,27 +1732,20 @@
     
-String logLine = %22%22
+keys += name
 ;%0A  
@@ -1758,98 +1758,122 @@
     
-E
 num
-eration keys = logTable.keys(
+Values++;%0A        %7D%0A        table.put(name, value
 );%0A    
+%7D%0A
     
+%0A
     
-while(keys.hasMoreElements()
+public void writeKeysToFile(
 )%0A    
+%7B%0A
         
 %7B%0A  
@@ -1872,147 +1872,117 @@
     
-%7B
 %0A    
+%7D%0A
     
+%0A
     
-    String key = (String)keys.nextElement
+public void calculateValueString
 ()
-;
 %0A    
+%7B%0A
     
+%7D%0A
     
+%0A
     
-Object value = logTable.get(key);%0A                %0A            %7D
+public void writeValuesToFile()%0A    %7B
 %0A   
@@ -1982,25 +1982,24 @@
   %7B%0A        
-%7D
 %0A    %7D%0A    %0A

set up the logging methods of the class and changed around its structure to rayne's specs