Esempio n. 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();
        }
Esempio n. 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);
            }
        }
Esempio n. 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();
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 6
0
 public bool IsRef(NnTemplate data) =>
 this.Template == data;
Esempio n. 7
0
 public NnTemplateData(NnTemplate template)
 {
     this.Template = template;
 }