Beispiel #1
0
  protected void sendSoftWarning(String str) {
    CoreTsp.out(str);
    NLDEvent nld = NLDEventFactory.getNLD("tspFeed");
    nld.addRoute(NLDConstants.WARNING | NLDConstants.REALTIMESTATUS);
    nld.addKey("Warining");
    nld.addMessage(str);

    nld.write();
    CoreTsp.status("Testing Warning: " + str);
    CoreTsp.out(str);
  }
Beispiel #2
0
  private String getCapIOR() throws TspRuntimeException {

    String capIOR;

    OrionManager orionMan = OrionManager.instance();

    capIOR = orionMan.getCapIOR();

    if (capIOR != null) return capIOR;

    try {
      OICToolManager oicToolManager = OICToolManager.instance();

      capIOR = oicToolManager.retrieveCapIor();

      if (capIOR != null) return capIOR;
    } catch (TspRuntimeException e) {
      e.printStackTrace();
    }

    // Failed to get CAP IOR from OIC tool. Maybe OIC tool doesn't
    // exist so try to get it from Orion
    CoreTsp.out(
        "Failed to retrieve test program connection from OICTool.  Attemting direct orion connection.");
    // OrionManager orionMan = OrionManager.instance();

    capIOR = orionMan.getCapIOR();

    if (capIOR != null) return capIOR;

    System.out.println("Failed to find retrieve a CAP IOR from OICTool or Orion.");

    return null;
  }
Beispiel #3
0
 public void variableUpdate(String key) {
   try {
     // String key = (String)props.get(enableFlag);
     if (key.equals(enableFlag)) {
       TSPProperties props = TSPProperties.instance();
       if (((String) props.get(enableFlag)).equalsIgnoreCase("true")) {
         enabled = true;
       } else {
         CoreTsp.out("SPCControlLimit: " + monitor + " disabled by input XML.");
         enabled = false;
       }
     }
   } catch (TspRuntimeException e) {
     CoreTsp.out("ControlLimit Variable Update Failure");
     e.printStackTrace();
   }
 }
Beispiel #4
0
 public CapArea enviroment() {
   try {
     return capInterface.getArea("Environment");
   } catch (Exception e) {
     CoreTsp.out("Failed to get CapArea[Enviroment]");
     healthy = false;
     return null;
   }
 }
Beispiel #5
0
  private CapAreaManager() throws TspRuntimeException {
    try {
      CorbaManager corbaManager = CorbaManager.instance();

      ORB orb = corbaManager.orbInstance();

      String capIOR = getCapIOR();

      org.omg.CORBA.Object capObj = orb.string_to_object(capIOR);

      capInterface = Sapphire.CAP.CapAreaHelper.narrow(capObj);

      CapArea corbaCapArea = capInterface.getArea("CorbaCap");

      Sapphire.CAP.CorbaCapArea corbaCap = Sapphire.CAP.CorbaCapAreaHelper.narrow(corbaCapArea);

      itaInterface = corbaCap.getITA(); // to restore connection after getting TestProgram Interface

      testProgram = capInterface.getArea("TestProgram");

      levelsArea = itaInterface.getArea("Level", "D4064PS");

      healthy = true;

    } catch (Fatal e) {
      e.printStackTrace();
      healthy = false;
    } catch (Basic e) {
      e.printStackTrace();
      healthy = false;
    } catch (org.omg.CORBA.BAD_PARAM e) {
      System.out.println(
          "CORBA COMM Failure Encountered:  This exception "
              + "will happen if Orion is not running.");
      healthy = false;
    }
    if (!healthy) CoreTsp.out("CapAreaManager is NOT healthy.");
    else CoreTsp.out("CapAreaManager is healthy.");
  }
Beispiel #6
0
  public static void pollActive() {

    if (activeLimits == null) return;
    if (equationVars != null && !simulation) updateTargetDataVars();
    else if (simulation) simulateVariables();

    Iterator limItr = activeLimits.keySet().iterator();

    while (limItr.hasNext()) {
      String limID = (String) limItr.next();
      ControlLimit lim = (ControlLimit) activeLimits.get(limID);
      if (lim.enabled) {
        lim.poll();

        lim.inControl();

        if (lim.stateChanged)
          if (lim.inControl) CoreTsp.out("Entering INCONTROL    :" + lim.toString());
          else lim.sendWarning();
      }
    }
  }
