Beispiel #1
0
  public void calculateAmounts() {
    Double tmp;

    try {
      // Annual Feed
      tmp =
          ((_sharedInstance.sumSteam / 2200.00)
                  * _sharedInstance.sumHours
                  * _sharedInstance.sumDays
                  * _sharedInstance.sumWeeks)
              + ((_sharedInstance.winSteam / 2200.00)
                  * _sharedInstance.winHours
                  * _sharedInstance.winDays
                  * _sharedInstance.winWeeks);

      _sharedInstance.annualFeed = tmp;

      // Dissolved Oxygen
      int idx = (int) (_sharedInstance.temp - 40.0) / 5;
      int maxIdx = lookupData.length - 1;
      if ((idx < 0) || (idx > maxIdx)) {
        Log.d(
            TAG,
            " Oops, temp index out of range!!! temp:" + _sharedInstance.temp + " index:" + idx);
        if (idx > maxIdx) {
          tmp = lookupData[maxIdx];
          _sharedInstance.dissolvedO2 = tmp;
        } else {
          _sharedInstance.dissolvedO2 = 0.0;
        }
      } else {
        tmp = lookupData[idx];
        _sharedInstance.dissolvedO2 = tmp;
      }
      Log.d(
          TAG,
          " temp:"
              + _sharedInstance.temp
              + " idx:"
              + idx
              + " O2:"
              + _sharedInstance.dissolvedO2
              + " (maxIdx:"
              + maxIdx
              + ")");

      // Product Amounts

      // SOLIDS

      // SS1294
      tmp = (220.0 / (_sharedInstance.maxTDS / _sharedInstance.TDS));
      _sharedInstance.ss1294Dosage = tmp;

      tmp = _sharedInstance.ss1294Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss1294Usage = tmp;

      // SS1295
      tmp =
          (_sharedInstance.dissolvedO2 * 10.0)
              + (35.0 / (_sharedInstance.maxTDS / _sharedInstance.TDS));
      _sharedInstance.ss1295Dosage = tmp;

      tmp = _sharedInstance.ss1295Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss1295Usage = tmp;

      // SS1350
      tmp =
          (_sharedInstance.dissolvedO2 * 10.0)
              + (35.0 / (_sharedInstance.maxTDS / _sharedInstance.TDS));
      _sharedInstance.ss1350Dosage = tmp;

      tmp = _sharedInstance.ss1350Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss1350Usage = tmp;

      // SS1095
      tmp =
          (_sharedInstance.dissolvedO2 * 9.0)
              + (28.0 / (_sharedInstance.maxTDS / _sharedInstance.TDS));
      _sharedInstance.ss1095Dosage = tmp;

      tmp = _sharedInstance.ss1095Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss1095Usage = tmp;

      // SS1995
      tmp =
          (_sharedInstance.CaHardness - _sharedInstance.MAlk)
              + ((1000.0 - _sharedInstance.minCausticAlk)
                  / (_sharedInstance.maxTDS / _sharedInstance.TDS));

      // -ve number means no need for product, so reset to 0.0
      if (tmp < 0.0) {
        _sharedInstance.ss1995Dosage = 0.0;
        _sharedInstance.ss1995Usage = 0.0;
      } else {
        _sharedInstance.ss1995Dosage = tmp;

        tmp = _sharedInstance.ss1995Dosage * _sharedInstance.annualFeed / 1000.0;
        _sharedInstance.ss1995Usage = tmp;
      }

      // SS2295
      tmp =
          (45.0 / (_sharedInstance.maxTDS / _sharedInstance.TDS))
              + (1.11 * _sharedInstance.CaHardness);
      _sharedInstance.ss2295Dosage = tmp;

      tmp = _sharedInstance.ss2295Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss2295Usage = tmp;

      // SS8985
      tmp = (_sharedInstance.MAlk / 3.0);
      _sharedInstance.ss8985Dosage = tmp;

      tmp = _sharedInstance.ss8985Dosage * _sharedInstance.annualFeed / 1000.0;
      _sharedInstance.ss8985Usage = tmp;

      // LIQUIDS

      _sharedInstance.minAlkalinity = 15.0 / 100.0 * _sharedInstance.maxTDS;
      Log.v(TAG, "minAlk: " + round1(_sharedInstance.minAlkalinity));

      tmp = _sharedInstance.maxTDS / _sharedInstance.TDS; // common term

      // S5
      _sharedInstance.s5Dosage = _sharedInstance.dissolvedO2 * 35.0 + (120.0 / tmp);
      _sharedInstance.s5Usage = _sharedInstance.s5Dosage * _sharedInstance.annualFeed / 1000.0;

      // S10
      _sharedInstance.s10Dosage = _sharedInstance.dissolvedO2 * 18.0 + (65.0 / tmp);
      _sharedInstance.s10Usage = _sharedInstance.s10Dosage * _sharedInstance.annualFeed / 1000.0;

      // S123
      _sharedInstance.s123Dosage = _sharedInstance.dissolvedO2 * 65.0 + (150.0 / tmp);
      _sharedInstance.s123Usage = _sharedInstance.s123Dosage * _sharedInstance.annualFeed / 1000.0;

      // S125
      _sharedInstance.s125Dosage = _sharedInstance.dissolvedO2 * 40.0 + (240.0 / tmp);
      _sharedInstance.s125Usage = _sharedInstance.s125Dosage * _sharedInstance.annualFeed / 1000.0;

      // S26
      _sharedInstance.s26Dosage = (600.0 / tmp);
      _sharedInstance.s26Usage = _sharedInstance.s26Dosage * _sharedInstance.annualFeed / 1000.0;

      // S28
      _sharedInstance.s28Dosage = (600.0 / tmp);
      _sharedInstance.s28Usage = _sharedInstance.s28Dosage * _sharedInstance.annualFeed / 1000.0;

      // S19
      _sharedInstance.s19Dosage =
          _sharedInstance.CaHardness
              - _sharedInstance.MAlk
              + ((1000.0 - _sharedInstance.minAlkalinity) / tmp);
      if (_sharedInstance.s19Dosage < 0.0) {
        _sharedInstance.s19Usage = 0.0;
        _sharedInstance.s19Dosage = 0.0;
      } else {
        _sharedInstance.s19Usage = _sharedInstance.s19Dosage * _sharedInstance.annualFeed / 1000.0;
      }

      // S456
      _sharedInstance.s456Dosage = 150.0 * (_sharedInstance.CaHardness + 0.25) / tmp;
      _sharedInstance.s456Usage = _sharedInstance.s456Dosage * _sharedInstance.annualFeed / 1000.0;

      // S124
      _sharedInstance.s124Dosage = (1200.0 / tmp);
      _sharedInstance.s124Usage = _sharedInstance.s124Dosage * _sharedInstance.annualFeed / 1000.0;

      // S22
      _sharedInstance.s22Dosage = (200.0 / tmp) + (4.0 * _sharedInstance.CaHardness);
      _sharedInstance.s22Usage = _sharedInstance.s22Dosage * _sharedInstance.annualFeed / 1000.0;

      // S23
      _sharedInstance.s23Dosage = (1000.0 / tmp) + (20.0 * _sharedInstance.CaHardness);
      _sharedInstance.s23Usage = _sharedInstance.s23Dosage * _sharedInstance.annualFeed / 1000.0;

      // S88
      _sharedInstance.s88Dosage = 3.0 * _sharedInstance.MAlk;
      _sharedInstance.s88Usage = _sharedInstance.s88Dosage * _sharedInstance.annualFeed / 1000.0;

      // S95
      _sharedInstance.s95Dosage = 5.0 * _sharedInstance.MAlk;
      _sharedInstance.s95Usage = _sharedInstance.s95Dosage * _sharedInstance.annualFeed / 1000.0;

    } catch (Exception e) {
      Log.e(TAG, "calculateAmounts() - exception: " + e.toString());
    }
  }
