Skip to content

Commit

Permalink
Add messages for deprecated and removed properties. Still no warnings…
Browse files Browse the repository at this point in the history
… though, only errors.

Closes #118
  • Loading branch information
PMeira committed Aug 5, 2022
1 parent e5b99d7 commit b215d07
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 112 deletions.
3 changes: 3 additions & 0 deletions src/CAPI/CAPI_Obj.pas
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ function flagsToArray(flags: TPropertyFlags): TJSONArray;
if TPropertyFlag.ConditionalValue in flags then Result.Add('ConditionalValue');
if TPropertyFlag.FullNameAsArray in flags then Result.Add('FullNameAsArray');
if TPropertyFlag.Util in flags then Result.Add('Util');
if TPropertyFlag.Deprecated in flags then Result.Add('Deprecated');
end;

function prepareEnum(e: TDSSEnum; enumIds: TClassNamesHashListType): TJSONObject;
Expand Down Expand Up @@ -313,6 +314,8 @@ function prepareClassSchema(clsidx: Integer; cls: TDSSClass; enumIds: TClassName
prop.Add('description', GetPropertyHelp(i));
if TPropertyFlag.Redundant in PropertyFlags[i] then
prop.Add('redundantWith', PropertyRedundantWith[i]);
if (PropertyType[i] = TPropertyType.DeprecatedAndRemoved) or (TPropertyFlag.Deprecated in PropertyFlags[i]) then
prop.Add('deprecationMessage', PropertyDeprecatedMessage[i]);

props.Add(prop);
end;
Expand Down
21 changes: 12 additions & 9 deletions src/Common/DSSClass.pas
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

unit DSSClass;
{
----------------------------------------------------------
Copyright (c) 2008-2015, Electric Power Research Institute, Inc.
All rights reserved.
----------------------------------------------------------
}
// ----------------------------------------------------------
// Copyright (c) 2018-2022, Paulo Meira, DSS Extensions contributors
// Copyright (c) 2008-2015, Electric Power Research Institute, Inc.
// All rights reserved.
// ----------------------------------------------------------

interface

Expand Down Expand Up @@ -91,7 +90,8 @@ interface
FullNameAsArray, // special case for LineGeometry, when reading wire as an array of strings through the Obj_* API
Redundant,
Util, // things like X and Y from XYcurve that don't have value as data
Unused
Unused,
Deprecated
);

TPropertyFlags = set of TPropertyFlag;
Expand Down Expand Up @@ -165,8 +165,9 @@ interface
StringOnStructArrayProperty,

BusOnStructArrayProperty,
BusesOnStructArrayProperty // AutoTrans, Transformer
BusesOnStructArrayProperty, // AutoTrans, Transformer

DeprecatedAndRemoved
// OtherProperty
);
{$SCOPEDENUMS OFF}
Expand Down Expand Up @@ -277,7 +278,8 @@ TDSSClass = class(TObject)
PropertyOffset: pPtrIntArray; // For most simple properties
PropertyOffset2: pPtrIntArray; // For separate complex quantities, double-on-array, ...
PropertyOffset3: pPtrIntArray; // For setters in e.g. object refs

PropertyDeprecatedMessage: Array of String; // For deprecated properties

PropertyStructArrayIndexOffset, PropertyStructArrayIndexOffset2,
PropertyStructArrayOffset,
PropertyStructArrayStep,
Expand Down Expand Up @@ -1301,6 +1303,7 @@ function TDSSClass.AddObjectToList(Obj:Pointer; Activate: Boolean): Integer;
PropertyOffset := Allocmem(SizeOf(PtrInt) * NumProperties);
PropertyOffset2 := Allocmem(SizeOf(PtrInt) * NumProperties);
PropertyOffset3 := Allocmem(SizeOf(PtrInt) * NumProperties);
SetLength(PropertyDeprecatedMessage, NumProperties + 1);
PropertyReadFunction := Allocmem(SizeOf(Pointer) * NumProperties);
PropertyWriteFunction := Allocmem(SizeOf(Pointer) * NumProperties);

Expand Down
106 changes: 48 additions & 58 deletions src/Controls/InvControl2.pas
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
unit InvControl2;

