Exemplo n.º 1
0
def main(argv: List[str]):
    start_time = time.time()
    rct = rct_lib.RCT(argv)

    if rct.connect_to_server() == True:
        try:
            MyTab = []
            for obj in rct.id_tab:
                if rct.search_id > 0 and obj.id != rct.search_id:
                    continue

                if rct.search_name is not None and fnmatch.fnmatch(
                        obj.name, rct.search_name) is False:
                    continue

                rct.add_by_id(MyTab, obj.id)

            response = rct.read(MyTab)
            rct.close()

            # debug output of processing time and all response elements
            rct.dbglog(response.format_list(time.time() - start_time))
        except:
            print("-" * 100)
            traceback.print_exc(file=sys.stdout)
            rct.close()

    rct = None
Exemplo n.º 2
0
def main(argv: List[str]):
    start_time = time.time()
    rct = rct_lib.RCT(argv)

    if rct.connect_to_server() == True:
        try:
            MyTab = []
            socx    = rct.add_by_name(MyTab, 'battery.soc')
            watt1   = rct.add_by_name(MyTab, 'g_sync.p_acc_lp')
            watt2   = rct.add_by_name(MyTab, 'battery.stored_energy')
            watt3   = rct.add_by_name(MyTab, 'battery.used_energy')
            stat1   = rct.add_by_name(MyTab, 'battery.bat_status')
            stat2   = rct.add_by_name(MyTab, 'battery.status')
            stat3   = rct.add_by_name(MyTab, 'battery.status2')
            socsoll = rct.add_by_name(MyTab, 'battery.soc_target')

            # read all parameters
            response = rct.read(MyTab)
            rct.close()

            # postprocess values
            socx    = socx.value
            watt1   = int(watt1.value) * -1.0
            watt2   = int(watt2.value)
            watt3   = int(watt3.value)
            stat1   = int(stat1.value)
            stat2   = int(stat2.value)
            stat3   = int(stat3.value)
            socsoll = int(socsoll.value * 100.0)


            soc = int(socx * 100.0)
            rct.write_ramdisk('speichersoc', soc, '0x959930BF battery.soc')
            rct.write_ramdisk('speicherleistung', watt1, '0x400F015B g_sync.p_acc_lp')
            rct.write_ramdisk('speicherikwh', watt2, '0x5570401B battery.stored_energy')
            rct.write_ramdisk('speicherekwh', watt3, '#0xA9033880 battery.used_energy')

            if (stat1 + stat2 + stat3) > 0:
                faultStr = "Battery ALARM Battery-Status nicht 0"
                faultState = 2
                # speicher in mqtt
            else:
                faultStr = ''
                faultState = 0

            os.system('mosquitto_pub -r -t openWB/set/housebattery/faultState -m "' + str(faultState) + '"')
            os.system('mosquitto_pub -r -t openWB/set/housebattery/faultStr -m "' + str(faultStr) + '"')
            os.system('mosquitto_pub -r -t openWB/housebattery/soctarget -m "' + str(socsoll) + '"')

            # debug output of processing time and all response elements
            rct.dbglog(response.format_list(time.time() - start_time))
        except:
            print("-"*100)
            traceback.print_exc(file=sys.stdout)
            rct.close()

    rct = None
