Esempio n. 1
0
  public void closeAllDIFiles() {
    if (saveDemandInterval) {
      /* While closing DI files, write all meter registers to one file */
      try {
        createMeterTotals();
      } catch (Exception e) {
        DSS.doSimpleMsg("Error on rewrite of totals file: " + e.getMessage(), 536);
      }

      /* Close all the DI file for each meter */
      for (EnergyMeterObj meter : DSS.activeCircuit.getEnergyMeters())
        if (meter.isEnabled()) meter.closeDemandIntervalFile();

      writeTotalsFile(); // sum all EnergyMeter registers to "totals.csv"
      systemMeter.closeDemandIntervalFile();
      systemMeter.save();
      try {
        meterTotals.close();
        DI_Totals.close();
        DSS.DIFilesAreOpen = false;
        if (overloadFileIsOpen) {
          overloadFile.close();
          overloadFileIsOpen = false;
        }
        if (voltageFileIsOpen) {
          voltageFile.close();
          voltageFileIsOpen = false;
        }
      } catch (IOException e) {
        DSS.doSimpleMsg("Error closing file: " + e.getMessage(), 537);
      }
    }
  }
Esempio n. 2
0
  public void appendAllDIFiles() {
    if (saveDemandInterval) {
      clearDI_Totals(); // clears accumulator arrays

      for (EnergyMeterObj meter : DSS.activeCircuit.getEnergyMeters())
        if (meter.isEnabled()) meter.appendDemandIntervalFile();

      systemMeter.appendDemandIntervalFile();

      /* Open DI_Totals */
      try {
        File DI_TotalsFile = new File(DI_Dir + DSS.SEPARATOR + "DI_Totals.csv");
        /* File must exist */
        if (DI_TotalsFile.exists()) {
          DI_Totals = new FileWriter(DI_TotalsFile, true);
        } else {
          createDI_Totals();
        }
      } catch (Exception e) {
        DSS.doSimpleMsg(
            "Error opening demand interval file \""
                + getClassName()
                + ".csv"
                + " for appending."
                + DSS.CRLF
                + e.getMessage(),
            538);
      }

      DSS.DIFilesAreOpen = true;
    }
  }
Esempio n. 3
0
  @Override
  protected int makeLike(String lineName) {
    int i;
    int success = 0;
    LineSpacingObj elem, other;

    /* See if we can find this line code in the present collection */
    other = (LineSpacingObj) find(lineName);

    if (other != null) {
      elem = activeLineSpacingObj;

      elem.setNWires(other.getNWires()); // allocates
      elem.setNPhases(other.getNPhases());

      for (i = 0; i < elem.getNConds(); i++) elem.setXCoord(i, other.getXCoord(i));

      for (i = 0; i < elem.getNConds(); i++) elem.setYCoord(i, other.getYCoord(i));

      elem.setUnits(other.getUnits());
      elem.setDataChanged(true);

      for (i = 0; i < elem.getParentClass().getNumProperties(); i++)
        elem.setPropertyValue(i, other.getPropertyValue(i));
      success = 1;
    } else {
      DSS.doSimpleMsg("Error in LineSpacing makeLike: \"" + lineName + "\" not found.", 102);
    }

    return success;
  }
Esempio n. 4
0
  /** Similar to "append", by creates the files. */
  public void openAllDIFiles() {
    if (saveDemandInterval) {

      clearDI_Totals(); // clears accumulator arrays

      for (EnergyMeterObj meter : DSS.activeCircuit.getEnergyMeters())
        if (meter.isEnabled()) meter.openDemandIntervalFile();

      systemMeter.openDemandIntervalFile();

      /* Optional exception reporting */
      if (doOverloadReport) openOverloadReportFile();
      if (doVoltageExceptionReport) openVoltageReportFile();

      /* Open DI_Totals */
      try {
        createDI_Totals();
      } catch (Exception e) {
        DSS.doSimpleMsg(
            "Error opening demand interval file \""
                + getClassName()
                + ".csv"
                + " for appending."
                + DSS.CRLF
                + e.getMessage(),
            538);
      }

      DSS.DIFilesAreOpen = true;
    }
  }
