Пример #1
0
def log_conn_state(inv, data=None):
    try:
        connected = inverter.get_conn_state(inv)
        power = inverter.get_power(inv, data)
        pf = inverter.get_power_factor(inv, data)
        ts.log('Current connection state is %s. Power output = %0.3f W. power factor %0.3f.' %
               (inverter.conn_state_str(connected), power, pf))
    except Exception, e:
        ts.log_error('Error logging connect state: %s' % str(e))
        raise
Пример #2
0
def test_run():

    result = script.RESULT_FAIL
    data = None
    trigger = None
    inv = None
    pv = None
    disable = None

    try:
        ifc_type = ts.param_value('comm.ifc_type')
        ifc_name = ts.param_value('comm.ifc_name')
        if ifc_type == client.MAPPED:
            ifc_name = ts.param_value('comm.map_name')
        baudrate = ts.param_value('comm.baudrate')
        parity = ts.param_value('comm.parity')
        ipaddr = ts.param_value('comm.ipaddr')
        ipport = ts.param_value('comm.ipport')
        slave_id = ts.param_value('comm.slave_id')

        power_factor = ts.param_value('inv3.power_factor')
        ramp_time = ts.param_value('inv3.ramp_time')  # time to ramp
        time_window = ts.param_value('inv3.time_window')
        timeout_period = ts.param_value('inv3.timeout_period')

        pretest_delay = ts.param_value('invt.pretest_delay')
        power_factor_range = ts.param_value('invt.power_factor_range')
        setpoint_failure_count = ts.param_value('invt.setpoint_failure_count')
        setpoint_period = ts.param_value('invt.setpoint_period')
        verification_delay = ts.param_value('invt.verification_delay')
        posttest_delay = ts.param_value('invt.posttest_delay')
        disable = ts.param_value('invt.disable')

        # initialize data acquisition system
        daq = das.das_init(ts)
        data = daq.data_init()
        trigger = daq.trigger_init()

        # initialize pv simulation
        pv = pvsim.pvsim_init(ts)
        pv.irradiance_set(ts.param_value('profile.irr_start'))
        pv.profile_load(ts.param_value('profile.profile_name'))
        pv.power_on()

        # Sandia Test Protocol: Communication is established between the Utility Management System Simulator and EUT
        ts.log('Scanning EUT')
        try:
            # Sandia Test Protocol Step 1: Request status of EUT
            # Sandia Test Protocol Step 2: UMS receives response from EUT
            inv = client.SunSpecClientDevice(ifc_type,
                                             slave_id=slave_id,
                                             name=ifc_name,
                                             baudrate=baudrate,
                                             parity=parity,
                                             ipaddr=ipaddr,
                                             ipport=ipport)
        except Exception, e:
            raise script.ScriptFail('Error: %s' % (e))

        if pretest_delay > 0:
            ts.log('Waiting for pre-test delay of %d seconds' % pretest_delay)
            ts.sleep(pretest_delay)

        # Make sure the EUT is on and operating
        ts.log(
            'Verifying EUT is in connected state. Waiting up to %d seconds for EUT to begin power export.'
            % (verification_delay + pretest_delay))
        if verify_initial_conn_state(
                inv,
                state=inverter.CONN_CONNECT,
                time_period=verification_delay + pretest_delay,
                data=data) is False:
            ts.log_error('Inverter unable to be set to connected state.')
            raise script.ScriptFail()

        # Get parameters
        try:
            inv.nameplate.read()
            # get min/max PF settings
            min_PF = float(inv.nameplate.PFRtgQ1)
            max_PF = float(inv.nameplate.PFRtgQ4)
            ts.log('Power factor range for this device is %.3f to %.3f' %
                   (min_PF, max_PF))

            # Sandia Test Protocol Step 3: EUT output power factor is measured and logged
            # Get INV3 settings and report these.

            # Get PF from EUT
            pf = inverter.get_power_factor(inv, das=data)
            ts.log('Power factor is %f.' % pf)
        except Exception, e:
            raise script.ScriptFail(
                'Unable to get PF limits or PF from EUT: %s' % str(e))
Пример #3
0
                # SA Table
                ts.log('Setting target power factor in the EUT to %0.3f.' % power_factor)
                inverter.set_power_factor(inv, power_factor=power_factor, enable=1, trigger=trigger)

                test_duration = pf_settling_time*2. + verification_delay
                ts.log('Waiting up to %0.2f seconds for power factor change with a verification period of %d seconds.' %
                       (pf_settling_time*2., verification_delay))

                # Initialize consecutive failure count to not script fail on transient behavior
                failures = 0

                while elapsed_time <= test_duration:
                    ts.sleep(0.93)
                    elapsed_time = time.time()-start_time

                    pf = inverter.get_power_factor(inv, data)

                    # Cheating here because the PF is unsigned in inv.inverter.PF and data.ac_pf
                    # With a good data acquisition system, this code block can be deleted.
                    if power_factor < 0 and pf > 0:
                        # assume the PF is the correct sign
                        pf = -pf

                    # Screening: determine if the PF is in the target range
                    out_of_range = pf_out_of_range(pf, power_factor_lower, power_factor_upper, power_factor_range)

                    ts.log('PF Target = %.3f, PF = %.3f (Total Error = %.3f%%), Time: %0.3f seconds.' %
                           (power_factor, pf, (pf - power_factor)*100.0, elapsed_time))

                    # if pf is out of range
                    if out_of_range is True:
Пример #4
0
                ts.log('Power factor mode is enabled.')
            else:
                ts.log('Power factor mode is not enabled.')
        except Exception, e:
            raise script.ScriptFail('Unable to read OutPFSet_Ena: %s' % str(e))

        #### Comparison of DAS PF and the EUT PF
        # Request status from DAS and display power factor
        if data:
            data.read()
            power_factor_data_original = data.ac_pf
            ts.log_debug('Current DAS-measured power factor is +/-%.3f' %
                         power_factor_data_original)

        # Request status from EUT and display power factor
        power_factor_original = inverter.get_power_factor(inv, data)
        if power_factor_original is not None:
            pass
            # ts.log_debug('Current inverter-measured power factor is +/-%.3f' % power_factor_original)
        else:
            ts.log_error('Inverter does not have PF in the inverter model.')
            raise script.ScriptFail()

        # Find pass/fail bounds
        (power_factor_upper,
         power_factor_lower) = calculate_pf_range(power_factor,
                                                  power_factor_range)
        ts.log(
            'Target power factor: %.3f. Pass limits for screening: lower = %.3f  upper = %.3f'
            % (power_factor, power_factor_lower, power_factor_upper))