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