Esempio n. 5
0
  /**
   * Set commands that do not require a circuit.
   *
   * <p>This is for setting global options that do not require an active circuit.
   */
  public static boolean doSetCmd_NoCircuit() {
    boolean success = true;

    Parser parser = Parser.getInstance();

    // 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 14:
          DSS.defaultEditor = param; // 'editor='
          break;
        case 56:
          DSS.setDataPath(param); // set a legal data path
          break;
        case 66:
          Executive.getInstance().setRecorderOn(Util.interpretYesNo(param));
          break;
        case 72:
          DSS.defaultBaseFreq = parser.doubleValue();
          break;
        default:
          DSS.doSimpleMsg(
              "You must create a circuit to execute this \"set\" command: " + parser.getCommand(),
              301);
          success = false; // indicate that we could not process all set command
          break;
      }

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

    return success;
  }
Esempio n. 6
0
  /** Reset all meters in active circuit to zero. */
  @Override
  public void resetAll() {
    Circuit ckt = DSS.activeCircuit;

    if (DSS.DIFilesAreOpen) closeAllDIFiles();

    if (saveDemandInterval) {
      /* Make directories to save data */
      File dir = new File(ckt.getCaseName());
      if (!dir.exists()) {
        try {
          dir.mkdir();
        } catch (Exception e) {
          DSS.doSimpleMsg(
              "Error making directory \"" + ckt.getCaseName() + "\": " + e.getMessage(), 522);
        }
      }
      DI_Dir = ckt.getCaseName() + "/DI_yr_" + String.valueOf(ckt.getSolution().getYear()).trim();
      dir = new File(DI_Dir);
      if (!dir.exists()) {
        try {
          dir.mkdir();
        } catch (Exception e) {
          DSS.doSimpleMsg(
              "Error making demand interval directory: \"" + DI_Dir + "\". " + e.getMessage(), 523);
        }
      }

      createDI_Totals();
      try {
        DI_Totals.close();
      } catch (IOException e) {
        DSS.doSimpleMsg("Error closing DI totals file: " + e.getMessage(), -1);
      }
    }

    for (EnergyMeterObj meter : ckt.getEnergyMeters()) meter.resetRegisters();

    systemMeter.reset();

    // reset generator objects, too
    generatorClass.resetRegistersAll();
    DSS.storageClass.resetRegistersAll();
  }
Esempio n. 7
0
  @Override
  protected int makeLike(String energyMeterName) {
    EnergyMeterObj elem;
    int success = 0;

    /* See if we can find this EnergyMeter name in the present collection */
    EnergyMeterObj other = (EnergyMeterObj) find(energyMeterName);

    if (other != null) {
      elem = activeEnergyMeterObj;

      elem.setNumPhases(other.getNumPhases());
      elem.setNumConds(other.getNumConds()); // force reallocation of terminal stuff

      elem.setElementName(other.getElementName());
      elem.setMeteredElement(other.getMeteredElement()); // pointer to target circuit element
      elem.setMeteredTerminalIdx(other.getMeteredTerminalIdx());
      elem.setExcessFlag(other.isExcessFlag());

      elem.setMaxZoneKVANorm(other.getMaxZoneKVANorm());
      elem.setMaxZoneKVAEmerg(other.getMaxZoneKVAEmerg());

      elem.setDefinedZoneListSize(other.getDefinedZoneListSize());
      elem.setDefinedZoneList(new String[elem.getDefinedZoneListSize()]);

      // copy strings over (actually incr ref count on string)
      for (int i = 0; i < elem.getDefinedZoneListSize(); i++)
        elem.getDefinedZoneList()[i] = other.getDefinedZoneList()[i];

      elem.setLocalOnly(other.isLocalOnly());
      elem.setVoltageUEOnly(other.isVoltageUEOnly());

      /* Boolean flags */
      elem.setLosses(other.isLosses());
      elem.setLineLosses(other.isLineLosses());
      elem.setXfmrLosses(other.isXfmrLosses());
      elem.setSeqLosses(other.isSeqLosses());
      elem.setThreePhaseLosses(other.isThreePhaseLosses());
      elem.setVBaseLosses(other.isVBaseLosses());
      elem.setPhaseVoltageReport(other.isPhaseVoltageReport());

      for (int i = 0; i < elem.getParentClass().getNumProperties(); i++)
        elem.setPropertyValue(i, other.getPropertyValue(i));

      success = 1;
    } else {
      DSS.doSimpleMsg("Error in EnergyMeter makeLike: \"" + energyMeterName + "\" not found.", 521);
    }

    return success;
  }