{
----------------------------------------------------------
Copyright (c) 2008-2015, Electric Power Research Institute, Inc.
All rights reserved.
----------------------------------------------------------
}
//
// A InvControl is a control element that is connected to a terminal of another
// circuit element and sends kW and/or kvar signals to a set of PVSystem objects it controls
//
// A InvControl is defined by a New command:
//
// New InvControl.Name=myname PVSystemList = (pvsystem1 pvsystem2 ...)
//
//Notes:
// WGS (11/26/2012): Using dynamic arrays for many private variables in this unit.
// Although dynamic arrays begin at 0 (by definition in Delphi),
// this unit is using 1 to numberelements in all for loops - the 0th
// element is un-used (except for Strings) in this unit.
// All dynamic arrays are set to length numberelements+1 in the appropriate dimension.
//
// Updated 9/24/2015 to allow for simultaneous modes and additional functionality
// ----------------------------------------------------------
// Copyright (c) 2018-2022, Paulo Meira, DSS Extensions contributors
// Copyright (c) 2008-2020, Electric Power Research Institute, Inc.
// All rights reserved.
// ----------------------------------------------------------

interface

Expand Down Expand Up @@ -50,40 +33,40 @@ interface
TInvControl2Prop = (
INVALID = 0,

DERList = 1,
Mode = 2,
CombiMode = 3,
vvc_curve1 = 4,
hysteresis_offset = 5,
voltage_curvex_ref = 6,
avgwindowlen = 7,

voltwatt_curve = 8,

DbVMin = 9,
DbVMax = 10,
ArGraLowV = 11,
ArGraHiV = 12,
DynReacavgwindowlen = 13,
deltaQ_Factor = 14,
VoltageChangeTolerance = 15,
VarChangeTolerance = 16,
VoltwattYAxis = 17,
RateofChangeMode = 18,
LPFTau = 19, // weird double: in the original version, value was not set
RiseFallLimit = 20, // weird double: in the original version, value was not set
deltaP_Factor = 21,
EventLog = 22,
RefReactivePower = 23,
ActivePChangeTolerance = 24,
monVoltageCalc = 25,
monBus = 26,
MonBusesVbase = 27,
voltwattCH_curve = 28,
wattpf_curve = 29,
wattvar_curve = 30,
// VV_RefReactivePower = 31, // was deprecated, removed
PVSystemList, // was 32
DERList,
Mode,
CombiMode,
vvc_curve1,
hysteresis_offset,
voltage_curvex_ref,
avgwindowlen,

voltwatt_curve,

DbVMin,
DbVMax,
ArGraLowV,
ArGraHiV,
DynReacavgwindowlen,
deltaQ_Factor,
VoltageChangeTolerance,
VarChangeTolerance,
VoltwattYAxis,
RateofChangeMode,
LPFTau, // weird double: in the original version, value was not set
RiseFallLimit, // weird double: in the original version, value was not set
deltaP_Factor,
EventLog,
RefReactivePower,
ActivePChangeTolerance,
monVoltageCalc,
monBus,
MonBusesVbase,
voltwattCH_curve,
wattpf_curve,
wattvar_curve,
VV_RefReactivePower, // was deprecated, reintroduced for v0.12.2; TODO: TO BE REMOVED AGAIN LATER
PVSystemList, // was 32 -- TODO: TO BE MARKED AS REMOVED
Vsetpoint // was 33
);
{$SCOPEDENUMS OFF}
Expand Down Expand Up @@ -488,6 +471,11 @@ procedure TInvControl2.DefineProperties;
PropertyOffset[ord(TProp.RefReactivePower)] := ptruint(@obj.FReacPower_ref);
PropertyOffset2[ord(TProp.RefReactivePower)] := PtrInt(RefQEnum);

PropertyOffset[ord(TProp.VV_RefReactivePower)] := 0;
PropertyType[ord(TProp.VV_RefReactivePower)] := TPropertyType.DeprecatedAndRemoved; //TODO: fully remove
PropertyDeprecatedMessage[ord(TProp.VV_RefReactivePower)] := '"VV_RefReactivePower" was deprecated in 2020. Use "RefReactivePower" instead.';
PropertyFlags[ord(TProp.VV_RefReactivePower)] := [TPropertyFlag.Deprecated];

