Beispiel #1
0
def calc_model_buildorder():
    """Generates pre-order for building whole structure"""
    # Check whether model data is in input
    if not request.json or not ec.TagCraneOptModelData in request.json:
        abort(400)

    # Parse project model from JSON
    client = ""
    if ec.ArgCraneOptClient in request.args:
        client = request.args.get(ec.ArgCraneOptClient,
                                  ec.ValCommonClientAdvanceSteel)
    parser = eutils.GetParserByClientType(client,
                                          ec.ValCommonClientAdvanceSteel)
    pm = parser.ParseProjectModel(request.json[ec.TagCraneOptModelData])
    modelData = SiteData(pm, [])

    # Build model dependency graph
    BarDependencyChecker.buildDependencyGraph(modelData)
    PanelDependencyChecker.buildDependencyGraph(modelData)

    # Get construction order usin the graph
    res = ConstructionOrdering.getConstructionOrder(
        modelData.dependencies, modelData.ConstructionObjects.values())

    # Return order
    return jsonify({ec.OutTagConstrOrderOrder: res}), 200
Beispiel #2
0
 def test_construction_order(self):
     G = nx.DiGraph()
     G.add_nodes_from(range(12))
     G.add_edges_from([(0, 1), (0, 4), (1, 2), (2, 3), (4, 5), (5, 2),
                       (5, 6), (6, 7), (6, 8), (7, 3), (8, 3), (9, 4),
                       (3, 10)])
     order = ConstructionOrdering.getConstructionOrder(G, [])
     self.assertEqual(order, [0, 9, 4, 5, 1, 6, 2, 8, 7, 11, 3, 10])