Пример #1
0
def get_charger_data(registers):
    client = EPsolarTracerClient(serialclient=None)
    client.connect()
    output = dict()
    for key in registers.iterkeys():
        value = client.read_input(key)
        output[key] = {'name': value.register.name, 'description': value.register.description, 'value': value.value}
    client.close()
    return output
Пример #2
0
    import datetime
    now = datetime.datetime.now()

    print now.year, now.month, now.day, now.hour, now.minute, now.second

    yearAndMonth = int(((now.year - 2000) << 8) | now.month)
    dayAndHour = int(((now.day) << 8) | now.hour)
    minuteAndSecond = int(((now.minute) << 8) | now.second)

    #register = registerByName("Real time clock 1")
    #print vars(register)

    addr = 0x9013
    vals = [minuteAndSecond, dayAndHour, yearAndMonth]

    response = client.read_input("Real time clock 1")
    print "Seconds: " + str(int(response) & 0xFF)
    print "Minutes: " + str(int(response) >> 8)

    response = client.read_input("Real time clock 2")
    print "Hours: " + str(int(response) & 0xFF)
    print "Day: " + str(int(response) >> 8)

    response = client.read_input("Real time clock 3")
    print "Month: " + str(int(response) & 0xFF)
    print "Year: " + str(int(response) >> 8)

    #response = client.client.write_registers(addr, vals, unit = client.unit)
    #print "Write result: " + str(vars(response))
    client.close()
Пример #3
0
                        help="Battery type(1=Sealed,2=Gel,3=Flooded)",
                        type=int,
                        dest="battery_type",
                        default=None)
    parser.add_argument("-c",
                        "--battery-capacity",
                        help="Battery capacity in Ah",
                        type=int,
                        dest="battery_capacity",
                        default=None)
    args = parser.parse_args()

    client = EPsolarTracerClient(port="/dev/ttyXRUSB0")

    if args.battery_type is None:
        print "Battery type: %s" % (
            battery_types[client.read_input(REG_BATTERY_TYPE).value])
    else:
        if args.battery_type in (1, 2, 3):
            client.write_output(REG_BATTERY_TYPE, args.battery_type)
            print "Battery type set to %s" % (battery_types[args.battery_type])
        else:
            print "Invalid battery type"

    if args.battery_capacity is None:
        print "Battery capacity: %dAh" % (
            client.read_input(REG_BATTERY_CAPACITY).value)
    else:
        client.write_output(REG_BATTERY_CAPACITY, args.battery_capacity)
        print "Battery capacity set to %dAh" % (args.battery_capacity)
Пример #4
0
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)

serialclient = ModbusClient()
#serialclient = None

client = EPsolarTracerClient(serialclient = serialclient)
client.connect()

response = client.read_device_info()
print "Manufacturer:", repr(response.information[0])
print "Model:", repr(response.information[1])
print "Version:", repr(response.information[2])

response = client.read_input("Charging equipment rated input voltage")
print str(response)

for reg in registers:
    #print
    #print reg
    value = client.read_input(reg.name)
    print value
    #if value.value is not None:
    #    print client.write_output(reg.name,value.value)

for reg in coils:
    #print
    #print reg
    value = client.read_input(reg.name)
    print value
Пример #5
0
announce['Manufacturer'] = str(response.information[0])
announce['Model'] = str(response.information[1])
announce['Version'] = str(response.information[2])
mqtt_client.publish('{}/$announce'.format(base_topic), json.dumps(announce), retain=True)
print_line("Manufacturer:" + repr(response.information[0]))
print_line("Model:" + repr(response.information[1]))
print_line("Version:" + repr(response.information[2]))

sd_notifier.notify('READY=1')