PropertyType[ord(TProp.monVoltageCalc)] := TPropertyType.MappedStringEnumProperty;
PropertyOffset[ord(TProp.monVoltageCalc)] := ptruint(@obj.FMonBusesPhase);
PropertyOffset2[ord(TProp.monVoltageCalc)] := PtrInt(DSS.MonPhaseEnum);
Expand All @@ -503,8 +491,9 @@ procedure TInvControl2.DefineProperties;
PropertyOffset[ord(TProp.DERList)] := ptruint(@obj.DERNameList);
PropertyOffset[ord(TProp.monBus)] := ptruint(@obj.MonBusesNameList);
PropertyOffset[ord(TProp.PVSystemList)] := ptruint(@obj.DERNameList);
PropertyFlags[ord(TProp.PVSystemList)] := [TPropertyFlag.Redundant];
PropertyFlags[ord(TProp.PVSystemList)] := [TPropertyFlag.Redundant, TPropertyFlag.Deprecated]; // TODO: mark as removed
PropertyRedundantWith[ord(TProp.PVSystemList)] := ord(TProp.DERList);
PropertyDeprecatedMessage[ord(TProp.PVSystemList)] := '"PVSystemList" was deprecated in 2020. Use "DERList" instead.';

// array of doubles
PropertyType[ord(TProp.MonBusesVbase)] := TPropertyType.DoubleVArrayProperty;
Expand Down Expand Up @@ -3992,7 +3981,8 @@ procedure TInvControl2.UpdateAll();
UpdateInvControl(i);
end;

