summaryrefslogtreecommitdiff
path: root/controllerfw.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-19 11:24:33 -0500
committercheapie <no-email-for-you@example.com>2024-04-19 11:24:33 -0500
commitc3d04606a3b4da5181ce3467cb9e77d6a4e61b04 (patch)
tree15c8277c9a9ed0bddf2f419d24a93bcdc74ad19d /controllerfw.lua
parent52821fcc17d7b17c5bb9f6ccbb1c13cbdddf71b2 (diff)
downloadcelevator-c3d04606a3b4da5181ce3467cb9e77d6a4e61b04.tar
celevator-c3d04606a3b4da5181ce3467cb9e77d6a4e61b04.tar.gz
celevator-c3d04606a3b4da5181ce3467cb9e77d6a4e61b04.tar.bz2
celevator-c3d04606a3b4da5181ce3467cb9e77d6a4e61b04.tar.xz
celevator-c3d04606a3b4da5181ce3467cb9e77d6a4e61b04.zip
Initial dispatcher work (not yet functional)
Diffstat (limited to 'controllerfw.lua')
-rw-r--r--controllerfw.lua42
1 files changed, 39 insertions, 3 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index 4fb93b3..e768efd 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -2,6 +2,16 @@ local pos,event,mem = ...
local changedinterrupts = {}
+mem.messages = {}
+
+local function send(carid,channel,message)
+ table.insert(mem.messages,{
+ carid = carid,
+ channel = channel,
+ message = message,
+ })
+end
+
local function fault(ftype,fatal)
if fatal then mem.fatalfault = true end
if not mem.activefaults then mem.activefaults = {} end
@@ -527,6 +537,31 @@ elseif event.type == "cartopbox" then
pos = math.floor(mem.drive.status.apos)-1
})
end
+elseif event.type == "dispatchermsg" then
+ if event.channel == "pairrequest" and mem.screenstate == "oobe_dispatcherconnect" then
+ mem.params.floornames = event.msg.floornames
+ mem.params.floorheights = event.msg.floorheights
+ mem.activefaults = {}
+ mem.faultlog = {}
+ mem.fatalfault = false
+ mem.state = "configured"
+ mem.screenstate = "status"
+ mem.screenpage = 1
+ mem.carstate = "bfdemand"
+ if mem.doorstate == "closed" then
+ drivecmd({
+ command = "setmaxvel",
+ maxvel = mem.params.contractspeed,
+ })
+ drivecmd({command = "resetpos"})
+ interrupt(0.1,"checkdrive")
+ mem.carmotion = true
+ juststarted = true
+ else
+ close()
+ end
+ send(event.source,"pairok",mem)
+ end
end
local oldstate = mem.carstate
@@ -787,10 +822,11 @@ elseif mem.screenstate == "oobe_groupmode" then
fs("button[1,3;2,1;simplex;Simplex]")
fs("label[1,4.5;This will be the only elevator in the group. Hall calls will be handled by this controller.]")
fs("button[1,6;2,1;group;Group]")
- fs("label[1,7.5;This elevator will participate in a group with others. Hall calls will be handled by a dispatcher. (not implemented)]")
+ fs("label[1,7.5;This elevator will participate in a group with others. Hall calls will be handled by a dispatcher.]")
elseif mem.screenstate == "oobe_dispatcherconnect" then
- fs("button[1,10;2,1;back;< Back]")
- fs("label[1,1;Not yet implemented. Press Back.]")
+ fs("button[1,10;2,1;back;< Cancel]")
+ fs("label[1,1;Waiting for connection from dispatcher...]")
+ fs(string.format("label[1,1.5;This controller's car ID is: %d]",mem.carid))
elseif mem.screenstate == "oobe_floortable" or mem.screenstate == "floortable" then
if mem.screenstate == "oobe_floortable" then
fs("label[1,1;Enter details of all floors this elevator will serve, then press Done.]")