Exemplo n.º 1
0
 /// <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;
     //}
 }
Exemplo n.º 2
0
 /// <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;
Exemplo n.º 3
0
 /// <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;
Exemplo n.º 4
0
 /// <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);
Exemplo n.º 5
0
 /// <summary>
 /// Returns null
 /// </summary>
 /// <param name="current"></param>
 /// <param name="voltageSource"></param>
 /// <returns></returns>
 public ISignalInformation Get(IACVoltageSource voltageSource, bool voltageBA) => null;