import SwtionProcess from "@/plugins/process";
import SwtionElement from "@/plugins/element";
import SwtionCalc from "@/plugins/calc";
import { valueType as calcValueType } from "@/enums/calc";
export default class SwtionProject {
    private swtionCalc = new SwtionCalc();
    private swtionEle = new SwtionElement();
    private swtionProc = new SwtionProcess();
    public generateProject() {
        const calcList = this.swtionCalc.loadCalc();
        const processList = this.swtionProc.loadProcess();
        const eleList = this.swtionEle.loadTree();
        return {
            calc: calcList,
            process: processList,
            element: eleList
        }
        // this.genCalc();
    }
    private genCalc() {

        const calcList = this.swtionCalc.loadCalc();
        let fun = ""
        for (let i = 0; i < calcList.length; i++) {
            let results = calcList[i].result;
            fun += `function calc${calcList[i].id}{
                return `
            for (let j = 0; j < results.length; j++) {
                switch (results[j].type) {
                    case calcValueType.attribute:
                        // let node = this.swtionAttr.findAttributeValueById(results[j].id);
                        // fun += `${node.name}`
                        // debugger;
                        break;
                    case calcValueType.calc:
                        fun += `calc${results[j].id}()`
                        break;
                    case calcValueType.operator:
                    case calcValueType.text:
                        fun += `${results[j].label}`
                        break;
                    case calcValueType.process:
                        fun += `proc${results[j].id}()`
                        break;
                }
            }
            fun += `}`
        }
        console.log(fun);
    }
}