/* * 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 mxgsegse.MXGSEGSE; import mxgsegse.power.Channel; import mxgstest.Output; /** * * @author stet */ public class Power { 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"; Output output = new Output(); static String stepResult; static String stepComment; static boolean stepErr; /** * Send DPU power on command to power supply (Channel 2). * @param egse */ public void powerOnDPU(MXGSEGSE egse) { egse.powerSupply.dpu.turnOn(); } /** * Send DPU power off command to power supply (Channel 2). * @param egse */ public void powerOffDPU(MXGSEGSE egse) { egse.powerSupply.dpu.turnOff(); } /** * Send PSU power on command to power supply (Channel 1). * @param egse */ public void powerOnPSU(MXGSEGSE egse) { egse.powerSupply.psu.turnOn(); } /** * Send PSU power off command to power supply (Channel 1). * @param egse * @throws mxgsegse.power.Channel.Error */ public void powerOffPSU(MXGSEGSE egse) throws Channel.Error { if(egse.powerSupply.psu.isOn()) { egse.powerSupply.psu.turnOff(); } } /** * Verifies the operating current for the DPU using the power supply values. * Gets the current consumption of the DPU at the moment the function is called, and compares to the given values. * @param egse * @param operatingCurrent expected operating current * @param offsetCurrent deviation limit from operatingCurrent (+/-) * @throws Throwable */ public void verifySupplyDPU(MXGSEGSE egse, double operatingCurrent, double offsetCurrent) throws Throwable { double supplyCurrent = egse.powerSupply.dpu.getCurrent(); if(supplyCurrent < (operatingCurrent-offsetCurrent)){ System.out.println("DPU supply current too low."+ANSI_RED+" Accepted minimum: "+(operatingCurrent-offsetCurrent)+" Received: "+supplyCurrent+ANSI_RESET); stepErr=false; stepResult="Failed"; stepComment="Too low"; } else if(supplyCurrent > (operatingCurrent+offsetCurrent)){ System.out.println("DPU supply current too high."+ANSI_RED+" Accepted minimum: "+(operatingCurrent+offsetCurrent)+" Received: "+supplyCurrent+ANSI_RESET); stepErr=false; stepResult="Failed"; stepComment="Too high"; } else { System.out.println(" DPU supply current within bounds. Low - Received - High: "+ANSI_GREEN+String.format("%.3f - %.3f - %.3f",(operatingCurrent-offsetCurrent),supplyCurrent,(operatingCurrent+offsetCurrent))+ANSI_RESET); stepErr=true; stepResult="OK"; stepComment=""; } output.printStepOut("DPU supply current", String.format("%.3f",operatingCurrent-offsetCurrent), String.format("%.3f",operatingCurrent), String.format("%.3f",operatingCurrent+offsetCurrent), String.format("%.3f",supplyCurrent), stepResult, stepComment, stepErr); } /** * Verifies the operating current for the PSU using the power supply values. * Gets the current consumption of the PSU at the moment the function is called, and compares to the given values. * @param egse * @param operatingCurrent expected operating current * @param offsetCurrent deviation limit from operatingCurrent (+/-) * @throws Throwable */ public void verifySupplyPSU(MXGSEGSE egse, double operatingCurrent, double offsetCurrent) throws Throwable { double supplyCurrent = egse.powerSupply.psu.getCurrent(); if(supplyCurrent < (operatingCurrent-offsetCurrent)){ System.out.println(" PSU supply current too low. "+ANSI_RED+"Accepted minimum: "+(operatingCurrent-offsetCurrent)+" Received: "+supplyCurrent+ANSI_RESET); stepErr=false; stepResult="Failed"; stepComment="Too low"; } else if(supplyCurrent > (operatingCurrent+offsetCurrent)){ System.out.println(" PSU supply current too high. "+ANSI_RED+"Accepted maximum: "+(operatingCurrent+offsetCurrent)+" Received: "+supplyCurrent+ANSI_RESET); stepErr=false; stepResult="Failed"; stepComment="Too high"; } else { System.out.println(" PSU supply current within bounds. Low - Received - High: "+ANSI_GREEN+String.format("%.3f - %.3f - %.3f",(operatingCurrent-offsetCurrent),supplyCurrent,(operatingCurrent+offsetCurrent))+ANSI_RESET); stepErr=true; stepResult="OK"; stepComment=""; } output.printStepOut("PSU supply current", String.format("%.3f",operatingCurrent-offsetCurrent), String.format("%.3f",operatingCurrent), String.format("%.3f",operatingCurrent+offsetCurrent), String.format("%.3f",supplyCurrent), stepResult, stepComment, stepErr); } }