The measured voltage that the battery is supplying (in microvolts)
778388
def measured_voltage(self):
        
        self._measured_voltage, value = self.get_attr_int(self._measured_voltage, 'voltage_now')
        return value
609624
def get_time_remaining_estimate(self):
        
        all_energy_now = []
        all_energy_not_discharging = []
        all_power_now = []
        for supply in os.listdir(POWER_SUPPLY_PATH):
            supply_path = os.path.join(POWER_SUPPLY_PATH, supply)
            try:
                type = self.power_source_type(supply_path)
                if type == common.POWER_TYPE_AC:
                    if self.is_ac_online(supply_path):
                        return common.TIME_REMAINING_UNLIMITED
                elif type == common.POWER_TYPE_BATTERY:
                    if self.is_battery_present(supply_path) and self.is_battery_discharging(supply_path):
                        energy_full, energy_now, power_now = self.get_battery_state(supply_path)
                        all_energy_now.append(energy_now)
                        all_power_now.append(power_now)
                    elif self.is_battery_present(supply_path) and not self.is_battery_discharging(supply_path):
                        energy_now = self.get_battery_state(supply_path)[1]
                        all_energy_not_discharging.append(energy_now)
                else:
                    warnings.warn("UPS is not supported.")
            except (RuntimeError, IOError) as e:
                warnings.warn("Unable to read properties of {0}: {1}".format(supply_path, e), category=RuntimeWarning)

        if len(all_energy_now) > 0:
            try:
                return sum([energy_now / power_now * 60.0 for energy_now, power_now in zip(all_energy_now, all_power_now)])\
                    + sum(all_energy_not_discharging) / (sum(all_power_now) / len(all_power_now)) * 60.0
            except ZeroDivisionError as e:
                warnings.warn("Unable to calculate time remaining estimate: {0}".format(e), category=RuntimeWarning)
                return common.TIME_REMAINING_UNKNOWN
        else:
            return common.TIME_REMAINING_UNKNOWN
705308
def check_power(self):
    """"""
    state = self.check_power_raw()
    data = {}
    data['s1'] = bool(state & 0x01)
    data['s2'] = bool(state & 0x02)
    data['s3'] = bool(state & 0x04)
    data['s4'] = bool(state & 0x08)
    return data
137965
function process(payload) {
  var batteryRaw = parseInt(payload.substr(2,2),16) % 64;
  var temperatureRaw = (parseInt(payload.substr(0,3),16) >> 2) % 256;
  var battery = ((batteryRaw / 34) + 1.8).toFixed(2) + "V";
  var temperature = ((temperatureRaw - 80) / 2).toFixed(1) + "C";
  return {
    battery: battery,
    temperature: temperature
  };
}
360440
def battery(self):
        
        if self._voltage is None or self._current is None or self._level is None:
            return None
        return Battery(self._voltage, self._current, self._level)
393658
def c_mvar(self):
        
        if self.b == -4:
            return 1.0
        elif self.b == -3:
            return 0.0
        elif self.b == -2:
            return -1.0
        elif self.b == -1:
            return -2.0
        elif self.b == 0:
            return -3.0
16210
private function _voltage()
    {
        foreach ($this->_lines as $line) {
            if (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+volts_dc,\s+([0-9\.]+)\s+V.*$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+([0-9\.]+)\s+V\sDC$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC\s+\((.*)\)$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[3]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            }
        }
    }
1237350
private function _current()
    {
        foreach ($this->_buf as $sensor) {
            if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Current'))
                ||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Current')))
               && isset($sensor['Unit']) && ($sensor['Unit'] == 'Amps')
               && isset($sensor['Value'])) {
                $dev = new SensorDevice();
                $dev->setName($sensor['Sensor']);
                $dev->setValue($sensor['Value']);
                if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
                    $dev->setMax($max);
                }
                if (isset($sensor['Lower Critical']) && (($min = $sensor['Lower Critical']) != "na")) {
                    $dev->setMin($min);
                }
                if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
                    $dev->setEvent($status);
                }
                $this->mbinfo->setMbCurrent($dev);
            }
        }
    }
556290
def as_dict_summary(self, print_subelectrodes=True):
        
        chg_comp = self.fully_charged_entry.composition
        dischg_comp = self.fully_discharged_entry.composition

        ion = self.working_ion
        d = {"average_voltage": self.get_average_voltage(),
             "max_voltage": self.max_voltage,
             "min_voltage": self.min_voltage,
             "max_delta_volume": self.max_delta_volume,
             "max_voltage_step": self.max_voltage_step,
             "capacity_grav": self.get_capacity_grav(),
             "capacity_vol": self.get_capacity_vol(),
             "energy_grav": self.get_specific_energy(),
             "energy_vol": self.get_energy_density(),
             "working_ion": self._working_ion.symbol,
             "nsteps": self.num_steps,
             "framework": self._vpairs[0].framework.to_data_dict,
             "formula_charge": chg_comp.reduced_formula,
             "id_charge": self.fully_charged_entry.entry_id,
             "formula_discharge": dischg_comp.reduced_formula,
             "id_discharge": self.fully_discharged_entry.entry_id,
             "fracA_charge": chg_comp.get_atomic_fraction(ion),
             "fracA_discharge": dischg_comp.get_atomic_fraction(ion),
             "max_instability": self.get_max_instability(),
             "min_instability": self.get_min_instability(),
             "material_ids" : [itr_ent.entry_id for itr_ent in self._entries],
             "stable_material_ids" : [itr_ent.entry_id for itr_ent in self.get_stable_entries()],
             "unstable_material_ids": [itr_ent.entry_id for itr_ent in self.get_unstable_entries()],
             }

        if all(['decomposition_energy' in itr_ent.data for itr_ent in self._entries]):
            d.update({"stability_charge": self.fully_charged_entry.data['decomposition_energy'],
                 "stability_discharge": self.fully_discharged_entry.data['decomposition_energy'],
                 "stability_data":{itr_ent.entry_id: itr_ent.data['decomposition_energy'] for itr_ent in self._entries},
                 })

        if all(['muO2' in itr_ent.data for itr_ent in self._entries]):
            d.update({"muO2_data" : {itr_ent.entry_id: itr_ent.data['muO2'] for itr_ent in self._entries}})

        if print_subelectrodes:
            f_dict = lambda c: c.as_dict_summary(print_subelectrodes=False)
            d["adj_pairs"] = list(map(f_dict,
                                 self.get_sub_electrodes(adjacent_only=True)))
            d["all_pairs"] = list(map(f_dict,
                                 self.get_sub_electrodes(adjacent_only=False)))
        return d
