示例#1
0
        public static (double Value, double Minimum, double Maximum) GetParameterValueStateOrDefaults(
            this Arr <SimParameterSharedState> parameterSharedStates,
            string name,
            Arr <SimParameter> parameters
            )
        {
            var parameterSharedState = parameterSharedStates.Find(pss => pss.Name == name);

            return(parameterSharedState.Match(
                       pss => (pss.Value, pss.Minimum, pss.Maximum),
                       () =>
            {
                var parameter = parameters.GetParameter(name);
                var scalar = parameter.Scalar;
                return (scalar, scalar.GetPreviousOrderOfMagnitude(), scalar.GetNextOrderOfMagnitude());
            }));
        }
示例#2
0
        private NumDataTable?_Execute(Arr <SimParameter> parameters)
        {
            File.Delete(_pathToOutFile);

            var source = _defaultSource.Map(
                p => parameters.Find(pp => pp.Name == p.Name).IfNone(p)
                );

            var scriptObject = new ScriptObject();

            source.Iter(p => scriptObject.Add(p.Name, p.Value));

            var context = new TemplateContext();

            context.PushGlobal(scriptObject);

            var @in = _templateIn.Render(context);

            WriteAllText(_pathToInFile, @in);

            using var run = Process.Start(_processStartInfo);

            RequireNotNull(run, "Failed to start MCSim process");

            run.WaitForExit();

            if (run.ExitCode != 0)
            {
                var stdOut = run.StandardOutput.ReadToEnd();
                var stdErr = run.StandardError.ReadToEnd();
                return(HandleFailure(run.ExitCode, stdOut, stdErr));
            }

            if (!File.Exists(_pathToOutFile))
            {
                var stdOut = run.StandardOutput.ReadToEnd();
                return(HandleIntegrationFailure(stdOut));
            }

            return(ProcessOutFile());
        }
示例#3
0
 public static Option <SimObservationsSharedState> FindState(this Arr <SimObservationsSharedState> observationsSharedStates, string reference) =>
 observationsSharedStates.Find(oss => oss.Reference == reference);
示例#4
0
 public static Option <SimElementSharedState> FindState(this Arr <SimElementSharedState> elementSharedStates, string name) =>
 elementSharedStates.Find(ess => ess.Name == name);
示例#5
0
 public static Option <SimParameterSharedState> FindState(this Arr <SimParameterSharedState> parameterSharedStates, string name) =>
 parameterSharedStates.Find(pss => pss.Name == name);
示例#6
0
 public static SimParameter GetParameter(this Arr <SimParameter> parameters, string name) =>
 parameters.Find(p => p.Name == name).AssertSome($"Unknown parameter: {name}");
示例#7
0
 public static Option <SimParameter> FindParameter(this Arr <SimParameter> parameters, string name) =>
 parameters.Find(p => p.Name == name);
示例#8
0
 public static Option <SimEvidenceSource> FindEvidenceSource(this Arr <SimEvidenceSource> evidenceSources, string refHash) =>
 evidenceSources.Find(es => es.RefHash == refHash);
示例#9
0
 public static Option <SimObservationsSet> FindObservationsSet(this Arr <SimObservationsSet> observationsSets, string subject) =>
 observationsSets.Find(os => os.Subject == subject);