Skip to content

Commit

Permalink
Bringing back GetPropertyValue functions for ConductorData and child …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
celsorocha committed Feb 11, 2022
1 parent 232898b commit 70266ba
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 25 deletions.
18 changes: 11 additions & 7 deletions Source/General/CNData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand Down
23 changes: 14 additions & 9 deletions Source/General/CableData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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';
Expand Down
24 changes: 15 additions & 9 deletions Source/General/ConductorData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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]);
Expand All @@ -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';
Expand Down
19 changes: 19 additions & 0 deletions Source/General/TSData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions Source/General/WireData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 70266ba

Please sign in to comment.