Esempio n. 8
0
  /** Sets the active LineSpacing. */
  public void setCode(String value) {
    LineSpacingObj spacing;

    activeLineSpacingObj = null;

    for (int i = 0; i < elementList.size(); i++) {
      spacing = (LineSpacingObj) elementList.get(i);

      if (spacing.getName().equalsIgnoreCase(value)) {
        activeLineSpacingObj = spacing;
        return;
      }
    }

    DSS.doSimpleMsg("LineSpacing: \"" + value + "\" not found", 103);
  }
Esempio n. 9
0
  private void createDI_Totals() {
    EnergyMeterObj meter;

    try {
      DI_Totals = new FileWriter(DI_Dir + DSS.SEPARATOR + "DI_Totals.csv");
      PrintWriter pw = new PrintWriter(DI_Totals);

      pw.write("Time");
      for (int i = 0; i < DSS.activeCircuit.getEnergyMeters().size(); i++) {
        meter = DSS.activeCircuit.getEnergyMeters().get(i);
        pw.print(", \"" + meter.getRegisterName(i) + "\"");
      }
      pw.println();
      pw.close();
    } catch (Exception e) {
      DSS.doSimpleMsg(
          "Error creating: \"" + DI_Dir + DSS.SEPARATOR + "DI_Totals.csv\": " + e.getMessage(),
          539);
    }
  }
Esempio n. 10
0
  private void writeTotalsFile() {
    EnergyMeterObj mtr;
    double[] regSum = new double[EnergyMeter.NUM_EM_REGISTERS];
    int i, j;
    File f;

    /* Sum up all registers of all meters and write to totals.csv */
    for (i = 0; i < EnergyMeter.NUM_EM_REGISTERS; i++) regSum[i] = 0.0;

    for (EnergyMeterObj meter : DSS.activeCircuit.getEnergyMeters()) {
      if (meter.isEnabled()) {
        for (j = 0; j < EnergyMeter.NUM_EM_REGISTERS; j++)
          regSum[j] = regSum[j] + meter.getRegister(j) * meter.getTotalsMask(j);
      }
    }

    try { // write the file
      f = new File(DI_Dir + DSS.SEPARATOR + "totals.csv");

      FileWriter fw = new FileWriter(f, false);
      PrintWriter pw = new PrintWriter(fw);

      pw.write("Year");
      mtr = DSS.activeCircuit.getEnergyMeters().get(0);
      if (mtr != null) {
        for (i = 0; i < EnergyMeter.NUM_EM_REGISTERS; i++)
          pw.print(", \"" + mtr.getRegisterName(i) + "\"");
      }
      pw.println();

      pw.write(DSS.activeCircuit.getSolution().getYear());
      for (i = 0; i < EnergyMeter.NUM_EM_REGISTERS; i++) pw.printf(", %g ", regSum[i]);
      pw.println();

      pw.close();
      fw.close();
    } catch (Exception e) {
      DSS.doSimpleMsg(
          "Error opening demand interval file Totals.csv." + DSS.CRLF + e.getMessage(), 543);
    }
  }
Esempio n. 11
0
  private void openVoltageReportFile() {
    try {
      if (voltageFileIsOpen) voltageFile.close();

      voltageFile =
          new FileWriter(
              DSS.energyMeterClass.getDI_Dir() + DSS.SEPARATOR + "DI_VoltExceptions.csv");

      voltageFileIsOpen = true;
      PrintWriter pw = new PrintWriter(voltageFile);
      pw.println("\"Hour\", \"Undervoltages\", \"Min Voltage\", \"Overvoltage\", \"Max Voltage\"");
      pw.close();
    } catch (Exception e) {
      DSS.doSimpleMsg(
          "Error opening demand interval file \""
              + DSS.energyMeterClass.getDI_Dir()
              + DSS.SEPARATOR
              + "DI_VoltExceptions.csv\" for writing."
              + DSS.CRLF
              + e.getMessage(),
          541);
    }
  }
Esempio n. 12
0
  private void openOverloadReportFile() {
    try {
      if (overloadFileIsOpen) overloadFile.close();

      overloadFile = new FileWriter(DSS.energyMeterClass.getDI_Dir() + "/DI_Overloads.csv");
      PrintWriter pw = new PrintWriter(overloadFile);

      overloadFileIsOpen = true;
      pw.print(
          "\"Hour\", \"Element\", \"Normal Amps\", \"Emerg Amps\", \"% Normal\", \"% Emerg\", \"kVBase\"");
      pw.println();
      pw.close();
    } catch (Exception e) {
      DSS.doSimpleMsg(
          "Error opening demand interval file \""
              + DSS.energyMeterClass.getDI_Dir()
              + DSS.SEPARATOR
              + "DI_Overloads.csv\" for writing."
              + DSS.CRLF
              + e.getMessage(),
          541);
    }
  }
