LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2014

HPS-SVN October 2014

Subject:

r1308 - /java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Mon, 27 Oct 2014 18:12:43 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (119 lines)

Author: omoreno
Date: Mon Oct 27 11:12:41 2014
New Revision: 1308

Log:
Abstract class providing basic setup information for an SVT sensor channel.

Added:
    java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java   (with props)

Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java
 =============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java	(added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java	Mon Oct 27 11:12:41 2014
@@ -0,0 +1,103 @@
+package org.hps.conditions.svt;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hps.conditions.AbstractConditionsObject;
+import org.hps.conditions.ConditionsObjectCollection;
+import org.hps.conditions.ConditionsObjectException;
+import org.hps.util.Pair;
+
+/**
+ * This abstract class provides basic setup information for an SVT
+ * sensor channel. 
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ */
+public class AbstractSvtChannel extends AbstractConditionsObject {
+
+    // TODO: Put constants into their own class
+	public static final int MAX_NUMBER_OF_SAMPLES = 6;
+    
+	public static abstract class AbstractSvtChannelCollection<T extends AbstractSvtChannel> 
+	    extends ConditionsObjectCollection<T> {
+	    
+	    Map<Integer, T> channelMap = new HashMap<Integer, T>();
+	   
+	    /**
+	     * Add a channel of type extending {@link AbstractSvtChannel} to the
+	     * channel map
+	     * 
+	     * @param A channel of a type extending {@link AbstractSvtChannel}
+	     */
+	    public void add(T channel){
+	    
+	        // If it doesn't exist, add the channel to the channel map
+	        if(channelMap.containsKey(channel.getChannelID())){
+                throw new IllegalArgumentException("[ " + this.getClass().getSimpleName() + " ]: Channel ID already exists: "
+                										+ channel.getChannelID());
+	        }
+	        channelMap.put(channel.getChannelID(), channel);
+	    
+	        // Add to the collection
+	        try { 
+	            super.add(channel);
+	        } catch(ConditionsObjectException e){
+	            throw new RuntimeException(e);
+	        }
+	    }
+	   
+	    /**
+	     * Find a channel of type extending {@link AbstractSvtChannel} using the
+	     * channel ID
+	     * 
+	     * @param channelID
+	     * @return An SVT channel of type extending {@link AbstractSvtChannel}
+	     */
+	    public T findChannel(int channelID){
+	        return channelMap.get(channelID);
+	    }
+	    
+        /**
+         * Find the collection of channels of type extending 
+         * {@link AbstractSvtChannel} that match a DAQ pair.
+         *  
+         * @param pair The DAQ pair.
+         * @return The channels matching the DAQ pair or null if not found.
+         */
+        public abstract Collection<T> find(Pair<Integer, Integer> pair);
+	
+        /**
+         * Convert this object to a human readable string.
+         * 
+         * @return This object converted to a string.
+         */
+        public String toString() {
+            StringBuffer buff = new StringBuffer();
+            for (T channel : this.getObjects()) {
+                buff.append(channel.toString() + '\n');
+            }
+            return buff.toString();
+        }
+	}
+	
+    /**
+     * Get the channel ID.
+     * 
+     * @return The channel ID.
+     */
+    public int getChannelID() {
+        return getFieldValue("channel_id");
+    }
+
+    /**
+     * Get the channel number. This is different from the ID.
+     * 
+     * @return The channel number.
+     */
+    public int getChannel() {
+        return getFieldValue("channel");
+    }
+    
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use