From 70266ba98d586a23b65f3d4f569abcad3fb95a30 Mon Sep 17 00:00:00 2001 From: celsorocha Date: Fri, 11 Feb 2022 21:47:28 +0000 Subject: [PATCH] Bringing back GetPropertyValue functions for ConductorData and child classes that allows properties to be kept in synch. Fixed indexing that was preventing those functions from properly working git-svn-id: https://svn.code.sf.net/p/electricdss/code/trunk@3362 d8739450-1e93-4ef4-a0af-c327d92816ff --- Source/General/CNData.pas | 18 +++++++++++------- Source/General/CableData.pas | 23 ++++++++++++++--------- Source/General/ConductorData.pas | 24 +++++++++++++++--------- Source/General/TSData.pas | 19 +++++++++++++++++++ Source/General/WireData.pas | 6 ++++++ 5 files changed, 65 insertions(+), 25 deletions(-) diff --git a/Source/General/CNData.pas b/Source/General/CNData.pas index 63dd5f8ff..e96f6f8c5 100644 --- a/Source/General/CNData.pas +++ b/Source/General/CNData.pas @@ -48,7 +48,8 @@ TCNDataObj = class(TCableDataObj) PROCEDURE InitPropertyValues(ArrayOffset:Integer);Override; PROCEDURE DumpProperties(Var F:TextFile; Complete:Boolean);Override; -// FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetNumProperties(ArrayOffset: Integer):Integer;Override; end; implementation @@ -236,22 +237,25 @@ destructor TCNDataObj.Destroy; End; End; end; -{ + FUNCTION TCNDataObj.GetPropertyValue(Index: Integer): String; -Var - i :Integer; Begin Result := ''; - Case i of + Case Index of 1: Result := Format('%d',[FkStrand]); 2: Result := Format('%.6g',[FDiaStrand]); 3: Result := Format('%.6g',[FGmrStrand]); 4: Result := Format('%.6g',[FRStrand]); ELSE - Result := Inherited GetPropertyValue(index); + Result := Inherited GetPropertyValue(index - NumPropsThisClass); END; end; -} + +Function TCNDataObj.GetNumProperties(ArrayOffset: Integer):Integer; +Begin + Result:= Inherited GetNumProperties(NumPropsThisClass+ArrayOffset); +end; + procedure TCNDataObj.InitPropertyValues(ArrayOffset: Integer); begin PropertyValue[1] := '2'; diff --git a/Source/General/CableData.pas b/Source/General/CableData.pas index e2a76fcd2..0b613aa3e 100644 --- a/Source/General/CableData.pas +++ b/Source/General/CableData.pas @@ -20,7 +20,6 @@ TCableData = class(TConductorData) Function ClassEdit(Const ActiveObj:Pointer; Const ParamPointer:Integer):Integer; Procedure ClassMakeLike(Const OtherObj:Pointer); public - NumCableClassProps: Integer; constructor Create; destructor Destroy; override; end; @@ -43,17 +42,19 @@ TCableDataObj = class(TConductorDataObj) PROCEDURE InitPropertyValues(ArrayOffset:Integer);Override; PROCEDURE DumpProperties(Var F:TextFile; Complete:Boolean);Override; -// FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetNumProperties(ArrayOffset:Integer):Integer;Override; end; implementation uses ParserDel, DSSGlobals, DSSClassDefs, Sysutils, Ucomplex, Arraydef, LineUnits; +Const NumCableClassProps = 4; + constructor TCableData.Create; // Creates superstructure for all Line objects BEGIN Inherited Create; - NumCableClassProps := 4; DSSClassType := DSS_OBJECT; END; @@ -165,22 +166,26 @@ destructor TCableDataObj.Destroy; End; End; end; -{ + +Function TCableDataObj.GetNumProperties(ArrayOffset:Integer):Integer; +Begin + Result:= NumCableClassProps+ArrayOffset; +end; + Function TCableDataObj.GetPropertyValue(Index:Integer):String; -Var - i :Integer; Begin Result := ''; - Case i of + Case Index of 1: Result := Format('%.3g',[FEpsR]); 2: Result := Format('%.6g',[FInsLayer]); 3: Result := Format('%.6g',[FDiaIns]); 4: Result := Format('%.6g',[FDiaCable]); ELSE - Result := Inherited GetPropertyValue(index); + Result := Inherited GetPropertyValue(index-NumCableClassProps); END; end; -} + + procedure TCableDataObj.InitPropertyValues(ArrayOffset: Integer); begin PropertyValue[ArrayOffset + 1] := '2.3'; diff --git a/Source/General/ConductorData.pas b/Source/General/ConductorData.pas index 4739c2784..fab3142b6 100644 --- a/Source/General/ConductorData.pas +++ b/Source/General/ConductorData.pas @@ -37,7 +37,6 @@ TConductorData = class(TDSSClass) Function ClassEdit(Const ActiveObj:Pointer; Const ParamPointer:Integer):Integer; Procedure ClassMakeLike(Const OtherObj:Pointer); public - NumConductorClassProps: Integer; constructor Create; destructor Destroy; override; end; @@ -72,7 +71,8 @@ TConductorDataObj = class(TDSSObject) PROCEDURE InitPropertyValues(ArrayOffset:Integer);Override; PROCEDURE DumpProperties(Var F:TextFile; Complete:Boolean);Override; -// FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetNumProperties(ArrayOffset: Integer):Integer;Virtual; end; TConductorDataArray = Array[1..100] of TConductorDataObj; @@ -86,12 +86,12 @@ implementation Const LineUnitsHelp = '{mi|kft|km|m|Ft|in|cm|mm} Default=none.'; + NumConductorClassProps = 13; //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - constructor TConductorData.Create; // Creates superstructure for all Line objects BEGIN Inherited Create; - NumConductorClassProps := 13; DSSClassType := DSS_OBJECT; END; @@ -286,13 +286,12 @@ destructor TConductorDataObj.Destroy; End; End; end; -{ + function TConductorDataObj.GetPropertyValue(Index: Integer): String; Var - i, j:Integer; - Tempstr : String; + j:Integer; + Tempstr : String; begin - Result := ''; CASE Index of // Special cases 1 : Result := Format('%.6g',[FRDC]); @@ -315,11 +314,18 @@ function TConductorDataObj.GetPropertyValue(Index: Integer): String; End; 13: Result := Format('%.6g',[Fcapradius60]); ELSE - Result := Inherited GetPropertyValue(index); + Result := Inherited GetPropertyValue(GetNumProperties(0) + index); // add num properties of child classes END; end; -} + +function TConductorDataObj.GetNumProperties(ArrayOffset: Integer):Integer; +begin + DoErrorMsg('Something is Wrong. Got to base Conductor GetNumProperties for Object:'+CRLF+DSSClassName+'.'+Name, + 'N/A', + 'Should not be able to get here. Probable Programming Error.', 400); +end; + procedure TConductorDataObj.InitPropertyValues(ArrayOffset: Integer); begin PropertyValue[ArrayOffset + 1] := '-1'; diff --git a/Source/General/TSData.pas b/Source/General/TSData.pas index c4df92edc..267a4abd1 100644 --- a/Source/General/TSData.pas +++ b/Source/General/TSData.pas @@ -46,6 +46,8 @@ TTSDataObj = class(TCableDataObj) PROCEDURE InitPropertyValues(ArrayOffset:Integer);Override; PROCEDURE DumpProperties(Var F:TextFile; Complete:Boolean);Override; + FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetNumProperties(ArrayOffset: Integer):Integer;Override; end; implementation @@ -223,6 +225,23 @@ destructor TTSDataObj.Destroy; End; end; +FUNCTION TTSDataObj.GetPropertyValue(Index: Integer): String; +Begin + Result := ''; + Case Index of + 1: Result := Format('%.6g',[FDiaShield]); + 2: Result := Format('%.6g',[FTapeLayer]); + 3: Result := Format('%.2g',[FTapeLap]); + ELSE + Result := Inherited GetPropertyValue(index - NumPropsThisClass); + END; +end; + +FUNCTION TTSDataObj.GetNumProperties(ArrayOffset: Integer):Integer; +Begin + Result:= Inherited GetNumProperties(NumPropsThisClass+ArrayOffset); +end; + procedure TTSDataObj.InitPropertyValues(ArrayOffset: Integer); begin PropertyValue[1] := '-1'; diff --git a/Source/General/WireData.pas b/Source/General/WireData.pas index 37fe19198..3bb6d7c9b 100644 --- a/Source/General/WireData.pas +++ b/Source/General/WireData.pas @@ -42,6 +42,7 @@ TWireDataObj = class(TConductorDataObj) PROCEDURE InitPropertyValues(ArrayOffset:Integer);Override; PROCEDURE DumpProperties(Var F:TextFile; Complete:Boolean);Override; FUNCTION GetPropertyValue(Index:Integer):String;Override; + FUNCTION GetNumProperties(ArrayOffset:Integer):Integer;Override; end; implementation @@ -191,6 +192,11 @@ function TWireDataObj.GetPropertyValue(Index: Integer): String; Result := Inherited GetPropertyValue(index); end; +Function TWireDataObj.GetNumProperties(ArrayOffset:Integer):Integer; +Begin + Result:= NumPropsThisClass; +end; + procedure TWireDataObj.InitPropertyValues(ArrayOffset: Integer); begin inherited InitPropertyValues(ArrayOffset + NumPropsThisClass);