finalization ModeEnum.Free;
finalization
ModeEnum.Free;
CombiModeEnum.Free;
VoltageCurveXRefEnum.Free;
VoltWattYAxisEnum.Free;
Expand Down
10 changes: 10 additions & 0 deletions src/General/DSSObjectHelper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ function TDSSClassHelper.ParseObjPropertyValue(Obj: Pointer; Index: Integer; con

ptype := PropertyType[Index];
case ptype of
TPropertyType.DeprecatedAndRemoved:
begin
DoSimpleMsg(
'%s.%s: %s',
[TDSSObject(obj).FullName, PropertyName[Index], _(PropertyDeprecatedMessage[Index])],
2020030);

Result := False;
Exit;
end;
TPropertyType.StringSilentROFunctionProperty:
//TPropertyType.DoubleArraySilentROFunctionProperty:
begin
Expand Down
6 changes: 2 additions & 4 deletions src/PCElements/PCElement.pas
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ TPCElement = class(TDSSCktElement)
procedure DumpProperties(F: TFileStream; Complete: Boolean; Leaf: Boolean = False); OVERRIDE;
procedure set_ITerminalUpdated(const Value: Boolean);

// Sweep solution removed PROCEDURE BackwardSweep;Override;

// For Harmonics Mode
// For Harmonics Mode
procedure InitHarmonics; VIRTUAL;

// For Dynamics Mode and Control Devices
// For Dynamics Mode and Control Devices
procedure InitStateVars; VIRTUAL;
procedure IntegrateStates; VIRTUAL;
function NumVariables: Integer; VIRTUAL;
Expand Down
85 changes: 44 additions & 41 deletions src/PCElements/Storage2.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,38 @@ interface
{$SCOPEDENUMS ON}
TStorage2Prop = (
INVALID = 0,
phases = 1,
bus1 = 2,
kv = 3, // propKV
conn = 4, // propCONNECTION
kW = 5, // propKW
kvar = 6, // propKVAR
pf = 7, // propPF
kVA = 8, // propKVA
pctCutin = 9, // propCutin
pctCutout = 10, // propCutout
EffCurve = 11, // propInvEffCurve
VarFollowInverter = 12, // propVarFollowInverter
kvarMax = 13, // propkvarLimit
kvarMaxAbs = 14, // propkvarLimitneg
WattPriority = 15, // propPpriority
PFPriority = 16, // propPFPriority
pctPminNoVars = 17, // propPminNoVars
pctPminkvarMax = 18, // propPminkvarLimit
kWrated = 19, // propKWRATED
pctkWrated = 20, // proppctkWrated
kWhrated = 21, // propKWHRATED
kWhstored = 22, // propKWHSTORED
pctstored = 23, // propPCTSTORED
pctreserve = 24, // propPCTRESERVE
State = 25, // propSTATE
pctDischarge = 26, // propPCTKWOUT
pctCharge = 27, // propPCTKWIN
pctEffCharge = 28, // propCHARGEEFF
pctEffDischarge = 29, // propDISCHARGEEFF
pctIdlingkW = 30, // propIDLEKW
phases,
bus1,
kv, // propKV
conn, // propCONNECTION
kW, // propKW
kvar, // propKVAR
pf, // propPF
kVA, // propKVA
pctCutin, // propCutin
pctCutout, // propCutout
EffCurve, // propInvEffCurve
VarFollowInverter, // propVarFollowInverter
kvarMax, // propkvarLimit
kvarMaxAbs, // propkvarLimitneg
WattPriority, // propPpriority
PFPriority, // propPFPriority
pctPminNoVars, // propPminNoVars
pctPminkvarMax, // propPminkvarLimit
kWrated, // propKWRATED
pctkWrated, // proppctkWrated
kWhrated, // propKWHRATED
kWhstored, // propKWHSTORED
pctstored, // propPCTSTORED
pctreserve, // propPCTRESERVE
State, // propSTATE
pctDischarge, // propPCTKWOUT
pctCharge, // propPCTKWIN
pctEffCharge, // propCHARGEEFF
pctEffDischarge, // propDISCHARGEEFF
pctIdlingkW, // propIDLEKW

// pctIdlingkvar = 31, // propIDLEKVAR --- was deprecated, removed
pctIdlingkvar, //= 31, // propIDLEKVAR was deprecated, reintroduced for v0.12.2; TODO: TO BE REMOVED AGAIN LATER

pctR, // propPCTR
pctX, // propPCTX
Expand All @@ -113,7 +113,7 @@ interface
DynaData, // propDynaData
UserModel, // propUSERMODEL
UserData, // propUSERDATA
debugtrace = 50 // propDEBUGTRACE
debugtrace // propDEBUGTRACE
);
{$SCOPEDENUMS OFF}

Expand Down Expand Up @@ -154,19 +154,19 @@ interface


// Dynamics variables
Vthev: Complex; {Thevenin equivalent voltage (complex) for dynamic model}
Vthev: Complex; // Thevenin equivalent voltage (complex) for dynamic model
ZThev: Complex;
Vthevharm: Double; {Thevenin equivalent voltage mag and angle reference for Harmonic model}
Thetaharm: Double; {Thevenin equivalent voltage mag and angle reference for Harmonic model}
VthevMag: Double; {Thevenin equivalent voltage for dynamic model}
Theta: Double; {Power angle between voltage and current}
w_grid: Double; {Grid frequency}
Vthevharm: Double; // Thevenin equivalent voltage mag and angle reference for Harmonic model
Thetaharm: Double; // Thevenin equivalent voltage mag and angle reference for Harmonic model
VthevMag: Double; // Thevenin equivalent voltage for dynamic model
Theta: Double; // Power angle between voltage and current
w_grid: Double; // Grid frequency
TotalLosses: Double;
IdlingLosses: Double;

{32-bit integers}
NumPhases, {Number of phases}
NumConductors, {Total Number of conductors (wye-connected will have 4)}
// 32-bit integers
NumPhases, // Number of phases
NumConductors, // Total Number of conductors (wye-connected will have 4)
Conn: Integer; // 0 = wye; 1 = Delta
end;

Expand Down Expand Up @@ -605,6 +605,9 @@ procedure TStorage2.DefineProperties;
PropertyFlags[ord(TProp.kvarMax)] := [TPropertyFlag.Transform_Abs];
PropertyFlags[ord(TProp.kvarMaxAbs)] := [TPropertyFlag.Transform_Abs];

PropertyType[ord(TProp.pctIdlingkvar)] := TPropertyType.DeprecatedAndRemoved; //TODO: fully remove
PropertyDeprecatedMessage[ord(TProp.pctIdlingkvar)] := '"%Idlingkvar" was deprecated in 2020. It does nothing since then; please update your scripts.';

// double properties (default type)
PropertyOffset[ord(TProp.pctR)] := ptruint(@obj.pctR);
PropertyOffset[ord(TProp.pctX)] := ptruint(@obj.pctX);
Expand Down

0 comments on commit b215d07

Please sign in to comment.