00001 package DisplayGUI;
00002
00003 public class MURInfo {
00004 String[] serialnos = new String[6];
00005 java.io.File murFile;
00006 String murID;
00007 String[][] rxThrMap = new String[2][];
00008 String[][] newRxThrMap = new String[2][];
00009 java.util.Map snMap = new java.util.HashMap();
00010 boolean update;
00011
00012 public MURInfo(String murID, java.io.File file) {
00013 this.murID=murID;
00014 murFile=file;
00015 update=false;
00016 for(int i=0;i<2;i++) {
00017 rxThrMap[i]=new String[6];
00018 newRxThrMap[i]=new String[6];
00019 }
00020 }
00021 public void addModule(String id, String sn) {
00022 try {
00023 int thisID = (Integer.valueOf(id)).intValue();
00024 thisID--;
00025 serialnos[thisID] = sn;
00026 snMap.put(sn,id);
00027 }catch(Exception e) {
00028 System.err.println("**Exception non-integer id for serialno "+sn+" in MUR "+murID);
00029 System.err.println("id="+id+" sn="+sn);
00030 }
00031 }
00032 public java.io.File getXMLFile() {
00033 return murFile;
00034 }
00035 public boolean containsModule(String id) {
00036 try {
00037 int thisID = (Integer.valueOf(id)).intValue();
00038 thisID--;
00039 return (serialnos[thisID]!=null);
00040 }catch(Exception e) {}
00041 return false;
00042 }
00043
00044 public void addThr(String id, int stream, String data, boolean isUpdate) {
00045 int thisID=-1;
00046 try {
00047 thisID = (Integer.valueOf(id)).intValue();
00048 thisID--;
00049 }catch(Exception e) {}
00050 if(thisID==-1) {
00051 System.err.println("Invalid id in MUR "+murID);
00052 return;
00053 }
00054 if(isUpdate) {
00055 newRxThrMap[stream][thisID]=new String(data);
00056 update=true;
00057 }
00058 else rxThrMap[stream][thisID]=new String(data);
00059 }
00060
00061 public String getRxThrData(String sn, int stream, boolean useUpdateValue) {
00062 if(!snMap.containsKey(sn)) {
00063 System.err.println(sn+" not in snMap for MUR "+murID);
00064 return null;
00065 }
00066 String id = (String)snMap.get(sn);
00067 int thisID = Integer.valueOf(id).intValue();
00068 thisID--;
00069 return useUpdateValue ? newRxThrMap[stream][thisID] : rxThrMap[stream][thisID];
00070 }
00071 public boolean isUpdated() {
00072 return update;
00073 }
00074 public String getModuleID(String sn) {
00075 if(!snMap.containsKey(sn)) return null;
00076 return (String)snMap.get(sn);
00077 }
00078 public String getSerialno(String id) {
00079 int index = Integer.valueOf(id).intValue();
00080 index--;
00081 return serialnos[index];
00082 }
00083
00084 }