Пример #1
0
  public void resetMeterZonesAll() {
    int i;
    Circuit ckt = DSS.activeCircuit;

    if (ckt.getEnergyMeters().size() == 0) return;

    // initialize the checked flag for all circuit elements.
    for (CktElement elem : ckt.getCktElements()) {
      elem.setChecked(false);
      elem.setIsolated(true);
      for (i = 0; i < elem.getNumTerms(); i++) elem.getTerminal(i).setChecked(false);
    }

    /* Clear some things that will be set by the meter zone */
    for (PDElement elem : ckt.getPDElements()) {
      elem.setMeterObj(null);
      elem.setSensorObj(null);
      elem.setParentPDElement(null);
    }

    for (PCElement elem : ckt.getPCElements()) {
      elem.setMeterObj(null);
      elem.setSensorObj(null);
    }

    // set up the bus adjacency lists for faster searches to build meter zone lists
    CktTree.buildActiveBusAdjacencyLists(busAdjPD, busAdjPC);

    /* Set hasMeter flag for all cktElements */
    setHasMeterFlag();
    DSS.sensorClass.setHasSensorFlag(); // set all sensor branch flags, too.

    // initialise the checked flag for all buses
    for (i = 0; i < ckt.getNumBuses(); i++) ckt.getBus(i).setBusChecked(false);

    for (EnergyMeterObj meter : ckt.getEnergyMeters())
      if (meter.isEnabled()) meter.makeMeterZoneLists();

    CktTree.freeBusAdjacencyLists(busAdjPD, busAdjPC);
    busAdjPD = null;
    busAdjPC = null;
  }
