/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package mxgstest.egse; import asim.envsim.dhpu.Tm; import asim.envsim.dhpu.tmutils.ParameterValueEvent; import asim.envsim.dhpu.tmutils.ParameterValueFilter; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import mxgsegse.MXGSEGSE; import mxgstest.Output; /** * * @author frec */ public class Science { Output output = new Output(); Basic bas = new Basic(); // static PrintWriter raw; static PrintWriter a0; static PrintWriter a2; static PrintWriter a4; static PrintWriter a6; static PrintWriter a7; static PrintWriter a8; static String Chapter; static String eol; static String w_open; static String scistr0; static int led,hed; static final String ANSI_RESET = "\u001B[0m"; static final String ANSI_BLACK = "\u001B[30m"; static final String ANSI_RED = "\u001B[31m"; static final String ANSI_GREEN = "\u001B[32m"; static final String ANSI_YELLOW = "\u001B[33m"; static final String ANSI_BLUE = "\u001B[34m"; static final String ANSI_PURPLE = "\u001B[35m"; static final String ANSI_CYAN = "\u001B[36m"; static final String ANSI_WHITE = "\u001B[37m"; public void init_science(String chapter) throws Exception { Chapter=chapter; eol=System.getProperty("line.separator"); try { Process p; p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/raw"); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/TGF"); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/Sampled"); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/Background"); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/Pulseheight"); p.waitFor(); p.destroy(); p = Runtime.getRuntime().exec("mkdir "+Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/Aurora"); p.waitFor(); p.destroy(); // raw = new PrintWriter(new BufferedWriter(new FileWriter(Output.home+"/Desktop/testoutput/"+Output.outname+"/"+Chapter+"/raw/"+Output.outname+"_raw.txt"))); w_open=""; scistr0=""; } catch (InterruptedException ex) { Logger.getLogger(Output.class.getName()).log(Level.SEVERE, null, ex); } } public void exit_science() { // raw.close(); if(w_open.equals("a0")){a0.close();} else if(w_open.equals("a2")){a2.close();} else if(w_open.equals("a4")){a4.close();} else if(w_open.equals("a6")){a6.close();} else if(w_open.equals("a8")){a8.close();} w_open=""; } public void out_science(MXGSEGSE egse, long delT) throws Exception { long[] mytime=bas.time(); long sec_start=mytime[1]; long sec_now=mytime[1]; Tm science; String scistr; boolean init,go_on=true; int siz,iwait=0; // ParameterValueEvent hk37Event = new ParameterValueEvent(egse.dhpu.getNonscienceTm(), egse.packetTool, "Private Header.Packet Identification.TM Type", "37", Logger.global); // ParameterValueFilter hk37Tm = new ParameterValueFilter(hk37Event, Logger.global); while(go_on) { Thread.sleep(2000); mytime=bas.time(); sec_now=mytime[1]; /* if(sec_now%60==0 & hk37Tm.size()>0) { System.out.println( egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.Time.")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT1.DAU.PSU TMONs.Channel 1")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT1.DAU.PSU TMONs.Channel 2")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT2.DAU.PSU TMONs.Channel 1")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT2.DAU.PSU TMONs.Channel 2")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT3.DAU.PSU TMONs.Channel 1")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT3.DAU.PSU TMONs.Channel 2")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT4.DAU.PSU TMONs.Channel 1")+" "+ egse.packetTool.getTmParameter(hk37Tm.getLast(), "Packet Data.CZT4.DAU.PSU TMONs.Channel 2") ); } */ siz=egse.dhpu.getScienceTm().size(); if(delT==0) { if(siz==0) { iwait++; } else { iwait=0; } if(iwait>10) go_on=false; } else if(sec_now-sec_start>delT) { go_on=false; } for(int i=0;i56) { n=Integer.valueOf(scistr.substring(48,56),16); if(l>56+n*16) { a6.write(" Time of Latest TCP"+eol+Integer.valueOf(scistr.substring(0,4),16)+" "); a6.write(Integer.valueOf(scistr.substring(4,8),16)+" "); a6.write(Integer.valueOf(scistr.substring(8,16),16)+eol); a6.write(" Observation Time"+eol+Integer.valueOf(scistr.substring(16,24),16)+" "); a6.write(Integer.valueOf(scistr.substring(24,32),16)+eol); a6.write(" DPU Counter Pre-Reset"+eol+Integer.valueOf(scistr.substring(32,40),16)+eol); a6.write(" DAU Data Reduction Factors"+eol+Integer.valueOf(scistr.substring(40,42),16)+" "); a6.write(Integer.valueOf(scistr.substring(42,44),16)+eol); a6.write(" Number of Counts"+eol+Integer.valueOf(scistr.substring(48,56),16)+eol); a6.write(" Detector Counts"+eol); for (int kk=0;kk