Example #1
0
def generate_outputfile(infile, outfile, prog_name):
    generate_preamble(outfile)
    nettype, tree = parse_xml(infile, outfile)

    algies = tree.findall('Algorithms')
    if len(algies) != 1:
        raise ValueError

    alg_list = algies[0].findall('Algorithm')
    weighttype = tree.find('WeightType')
    generate_opening(outfile, tree, weighttype.text)
    outfile.write('\t// generating algorithms\n')
    algorithms.parse_algorithms(alg_list, weighttype, outfile, for_lib=True)
    node_list = tree.findall('Nodes/Node')
    outfile.write('\t// generating nodes\n')
    nodes.parse_nodes(node_list, weighttype, outfile)
    outfile.write('\t// generating connections\n')
    connection_list = tree.findall('Connections/Connection')
    connections.parse_connections(connection_list, weighttype, outfile)
    connection_list = tree.findall('Connections/IncomingConnection')
    connections.parse_incoming_connections(connection_list, weighttype,
                                           outfile)
    connection_list = tree.findall('Connections/OutgoingConnection')
    connections.parse_outgoing_connections(connection_list, outfile)

    t_end = tree.find('SimulationRunParameter/t_end')
    t_step = tree.find('SimulationRunParameter/t_step')

    generate_closing(outfile, '(' + t_end.text + ') / ' + t_step.text,
                     t_step.text, weighttype, tree, prog_name)

    python_wrapper(outfile, prog_name)

    algorithms.reset_algorithms()
    nodes.reset_nodes()
Example #2
0
def generate_outputfile(infile, outfile):
    generate_preamble(outfile)
    nettype, tree = parse_xml(infile,outfile)
    outfile.write(nettype)
    outfile.write('\t// defining variables\n') # whatever variables are use are global

    algies = tree.findall('Algorithms')
    if len(algies) != 1:
        raise ValueError

    alg_list = algies[0].findall('Algorithm')
    weighttype = tree.find('WeightType')
    generate_opening(outfile, tree, weighttype.text)
    outfile.write('\t// generating algorithms\n')
    algorithms.parse_algorithms(alg_list,weighttype,outfile)
    node_list = tree.findall('Nodes/Node')
    outfile.write('\t// generating nodes\n')
    nodes.parse_nodes(node_list,weighttype,outfile)
    outfile.write('\t// generating connections\n')
    connection_list = tree.findall('Connections/Connection')
    connections.parse_connections(connection_list,weighttype,outfile)
    connection_list = tree.findall('Connections/IncomingConnection')
    connections.parse_incoming_connections(connection_list,weighttype,outfile)
    connection_list = tree.findall('Connections/OutgoingConnection')
    connections.parse_outgoing_connections(connection_list,outfile)
    generate_closing(outfile, weighttype.text, tree)
    algorithms.reset_algorithms()
    nodes.reset_nodes()
Example #3
0
def generate_outputfile(infile, outfile, enable_root):
    generate_preamble(outfile)
    nettype, tree = parse_xml(infile, outfile)
    outfile.write(nettype)
    outfile.write(
        '\t// defining variables\n')  # whatever variables are use are global
    variable_list = tree.findall('Variable')
    variables.parse_variables(variable_list, outfile)
    algies = tree.findall('Algorithms')
    if len(algies) != 1:
        raise ValueError

    alg_list = algies[0].findall('Algorithm')
    weighttype = tree.find('WeightType')
    generate_opening(outfile)
    outfile.write('\t// generating algorithms\n')
    algorithms.parse_algorithms(alg_list, weighttype, outfile)
    node_list = tree.findall('Nodes/Node')
    outfile.write('\t// generating nodes\n')
    nodes.parse_nodes(node_list, weighttype, outfile)
    outfile.write('\t// generating connections\n')
    connection_list = tree.findall('Connections/Connection')
    connections.parse_connections(connection_list, weighttype, outfile)
    outfile.write('\t// generation simulation parameter\n')
    simhand = tree.find('SimulationIO')
    simulation.parse_simulation(simhand, outfile, enable_root)
    simpar = tree.find('SimulationRunParameter')
    simulation.parse_parameter(simpar, outfile)

    t_begin = tree.find('SimulationRunParameter/t_begin')
    t_end = tree.find('SimulationRunParameter/t_end')
    t_step = tree.find('SimulationRunParameter/t_step')

    m = tree.find('WeightType')
    s = m.text

    generate_closing(
        outfile,
        '(' + t_end.text + ' - ' + t_begin.text + ') / ' + t_step.text, s,
        t_step.text)
    algorithms.reset_algorithms()
    nodes.reset_nodes()
Example #4
0
def generate_outputfile(infile, outfile):
    generate_preamble(outfile)
    nettype, tree = parse_xml(infile, outfile)
    outfile.write(nettype)
    alg_list = tree.findall('Algorithms/AbstractAlgorithm')
    weighttype = tree.find('WeightType')
    generate_opening(outfile)
    outfile.write('\t// generating algorithms\n')
    algorithms.parse_algorithms(alg_list, weighttype, outfile)
    node_list = tree.findall('Nodes/Node')
    outfile.write('\t// generating nodes\n')
    nodes.parse_nodes(node_list, weighttype, outfile)
    outfile.write('\t// generating connections\n')
    connection_list = tree.findall('Connections/Connection')
    connections.parse_connections(connection_list, weighttype, outfile)
    outfile.write('\t// generation simulation parameter\n')
    simhand = tree.find('SimulationIO')
    simulation.parse_simulation(simhand, outfile)
    simpar = tree.find('SimulationRunParameter')
    simulation.parse_parameter(simpar, outfile)
    generate_closing(outfile)
    algorithms.reset_algorithms()
    nodes.reset_nodes()
Example #5
0
def generate_outputfile(infile, outfile):
    generate_preamble(outfile)
    nettype, tree = parse_xml(infile,outfile)
    outfile.write(nettype)
    alg_list = tree.findall('Algorithms/AbstractAlgorithm')
    weighttype = tree.find('WeightType')
    generate_opening(outfile)
    outfile.write('\t// generating algorithms\n')
    algorithms.parse_algorithms(alg_list,weighttype,outfile)
    node_list = tree.findall('Nodes/Node')
    outfile.write('\t// generating nodes\n')
    nodes.parse_nodes(node_list,weighttype,outfile)
    outfile.write('\t// generating connections\n')
    connection_list = tree.findall('Connections/Connection')
    connections.parse_connections(connection_list,weighttype,outfile)
    outfile.write('\t// generation simulation parameter\n')
    simhand = tree.find('SimulationIO')
    simulation.parse_simulation(simhand,outfile)
    simpar = tree.find('SimulationRunParameter')
    simulation.parse_parameter(simpar,outfile)
    generate_closing(outfile)
    algorithms.reset_algorithms()
    nodes.reset_nodes()