00001 package GuiComponents.SctConf;
00002
00003 import sctConf.*;
00004 import ipc.*;
00005
00006
00007
00008
00009 import org.omg.CORBA.IntHolder;
00010
00011 public class Proxies {
00012 protected sctConf.Configuration config;
00013
00014 public Proxies(sctConf.Configuration conf) {
00015 config = conf;
00016
00017 if (config==null) {
00018 System.err.println("Error (check configuration running)");
00019 System.exit(0);
00020 }
00021 System.out.println("Found configuration");
00022 }
00023
00024 public PartitionProxy getPartition(int i) {
00025 return new PartitionProxy(i);
00026 }
00027
00028 public class PartitionProxy {
00029 private int m_i;
00030
00031 PartitionProxy(int i) { m_i = i; }
00032
00033 public int index() { return m_i; }
00034 public String toString() {
00035 return "Partition " + m_i;
00036 }
00037 }
00038
00039 public CrateProxy getCrate(int i, int part) {
00040 return new CrateProxy(i, part);
00041 }
00042
00043 public class CrateProxy {
00044 int m_i;
00045 int p;
00046 CrateProxy(int i, int part) { m_i = i; p = part; }
00047 public int index() { return m_i; }
00048 public int partition() { return p; }
00049 public String toString() {
00050 return "Crate " + p + " " + m_i;
00051 }
00052 }
00053
00054 public RodProxy getRod(int i, int part, int crate) {
00055 return new RodProxy(i, part, crate);
00056 }
00057
00058 public class RodProxy {
00059 int m_i;
00060 int p, c;
00061 RodProxy(int i, int crate, int part) { m_i = i; c = crate; p = part; }
00062 public int partition() { return p; }
00063 public int crate() { return c; }
00064 public int index() { return m_i; }
00065 public String toString() {
00066 return "Rod " + p + " " + c + " " + m_i;
00067 }
00068 }
00069
00070 public MurProxy getMUR(int order, int mur, int part, int crate, int rod) {
00071 return new MurProxy(order, mur, part, crate, rod);
00072 }
00073
00074 public MurProxy getMUR(int mur) throws ConfigurationException {
00075 IntHolder mapPart = new IntHolder(), mapCrate = new IntHolder(), mapROD = new IntHolder(), mapOrder = new IntHolder();
00076 config.getMapMURROD(mur, mapPart, mapCrate, mapROD, mapOrder);
00077
00078 return new MurProxy(mapOrder.value, mur, mapPart.value, mapCrate.value, mapROD.value);
00079 }
00080
00081 public class MurProxy {
00082 int m_MUR, m_i;
00083 int m_p, m_c, m_r;
00084 MurProxy(int i, int mur, int partition, int crate, int rod) { m_MUR = mur; m_i = i; m_c = crate; m_p = partition; m_r = rod; }
00085 public int partition() { return m_p; }
00086 public int crate() { return m_c; }
00087 public int rod() { return m_r; }
00089 public int index() { return m_i; }
00091 public int id() { return m_MUR; }
00092 public String toString() {
00093 return "MUR " + m_MUR + " at " + m_i + " in " + m_p + " " + m_c + " " + m_r;
00094 }
00095 }
00096
00097 public ModuleProxy getModule(String sn) {
00098 return new ModuleProxy(sn);
00099 }
00100
00101 public class ModuleProxy {
00102 String sn;
00103 ModuleProxy(String sNum) { sn = sNum; }
00104 public String toString() {
00105 return sn;
00106 }
00107 public String getSN() {
00108 return sn;
00109 }
00110
00111 public String getMURString() {
00112 try {
00113 IntHolder MUR = new IntHolder(), num = new IntHolder();
00114 config.translateFromSN(sn, MUR, num);
00115 return "MUR: " + MUR.value + " index: " + num.value;
00116 } catch(ConfigurationException e) {
00117 return "No mapping to MUR";
00118 }
00119 }
00120
00121 public sctConf.MURType getMURType() {
00122 try {
00123 IntHolder MUR = new IntHolder(), num = new IntHolder();
00124 config.translateFromSN(sn, MUR, num);
00125 return config.getMURType(MUR.value);
00126 } catch(ConfigurationException c) {
00127 return sctConf.MURType.UNKNOWN;
00128 }
00129 }
00130
00131 public int getMUR() throws ConfigurationException {
00132 IntHolder MUR = new IntHolder(), num = new IntHolder();
00133 config.translateFromSN(sn, MUR, num);
00134 return MUR.value;
00135 }
00136
00137 public String getPowerString() {
00138 try {
00139 IntHolder MUR = new IntHolder(), num = new IntHolder();
00140 config.translateFromSN(sn, MUR, num);
00141
00142 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00143 channel = new IntHolder();
00144 config.translateToPowerSupply(MUR.value, num.value, partition, crate, channel);
00145 return "Power: " + partition.value + " " + crate.value + " " + channel.value;
00146 } catch(ConfigurationException e) {
00147 return "Power mapping undefined";
00148 }
00149 }
00150
00151 public String getRODString() {
00152 try {
00153 IntHolder MUR = new IntHolder(), num = new IntHolder();
00154 config.translateFromSN(sn, MUR, num);
00155
00156 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00157 rod = new IntHolder(), channel = new IntHolder();
00158 config.translateToROD(MUR.value, num.value,
00159 partition, rod, crate, channel);
00160 return "Partition: " + partition.value + " Crate: " + crate.value
00161 + " ROD: " + rod.value + " Channel: " + channel.value;
00162 } catch(ConfigurationException e) {
00163 return "No mapping for ROD";
00164 }
00165 }
00166
00167 public int partition() throws ConfigurationException {
00168 IntHolder MUR = new IntHolder(), num = new IntHolder();
00169 config.translateFromSN(sn, MUR, num);
00170
00171 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00172 rod = new IntHolder(), channel = new IntHolder();
00173 config.translateToROD(MUR.value, num.value,
00174 partition, rod, crate, channel);
00175 return partition.value;
00176 }
00177
00178 public int crate() throws ConfigurationException {
00179 IntHolder MUR = new IntHolder(), num = new IntHolder();
00180 config.translateFromSN(sn, MUR, num);
00181
00182 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00183 rod = new IntHolder(), channel = new IntHolder();
00184 config.translateToROD(MUR.value, num.value,
00185 partition, rod, crate, channel);
00186 return crate.value;
00187 }
00188
00189 public int rod() throws ConfigurationException {
00190 IntHolder MUR = new IntHolder(), num = new IntHolder();
00191 config.translateFromSN(sn, MUR, num);
00192
00193 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00194 rod = new IntHolder(), channel = new IntHolder();
00195 config.translateToROD(MUR.value, num.value,
00196 partition, rod, crate, channel);
00197 return rod.value;
00198 }
00199
00200 public String getRRODString() {
00201 try {
00202 IntHolder MUR = new IntHolder(), num = new IntHolder();
00203 config.translateFromSN(sn, MUR, num);
00204
00205 IntHolder partition = new IntHolder(), crate = new IntHolder(),
00206 rod = new IntHolder(), channel = new IntHolder();
00207 config.translateToRROD(MUR.value, num.value,
00208 partition, rod, crate, channel);
00209 return "Redundant connection to:\nPartition: " + partition.value + " Crate: " + crate.value
00210 + " ROD: " + rod.value + " Channel: " + channel.value;
00211 } catch(ConfigurationException e) {
00212 return "No redundant mapping for ROD";
00213 }
00214 }
00215
00216 public String getPhysicalString() {
00217 try {
00218 IntHolder MUR = new IntHolder(), num = new IntHolder();
00219 config.translateFromSN(sn, MUR, num);
00220
00221 if(getMURType() == sctConf.MURType.BARREL) {
00222 IntHolder barrel = new IntHolder(), row = new IntHolder(), number = new IntHolder();
00223 config.translateToBarrel(MUR.value, num.value,
00224 barrel, row, number);
00225 return "Barrel: " + barrel.value + " Row: " + row.value + " Position: " + number.value;
00226 } else if(getMURType() == sctConf.MURType.ENDCAP) {
00227 IntHolder disk = new IntHolder(), quadrant = new IntHolder(), number = new IntHolder();
00228 config.translateToEndcap(MUR.value, num.value,
00229 disk, quadrant, number);
00230 return "Disk: " + disk.value + " Quadrant: " + quadrant.value + " Position: " + number.value;
00231 } else if(getMURType() == sctConf.MURType.UNMAPPED) {
00232 return "No mapping to physical structure";
00233 } else if(getMURType() == sctConf.MURType.UNKNOWN) {
00234 return "MUR of module is unknown (database inconsistent)";
00235 } else {
00236 return "Unknown MUR type returned";
00237 }
00238 } catch(ConfigurationException e) {
00239 return "No mapping to physical structure";
00240 }
00241 }
00242 }
00243 }