/// <summary> /// Transfers the specified source. /// </summary> /// <param name="src">The source.</param> /// <param name="srcIdx">Index of the source.</param> /// <param name="dest">The dest.</param> /// <param name="destIdx">Index of the dest.</param> /// <param name="amount">The amount.</param> /// <exception cref="System.Exception">Invalid transfer of feed</exception> private void Transfer(TSupplementRation src, int srcIdx, TSupplementRation dest, int destIdx, double amount) { if (srcIdx < 0 || srcIdx >= src.Count || destIdx < 0 || destIdx > dest.Count) throw new Exception("Invalid transfer of feed"); if (amount > 0.0) { if (destIdx < dest.Count) SuppIntoRation(dest, destIdx, src[srcIdx], amount); else { TSupplement copy = new TSupplement(); copy.Assign(src[srcIdx]); dest.Add(copy, amount); } src[srcIdx].Amount -= amount; } }
/// <summary> /// Assigns the specified source ration. /// </summary> /// <param name="srcRation">The source ration.</param> public void Assign(TSupplementRation srcRation) { Array.Resize(ref fSuppts, srcRation.Count); for (int idx = 0; idx < srcRation.Count; idx++) { if (fSuppts[idx] == null) fSuppts[idx] = new TSupplementItem(); fSuppts[idx].Assign(srcRation[idx]); } rationChoice = srcRation.rationChoice; }
/// <summary> /// Supps the into ration. /// </summary> /// <param name="ration">The ration.</param> /// <param name="idx">The index.</param> /// <param name="supp">The supp.</param> /// <param name="amount">The amount.</param> private void SuppIntoRation(TSupplementRation ration, int idx, TSupplement supp, double amount) { if (amount > 0.0) { double propn = amount / (amount + ration[idx].Amount); ration[idx].Mix(supp, ration[idx], propn); ration[idx].Amount += amount; } }