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

ModuleConfiguration.java

00001 package SctData;
00002 
00003 import Sct.*;
00004 import sctConf.*;
00005 
00016 public class ModuleConfiguration implements Streamable {
00017  
00018     public ModuleConfiguration() {
00019         data = new ABCDModule();
00020         data.chip = new ABCDChip[Parameters.nChipModule];
00021         for (int i=0; i<data.chip.length; ++i) {
00022             data.chip[i] = new ABCDChip();
00023             data.chip[i].basic = new ABCDBasic();
00024             data.chip[i].caldata = new ABCDCaldata();
00025             data.chip[i].trim = new byte[Parameters.nChannelChip];
00026             data.chip[i].caldata.rc_params = new float[3];
00027             data.chip[i].basic.config = new ABCDConfig();
00028             data.chip[i].basic.mask = new int[4];            
00029         }
00030         data.rx = new byte[2];
00031         
00032         for (int i=0; i<chips.length; ++i) {
00033             chips[i] = new ChipConfiguration(data.chip[i]);
00034         }
00035     }
00036     
00037     public ModuleConfiguration(ABCDModule data) {
00038         this.data = data;
00039         for (int i=0; i<chips.length; ++i) {
00040             chips[i] = new ChipConfiguration(data.chip[i]);
00041         }
00042     }
00043     
00044     public ABCDModule getData() {
00045         return data;
00046     }
00047     
00048     public ChipConfiguration getChipConfiguration(int chip) {
00049         return chips[chip];
00050     }
00051 
00056     public boolean isPresent() {
00057         return data.present!=0;
00058     }
00059 
00061     public boolean isActive() {
00062         return data.active != 0;
00063     }
00064 
00065     public void setActive(boolean active) {
00066         if (active) data.active = 1;
00067         else data.active = 0;
00068     }
00069 
00070     public boolean usingPrimaryClock() {
00071         return data.select != 0;
00072     }
00073 
00074     public void setUsingPrimaryClock(boolean usePrimaryClock) {
00075         data.select = usePrimaryClock ? (byte)1 : (byte)0;
00076     }
00077 
00078     public boolean channelIsMasked(int ichannel) {
00079         return getChipConfiguration(ichannel/Parameters.nChannelChip).isMasked(ichannel%Parameters.nChannelChip);
00080     }
00081 
00082     public void maskChannel(int ichannel) {
00083         getChipConfiguration(ichannel/Parameters.nChannelChip).mask(ichannel%Parameters.nChannelChip);
00084     }
00085 
00091     public byte getGroupId() {
00092         return data.groupId;
00093     }
00094 
00095     public void setGroupId(byte param) {
00096         data.groupId = param;
00097     }
00098 
00099     public String getClassName() {
00100         return "SctData.ModuleConfiguration";
00101     }    
00102     
00103     public static Streamable read(IStream s, ObjectManager o) throws java.io.IOException {
00104         ModuleConfiguration mc = new ModuleConfiguration();
00105         for (int i=0; i<mc.chips.length; ++i) {
00106             mc.chips[i] = (ChipConfiguration)o.readObject(s, "ChipConfiguration", "SctData.ChipConfiguration");
00107             mc.data.chip[i] = mc.chips[i].getData();
00108         }
00109         mc.data.present = s.readByte("Present");
00110         mc.data.active = s.readByte("Active");
00111         mc.data.select = s.readByte("Select");
00112         mc.data.groupId = s.readByte("GroupId");
00113         mc.data.pTTC = s.readByte("pTTC");
00114         mc.data.rTTC = s.readByte("rTTC");
00115         mc.data.rx = s.readByteArray("rx");
00116         
00117         return mc;
00118     }    
00119     
00120     public void write(OStream s, ObjectManager o) throws java.io.IOException {
00121         for (int i=0; i<chips.length; ++i) {
00122             o.writeObject(s, "ChipConfiguration", chips[i], false);
00123         }
00124         s.writeByte("Present", data.present, false);
00125         s.writeByte("Active", data.active, false);
00126         s.writeByte("Select", data.select, false);
00127         s.writeByte("GroupId", data.groupId, false);
00128         s.writeByte("pTTC", data.pTTC, false);
00129         s.writeByte("rTTC", data.rTTC, false);
00130         s.writeByteArray("rx", data.rx, false);
00131     }
00132     
00133     //Data
00134     private ABCDModule data;
00135     private ChipConfiguration[] chips = new ChipConfiguration[Parameters.nChipModule];
00136 }

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