Clean code

v1.6
Maxson Ramon dos Anjos Medeiros 3 months ago
parent 1cda600ea1
commit 7a0070ac6b

@ -3,7 +3,6 @@ using IEC61850.SCL.DataModel;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml;
namespace DynamicModel namespace DynamicModel
{ {

@ -9,8 +9,6 @@
using IEC61850.SCL.DataModel; using IEC61850.SCL.DataModel;
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Linq;
namespace IEC61850.SCL namespace IEC61850.SCL
{ {
@ -228,7 +226,7 @@ namespace IEC61850.SCL
else else
output.Write("0 "); output.Write("0 ");
if(smv.SclSMVControl.SmpRate != -1) if (smv.SclSMVControl.SmpRate != -1)
output.Write(smv.SclSMVControl.SmpRate + " "); output.Write(smv.SclSMVControl.SmpRate + " ");
else else
output.Write("0 "); output.Write("0 ");
@ -296,7 +294,7 @@ namespace IEC61850.SCL
} }
if(lcb.SclLogControl.IntgPd is null) if (lcb.SclLogControl.IntgPd is null)
output.Write("0 "); output.Write("0 ");
else else
output.Write(lcb.SclLogControl.IntgPd + " "); output.Write(lcb.SclLogControl.IntgPd + " ");
@ -440,7 +438,7 @@ namespace IEC61850.SCL
{ {
DataObject parentObject = null; DataObject parentObject = null;
while(!(dataAttribute.Parent is DataObject)) while (!(dataAttribute.Parent is DataObject))
{ {
dataAttribute = dataAttribute.Parent as DataAttribute; dataAttribute = dataAttribute.Parent as DataAttribute;
} }
@ -482,9 +480,9 @@ namespace IEC61850.SCL
SclDAI getDAIInternal(SclSDI sclSDI, DataAttribute dataAttribute) SclDAI getDAIInternal(SclSDI sclSDI, DataAttribute dataAttribute)
{ {
SclDAI returnValue = null; SclDAI returnValue = null;
foreach(SclDAI sclDAI1 in sclSDI.SclDAIs) foreach (SclDAI sclDAI1 in sclSDI.SclDAIs)
{ {
if(sclDAI1.Name == dataAttribute.Name) if (sclDAI1.Name == dataAttribute.Name)
{ {
if (dataAttribute.ObjRef.EndsWith("." + sclSDI.Name + "." + sclDAI1.Name)) if (dataAttribute.ObjRef.EndsWith("." + sclSDI.Name + "." + sclDAI1.Name))
{ {
@ -567,7 +565,7 @@ namespace IEC61850.SCL
string getObjRef(string initialString, SclSDI sclSDI) string getObjRef(string initialString, SclSDI sclSDI)
{ {
object parent = sclSDI.Parent; object parent = sclSDI.Parent;
while(!(parent is SclDOI)) while (!(parent is SclDOI))
{ {
SclSDI sclSDI1 = parent as SclSDI; SclSDI sclSDI1 = parent as SclSDI;
parent = sclSDI1.Parent; parent = sclSDI1.Parent;
@ -658,16 +656,16 @@ namespace IEC61850.SCL
foreach (SclDOI sclDOI1 in logicalNode.SclElement.DOIs) foreach (SclDOI sclDOI1 in logicalNode.SclElement.DOIs)
{ {
foreach(SclSDI sclSDI in sclDOI1.SclSDIs) foreach (SclSDI sclSDI in sclDOI1.SclSDIs)
{ {
returnSDI = getSDI(logicalNode, dataObject, sclSDI); returnSDI = getSDI(logicalNode, dataObject, sclSDI);
if(returnSDI != null) if (returnSDI != null)
{ {
break; break;
} }
} }
if(returnSDI != null) if (returnSDI != null)
{ {
break; break;
} }
@ -694,7 +692,7 @@ namespace IEC61850.SCL
SclDOI sclDOI = logicalNode.SclElement.DOIs.Find(x => x.Name == dataObject.Name); SclDOI sclDOI = logicalNode.SclElement.DOIs.Find(x => x.Name == dataObject.Name);
if(sclDOI == null) if (sclDOI == null)
{ {
sclDOI = getSDO(logicalNode, dataObject); sclDOI = getSDO(logicalNode, dataObject);
} }

@ -312,7 +312,7 @@ namespace StaticModelGenerator.C_Structures
public override string ToString() public override string ToString()
{ {
string cText = ""; string cText = "";
if(arrayIndex == -1) if (arrayIndex == -1)
cText = "DataObject " + parent + "_" + name + " = {\n"; cText = "DataObject " + parent + "_" + name + " = {\n";
else else
cText = "DataObject " + parent + "_" + name + "_" + arrayIndex + " = {\n"; cText = "DataObject " + parent + "_" + name + "_" + arrayIndex + " = {\n";
@ -320,7 +320,7 @@ namespace StaticModelGenerator.C_Structures
cText += " " + ModelNodeType + ",\n"; cText += " " + ModelNodeType + ",\n";
cText += " \"" + name + "\",\n"; cText += " \"" + name + "\",\n";
if(arrayIndex != -1) if (arrayIndex != -1)
cText += " (ModelNode*) &" + parent + "_" + name + ",\n"; cText += " (ModelNode*) &" + parent + "_" + name + ",\n";
else else
cText += " (ModelNode*) &" + parent + ",\n"; cText += " (ModelNode*) &" + parent + ",\n";
@ -337,7 +337,7 @@ namespace StaticModelGenerator.C_Structures
cText += " " + elementCount + ",\n"; cText += " " + elementCount + ",\n";
if(elementCount == 0) if (elementCount == 0)
cText += " " + arrayIndex + "\n"; cText += " " + arrayIndex + "\n";
else else
cText += " 0" + arrayIndex + "\n"; cText += " 0" + arrayIndex + "\n";
@ -768,7 +768,7 @@ namespace StaticModelGenerator.C_Structures
cText += "SVControlBlock " + externName + " = {\n"; cText += "SVControlBlock " + externName + " = {\n";
cText += " &" + parent + ",\n"; cText += " &" + parent + ",\n";
if(SMVControl.SclSMVControl.Name != null) if (SMVControl.SclSMVControl.Name != null)
cText += " \"" + SMVControl.Name + index + "\",\n"; cText += " \"" + SMVControl.Name + index + "\",\n";
else else
cText += " NULL,\n"; cText += " NULL,\n";

@ -14,7 +14,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Runtime.InteropServices.ComTypes;
using DataSet = IEC61850.SCL.DataModel.DataSet; using DataSet = IEC61850.SCL.DataModel.DataSet;
namespace StaticModelGenerator namespace StaticModelGenerator
@ -329,7 +328,7 @@ namespace StaticModelGenerator
c_DataObjectStructure.parent = lnRef; c_DataObjectStructure.parent = lnRef;
c_DataObjectStructure.name = dataObject.Name; c_DataObjectStructure.name = dataObject.Name;
if(c_DataObjectStructure.arrayIndex != -1) if (c_DataObjectStructure.arrayIndex != -1)
c_DataObjectStructure.name = dataObject.Name + "_" + c_DataObjectStructure.arrayIndex; c_DataObjectStructure.name = dataObject.Name + "_" + c_DataObjectStructure.arrayIndex;
else else
c_DataObjectStructure.objRef = lnRef + "_" + dataObject.Name; c_DataObjectStructure.objRef = lnRef + "_" + dataObject.Name;

@ -6,8 +6,6 @@
* All rights reserved. * All rights reserved.
*/ */
using StaticModelGenerator;
namespace modeGenerator_example namespace modeGenerator_example
{ {

Loading…
Cancel
Save