while True:
    data = dict()
    for reg in registers:
        #print
        #print reg
        value = client.read_input(reg.name)
        #print_line(value)
        data[reg.name] = float(value)
        mqtt_client.publish('{}/registers/{}/unitShort'.format(base_topic, reg.name), reg.unit()[1], 1, True)
        mqtt_client.publish('{}/registers/{}/unitLong'.format(base_topic, reg.name), reg.unit()[0], 1, True)
        mqtt_client.publish('{}/registers/{}/value'.format(base_topic, reg.name), float(value), 1, True)

        #if value.value is not None:
        #    print client.write_output(reg.name,value.value)
    chargingEquipmentStatus = int(client.read_input("Charging equipment status"))
    chargingStatus = 3 & (chargingEquipmentStatus >> 2)
    print_line("cs" + str(chargingStatus))
    # charger status: 1 = running 0 = standby
    data["Charging equipment status D0"] = 1 & chargingEquipmentStatus
    # pv equipment: 0 = normale 1 = fault
    data["Charging equipment status D1"] = 1 & (chargingEquipmentStatus >> 1)
Пример #6
0
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)

client = EPsolarTracerClient()
client.connect()

response = client.read_device_info()
print("Manufacturer:", repr(response.information[0]))
print("Model:", repr(response.information[1]))
print("Version:", repr(response.information[2]))

print("Aktuelle Werte:")
print("")
print("PV-Generator:")
print(client.read_input(
    "Charging equipment input voltage"))  # Momentary Voltage of PV-Generator
print(client.read_input(
    "Charging equipment input current"))  # Momentary Current of PV-Generator
print(client.read_input(
    "Charging equipment input power"))  # Momentary Power of PV-Generator
print("")
print("Battery:")
print(client.read_input("Charging equipment output voltage")
      )  # Momentary Voltage of Battery-Output
print(client.read_input("Charging equipment output current")
      )  # Momentary Current of Battery-Output
print(client.read_input(
    "Charging equipment output power"))  # Momentary Power of Battery-Output
print("")
rprint("LoAD::")
print(client.read_input("Discharging equipment output voltage")
for port in ports:
    print "************ " + port + " ***************"
    serialclient = ModbusSerialClient(method='rtu', port=port, baudrate=115200)
    client = EPsolarTracerClient(serialclient=serialclient)
    client.connect()

    import datetime
    now = datetime.datetime.now()

    print now.year, now.month, now.day, now.hour, now.minute, now.second

    yearAndMonth = int(((now.year - 2000) << 8) | now.month)
    dayAndHour = int(((now.day) << 8) | now.hour)
    minuteAndSecond = int(((now.minute) << 8) | now.second)

    response = client.read_input("Real time clock 2")
    stdout.write("Device Time: " + str(int(response) & 0xFF))
    response = client.read_input("Real time clock 1")
    stdout.write(":" + str(int(response) >> 8) + ":" +
                 str(int(response) & 0xFF))
    stdout.flush()

    print ""
    print "******************************************************"
    loadCtrlModesAddr = 0x903D

    # 0000H Manual Control
    # 0001H Light ON/OFF
    # 0002H Light ON+ Timer/
    # 0003H Time Control
    loadCtrlMode = 0x0003
Пример #8
0
client.connect()

response = client.read_device_info()
#print "Manufacturer:", repr(response.information[0])
#print "Model:", repr(response.information[1])
#print "Version:", repr(response.information[2])

#response = client.read_input("Charging equipment rated input voltage")
#print str(response)

vlist = []

for reg in registers:
    #print
    #print reg
    value = client.read_input(reg.name)
    vlist.append(value)
    #print value
    #if value.value is not None:
    #    print client.write_output(reg.name,value.value)

print(value)

for reg in coils:
    #print
    #print reg
    value = client.read_input(reg.name)
    print(value)
    vlist.append(value)
    #print value
    #print client.write_output(reg.name,value.value)
Пример #9
0
from pyepsolartracer.client import EPsolarTracerClient
from pyepsolartracer.registers import registers, coils
from pymodbus.client.sync import ModbusSerialClient as ModbusClient

# configure the client logging
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)

