summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-27 19:59:22 -0500
committercheapie <no-email-for-you@example.com>2024-04-27 19:59:22 -0500
commit6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691 (patch)
treed9b9b4958059a0da87de4cdda66edcc2c4c61c47
parent21574f2a670bfae5b3f7877a6446079d1343f00e (diff)
downloadcelevator-6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691.tar
celevator-6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691.tar.gz
celevator-6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691.tar.bz2
celevator-6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691.tar.xz
celevator-6c00ce6f56c1ab4a9a3f111a3e26175a2f46c691.zip
Allow car to reverse when serving a car call if there is no demand in the original direction
-rw-r--r--controllerfw.lua33
1 files changed, 29 insertions, 4 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index a23932f..d0a4eb5 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -121,8 +121,9 @@ local function gotofloor(floor)
juststarted = true
end
-local function getnextcallabove(dir)
- for i=getpos(),#mem.params.floorheights,1 do
+local function getnextcallabove(dir,excludecurrent)
+ local start = (excludecurrent and getpos()+1 or getpos())
+ for i=start,#mem.params.floorheights,1 do
if not dir then
if mem.carcalls[i] then
return i,"car"
@@ -147,8 +148,9 @@ local function getnextcallabove(dir)
end
end
-local function getnextcallbelow(dir)
- for i=getpos(),1,-1 do
+local function getnextcallbelow(dir,excludecurrent)
+ local start = (excludecurrent and getpos()-1 or getpos())
+ for i=start,1,-1 do
if not dir then
if mem.carcalls[i] then
return i,"car"
@@ -856,21 +858,44 @@ if mem.carmotion then
if mem.carmotion then
interrupt(0.1,"checkdrive")
else
+ local hallcall = mem.upcalls[getpos()] or mem.dncalls[getpos()]
if mem.carstate == "normal" or mem.carstate == "indep" or mem.carstate == "fs1" or mem.carstate == "fs2" then
mem.carcalls[getpos()] = nil
if mem.direction == "up" then
mem.upcalls[getpos()] = nil
mem.swingupcalls[getpos()] = nil
mem.groupupcalls[getpos()] = nil
+ if (not hallcall) and (not getnextcallabove()) and getnextcallbelow() then
+ mem.direction = "down"
+ elseif mem.dncalls[getpos()] and (not mem.upcalls[getpos()]) and (not getnextcallabove(nil,true)) then
+ mem.direction = "down"
+ mem.dncalls[getpos()] = nil
+ mem.swingdncalls[getpos()] = nil
+ mem.groupdncalls[getpos()] = nil
+ end
elseif mem.direction == "down" then
mem.dncalls[getpos()] = nil
mem.swingdncalls[getpos()] = nil
mem.groupdncalls[getpos()] = nil
+ if (not hallcall) and (not getnextcallbelow()) and getnextcallabove() then
+ mem.direction = "up"
+ elseif mem.upcalls[getpos()] and (not mem.dncalls[getpos()]) and (not getnextcallbelow(nil,true)) then
+ mem.direction = "up"
+ mem.upcalls[getpos()] = nil
+ mem.swingupcalls[getpos()] = nil
+ mem.groupupcalls[getpos()] = nil
+ end
end
if getpos() >= #mem.params.floornames then
mem.direction = "down"
+ mem.dncalls[#mem.params.floornames] = nil
+ mem.swingdncalls[#mem.params.floornames] = nil
+ mem.groupdncalls[#mem.params.floornames] = nil
elseif getpos() <= 1 then
mem.direction = "up"
+ mem.upcalls[1] = nil
+ mem.swingupcalls[1] = nil
+ mem.groupupcalls[1] = nil
end
if (mem.carstate ~= "fs1" or getpos() == (mem.params.mainlanding or 1)) and mem.carstate ~= "fs2" and mem.carstate ~= "fs2hold" then open() end
if mem.carstate == "fs1" and getpos() ~= (mem.params.mainlanding or 1) then