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

    # Get arguments
    numCranes = 1
    if ec.ArgConstrOrderNumFlows in request.args:
        numCranes = int(request.args.get(ec.ArgConstrOrderNumFlows, 1))

    # 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 bars dependency graph
    BarDependencyChecker.buildDependencyGraph(modelData)
    PanelDependencyChecker.buildDependencyGraph(modelData)

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

    # Return order
    return jsonify({ec.OutTagConstrOrderOrder: res}), 200
Example #2
0
    def test_mult_ordering_noerror(self):
        filePath = os.path.dirname(os.path.abspath(__file__))

        with open(
                os.path.join(
                    os.path.join(
                        os.path.split(
                            os.path.split(
                                os.path.split(
                                    os.path.split(filePath)[0])[0])[0])[0],
                        "TestData"), "testModelDataWithOneCrane.json"),
                "r") as dataFile:
            dataFile.seek(0, 0)
            data = json.loads(dataFile.read())
            if not "modelData" in data or not "cranes" in data:
                self.fail("Bad json implemented")
            parser = AdvanceSteelModelParser()
            pm = parser.ParseProjectModel(data[ec.TagCraneOptModelData])
            cranes = [TowerCraneData(data[ec.TagCraneOptCranes][0])] * 3
            sd = SiteData(pm, cranes)

            # Build model bars dependency graph
            BarDependencyChecker.buildDependencyGraph(sd)
            order = ConstructionOrdering.GetConstructionOrderMult(
                sd.dependencies, list(sd.Bars.values()), 3)
Example #3
0
def calc_model_buildordermult_bo():
    """not working"""
    """Generates pre-order for building whole structure with multiple cranes data"""
    import json

    # default installation time 1.5 minutes
    installationTime = 1.5

    # load the base JSON
    baseModel = None
    reader = codecs.getreader("utf-8")
    file_name = os.path.normpath(
        "c:/dev/BuildOptimizer/PrefabOptimizationServer/PrefabOptimizationServer/Tests/model.json"
    )

    with open(file_name, encoding='utf-8-sig') as data_file:
        baseModel = json.loads(data_file.read())
    # Get arguments
    numCranes = 1

    # Parse project model from JSON
    client = ""
    parser = eutils.GetParserByClientType(client,
                                          ec.ValCommonClientAdvanceSteel)
    pm = parser.ParseProjectModel(baseModel[ec.TagCraneOptStructureData])
    modelData = SiteData(pm, [])

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

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

    # Return order
    return jsonify({ec.OutTagConstrOrderOrder: res}), 200