-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwtControls.Action() has no effect after SwtControl is unlocked #99
Comments
If you check It seems that the only way to set COM version of the sample codeimport os, win32com.client
orgcd = os.getcwd()
dss = win32com.client.Dispatch('OpenDSSengine.DSS')
os.chdir(orgcd)
dss.Text.Command = "redirect IEEE13Nodeckt.dss"
dss.Text.Command = "new swtcontrol.sw1 delay=0.0 normal=closed switchedobj=line.671684 switchedterm=1"
dss.ActiveCircuit.Solution.SolveSnap()
dss.ActiveCircuit.SwtControls.Name = "sw1"
# open the switch
dss.ActiveCircuit.SwtControls.Action = 1
dss.ActiveCircuit.Solution.SolvePlusControl()
# lock the switch control
dss.ActiveCircuit.SwtControls.IsLocked = True
# try to close the switch ...
dss.ActiveCircuit.SwtControls.Action = 2
dss.ActiveCircuit.Solution.SolvePlusControl()
# ... but the line is still open because the control is locked
dss.ActiveCircuit.SetActiveElement("line.671684")
assert dss.ActiveCircuit.ActiveCktElement.IsOpen(1, 1)
# unlock the control and close the switch
dss.ActiveCircuit.SwtControls.IsLocked = False
dss.ActiveCircuit.SwtControls.Action = 2
dss.ActiveCircuit.Solution.SolvePlusControl()
# the line should now be closed
assert not dss.ActiveCircuit.ActiveCktElement.IsOpen(1, 1)
It does the following instantly, no control queue is involved (unlike
Looks like just saving its state, resetting, then updating the state to the saved state would be enough, no? By the way, be sure you know what |
# [...]
# unlock the control and close the switch
state = dssdirect.SwtControls.State()
dssdirect.SwtControls.Reset()
dssdirect.SwtControls.State(state)
dssdirect.Solution.Solve()
assert dssdirect.CktElement.IsOpen(1, 1), "closed after reset (should be open)" Unfortunately that work-around doesn't seem to work. Checking the event log I see an extra control action has been taken to close the switch, and the call to
I'll hit up the official OpenDSS forums. If there is a reason, I'd like to understand it. The current behavior seem pretty strange to me; makes me question whether I'm using switch controls correctly in the first place.
My understanding is that it just executes a powerflow then clears the control queue by executing all pending actions, is that right? |
Just checked the code again, and yeah, it wouldn't work. A state diagram would certainly help clear things up.
The main |
@wfvining, sorry to bother, did you ever look further into this? |
Versions
Bug
Switch controls don't work after being unlocked. For example after calling
SwtControls.IsLocked(False)
I should be able to useSwtControls.Action()
to open or close the switch, but it has no effect. If I reset the control withSwtControls.Reset()
then I can open/close the switch again.After unlocking a switch control object it should be possible to use it to open/close the switch it controls by calling
SwtControls.Action()
without resetting the switch controller. Using reset may change the state of the switch which prevents me from simulating a situation where the switch can operate again, but I want it to stay its current state (which may or may not be its "normal" state).The text was updated successfully, but these errors were encountered: