예제 #1
0
        public NnPlan(
            string name,
            RPath path,
            NnTemplate template,
            PlanType type = PlanType.NoPlan
            )
        {
            this.Name     = name;
            this.FSPath   = path;
            this.Template = template;
            this.Type     = type;

            tasks = new Dictionary <NnParam, NnTask>();

            KernelInitialize();

            Save();
        }
예제 #2
0
        public static NnPlan?Load(RPath path)
        {
            try {
                var planData =
                    (SaveData)Util.DeserializeFromFile(
                        path.SubPath(NnAgent.planFileName)
                        );

                Dictionary <NnParam, NnTask> tasks = new Dictionary <NnParam, NnTask>();
                foreach (var taskId in planData.taskIds)
                {
                    NnTask?task = NnTask.Load(
                        path.SubPath("tasks").SubPath(taskId.Value)
                        );
                    if (task != null)
                    {
                        tasks[taskId.Key] = task;
                    }
                }

                NnTemplate?template = NnTemplate.Load(path);

                if (template == null)
                {
                    throw new Exception();
                }

                NnPlan plan = new NnPlan(
                    planData.name,
                    path,
                    template,
                    tasks,
                    // planData.consts?.ToImmutableDictionary(),
                    planData.Type
                    );

                return(plan);
            } catch {
                Util.ErrorHappend($"Error while loading plan!");
                return(null);
            }
        }
예제 #3
0
        NnPlan(
            string name,
            RPath path,
            NnTemplate template,
            Dictionary <NnParam, NnTask> tasks,
            // ImmutableDictionary<string, string> ? consts,
            PlanType type
            )
        {
            this.Name     = name;
            this.FSPath   = path;
            this.Template = template;
            this.tasks    = tasks;
            // this.Consts = consts;
            this.Type = type;

            KernelInitialize();

            Save();
        }
예제 #4
0
        public NnTemplateData?AddTemplate(string id, string content)
        {
            var template = NnTemplate.NewTemplate(
                id,
                content,
                project.FSPath.SubPath("templates").SubPath(id)
                );

            if (template == null)
            {
                return(null);
            }

            if (project.AddTemplate(template))
            {
                return(new NnTemplateData(template));
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
        public static NnTemplate?Load(RPath path)
        {
            try {
                var tempData =
                    (SaveData)Util.DeserializeFromFile(
                        path.SubPath(NnAgent.tempFileName)
                        );

                NnTemplate temp = new NnTemplate(
                    tempData.name,
                    tempData.type,
                    path,
                    tempData.elements,
                    tempData.variables.ToImmutableDictionary(),
                    tempData.derivedVariables.ToImmutableDictionary()
                    );

                return(temp);
            } catch {
                Util.ErrorHappend($"Error while loading template!");
                return(null);
            }
        }
예제 #6
0
 public bool IsRef(NnTemplate data) =>
 this.Template == data;
예제 #7
0
 public NnTemplateData(NnTemplate template)
 {
     this.Template = template;
 }