Hi all,
This was reported to us on GitHub but also affects the official COM interface.
In the circuit interface (TCircuit.Disable(const Name: WideString), TCircuit.Enable(const Name: WideString)), the Name variable is ambiguous since there is the procedure argument Name and ActiveCircuit[ActiveActor].Name, introduced via WITH scoping. Effectively, the circuit name is used instead of the argument. This will then either enable the wrong element or use the latest activated element.
As a workaround, COM users could use the Text interface instead (e.g. editing and setting enabled=n, or using the disable DSS command).
A minimal sample in Python to reproduce the issue:
importcomtypes.clientdss=comtypes.client.CreateObject('OpenDSSengine.DSS')print(dss.Version)dss.Text.Command='new Circuit.test'dss.Text.Command='new Load.A'dss.Text.Command='new Load.B'# Try to disable the first loaddss.ActiveCircuit.Disable('Load.A')# Here we can see that the it uses the latest activated element, disabling itprint(dss.ActiveCircuit.ActiveDSSElement.Name,dss.ActiveCircuit.ActiveDSSElement.Properties['enabled'].Val)# And here we manually check both loadsdss.ActiveCircuit.SetActiveElement('Load.A')print(dss.ActiveCircuit.ActiveDSSElement.Name,dss.ActiveCircuit.ActiveDSSElement.Properties['enabled'].Val)dss.ActiveCircuit.SetActiveElement('Load.B')print(dss.ActiveCircuit.ActiveDSSElement.Name,dss.ActiveCircuit.ActiveDSSElement.Properties['enabled'].Val)
Current output:
Version 9.6.1.3 (64-bit build); License Status: Open
Load.b false
Load.a true
Load.b false
To fix this, either renaming the argument Name in the related code to make it distinct or removing the use of the WITH construct both work. There are other similar issues related to WITH in the Delphi codebase.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
This was reported to us on GitHub but also affects the official COM interface.
In the circuit interface (
TCircuit.Disable(const Name: WideString)
,TCircuit.Enable(const Name: WideString)
), theName
variable is ambiguous since there is the procedure argumentName
andActiveCircuit[ActiveActor].Name
, introduced viaWITH
scoping. Effectively, the circuit name is used instead of the argument. This will then either enable the wrong element or use the latest activated element.As a workaround, COM users could use the Text interface instead (e.g. editing and setting
enabled=n
, or using thedisable
DSS command).Related code in: https://sourceforge.net/p/electricdss/code/3639/tree/trunk/Version8/Source/DLL/ImplCircuit.pas#l392
A minimal sample in Python to reproduce the issue:
Current output:
To fix this, either renaming the argument
Name
in the related code to make it distinct or removing the use of theWITH
construct both work. There are other similar issues related toWITH
in the Delphi codebase.Dear Paulo,
Thanks for the heads up, this change will be reflected in our next release.
Best regards
Davis