1 removed + 5 modified, total 6 files
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsConverterRegistery.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsConverterRegistery.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -9,7 +9,7 @@
import org.hps.conditions.svt.SvtPulseParametersConverter;
import org.hps.conditions.svt.SvtBadChannelConverter;
import org.hps.conditions.svt.SvtCalibrationConverter;
-import org.hps.conditions.svt.SvtChannelCollectionConverter;
+import org.hps.conditions.svt.SvtChannelConverter;
import org.hps.conditions.svt.SvtConditionsConverter;
import org.hps.conditions.svt.SvtDaqMapConverter;
import org.hps.conditions.svt.SvtGainConverter;
@@ -53,7 +53,7 @@
// SVT channel map.
// TODO: Needs to support unique collection IDs.
- manager.registerConditionsConverter(new SvtChannelCollectionConverter(factory));
+ manager.registerConditionsConverter(new SvtChannelConverter(factory));
// SVT time shift by sensor.
manager.registerConditionsConverter(new SvtTimeShiftConverter(factory));
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -12,8 +12,8 @@
* Get the channel ID.
* @return The channel ID.
*/
- public int getId() {
- return getFieldValue("id");
+ public int getChannelId() {
+ return getFieldValue("channel_id");
}
/**
@@ -45,7 +45,7 @@
* @return This object as a string.
*/
public String toString() {
- return "id: " + getId() + ", fpga: " + getFpga() + ", hybrid: " + getHybrid() + ", channel: " + getChannel();
+ return "channel_id: " + getChannelId() + ", fpga: " + getFpga() + ", hybrid: " + getHybrid() + ", channel: " + getChannel();
}
/**
@@ -60,7 +60,7 @@
if (o == this)
return true;
SvtChannel channel = (SvtChannel)o;
- return getId() == channel.getId()
+ return getChannelId() == channel.getChannelId()
&& getHybrid() == channel.getHybrid()
&& getFpga() == channel.getFpga()
&& getHybrid() == channel.getHybrid();
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannelCollection.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannelCollection.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -25,10 +25,10 @@
public void add(SvtChannel channel) {
// Add to map.
- if (channelMap.containsKey(channel.getId())) {
- throw new IllegalArgumentException("Channel ID already exists: " + channel.getId());
+ if (channelMap.containsKey(channel.getChannelId())) {
+ throw new IllegalArgumentException("Channel ID already exists: " + channel.getChannelId());
}
- channelMap.put(channel.getId(), channel);
+ channelMap.put(channel.getChannelId(), channel);
// Add to collection.
super.add(channel);
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannelCollectionConverter.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannelCollectionConverter.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -1,79 +0,0 @@
-package org.hps.conditions.svt;
-
-import static org.hps.conditions.ConditionsTableConstants.SVT_CHANNELS;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.hps.conditions.AbstractConditionsObject.FieldValueMap;
-import org.hps.conditions.ConditionsObjectException;
-import org.hps.conditions.ConditionsObjectFactory;
-import org.hps.conditions.ConnectionManager;
-import org.hps.conditions.DatabaseConditionsConverter;
-import org.lcsim.conditions.ConditionsManager;
-
-/**
- * This class converts a table of SVT channel setup data into an {@link SvtChannelCollection}.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-// TODO: This needs to support different collectionIDs.
-public class SvtChannelCollectionConverter extends DatabaseConditionsConverter<SvtChannelCollection> {
-
- public SvtChannelCollectionConverter(ConditionsObjectFactory objectFactory) {
- super(objectFactory);
- }
-
- /**
- * Create the channel map from the conditions database.
- * @param manager The current conditions manager.
- * @param name The name of the conditions set.
- */
- public SvtChannelCollection getData(ConditionsManager manager, String name) {
-
- // Get the connection manager.
- ConnectionManager connectionManager = getConnectionManager();
-
- // Assign default key name for channel data if none given.
- if (name == null)
- name = SVT_CHANNELS;
-
- // Objects for building the return value.
- SvtChannelCollection channels = new SvtChannelCollection(
- _objectFactory.getTableRegistry().getTableMetaData(name),
- -1,
- true);
-
- // Construct the query to get the channel data.
- String query = "SELECT id, fpga, hybrid, channel FROM " + name;
-
- // Execute the query and get the results.
- ResultSet resultSet = connectionManager.query(query);
-
- try {
- // Loop over records.
- while (resultSet.next()) {
- FieldValueMap fieldValues = new FieldValueMap();
- fieldValues.put("id", resultSet.getInt(1));
- fieldValues.put("fpga", resultSet.getInt(2));
- fieldValues.put("hybrid", resultSet.getInt(3));
- fieldValues.put("channel", resultSet.getInt(4));
- SvtChannel newObject = _objectFactory.createObject(
- SvtChannel.class, name, resultSet.getInt(1), fieldValues, true);
- channels.add(newObject);
- }
- } catch (SQLException x) {
- throw new RuntimeException("Database error.", x);
- } catch (ConditionsObjectException x) {
- throw new RuntimeException("Error converting to SvtChannel object.", x);
- }
- return channels;
- }
-
- /**
- * Get the type handled by this converter.
- * @return The type handled by this converter.
- */
- public Class<SvtChannelCollection> getType() {
- return SvtChannelCollection.class;
- }
-}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -142,7 +142,7 @@
SvtCalibration calibration = constants.getCalibration();
// Channel data.
- buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getId(), channel.getFpga(), channel.getHybrid(), channel.getChannel()));
+ buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelId(), channel.getFpga(), channel.getHybrid(), channel.getChannel()));
// Calibration.
buff.append(String.format("%-9.4f %-11.4f ", calibration.getNoise(), calibration.getPedestal()));
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-03-18 23:05:19 UTC (rev 316)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-03-18 23:41:30 UTC (rev 317)
@@ -64,6 +64,7 @@
final int nchannels = sensors.get(0).getNumberOfChannels();
int badChannels = 0;
int pulseNotSet = 0;
+ int nsensors = 0;
// Loop over sensors.
for (HpsSiSensor sensor : sensors) {
// Loop over channels.
@@ -98,6 +99,7 @@
if (sensor.isBadChannel(channel)) {
++badChannels;
}
+ ++nsensors;
}
// Check that time shift is set for the sensor. When unset, it's value will be NaN.
@@ -113,6 +115,8 @@
// There should be exactly 4 channels where the pulse parameters are all zeroes.
assertEquals("The number of channels for which pulse was not set is wrong.", PULSE_NOT_SET_ANSWER, pulseNotSet);
+ System.out.println("Successfully loaded conditions data onto " + nsensors + " SVT sensors!");
+
// Cleanup the database connection.
ConnectionManager.getConnectionManager().disconnect();
}
SVNspam 0.1