/* * 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.mxgs; import asim.envsim.dhpu.tmutils.ParameterValueEvent; import asim.envsim.dhpu.tmutils.ParameterValueFilter; import java.util.logging.Logger; import mxgsegse.MXGSEGSE; import mxgstest.Output; /** * * @author stet */ public class Psu { Output output = new Output(); 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"; static String stepResult; static String stepComment; static boolean stepErr; public void verifyLHPStartupHeatersSwitchOnTc(MXGSEGSE egse, double wait, String period, int result) throws Throwable { ParameterValueEvent hkEvent = new ParameterValueEvent(egse.dhpu.getNonscienceTm(), egse.packetTool, "Private Header.Packet Identification.TM Type", String.valueOf(0x10), Logger.global); ParameterValueFilter hkTm = new ParameterValueFilter(hkEvent, Logger.global); egse.packetTool.setTcParameter("LHPStartUpHeaterTC", "Packet Data.Period", period); egse.dhpu.sendNormalTc(egse.packetTool.getTc("LHPStartUpHeaterTC")); while((hkTm.size() < 1) && (wait > 0)) { Thread.sleep(100); wait = wait - 0.1; } int resultCode = 0; if(wait <= 0){ stepErr=false; stepResult="Failed"; stepComment="No response (Timeout)"; System.out.println(ANSI_RED+"No response received from LHPStartupHeatersSwitchOnTC (Timeout)."+ANSI_RESET); } else { resultCode = Integer.valueOf(egse.packetTool.getTmParameter(hkTm.removeLast(), "Packet Data.Result")); if(result != resultCode){ stepErr=false; stepResult="Failed"; stepComment=""; System.out.println("Failed comparing Result. "+ANSI_RED+"Expected: "+result+". Recieved: "+resultCode+ANSI_RESET); } else { stepErr=true; stepResult="OK"; stepComment=""; System.out.println(" LHPStartupHeatersSwitchOn: "+ANSI_GREEN+"OK"+ANSI_RESET); } } output.printStepOut("Result", result, resultCode, stepResult, stepComment, stepErr); } public void sendLHPStartupHeatersSwitchOnTc(MXGSEGSE egse, double wait, int period) throws Throwable { egse.packetTool.setTcParameter("LHPStartUpHeaterTC", "Packet Data.Period", String.valueOf(period)); egse.dhpu.sendNormalTc(egse.packetTool.getTc("LHPStartUpHeaterTC")); } }