Exemplo n.º 3
0
def main(argv: List[str]):
    start_time = time.time()
    rct = rct_lib.RCT(argv)

    if rct.connect_to_server() == True:
        try:
            # generate id list for fast bulk read
            MyTab = []
            totalfeed = rct.add_by_name(MyTab, 'energy.e_grid_feed_total')
            totalload = rct.add_by_name(MyTab, 'energy.e_grid_load_total')
            p_ac_sc_sum = rct.add_by_name(MyTab, 'g_sync.p_ac_sc_sum')
            volt1 = rct.add_by_name(MyTab, 'g_sync.u_l_rms[0]')
            volt2 = rct.add_by_name(MyTab, 'g_sync.u_l_rms[1]')
            volt3 = rct.add_by_name(MyTab, 'g_sync.u_l_rms[2]')
            watt1 = rct.add_by_name(MyTab, 'g_sync.p_ac_sc[0]')
            watt2 = rct.add_by_name(MyTab, 'g_sync.p_ac_sc[1]')
            watt3 = rct.add_by_name(MyTab, 'g_sync.p_ac_sc[2]')
            freq = rct.add_by_name(MyTab, 'grid_pll[0].f')
            stat1 = rct.add_by_name(MyTab, 'fault[0].flt')
            stat2 = rct.add_by_name(MyTab, 'fault[1].flt')
            stat3 = rct.add_by_name(MyTab, 'fault[2].flt')
            stat4 = rct.add_by_name(MyTab, 'fault[3].flt')

            # read all parameters
            response = rct.read(MyTab)
            rct.close()

            # postprocess values
            totalfeed = int(totalfeed.value * -1.0)
            totalload = int(totalload.value)
            p_ac_sc_sum = p_ac_sc_sum.value
            volt1 = int(volt1.value * 10) / 10.0
            volt2 = int(volt2.value * 10) / 10.0
            volt3 = int(volt3.value * 10) / 10.0
            watt1 = int(watt1.value)
            watt2 = int(watt2.value)
            watt3 = int(watt3.value)
            freq = int(freq.value * 100) / 100.0
            stat1 = int(stat1.value)
            stat2 = int(stat2.value)
            stat3 = int(stat3.value)
            stat4 = int(stat4.value)

            #
            # Adjust and write values to ramdisk
            rct.write_ramdisk('einspeisungkwh', totalfeed,
                              '0x44D4C533 energy.e_grid_feed_total')
            rct.write_ramdisk('bezugkwh', totalload,
                              '#0x62FBE7DC energy.e_grid_load_total')
            rct.write_ramdisk('wattbezug',
                              int(p_ac_sc_sum) * 1,
                              '#0x6002891F g_sync.p_ac_sc_sum')
            rct.write_ramdisk('evuv1', volt1, '0xCF053085 g_sync.u_l_rms[0] ')
            rct.write_ramdisk('evuv2', volt2, '0x54B4684E g_sync.u_l_rms[1] ')
            rct.write_ramdisk('evuv3', volt3, '0x2545E22D g_sync.u_l_rms[2] ')

            rct.write_ramdisk('bezugw1', watt1,
                              '0x27BE51D9 als Watt g_sync.p_ac_sc[0]')
            ampere = int(watt1 / volt1 * 10.0) / 10.0
            rct.write_ramdisk('bezuga1', ampere,
                              '0x27BE51D9 als Ampere g_sync.p_ac_sc[0]')

            rct.write_ramdisk('bezugw2', watt2,
                              '0xF5584F90 als Watt g_sync.p_ac_sc[1]')
            ampere = int(watt2 / volt2 * 10.0) / 10.0
            rct.write_ramdisk('bezuga2', ampere,
                              '0xF5584F90 als Ampere g_sync.p_ac_sc[1]')

            rct.write_ramdisk('bezugw3', watt3,
                              '0xB221BCFA als Watt g_sync.p_ac_sc[2]')
            ampere = int(watt3 / volt3 * 10.0) / 10.0
            rct.write_ramdisk('bezuga3', ampere,
                              '0xF5584F90 als Ampere g_sync.p_ac_sc[2]')

            rct.write_ramdisk('evuhz', freq, '0x1C4A665F grid_pll[0].f')
            rct.write_ramdisk('llhz', freq, '0x1C4A665F grid_pll[0].f')

            if (stat1 + stat2 + stat3 + stat4) > 0:
                faultStr = "ALARM EVU Status nicht 0"
                faultState = 2
                # speicher in mqtt
            else:
                faultStr = ''
                faultState = 0

            os.system('mosquitto_pub -r -t openWB/set/evu/faultState -m "' +
                      str(faultState) + '"')
            os.system('mosquitto_pub -r -t openWB/set/evu/faultStr -m "' +
                      str(faultStr) + '"')

            # debug output of processing time and all response elements
            rct.dbglog(response.format_list(time.time() - start_time))
        except:
            print("-" * 100)
            traceback.print_exc(file=sys.stdout)
            rct.close()

    rct = None
