コード例 #1
0
ファイル: ControlLimit.java プロジェクト: guanghaofan/MyTSP
 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();
   }
 }
コード例 #2
0
ファイル: CapAreaManager.java プロジェクト: guanghaofan/MyTSP
  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.");
    }
  }
コード例 #3
0
ファイル: ControlLimit.java プロジェクト: guanghaofan/MyTSP
  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);
  }