/// <summary> /// Run every single experiment on a vessel /// </summary> /// <param name="onlyIncomplete"> /// Only run experiments that aren't complete. /// </param> public void RunEveryExperiment(bool onlyIncomplete) { IList <ScienceInstance> dsi = _filter.DisplayScienceInstances.Where(x => (!x.IsCollected || !onlyIncomplete)).ToList(); foreach (ScienceInstance s in dsi) { if (ModuleScienceExperiments != null && ModuleScienceExperiments.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = ModuleScienceExperiments.Where(x => (x.experimentID == s.ScienceExperiment.id && !(x.GetScienceCount() > 0) && !x.Inoperable)); foreach (ModuleScienceExperiment mse in lm) { _logger.Trace("Running Experiment " + mse.experimentID + " on part " + mse.part.partInfo.name); RunStandardModuleScienceExperiment(mse); } } if (DMModuleScienceAnimates != null && DMModuleScienceAnimates.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = DMModuleScienceAnimates.Where(x => (x.experimentID == s.ScienceExperiment.id && !x.Inoperable && DMagic.DMAPI.experimentCanConduct(x))); foreach (ModuleScienceExperiment mse in lm) { _logger.Trace("Running DMModuleScienceAnimates Experiment " + mse.experimentID + " on part " + mse.part.partInfo.name); DMagic.DMAPI.deployDMExperiment(mse); } } if (DMModuleScienceAnimateGenerics != null && DMModuleScienceAnimateGenerics.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = DMModuleScienceAnimateGenerics.Where(x => (x.experimentID == s.ScienceExperiment.id && !x.Inoperable && DMagic.DMModuleScienceAnimateGeneric.canConduct(x))); foreach (ModuleScienceExperiment mse in lm) { _logger.Trace("Running DMModuleScienceAnimateGenerics Experiment " + mse.experimentID + " on part " + mse.part.partInfo.name); DMagic.DMModuleScienceAnimateGeneric.gatherScienceData(mse); } } } }
/// <summary> /// Run an individual experiment. Don't run experiment if already has data or is not rerunnable and runSingleUse is false. /// </summary> public void RunExperiment(ScienceInstance s, bool runSingleUse = true) { //_logger.Trace("Finding Module for Science Report: " + s.ScienceExperiment.id); ModuleScienceExperiment m = null; if (ModuleScienceExperiments != null && ModuleScienceExperiments.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = ModuleScienceExperiments.Where(x => ( x.experimentID == s.ScienceExperiment.id && !(x.GetScienceCount() > 0) && (x.rerunnable || runSingleUse) && !x.Inoperable )); if (lm.Count() != 0) { m = lm.First(); } if (m != null) { _logger.Trace("Running Experiment " + m.experimentID + " on part " + m.part.partInfo.name); RunStandardModuleScienceExperiment(m); return; } } if (DMModuleScienceAnimates != null && DMModuleScienceAnimates.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = DMModuleScienceAnimates.Where(x => { return(x.experimentID == s.ScienceExperiment.id && !x.Inoperable && ((int)x.Fields.GetValue("experimentLimit") > 1 ? DMagic.DMAPI.experimentCanConduct(x) : DMagic.DMAPI.experimentCanConduct(x) && (x.rerunnable || runSingleUse))); }); if (lm.Count() != 0) { m = lm.First(); } if (m != null) { _logger.Trace("Running DMModuleScienceAnimates Experiment " + m.experimentID + " on part " + m.part.partInfo.name); DMagic.DMAPI.deployDMExperiment(m); return; } } if (DMModuleScienceAnimateGenerics != null && DMModuleScienceAnimateGenerics.Count > 0) { IEnumerable <ModuleScienceExperiment> lm = DMModuleScienceAnimateGenerics.Where(x => ( x.experimentID == s.ScienceExperiment.id && !x.Inoperable && ((int)x.Fields.GetValue("experimentLimit") > 1 ? DMagic.DMModuleScienceAnimateGeneric.canConduct(x) : DMagic.DMModuleScienceAnimateGeneric.canConduct(x) && (x.rerunnable || runSingleUse)) )); if (lm.Count() != 0) { m = lm.First(); } if (m != null) { _logger.Debug("Running DMModuleScienceAnimateGenerics Experiment " + m.experimentID + " on part " + m.part.partInfo.name); DMagic.DMModuleScienceAnimateGeneric.gatherScienceData(m); return; } } }