Exemplo n.º 4
0
def main(argv: List[str]):
    start_time = time.time()
    rct = rct_lib.RCT(argv)

    if rct.connect_to_server() == True:
        try:
            # generate id list for fast bulk read
            MyTab = []
            HWVersion = rct.add_by_name(MyTab, 'battery.bms_power_version')
            SWVersion = rct.add_by_name(MyTab, "battery.bms_software_version")
            Ser       = rct.add_by_name(MyTab, "battery.bms_sn")
            Status    = rct.add_by_name(MyTab, "battery.bat_status") 
            cap       = rct.add_by_name(MyTab, "battery.ah_capacity") 
            cycl      = rct.add_by_name(MyTab, "battery.cycles")
            Eff       = rct.add_by_name(MyTab, "battery.efficiency")
            Soh       = rct.add_by_name(MyTab, "battery.soh")
            SoC       = rct.add_by_name(MyTab, "battery.soc") 
            temp      = rct.add_by_name(MyTab, "battery.max_cell_temperature") 
            ms1       = rct.add_by_name(MyTab, "battery.module_sn[0]")
            ms2       = rct.add_by_name(MyTab, "battery.module_sn[1]") 
            ms3       = rct.add_by_name(MyTab, "battery.module_sn[2]")
            ms4       = rct.add_by_name(MyTab, "battery.module_sn[3]") 
            ms5       = rct.add_by_name(MyTab, "battery.module_sn[4]") 
            ms6       = rct.add_by_name(MyTab, "battery.module_sn[5]") 
            ms7       = rct.add_by_name(MyTab, "battery.module_sn[6]") 
            Stat1     = rct.add_by_name(MyTab, "battery.status")
            Stat2     = rct.add_by_name(MyTab, "battery.status2") 
            Stor      = rct.add_by_name(MyTab, "battery.stored_energy") 
            Used      = rct.add_by_name(MyTab, "battery.used_energy")
            rct.add_by_name(MyTab, "battery.temperature")
            rct.add_by_name(MyTab, "battery.voltage")
            rct.add_by_name(MyTab, "battery.prog_sn")
            rct.add_by_name(MyTab, "battery.soc_target")
            rct.add_by_name(MyTab, "battery.soc_target_high")
            rct.add_by_name(MyTab, "battery.soc_target_low")
            rct.add_by_name(MyTab, "battery.soc_update_since")
            rct.add_by_name(MyTab, "battery.stack_cycles[0]")
            rct.add_by_name(MyTab, "battery.stack_cycles[1]")
            rct.add_by_name(MyTab, "battery.stack_cycles[2]")
            rct.add_by_name(MyTab, "battery.stack_cycles[3]")
            rct.add_by_name(MyTab, "battery.stack_cycles[4]")
            rct.add_by_name(MyTab, "battery.stack_cycles[5]")
            rct.add_by_name(MyTab, "battery.stack_cycles[6]")
            rct.add_by_name(MyTab, "battery.stack_software_version[0]")
            rct.add_by_name(MyTab, "battery.stack_software_version[1]")
            rct.add_by_name(MyTab, "battery.stack_software_version[2]")
            rct.add_by_name(MyTab, "battery.stack_software_version[3]")
            rct.add_by_name(MyTab, "battery.stack_software_version[4]")
            rct.add_by_name(MyTab, "battery.stack_software_version[5]")
            rct.add_by_name(MyTab, "battery.stack_software_version[6]")

            # read parameters
            response = rct.read(MyTab)
            rct.close()
            
            print( "Battery Controller   : " + str(rct.host) )
            print( "Hardware Version     : " + str(HWVersion.value))
            print( "Software Version     : " + str(SWVersion.value) )
            print( "Serial Nr            : " + str(Ser.value) )
            print( "Status               : "  + str(Status.value) )
            print( "Max.Lade/Enladetrom A: "  + str(cap.value) + ' A' )
            print( "Durchlaufene Zyklen  : "  + str(cycl.value) )
            Eff =  (Eff.value * 10000) / 100.0
            print( "Efficency            : "  + str(Eff) + ' %' )
            print( "SoH                  : "  + str(Soh.value) )
            SoC =  int(SoC.value *10000) / 100
            print( "SoC                  : "  + str(SoC) + ' %' )
            temp =  int(temp.value * 100) / 100.0
            print( "Max Cell Temp.       : "  + str(temp) + ' Grad' )

            if  str(ms1.value)>"  ":
                print( "Batt.Pack 1 SN       : "  + str(ms1.value) )
            if  str(ms2.value)>"  ":
                print( "Batt.Pack 2 SN       : "  + str(ms2.value) )
            if  str(ms3.value)>"  ":
                print( "Batt.Pack 3 SN       : "  + str(ms3.value) )
            if  str(ms4.value)>"  ":
                print( "Batt.Pack 4 SN       : "  + str(ms4.value) )
            if  str(ms5.value)>"  ":
                print( "Batt.Pack 5 SN       : "  + str(ms5.value) )
            if  str(ms6.value)>"  ":
                print( "Batt.Pack 6 SN       : "  + str(ms6.value) )

            print( "Batt Status 1        : "  + str(Stat1.value) )
            print( "Batt Status 2        : "  + str(Stat2.value) )
            Stor=  (int(Stor.value) / 1000.0)
            print(  "Gespeicherte Energy  : "  + str(Stor) + ' Kwh' )
            Used=  (int(Used.value) / 1000.0)
            print(  "Entnommene Energy    : "  + str(Used) + ' Kwh' )

            # debug output of processing time and all response elements
            rct.dbglog(response.format_list(time.time() - start_time))
        except:
            print("-"*100)
            traceback.print_exc(file=sys.stdout)
            rct.close()

    rct = None
