Example #1
0
            /// <summary>
            /// Updates the display for <paramref name="component"/>
            /// </summary>
            /// <param name="component"></param>
            public void Update(IBaseComponent component)
            {
                // Get the new info
                var newInfo = _CurrentSection.Current.Item1.GetInfo(component);

                // Assign it to proper properties
                Info            = newInfo.Item1;
                InterpretedInfo = newInfo.Item2;
            }
            /// <summary>
            /// Interprets the given signal and returns a sequence of strings ready to be displayed on the screen
            /// </summary>
            /// <param name="info"></param>
            /// <returns></returns>
            public IEnumerable <string> Get(ISignalInformation info)
            {
                // Return empty sequence for null info
                if (info == null)
                {
                    yield break;
                }

                // Characteristic signal information
                yield return(LineInfo("Minimum instantenous " + _SignalName, info.Minimum, _Unit));

                yield return(LineInfo("Maximum instantenous " + _SignalName, info.Maximum, _Unit));

                yield return(LineInfo("RMS " + _SignalName, info.RMS, _Unit));

                yield return(LineInfo("Average " + _SignalName, info.Average, _Unit));
            }
Example #3
0
 /// <summary>
 /// Tries to obtain current from the <see cref="_ActiveComponentsCache"/>, if successful assigns it to <paramref name="info"/>
 /// and returns true, otherwise assigns null to <paramref name="info"/> and returns false
 /// </summary>
 /// <param name="activeComponentIndex"></param>
 /// <param name="info"></param>
 /// <param name="reverseDirection">True if the direction is assumed to be standard, false if reversed</param>
 /// <returns></returns>
 protected bool TryGetActiveComponentCurrent(int activeComponentIndex, out ISignalInformation info, bool reverseDirection)
 {
     // Check if the current is in the cache (If it was not provided during object construction, it's not possible to
     // calculate it now)
     if (_ActiveComponentsCache.TryGetValue(
             new Tuple <int, bool>(activeComponentIndex, reverseDirection), out var currentPackage))
     {
         // If so, assign it and return success
         info = currentPackage.Item2;
         return(true);
     }
     else
     {
         // Otherwise assign null and return false
         info = null;
         return(false);
     }
 }
            /// <summary>
            /// Gets a current flow
            /// </summary>
            /// <param name="target"></param>
            /// <returns></returns>
            protected override ISignalInformation GetSignalInformation(IBaseComponent target)
            {
                // Get currents
                var results = IoC.Resolve <ISimulationResultsProvider>().Value.Current;

                // The info to get
                ISignalInformation info = null;

                // Get the results from provider and return its return value (lazy cases because we operate on interfaces)
                TypeSwitch.Construct().
                // For resistors no change in VI directions means that current flow is taken for voltage from node A (reference) to node B
                LazyCase <IResistor>((x) => info = results.Get(x, !target.ChangeVIDirections)).
                // For capacitors no change in VI directions means that current flow is taken for voltage from node A (reference) to node B
                LazyCase <ICapacitor>((x) => info = results.Get(x, !target.ChangeVIDirections)).
                // For active components no change in VI directions means that current flow is taken for voltage from node A (reference) to node B
                LazyCase <IActiveComponent>((x) => info = results.Get(x.Index, !target.ChangeVIDirections)).
                Switch(target);

                return(info);
            }
Example #5
0
            /// <summary>
            /// Gets a power on a component
            /// </summary>
            /// <param name="target"></param>
            /// <returns></returns>
            protected override ISignalInformation GetSignalInformation(IBaseComponent target)
            {
                // Get currents
                var results = IoC.Resolve <ISimulationResultsProvider>().Value.Power;

                // The info to get
                ISignalInformation info = null;

                // Get the results from provider and return its return value (lazy cases because we operate on interfaces)
                TypeSwitch.Construct().
                LazyCase <IResistor>((x) => info      = results.Get(x, target.ChangeVIDirections)).
                LazyCase <ICapacitor>((x) => info     = results.Get(x, target.ChangeVIDirections)).
                LazyCase <ICurrentSource>((x) => info = results.Get(x, target.ChangeVIDirections)).
                // Because IACVoltageSource extens IVoltageSource the check for that needs to be done manually so as not to
                // fetch the result twice (first only for IVoltageSource then for IACVoltageSource)
                LazyCase <IDCVoltageSource>((x) => info = results.Get(x, target.ChangeVIDirections)).
                LazyCase <IACVoltageSource>((x) => info = results.Get(x, target.ChangeVIDirections)).
                Switch(target);

                return(info);
            }
Example #6
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="source"></param>
 /// <exception cref="ArgumentNullException"></exception>
 public SignalInformation(ISignalInformation source)
 {
     Copy(source ?? throw new ArgumentNullException(nameof(source)));
 }