Skip to content

Commit

Permalink
CapControl, port SVN 3622: "Solves a bug introduced in version 9.6.1.…
Browse files Browse the repository at this point in the history
…2 when using CapControl in time or follow control modes." by davismont.

Note: slightly changed, there was another potential bug in the fix.

Ref:
git-svn-id: https://svn.code.sf.net/p/electricdss/code/trunk@3622 d8739450-1e93-4ef4-a0af-c327d92816ff
  • Loading branch information
PMeira committed Jun 23, 2023
1 parent 0dea44c commit e11c3bc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Controls/CapControl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ destructor TCapControlObj.Destroy;
end;

procedure TCapControlObj.RecalcElementData;
var
effElement: TDSSCktElement = NIL;
begin
// Check for existence of capacitor

Expand Down Expand Up @@ -568,17 +570,21 @@ procedure TCapControlObj.RecalcElementData;
DoErrorMsg(FullName,
Format(_('Terminal number %d does not exist.'), [ElementTerminal]),
_('Re-specify terminal number.'), 362);
end
else
begin
// Sets name of i-th terminal's connected bus in CapControl's buslist
Setbus(1, MonitoredElement.GetBus(ElementTerminal));
// Allocate a buffer bigenough to hold everything from the monitored element
ReAllocMem(cBuffer, SizeOF(cbuffer[1]) * MonitoredElement.Yorder);
ControlVars.CondOffset := (ElementTerminal - 1) * MonitoredElement.NConds; // for speedy sampling
Exit;
end;
effElement := MonitoredElement;
end
else
begin
effElement := ControlledElement;
end;

// Sets name of i-th terminal's connected bus in CapControl's buslist
Setbus(1, effElement.GetBus(ElementTerminal));
// Allocate a buffer bigenough to hold everything from the monitored element
ReAllocMem(cBuffer, SizeOF(cbuffer[1]) * effElement.Yorder);
ControlVars.CondOffset := (ElementTerminal - 1) * effElement.NConds; // for speedy sampling

// Alternative override bus
if ControlVars.VoverrideBusSpecified then
with ControlVars do
Expand Down Expand Up @@ -815,7 +821,7 @@ procedure TCapControlObj.Sample;
else
ControlVars.PresentState := CTRL_OPEN;

with MonitoredElement, ControlVars do
with ControlVars do
begin
ShouldSwitch := FALSE;

Expand Down

0 comments on commit e11c3bc

Please sign in to comment.