chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//            Copyright Keysight Technologies 2012-2019
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at http://mozilla.org/MPL/2.0/.
using System.Collections.Generic;
 
namespace OpenTap
{
    /// <summary>
    /// A directional <see cref="Connection"/> that has an RF cable loss parameter.
    /// </summary>
    [Display("Directional RF Connection", "Directional RF connection modeled as a set of cable loss points with frequency and loss values and a direction.", "Basic Connections")]
    public class DirectionalRfConnection : RfConnection
    {
        /// <summary>
        /// Specifies the direction of a connection.
        /// </summary>
        public enum PortDirectionEnum
        {
            /// <summary>
            /// Directional RF connection from Port1 to Port2.
            /// </summary>
            [Display("From 1 to 2", "The signal in this connection flows from port 1 to port 2.")]
            FROM_1_TO_2,
            /// <summary>
            /// Directional RF connection from Port2 to Port1.
            /// </summary>
            [Display("From 2 to 1", "The signal in this connection flows from port 2 to port 1.")]
            FROM_2_TO_1
        };
 
        /// <summary>
        /// Direction of RF connection.
        /// </summary>
        [Display("Port Direction", Order: -1)]
        public PortDirectionEnum PortDirection { get; set; }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectionalRfConnection"/> class.
        /// </summary>
        public DirectionalRfConnection()
        {
            Name = "DRF";
            CableLoss = new List<RfConnection.CableLossPoint>();
 
            Rules.Add(() => (PortDirection == PortDirectionEnum.FROM_1_TO_2) ? ((Port1 == null) || !(Port1 is InputPort)) : true, () => "Direction indicates an output port, but an input port is connected.", "Port1");
            Rules.Add(() => (PortDirection == PortDirectionEnum.FROM_2_TO_1) ? ((Port1 == null) || !(Port1 is OutputPort)) : true, () => "Direction indicates an input port, but an output port is connected.", "Port1");
            Rules.Add(() => (PortDirection == PortDirectionEnum.FROM_1_TO_2) ? ((Port2 == null) || !(Port2 is OutputPort)) : true, () => "Direction indicates an input port, but an output port is connected.", "Port2");
            Rules.Add(() => (PortDirection == PortDirectionEnum.FROM_2_TO_1) ? ((Port2 == null) || !(Port2 is InputPort)) : true, () => "Direction indicates an output port, but an input port is connected.", "Port2");
        }
    }
 
}