Beispiel #2
0
  // restore saved values
  public void restore() {
    try {
      if (mContext != null) {
        SharedPreferences settings = mContext.getSharedPreferences(PREFS_NAME, 0);

        if (settings != null) {
          _sharedInstance.inSite = settings.getString("inSite", "");
          if (_sharedInstance.inSite.length() > 0) {
            _sharedInstance.inSumSteam = settings.getString("inSumSteam", "");
            _sharedInstance.inSumHours = settings.getString("inSumHours", "");
            _sharedInstance.inSumDays = settings.getString("inSumDays", "");
            _sharedInstance.inSumWeeks = settings.getString("inSumWeeks", "");
            _sharedInstance.inWinSteam = settings.getString("inWinSteam", "");
            _sharedInstance.inWinHours = settings.getString("inWinHours", "");
            _sharedInstance.inWinDays = settings.getString("inWinDays", "");
            _sharedInstance.inWinWeeks = settings.getString("inWinWeeks", "");
            _sharedInstance.inTDS = settings.getString("inTDS", "");
            _sharedInstance.inMAlk = settings.getString("inMAlk", "");
            _sharedInstance.inPH = settings.getString("inPH", "");
            _sharedInstance.inCaHardness = settings.getString("inCaHardness", "");
            _sharedInstance.inTemp = settings.getString("inTemp", "");
            _sharedInstance.inMaxTDS = settings.getString("inMaxTDS", "");
            _sharedInstance.inMinSulphite = settings.getString("inMinSulphite", "");
            _sharedInstance.inMinCausticAlk = settings.getString("inMinCausticAlk", "");

            // convert strings and update binary versions of parameters
            _sharedInstance.sumSteam = Double.valueOf(_sharedInstance.inSumSteam);
            _sharedInstance.sumHours = Double.valueOf(_sharedInstance.inSumHours);
            _sharedInstance.sumDays = Double.valueOf(_sharedInstance.inSumDays);
            _sharedInstance.sumWeeks = Double.valueOf(_sharedInstance.inSumWeeks);
            _sharedInstance.winSteam = Double.valueOf(_sharedInstance.inWinSteam);
            _sharedInstance.winHours = Double.valueOf(_sharedInstance.inWinHours);
            _sharedInstance.winDays = Double.valueOf(_sharedInstance.inWinDays);
            _sharedInstance.winWeeks = Double.valueOf(_sharedInstance.inWinWeeks);
            _sharedInstance.TDS = Double.valueOf(_sharedInstance.inTDS);
            _sharedInstance.MAlk = Double.valueOf(_sharedInstance.inMAlk);
            _sharedInstance.pH = Double.valueOf(_sharedInstance.inPH);
            _sharedInstance.CaHardness = Double.valueOf(_sharedInstance.inCaHardness);
            _sharedInstance.temp = Double.valueOf(_sharedInstance.inTemp);
            _sharedInstance.maxTDS = Double.valueOf(_sharedInstance.inMaxTDS);
            _sharedInstance.minSulphite = Double.valueOf(_sharedInstance.inMinSulphite);
            _sharedInstance.minCausticAlk = Double.valueOf(_sharedInstance.inMinCausticAlk);
          } else {
            Log.d(TAG, "restore(), no data found");
          }

        } else {
          Log.e(TAG, "restore() Settings file not found!");
        }

      } else {
        Log.e(TAG, "restore() Context not defined. Preferences NOT fully restored");
      }
    } catch (Exception e) {
      Log.e(TAG, "restore() exception: " + e.toString());
    }
  } // restore()