Пример #1
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x1a:  #ACK
            (_dvg, _drg, _chksum) = unpack("<HHH", recv_data[5:])
            _dvg = eza2500_util.q_denormalize(_dvg, 14, '380', '260', '390',
                                              'dvg')
            _drg = eza2500_util.q_denormalize(_drg, 13, '1', '0', '3.999',
                                              'drg')
            res["dvg"] = _dvg
            res["drg"] = _drg
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x9a:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #2
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x16:  #ACK
            (_ccr, _ddr, _chksum) = unpack("<HHH", recv_data[5:])
            _ccr = eza2500_util.q_denormalize(_ccr, 14, '48', '0', '12', 'ccr')
            _ddr = eza2500_util.q_denormalize(_ddr, 14, '48', '0', '12', 'ddr')
            res["ccr"] = _ccr
            res["ddr"] = _ddr
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x96:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #3
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x0e:  #ACK
            (_tsq, _tpq, _v5q, _fn1q, _fn2q, _fn3q, _fn4q, _fn5q,
             _chksum) = unpack("<HHHHHHHHH", recv_data[5:])
            res["tsq"] = _tsq
            res["tpq"] = _tpq
            res["v5q"] = _v5q
            res["fn1q"] = _fn1q
            res["fn2q"] = _fn2q
            res["fn3q"] = _fn3q
            res["fn4q"] = _fn4q
            res["fn5q"] = _fn5q
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x8e:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #4
0
  def recv(self):
    essx_debug.log('recv')
    recv_data = self._recv()

    self.response_raw = recv_data
    res = {}
    (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
    if _cmd == 0x17: #ACK
      (_pdz ,_mdz ,_chksum) = unpack("<HHH", recv_data[5:])
      _pdz = eza2500_util.q_denormalize(_pdz, 14, '380', '0', '57', 'pdz')
      _mdz = eza2500_util.q_denormalize(_mdz, 14, '380', '0', '57', 'mdz')
      res["pdz"] = _pdz
      res["mdz"] = _mdz
      res["chksum"] = _chksum
      self.response = res
    elif _cmd == 0x97: #NAK
      (_ercd ,_chksum) = unpack("<HH", recv_data[5:])
      res["ercd"] = _ercd
      res["chksum"] = _chksum
      self.response = res
      raise ESSXDeviceException("error: ERCD=%x" % _ercd)
    else:
      raise ESSXValueException("bad response")

    self.response = res
    essx_debug.log('recv')
    #essx_debug.dump(recv_data)
    return recv_data
Пример #5
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x01:  #ACK
            (_cst, _ext, _chksum) = unpack("<HHH", recv_data[5:])
            res["cst"] = _cst
            res["ext"] = _ext
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x81:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #6
0
  def recv(self):
    essx_debug.log('recv')
    recv_data = self._recv()

    self.response_raw = recv_data
    res = {}
    (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
    if _cmd == 0x1d: #ACK
      (_bcf ,_cvb ,_dlb ,_cdb ,_ddb ,_chksum) = unpack("<HHHHHH", recv_data[5:])
      _cvb = eza2500_util.q_denormalize(_cvb, 14, '48', '32', '62', 'cvb')
      _dlb = eza2500_util.q_denormalize(_dlb, 14, '48', '32', '64', 'dlb')
      _cdb = eza2500_util.q_denormalize(_cdb, 14, '48', '0', '12', 'cdb')
      _ddb = eza2500_util.q_denormalize(_ddb, 14, '48', '0', '12', 'ddb')
      res["bcf"] = _bcf
      res["cvb"] = _cvb
      res["dlb"] = _dlb
      res["cdb"] = _cdb
      res["ddb"] = _ddb
      res["chksum"] = _chksum
      self.response = res
    elif _cmd == 0x9d: #NAK
      (_ercd ,_chksum) = unpack("<HH", recv_data[5:])
      res["ercd"] = _ercd
      res["chksum"] = _chksum
      self.response = res
      raise ESSXDeviceException("error: ERCD=%x" % _ercd)
    else:
      raise ESSXValueException("bad response")

    self.response = res
    essx_debug.log('recv')
    #essx_debug.dump(recv_data)
    return recv_data
Пример #7
0
  def recv(self):
    essx_debug.log('recv')
    recv_data = self._recv()

    self.response_raw = recv_data
    res = {}
    (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
    if _cmd == 0x0d: #ACK
      (_vgq ,_igq ,_vbq ,_ibq ,_wgq ,_wbq ,_icq ,_tmpq ,_chksum) = unpack("<HHHHHHHHH", recv_data[5:])
      res["vgq"] = _vgq
      res["igq"] = _igq
      res["vbq"] = _vbq
      res["ibq"] = _ibq
      res["wgq"] = _wgq
      res["wbq"] = _wbq
      res["icq"] = _icq
      res["tmpq"] = _tmpq
      res["chksum"] = _chksum
      self.response = res
    elif _cmd == 0x8d: #NAK
      (_ercd ,_chksum) = unpack("<HH", recv_data[5:])
      res["ercd"] = _ercd
      res["chksum"] = _chksum
      self.response = res
      raise ESSXDeviceException("error: ERCD=%x" % _ercd)
    else:
      raise ESSXValueException("bad response")

    self.response = res
    essx_debug.log('recv')
    #essx_debug.dump(recv_data)
    return recv_data
Пример #8
0
 def remote_status(self):
     """ statusを取得するコマンドを発行する """
     if self._status_ts > time.time() - T:
         return
     rr = self.dev.read_input_registers(self.modbus_adr_status,
                                        1,
                                        unit=self.unit)
     if isinstance(rr, pymodbus.exceptions.ModbusIOException):
         raise ESSXDeviceException("modbus io exception")
     self._status = rr.getRegister(0)
     self._status_ts = time.time()
Пример #9
0
 def remote_rsoc_and_status(self):
     """ rsocと statusのアドレスが隣りあってるときは一回で取得する """
     if self._rsoc_ts > time.time() - T and self._status_ts > time.time(
     ) - T:
         return
     rr = self.dev.read_input_registers(self.modbus_adr_rsoc,
                                        2,
                                        unit=self.unit)
     if isinstance(rr, pymodbus.exceptions.ModbusIOException):
         raise ESSXDeviceException("modbus io exception")
     self._rsoc = rr.getRegister(0)
     self._status = rr.getRegister(1)
     self._rsoc_ts = time.time()
     self._status_ts = time.time()
Пример #10
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x09:  #ACK
            (_vg, _ig, _vb, _ib, _wg, _wb, _ic, _tmp,
             _chksum) = unpack("<hhhhhhhhH", recv_data[5:])
            _vg = eza2500_util.q_denormalize(_vg, 14, '380', 'None', 'None',
                                             'vg')
            _ig = eza2500_util.q_denormalize(_ig, 13, '7.8125', 'None', 'None',
                                             'ig')
            _vb = eza2500_util.q_denormalize(_vb, 14, '48', 'None', 'None',
                                             'vb')
            _ib = eza2500_util.q_denormalize(_ib, 13, '52.08', 'None', 'None',
                                             'ib')
            _wg = eza2500_util.q_denormalize(_wg, 11, '2500', 'None', 'None',
                                             'wg')
            _wb = eza2500_util.q_denormalize(_wb, 11, '2500', 'None', 'None',
                                             'wb')
            _tmp = eza2500_util.q_denormalize(_tmp, 7, '1', 'None', 'None',
                                              'tmp')
            res["vg"] = _vg
            res["ig"] = _ig
            res["vb"] = _vb
            res["ib"] = _ib
            res["wg"] = _wg
            res["wb"] = _wb
            res["ic"] = _ic
            res["tmp"] = _tmp
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x89:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #11
0
    def recv(self):
        essx_debug.log('recv')
        recv_data = self._recv()

        self.response_raw = recv_data
        res = {}
        (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
        if _cmd == 0x1c:  #ACK
            (_cib, _dig, _ubv, _ugv, _obv, _ogv,
             _chksum) = unpack("<HHHHHHH", recv_data[5:])
            _cib = eza2500_util.q_denormalize(_cib, 13, '52.08', '0', '56.77',
                                              'cib')
            _dig = eza2500_util.q_denormalize(_dig, 13, '7.8125', '0',
                                              '8.5162', 'dig')
            _ubv = eza2500_util.q_denormalize(_ubv, 14, '48', '32', '68',
                                              'ubv')
            _ugv = eza2500_util.q_denormalize(_ugv, 14, '380', '260', '425',
                                              'ugv')
            _obv = eza2500_util.q_denormalize(_obv, 14, '48', '32', '68',
                                              'obv')
            _ogv = eza2500_util.q_denormalize(_ogv, 14, '380', '260', '425',
                                              'ogv')
            res["cib"] = _cib
            res["dig"] = _dig
            res["ubv"] = _ubv
            res["ugv"] = _ugv
            res["obv"] = _obv
            res["ogv"] = _ogv
            res["chksum"] = _chksum
            self.response = res
        elif _cmd == 0x9c:  #NAK
            (_ercd, _chksum) = unpack("<HH", recv_data[5:])
            res["ercd"] = _ercd
            res["chksum"] = _chksum
            self.response = res
            raise ESSXDeviceException("error: ERCD=%x" % _ercd)
        else:
            raise ESSXValueException("bad response")

        self.response = res
        essx_debug.log('recv')
        #essx_debug.dump(recv_data)
        return recv_data
Пример #12
0
  def recv(self):
    essx_debug.log('recv')
    recv_data = self._recv()

    self.response_raw = recv_data
    res = {}
    (_sfd, _len, _ad1, _ad2, _cmd) = unpack("BBBBB", recv_data[0:5])
    if _cmd == 0x0a: #ACK
      (_ts ,_tp ,_v5s ,_fan1 ,_fan2 ,_fan3 ,_fan4 ,_fan5 ,_chksum) = unpack("<hhhhhhhhH", recv_data[5:])
      _v5s = eza2500_util.q_denormalize(_v5s, 10, '1', 'None', 'None', 'v5s')
      _fan1 = eza2500_util.q_denormalize(_fan1, 0, '1', 'None', 'None', 'fan1')
      _fan2 = eza2500_util.q_denormalize(_fan2, 0, '1', 'None', 'None', 'fan2')
      _fan3 = eza2500_util.q_denormalize(_fan3, 0, '1', 'None', 'None', 'fan3')
      _fan4 = eza2500_util.q_denormalize(_fan4, 0, '1', 'None', 'None', 'fan4')
      _fan5 = eza2500_util.q_denormalize(_fan5, 0, '1', 'None', 'None', 'fan5')
      res["ts"] = _ts
      res["tp"] = _tp
      res["v5s"] = _v5s
      res["fan1"] = _fan1
      res["fan2"] = _fan2
      res["fan3"] = _fan3
      res["fan4"] = _fan4
      res["fan5"] = _fan5
      res["chksum"] = _chksum
      self.response = res
    elif _cmd == 0x8a: #NAK
      (_ercd ,_chksum) = unpack("<HH", recv_data[5:])
      res["ercd"] = _ercd
      res["chksum"] = _chksum
      self.response = res
      raise ESSXDeviceException("error: ERCD=%x" % _ercd)
    else:
      raise ESSXValueException("bad response")

    self.response = res
    essx_debug.log('recv')
    #essx_debug.dump(recv_data)
    return recv_data
Пример #13
0
    def log_data(self, params):
        _dcdc_conf = self.dcdc_config['config']
        _bat_conf = self.bat_config['config']

        (rsoc, bos, comm_err) = self._check_battery()

        if comm_err == -1:
            raise ESSXDeviceException('comm error')


#        if bos == 0:
#            if 'force_dcdc_waiting' in self.bat_config['config'] and self.bat_config['config']['force_dcdc_waiting'] == True:
#                self.run(self.com0104, {
#                        'mode': self.checkOperationMode_2500(0)
#                })

        return {
            "system_time": {
                "year": 0,
                "month": 0,
                "day": 0,
                "hour": 0,
                "minute": 0
            },
            "rsoc":
            float(rsoc),
            "dischargeable_time": {
                "hour": 0,
                "minute": 0
            },
            "battery_voltage":
            _bat_conf['battery_voltage'],
            "battery_current":
            _bat_conf['battery_current'],
            "battery_rsoc":
            float(rsoc),
            "battery_status":
            0,
            "battery_warning":
            0,
            #"battery_alarm": 0
            "battery_operation_status":
            bos,
            "battery_comm_err":
            comm_err,
            "charge_discharge_power":
            _bat_conf['battery_voltage'] * _bat_conf['battery_current'],
            "ups_operation_schedule":
            0,
            "ups_operation_mode": {
                "mode": 0,
                "parameter": 0,
                "stop_mode": 0
            },
            #"ups_input_voltage": res["ac_input_voltage"],
            #"ups_output_voltage": res["ac_output_voltage"],
            #"ups_output_current": res["ac_output_current_r"] + res["ac_output_current_s"],
            #"ups_output_frequency": res["ac_output_frequency"],
            #"ups_output_power": res["ac_output_power"],
            #"pvc_charge_voltage": res["pvc_charge_voltage"],
            #"pvc_charge_current": res["pvc_charge_current"],
            #"pvc_charge_power": res["pvc_charge_power"],
            #"pvc_alarm": res["pvc_alarm"],
            #"ups_alarm": res["inverter_alarm"]
        }