Ejemplo n.º 1
0
        private static bool IsDTToSelf(DataRow dr)
        {
            int?StratumIdSource    = null;
            int StateClassIdSource = 0;
            int?StratumIdDest      = null;
            int?StateClassIdDest   = null;

            DTAnalyzer.GetDTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest);

            if (!StateClassIdDest.HasValue)
            {
                return(true);
            }

            if (StateClassIdSource == StateClassIdDest.Value)
            {
                if (!StratumIdDest.HasValue)
                {
                    return(true);
                }
                else
                {
                    return(NullableUtilities.NullableIdsEqual(StratumIdSource, StratumIdDest));
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void CreateOutgoingDTOffStratumCues(StateClassShape shape, DTAnalyzer analyzer)
        {
            //If there is no destination state class then it is a transition-to-self

            if (!shape.StateClassIdDest.HasValue)
            {
                return;
            }

            int?StratumIdActual = null;

            analyzer.ResolveStateClassStratum(shape.StratumIdSource, shape.StratumIdDest, shape.StateClassIdDest.Value, ref StratumIdActual);

            //If the class was found in the current stratum then it is not an off-stratum transition

            if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId))
            {
                return;
            }

            //If the class was found in the wild card stratum then it is not an off-stratum transition

            if (!StratumIdActual.HasValue)
            {
                return;
            }

            this.AddLine(CreateOutgoingDTOffStratumCue(shape));
        }
Ejemplo n.º 3
0
 private void CreateIncomingPTOffStratumCues(StateClassShape shape)
 {
     foreach (Transition t in shape.IncomingPT)
     {
         if (!NullableUtilities.NullableIdsEqual(t.StratumIdSource, shape.StratumIdSource))
         {
             this.AddLine(this.CreateIncomingPTOffStratumCue(shape, t));
         }
     }
 }
Ejemplo n.º 4
0
        private void CreateOutgoingDTLines(StateClassShape fromShape, DTAnalyzer analyzer)
        {
            //If there is no destination state class then it is a transition-to-self

            if (!fromShape.StateClassIdDest.HasValue)
            {
                return;
            }

            StateClassShape ToShape         = null;
            int?            StratumIdActual = null;

            analyzer.ResolveStateClassStratum(fromShape.StratumIdSource, fromShape.StratumIdDest, fromShape.StateClassIdDest.Value, ref StratumIdActual);

            if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId))
            {
                //If the class was found in the current stratum then it will be in the
                //explicit lookups if the current stratum is explicit and the wildcard
                //lookups if it is not.

                if (this.m_StratumId.HasValue)
                {
                    ToShape = this.m_ExplicitClasses[fromShape.StateClassIdDest.Value];
                }
                else
                {
                    ToShape = this.m_WildcardClasses[fromShape.StateClassIdDest.Value];
                }
            }
            else
            {
                //If the class was not found in the current stratum it will be in the
                //wild card lookups if its stratum is wild.

                if (this.m_StratumId.HasValue && (!StratumIdActual.HasValue))
                {
                    ToShape = this.m_WildcardClasses[fromShape.StateClassIdDest.Value];
                }
            }

            //If the class was not found or it is a transition-to-self then it is an
            //off stratum transition.  Otherwise, add an outgoing line.

            if ((ToShape != null) && (ToShape != fromShape))
            {
                DeterministicTransitionLine Line = new DeterministicTransitionLine(Constants.DETERMINISTIC_TRANSITION_LINE_COLOR);

                this.FillLineSegments(fromShape, ToShape, Line, BoxArrowDiagramConnectorMode.Horizontal);
                this.AddLine(Line);

                fromShape.OutgoingDTLines.Add(Line);
                ToShape.IncomingDTLines.Add(Line);
            }
        }
