示例#1
0
def chug():
    """Create a bunch of templates..."""
    import os
    import FactoryTalkXML as ftxml
    os.chdir('/Users/benmordecai/github/factorytalkxml/damo/')
    file1 = open('Diag Inputs 1.xml', 'r')
    dict1 = ftxml.populate(file1)
    file1.close()
    assert dict1 
    objex1 = ftxml.get_object_explorer(dict1)
    temp1a = create_template(objex1, INPUT_STATIC_NAMES)
    temp1b = create_template(objex1, INPUT_ITERABLE_NAMES)
    pickle_template(temp1a, temp1b, 'inputs.ftt')
示例#2
0
 def rdedupe(object_list): # recursive portion for handling nested Groups
     for obj in object_list:
         if obj.name in dedupe_names.names_remaining:
             dedupe_names.names_remaining.remove(obj.name)
         else:
             new_name = strip_suffix(obj.name)
             new_name = gen_unique_name(new_name, 
                                        dedupe_names.unique_names)
             dedupe_names.unique_names.append(new_name)
             # Note that self.set_attribute is not allowed for names, since
             #    the xml object itself has a name.
             obj = ftxml.set_name(obj, new_name)
         if 'Group' in obj.name:
             rdedupe(obj.children)
     return object_list
示例#3
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