示例#1
0
def print_instantdemand(idemand) :


    multiplier = int(idemand['Multiplier'], 16)
    divisor = int(idemand['Divisor'], 16)

#    demand = twos_comp(int(idemand['Demand'], 16))

    demand = int(idemand['Demand'], 16)

    if demand > 0x7FFFFFFF:
        demand -= 0x100000000

    if multiplier == 0 :
        multiplier = 1

    if divisor == 0 :
        divisor = 1

    reading = (demand * multiplier) / float (divisor)

    if 'TimeStamp' in idemand :
        time_stamp = to_epoch_1970(idemand['TimeStamp'])
        print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))

    print "\tDemand    = {0:{width}.3f} Kw".format(reading, width=10)
    print "\tAmps      = {0:{width}.3f}".format( ((reading * 1000) / 240), width=10)
示例#2
0
def print_instantdemand(idemand) :


    multiplier = int(idemand['Multiplier'], 16)
    divisor = int(idemand['Divisor'], 16)

#    demand = twos_comp(int(idemand['Demand'], 16))

    demand = int(idemand['Demand'], 16)

    if demand > 0x7FFFFFFF:
        demand -= 0x100000000

    if multiplier == 0 :
        multiplier = 1

    if divisor == 0 :
        divisor = 1

    reading = (demand * multiplier) / float (divisor)

    if 'TimeStamp' in idemand :
        time_stamp = to_epoch_1970(idemand['TimeStamp'])
        print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))

    print "\tDemand    = {0:10.3f} Kw".format(reading)
    print "\tAmps      = {0:10.3f}".format( ((reading * 1000) / 240))
示例#3
0
def print_currentsummation(cs) :
    global last_delivered
    global last_received

    global max_delta_received
    global max_delta_delivered
    global day_delta_received
    global day_delta_delivered
    global curr_day

    time_stamp = to_epoch_1970(cs['TimeStamp'])

    multiplier = int(cs['Multiplier'], 16)
    divisor = int(cs['Divisor'], 16)
    delivered = int(cs['SummationDelivered'], 16)
    received = int(cs['SummationReceived'], 16)

    # print "Multiplier=", multiplier, "Divisor=", divisor, "Demand=", demand

    if multiplier == 0 :
        multiplier = 1

    if divisor == 0 :
        divisor = 1

    reading_received = received * multiplier / float(divisor)
    delta_received = (reading_received - last_received)
    last_received = reading_received
    if (delta_received > max_delta_received and delta_received < 1000) :
        max_delta_received = delta_received
        #print "new max_delta_received :", max_delta_received

    reading_delivered = delivered * multiplier / float(divisor)
    delta_delivered = (reading_delivered - last_delivered)
    last_delivered = reading_delivered
    if (delta_delivered > max_delta_delivered and delta_delivered < 1000) :
        max_delta_delivered = delta_delivered
        #print "\t\tnew max_delta_delivered :", max_delta_delivered

    time_struct = time.localtime(time_stamp)
    if curr_day.tm_mday != time_struct.tm_mday :
        curr_day = time_struct
        print "# {0} day_delta_received={1:0.4f}".format( \
                    time.strftime("%a %Y-%m-%d", curr_day),
                    day_delta_received) \
            + "\tday_delta_delivered={0:0.4f}".format(day_delta_delivered) \
            + " : {0:0.4f}".format((day_delta_delivered - day_delta_received))
        day_delta_received = 0
        day_delta_delivered = 0

    day_delta_received += delta_received
    day_delta_delivered += delta_delivered

    print "{0}\t{1:.4f}\t{2:0.4f}\t{3:.4f}\t{4:0.4f}".format(
        time.strftime("%Y-%m-%d %H:%M:%S", time_struct),
        reading_received,
        delta_received,
        reading_delivered,
        delta_delivered)
示例#4
0
def print_currentsummation(cs):
    global last_delivered
    global last_received

    global max_delta_received
    global max_delta_delivered
    global day_delta_received
    global day_delta_delivered
    global curr_day

    time_stamp = to_epoch_1970(cs['TimeStamp'])

    multiplier = int(cs['Multiplier'], 16)
    divisor = int(cs['Divisor'], 16)
    delivered = int(cs['SummationDelivered'], 16)
    received = int(cs['SummationReceived'], 16)

    # print "Multiplier=", multiplier, "Divisor=", divisor, "Demand=", demand

    if multiplier == 0:
        multiplier = 1

    if divisor == 0:
        divisor = 1

    reading_received = received * multiplier / float(divisor)
    delta_received = (reading_received - last_received)
    last_received = reading_received
    if (delta_received > max_delta_received and delta_received < 1000):
        max_delta_received = delta_received
        #print "new max_delta_received :", max_delta_received

    reading_delivered = delivered * multiplier / float(divisor)
    delta_delivered = (reading_delivered - last_delivered)
    last_delivered = reading_delivered
    if (delta_delivered > max_delta_delivered and delta_delivered < 1000):
        max_delta_delivered = delta_delivered
        #print "\t\tnew max_delta_delivered :", max_delta_delivered

    time_struct = time.localtime(time_stamp)
    if curr_day.tm_mday != time_struct.tm_mday:
        curr_day = time_struct
        print "# {0} day_delta_received={1:0.4f}".format( \
                    time.strftime("%a %Y-%m-%d", curr_day),
                    day_delta_received) \
            + "\tday_delta_delivered={0:0.4f}".format(day_delta_delivered) \
            + " : {0:0.4f}".format((day_delta_delivered - day_delta_received))
        day_delta_received = 0
        day_delta_delivered = 0

    day_delta_received += delta_received
    day_delta_delivered += delta_delivered

    print "{0}\t{1:.4f}\t{2:0.4f}\t{3:.4f}\t{4:0.4f}".format(
        time.strftime("%Y-%m-%d %H:%M:%S", time_struct), reading_received,
        delta_received, reading_delivered, delta_delivered)
示例#5
0
def print_currentsummation(cs) :

    multiplier = int(cs['Multiplier'], 16)
    divisor = int(cs['Divisor'], 16)
    delivered = int(cs['SummationDelivered'], 16)
    received = int(cs['SummationReceived'], 16)

    if multiplier == 0 :
        multiplier = 1

    if divisor == 0 :
        divisor = 1

    reading_received = received * multiplier / float (divisor)
    reading_delivered = delivered * multiplier / float (divisor)

    if 'TimeStamp' in cs :
        time_stamp = to_epoch_1970(cs['TimeStamp'])
        print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))
    print "\tReceived  = {0:{width}.3f} Kw".format(reading_received, width=10)
    print "\tDelivered = {0:{width}.3f} Kw".format(reading_delivered, width=10)
    print "\t\t{0:{width}.3f} Kw".format( (reading_delivered - reading_received), width=14)
示例#6
0
def print_currentsummation(cs) :

    multiplier = int(cs['Multiplier'], 16)
    divisor = int(cs['Divisor'], 16)
    delivered = int(cs['SummationDelivered'], 16)
    received = int(cs['SummationReceived'], 16)

    if multiplier == 0 :
        multiplier = 1

    if divisor == 0 :
        divisor = 1

    reading_received = received * multiplier / float (divisor)
    reading_delivered = delivered * multiplier / float (divisor)

    if 'TimeStamp' in cs :
        time_stamp = to_epoch_1970(cs['TimeStamp'])
        print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))
    print "\tReceived  = {0:10.3f} Kw".format(reading_received)
    print "\tDelivered = {0:10.3f} Kw".format(reading_delivered)
    print "\tMeter     = {0:10.3f} Kw".format( (reading_delivered - reading_received))