コード例 #1
0
 /// <summary>
 /// Adds a path between two variables.
 /// </summary>
 /// <param name="a">The first variable.</param>
 /// <param name="b">The second variable.</param>
 /// <param name="type">The path type.</param>
 private void AddPath(IVariable a, IVariable b, ConductionTypes type)
 {
     if (type == ConductionTypes.None)
     {
         throw new SpiceSharpException("Invalid path");
     }
     if ((type & ConductionTypes.Dc) != 0)
     {
         Connect(a, b, _dcGroups, ref _dcGroupCount);
     }
     else
     {
         Add(a, _dcGroups, ref _dcGroupCount);
         Add(b, _dcGroups, ref _dcGroupCount);
     }
     if ((type & ConductionTypes.Ac) != 0)
     {
         Connect(a, b, _acGroups, ref _acGroupCount);
     }
     else
     {
         Add(a, _acGroups, ref _acGroupCount);
         Add(b, _acGroups, ref _acGroupCount);
     }
 }
コード例 #2
0
 /// <summary>
 /// Specifies variables as being connected by a conductive path of the specified type.
 /// </summary>
 /// <param name="subject">The subject that applies the conductive paths.</param>
 /// <param name="type">The type of path between these variables.</param>
 /// <param name="variables">The variables that are connected.</param>
 public void AddPath(IRuleSubject subject, ConductionTypes type, params IVariable[] variables)
 {
     if (variables == null || variables.Length == 0)
     {
         return;
     }
     if (variables.Length == 1 || type == ConductionTypes.None)
     {
         foreach (var variable in variables)
         {
             Add(variable, _dcGroups, ref _dcGroupCount);
             Add(variable, _acGroups, ref _acGroupCount);
         }
     }
     else
     {
         for (var i = 0; i < variables.Length; i++)
         {
             for (var j = i + 1; j < variables.Length; j++)
             {
                 AddPath(variables[i], variables[j], type);
             }
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Specifies variables as being connected by a conductive path of the specified type.
 /// </summary>
 /// <param name="subject">The subject that applies the conductive paths.</param>
 /// <param name="type">The type of path between these variables.</param>
 /// <param name="variables">The variables that are connected.</param>
 public void AddPath(IRuleSubject subject, ConductionTypes type, params IVariable[] variables)
 {
     foreach (var v in variables)
     {
         if (v.Equals(_search))
         {
             ViolationCount = 0;
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FloatingNodeRuleViolation" /> class.
 /// </summary>
 /// <param name="rule">The rule.</param>
 /// <param name="floatingVariable">The floating node variable.</param>
 /// <param name="fixedVariable">The fixed node variable.</param>
 /// <param name="type">The path type.</param>
 public FloatingNodeRuleViolation(IRule rule, IVariable floatingVariable, IVariable fixedVariable, ConductionTypes type)
 {
     Rule = rule.ThrowIfNull(nameof(rule));
     if (type == ConductionTypes.All)
     {
         throw new SpiceSharpException("This is not a floating node!");
     }
     FixedVariable    = fixedVariable;
     FloatingVariable = floatingVariable;
     Type             = type;
 }