Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
FpgaData.java+142added 1.1
Class to contain hybrid temperature data and SVT data tail values

hps-java/src/main/java/org/lcsim/hps/recon/tracking
FpgaData.java added at 1.1
diff -N FpgaData.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ FpgaData.java	28 Apr 2012 23:26:27 -0000	1.1
@@ -0,0 +1,142 @@
+package org.lcsim.hps.recon.tracking;
+
+//--- java ---//
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_MASK;
+
+import java.util.ArrayList;
+import java.util.List;
+
+//--- org.lcsim ---//
+import org.lcsim.event.GenericObject;
+
+//-- Constants ---//
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.ADC_TEMP_COUNT;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.MAX_TEMP;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.MIN_TEMP;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_K0;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.CONST_A;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.BETA;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.V_MAX;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.V_REF;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.R_DIV;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_INC;
+
+/**
+ * Generic object to contain hybrid temperatures and data tail value. 
+ * Converts and ADC value to a temperature in celsius 
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: FpgaData.java,v 1.1 2012/04/28 23:26:27 omoreno Exp $
+ */
+public class FpgaData implements GenericObject {
+
+	List<Double> temperatures = new ArrayList<Double>();
+	int tail;
+	 
+	public static double[] temperatureTable = null;
+	
+	/**
+	 * 
+	 * @param temperature : array containing hybrid temperatures
+	 * @param tail : word present at the end of a FPGA data set
+	 */
+	public FpgaData(int[] data, int tail){
+		
+		int[] temperature = this.extractTemperature(data);
+		
+		// Fill the temperature lookup table
+		this.fillTemperatureTable();
+		
+		this.tail = tail;
+		
+		// Fill the temperature list
+		for(int index = 0; index < temperature.length; index++){
+			temperatures.add(temperatureTable[temperature[index]]);
+		}
+	}
+
+   /**
+    * Extract temperatures from the SVT data stream
+    * 
+    * @param data : array containing temperature data
+    * @return temperatures
+    *  
+    */
+   public int[] extractTemperature(int[] data) {
+       int[] temperatures = new int[(data.length) * 2];
+
+       int tempIndex = 0;
+       for (int index = 0; index < data.length; index++) {
+           temperatures[tempIndex] = data[index] & TEMP_MASK;
+           temperatures[tempIndex + 1] = (data[index] >>> 16) & TEMP_MASK;
+           tempIndex += 2;
+       }
+       return temperatures;
+   }
+   
+   /**
+    * Temperature lookup table.  Takes an ADC value and returns a temperature in Celsius
+    */
+   private void fillTemperatureTable() {
+	   
+	   if(temperatureTable == null){
+		   temperatureTable =  new double[ADC_TEMP_COUNT];
+		  
+		   double tempK, res, volt;
+		   int idx;
+		   double temp = MIN_TEMP;
+		   
+		   while(temp < MAX_TEMP){
+			   
+			   tempK = TEMP_K0 + temp; 
+			   res = CONST_A*Math.exp(BETA/tempK);
+			   volt = (res*V_MAX)/(R_DIV + res);
+			   idx = (int) ((volt/V_REF)*(double)(ADC_TEMP_COUNT - 1));
+			   if(idx < ADC_TEMP_COUNT) temperatureTable[idx] = temp;
+			   temp += TEMP_INC;
+		   }
+	   }
+   }
+	
+	
+   /**
+    * Get the temperature at a given index
+    */
+	@Override
+	public double getDoubleVal(int index) {
+		return temperatures.get(index);
+	}
+
+	@Override
+	public float getFloatVal(int index) {
+		return 0;
+	}
+
+	/**
+	 * Get the tail value
+	 */
+	@Override
+	public int getIntVal(int index) {
+		return tail;
+	}
+
+	@Override
+	public int getNDouble() {
+		return temperatures.size();
+	}
+
+	@Override
+	public int getNFloat() {
+		return 0;
+	}
+
+	@Override
+	public int getNInt() {
+		return 1;
+	}
+
+	@Override
+	public boolean isFixedSize() {
+		return true;
+	};
+}
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1