Ejemplo n.º 5
0
 private void CreateIncomingDTOffStratumCues(StateClassShape shape)
 {
     foreach (DeterministicTransition t in shape.IncomingDT)
     {
         if (!NullableUtilities.NullableIdsEqual(t.StratumIdSource, shape.StratumIdSource))
         {
             if (t.StratumIdSource.HasValue)
             {
                 DeterministicTransitionLine l = CreateIncomingDTOffStratumCue(shape);
                 this.AddLine(l);
             }
         }
     }
 }
        public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod)
        {
            base.Validate(proposedRow, transferMethod);

            int?StratumIdSource    = null;
            int StateClassIdSource = 0;
            int?StratumIdDest      = null;
            int?StateClassIdDest   = null;

            DTAnalyzer.GetDTFieldValues(proposedRow, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest);

            if (!StateClassIdDest.HasValue)
            {
                return;
            }

            if (StateClassIdDest.Value == StateClassIdSource)
            {
                if (!StratumIdDest.HasValue)
                {
                    return;
                }

                if (NullableUtilities.NullableIdsEqual(StratumIdSource, StratumIdDest))
                {
                    return;
                }
            }

            DTAnalyzer Analyzer = new DTAnalyzer(this.GetData(), this.Project);

            if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value))
            {
                Analyzer.ThrowDataException(StateClassIdDest.Value, true);
            }
        }
Ejemplo n.º 7
0
        private void CreateOutgoingPTOffStratumCues(StateClassShape shape, DTAnalyzer analyzer)
        {
            foreach (Transition t in shape.OutgoingPT)
            {
                //If it is a transition-to-self then it is not an off-stratum transition

                if (!t.StateClassIdDestination.HasValue)
                {
                    continue;
                }

                int?StratumIdActual = null;

                analyzer.ResolveStateClassStratum(
                    t.StratumIdSource,
                    t.StratumIdDestination,
                    t.StateClassIdDestination.Value,
                    ref StratumIdActual);

                //If the class was found in the current stratum then it is not an off-stratum transition

                if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId))
                {
                    continue;
                }

                //If the class was found in the wild card stratum then it is not an off-stratum transition

                if (!StratumIdActual.HasValue)
                {
                    continue;
                }

                this.AddLine(this.CreateOutgoingPTOffStratumCue(shape, t));
            }
        }
