Beispiel #1
0
        public MainForm()
        {
            InitializeComponent();

            configuratorTC.Visible = false;

            var configs = ConfigUtility.GetCyberConfig();

            // Collect the topology and populate the tree view
            TopologyGeneration.CreateCompleteCyberNetwork(configs);
            //TopologyGeneration.CreateCyberNetwork();
            var nodes = TopologyGeneration.nodes;

            foreach (var node in nodes)
            {
                var classType = node.GetType().ToString().Split('.')[2];
                switch (classType)
                {
                case "UtilityControlCenter":
                    var util = (UtilityControlCenter)node;
                    ucs.Add(util);
                    break;

                case "Substation":
                    var sub = (Substation)node;
                    subs.Add(sub);
                    break;
                }
            }

            foreach (var util in ucs)
            {
                TreeNode utilNode = new TreeNode(util.label);
                utilNode.Tag = new UtilityControlCenter
                {
                    label      = util.label,
                    networkLan = util.networkLan,
                    subnetMask = util.subnetMask
                };
                var substations = util.substations;
                foreach (var sub in substations)
                {
                    var      actualsub = TopologyGeneration.substationList.Single(a => a.label == sub);
                    var      subName   = actualsub.label.Split('.')[actualsub.label.Split('.').Count() - 1];
                    TreeNode subNode   = new TreeNode(subName);
                    subNode.Tag = new Substation
                    {
                        label        = subName,
                        networkLan   = actualsub.networkLan,
                        OTSubnetMask = actualsub.OTSubnetMask
                    };
                    utilNode.Nodes.Add(subNode);
                }
                firewallAccessTreeView.Nodes[0].Nodes.Add(utilNode);
            }
        }