Пример #2
0
  /**
   * Set DSS options.
   *
   * <p>Solve command is re-routed here first to set options before solving.
   */
  public static int doSetCmd(int solveOption) {
    LoadShapeObj testLoadShapeObj;
    int[] numRegs;

    Parser parser = Parser.getInstance();
    Circuit ckt = DSS.activeCircuit;

    int ret = 0;

    // continue parsing command line
    int paramPointer = -1;
    String paramName = parser.getNextParam();
    String param = parser.stringValue();

    while (param.length() > 0) {
      if (paramName.length() == 0) {
        paramPointer += 1;
      } else {
        paramPointer = optionList.getCommand(paramName);
      }

      switch (paramPointer) {
        case -1:
          DSS.doSimpleMsg("Unknown parameter \"" + paramName + "\" for set command ", 130);
          break;
        case 0:
        case 11:
          DSSClassDefs.setObjectClass(param);
          break;
        case 1:
        case 12:
          DSS.setObject(param);
          break;
        case 2:
          ckt.getSolution().setIntHour(parser.integerValue());
          break;
        case 3:
          ckt.getSolution().getDynaVars().t = parser.doubleValue();
          break;
        case 4:
          ckt.getSolution().setYear(parser.integerValue());
          ckt.setDefaultGrowthFactor(
              Math.pow(ckt.getDefaultGrowthRate(), ckt.getSolution().getYear() - 1));
          break;
        case 5:
          ckt.getSolution().setFrequency(parser.doubleValue());
          break;
        case 6:
          ckt.getSolution().getDynaVars().h = Util.interpretTimeStepSize(param);
          break;
        case 17:
          ckt.getSolution().getDynaVars().h = Util.interpretTimeStepSize(param);
          break;
        case 7:
          ckt.getSolution().setMode(Util.interpretSolveMode(param)); // see DSSGlobals
          break;
        case 8:
          ckt.getSolution().setRandomType(Util.interpretRandom(param));
          break;
        case 9:
          ckt.getSolution().setNumberOfTimes(parser.integerValue());
          break;
        case 10:
          ExecHelper.setTime();
          break;
        case 13:
          ExecHelper.setActiveCircuit(param);
          break;
        case 14:
          DSS.defaultEditor = param; // 'Editor='
          break;
        case 15:
          ckt.getSolution().setConvergenceTolerance(parser.doubleValue());
          break;
        case 16:
          ckt.getSolution().setMaxIterations(parser.integerValue());
          break;
        case 18:
          ckt.getSolution()
              .setDefaultLoadModel(
                  Util.interpretLoadModel(param)); // for reverting to last on specified
          ckt.getSolution().setLoadModel(ckt.getSolution().getDefaultLoadModel());
          break;
        case 19:
          ckt.setLoadMultiplier(parser.doubleValue()); // set using loadMultiplier property
          break;
        case 20:
          ckt.setNormalMinVolts(parser.doubleValue());
          break;
        case 21:
          ckt.setNormalMaxVolts(parser.doubleValue());
          break;
        case 22:
          ckt.setEmergMinVolts(parser.doubleValue());
          break;
        case 23:
          ckt.setEmergMaxVolts(parser.doubleValue());
          break;
        case 24:
          ckt.getDefaultDailyShapeObj().setMean(parser.doubleValue() / 100.0);
          break;
        case 25:
          ckt.getDefaultDailyShapeObj().setStdDev(parser.doubleValue() / 100.0);
          break;
        case 26:
          ckt.setLoadDurCurve(param);
          ckt.setLoadDurCurveObj((LoadShapeObj) DSS.loadShapeClass.find(param));
          if (ckt.getLoadDurCurveObj() == null)
            DSS.doSimpleMsg("Load-duration curve not found.", 131);
          break;
        case 27:
          ckt.setDefaultGrowthRate(1.0 + parser.doubleValue() / 100.0);
          ckt.setDefaultGrowthFactor(
              Math.pow(ckt.getDefaultGrowthRate(), ckt.getSolution().getYear() - 1));
          break;
        case 28:
          ckt.getAutoAddObj().setGenKW(parser.doubleValue());
          break;
        case 29:
          ckt.getAutoAddObj().setGenPF(parser.doubleValue());
          break;
        case 30:
          ckt.getAutoAddObj().setCapKVAr(parser.doubleValue());
          break;
        case 31:
          ckt.getAutoAddObj().setAddType(Util.interpretAddType(param));
          break;
        case 32:
          ckt.setDuplicatesAllowed(Util.interpretYesNo(param));
          break;
        case 33:
          ckt.setZonesLocked(Util.interpretYesNo(param));
          break;
        case 34:
          ckt.setUEWeight(parser.doubleValue());
          break;
        case 35:
          ckt.setLossWeight(parser.doubleValue());
          break;
        case 36:
          numRegs = new int[1];
          ckt.setUERegs(Util.parseIntArray(ckt.getUERegs(), numRegs, param));
          ckt.setNumUERegs(numRegs[0]);
          break;
        case 37:
          numRegs = new int[1];
          ckt.setLossRegs(Util.parseIntArray(ckt.getLossRegs(), numRegs, param));
          ckt.setNumLossRegs(numRegs[0]);
          break;
        case 38:
          ExecHelper.doLegalVoltageBases();
          break;
        case 39:
          ckt.getSolution().setAlgorithm(Util.interpretSolveAlg(param));
          break;
        case 40:
          ckt.setTrapezoidalIntegration(Util.interpretYesNo(param));
          break;
        case 41:
          ExecHelper.doAutoAddBusList(param);
          break;
        case 42:
          ckt.getSolution().setControlMode(Util.interpretControlMode(param));
          ckt.getSolution()
              .setDefaultControlMode(
                  ckt.getSolution()
                      .getControlMode()); // always revert to last one specified in a script
          break;
        case 43:
          ckt.getControlQueue().setTrace(Util.interpretYesNo(param));
          break;
        case 44:
          ckt.setGenMultiplier(parser.doubleValue());
          break;
        case 45:
          testLoadShapeObj = (LoadShapeObj) DSS.loadShapeClass.find(param);
          if (testLoadShapeObj != null) ckt.setDefaultDailyShapeObj(testLoadShapeObj);
          break;
        case 46:
          testLoadShapeObj = (LoadShapeObj) DSS.loadShapeClass.find(param);
          if (testLoadShapeObj != null) ckt.setDefaultYearlyShapeObj(testLoadShapeObj);
          break;
        case 47:
          ExecHelper.doSetAllocationFactors(parser.doubleValue());
          break;
        case 48:
          ckt.setPositiveSequence(Util.interpretCktModel(param));
          break;
        case 49:
          ckt.setPriceSignal(parser.doubleValue());
          break;
        case 50:
          ckt.setPriceCurve(param);
          ckt.setPriceCurveObj((PriceShapeObj) DSS.loadShapeClass.find(param));
          if (ckt.getPriceCurveObj() == null)
            DSS.doSimpleMsg("PriceShape: \"" + param + "\" not found.", 132);
          break;
        case 51:
          if (ckt.getActiveCktElement() != null) {
            CktElement elem = ckt.getActiveCktElement();
            elem.setActiveTerminalIdx(parser.integerValue());
            DSS.setActiveBus(
                Util.stripExtension(
                    elem.getBus(elem.getActiveTerminalIdx()))); // bus connected to terminal
          }
          break;
        case 52:
          ckt.setFundamental(
              parser.doubleValue()); // set base frequency for system (used henceforth)
          ckt.getSolution().setFrequency(parser.doubleValue());
          break;
        case 53:
          ExecHelper.doHarmonicsList(param);
          break;
        case 54:
          ckt.getSolution().setMaxControlIterations(parser.integerValue());
          break;
        case 55:
          ret = DSS.setActiveBus(param); // see DSS globals
          break;
        case 56:
          DSS.setDataPath(param); // set a legal data path
          break;
        case 57:
          ExecHelper.doKeeperBusList(param);
          break;
        case 58:
          ExecHelper.doSetReduceStrategy(param);
          break;
        case 59:
          DSS.energyMeterClass.setSaveDemandInterval(Util.interpretYesNo(param));
          break;
        case 60:
          ckt.setPctNormalFactor(parser.doubleValue());
          ExecHelper.doSetNormal(ckt.getPctNormalFactor());
          break;
        case 61:
          DSS.energyMeterClass.setDIVerbose(Util.interpretYesNo(param));
          break;
        case 62:
          ckt.setCaseName(parser.stringValue());
          break;
        case 63:
          ckt.setNodeMarkerCode(parser.integerValue());
          break;
        case 64:
          ckt.setNodeMarkerWidth(parser.integerValue());
          break;
        case 65:
          ckt.setLogEvents(Util.interpretYesNo(param));
          break;
        case 66:
          Executive.getInstance().setRecorderOn(Util.interpretYesNo(param));
          break;
        case 67:
          DSS.energyMeterClass.setDoOverloadReport(Util.interpretYesNo(param));
          break;
        case 68:
          DSS.energyMeterClass.setDoVoltageExceptionReport(Util.interpretYesNo(param));
          break;
        case 69:
          ExecHelper.doSetCFactors(parser.doubleValue());
          break;
        case 70:
          DSS.autoShowExport = Util.interpretYesNo(param);
          break;
        case 71:
          DSS.maxAllocationIterations = parser.integerValue();
          break;
        case 72:
          DSS.defaultBaseFreq = parser.doubleValue();
          ckt.setFundamental(
              parser.doubleValue()); // set base frequency for system (used henceforth)
          ckt.getSolution().setFrequency(parser.doubleValue());
          break;
        case 73:
          ckt.setMarkSwitches(Util.interpretYesNo(param));
          break;
        case 74:
          ckt.setSwitchMarkerCode(parser.integerValue());
          break;
        case 75:
          DSS.daisySize = parser.doubleValue();
          break;
        case 76:
          ckt.setMarkTransformers(Util.interpretYesNo(param));
          break;
        case 77:
          ckt.setTransMarkerCode(parser.integerValue());
          break;
        case 78:
          ckt.setTransMarkerSize(parser.integerValue());
          break;
        case 79:
          ckt.setActiveLoadShapeClass(Util.interpretLoadShapeClass(param));
          break;
        case 80:
          DSS.defaultEarthModel = Util.interpretEarthModel(param);
          break;
        case 81:
          DSS.logQueries = Util.interpretYesNo(param);
          if (DSS.logQueries) DSS.resetQueryLogFile();
        default:
          // ignore excess parameters
          break;
      }

      switch (paramPointer) {
        case 3:
          ckt.getSolution().updateDblHour();
          break;
        case 4:
          ckt.getSolution().updateDblHour();
          break;
      }

      paramName = parser.getNextParam();
      param = parser.stringValue();
    }

    if (solveOption == 1) ExecHelper.doSolveCmd();

    return ret;
  }