// analyze a sample private static void Analyze(Vessel v, string filename, double amount) { // get vessel drive Drive drive = DB.Vessel(v).drive; // get sample Sample sample = drive.samples[filename]; // analyze, and produce data amount = Math.Min(amount, sample.size); bool completed = amount >= sample.size - double.Epsilon; drive.Delete_sample(filename, amount); drive.Record_file(filename, amount); // if the analysis is completed if (completed) { // inform the user Message.Post(Lib.BuildString(Lib.Color("cyan", Localizer.Format("#KERBALISM_Laboratory_Analysis"), true), "\n", Localizer.Format("#KERBALISM_Laboratory_Analyzed", Lib.Bold(v.vesselName), Lib.Bold(Science.Experiment(filename).name))), localized_results); // record landmark event if (!Lib.Landed(v)) { DB.landmarks.space_analysis = true; } } }
// remove a sample from a vessel public static void RemoveSample(Vessel v, string subject_id, double amount) { if (!Cache.VesselInfo(v).is_valid) { return; } Drive drive = DB.Vessel(v).drive; drive.Delete_sample(subject_id, amount); }
public void DumpData(ScienceData data) { // remove the data if (data.baseTransmitValue > float.Epsilon || data.transmitBonus > double.Epsilon) { drive.Delete_file(data.subjectID, data.dataAmount, null); } else { drive.Delete_sample(data.subjectID, data.dataAmount); } }
public void DumpData(ScienceData data) { SubjectData subjectData = ScienceDB.GetSubjectDataFromStockId(data.subjectID); // remove the data if (data.baseTransmitValue > float.Epsilon || data.transmitBonus > float.Epsilon) { drive.Delete_file(subjectData, data.dataAmount); } else { drive.Delete_sample(subjectData, data.dataAmount); } }
static void Render_sample(Panel p, uint partId, Sample sample, Drive drive, bool short_strings) { // render experiment name string exp_label = Lib.BuildString ( "<b>", Lib.Ellipsis(sample.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)), "</b> <size=", Styles.ScaleInteger(10).ToString(), ">", Lib.Ellipsis(sample.subjectData.SituationTitle, Styles.ScaleStringLength((short_strings ? 32 : 62) - Lib.Ellipsis(sample.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)).Length)), "</size>" ); string exp_tooltip = Lib.BuildString ( sample.subjectData.ExperimentTitle, "\n", Lib.Color(sample.subjectData.SituationTitle, Lib.Kolor.LightGrey) ); double exp_value = sample.size * sample.subjectData.SciencePerMB; if (exp_value >= 0.1) { exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value, false), "</b>"); } if (sample.mass > Double.Epsilon) { exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableMass(sample.mass), "</b>"); } if (!string.IsNullOrEmpty(sample.resultText)) { exp_tooltip = Lib.BuildString(exp_tooltip, "\n", Lib.WordWrapAtLength(sample.resultText, 50)); } p.AddContent(exp_label, Lib.HumanReadableSampleSize(sample.size), exp_tooltip, (Action)null, () => Highlighter.Set(partId, Color.cyan)); p.AddRightIcon(sample.analyze ? Textures.lab_cyan : Textures.lab_black, "Flag the file for analysis in a <b>laboratory</b>", () => { sample.analyze = !sample.analyze; }); p.AddRightIcon(Textures.toggle_red, "Dump the sample", () => { Lib.Popup("Warning!", Lib.BuildString("Do you really want to dump ", sample.subjectData.FullTitle, "?"), new DialogGUIButton("Dump it", () => drive.Delete_sample(sample.subjectData)), new DialogGUIButton("Keep it", () => { })); } ); }
public void DumpData(ScienceData data) { // get drive Drive drive = DB.Vessel(vessel).drive; // if not the preferred drive if (drive.location != part.flightID) { return; } // remove the data if (data.baseTransmitValue > float.Epsilon || data.transmitBonus > double.Epsilon) { drive.Delete_file(data.subjectID, data.dataAmount); } else { drive.Delete_sample(data.subjectID, data.dataAmount); } }
// analyze a sample private static Status Analyze(Vessel v, SubjectData subject, double amount) { Sample sample = null; Drive sampleDrive = null; foreach (var d in Drive.GetDrives(v, true)) { if (d.samples.ContainsKey(subject) && d.samples[subject].analyze) { sample = d.samples[subject]; sampleDrive = d; break; } } bool completed = false; if (sample != null) { completed = amount > sample.size; amount = Math.Min(amount, sample.size); } Drive fileDrive = Drive.FileDrive(v.KerbalismData(), amount); if (fileDrive == null) { return(Status.NO_STORAGE); } if (sample != null) { bool recorded = fileDrive.Record_file(subject, amount, false); double massRemoved = 0.0; if (recorded) { massRemoved = sampleDrive.Delete_sample(subject, amount); } else { Message.Post( Lib.Color(Lib.BuildString(Localizer.Format("#KERBALISM_Laboratory_Analysis"), " stopped"), Lib.Kolor.Red), "Not enough space on hard drive" ); return(Status.NO_STORAGE); } // return sample mass to experiment if needed if (massRemoved > 0.0) { RestoreSampleMass(v, subject, massRemoved); } } // if the analysis is completed if (completed) { if (!PreferencesScience.Instance.analyzeSamples) { // only inform the user if auto-analyze is turned off // otherwise we could be spamming "Analysis complete" messages Message.Post(Lib.BuildString(Lib.Color(Localizer.Format("#KERBALISM_Laboratory_Analysis"), Lib.Kolor.Science, true), "\n", Localizer.Format("#KERBALISM_Laboratory_Analyzed", Lib.Bold(v.vesselName), Lib.Bold(subject.FullTitle))), localized_results); } if (PreferencesScience.Instance.transmitScience) { fileDrive.Send(subject.Id, true); } // record landmark event if (!Lib.Landed(v)) { DB.landmarks.space_analysis = true; } } return(Status.RUNNING); }