예제 #1
0
        public IHttpActionResult PuttCommunication(int id, tCommunication tCommunication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tCommunication.f交流編號)
            {
                return(BadRequest());
            }

            db.Entry(tCommunication).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tCommunicationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GettCommunication(int id)
        {
            tCommunication tCommunication = db.tCommunications.Find(id);

            if (tCommunication == null)
            {
                return(NotFound());
            }

            return(Ok(tCommunication));
        }
예제 #3
0
        public IHttpActionResult PosttCommunication(tCommunication tCommunication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tCommunications.Add(tCommunication);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tCommunication.f交流編號 }, tCommunication));
        }
예제 #4
0
        public IHttpActionResult DeletetCommunication(int id)
        {
            tCommunication tCommunication = db.tCommunications.Find(id);

            if (tCommunication == null)
            {
                return(NotFound());
            }

            db.tCommunications.Remove(tCommunication);
            db.SaveChanges();

            return(Ok(tCommunication));
        }
예제 #5
0
        public CommunicationNode(tCommunication c)
        {
            if (c == null)
            {
                return;
            }

            Name = "Substation Networks";
            Tag  = c;
            if (c.SubNetwork != null)
            {
                for (int i = 0; i < c.SubNetwork.Length; i++)
                {
                    var sn = new SubnetworkNode(c.SubNetwork [i]);
                    this.Nodes.Add(sn);
                }
                this.Expand();
            }
        }
        /// <summary>
        /// This method draws the Communication nodes on the main tree.
        /// </summary>
        private void DrawCommunication()
        {
            // Add a tCommunication object to SCL
            if (this.scl.Communication == null)
            {
                tCommunication communication = new tCommunication();
                this.scl.Communication = communication;
                nodeComm      = new TreeNode();
                nodeComm.Name = "tCommunication";
                nodeComm.Tag  = this.scl.Communication;
                nodeComm.Text = "tCommunication";
                treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes.Add(nodeComm);
            }
            else
            {
                nodeComm = this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"];
            }
            // Add a Subnetwork
            if (this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"] == null)
            {
                nodeSubNetwork      = new TreeNode();
                nodeSubNetwork.Name = "tSubNetwork[]";
                nodeSubNetwork.Tag  = this.scl.Communication.SubNetwork;
                nodeSubNetwork.Text = "SubNetwork";
                treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes.Add(nodeSubNetwork);
            }
            else
            {
                nodeSubNetwork = this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"];
            }
            if (this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[this.nameSubNet.Text] == null &&
                this.GetNodeName(nodeSubNetwork.Nodes, nameSubNet.Text, "name") == null)
            {
                int sni = this.scl.Communication.AddSubNetwork(this.nameSubNet.Text, this.descSubNet.Text);
                if (sni >= 0)
                {
                    nodetSubNetwork      = new TreeNode();
                    nodetSubNetwork.Name = this.scl.Communication.SubNetwork[sni].name;
                    nodetSubNetwork.Text = "tSubNetwork";
                    nodetSubNetwork.Tag  = this.scl.Communication.SubNetwork[sni];
                    treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes.Add(nodetSubNetwork);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Subnetwork couldn't be added. Verify if it already exist and try again",
                                                         "Subnetwork wasn't added",
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Error);
                }
            }
            else
            {
                nodetSubNetwork = this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[this.GetNodeName(nodeSubNetwork.Nodes, nameSubNet.Text, "name")];
            }
            if (this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name].Nodes["tConnectedAP[]"] == null)
            {
                nodeComm      = new TreeNode();
                nodeComm.Name = "tConnectedAP[]";
                nodeComm.Tag  = this.scl.Communication.SubNetwork[nodetSubNetwork.Index].ConnectedAP;
                nodeComm.Text = "ConnectedAP";
                treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"]
                .Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name].Nodes.Add(nodeComm);
            }
            else
            {
                nodeComm = this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name].Nodes["tConnectedAP[]"];
            }

            this.treeViewSCL = new TreeViewSCL();
            connap.apName    = this.apName;
            connap.iedName   = this.iedName;
            if (this.treeViewSCL.SeekAssociation(this.treeSCL.TreeView.Nodes["root"]
                                                 .Nodes["SCL"].Nodes["tCommunication"]
                                                 .Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name]
                                                 .Nodes, this.apName, this.iedName) == null)
            {
                // Create tAddress
                tP[]  tp  = new tP[6];
                tP_IP _ip = new tP_IP();
                _ip.Value = this.ip.Text;
                tp[0]     = _ip;

                tP_IPSUBNET _subnet = new tP_IPSUBNET();
                _subnet.Value = this.mask.Text;
                tp[1]         = _subnet;

                tP_IPGATEWAY _gate = new tP_IPGATEWAY();
                _gate.Value = this.gateway.Text;
                tp[2]       = _gate;

                tP_OSITSEL _tsel = new tP_OSITSEL();
                _tsel.Value = this.tsel.Text;
                tp[3]       = _tsel;

                tP_OSISSEL _ssel = new tP_OSISSEL();
                _ssel.Value = this.ssel.Text;
                tp[4]       = _ssel;

                tP_OSIPSEL _psel = new tP_OSIPSEL();
                _psel.Value = this.psel.Text;
                tp[5]       = _psel;

                tAddress addr = new tAddress();
                addr.P = tp;

                tIED ied  = this.scl.IED[this.scl.GetIED(this.iedName)];
                int  api  = ied.GetAP(this.apName);
                int  capi = this.scl.Communication
                            .SubNetwork[nodetSubNetwork.Index].AddConnectedAP(ied, api, addr, null);
                if (capi >= 0)
                {
                    AttributeReferences refe = new AttributeReferences();
                    nodetConnected      = new TreeNode();
                    nodetConnected.Name = "tConnectedAP" + this.iedName + this.apName;
                    nodetConnected.Tag  = this.scl.Communication.SubNetwork[nodetSubNetwork.Index].ConnectedAP[capi];
                    nodetConnected.Text = "tConnectedAP";
                    treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"]
                    .Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name]
                    .Nodes["tConnectedAP[]"].Nodes.Add(nodetConnected);
                    refe.Insert(this.scl.Communication.SubNetwork[nodetSubNetwork.Index].ConnectedAP[capi],
                                this.treeSCL.TreeView.SelectedNode);

                    // Add Nodes for tAddress and tP
                    TreeNode nodeAddress = new TreeNode();
                    nodeAddress.Name = "Adress";
                    nodeAddress.Tag  = address;
                    nodeAddress.Text = "Address";
                    treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"]
                    .Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name]
                    .Nodes["tConnectedAP[]"].Nodes[nodetConnected.Name].Nodes.Add(nodeAddress);
                    nodeP.Name = "tP[]";
                    nodeP.Text = "P";
                    treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"]
                    .Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name]
                    .Nodes["tConnectedAP[]"].Nodes[nodetConnected.Name]
                    .Nodes["Adress"].Nodes.Add(nodeP);

                    Utils.AddTPTreeNode(_ip, nodeP);
                    Utils.AddTPTreeNode(_subnet, nodeP);
                    Utils.AddTPTreeNode(_gate, nodeP);
                    Utils.AddTPTreeNode(_tsel, nodeP);
                    Utils.AddTPTreeNode(_psel, nodeP);
                    Utils.AddTPTreeNode(_ssel, nodeP);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("ConnectedAP couldn't be added. Verify if it already exist and try again",
                                                         "ConnectedAP wasn't added",
                                                         System.Windows.Forms.MessageBoxButtons.OK,
                                                         System.Windows.Forms.MessageBoxIcon.Error);
                }
            }
            else
            {
                nodetConnected = this.treeViewSCL.SeekAssociation(this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[nodetSubNetwork.Name].Nodes["tConnectedAP[]"].Nodes, this.apName, this.iedName, "apName", "iedName");
            }
        }