serialclient = ModbusClient(method='rtu',
                            port='/dev/ttyXRUSB0',
                            baudrate=115200,
                            stopbits=1,
                            bytesize=8,
                            timeout=0.05)

client = EPsolarTracerClient(serialclient=serialclient)
client.connect()

value = client.read_input("Manual control the load")
print bool(int(value))

client.close()
Пример #10
0
client = EPsolarTracerClient()
client.connect()

data = []  # New List for Data

response = client.read_device_info()

data.append({
    'con-manufacturer':
    repr(response.information[0]),
    'con-model':
    repr(response.information[1]),
    'con-version':
    repr(response.information[2]),
    'con-temp-controller':
    client.read_input("Temperature inside equipment").value,
    'con-temp-heatsink':
    client.read_input("Power components temperature").value
})

data.append({
    'pv-voltage':
    client.read_input("Charging equipment input voltage").value,
    'pv-current':
    client.read_input("Charging equipment input current").value,
    'pv-power':
    client.read_input("Charging equipment input power").value
})

data.append({
    'bat-voltage':
Пример #11
0
    parser.add_argument("-n", "--nodename", type = str, dest = "nodename", default=socket.gethostname())
    parser.add_argument("-H", "--dbhost", type = str, dest = "dbhost", default="localhost")
    parser.add_argument("-p", "--port", type = str, dest = "port", default = "/dev/ttyXRUSB0")
    args = parser.parse_args()

    print "# Nodename:", args.nodename

    client = EPsolarTracerClient(port = args.port)
    client.connect()

    response = client.read_device_info()
    print "# Manufacturer:", repr(response.information[0])
    print "# Model:", repr(response.information[1])
    print "# Version:", repr(response.information[2])

    try:
        with database.Connection(dbhost=args.dbhost) as cur:
            while True:
                values = [ client.read_input(x).value for x in registers ]
                now_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                piv = values[0]

            	cur.execute("replace into data(hostname,t,piv,pia,piw,pov,poa,loadw,temp,kwh,lkwh) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", (args.nodename,now_str, piv,values[1],values[2],values[3],values[4],values[5],values[6],values[7],values[8]))

                print "%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f" % (now_str, piv,values[1],values[2],values[3],values[4],values[5],values[6],values[7],values[8])
                sys.stdout.flush()
                time.sleep(5 if piv > 0.00 else 60)
    finally:
        client.close()
        print "# End of file"
Пример #12
0
from pyepsolartracer.client import EPsolarTracerClient
from pyepsolartracer.registers import registers,coils
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pyepsolartracer.registers import registerByName

# configure the client logging
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)

serialclient = ModbusClient(method='rtu', port='/dev/ttyXRUSB0', baudrate=115200, stopbits = 1, bytesize = 8, timeout = 0.05)

client = EPsolarTracerClient(serialclient = serialclient)
client.connect()

value = client.read_input("Charging equipment input current")
print float(value)

client.close()
Пример #13
0
if client.connect() == False:
    print("Error. Port not able to be opened")


data = []  # New List for Data

response = client.read_device_info()

#data.append(["Device Info"])  # Root Layer
#data[0].append(
data.append(
    {
        'con-manufacturer':repr(response.information[0]),
        'con-model':repr(response.information[1]),
        'con-version':repr(response.information[2]),
        'con-temp-controller':client.read_input("Temperature inside equipment").value,
        'con-temp-heatsink':client.read_input("Power components temperature").value
    }
)

#data.append(["PV-Generator"])  # Root Layer
#data[1].append(
data.append(
    {
        'pv-voltage':client.read_input("Charging equipment input voltage").value,
        'pv-current':client.read_input("Charging equipment input current").value,
        'pv-power':client.read_input("Charging equipment input power").value
    }
)

#data.append(["Battery"])  # Root Layer