138321
def mavlink_packet(self, m):
        ''''''
        mtype = m.get_type()
        if mtype == "SYS_STATUS":
            self.battery_update(m)
        if mtype == "BATTERY2":
            self.battery2_voltage = m.voltage * 0.001
        if mtype == "POWER_STATUS":
            self.power_status_update(m)
        if self.battery_period.trigger():
            self.battery_report()
709001
def voltage(self):
        """"""
        raw = self.value
        volts = raw * (_ADS1X15_PGA_RANGE[self._ads.gain] / (2**(self._ads.bits-1) - 1))
        return volts
709323
def poll_values():
    """"""
    subscription = processor.create_parameter_subscription([
        '/YSS/SIMULATOR/BatteryVoltage1'
    ])

    sleep(5)
    print('Latest value:')
    print(subscription.get_value('/YSS/SIMULATOR/BatteryVoltage1'))

    sleep(5)
    print('Latest value:')
    print(subscription.get_value('/YSS/SIMULATOR/BatteryVoltage1'))
986069
def check_battery(self):
        
        self.charging = False if \
            subprocess.getoutput("cat /sys/class/power_supply/BAT0/status") == 'Discharging' \
            else True
        percent = subprocess.getoutput("cat /sys/class/power_supply/BAT0/capacity")
        if not self.charging:
            for val in self.dischlist:
                if int(percent) <= int(val):
                    self.indicator.set_icon(self.dischformat.format(value=val))
                    break
        else:
            for val in self.chlist:
                if int(percent) <= int(val):
                    self.indicator.set_icon(self.chformat.format(value=val))
                    break
        return True
320734
function getRes(unit) {
      var measured,
          begin,
          count = 30,
          divisor = 1e3,
          ns = timer.ns,
          sample = [];

      // get average smallest measurable time
      while (count--) {
        if (unit == 'us') {
          divisor = 1e6;
          if (ns.stop) {
            ns.start();
            while (!(measured = ns.microseconds())) { }
          } else if (perfName) {
            divisor = 1e3;
            measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns);
          } else {
            begin = ns();
            while (!(measured = ns() - begin)) { }
          }
        }
        else if (unit == 'ns') {
          divisor = 1e9;
          begin = ns.nanoTime();
          while (!(measured = ns.nanoTime() - begin)) { }
        }
        else {
          begin = new ns;
          while (!(measured = new ns - begin)) { }
        }
        // check for broken timers (nanoTime may have issues)
        // http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/
        if (measured > 0) {
          sample.push(measured);
        } else {
          sample.push(Infinity);
          break;
        }
      }
      // convert to seconds
      return getMean(sample) / divisor;
    }
405821
private function _voltage()
    {
        foreach ($this->_lines as $line) {
            if (preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) {
                if ($data[2] <> '+0.00') {
                    $dev = new SensorDevice();
                    $dev->setName($data[1]);
                    $dev->setValue($data[2]);
                    $this->mbinfo->setMbVolt($dev);
                }
            }
        }
    }
431974
def get_time_remaining_estimate(self):
        
        all_energy_now = []
        all_power_now = []
        try:
            type = self.power_source_type()
            if type == common.POWER_TYPE_AC:
                if self.is_ac_online(supply_path):
                    return common.TIME_REMAINING_UNLIMITED
            elif type == common.POWER_TYPE_BATTERY:
                if self.is_battery_present() and self.is_battery_discharging():
                    energy_full, energy_now, power_now = self.get_battery_state()
                    all_energy_now.append(energy_now)
                    all_power_now.append(power_now)
            else:
                warnings.warn("UPS is not supported.")
        except (RuntimeError, IOError) as e:
            warnings.warn("Unable to read system power information!", category=RuntimeWarning)

        if len(all_energy_now) > 0:
            try:
                return sum([energy_now / power_now * 60.0 for energy_now, power_now in zip(all_energy_now, all_power_now)])
            except ZeroDivisionError as e:
                warnings.warn("Unable to calculate time remaining estimate: {0}".format(e), category=RuntimeWarning)
                return common.TIME_REMAINING_UNKNOWN
        else:
            return common.TIME_REMAINING_UNKNOWN
219888
def battery2_send(self, voltage, current_battery, force_mavlink1=False):
                '''
                

                '''
                return self.send(self.battery2_encode(voltage, current_battery), force_mavlink1=force_mavlink1)