Esempio n. 13
0
  private void createMeterTotals() {
    int i;
    EnergyMeterObj mtr;
    Circuit ckt = DSS.activeCircuit;

    try {
      File f = new File(DI_Dir + DSS.SEPARATOR + "EnergyMeterTotals.csv");
      meterTotals = new FileWriter(f);
      PrintWriter pw = new PrintWriter(meterTotals);

      pw.write("Name");
      mtr = ckt.getEnergyMeters().get(0);
      if (mtr != null) {
        for (i = 0; i < EnergyMeter.NUM_EM_REGISTERS; i++)
          pw.print(", \"" + mtr.getRegisterName(i) + "\"");
      }
      pw.println();

      pw.close();
    } catch (IOException e) {
      DSS.doSimpleMsg("Error writing meter totals: " + e.getMessage(), -1);
    }
  }
Esempio n. 14
0
  /** Get DSS options requested and put in the global result string. */
  public static int doGetCmd() {
    int paramPointer;
    Circuit ckt = DSS.activeCircuit;

    try {
      DSS.globalResult = ""; // initialize for appending

      // continue parsing command line
      String paramName = Parser.getInstance().getNextParam();
      String param = Parser.getInstance().stringValue();

      // there will be no named parameters in this command and the params
      // themselves will be the parameter name to return
      while (param.length() > 0) {
        paramPointer = optionList.getCommand(param);

        switch (paramPointer) {
          case -1:
            DSS.doSimpleMsg("Unknown parameter \"" + paramName + "\" for Get command ", 133);
            break;
          case 0:
            DSS.appendGlobalResult(ckt.getActiveCktElement().getDSSClassName());
            break;
          case 11:
            DSS.appendGlobalResult(ckt.getActiveCktElement().getDSSClassName());
            break;
          case 1:
            DSS.appendGlobalResult(ckt.getActiveCktElement().getName());
            break;
          case 12:
            DSS.appendGlobalResult(ckt.getActiveCktElement().getName());
            break;
          case 2:
            DSS.appendGlobalResult(String.valueOf(ckt.getSolution().getIntHour()));
            break;
          case 3:
            DSS.appendGlobalResult(String.format("%g", ckt.getSolution().getDynaVars().t));
            break;
          case 4:
            DSS.appendGlobalResult(String.valueOf(ckt.getSolution().getYear()));
            break;
          case 5:
            DSS.appendGlobalResult(String.format("%g", ckt.getSolution().getFrequency()));
            break;
          case 6:
            DSS.appendGlobalResult(String.format("%g", ckt.getSolution().getDynaVars().h));
            break;
          case 17:
            DSS.appendGlobalResult(String.format("%g", ckt.getSolution().getDynaVars().h));
            break;
          case 7:
            DSS.appendGlobalResult(Util.getSolutionModeID());
            break;
          case 8:
            DSS.appendGlobalResult(Util.getRandomModeID());
            break;
          case 9:
            DSS.appendGlobalResult(String.valueOf(ckt.getSolution().getNumberOfTimes()));
            break;
          case 10:
            DSS.appendGlobalResult(
                String.format(
                    "[ %d, %g ]",
                    String.valueOf(ckt.getSolution().getIntHour()),
                    ckt.getSolution().getDynaVars().t));
            break;
          case 13:
            DSS.appendGlobalResult(ckt.getName());
            break;
          case 14:
            DSS.appendGlobalResult(DSS.defaultEditor);
            break;
          case 15:
            DSS.appendGlobalResult(
                String.format("%g", ckt.getSolution().getConvergenceTolerance()));
            break;
          case 16:
            DSS.appendGlobalResult(String.valueOf(ckt.getSolution().getMaxIterations()));
            break;
          case 18:
            DSS.appendGlobalResult(Util.getLoadModel());
            break;
          case 19:
            DSS.appendGlobalResult(String.format("%g", ckt.getLoadMultiplier()));
            break;
          case 20:
            DSS.appendGlobalResult(String.format("%g", ckt.getNormalMinVolts()));
            break;
          case 21:
            DSS.appendGlobalResult(String.format("%g", ckt.getNormalMaxVolts()));
            break;
          case 22:
            DSS.appendGlobalResult(String.format("%g", ckt.getEmergMinVolts()));
            break;
          case 23:
            DSS.appendGlobalResult(String.format("%g", ckt.getEmergMaxVolts()));
            break;
          case 24:
            DSS.appendGlobalResult(
                String.format("%g", ckt.getDefaultDailyShapeObj().getMean() * 100.0));
            break;
          case 25:
            DSS.appendGlobalResult(
                String.format("%g", ckt.getDefaultDailyShapeObj().getStdDev() * 100.0));
            break;
          case 26:
            DSS.appendGlobalResult(ckt.getLoadDurCurve());
            break;
          case 27:
            DSS.appendGlobalResult(String.format("%g", (ckt.getDefaultGrowthRate() - 1.0) * 100.0));
            break;
          case 28:
            DSS.appendGlobalResult(String.format("%g", ckt.getAutoAddObj().getGenKW()));
            break;
          case 29:
            DSS.appendGlobalResult(String.format("%g", ckt.getAutoAddObj().getGenPF()));
            break;
          case 30:
            DSS.appendGlobalResult(String.format("%g", ckt.getAutoAddObj().getCapKVAr()));
            break;
          case 31:
            switch (ckt.getAutoAddObj().getAddType()) {
              case GEN:
                DSS.appendGlobalResult("generator");
                break;
              case CAP:
                DSS.appendGlobalResult("capacitor");
                break;
            }
            break;
          case 32:
            if (ckt.isDuplicatesAllowed()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 33:
            if (ckt.isZonesLocked()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 34:
            DSS.appendGlobalResult(String.format("%g", ckt.getUEWeight()));
            break;
          case 35:
            DSS.appendGlobalResult(String.format("%g", ckt.getLossWeight()));
            break;
          case 36:
            DSS.appendGlobalResult(Util.intArrayToString(ckt.getUERegs(), ckt.getNumUERegs()));
            break;
          case 37:
            DSS.appendGlobalResult(Util.intArrayToString(ckt.getLossRegs(), ckt.getNumLossRegs()));
            break;
          case 38:
            DSS.globalResult = "(";
            for (double vBase : ckt.getLegalVoltageBases())
              DSS.globalResult += String.format("%g, ", vBase);
            DSS.globalResult += ")";
            break;
          case 39:
            switch (ckt.getSolution().getAlgorithm()) {
              case NORMAL:
                DSS.appendGlobalResult("normal");
                break;
              case NEWTON:
                DSS.appendGlobalResult("newton");
                break;
            }
            break;
          case 40:
            if (ckt.isTrapezoidalIntegration()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 41:
            for (int i = 0; i < ckt.getAutoAddBusList().listSize(); i++)
              DSS.appendGlobalResult(ckt.getAutoAddBusList().get(i));
            break;
          case 42:
            DSS.appendGlobalResult(Util.getControlModeID());
            break;
          case 43:
            if (ckt.getControlQueue().isTrace()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 44:
            DSS.appendGlobalResult(String.format("%g", ckt.getGenMultiplier()));
            break;
          case 45:
            DSS.appendGlobalResult(ckt.getDefaultDailyShapeObj().getName());
            break;
          case 46:
            DSS.appendGlobalResult(ckt.getDefaultYearlyShapeObj().getName());
            break;
          case 47:
            DSS.appendGlobalResult("Get function not applicable.");
            break;
          case 48:
            if (ckt.isPositiveSequence()) {
              DSS.appendGlobalResult("positive");
            } else {
              DSS.appendGlobalResult("multiphase");
            }
            break;
          case 49:
            DSS.appendGlobalResult(String.format("%g", ckt.getPriceSignal()));
            break;
          case 50:
            DSS.appendGlobalResult(ckt.getPriceCurve());
            break;
          case 51:
            DSS.appendGlobalResult(
                String.format("%d", ckt.getActiveCktElement().getActiveTerminalIdx()));
            break;
          case 52:
            DSS.appendGlobalResult(String.format("%g", ckt.getFundamental()));
            break;
          case 53:
            if (ckt.getSolution().isDoAllHarmonics()) {
              DSS.appendGlobalResult("ALL");
            } else {
              for (int i = 0; i < ckt.getSolution().getHarmonicListSize(); i++)
                DSS.appendGlobalResult(String.format("%g", ckt.getSolution().getHarmonicList()[i]));
            }
            break;
          case 54:
            DSS.appendGlobalResult(String.valueOf(ckt.getSolution().getMaxControlIterations()));
            break;
          case 55:
            DSS.appendGlobalResult(ckt.getBusList().get(ckt.getActiveBusIndex()));
            break;
          case 56:
            DSS.appendGlobalResult(DSS.dataDirectory);
            break;
          case 57:
            for (int i = 0; i < ckt.getNumBuses(); i++)
              if (ckt.getBus(i).isKeep()) DSS.appendGlobalResult(ckt.getBusList().get(i));
            break;
          case 58:
            DSS.appendGlobalResult(ckt.getReductionStrategyString());
            break;
          case 59:
            if (DSS.energyMeterClass.isSaveDemandInterval()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 60:
            DSS.appendGlobalResult(String.format("%-.g", ckt.getPctNormalFactor()));
            break;
          case 61:
            if (DSS.energyMeterClass.isDI_Verbose()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 62:
            DSS.appendGlobalResult(ckt.getCaseName());
            break;
          case 63:
            DSS.appendGlobalResult(String.format("%d", ckt.getNodeMarkerCode()));
            break;
          case 64:
            DSS.appendGlobalResult(String.format("%d", ckt.getNodeMarkerWidth()));
            break;
          case 65:
            if (ckt.isLogEvents()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 66:
            if (Executive.getInstance().isRecorderOn()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 67:
            if (DSS.energyMeterClass.isDoOverloadReport()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 68:
            if (DSS.energyMeterClass.isDoVoltageExceptionReport()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 69:
            DSS.appendGlobalResult("Get function not applicable.");
            break;
          case 70:
            if (DSS.autoShowExport) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 71:
            DSS.appendGlobalResult(String.format("%d", DSS.maxAllocationIterations));
            break;
          case 72:
            DSS.appendGlobalResult(String.format("%d", DSS.defaultBaseFreq));
            break;
          case 73:
            if (ckt.isMarkSwitches()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 74:
            DSS.appendGlobalResult(String.format("%d", ckt.getSwitchMarkerCode()));
            break;
          case 75:
            DSS.appendGlobalResult(String.format("%-.6g", DSS.daisySize));
            break;
          case 76:
            if (ckt.isMarkTransformers()) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
            break;
          case 77:
            DSS.appendGlobalResult(String.format("%d", ckt.getTransMarkerCode()));
            break;
          case 78:
            DSS.appendGlobalResult(String.format("%d", ckt.getTransMarkerSize()));
            break;
          case 79:
            DSS.appendGlobalResult(Util.getActiveLoadShapeClass());
            break;
          case 80:
            DSS.appendGlobalResult(Util.getEarthModel(DSS.defaultEarthModel));
            break;
          case 81:
            if (DSS.logQueries) {
              DSS.appendGlobalResult("Yes");
            } else {
              DSS.appendGlobalResult("No");
            }
          default:
            // ignore excess parameters
            break;
        }

        paramName = Parser.getInstance().getNextParam();
        param = Parser.getInstance().stringValue();
      }

    } catch (Exception e) {
      DSS.appendGlobalResult("***Error***");
    }

    return 0;
  }
Esempio n. 15
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;
  }
Esempio n. 16
0
 @Override
 public int init(int handle) {
   DSS.doSimpleMsg("Need to implement LineSpacing.init()", -1);
   return 0;
 }
Esempio n. 17
0
 @Override
 public int init(int handle) {
   DSS.doSimpleMsg("Need to implement EnergyMeter.init", -1);
   return 0;
 }
Esempio n. 18
0
  @Override
  public int edit() {
    Parser parser = Parser.getInstance();

    // continue parsing with contents of parser
    activeEnergyMeterObj = (EnergyMeterObj) elementList.getActive();
    DSS.activeCircuit.setActiveCktElement(activeEnergyMeterObj);

    boolean doRecalc = false;

    EnergyMeterObj elem = activeEnergyMeterObj;

    elem.setMeteredElementChanged(false);

    int paramPointer = -1;
    String paramName = parser.getNextParam();
    String param = parser.stringValue();

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

      if (paramPointer >= 0 && paramPointer < numProperties)
        elem.setPropertyValue(paramPointer, param);

      switch (paramPointer) {
        case -1:
          DSS.doSimpleMsg(
              "Unknown parameter \""
                  + paramName
                  + "\" for object \""
                  + getClassName()
                  + "."
                  + elem.getName()
                  + "\"",
              520);
          break;
        case 0:
          elem.setElementName(param.toLowerCase());
          break;
        case 1:
          elem.setMeteredTerminalIdx(parser.integerValue() - 1);
          break;
        case 2: /* Actions */
          switch (param.toLowerCase().charAt(0)) {
            case 'a':
              elem.allocateLoad();
              break;
            case 'c':
              elem.resetRegisters();
              break;
            case 'r':
              elem.reduceZone();
              break;
            case 's':
              elem.saveRegisters();
              break;
            case 't':
              elem.takeSample();
              break;
            case 'z':
              elem.zoneDump();
              break;
          }
          break;
        case 3:
          processOptions(param);
          break;
        case 4:
          elem.setMaxZoneKVANorm(parser.doubleValue());
          break;
        case 5:
          elem.setMaxZoneKVAEmerg(parser.doubleValue());
          break;
        case 6:
          parser.parseAsVector(elem.getNumPhases(), elem.getSensorCurrent()); // inits to zero
          break;
        case 7:
          Util.interpretAndAllocStrArray(
              param, elem.getDefinedZoneListSize(), elem.getDefinedZoneList());
          break;
        case 8:
          elem.setLocalOnly(Util.interpretYesNo(param));
          break;
        case 9:
          interpretRegisterMaskArray(elem.getTotalsMask());
          break;
        case 10:
          elem.setLosses(Util.interpretYesNo(param));
          break;
        case 11:
          elem.setLineLosses(Util.interpretYesNo(param));
          break;
        case 12:
          elem.setXfmrLosses(Util.interpretYesNo(param));
          break;
        case 13:
          elem.setSeqLosses(Util.interpretYesNo(param));
          break;
        case 14:
          elem.setThreePhaseLosses(Util.interpretYesNo(param));
          break;
        case 15:
          elem.setVBaseLosses(Util.interpretYesNo(param));
          break;
        case 16:
          elem.setPhaseVoltageReport(Util.interpretYesNo(param));
          break;
          /* case 10: aem.setHasFeeder(Utilities.interpretYesNo(Param)); break;*/
        default:
          classEdit(activeEnergyMeterObj, paramPointer - EnergyMeter.NumPropsThisClass);
          break;
      }

      switch (paramPointer) {
        case 0:
          elem.setMeteredElementChanged(true);
          doRecalc = true;
          break;
        case 1:
          elem.setMeteredElementChanged(true);
          doRecalc = true;
          break;
        case 10:
          if (elem.hasFeeder()) {
            doRecalc = true;
          } else {
            elem.removeFeederObj();
          }
          break;
      }

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

    if (doRecalc) elem.recalcElementData(); // when some basic data have changed

    return 0;
  }
Esempio n. 19
0
  @Override
  public int edit() {
    Parser parser = Parser.getInstance();

    // continue parsing with contents of parser
    activeLineSpacingObj = (LineSpacingObj) elementList.getActive();
    DSS.activeDSSObject = activeLineSpacingObj;

    LineSpacingObj elem = activeLineSpacingObj;

    int paramPointer = -1;
    String paramName = parser.getNextParam();
    String param = parser.stringValue();

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

      if (paramPointer >= 0 && paramPointer < numProperties)
        elem.setPropertyValue(paramPointer, param);

      switch (paramPointer) {
        case -1:
          DSS.doSimpleMsg(
              "Unknown parameter \""
                  + paramName
                  + "\" for object \""
                  + getClassName()
                  + "."
                  + elem.getName()
                  + "\"",
              10101);
          break;
        case 0:
          elem.setNWires(parser.integerValue()); // forces reallocations
          break;
        case 1:
          elem.setNPhases(parser.integerValue());
          break;
        case 2:
          interpretArray(param, SpcParmChoice.X);
          break;
        case 3:
          interpretArray(param, SpcParmChoice.H);
          break;
        case 4:
          elem.setUnits(LineUnits.interpretUnitsCode(param));
          break;
        default:
          // inherited parameters
          classEdit(activeLineSpacingObj, paramPointer - LineSpacing.NumPropsThisClass);
          break;
      }

      switch (paramPointer) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
          elem.setDataChanged(true);
          break;
      }

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

    return 0;
  }