Beispiel #1
0
 public override void Check(ArcChart chart)
 {
     // foreach (var h in chart.Holds)
     // {
     //     foreach (var t in chart.Timings)
     //     {
     //         if (t.Timing > h.Timing && t.Timing < h.EndTiming)
     //         {
     //             Faults.Add(h);
     //         }
     //     }
     // }
     foreach (var a in chart.Arcs)
     {
         foreach (var t in chart.Timings)
         {
             if (t.Timing > a.Timing && t.Timing < a.EndTiming)
             {
                 if (Mathf.Approximately(a.XStart, a.XEnd) && Mathf.Approximately(a.YStart, a.YEnd))
                 {
                     continue;
                 }
                 Faults.Add(a);
             }
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #2
0
 public Jp2KrDesignVM() : base(null, null)
 {
     Ongoings.Add(new TestLabelProgressVM());
     Ongoings.Add(new TestLabelProgressVM());
     Faults.Add(new TestLabelProgressVM());
     Progress = new TestLabelProgressVM();
 }
Beispiel #3
0
        private Task ParallelForEach(Func <TranslationUnit, Jp2KrWork> genViewModel)
        {
            List <TranslationUnit> transUnits = translations ?? FindTranslations().ToList();
            int complete = 0;

            Progress.Value = 0;
            Progress.Label = $"{workKind}{complete} / {transUnits.Count}";

            return(transUnits.ForEachPinnedAsync(coreCount, async t => {
                Jp2KrWork item = genViewModel(t);
                Ongoings.Add(item.Progress);
                try {
                    await Task.Run(() => item.Process());
                }
                catch (EhndNotFoundException) {
                    Progress.Foreground = LabelProgressVM.FgError;
                    throw;
                }
                catch (Exception e) {
                    Progress.Foreground = LabelProgressVM.FgError;
                    string msg = e is RegexMatchTimeoutException
            ? "정규식 검색이 너무 오래 걸립니다. 정규식을 점검해주세요."
            : e.Message;
                    item.SetProgress(TranslationPhase.Error, 100, msg);
                    Faults.Add(item.Progress);
                    Exceptions.Add(e);
                }
                finally {
                    _ = Ongoings.Remove(item.Progress);
                    complete++;
                    Progress.Value = (double)complete / transUnits.Count * 100;
                    Progress.Label = $"{workKind}{complete} / {transUnits.Count}";
                }
            }));
        }
Beispiel #4
0
        public override void Check(ArcChart chart)
        {
            List <(ArcArcTap, float, float)> ats = new List <(ArcArcTap, float, float)>();

            foreach (var arc in chart.Arcs)
            {
                foreach (var at in arc.ArcTaps)
                {
                    float t = 1f * (at.Timing - arc.Timing) / (arc.EndTiming - arc.Timing);
                    float x = ArcAlgorithm.X(arc.XStart, arc.XEnd, t, arc.LineType);
                    float y = ArcAlgorithm.Y(arc.YStart, arc.YEnd, t, arc.LineType);
                    ats.Add((at, x, y));
                }
            }
            for (int i = 0; i < ats.Count - 1; ++i)
            {
                for (int k = i + 1; k < ats.Count; ++k)
                {
                    if (ats[i].Item2 == ats[k].Item2 &&
                        ats[i].Item3 == ats[k].Item3 &&
                        ats[i].Item1.Timing == ats[k].Item1.Timing)
                    {
                        Faults.Add(ats[i].Item1);
                    }
                }
            }
            Faults = Faults.Distinct().ToList();
        }
Beispiel #5
0
        public void SetAnalysisMode(AnalysisMode mode)
        {
            ObserverController.Mode = mode;
            var agents = ObserverController.Agents;

            switch (mode)
            {
            case AnalysisMode.TolerableFaults:
                agents.Select(agent => agent.ConfigurationUpdateFailed).SuppressActivations();
                Workpieces.Select(workpiece => workpiece.IncorrectlyPositionedFault).SuppressActivations();
                Workpieces.Select(workpiece => workpiece.ToolApplicationFailed).SuppressActivations();
                Robots.Select(robot => robot.SwitchToWrongToolFault).SuppressActivations();
                Carts.Select(cart => cart.Lost).SuppressActivations();
                ObserverController.ReconfigurationFailure.SuppressActivation();
                break;

            case AnalysisMode.IntolerableFaults:
                Faults.SuppressActivations();
                agents.Select(agent => agent.ConfigurationUpdateFailed).MakeNondeterministic();
                Workpieces.Select(workpiece => workpiece.IncorrectlyPositionedFault).MakeNondeterministic();
                Workpieces.Select(workpiece => workpiece.ToolApplicationFailed).MakeNondeterministic();
                Robots.Select(robot => robot.SwitchToWrongToolFault).MakeNondeterministic();
                Carts.Select(cart => cart.Lost).MakeNondeterministic();
                ObserverController.ReconfigurationFailure.MakeNondeterministic();
                break;

            case AnalysisMode.AllFaults:
                return;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }
        }
Beispiel #6
0
        /// <summary>
        ///   Creates a counter example from the <paramref name="path" />.
        /// </summary>
        /// <param name="createModel">The factory function that can be used to create new instances of this model.</param>
        /// <param name="path">
        ///   The path the counter example should be generated from. A value of <c>null</c> indicates that no
        ///   transitions could be generated for the model.
        /// </param>
        /// <param name="endsWithException">Indicates whether the counter example ends with an exception.</param>
        public CounterExample CreateCounterExample(CoupledExecutableModelCreator <TExecutableModel> createModel, byte[][] path, bool endsWithException)
        {
            Requires.NotNull(createModel, nameof(createModel));

            // We have to create new model instances to generate and initialize the counter example, otherwise hidden
            // state variables might prevent us from doing so if they somehow influence the state
            var replayModel    = createModel.Create(StateHeaderBytes);
            var choiceResolver = new NondeterministicChoiceResolver(true);

            replayModel.SetChoiceResolver(choiceResolver);

            CopyFaultActivationStates(replayModel);
            var faultActivations = Faults.Select(fault => fault.Activation).ToArray();

            // Prepend the construction state to the path; if the path is null, at least one further state must be added
            // to enable counter example debugging.
            // Also, get the replay information, i.e., the nondeterministic choices that were made on the path; if the path is null,
            // we still have to get the choices that caused the problem.

            if (path == null)
            {
                path = new[] { new byte[StateVectorSize] }
            }
            ;

            path = new[] { ConstructionState }.Concat(path).ToArray();
            var replayInfo = replayModel.GenerateReplayInformation(choiceResolver, path, endsWithException);

            return(new CounterExample(path, replayInfo, endsWithException, faultActivations));
        }
Beispiel #7
0
        public RpdChannelViewModel(IRpdChannel channel, RpdMeterViewModel meter)
        {
            _channel       = channel;
            TrendChartType = TrendChartType.Rpd;
            Meter          = meter;

            Faults.Add(meter.Fault);
        }
Beispiel #8
0
 /// <summary>
 ///   Updates the fault sets in accordance with the fault's actual activation states.
 /// </summary>
 public void UpdateFaultSets()
 {
     NondeterministicFaults    = Faults.Where(fault => fault.Activation == Activation.Nondeterministic).ToArray();
     ActivationSensitiveFaults = NondeterministicFaults.Where(fault => fault.RequiresActivationNotification).ToArray();
     OnStartOfStepFaults       = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnStartOfStep).ToArray();
     OnMethodCallFaults        = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnMethodCall).ToArray();
     OnCustomFaults            = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnCustom).ToArray();
 }
        public IFaultablePort AppendFault(Exception e)
        {
            var fault = e.Message;

            Faults = Faults ?? new List <string>();
            Faults.Add(fault);

            return(this);
        }
