private void recursiveReadData(Data d, XElement el) { XElement eldn; if (d.isStructureSelected()) { el.Add(new XElement("Data", new XAttribute("Type", "structure"))); eldn = el.Descendants().Last(); foreach (GOOSE_ASN1_Model.Data data in d.Structure.Value) { recursiveReadData(data, eldn); } } else if (d.isBitstringSelected()) { NodeGData ngd = new NodeGData("bitstring"); ngd.DataType = scsm_MMS_TypeEnum.bit_string; ngd.DataValue = d.Bitstring.Value; ngd.DataParam = d.Bitstring.TrailBitsCnt; el.Add(new XElement("Data", new XAttribute("Type", "bit_string"), new XAttribute("Value", ngd.StringValue), (d.Description != null && d.Description != "") ? new XAttribute("Desc", d.Description) : null)); } else if (d.isIntegerSelected()) { el.Add(new XElement("Data", new XAttribute("Type", "integer"), new XAttribute("Value", d.Integer.ToString()), (d.Description != null && d.Description != "") ? new XAttribute("Desc", d.Description) : null)); } else if (d.isBooleanSelected()) { el.Add(new XElement("Data", new XAttribute("Type", "boolean"), new XAttribute("Value", d.Boolean.ToString()), (d.Description != null && d.Description != "") ? new XAttribute("Desc", d.Description) : null)); } }
private NodeGData recursiveCheckIfDataPresent(NodeGData ngdcn, NodeGData ngd) { if (ngdcn.DataType == scsm_MMS_TypeEnum.structure) { if (ngdcn.GetChildNodes().Length > 0) { foreach (NodeGData ngdcncn in ngdcn.GetChildNodes()) { NodeGData ret = recursiveCheckIfDataPresent(ngdcncn, ngd); if (ret != null) { return(ret); } } return(null); } else { return(null); } } else { if (ngd.Tag == ngdcn.Tag) { return(ngdcn); } else { return(null); } } }
private void myListView1_CheckDataIntegrity() { if (_seqDataList.Count > 0) { List <SeqData> itemsToDel = new List <SeqData>(); foreach (SeqData sqd in _seqDataList) { if (Gvl != null && Gvl.GetChildNodes().Length > 0) { NodeGData ret = null; foreach (NodeGData ngdcn in Gvl.GetChildNodes()) { ret = recursiveCheckIfDataPresent(ngdcn, sqd.refdata); if (ret != null) { break; } } if (ret == null) { itemsToDel.Add(sqd); } else { if (sqd.refdata != ret) { sqd.refdata = ret; } } } else { _seqDataList.Clear(); } } if (itemsToDel.Count > 0) { foreach (SeqData sqd in itemsToDel) { _seqDataList.Remove(sqd); } } } myListView1_Refresh(); }
private void recursiveReadGvl(NodeGData ngd, XElement el) { el.Add(new XElement("Data", new XAttribute("Type", ngd.DataType.ToString()), new XAttribute("Value", ngd.StringValue), (ngd.Tag is Data) ? (((ngd.Tag as Data).Description != null && (ngd.Tag as Data).Description != "") ? new XAttribute("Desc", (ngd.Tag as Data).Description) : null) : ((ngd.Description != null && ngd.Description != "") ? new XAttribute("Desc", ngd.Description) : null))); XElement eldn = el.Descendants().Last(); if (ngd.GetChildNodes().Length > 0) { foreach (NodeGData ngdcn in ngd.GetChildNodes()) { recursiveReadGvl(ngdcn, eldn); } } }
private NodeGData recursiveFindNodeGData(NodeGData ngd, string name) { if (name == ngd.CommAddress.Domain.ToString() + ((ngd.CommAddress.Variable.ToString() != "") ? ("/" + ngd.CommAddress.Variable.ToString().Replace("$", "/")) : "")) { return(ngd); } if (ngd.GetChildNodes().Length > 0) { foreach (NodeGData ngdcn in ngd.GetChildNodes()) { NodeGData ret = recursiveFindNodeGData(ngdcn, name); if (ret != null) { return(ret); } } } return(null); }
int recursiveReadData(NodeBase nd, GOOSE_ASN1_Model.Data t, NodeBase ndcn, int id, DateTime captureTime) { int _id = id; if (t == null) { return(-1); } if (t.Array != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.array; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Array_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.array; (nb as NodeGData).DataValue = t.Array; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Binarytime != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.array; (nd as NodeGData).DataValue = t.Binarytime; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Binarytime_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.binary_time; (nb as NodeGData).DataValue = t.Binarytime; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Bitstring != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.bit_string; (nd as NodeGData).DataValue = t.Bitstring.Value; (nd as NodeGData).DataParam = t.Bitstring.TrailBitsCnt; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Bitstring_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.bit_string; (nb as NodeGData).DataValue = t.Bitstring.Value; (nb as NodeGData).DataParam = t.Bitstring.TrailBitsCnt; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.isBooleanSelected()) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.boolean; (nd as NodeGData).DataValue = t.Boolean; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Boolean_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.boolean; (nb as NodeGData).DataValue = t.Boolean; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.BooleanArray != null) { return(0); } else if (t.Floatingpoint != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.floating_point; (nd as NodeGData).DataValue = t.Floatingpoint; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Floatingpoint_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.floating_point; (nb as NodeGData).DataValue = t.Floatingpoint; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Generalizedtime != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.generalized_time; (nd as NodeGData).DataValue = t.Generalizedtime; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Generalizedtime_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.generalized_time; (nb as NodeGData).DataValue = t.Generalizedtime; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.isIntegerSelected()) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.integer; (nd as NodeGData).DataValue = t.Integer; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Integer_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.integer; (nb as NodeGData).DataValue = t.Integer; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.MMSString != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.mMSString; (nd as NodeGData).DataValue = t.MMSString; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("MMSString_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.mMSString; (nb as NodeGData).DataValue = t.MMSString; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Octetstring != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.octet_string; (nd as NodeGData).DataValue = t.Octetstring; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Octetstring_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.octet_string; (nb as NodeGData).DataValue = t.Octetstring; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Structure != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.structure; NodeBase[] nd1 = nd.GetChildNodes(); int i = 0; int j = 0; foreach (GOOSE_ASN1_Model.Data data in t.Structure.Value) { j = recursiveReadData(nd1[i++], data, null, j, captureTime); } return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Structure_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.structure; NodeBase nb1 = ndcn.AddChildNode(nb); int i = 0; foreach (GOOSE_ASN1_Model.Data data in t.Structure.Value) { i = recursiveReadData(null, data, nb1, i, captureTime); } return(++_id); } else { return(-1); } } else if (t.isUnsignedSelected()) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.unsigned; (nd as NodeGData).DataValue = t.Unsigned; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Unsigned_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.unsigned; (nb as NodeGData).DataValue = t.Unsigned; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Utctime != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.utc_time; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Utctime_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.utc_time; ndcn.AddChildNode(nb); return(++_id); } else { return(-1); } } else if (t.Visiblestring != null) { if (nd != null) { (nd as NodeGData).CaptureTime = captureTime; (nd as NodeGData).DataType = scsm_MMS_TypeEnum.visible_string; (nd as NodeGData).DataValue = t.Visiblestring; return(0); } else if (ndcn != null) { NodeBase nb = new NodeGData("Utctime_" + _id.ToString()); (nb as NodeGData).CaptureTime = captureTime; (nb as NodeGData).DataType = scsm_MMS_TypeEnum.visible_string; (nb as NodeGData).DataValue = t.Visiblestring; return(++_id); } else { return(-1); } } else { return(-1); } }
public SeqData(NodeGData dat, string val, int dur) { this.refdata = dat; this.duration = dur; this.data = val; }
public SeqData(NodeGData dat, int dur) { this.refdata = dat; this.duration = dur; this.data = dat.StringValue; }