Ejemplo n.º 8
0
        private static void InternalChangeStateClassId(
            DataSheet dataSheet, string fromStratumColName, string fromStateClassColName,
            string toStratumColName, string toStateClassColname, int oldStateClassId, int newStateClassId, int?currentStratumId)
        {
            foreach (DataRow dr in dataSheet.GetData().Rows)
            {
                if (dr.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                int?StratumIdSource    = null;
                int StateClassIdSource = Convert.ToInt32(dr[fromStateClassColName], CultureInfo.InvariantCulture);
                int?StratumIdDest      = null;
                int?StateClassIdDest   = null;

                if (dr[fromStratumColName] != DBNull.Value)
                {
                    StratumIdSource = Convert.ToInt32(dr[fromStratumColName], CultureInfo.InvariantCulture);
                }

                if (dr[toStratumColName] != DBNull.Value)
                {
                    StratumIdDest = Convert.ToInt32(dr[toStratumColName], CultureInfo.InvariantCulture);
                }

                if (dr[toStateClassColname] != DBNull.Value)
                {
                    StateClassIdDest = Convert.ToInt32(dr[toStateClassColname], CultureInfo.InvariantCulture);
                }

                //If the FROM state class is the old ID then change it, but ONLY
                //if the FROM stratum is the current stratum.

                if (StateClassIdSource == oldStateClassId)
                {
                    if (NullableUtilities.NullableIdsEqual(StratumIdSource, currentStratumId))
                    {
                        dr[fromStateClassColName] = newStateClassId;
                    }
                }

                //If the TO state class is the old ID then change it, but only
                //if the TO stratum is the current stratum.

                if (!StateClassIdDest.HasValue)
                {
                    continue;
                }

                if (StateClassIdDest.Value == oldStateClassId)
                {
                    bool update = false;

                    if (currentStratumId.HasValue)
                    {
                        if (StratumIdDest.HasValue)
                        {
                            update = (StratumIdDest.Value == currentStratumId.Value);
                        }
                        else
                        {
                            update = NullableUtilities.NullableIdsEqual(StratumIdSource, currentStratumId.Value);
                        }
                    }
                    else
                    {
                        update = (!StratumIdDest.HasValue);
                    }

                    if (update)
                    {
                        dr[toStateClassColname] = newStateClassId;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private static bool PTClipObjectsEqual(ProbabilisticTransitionClipData t1, ProbabilisticTransitionClipData t2)
        {
            if (!NullableUtilities.NullableIdsEqual(t1.StratumIdSource, t2.StratumIdSource))
            {
                return(false);
            }

            if (t1.StateClassIdSource != t2.StateClassIdSource)
            {
                return(false);
            }

            if (!NullableUtilities.NullableIdsEqual(t1.StratumIdDest, t2.StratumIdDest))
            {
                return(false);
            }

            if (!NullableUtilities.NullableIdsEqual(t1.StateClassIdDest, t2.StateClassIdDest))
            {
                return(false);
            }

            if (t1.TransitionTypeId != t2.TransitionTypeId)
            {
                return(false);
            }

            if (t1.Proportion != t2.Proportion)
            {
                return(false);
            }

            if (t1.Probability != t2.Probability)
            {
                return(false);
            }

            if (t1.AgeMin != t2.AgeMin)
            {
                return(false);
            }

            if (t1.AgeMax != t2.AgeMax)
            {
                return(false);
            }

            if (t1.AgeRelative != t2.AgeRelative)
            {
                return(false);
            }

            if (t1.AgeReset != t2.AgeReset)
            {
                return(false);
            }

            if (t1.TstMin != t2.TstMin)
            {
                return(false);
            }

            if (t1.TstMax != t2.TstMax)
            {
                return(false);
            }

            if (t1.TstRelative != t2.TstRelative)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void CreateOutgoingPTLines(StateClassShape fromShape, DTAnalyzer analyzer)
        {
            foreach (Transition t in fromShape.OutgoingPT)
            {
                StateClassShape ToShape = null;

                //If there is no destination state class then it is a transition-to-self

                if (!t.StateClassIdDestination.HasValue)
                {
                    ToShape = fromShape;
                }
                else
                {
                    int?StratumIdActual = null;

                    analyzer.ResolveStateClassStratum(
                        t.StratumIdSource,
                        t.StratumIdDestination,
                        t.StateClassIdDestination.Value,
                        ref StratumIdActual);

                    if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId))
                    {
                        //If the class was found in the current stratum then it will be in the
                        //explicit lookups if the current stratum is explicit and the wildcard
                        //lookups if it is not.

                        if (this.m_StratumId.HasValue)
                        {
                            ToShape = this.m_ExplicitClasses[t.StateClassIdDestination.Value];
                        }
                        else
                        {
                            ToShape = this.m_WildcardClasses[t.StateClassIdDestination.Value];
                        }
                    }
                    else
                    {
                        //If the class was not found in the current stratum it will be in the
                        //wild card lookups if its stratum is wild.

                        if (this.m_StratumId.HasValue && (!StratumIdActual.HasValue))
                        {
                            ToShape = this.m_WildcardClasses[t.StateClassIdDestination.Value];
                        }
                    }
                }

                //If a shape was not found then it is an off-stratum transition.
                //Otherwise, create the approprate line and add it to the diagram.

                if (ToShape != null)
                {
                    ProbabilisticTransitionLine Line = null;

                    if (fromShape == ToShape)
                    {
                        Line = CreatePTLineToSelf(fromShape, t.TransitionTypeId);
                    }
                    else
                    {
                        Line = new ProbabilisticTransitionLine(t.TransitionTypeId, Constants.PROBABILISTIC_TRANSITION_LINE_COLOR);
                        this.FillLineSegments(fromShape, ToShape, Line, BoxArrowDiagramConnectorMode.Vertical);
                    }

                    this.FillPTLineTransitionGroups(Line);
                    this.AddLine(Line);

                    fromShape.OutgoingPTLines.Add(Line);
                    ToShape.IncomingPTLines.Add(Line);
                }
            }
        }