Beispiel #7
0
  public void setEnvVars() {
    // Load some test program enviroment variables
    try {
      CapArea env = capInterface.getArea("Environment");

      TSPProperties properties = TSPProperties.instance();
      ProgramInitInfo testProgInit = ProgramInitInfo.instance();

      String tpFullPath = testProgram.getS("Path");

      String[] tpPathEls = tpFullPath.split("\\\\");

      String progName = "";
      String progVersion = ""; // Added as part of IMS changes

      for (int i = tpPathEls.length - 1; i >= 0; i--) {
        CoreTsp.out(tpPathEls[i]);
        if (tpPathEls[i] != null && !tpPathEls[i].equals("")) {
          progName = tpPathEls[i];
          progVersion = tpPathEls[i - 1]; // Added as part of IMS changes
          break;
        }
      }

      // Added as part of IMS changes
      String[] progVersionEls = progVersion.split("_");
      String TpVer = progVersionEls[progVersionEls.length - 1];

      testProgInit.put("TpName", progName);
      testProgInit.put("TpPath", tpFullPath);
      testProgInit.put("TpVersion", TpVer); // Added as part of IMS changes

      properties.put("TPPath", tpFullPath);
      properties.put("Program", progName);
      properties.put("ProgramVersion", TpVer); // Added as part of IMS changes

      // }

      env.setS("VariableName", "XTOS_TSPCLASSPATH");

      if (env.getB("VariableExists")) {
        String tspClassPath = env.getS("VariableValue");
        String tspPath = tspClassPath.split("classes")[0];

        properties.put("TspDir", tspPath);
        properties.put("TspClassPath", tspClassPath);
        healthy = true;
      } else CoreTsp.out("Error: XTOS_TSPCLASSPATH not set");
    } catch (Fatal e) {
      CoreTsp.out("An exception occurred while communicating with XTOS.");
      e.printStackTrace();
      healthy = false;
    } catch (Basic e) {
      e.printStackTrace();
      healthy = false;
    } catch (TspRuntimeException e) {
      CoreTsp.out(
          "An exception occurred while attempting to "
              + "retrieve an instance of the the internal properties data structure.");
    }
  }
Beispiel #8
0
  public ControlLimit(Element gElement) throws TspRuntimeException {

    value = new Double(0);

    if (blocks == null) blocks = new BlockAccessor();

    monitor = gElement.getChildText("Monitor");
    id = gElement.getChildText("Name");
    enableFlag = gElement.getChildText("EnableFlag");

    String alarmTypeStr = gElement.getChildText("AlarmType");
    String sRate = gElement.getChildText("SampleRate");

    if (alarmTypeStr == null
        || id == null
        || monitor == null
        || sRate == null
        || enableFlag == null) {
      StringBuffer msg = new StringBuffer();
      msg.append("While processing Control Limit[monitor=" + monitor + "][id=" + id + "]");
      msg.append("\nencountered invalid XML exception.  Missing required elements:\n");

      if (alarmTypeStr == null) msg.append("Missing AlarmType\n");
      if (id == null) msg.append("Missing Name\n");
      if (monitor == null) msg.append("Missing Monitor\n");
      if (sRate == null) msg.append("Missing SampleRate\n");
      if (enableFlag == null) msg.append("Missing EnableFlag\n");

      throw new InputFileException(msg);
    }

    // Set the enable flag
    TSPProperties props = TSPProperties.instance();
    if (props.containsKey(enableFlag)) {
      String key = (String) props.get(enableFlag);
      if (key.equalsIgnoreCase("true")) {
        enabled = true;
      } else {
        CoreTsp.out("SPCControlLimit: " + monitor + " disabled by input XML.");
        enabled = false;
        return;
      }
    }

    for (int i = 0; i < ALARMTYPES.length; i++)
      if (alarmTypeStr.equals(ALARMTYPES[i])) alarmType = i;

    if (alarmType == NOTYPE) {
      StringBuffer msg = new StringBuffer();
      msg.append("While processing Control Limit[monitor=" + monitor + "][id=" + id + "]\n");
      msg.append(
          "Encountered invalid XML exception.  AlarmType[" + alarmTypeStr + "] is invalid.\n");
      msg.append("Valid Types:\n");
      for (int i = 0; i < ALARMTYPES.length; i++) msg.append(" " + ALARMTYPES[i]);
      throw new InputFileException(msg);
    }

    sampleRate = Integer.parseInt(sRate);

    targetData = gElement.getChildText("TargetVariable");

    if (targetData != null) {
      if (equationVars == null) {
        HandlerManager hm = HandlerManager.instance();

        TspHandler handler = hm.getHandler();
        int siteCount = handler.getSiteCount();

        equationVars = new HashMap[siteCount];
      }
      for (int i = 0; i < equationVars.length; i++) {
        if (equationVars[i] == null) equationVars[i] = new HashMap();
        equationVars[i].put(targetData, new Double(-1.0));
      }
    }

    loadArguments(gElement);

    inControl = true;

    if (activeLimits == null) activeLimits = new HashMap();

    CoreTsp.out(
        "Activating SPC Control Limit: \n"
            + " Name="
            + id
            + "\n"
            + " MonitorType="
            + monitor
            + "\n"
            + " AlarmType="
            + alarmTypeStr
            + "\n"
            + " SampleRate="
            + sampleRate
            + "\n"
            + " TargetVariable="
            + targetData
            + "\n");

    activeLimits.put(monitor + ":" + id, this);
  }
Beispiel #9
0
 public static void out(String str) {
   if (cntrlDebug) CoreTsp.out(str);
 }