/// <summary> /// Tries to construct a power for <paramref name="voltageSource"/>, returns true on success /// </summary> /// <param name="element"></param> /// <returns></returns> private bool TryConstructPower(IACVoltageSource voltageSource) { return(false); // TODO: Adapt for new current resolution //// Try to get voltage drop across the element //if (_Currents.TryGet(voltageSource.ActiveComponentIndex, out var current)) //{ // // If successful, create a new power signal based on it, cache it // CachePower(voltageSource, new CharacteristicValuesPowerSignal( // // Min and max can't be calculated // double.NaN, // double.NaN, // // If there is only one phasor then average can be calculated, otherwise not // current.Phasors.Count() != 1 ? double.NaN : // current.Interpreter.RMS() * voltageSource.PeakProducedVoltage / Math.Sqrt(2) * Math.Cos(current.Phasors.First().Value.Phase))); // // // And return success // return true; //} //else //{ // // Return failure // return false; //} }
/// <summary> /// Gets information about power on an <see cref="IACVoltageSource"/>. If the <paramref name="current"/> is composed of /// phasors with different frequency than that of <paramref name="voltageSource"/> the average power will be assigned /// <see cref="Double.NaN"/> (it's impossible to calculate it using only phasors). Doesn't compute maximum/minimum /// instantenous power. /// </summary> /// <param name="current"></param> /// <param name="voltageSource"></param> /// <returns></returns> public ISignalInformation Get(IACVoltageSource voltageSource, bool voltageBA) => // Check if power can be enabled and if it can be fetched, if so return it, otherwise return null TryEnablePower(voltageSource) && _Cache.TryGetValue(voltageSource, out var power) ? power : null;
/// <summary> /// Gets information about power on an <see cref="IACVoltageSource"/>. If the <paramref name="current"/> is composed of /// phasors with different frequency than that of <paramref name="voltageSource"/> the average power will be assigned /// <see cref="Double.NaN"/> (it's impossible to calculate it using only phasors). Doesn't compute maximum/minimum /// instantenous power. /// </summary> /// <param name="current"></param> /// <param name="voltageSource"></param> /// <returns></returns> public ISignalInformation Get(IACVoltageSource voltageSource, bool voltageBA) => // Check if power can be enabled and if it can be fetched, if so return it, otherwise return null TryEnablePower(voltageSource, voltageBA) && _Cache.TryGetValue(Tuple.Create <IBaseComponent, bool>(voltageSource, voltageBA), out var power) ? power.Item2 : null;
/// <summary> /// Returns true if power for <paramref name="voltageSource"/> can be obtained from <see cref="_Cache"/> /// </summary> /// <param name="voltageSource"></param> /// <returns></returns> private bool TryEnablePower(IACVoltageSource voltageSource) => // Check if the cache already contains an entry, otherwise try to construct it _Cache.ContainsKey(voltageSource) || TryConstructPower(voltageSource);
/// <summary> /// Returns null /// </summary> /// <param name="current"></param> /// <param name="voltageSource"></param> /// <returns></returns> public ISignalInformation Get(IACVoltageSource voltageSource, bool voltageBA) => null;