diff options
Diffstat (limited to 'auto_yards')
42 files changed, 495 insertions, 42 deletions
diff --git a/auto_yards/init_code.lua b/auto_yards/init_code.lua index 92b69bd..0a4312c 100644 --- a/auto_yards/init_code.lua +++ b/auto_yards/init_code.lua @@ -4,39 +4,79 @@ if event.init then S.yards = { --[[ yard info template - yard_id = { + yard_id = { + yard_name = string, active_indicator_pos = POS(), dir_indicator_pos = POS(), error_indicator_pos = POS(), headshunt_max = number, notify = empty table, notify_pos = pos, + + -- reserved vars -- + last_id = string (the id of the last train that entered the yard last) + arrival_length = number + arrival_time = string (RWT) + departure_length = number or "?" (set when train arrives, until train departs) + departure_time = string (RWT) + rts = bool (whether the entering train will exit the way it came in) }, ]]-- TY = { + yard_name = "Trisiston", active_indicator_pos = POS(-4025,14,-2659), dir_indicator_pos = POS(-4025,12,-2665), error_indicator_pos = POS(-4025,13,-2671), headshunt_max = 5, - + notify = {}, + notify_pos = POS(-4023,12,-2660), + arrival_time = rwt.now(), + departure_time = rwt.now() }, BY = { + yard_name = "Banach", active_indicator_pos = POS(-2002,3,-1099), dir_indicator_pos = POS(-2009,3,-1101), error_indicator_pos = POS(-1999,3,-1099), headshunt_max = 5, notify = {}, - notify_pos = POS(-2004,2,-1101) + notify_pos = POS(-2004,2,-1101), + arrival_time = rwt.now(), + departure_time = rwt.now() + }, + ARC = { + yard_name = "Arcadius", + active_indicator_pos = POS(-1952,16,840), + dir_indicator_pos = POS(-1950,16,840), + error_indicator_pos = POS(-1948,16,840), + headshunt_max = 5, + notify = {}, + notify_pos = POS(-1946,16,840), + arrival_time = rwt.now(), + departure_time = rwt.now() }, IP = { + yard_name = "Ipswich", active_indicator_pos = POS(1179,16,3848), dir_indicator_pos = POS(1177,16,3855), error_indicator_pos = POS(1179,16,3850), headshunt_max = 5, notify = {}, - notify_pos = POS(1178,16,3851) - + notify_pos = POS(1178,16,3851), + arrival_time = rwt.now(), + departure_time = rwt.now() }, + CAN = { + yard_name = "Cannery", + active_indicator_pos = POS(-594,26,2486), + dir_indicator_pos = POS(-594,26,2484), + error_indicator_pos = POS(-594,26,2482), + headshunt_max = 2, + --notify = {}, + --notify_pos = POS(-594,26,2485), + arrival_time = rwt.now(), + departure_time = rwt.now() + } -- HY = { -- active_indicator_pos = POS(-4025,14,-2659), -- dir_indicator_pos = POS(-4025,13,-2665), @@ -75,12 +115,12 @@ F.has_rc_match = function(query,rc_list) -- query = pattern string, single entry if not atc_id then return false end if rc_list == "" or query == nil or query=="" then return false end if not rc_list then rc_list = F.get_rc_safe() end - + local rc = {} for v in rc_list:gmatch("("..query..")") do table.insert(rc,v) end - + if rc[1] == true then return true, rc else @@ -102,11 +142,11 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" -- true: with arrow direction -- false: against arrow direction -- nil: ignores arrow direction - + if not atc_id then return false end if not rc_list then return false end - - if (arrow_mode == nil) or (atc_arrow == arrow_mode) then + + if (arrow_mode == nil) or (atc_arrow == arrow_mode) then -- prep rc_list to useable format local rc_remove = {} if type(rc_list) == "string" then @@ -118,7 +158,7 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" rc_remove[word] = true end end - + -- remove codes from train's rc local rc = F.get_rc_safe() local reinsert = {} @@ -146,7 +186,8 @@ end ---------------------------------------------------------------------------------------------- -- Trackside Functions -F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard +-- this_dir = points towards Origin/Junction Yard +F.yard_arrival = function(yard_id,this_dir, force_rts) -- arrow points towards yard local yard = S.yards[yard_id] --yard ref if F.has_rc(yard_id.."_NOSHUNT") then return end @@ -160,16 +201,28 @@ F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard F.indicator(yard.active_indicator_pos,true) F.add_rc({yard_id.."_ARRIVE"}) local rts = false - if F.has_rc(yard_id.."_RTS") then --save the RTS flag as it's removed during the arrival procedure + if force_rts then -- yard is designated as a terminus yard. all trains MUST rts + F.add_rc(yard_id.."_RTS") + rts = true + elseif F.has_rc(yard_id.."_RTS") then --save the RTS flag as it's removed during the arrival procedure F.add_rc({yard_id.."_HAS_RTS"}) rts = true end atc_set_ars_disable(false) atc_send("S6") - - print(rwt.to_string(rwt.now())) - print("YARD "..yard_id..": Train "..atc_id.." enters from the "..tostring(this_dir).." direction and "..((rts and "will") or "won't").." return in the same direction") - print("YARD "..yard_id..": Length "..train_length()) + + S.yards[yard_id].last_id = atc_id + S.yards[yard_id].arrival_length = train_length() + S.yards[yard_id].arrival_time = rwt.now() + S.yards[yard_id].departure_length = "?" + S.yards[yard_id].departure_time = rwt.now() + S.yards[yard_id].rts = rts + + if S.print_debug then + print(rwt.to_string(rwt.now())) + print("YARD "..yard_id..": Train "..atc_id.." enters from the "..tostring(this_dir).." direction and will exit in the "..tostring(rts).." direction") + print("YARD "..yard_id..": Length "..train_length()) + end return end @@ -182,14 +235,16 @@ F.yard_arrival = function(yard_id,this_dir) -- arrow points towards yard if event.train and atc_arrow then if F.indicator(yard.active_indicator_pos) then - print(rwt.to_string(rwt.now())) - print("YARD "..yard_id..": Train "..atc_id.." has arrived and has to wait for the yard to deactivate.") + if S.print_debug then + print(rwt.to_string(rwt.now())) + print("YARD "..yard_id..": Train "..atc_id.." has arrived from the "..tostring(this_dir).." direction and has to wait for the yard to deactivate.") + end schedule_in(";10","recheck") return else enter_yard() return true - end + end end if event.schedule then @@ -208,7 +263,7 @@ F.classification = function(yard_id, this_dir) -- arrow points towards headshunt if not F.indicator(yard.active_indicator_pos) then return end if F.has_rc(yard_id.."_NOSHUNT") then return end - + -- this_dir == true for north end, false for south end if F.indicator(yard.active_indicator_pos) then if atc_arrow then -- loco is at working end @@ -235,8 +290,8 @@ F.classification = function(yard_id, this_dir) -- arrow points towards headshunt F.indicator(yard.dir_indicator_pos,not F.indicator(yard.dir_indicator_pos)) F.remove_rc({yard_id.."_RTS"}) F.add_rc({yard_id.."_AROUND"}) -- send loco around to the other end - atc_set_ars_disable(false) end + atc_set_ars_disable(false) return -- train has departed for headshunt/around end --else train has arrived from wagon count and headshunt/around F.remove_rc({yard_id.."_ARRIVE"}) @@ -262,6 +317,7 @@ F.classification = function(yard_id, this_dir) -- arrow points towards headshunt unset_autocouple() end else -- train entering from the far end. set autocouple so it pushes all the way through to the bounce + atc_set_ars_disable(true) set_autocouple() end end @@ -302,7 +358,7 @@ F.headshunt_yard = function(yard_id,this_dir) -- arrow points toward yard return end end - + --else let train proceed forward to the exit controller without a rake end --else train has already collected rake. let it exit yard else --train has bounced @@ -314,7 +370,7 @@ F.headshunt_yard = function(yard_id,this_dir) -- arrow points toward yard return end --if at wrong end, do nothing. train will follow <yard_id>_AROUND ARS to relevant headshunt end -- if doesn't have <yard_id>_AROUND then let ARS classify the train - + atc_set_ars_disable(false) end return @@ -338,7 +394,7 @@ end F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard local yard = S.yards[yard_id] --yard ref - + __approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) @@ -348,22 +404,25 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard if not F.indicator(yard.active_indicator_pos) then return end if F.has_rc(yard_id.."_NOSHUNT") then return end - + if event.train then if atc_arrow and (F.indicator(yard.dir_indicator_pos) == this_dir) then if F.has_rc(yard_id.."_DEPART") then - print(rwt.to_string(rwt.now())) - print("YARD "..yard_id..": Train "..atc_id.." has a length of "..train_length()) - print("YARD "..yard_id..": It will depart in the "..tostring(this_dir).." direction.") + if S.print_debug then + print(rwt.to_string(rwt.now())) + print("YARD "..yard_id..": Train "..atc_id.." has a length of "..train_length()) + print("YARD "..yard_id..": It will depart in the "..tostring(this_dir).." direction.") + end + S.yards[yard_id].departure_length = train_length() unset_autocouple() F.remove_rc({yard_id.."_FINAL_COLLECT",yard_id.."_DEPART"}) F.remove_rc_match(yard_id.."_LOCOS_%d+") F.remove_rc_match(yard_id.."_WAGONS_%d+") - + if yard.notify_pos then interrupt_pos(yard.notify_pos,"notify") end - + if F.has_rc(yard_id.."_HAS_RTS") then --reinsert the RTS flag to fully return RC list to starting F.remove_rc(yard_id.."_HAS_RTS") F.add_rc({yard_id.."_RTS"}) @@ -384,8 +443,11 @@ F.headshunt_exit = function(yard_id,this_dir) -- arrow points out of yard if event.msg == "deactivate_check" then if not atc_id then F.indicator(yard.active_indicator_pos,false) - print(rwt.to_string(rwt.now())) - print("YARD "..yard_id..": yard Disabled") + S.yards[yard_id].departure_time = rwt.now() + if S.print_debug then + print(rwt.to_string(rwt.now())) + print("YARD "..yard_id..": yard Disabled") + end else schedule_in(";05","deactivate_check") return @@ -399,7 +461,7 @@ F.lane_EOL = function(yard_id,this_dir) -- arrow points towards headshunt if not F.indicator(yard.active_indicator_pos) then return end if F.has_rc(yard_id.."_NOSHUNT") then return end - + if atc_arrow then if F.indicator(yard.dir_indicator_pos) == this_dir then --train has bounced and needs to leave the rake or depart with it if F.has_rc(yard_id.."_LAST_CLASS") then -- this is the last clasification move @@ -413,7 +475,7 @@ F.lane_EOL = function(yard_id,this_dir) -- arrow points towards headshunt end --if has FINAL_COLLECT then don't split off the loco. take the full rake F.add_rc({yard_id.."_HEADSHUNT"}) else --train needs to bounce - atc_send("B0WRD1S4") + atc_send("S0WRD1S4") end else if F.indicator(yard.dir_indicator_pos) == this_dir then diff --git a/auto_yards/nodes/(-1908,16,835).lua b/auto_yards/nodes/(-1908,16,835).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1908,16,835).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1910,16,837).lua b/auto_yards/nodes/(-1910,16,837).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1910,16,837).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1912,16,839).lua b/auto_yards/nodes/(-1912,16,839).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1912,16,839).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1925,16,833).lua b/auto_yards/nodes/(-1925,16,833).lua new file mode 100644 index 0000000..2d94f29 --- /dev/null +++ b/auto_yards/nodes/(-1925,16,833).lua @@ -0,0 +1 @@ +F.classification("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1928,16,834).lua b/auto_yards/nodes/(-1928,16,834).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1928,16,834).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1933,16,806).lua b/auto_yards/nodes/(-1933,16,806).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1933,16,806).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1933,16,833).lua b/auto_yards/nodes/(-1933,16,833).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1933,16,833).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1936,16,834).lua b/auto_yards/nodes/(-1936,16,834).lua new file mode 100644 index 0000000..89349e3 --- /dev/null +++ b/auto_yards/nodes/(-1936,16,834).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1946,16,801).lua b/auto_yards/nodes/(-1946,16,801).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1946,16,801).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1947,16,837).lua b/auto_yards/nodes/(-1947,16,837).lua new file mode 100644 index 0000000..f77e28c --- /dev/null +++ b/auto_yards/nodes/(-1947,16,837).lua @@ -0,0 +1,2 @@ +S.yards.ARC.notify = {['ARC_SB'] = true, ['CANNERY'] = true} +print(S.yards.ARC.notify)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1954,16,797).lua b/auto_yards/nodes/(-1954,16,797).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1954,16,797).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1957,3,-1059).lua b/auto_yards/nodes/(-1957,3,-1059).lua new file mode 100644 index 0000000..ad61223 --- /dev/null +++ b/auto_yards/nodes/(-1957,3,-1059).lua @@ -0,0 +1 @@ +F.lane_EOL("BY",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1958,16,808).lua b/auto_yards/nodes/(-1958,16,808).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1958,16,808).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1959,16,811).lua b/auto_yards/nodes/(-1959,16,811).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1959,16,811).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1965,16,793).lua b/auto_yards/nodes/(-1965,16,793).lua new file mode 100644 index 0000000..677ba3a --- /dev/null +++ b/auto_yards/nodes/(-1965,16,793).lua @@ -0,0 +1 @@ +F.classification("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1966,16,796).lua b/auto_yards/nodes/(-1966,16,796).lua new file mode 100644 index 0000000..4503e25 --- /dev/null +++ b/auto_yards/nodes/(-1966,16,796).lua @@ -0,0 +1 @@ +F.lane_EOL("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1976,16,782).lua b/auto_yards/nodes/(-1976,16,782).lua new file mode 100644 index 0000000..3c1b64f --- /dev/null +++ b/auto_yards/nodes/(-1976,16,782).lua @@ -0,0 +1 @@ +F.yard_arrival("ARC",false,true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-1982,17,780).lua b/auto_yards/nodes/(-1982,17,780).lua new file mode 100644 index 0000000..072f902 --- /dev/null +++ b/auto_yards/nodes/(-1982,17,780).lua @@ -0,0 +1,51 @@ +local yard_id = "ARC" + + +if event.train then + if F.has_rc("ARC_LIGHT_EXIT") then return end + if F.has_rc("ARC_NOSHUNT") then return end + + if train_length() == 1 then -- eliminates near half the trains + if F.has_rc("ARC_LOCOSTORE") then -- specifies only the relevant train + if F.has_rc("ARC_DEPART") and F.has_rc("ARC_FINAL_COLLECT") and F.has_rc("ARC_HEADSHUNT") then --only activate if train is set to depart anyway + if not atc_arrow then -- train is pointing towards exit. let it pass and the reverse it + atc_set_ars_disable(true) + schedule_in(";01",atc_id) -- prepare to reverse the train + return + else --train has reversed. send it to the siding and deactivate the yard + F.remove_rc({"ARC_DEPART","ARC_FINAL_COLLECT"}) + F.add_rc("ARC_send_to_locostore") + atc_set_ars_disable(false) + F.indicator(S.yards[yard_id].active_indicator_pos, false) + S.yards[yard_id].departure_time = rwt.now() + S.yards[yard_id].departure_length = S.yards[yard_id].arrival_length + + if S.yards[yard_id].notify_pos then + interrupt_pos(S.yards[yard_id].notify_pos,"notify") + end + return + end + end + end + end +end + +if event.schedule then --this is a duplicate of the reversing schedule in the env anyway + if not atc_id then --bounce the train that just passed + atc_send_to_train(event.msg,"B0WRD1A1S3") + else + if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer + schedule_in(";01",atc_id) + else -- somehow another train crossed the controller before the first one returned. Unlikely but possible + atc_send_to_train(event.msg,"BBOL") + atc_send("BBOL") + F.indicator(yard.error_indicator_pos,true) + end + end + return +end + + + +-- if all else fails, do a normal headshunt_yard function +F.headshunt_yard("ARC",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-2004,2,-1101).lua b/auto_yards/nodes/(-2004,2,-1101).lua index b686f37..c0d57ae 100644 --- a/auto_yards/nodes/(-2004,2,-1101).lua +++ b/auto_yards/nodes/(-2004,2,-1101).lua @@ -1,13 +1,25 @@ local yard_id = "BY" + +if not S.yards[yard_id].notify then return end + local subs = { - ['S27'] = POS(-1512,8,-2613), +--[[ + A list of FC subscribers to send out notifications for. + Each entry must have a coresponding Lua Track / Operators Panel to trigger (using event.ext_int) + Used to alert a shunter locomotive or other yard that there's wagons available to collect from this yard. +]]-- + + ['ARC'] = {['pos'] = POS(-1973,16,800), ['msg'] = "notify"}, } if event.ext_int or event.punch then - for fc, pos in pairs(subs) do + local list = "Notify: " + for fc, sub in pairs(subs) do if S.yards[yard_id].notify[fc] then - interrupt_pos(pos,"notify") + interrupt_pos(sub.pos,sub.msg or "notify") + list = list .. fc .. ", " end end + digiline_send("lcd",list) S.yards[yard_id].notify = {} end diff --git a/auto_yards/nodes/(-2029,19,733).lua b/auto_yards/nodes/(-2029,19,733).lua new file mode 100644 index 0000000..2672033 --- /dev/null +++ b/auto_yards/nodes/(-2029,19,733).lua @@ -0,0 +1,10 @@ +local yard_id = "ARC" +if event.train then + if F.has_rc(yard_id.."_LIGHT_EXIT") then + F.remove_rc(yard_id.."_LIGHT_EXIT") + atc_set_ars_disable(false) + atc_send("SM") + return + end +end +F.headshunt_exit(yard_id,true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-2030,3,-1091).lua b/auto_yards/nodes/(-2030,3,-1091).lua new file mode 100644 index 0000000..cbce1da --- /dev/null +++ b/auto_yards/nodes/(-2030,3,-1091).lua @@ -0,0 +1 @@ +F.lane_EOL("BY",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-2038,20,730).lua b/auto_yards/nodes/(-2038,20,730).lua new file mode 100644 index 0000000..a790746 --- /dev/null +++ b/auto_yards/nodes/(-2038,20,730).lua @@ -0,0 +1,6 @@ +local yard_id = "ARC" +if event.digiline and event.channel=="yard_ctl" and event.msg=="disable" then + F.indicator(S.yards[yard_id].active_indicator_pos, false) + S.yards[yard_id].departure_time = rwt.now() + S.yards[yard_id].departure_length = S.yards[yard_id].arrival_length +end
\ No newline at end of file diff --git a/auto_yards/nodes/(-4023,12,-2660).lua b/auto_yards/nodes/(-4023,12,-2660).lua new file mode 100644 index 0000000..9d743b7 --- /dev/null +++ b/auto_yards/nodes/(-4023,12,-2660).lua @@ -0,0 +1,16 @@ +local yard_id = "TY" +local subs = { +-- ['MMF'] = {['pos'] = POS(1,2,3), ['msg'] = "notify"}, +} + +if event.ext_int or event.punch then + local list = "Notify: " + for fc, sub in pairs(subs) do + if S.yards[yard_id].notify[fc] then + interrupt_pos(sub.pos,sub.msg or "notify") + list = list .. fc .. ", " + end + end + digiline_send("lcd",list) + S.yards[yard_id].notify = {} +end
\ No newline at end of file diff --git a/auto_yards/nodes/(-513,26,2455).lua b/auto_yards/nodes/(-513,26,2455).lua new file mode 100644 index 0000000..14a78ea --- /dev/null +++ b/auto_yards/nodes/(-513,26,2455).lua @@ -0,0 +1,2 @@ +-- hs-exit +F.headshunt_exit("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-522,26,2469).lua b/auto_yards/nodes/(-522,26,2469).lua new file mode 100644 index 0000000..59df437 --- /dev/null +++ b/auto_yards/nodes/(-522,26,2469).lua @@ -0,0 +1,2 @@ +-- hs-yard +F.headshunt_yard("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-528,26,2475).lua b/auto_yards/nodes/(-528,26,2475).lua new file mode 100644 index 0000000..bb8ce55 --- /dev/null +++ b/auto_yards/nodes/(-528,26,2475).lua @@ -0,0 +1,2 @@ +-- arrival +F.yard_arrival("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-574,26,2469).lua b/auto_yards/nodes/(-574,26,2469).lua new file mode 100644 index 0000000..74a7624 --- /dev/null +++ b/auto_yards/nodes/(-574,26,2469).lua @@ -0,0 +1,2 @@ +-- EOL +F.lane_EOL("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-575,26,2465).lua b/auto_yards/nodes/(-575,26,2465).lua new file mode 100644 index 0000000..74a7624 --- /dev/null +++ b/auto_yards/nodes/(-575,26,2465).lua @@ -0,0 +1,2 @@ +-- EOL +F.lane_EOL("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(-594,26,2485).lua b/auto_yards/nodes/(-594,26,2485).lua new file mode 100644 index 0000000..270750f --- /dev/null +++ b/auto_yards/nodes/(-594,26,2485).lua @@ -0,0 +1,28 @@ +local yard_id = "CAN" + +if not S.yards[yard_id].notify then return end + +local subs = { +--[[ + A list of FC subscribers to send out notifications for. + Each entry must have a coresponding Lua Track / Operators Panel to trigger (using event.ext_int) + Used to alert a shunter locomotive or other yard that there's wagons available to collect from this yard. +]]-- + + ['ARC'] = {['pos'] = POS(-630,26,2454), ['msg'] = "notify"}, --send the CAN loco to collect from ARC, then return and deliver here for ARC + ['CORN'] = {['pos'] = POS(-630,26,2454), ['msg'] = "shuffle"} -- consolidate wagons to the departure track + ['BOTTLES'] = {['pos'] = POS(-630,26,2454), ['msg'] = "shuffle"} -- consolidate wagons to the departure track + ['ETHANOL'] = {['pos'] = POS(-630,26,2454), ['msg'] = "shuffle"} -- consolidate wagons to the departure track +} + +if event.ext_int or event.punch then + local list = "Notify: " + for fc, sub in pairs(subs) do + if S.yards[yard_id].notify[fc] then + interrupt_pos(sub.pos,sub.msg or "notify") + list = list .. fc .. ", " + end + end + digiline_send("lcd",list) + S.yards[yard_id].notify = {} +end
\ No newline at end of file diff --git a/auto_yards/nodes/(-604,26,2469).lua b/auto_yards/nodes/(-604,26,2469).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/auto_yards/nodes/(-604,26,2469).lua @@ -0,0 +1 @@ +--
\ No newline at end of file diff --git a/auto_yards/nodes/(-614,26,2469).lua b/auto_yards/nodes/(-614,26,2469).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/auto_yards/nodes/(-614,26,2469).lua @@ -0,0 +1 @@ +--
\ No newline at end of file diff --git a/auto_yards/nodes/(-623,26,2469).lua b/auto_yards/nodes/(-623,26,2469).lua new file mode 100644 index 0000000..46e3050 --- /dev/null +++ b/auto_yards/nodes/(-623,26,2469).lua @@ -0,0 +1,2 @@ +-- EOL +F.lane_EOL("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-623,26,2472).lua b/auto_yards/nodes/(-623,26,2472).lua new file mode 100644 index 0000000..46e3050 --- /dev/null +++ b/auto_yards/nodes/(-623,26,2472).lua @@ -0,0 +1,2 @@ +-- EOL +F.lane_EOL("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-623,26,2475).lua b/auto_yards/nodes/(-623,26,2475).lua new file mode 100644 index 0000000..f919bc0 --- /dev/null +++ b/auto_yards/nodes/(-623,26,2475).lua @@ -0,0 +1,2 @@ +-- class +F.classification("CAN",true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-630,26,2454).lua b/auto_yards/nodes/(-630,26,2454).lua new file mode 100644 index 0000000..e01fb60 --- /dev/null +++ b/auto_yards/nodes/(-630,26,2454).lua @@ -0,0 +1,73 @@ +local notification_id = "CAN" +local ind = POS(-594,26,2488) +local shuffle_ind = POS(-594,26,2487) +local print_notification = true +local function send_train() + set_rc("FREIGHT CAN_LOCOSTORE CAN_LIGHT_EXIT EWL-W EWL S23 ARCAUTO ARC_RTS ARC_COLLECT_CANNERY ARC_AUTO_S23N CANNERY CAN_RTS CAN_COLLECT_ARC") + atc_send("S0WRD2A1S4") + F.indicator(ind,false) +end + +local function shuffle_wagons() + F.indicator(S.yards[notification_id].active_indicator_pos, true) --stop other trains entering the yard + F.indicator(S.yards[notification_id].dir_indicator_pos,true) + F.indicator(shuffle_ind,false) + F.indicator(ind,true) + S.yards[notification_id].shuffle_stage = 1 -- set a shuffle stage counter + set_rc("CAN_LOCOSTORE CAN_SHUFFLE") + atc_send("S0WRD2A1S4") --send train to headshunt + return +end + +if event.ext_int then + if event.message == "notify" then + if print_notification then print(rwt.to_string(rwt.now()).. " "..notification_id.." RX Notification") end + if F.indicator(ind) then return end + if atc_id then + send_train() + return + else + F.indicator(ind,true) + return + end + elseif event.message == "shuffle" then + if atc_id then + if not F.indicator(S.yards[notification_id].active_indicator_pos) then + shuffle_wagons() + return + end + schedule_in(":05","shuffle") + return + else + F.indicator(shuffle_ind,true) + return + end + end + return +end + +if event.schedule then + if event.message=="shuffle" then + if not F.idicator(S.yards[notification_id].active_indicator_pos) then + shuffle_wagons() + return + end + schedule_in(":05","shuffle") + return + end + return +end + +if event.train then + unset_autocouple() + if F.indicator(shuffle_ind) then + shuffle_wagons() + return + end + if F.indicator(ind) then + send_train() + return + end + atc_send("B0") + return +end
\ No newline at end of file diff --git a/auto_yards/nodes/(-633,26,2456).lua b/auto_yards/nodes/(-633,26,2456).lua new file mode 100644 index 0000000..8dc117b --- /dev/null +++ b/auto_yards/nodes/(-633,26,2456).lua @@ -0,0 +1,4 @@ +if event.punch then + F.indicator(S.yards.CAN.active_indicator_pos,false) + interrupt_pos(POS(-630,26,2454),"shuffle") +end
\ No newline at end of file diff --git a/auto_yards/nodes/(-643,26,2475).lua b/auto_yards/nodes/(-643,26,2475).lua new file mode 100644 index 0000000..1523fcd --- /dev/null +++ b/auto_yards/nodes/(-643,26,2475).lua @@ -0,0 +1,83 @@ +local yard_id = "CAN" + + +if event.train then + if F.has_rc(yard_id.."_LIGHT_EXIT") then return end + if F.has_rc(yard_id.."_NOSHUNT") then return end + + if F.has_rc("CAN_SHUFFLE") then -- train is consolidating wagons for export to ARC + if not atc_arrow then + schedule_in(";01",atc_id) -- prepare to reverse the train + return + end + print(F.get_rc_safe()) + F.remove_rc_match("CAN_CLASS_%S+") + F.remove_rc_match("CAN_COLLECT_%S+") + F.remove_rc("CAN_PICKUP CAN_HEADSHUNT CAN_FINAL_COLLECT") + local stage_list = { + "CAN_CLASS_ETHANOL CAN_COLLECT_ETHANOL CAN_FINAL_COLLECT", + "CAN_CLASS_ARC", + "CAN_CLASS_CORN CAN_COLLECT_CORN CAN_FINAL_COLLECT", + "CAN_CLASS_ARC", + "CAN_send_to_locostore" + } + F.add_rc(stage_list[S.yards[yard_id].shuffle_stage]) + print(F.get_rc_safe()) + print(S.yards[yard_id].shuffle_stage) + set_autocouple() + atc_set_ars_disable(false) + + if S.yards[yard_id].shuffle_stage == #stage_list then -- loco is returning to storage. release the yard + F.indicator(S.yards[yard_id].active_indicator_pos,false) + S.yards[yard_id].notify.ARC = true + interrupt_pos(S.yards[yard_id].notify_pos) + else + S.yards[yard_id].shuffle_stage = S.yards[yard_id].shuffle_stage + 1 + end + return + end + + if train_length() == 1 then -- eliminates near half the trains + if F.has_rc(yard_id.."_LOCOSTORE") then -- specifies only the relevant train + if F.has_rc(yard_id.."_DEPART") and F.has_rc(yard_id.."_FINAL_COLLECT") and F.has_rc(yard_id.."_HEADSHUNT") then --only activate if train is set to depart anyway + if not atc_arrow then -- train is pointing towards exit. let it pass and the reverse it + atc_set_ars_disable(true) + schedule_in(";01",atc_id) -- prepare to reverse the train + return + else --train has reversed. send it to the siding and deactivate the yard + F.remove_rc({yard_id.."_DEPART",yard_id.."_FINAL_COLLECT"}) + F.add_rc(yard_id.."_send_to_locostore") + atc_set_ars_disable(false) + F.indicator(S.yards[yard_id].active_indicator_pos, false) + S.yards[yard_id].departure_time = rwt.now() + S.yards[yard_id].departure_length = S.yards[yard_id].arrival_length + + if S.yards[yard_id].notify_pos then + interrupt_pos(S.yards[yard_id].notify_pos,"notify") + end + return + end + end + end + end +end + +if event.schedule then --this is a duplicate of the reversing schedule in the env anyway + if not atc_id then --bounce the train that just passed + atc_send_to_train(event.msg,"B0WRD1A1S3") + else + if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer + schedule_in(";01",atc_id) + else -- somehow another train crossed the controller before the first one returned. Unlikely but possible + atc_send_to_train(event.msg,"BBOL") + atc_send("BBOL") + F.indicator(yard.error_indicator_pos,true) + end + end + return +end + + + +-- if all else fails, do a normal headshunt_yard function +F.headshunt_yard(yard_id,true)
\ No newline at end of file diff --git a/auto_yards/nodes/(-668,20,2478).lua b/auto_yards/nodes/(-668,20,2478).lua new file mode 100644 index 0000000..7c582c0 --- /dev/null +++ b/auto_yards/nodes/(-668,20,2478).lua @@ -0,0 +1,3 @@ +-- arrival +if not F.has_rc("CANNERY") then return end +F.yard_arrival("CAN",false)
\ No newline at end of file diff --git a/auto_yards/nodes/(1178,16,3851).lua b/auto_yards/nodes/(1178,16,3851).lua index 35047d5..6d126c4 100644 --- a/auto_yards/nodes/(1178,16,3851).lua +++ b/auto_yards/nodes/(1178,16,3851).lua @@ -1,13 +1,16 @@ local yard_id = "IP" local subs = { - ['WOA_mine_empty'] = POS(1949,7,9112), + ['WOA_mine_empty'] = {['pos'] = POS(1949,7,9112), ['msg'] = "notify"}, } if event.ext_int or event.punch then - for fc, pos in pairs(subs) do + local list = "Notify: " + for fc, sub in pairs(subs) do if S.yards[yard_id].notify[fc] then - interrupt_pos(pos,"notify") + interrupt_pos(sub.pos,sub.msg or "notify") + list = list .. fc .. ", " end end + digiline_send("lcd",list) S.yards[yard_id].notify = {} -end +end
\ No newline at end of file diff --git a/auto_yards/nodes/(417,17,4).lua b/auto_yards/nodes/(417,17,4).lua new file mode 100644 index 0000000..b634cde --- /dev/null +++ b/auto_yards/nodes/(417,17,4).lua @@ -0,0 +1,62 @@ +if event.channel=="clock" then + local yard_id = event.msg + local info = S.yards[yard_id] + digiline_send("rwt_clock","Rwt Now:\n"..rwt.to_string(rwt.now())) + + if not S.yards[yard_id] then + digiline_send(yard_id.."_1",yard_id.." -- Not In Service") + digiline_send(yard_id.."_2"," ") + digiline_send(yard_id.."_NOTIFY"," ") + return + end + + local function getN(t) + local count = 0 + for _ in pairs(t) do + count = count+1 + end + return count + end + + + local txt = {} + local txt2 = {} + txt[#txt+1] = yard_id.." --"..info.yard_name.." Yard--" + txt[#txt+1] = "Active: " .. tostring(F.indicator(info.active_indicator_pos)) + + txt[#txt+1] = "Direction: " .. tostring(F.indicator(info.dir_indicator_pos)) + txt[#txt+1] = "Last Train: " .. tostring(info.last_id).." ("..tostring(info.arrival_length).."-"..tostring(info.departure_length)..")" + txt2[#txt2+1] = "Time: "..tostring(rwt.to_string(info.arrival_time)).."+"..tostring(rwt.to_string(rwt.diff(info.arrival_time,info.departure_time))) + digiline_send(yard_id.."_1",table.concat(txt,"\n")) + + + + + txt2[#txt2+1] = "RTS: "..tostring(info.rts) + txt2[#txt2+1] = "Error: ".. tostring(F.indicator(info.error_indicator_pos)) + txt2[#txt2+1] = "" + digiline_send(yard_id.."_2",table.concat(txt2,"\n")) + + local notifications = "" + if info.notify then + local nt = "" + if getN(info.notify) > 0 then + nt = "Notify: " + for k in pairs(info.notify) do + nt = nt..k..", " + end + else + nt = "Notify: No Notifications" + end + + local st_len = 26 + if nt:len() > st_len then + nt = nt:sub(1,st_len).."\n"..nt:sub(st_len+1) + end + notifications = nt + else + notifications = "Notify: Not Enabled" + end + digiline_send(yard_id.."_NOTIFY",notifications) + return +end
\ No newline at end of file diff --git a/auto_yards/nodes/(417,18,4).lua b/auto_yards/nodes/(417,18,4).lua new file mode 100644 index 0000000..48ef9b8 --- /dev/null +++ b/auto_yards/nodes/(417,18,4).lua @@ -0,0 +1,3 @@ +if event.channel ~= "debug_switch" then return end +S.print_debug = event.msg +print("Print Debug: "..tostring(S.print_debug))
\ No newline at end of file |