Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ChipConfiguration.java

00001 /*
00002  * ChipConfiguration.java
00003  *
00004  * Created on 16 September 2003, 16:35
00005  */
00006 
00007 package SctData;
00008 
00009 import Sct.*;
00010 import sctConf.*;
00011 
00016 public class ChipConfiguration implements Streamable {
00017     
00018     public ChipConfiguration(ABCDChip data) {
00019         this.data = data;
00020         options = new ChipOptions(data.basic.config);
00021     }
00022     
00023     public ABCDChip getData() {
00024         return data;
00025     }
00026     
00027     public ChipOptions getOptions() {
00028         return options;
00029     }
00030     
00032     public boolean isActive() {
00033         return data.active != 0;
00034     }
00035     
00037     public void setActive(boolean active) {
00038         data.active = active ? (byte)1 : (byte)0;
00039     }
00040     
00044     public byte getAddress() {
00045         return data.address;
00046     }
00047     
00049     public byte getTrimTarget() {
00050         return data.target;
00051     }
00052     
00054     public void setTrimTarget(byte target) {
00055         data.target = target;
00056     }
00057     
00059     public byte getTrim(int channel) {
00060         return data.trim[channel];
00061     }
00062     
00064     public void setTrim(int channel, byte trim) throws IllegalArgumentException {
00065         if (trim > 15 || trim < 0) throw new IllegalArgumentException("Trim must be 0->15, channel: " + channel + " trim: " + trim);
00066         data.trim[channel] = trim;
00067     }
00068     
00070     public byte getThreshold() {
00071         return data.basic.vthr;
00072     }
00073     
00076     public void setThreshold(byte threshold) {        
00077         data.basic.vthr = threshold;
00078     }
00079     
00081     public byte getCalCharge() {
00082         return data.basic.vcal;
00083     }
00084     
00087     public void setCalCharge(byte calCharge) {        
00088         data.basic.vcal = calCharge;
00089     }
00090     
00092     public byte getStrobeDelay() {
00093         return data.basic.delay;
00094     }
00095     
00097     public void setStrobeDelay(byte strobeDelay) throws IllegalArgumentException {
00098         if (strobeDelay > 63 || strobeDelay < 0) throw new IllegalArgumentException("delay must be 0->63, delay: " + strobeDelay);
00099         data.basic.delay = strobeDelay;
00100     }
00101     
00102     
00104     public void resetMask() {
00105        for (int i=0; i<data.basic.mask.length; ++i) {
00106            data.basic.mask[i] = 0;
00107        }
00108     }
00109     
00111     public void setMask(int ichannel, boolean value) {
00112         if (value) mask(ichannel); 
00113         else unmask(ichannel);
00114     }
00115     
00117     public void mask(int ichannel) {
00118         data.basic.mask[ichannel/32] &= ~(1<<ichannel%32);
00119     }
00120     
00122     public void unmask(int ichannel) {
00123         data.basic.mask[ichannel/32] |= (1<<ichannel%32);
00124     }
00125     
00127     public boolean isMasked(int ichannel) {
00128         return (data.basic.mask[ichannel/32] & (1<<ichannel%32)) == 0;
00129     }
00130     
00140     public byte getRcFunctionIndex() {
00141         return data.caldata.rc_function;
00142     }
00143     
00145     public void setRcFunctionIndex(byte index)  throws IllegalArgumentException {
00146         if (index > 4 || index <= 0) throw new IllegalArgumentException("rcFunction must be 1->4, rcFunction: " + index);
00147         data.caldata.rc_function = index;        
00148     }
00149     
00151     public double getRcParam(int ipar) {
00152         return data.caldata.rc_params[ipar];
00153     }
00154     
00159     public void setRcParam(int ipar, double val) {
00160         data.caldata.rc_params[ipar] = (float)val;
00161     }
00162     
00164 
00169     public void setCalFactor(float factor) {
00170         data.caldata.c_factor = factor;
00171     }
00172     
00174     public float getCalFactor() {
00175         return data.caldata.c_factor;
00176     }    
00177     
00178     public String getClassName() {
00179         return "SctData.ChipConfiguration";
00180     }
00181     
00182     public static Streamable read(IStream s, ObjectManager o) throws java.io.IOException {
00183         ABCDChip data = new ABCDChip();
00184         data.basic = new ABCDBasic();
00185         data.caldata = new ABCDCaldata();        
00186         ChipConfiguration c = new ChipConfiguration(data);
00187         c.readObject(s, o);
00188         return c;
00189     }
00190     
00191     public void readObject(IStream s, ObjectManager o) throws java.io.IOException {        
00192         data.active = s.readByte("Active");
00193         data.address = s.readByte("Address");
00194         data.target = s.readByte("Target");
00195         
00196         options = (ChipOptions)o.readObject(s, "ChipOptions", "SctData.ChipOptions");
00197         data.basic.config = options.getData();
00198         
00199         setThreshold(s.readByte("Threshold"));
00200         setCalCharge(s.readByte("CalCharge"));
00201         setStrobeDelay(s.readByte("Delay"));
00202         data.basic.preamp = s.readByte("Preamp");
00203         data.basic.shaper = s.readByte("Shaper");
00204         
00205         data.basic.mask = s.readIntArray("Masks");
00206         
00207         data.caldata.rc_function = s.readByte("RcFunction");
00208         data.caldata.rc_params = s.readFloatArray("RcParams");
00209         data.caldata.c_factor = s.readFloat("CalFactor");
00210         
00211         data.trim = s.readByteArray("Trims");        
00212     }
00213     
00214     public void write(OStream s, ObjectManager o) throws java.io.IOException {        
00215         s.writeByte("Active", data.active, false);
00216         s.writeByte("Address", data.address, false);
00217         s.writeByte("Target", data.target, false);        
00218         
00219         o.writeObject(s, "ChipOptions", options, false);
00220         
00221         s.writeByte("Threshold", getThreshold(), false);
00222         s.writeByte("CalCharge", getCalCharge(), false);
00223         s.writeByte("Delay", getStrobeDelay(), false);
00224         s.writeByte("Preamp", data.basic.preamp, false);
00225         s.writeByte("Shaper", data.basic.shaper, false);
00226         
00227         s.writeIntArray("Masks", data.basic.mask, false);
00228         
00229         s.writeByte("RcFunction", data.caldata.rc_function, false);
00230         s.writeFloatArray("RcParams", data.caldata.rc_params);
00231         s.writeFloat("CalFactor", data.caldata.c_factor);
00232         
00233         s.writeByteArray("Trims", data.trim, false);
00234     }
00235     
00236     //Data
00237     ABCDChip data;
00238     ChipOptions options;
00239 }

Generated on Thu Jul 15 09:55:40 2004 for SCT DAQ/DCS Software - Java by doxygen 1.3.5