// add science data, creating new file or incrementing existing one public bool Record_file(SubjectData subjectData, double amount, bool allowImmediateTransmission = true, bool useStockCrediting = false) { if (dataCapacity >= 0 && FilesSize() + amount > dataCapacity) { return(false); } // create new data or get existing one File file; if (!files.TryGetValue(subjectData, out file)) { file = new File(subjectData, 0.0, useStockCrediting); files.Add(subjectData, file); if (!allowImmediateTransmission) { Send(subjectData.Id, false); } } // increase amount of data stored in the file file.size += amount; // keep track of data collected subjectData.AddDataCollectedInFlight(amount); return(true); }
// add science sample, creating new sample or incrementing existing one public bool Record_sample(SubjectData subjectData, double amount, double mass, bool useStockCrediting = false) { int currentSampleSlots = SamplesSize(); if (sampleCapacity >= 0) { if (!samples.ContainsKey(subjectData) && currentSampleSlots >= sampleCapacity) { // can't take a new sample if we're already at capacity return(false); } } Sample sample; if (samples.ContainsKey(subjectData) && sampleCapacity >= 0) { // test if adding the amount to the sample would exceed our capacity sample = samples[subjectData]; int existingSampleSlots = Lib.SampleSizeToSlots(sample.size); int newSampleSlots = Lib.SampleSizeToSlots(sample.size + amount); if (currentSampleSlots - existingSampleSlots + newSampleSlots > sampleCapacity) { return(false); } } // create new data or get existing one if (!samples.TryGetValue(subjectData, out sample)) { sample = new Sample(subjectData, 0.0, useStockCrediting); sample.analyze = PreferencesScience.Instance.analyzeSamples; samples.Add(subjectData, sample); } // increase amount of data stored in the sample sample.size += amount; sample.mass += mass; // keep track of data collected subjectData.AddDataCollectedInFlight(amount); return(true); }