示例#1
0
def configure_vfddiag(gui_row, n, device_collections, plc_name='CLOGIX'):
    """This is a configuration function for a VFD Diagnostic screen. It is
    bundled as an attribute to the corresponding ScreenType.
    
    Pass:
    gui_row - a list of gui object in left to right order as they appear on
        an HMI screen.
    n - the number representing the order that row appears relative to other
        rows. Numbered from 0.
    device_collections - a list of DeviceConnection instances, which contain
        spreadsheet used to set the attributes of the gui elements.
    plc_name - (optional) the device shortcut required for the HMI to access
        tags from a PLC
    Return:
    gui_row with all settings configured properly.
    """
    # Caption, Green Jog, Grey Jog, Speed Input, Current Display
    dc = find_device_collection(device_collections, n)
    caption = gui_row[0]
    caption.set_attribute('caption', dc.cells['Caption'])
    green_jog = gui_row[1] 
    vfd_man = '[%s]%s' % (plc_name, dc.cells['VFD Manual'])
    vfd_io = '[%s]%s' % (plc_name, dc.cells['VFDIO'])
    green_jog_value = '{' + vfd_man + '.Jog_FWD}'
    green_jog.set_connection(green_jog_value)
    green_jog_indicator = '{' + vfd_man + '.Jogging}'
    green_jog.set_connection(green_jog_indicator, 
                                     connection_type = 'Indicator')
    green_jog_vis = '{' + vfd_man + '.JogFwd_Available}'
    green_jog.set_animation(green_jog_vis)
    sp_input = gui_row[3]
    sp_numerics = get_numerics(dc.cells['Jog Speed Numerics'])
    sp_min = dc.cells['Min Jog Speed']
    sp_max = dc.cells['Max Jog Speed']
    sp_input = ftxml.set_min_max(sp_input, sp_min, sp_max, plc_name)
    sp_input.set_attribute('numberOfDigits', sp_numerics[0])
    sp_input.set_attribute('digitsAfterDecimalPoint', sp_numerics[1])
    sp_input.set_attribute('decimalPlaces', sp_numerics[1])
    sp_input_value = '{' + vfd_man + '.Jog_Speed}'
    sp_input.set_connection(sp_input_value)
    curr_display = gui_row[4]
    curr_numerics = get_numerics(dc.cells['Current Numerics'])
    curr_display.set_attribute('numberOfDigits', curr_numerics[0])
    curr_display.set_attribute('decimalPlaces', curr_numerics[1])
    assert curr_display.attributes is not None
    curr_display_value =  '{' + vfd_io + '.Current}'
    curr_display.set_connection(curr_display_value)
    return gui_row