Exemplo n.º 5
0
def main(argv: List[str]):
    start_time = time.time()
    rct = rct_lib.RCT(argv)

    if rct.connect_to_server() == True:
        try:
            MyTab = []
            pv1watt = rct.add_by_name(MyTab, 'dc_conv.dc_conv_struct[0].p_dc')
            pv2watt = rct.add_by_name(MyTab, 'dc_conv.dc_conv_struct[1].p_dc')
            pv3watt = rct.add_by_name(MyTab, 'io_board.s0_external_power')
            pLimit = rct.add_by_name(
                MyTab, 'p_rec_lim[2]')  # max. AC power according to RCT Power
            dA = rct.add_by_name(MyTab, 'energy.e_dc_day[0]')
            dB = rct.add_by_name(MyTab, 'energy.e_dc_day[1]')
            dE = rct.add_by_name(MyTab, 'energy.e_ext_day')
            mA = rct.add_by_name(MyTab, 'energy.e_dc_month[0]')
            mB = rct.add_by_name(MyTab, 'energy.e_dc_month[1]')
            mE = rct.add_by_name(MyTab, 'energy.e_ext_month')
            yA = rct.add_by_name(MyTab, 'energy.e_dc_year[0]')
            yB = rct.add_by_name(MyTab, 'energy.e_dc_year[1]')
            yE = rct.add_by_name(MyTab, 'energy.e_ext_year')
            pv1total = rct.add_by_name(MyTab, 'energy.e_dc_total[0]')
            pv2total = rct.add_by_name(MyTab, 'energy.e_dc_total[1]')
            pv3total = rct.add_by_name(MyTab, 'energy.e_ext_total')

            # read all parameters
            response = rct.read(MyTab)
            rct.close()

            # actual DC power
            rct.write_ramdisk('pv1wattString1', pv1watt.value, 'pv1watt')
            rct.write_ramdisk('pv1wattString2', pv2watt.value, 'pv2watt')
            pvwatt = pv1watt.value + pv2watt.value + pv3watt.value
            rct.write_ramdisk(
                'pvwatt',
                int(pvwatt) * -1,
                'negative Summe von pv1watt + pv2watt + pv3watt')

            # max. possible AC power (might be used by the control loop to limit PV charging power)
            rct.write_ramdisk(
                'maxACkW', int(pLimit.value),
                'Maximale zur Ladung verwendete AC-Leistung des Wechselrichters'
            )

            # daily
            daily_pvkwhk = (dA.value + dB.value + dE.value) / 1000.0  # -> KW
            rct.write_ramdisk('daily_pvkwhk', daily_pvkwhk, 'daily_pvkwhk')

            # monthly
            monthly_pvkwhk = (mA.value + mB.value + mE.value) / 1000.0  # -> KW
            rct.write_ramdisk('monthly_pvkwhk', monthly_pvkwhk,
                              'monthly_pvkwhk')

            # yearly
            yearly_pvkwhk = (yA.value + yB.value + yE.value) / 1000.0  # -> KW
            rct.write_ramdisk('yearly_pvkwhk', yearly_pvkwhk, 'yearly_pvkwhk')

            # total
            pvkwh = (pv1total.value + pv2total.value + pv3total.value)
            rct.write_ramdisk('pvkwh', pvkwh,
                              'Summe von pv1total pv1total pv1total')

            # debug output of processing time and all response elements
            rct.dbglog(response.format_list(time.time() - start_time))
        except:
            print("-" * 100)
            traceback.print_exc(file=sys.stdout)
            rct.close()

    rct = None