Example #1
0
        // remove science sample, deleting the sample when it is empty
        public double Delete_sample(SubjectData subjectData, double amount = 0.0)
        {
            // get data
            Sample sample;

            if (samples.TryGetValue(subjectData, out sample))
            {
                // decrease amount of data stored in the sample
                if (amount == 0.0)
                {
                    amount = sample.size;
                }
                else
                {
                    amount = Math.Min(amount, sample.size);
                }

                double massDelta = sample.mass * amount / sample.size;
                sample.size -= amount;
                sample.mass -= massDelta;

                // keep track of data collected
                subjectData.RemoveDataCollectedInFlight(amount);

                // remove sample if empty
                if (sample.size <= 0.0)
                {
                    samples.Remove(subjectData);
                }

                return(massDelta);
            }
            return(0.0);
        }
Example #2
0
        // remove science data, deleting the file when it is empty
        public void Delete_file(SubjectData subjectData, double amount = 0.0)
        {
            // get data
            File file;

            if (files.TryGetValue(subjectData, out file))
            {
                // decrease amount of data stored in the file
                if (amount == 0.0)
                {
                    amount = file.size;
                }
                else
                {
                    amount = Math.Min(amount, file.size);
                }

                file.size -= amount;

                // keep track of data collected
                subjectData.RemoveDataCollectedInFlight(amount);

                // remove file if empty
                if (file.size <= 0.0)
                {
                    files.Remove(subjectData);
                }
            }
        }