summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-05-10 19:18:46 -0500
committercheapie <no-email-for-you@example.com>2024-05-10 19:18:46 -0500
commit5ac4571337aea7ea2f9153a3138c3d1db1ff981f (patch)
tree1686893be4a08b9f4049541e20d498cb9d3b36d6
parent79aae966416d5a5322d1bd74113382d16e997c54 (diff)
downloadcelevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar
celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.gz
celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.bz2
celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.tar.xz
celevator-5ac4571337aea7ea2f9153a3138c3d1db1ff981f.zip
Fix some minor bugs
This improves fire recall when the car is currently moving past the recall floor, and fixes a delay in hall call dispatching when a car is currently leaving the floor the call is on.
-rw-r--r--controllerfw.lua18
-rw-r--r--dispatcherfw.lua17
2 files changed, 29 insertions, 6 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index b509df8..47f21f0 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -833,12 +833,26 @@ elseif mem.fs1switch then
end
end
elseif mem.drive.status.vel < 0 and mem.drive.status.apos < gettarget(mem.params.mainlanding or 1) then
- for i=1,getpos(),1 do
+ for i=getpos(),1,-1 do
if mem.drive.status.neareststop > gettarget(i) and mem.drive.status.dpos < gettarget(i) then
gotofloor(i)
break
end
end
+ elseif mem.drive.status.vel < 0 and mem.drive.status.dpos < gettarget(mem.params.mainlanding or 1) and mem.drive.status.apos > gettarget(mem.params.mainlanding or 1) then
+ for i=(mem.params.mainlanding or 1),1,-1 do
+ if mem.drive.status.neareststop > gettarget(i) and mem.drive.status.dpos < gettarget(i) then
+ gotofloor(i)
+ break
+ end
+ end
+ elseif mem.drive.status.vel > 0 and mem.drive.status.dpos > gettarget(mem.params.mainlanding or 1) and mem.drive.status.apos < gettarget(mem.params.mainlanding or 1) then
+ for i=(mem.params.mainlanding or 1),#mem.params.floornames,1 do
+ if mem.drive.status.neareststop < gettarget(i) and mem.drive.status.dpos > gettarget(i) then
+ gotofloor(i)
+ break
+ end
+ end
elseif getpos() ~= (mem.params.mainlanding or 1) then
if not (mem.carmotion or juststarted) then
if mem.doorstate == "closed" then
@@ -847,7 +861,7 @@ elseif mem.fs1switch then
close()
end
end
- elseif mem.doorstate == "closed" then
+ elseif mem.doorstate == "closed" or mem.doorstate == "closing" then
if not (mem.carmotion or juststarted) then
open()
end
diff --git a/dispatcherfw.lua b/dispatcherfw.lua
index aac7e07..bb609d5 100644
--- a/dispatcherfw.lua
+++ b/dispatcherfw.lua
@@ -169,7 +169,15 @@ local function gettarget(floor)
return target
end
-local function predictnextstop(carid,startpos,direction,carcalls,upcalls,dncalls)
+local function predictnextstop(carid,startpos,direction,carcalls,upcalls,dncalls,leaving)
+ if leaving then
+ local vel = mem.carstatus[carid].vel
+ if vel > 0 then
+ startpos = startpos+1
+ elseif vel < 0 then
+ startpos = startpos-1
+ end
+ end
if direction == "up" then
if getnextcallabove(carid,"up",startpos,carcalls,upcalls,dncalls) then
return getnextcallabove(carid,"up",startpos,carcalls,upcalls,dncalls),"up"
@@ -216,7 +224,7 @@ local function estimatetraveltime(carid,src,dest)
return estimate
end
-local function buildstopsequence(carid,startfloor,direction,target,targetdir)
+local function buildstopsequence(carid,startfloor,direction,target,targetdir,leaving)
local carcalls = cartorealfloor(carid,mem.carstatus[carid].carcalls)
local upcalls = cartorealfloor(carid,mem.carstatus[carid].upcalls)
local dncalls = cartorealfloor(carid,mem.carstatus[carid].dncalls)
@@ -235,7 +243,7 @@ local function buildstopsequence(carid,startfloor,direction,target,targetdir)
end
repeat
local src = carpos
- carpos,direction = predictnextstop(carid,carpos,direction,carcalls,upcalls,dncalls)
+ carpos,direction = predictnextstop(carid,carpos,direction,carcalls,upcalls,dncalls,leaving)
carcalls[carpos] = nil
if direction == "up" then
upcalls[carpos] = nil
@@ -251,7 +259,8 @@ local function buildstopsequence(carid,startfloor,direction,target,targetdir)
end
local function calculateeta(carid,floor,direction)
- local sequence = buildstopsequence(carid,getpos(carid),mem.carstatus[carid].direction,floor,direction)
+ local leaving = (getpos(carid) ~= getdpos(carid)) and (getpos(carid) == floor)
+ local sequence = buildstopsequence(carid,getpos(carid),mem.carstatus[carid].direction,floor,direction,leaving)
local doorstate = mem.carstatus[carid].doorstate
local doortimes = {
closed = 0,