Example #1
0
        public bool SetConfig(Config.Calculation newConfig)
        {
            var inputs = newConfig.Inputs.ToArray();

            newConfig.Inputs.Clear();

            var outputs = newConfig.Outputs.ToArray();

            newConfig.Outputs.Clear();

            var states = newConfig.States.ToArray();

            newConfig.States.Clear();

            string newOriginalConfigWithoutIO = Xml.ToXml(newConfig);
            bool   changed = (newOriginalConfigWithoutIO != originalConfigWithoutIO);

            newConfig.Inputs.AddRange(inputs);
            newConfig.Outputs.AddRange(outputs);
            newConfig.States.AddRange(states);

            CalcConfig = newConfig;
            originalConfigWithoutIO = newOriginalConfigWithoutIO;
            return(changed);
        }
Example #2
0
 private static Config.Output MakeOutput(OutputDef output, Config.Calculation calc)
 {
     Config.Output old = calc.Outputs.FirstOrDefault(x => x.ID == output.ID);
     return(new Config.Output()
     {
         ID = output.ID,
         Name = output.Name,
         Unit = output.Unit,
         Dimension = output.Dimension,
         Type = output.Type,
         Variable = old != null ? old.Variable : null,
     });
 }
Example #3
0
 private static Config.Input MakeInput(InputDef input, Config.Calculation calc)
 {
     Config.Input old = calc.Inputs.FirstOrDefault(x => x.ID == input.ID);
     return(new Config.Input()
     {
         ID = input.ID,
         Name = input.Name,
         Unit = input.Unit,
         Dimension = input.Dimension,
         Type = input.Type,
         Constant = old != null ? old.Constant : (input.DefaultValue.HasValue ? input.DefaultValue.Value: (DataValue?)null),
         Variable = old != null ? old.Variable : null,
     });
 }
Example #4
0
        private ObjectRef[] GetObjects(Config.Calculation c)
        {
            var res = new List <ObjectRef>();

            foreach (var input in c.Inputs)
            {
                if (input.Variable.HasValue)
                {
                    res.Add(input.Variable.Value.Object);
                }
            }
            foreach (var output in c.Outputs)
            {
                if (output.Variable.HasValue)
                {
                    res.Add(output.Variable.Value.Object);
                }
            }
            return(res.ToArray());
        }
Example #5
0
 public CalcInstance(Config.Calculation a, string moduleID)
 {
     SetConfig(a);
     State         = State.Created;
     this.moduleID = moduleID;
 }