Beispiel #10
0
        void FillFaults()
        {
            for (int i = 0; i < Section.Faults.Count; i++)
            {
                Faults.Add(new FaultViewModel(Section.Faults[i]));
            }

            _faultsLinker = new ObservableCollectionsConnector <IFaultLog, IFaultViewModel>(Section.Faults, Faults, ConstructNewFault,
                                                                                            log => Faults.FirstOrDefault(e => e.Fault == log));
        }
Beispiel #11
0
 public override void Check(ArcChart chart)
 {
     foreach (var h in chart.Holds)
     {
         if (h.EndTiming <= h.Timing)
         {
             Faults.Add(h);
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #12
0
        private void GetData()
        {
            byte[] raw = new byte[4];
            _device.Read(raw);
            Array.Reverse(raw);
            var data = BitConverter.ToInt32(raw, 0);

            //check for fault
            switch (data & 0x07) // first three bits are faults 0b111, if all are 0 then we have good data
            {
            case 0x0:
                _fault = Faults.OK;
                break;

            case 0x1:
                _fault = Faults.OPEN_CIRCUIT;
                break;

            case 0x2:
                _fault = Faults.SHORT_TO_GND;
                break;

            case 0x4:
                _fault = Faults.SHORT_TO_VCC;
                break;

            default:
                _fault = Faults.GENERAL_FAULT;
                break;
            }

            if (_fault != Faults.OK)
            {
                _temperature = double.NaN;
                _internal    = double.NaN;
            }

            data    >>= 4;                       // shift right 4 spaces (the fourth space is unused)
            _internal = (data & 0x7FF) * 0.0625; // 7FF = 0b11111111111, 11 bits for the temp + 1 for the sign bit (see below)

            if ((data & 0x800) != 0)             //check negative sign bit 0b100000000000
            {
                _internal += -128;
            }

            data >>= 14;                           //trim off everything except the thermocouple temperature, i.e. shift right the 14 bits of the internal temp bits

            _temperature = (data & 0x1FFF) * 0.25; // 1FFF = 0b1111111111111, 13 bits for the temp + 1 for the sign bit

            if ((data & 0x02000) != 0)             //check negative sign bit (14th bit from the right) 0b10000000000000
            {
                _temperature += -2048;
            }
        }
Beispiel #13
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="serializedData">The serialized data describing the model.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal RuntimeModel(SerializedRuntimeModel serializedData, int stateHeaderBytes = 0)
        {
            Requires.That(serializedData.Model != null, "Expected a valid model instance.");

            var buffer         = serializedData.Buffer;
            var rootComponents = serializedData.Model.Roots;
            var objectTable    = serializedData.ObjectTable;
            var formulas       = serializedData.Formulas;

            Requires.NotNull(buffer, nameof(buffer));
            Requires.NotNull(rootComponents, nameof(rootComponents));
            Requires.NotNull(objectTable, nameof(objectTable));
            Requires.NotNull(formulas, nameof(formulas));
            Requires.That(stateHeaderBytes % 4 == 0, nameof(stateHeaderBytes), "Expected a multiple of 4.");

            Model                     = serializedData.Model;
            SerializedModel           = buffer;
            RootComponents            = rootComponents.Cast <Component>().ToArray();
            Faults                    = objectTable.OfType <Fault>().Where(fault => fault.Activation == Activation.Nondeterministic && fault.IsUsed).ToArray();
            ActivationSensitiveFaults = Faults.Where(fault => fault.RequiresActivationNotification).ToArray();
            StateFormulas             = objectTable.OfType <StateFormula>().ToArray();
            Formulas                  = formulas;

            // Create a local object table just for the objects referenced by the model; only these objects
            // have to be serialized and deserialized. The local object table does not contain, for instance,
            // the closure types of the state formulas
            var objects             = Model.ReferencedObjects;
            var deterministicFaults = objectTable.OfType <Fault>().Where(fault => fault.Activation != Activation.Nondeterministic);

            _serializedObjects = new ObjectTable(objects.Except(deterministicFaults, ReferenceEqualityComparer <object> .Default));
            Objects            = objectTable;

            StateVectorLayout = SerializationRegistry.Default.GetStateVectorLayout(Model, _serializedObjects, SerializationMode.Optimized);

            _deserialize      = StateVectorLayout.CreateDeserializer(_serializedObjects);
            _serialize        = StateVectorLayout.CreateSerializer(_serializedObjects);
            _restrictRanges   = StateVectorLayout.CreateRangeRestrictor(_serializedObjects);
            _stateHeaderBytes = stateHeaderBytes;

            PortBinding.BindAll(objectTable);
            _choiceResolver = new ChoiceResolver(objectTable);

            ConstructionState = new byte[StateVectorSize];
            fixed(byte *state = ConstructionState)
            {
                Serialize(state);
                _restrictRanges();
            }

            FaultSet.CheckFaultCount(Faults.Length);
            StateFormulaSet.CheckFormulaCount(StateFormulas.Length);
        }
Beispiel #14
0
 public void AddFault(Fault fault)
 {
     if (Faults == null)
     {
         Faults = new List <Fault>
         {
             fault
         };
     }
     else
     {
         Faults.Add(fault);
     }
 }
Beispiel #15
0
 public override void Check(ArcChart chart)
 {
     foreach (var h in chart.Holds)
     {
         foreach (var t in chart.Taps)
         {
             if (t.Timing >= h.Timing && t.Timing <= h.EndTiming &&
                 t.Track == h.Track)
             {
                 Faults.Add(t);
             }
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #16
0
 public override void Check(ArcChart chart)
 {
     for (int i = 0; i < chart.Taps.Count - 1; ++i)
     {
         for (int k = i + 1; k < chart.Taps.Count; ++k)
         {
             if (chart.Taps[i].Timing == chart.Taps[k].Timing &&
                 chart.Taps[i].Track == chart.Taps[k].Track)
             {
                 Faults.Add(chart.Taps[i]);
             }
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #17
0
 public override void Check(ArcChart chart)
 {
     foreach (var a in chart.Arcs)
     {
         if (a.EndTiming <= a.Timing)
         {
             if (a.XEnd == a.XStart)
             {
                 if (a.YEnd == a.YStart)
                 {
                     Faults.Add(a);
                 }
             }
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #18
0
        protected override async Task HandleCommand(UpdateProductCommand command)
        {
            Models.Product product = await _readOnlyProductRepository.GetProductAsync(command.ProductId).ConfigureAwait(false);

            if (product == null)
            {
                throw new NotFoundException(new Fault {
                    Reason = "ResourceNotFound", Message = PRODUCT_NOT_FOUND
                });
            }

            bool wasCodeChanged = product.Code != command.Code;

            if (wasCodeChanged)
            {
                var productByCode = await _readOnlyProductRepository.GetProductByCodeAsync(command.Code).ConfigureAwait(false);

                ProductValidator.ValidateProductCode(Faults, productByCode, command.Code);
                if (Faults.Any())
                {
                    var exception = new ValidationException();
                    exception.AddErrors(Faults);
                    throw exception;
                }
            }

            product.LastUpdated = DateTime.Now;
            product.Name        = command.Name;
            product.Code        = command.Code;
            product.Price       = command.Price;

            if (!string.IsNullOrEmpty(command.FileContent) && !string.IsNullOrEmpty(command.FileTitle))
            {
                byte[] imageBytes = Convert.FromBase64String(command.FileContent);

                HandleProductImage(command, product, imageBytes);
                HandleProductImageThumbnail(command, product, imageBytes);
            }

            await _writeOnlyProductRepository.UpdateAsync().ConfigureAwait(false);
        }
 public override void Check(ArcChart chart)
 {
     foreach (var h in chart.Holds)
     {
         foreach (var t in chart.Timings)
         {
             if (t.Timing > h.Timing && t.Timing < h.EndTiming)
             {
                 Faults.Add(h);
             }
         }
     }
     foreach (var a in chart.Arcs)
     {
         foreach (var t in chart.Timings)
         {
             if (t.Timing > a.Timing && t.Timing < a.EndTiming)
             {
                 Faults.Add(a);
             }
         }
     }
     Faults = Faults.Distinct().ToList();
 }
Beispiel #20
0
 public ErrorCode GetStickyFaults(Faults toFill)
 {
     return(_ll.GetStickyFaults(toFill));
 }
        /// <summary>
        /// Method to obtain all the faults as a result of the validation of the html
        /// </summary>
        /// <param name="htmlValid">Boolean that will indicate if the document is or not valid html.</param>
        /// <param name="urlDocument">Xml document that represents the result of the validation</param>
        /// <param name="envNamespace">Namespace using to obtain some data such as line, colum, etc.</param>
        /// <param name="mNamespace">Namespace using to obtain some data such as line, colum, etc.</param>
        private void HTMLFaults(XDocument urlDocument, XNamespace envNamespace, XNamespace mNamespace)
        {
            faults = new Faults();

            //Obtaining the descendants of the elements labeled "Fault". With this we obtain all the faults
            var faultElement = from e in urlDocument.Descendants(envNamespace + "Fault")
                               select e;

            //Obtaining the descendants of the elements labeled "Detail". With this we obtain the details of the fault 
            var faultDetail = from e in faultElement.Descendants(envNamespace + "Detail")
                              select e;

            //Obtaining the descendants of the elements labeled "Text". With this we obtain the reason text of the fault
            var faultReason = from e in faultElement.Descendants(envNamespace + "Text")
                              select e;

            //Iterate over the fault elements
            foreach (var element in faultElement)
            {
                //Create a new instance of the class Fault
                Fault fault = new Fault();

                //Iterate over the fault reason
                foreach (var reason in faultReason)
                {
                    //Store the value of the reason into de instance of the fault
                    fault.reason = reason.Value;
                }
                //Iterate over the fault detail
                foreach (var e in faultDetail)
                {
                    //Store the value of the messageid and errordetail
                    fault.messageid = e.Descendants(mNamespace + "messageid").First().Value;
                    fault.errorDetail = e.Descendants(mNamespace + "errordetail").First().Value;
                }

                //Insert the fault in the list of faults
                faults.Add(fault);
            }
        }
Beispiel #22
0
 /// <summary>
 /// get (the) local authority for...
 /// </summary>
 /// <param name="theTouchpoint">the touchpoint</param>
 /// <param name="theLADCode">the local adinistrative district code</param>
 /// <param name="inScope">in scope</param>
 /// <returns>the result of the operation</returns>
 public async Task <HttpResponseMessage> GetAuthorityFor(string theTouchpoint, string theLADCode, IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessGetAuthorityFor(theTouchpoint, theLADCode, inScope), x => Faults.GetResponseFor(x, inScope));
 /// <summary>
 /// delete an area routing detail using...
 /// </summary>
 /// <param name="theTouchpointID">the touchpoint id</param>
 /// <param name="inScope">in logging scope</param>
 /// <returns>the currently running task containing the response message (success or fail)</returns>
 public async Task <HttpResponseMessage> DeleteAreaRoutingDetailUsing(string theTouchpointID, IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessDeleteAreaRoutingDetailUsing(theTouchpointID, inScope), x => Faults.GetResponseFor(x, TypeOfFunction.Delete, inScope));
Beispiel #24
0
 public IEnumerator <ServiceFaultDetail> GetEnumerator()
 {
     return(Faults.GetEnumerator());
 }
Beispiel #25
0
 /// <summary>
 ///   Updates the fault sets in accordance with the fault's actual activation states.
 /// </summary>
 public void UpdateFaultSets()
 {
     NondeterministicFaults    = Faults.Where(fault => fault.Activation == Activation.Nondeterministic).ToArray();
     ActivationSensitiveFaults = NondeterministicFaults.Where(fault => fault.RequiresActivationNotification).ToArray();
 }
 /// <summary>
 /// Constructor with parameters
 /// </summary>
 public HTMLValidate(string url)
 {
     errors = new Errors();
     warnings = new Warnings();
     warningPotentialIssues = new WarningPotentialIssues();
     faults = new Faults();
     this.URL = url;
 }
 /// <summary>
 /// get (the) area routing detail by...
 /// excluded from coverage as moq doesn't support the lambda complexity for this routine
 /// </summary>
 /// <param name="theLocation">the location</param>
 /// <param name="inScope">in logging scope</param>
 /// <returns>the currently running task containing the response message (success or fail)</returns>
 public async Task <HttpResponseMessage> GetAreaRoutingDetailBy(string theLocation, IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessGetAreaRoutingDetailBy(theLocation, inScope), x => Faults.GetResponseFor(x, TypeOfFunction.GetByLocation, inScope));
Beispiel #28
0
 /// <summary>
 /// add new authority for...
 /// </summary>
 /// <param name="theTouchpoint">the touchpoint</param>
 /// <param name="usingContent">using content</param>
 /// <param name="inScope">in scope</param>
 /// <returns>the result of the operation</returns>
 public async Task <HttpResponseMessage> AddNewAuthorityFor(string theTouchpoint, string usingContent, IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessAddNewAuthorityFor(theTouchpoint, usingContent, inScope), x => Faults.GetResponseFor(x, inScope));
 /// <summary>
 /// get all route id's
 /// </summary>
 /// <param name="inScope">in logging scope</param>
 /// <returns>the currently running task containing the response message (success or fail)</returns>
 public async Task <HttpResponseMessage> GetAllRouteIDs(IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessGetAllRouteIDs(inScope), x => Faults.GetResponseFor(x, TypeOfFunction.GetAll, inScope));
        /// <summary>
        ///   Returns a string representation of the minimal critical fault sets.
        /// </summary>
        public override string ToString()
        {
            var builder        = new StringBuilder();
            var percentage     = CheckedSetCount / (double)(1L << Faults.Count()) * 100;
            var cardinalitySum = MinimalCriticalSets.Sum(set => set.Count);
            var minimalSetCardinalityAverage = cardinalitySum == 0 ? 0 : cardinalitySum / (double)MinimalCriticalSets.Count;

            builder.AppendLine();
            builder.AppendLine("=======================================================================");
            builder.AppendLine("=======      Deductive Cause Consequence Analysis: Results      =======");
            builder.AppendLine("=======================================================================");
            builder.AppendLine();

            if (Exceptions.Any())
            {
                builder.AppendLine("*** Warning: Unhandled exceptions have been thrown during the analysis. ***");
                builder.AppendLine();
            }

            if (!IsComplete)
            {
                builder.AppendLine("*** Warning: Analysis might be incomplete; not all fault sets have been checked. ***");
                builder.AppendLine();
            }

            Func <IEnumerable <Fault>, string> getFaultString =
                faults => String.Join(", ", faults.Select(fault => fault.Name).OrderBy(name => name));

            builder.AppendLine($"Elapsed Time: {Time}");
            builder.AppendLine($"Fault Count: {Faults.Count()}");
            builder.AppendLine($"Faults: {getFaultString(Faults)}");

            if (ForcedFaults.Any())
            {
                builder.AppendLine($"Forced Faults: {getFaultString(ForcedFaults)}");
            }

            if (SuppressedFaults.Any())
            {
                builder.AppendLine($"Suppressed Faults: {getFaultString(SuppressedFaults)}");
            }

            builder.AppendLine();
            builder.AppendLine($"Checked Fault Sets: {CheckedSetCount} ({percentage:F0}% of all fault sets)");
            builder.AppendLine($"Minimal Critical Sets: {MinimalCriticalSets.Count}");
            builder.AppendLine($"Average Minimal Critical Set Cardinality: {minimalSetCardinalityAverage:F1}");
            builder.AppendLine();

            var i = 1;

            foreach (var criticalSet in MinimalCriticalSets)
            {
                builder.AppendFormat("   ({1}) {{ {0} }}", String.Join(", ", criticalSet.Select(fault => fault.Name).OrderBy(name => name)), i++);

                Exception e;
                if (Exceptions.TryGetValue(criticalSet, out e))
                {
                    builder.AppendLine();
                    builder.Append(
                        $"    An unhandled exception of type {e.GetType().FullName} was thrown while checking the fault set: {e.Message}");
                }

                builder.AppendLine();
            }

            var heuristicCount = Heuristics.Count();

            if (heuristicCount != 0)
            {
                builder.AppendLine();

                if (HeuristicSuggestionCount == 0)
                {
                    builder.AppendLine("No suggestions were made by the heuristics.");
                }
                else
                {
                    var nonTriviallyCritical         = HeuristicSuggestionCount - HeuristicNonTrivialSafeCount - HeuristicTrivialCount;
                    var percentageTrivial            = HeuristicTrivialCount / (double)(HeuristicSuggestionCount) * 100;
                    var percentageNonTrivialSafe     = HeuristicNonTrivialSafeCount / (double)(HeuristicSuggestionCount) * 100;
                    var percentageNonTrivialCritical = nonTriviallyCritical / (double)(HeuristicSuggestionCount) * 100;

                    builder.AppendLine($"Of {HeuristicSuggestionCount} fault sets suggested by {heuristicCount} heuristics");
                    builder.AppendLine($"    {HeuristicTrivialCount} ({percentageTrivial:F0}%) were trivially safe or trivially critical,");
                    builder.AppendLine($"    {HeuristicNonTrivialSafeCount} ({percentageNonTrivialSafe:F0}%) were non-trivially safe, and");
                    builder.AppendLine($"    {nonTriviallyCritical} ({percentageNonTrivialCritical:F0}%) were non-trivially critical.");
                    builder.AppendLine($"In total, {TrivialChecksCount} trivial checks were performed.");
                }
            }

            return(builder.ToString());
        }
Beispiel #31
0
            /// <summary>
            ///   Returns a string representation of the minimal critical fault sets.
            /// </summary>
            public override string ToString()
            {
                var builder    = new StringBuilder();
                var percentage = CheckedSets.Count / (float)(1 << Faults.Count()) * 100;

                builder.AppendLine();
                builder.AppendLine("=======================================================================");
                builder.AppendLine("=======      Deductive Cause Consequence Analysis: Results      =======");
                builder.AppendLine("=======================================================================");
                builder.AppendLine();

                if (Exceptions.Any())
                {
                    builder.AppendLine("*** Warning: Unhandled exceptions have been thrown during the analysis. ***");
                    builder.AppendLine();
                }

                if (!IsComplete)
                {
                    builder.AppendLine("*** Warning: Analysis might be incomplete; not all fault sets have been checked. ***");
                    builder.AppendLine();
                }

                Func <IEnumerable <Fault>, string> getFaultString =
                    faults => String.Join(", ", faults.Select(fault => fault.Name).OrderBy(name => name));

                builder.AppendFormat("Elapsed Time: {0}", Time);
                builder.AppendLine();
                builder.AppendFormat("Fault Count: {0}", Faults.Count());
                builder.AppendLine();
                builder.AppendFormat("Faults: {0}", getFaultString(Faults));
                builder.AppendLine();

                if (ForcedFaults.Any())
                {
                    builder.AppendFormat("Forced Faults: {0}", getFaultString(ForcedFaults));
                    builder.AppendLine();
                }

                if (SuppressedFaults.Any())
                {
                    builder.AppendFormat("Suppressed Faults: {0}", getFaultString(SuppressedFaults));
                    builder.AppendLine();
                }

                builder.AppendLine();

                builder.AppendFormat("Checked Fault Sets: {0} ({1:F0}% of all fault sets)", CheckedSets.Count, percentage);
                builder.AppendLine();

                builder.AppendFormat("Minimal Critical Sets: {0}", MinimalCriticalSets.Count);
                builder.AppendLine();
                builder.AppendLine();

                var i = 1;

                foreach (var criticalSet in MinimalCriticalSets)
                {
                    builder.AppendFormat("   ({1}) {{ {0} }}", String.Join(", ", criticalSet.Select(fault => fault.Name).OrderBy(name => name)), i++);

                    Exception e;
                    if (Exceptions.TryGetValue(criticalSet, out e))
                    {
                        builder.AppendLine();
                        builder.AppendFormat(
                            "    An unhandled exception of type {0} was thrown while checking the fault set: {1}",
                            e.GetType().FullName, e.Message);
                    }

                    builder.AppendLine();
                }

                return(builder.ToString());
            }
 /// <summary>
 /// add new area routing detail
 /// excluded from coverage as moq doesn't support the lambda complexity for this routine
 /// </summary>
 /// <param name="theTouchpoint">the touchpoint</param>
 /// <param name="usingContent">using content</param>
 /// <param name="inScope">in scope</param>
 /// <returns>the result of the operation</returns>
 public async Task <HttpResponseMessage> AddAreaRoutingDetailUsing(string theContent, IScopeLoggingContext inScope) =>
 await SafeOperations.Try(() => ProcessAddAreaRoutingDetailUsing(theContent, inScope), x => Faults.GetResponseFor(x, TypeOfFunction.Post, inScope));