summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controllerfw.lua42
-rw-r--r--dispatcherfw.lua12
2 files changed, 40 insertions, 14 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index a08da7e..62ae939 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -478,18 +478,24 @@ elseif event.iid == "closed" and (mem.doorstate == "closing" or mem.doorstate ==
juststarted = true
end
elseif event.type == "callbutton" and mem.carstate == "normal" then
- if mem.params.groupmode == "group" then
- if event.dir == "up" and event.landing >= 1 and event.landing < #mem.params.floornames then
- mem.swingupcalls[event.landing] = true
- elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then
- mem.swingdncalls[event.landing] = true
- end
- else
- if event.dir == "up" and event.landing >= 1 and event.landing < #mem.params.floornames then
- mem.upcalls[event.landing] = true
- elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then
- mem.dncalls[event.landing] = true
+ if mem.doorstate == "closed" or mem.direction ~= event.dir or getpos() ~= event.landing then
+ if mem.params.groupmode == "group" then
+ if event.dir == "up" and event.landing >= 1 and event.landing < #mem.params.floornames then
+ mem.swingupcalls[event.landing] = true
+ elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then
+ mem.swingdncalls[event.landing] = true
+ end
+ else
+ if event.dir == "up" and event.landing >= 1 and event.landing < #mem.params.floornames then
+ mem.upcalls[event.landing] = true
+ elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then
+ mem.dncalls[event.landing] = true
+ end
end
+ elseif mem.direction == event.dir and mem.doorstate == "open" then
+ interrupt(mem.params.doortimer,"close")
+ elseif mem.direction == event.dir and mem.doorstate == "closing" then
+ open()
end
elseif event.iid == "checkopen" then
if mem.drive.status.doorstate == "open" then
@@ -518,7 +524,19 @@ elseif event.type == "cop" then
if string.sub(k,1,7) == "carcall" then
local landing = tonumber(string.sub(k,8,-1))
if v and landing and landing >= 1 and landing <= #mem.params.floorheights then
- mem.carcalls[landing] = true
+ if getpos() == landing then
+ if mem.carstate == "normal" or mem.carstate == "indep" then
+ if mem.doorstate == "closing" then
+ open()
+ elseif mem.doorstate == "open" then
+ interrupt(mem.params.doortimer,"close")
+ elseif mem.doorstate == "closed" then
+ mem.carcalls[landing] = true
+ end
+ end
+ else
+ mem.carcalls[landing] = true
+ end
end
end
end
diff --git a/dispatcherfw.lua b/dispatcherfw.lua
index 083d755..1d88888 100644
--- a/dispatcherfw.lua
+++ b/dispatcherfw.lua
@@ -581,15 +581,19 @@ elseif event.type == "abm" or event.iid == "run" and (mem.screenstate == "status
end
local besteta = 999
local bestcar
+ local alreadyserved
for carid in pairs(eligiblecars) do
local eta = calculateeta(carid,i,"up")
if eta < besteta then
besteta = eta
bestcar = carid
end
+ if getpos(carid) == i and mem.carstatus[carid].direction == "up" and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") then
+ alreadyserved = true
+ end
end
mem.upeta[i] = besteta
- if bestcar then
+ if bestcar and not alreadyserved then
send(bestcar,"groupupcall",realtocarfloor(bestcar,i))
mem.assignedup[i] = bestcar
else
@@ -654,15 +658,19 @@ elseif event.type == "abm" or event.iid == "run" and (mem.screenstate == "status
if not permanent then
local besteta = 999
local bestcar
+ local alreadyserved = false
for carid in pairs(eligiblecars) do
local eta = calculateeta(carid,i,"down")
if eta < besteta then
besteta = eta
bestcar = carid
end
+ if getpos(carid) == i and mem.carstatus[carid].direction == "down" and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") then
+ alreadyserved = true
+ end
end
mem.dneta[i] = besteta
- if bestcar then
+ if bestcar and not alreadyserved then
send(bestcar,"groupdncall",realtocarfloor(bestcar,i))
mem.assigneddn[i] = bestcar
else