/// <summary> /// A verbose string representation of the <see cref="LinearStateEstimator.Modeling.CircuitBreaker"/> and can be used for detailed text based output via a console or a text file. /// </summary> /// <returns>A verbose string representation of the <see cref="LinearStateEstimator.Modeling.CircuitBreaker"/>.</returns> public new string ToVerboseString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(); stringBuilder.AppendFormat("----- Circuit Breaker ----------------------------------------------------------"); stringBuilder.AppendLine(); stringBuilder.AppendFormat(" InternalID: " + InternalID.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Number: " + Number.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Name: " + Name + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Description: " + Description + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Can Infer State: " + CanInferState.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat("Group A Reported: " + CrossDevicePhasors.GroupAWasReported + "{0}", Environment.NewLine); stringBuilder.AppendFormat("Group B Reported: " + CrossDevicePhasors.GroupBWasReported + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Normal: " + NormalState.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Actual: " + ActualState.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Measured: " + MeasuredState.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Measured Open: " + IsMeasuredOpen.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Measured Closed: " + IsMeasuredClosed.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Inferred Open: " + IsInferredOpen.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Inferred Closed: " + IsInferredClosed.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Is Open: " + IsOpen.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Is Closed: " + IsClosed.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" In Pruning Mode: " + InPruningMode.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Manual: " + InManualOverrideMode.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" FromNode: " + FromNode.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" ToNode: " + ToNode.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat("ParentSubstation: " + m_parentSubstation.ToString() + "{0}", Environment.NewLine); stringBuilder.AppendFormat(" Status: {0}", Environment.NewLine); stringBuilder.AppendFormat(m_breakerStatus.ToStatusString() + "{0}", Environment.NewLine); stringBuilder.AppendLine(); return(stringBuilder.ToString()); }
//public static MeasuredState Hydrate(State state) //{ // var measured = new MeasuredState {State = state}; // SetBlocks(ref measured); // var (redCurrent, blueCurrent) = BuildStackTypeSetCurrent(measured); //} private static void SetBlocks(ref MeasuredState measured) { foreach (var location in State.AllBoardLocations) { measured.Blocks[location] = measured.State[location].IsBlock(); } }
private static (StackTypeMeasurementSet, StackTypeMeasurementSet) BuildStackTypeSetCurrent(MeasuredState measured) { var redMs = new StackTypeMeasurementSet(); var blueMs = new StackTypeMeasurementSet(); foreach (var location in State.AllBoardLocations) { var current = measured.State[location]; redMs.Normal.OneStack[location] = current == (Cell.SideRed | Cell.Size1); redMs.Normal.TwoStack[location] = current == (Cell.SideRed | Cell.Size2); redMs.Normal.ThreeStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Size2); redMs.Normal.FourStack[location] = current == (Cell.SideRed | Cell.Size4); redMs.Normal.FiveStack[location] = current.IsPiece() && current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && !current.IsKing() && !current.IsCursed(); blueMs.Normal.OneStack[location] = current == Cell.Size1; blueMs.Normal.TwoStack[location] = current == Cell.Size2; blueMs.Normal.ThreeStack[location] = current == (Cell.Size1 | Cell.Size2); blueMs.Normal.FourStack[location] = current == Cell.Size4; blueMs.Normal.FiveStack[location] = current.IsPiece() && !current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && !current.IsKing() && !current.IsCursed(); redMs.Blessed.OneStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Blessed); redMs.Blessed.TwoStack[location] = current == (Cell.SideRed | Cell.Size2 | Cell.Blessed); redMs.Blessed.ThreeStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Size2 | Cell.Blessed); redMs.Blessed.FourStack[location] = current == (Cell.SideRed | Cell.Size4 | Cell.Blessed); redMs.Blessed.FiveStack[location] = current.IsPiece() && current.RedPiece() && current.GetSize() > 4 && current.IsBlessed() && !current.IsKing() && !current.IsCursed(); blueMs.Blessed.OneStack[location] = current == (Cell.Size1 | Cell.Blessed); blueMs.Blessed.TwoStack[location] = current == (Cell.Size2 | Cell.Blessed); blueMs.Blessed.ThreeStack[location] = current == (Cell.Size1 | Cell.Size2 | Cell.Blessed); blueMs.Blessed.FourStack[location] = current == (Cell.Size4 | Cell.Blessed); blueMs.Blessed.FiveStack[location] = current.IsPiece() && !current.RedPiece() && current.GetSize() > 4 && current.IsBlessed() && !current.IsKing() && !current.IsCursed(); redMs.Cursed.OneStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Cursed); redMs.Cursed.TwoStack[location] = current == (Cell.SideRed | Cell.Size2 | Cell.Cursed); redMs.Cursed.ThreeStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Size2 | Cell.Cursed); redMs.Cursed.FourStack[location] = current == (Cell.SideRed | Cell.Size4 | Cell.Cursed); redMs.Cursed.FiveStack[location] = current.IsPiece() && current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && !current.IsKing() && current.IsCursed(); blueMs.Cursed.OneStack[location] = current == (Cell.Size1 | Cell.Cursed); blueMs.Cursed.TwoStack[location] = current == (Cell.Size2 | Cell.Cursed); blueMs.Cursed.ThreeStack[location] = current == (Cell.Size1 | Cell.Size2 | Cell.Cursed); blueMs.Cursed.FourStack[location] = current == (Cell.Size4 | Cell.Cursed); blueMs.Cursed.FiveStack[location] = current.IsPiece() && !current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && !current.IsKing() && current.IsCursed(); redMs.King.OneStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.King); redMs.King.TwoStack[location] = current == (Cell.SideRed | Cell.Size2 | Cell.King); redMs.King.ThreeStack[location] = current == (Cell.SideRed | Cell.Size1 | Cell.Size2 | Cell.King); redMs.King.FourStack[location] = current == (Cell.SideRed | Cell.Size4 | Cell.King); redMs.King.FiveStack[location] = current.IsPiece() && current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && current.IsKing() && !current.IsCursed(); blueMs.King.OneStack[location] = current == (Cell.Size1 | Cell.King); blueMs.King.TwoStack[location] = current == (Cell.Size2 | Cell.King); blueMs.King.ThreeStack[location] = current == (Cell.Size1 | Cell.Size2 | Cell.King); blueMs.King.FourStack[location] = current == (Cell.Size4 | Cell.King); blueMs.King.FiveStack[location] = current.IsPiece() && !current.RedPiece() && current.GetSize() > 4 && !current.IsBlessed() && current.IsKing() && !current.IsCursed(); } return(redMs, blueMs); }