Skip to content

Commit

Permalink
added debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsanches committed Feb 3, 2025
2 parents c8afcc5 + 3ae6bd6 commit fc525af
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
64 changes: 33 additions & 31 deletions data/EFMR/scripts/tc_signal_d06.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ The Signal D06 has a diagram like this:
--------------O----|-------O-----|----------------------------------- -> Staging Exit - Stop
|-O \ HLX_DTC02 HLX_DTC01 / \
D06 \ / \----------- -> Staging Entrance - Clear
\ ____________________/
\ ____________________/
| /
|/ HLX_T04 HLX_T08
| /---> Coronel Fulgêncio (down line - internal - Stop)
| HLX_T07 /
| HLX_T07 /
|\ HLX_T05 ---------------------------> Coronel Fulgêncio (up line - external - RESTRICTED)
| \ /
| \--------------------/
|
|
sl_bp_main_d04 O /
sl_bp_main_d04 O /
| /
|/ HLX_T06
O sl_bp_main_s03
Expand All @@ -29,7 +29,7 @@ sl_bp_main_d04 O /
]]--

log_info("TC_SIGNAL_D06 Initializing")
log_info("[TC_SIGNAL_D06] Initializing")

-- signal
local signal_d06 = dcclite.dcc0.TC_SIG_6D
Expand Down Expand Up @@ -77,24 +77,24 @@ end

function set_helix_down_aspect()
log_info("TC_SIGNAL_D06 Route to staging CLEAR")
signal_d06:set_aspect(SignalAspects.Clear, "TC_SIGNAL_D06_SCRIPT", "helix path down to staging is set")
signal_d06:set_aspect(SignalAspects.Clear)

signal_state = SIGNAL_STATES.helix_path_clear
end

function set_soledade_branch_aspect()
log_info("TC_SIGNAL_D06 soledade path CLEAR")
log_info("[TC_SIGNAL_D06] soledade path CLEAR")
signal_d06:set_aspect(SignalAspects.Aproach)
signal_state = SIGNAL_STATES.soledade_path_clear
end

function on_train_entered_helix_down(device)

log_info("TC_SIGNAL_D06 on_train_entered_helix_down")
log_info("[TC_SIGNAL_D06] on_train_entered_helix_down")

-- sensor turned off? We do not care...
if not device.active then
log_trace("TC_SIGNAL_D06 on_train_entered_helix_down sensor is off")
log_trace("[TC_SIGNAL_D06] on_train_entered_helix_down sensor is off")

return
end
Expand All @@ -108,7 +108,7 @@ function on_train_entered_helix_down(device)
signal_d06:set_aspect(SignalAspects.Stop)

elseif signal_state == SIGNAL_STATES.helix_path_clear then
log_trace("TC_SIGNAL_D06 on_train_entered_helix_down sensor is on, now path is busy, signal is STOP")
log_trace("[TC_SIGNAL_D06] on_train_entered_helix_down sensor is on, now path is busy, signal is STOP")

-- now wait for train to reach end sensor
signal_state = SIGNAL_STATES.helix_path_busy
Expand All @@ -119,15 +119,15 @@ end

function on_helix_exit_sensor(sensor)

log_trace("TC_SIGNAL_D06 on_helix_exit_sensor sensor")
log_trace("[TC_SIGNAL_D06] on_helix_exit_sensor sensor")

if (signal_state == SIGNAL_STATES.helix_path_busy) and sensor.active then
log_trace("TC_SIGNAL_D06 on_helix_exit_sensor sensor ACTIVE")
log_trace("[TC_SIGNAL_D06] on_helix_exit_sensor sensor ACTIVE")

signal_state = SIGNAL_STATES.helix_path_exiting

elseif (signal_state == SIGNAL_STATES.helix_path_exiting) and sensor.inactive then
log_trace("TC_SIGNAL_D06 on_helix_exit_sensor INACTIVE - resetting")
log_trace("[TC_SIGNAL_D06] on_helix_exit_sensor INACTIVE - resetting")

--reset signal
signal_state = SIGNAL_STATES.automatic
Expand All @@ -152,75 +152,76 @@ end

function on_device_change(device)

log_info("TC_SIGNAL_D06 on_device_change")
log_info("[TC_SIGNAL_D06] on_device_change")

-- Are we going to Soledade or up the helix?
if hlx_t03.thrown then

log_info("TC_SIGNAL_D06 hlx_t03 thrown")
log_info("[TC_SIGNAL_D06] hlx_t03 thrown - Soledade or Helix UP path")

-- Is path blocked?
if hlx_t04.thrown then
set_stop_aspect("TC_SIGNAL_D06 hlx_t04 thrown - STOP")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t04 thrown - Soledade or Helix blocked - STOP")

return
end

-- Are we going up the helix?
if hlx_t05.thrown then
log_info("TC_SIGNAL_D06 hlx_t05 thrown")
log_info("[TC_SIGNAL_D06] hlx_t05 thrown - going up to Helix")

-- Is path blocked?
if hlx_t07.closed then
set_stop_aspect("TC_SIGNAL_D06 hlx_t07 closed - STOP")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t07 closed - path blocked - STOP")

return
end

-- Is route set to down line (internal)?
if hlx_t08.thrown then
set_stop_aspect("TC_SIGNAL_D06 hlx_t08 thrown - STOP")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t08 thrown - path to wrong line - STOP")

return
end

-- Going up... give a restricted, as line is incomplete
log_info("TC_SIGNAL_D06 hlx_t07 thrown - RESTRICTED")
log_info("[TC_SIGNAL_D06] hlx_t07 thrown - going up the helix - RESTRICTED")
signal_d06:set_aspect(SignalAspects.Restricted)
return
end

-- ok, we are heading towards to Soledade
log_info("[TC_SIGNAL_D06] going to Soledade")

-- Is path blocked?
if hlx_t06.thrown then
set_stop_aspect("TC_SIGNAL_D06 hlx_t06 thrown - STOP")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t06 thrown - path to Soledade blocked - STOP")

return
end

-- if heading down to SOLEDADE, ignore sensors...
if (signal_state == SIGNAL_STATES.soledade_path_busy) or (signal_state == SIGNAL_STATES.soledade_path_exiting) then
-- do not modify signal, wait for sensors
log_trace("TC_SIGNAL_D06 path is busy by soledade, waiting sensors: " .. signal_state)
log_trace("[TC_SIGNAL_D06] path is busy by soledade, waiting sensors: " .. signal_state)
return
end

--[[
--[[ Sections are buggy, ignore for now
if sl_bp_main_s03.active then
set_stop_aspect("TC_SIGNAL_D06 sl_bp_main_s03 IN USE - STOP")
set_stop_aspect("[TC_SIGNAL_D06] sl_bp_main_s03 IN USE - STOP")
return
end
if sl_bp_main_s02.active then
set_stop_aspect("TC_SIGNAL_D06 sl_bp_main_s02 IN USE - STOP")
set_stop_aspect("[TC_SIGNAL_D06] sl_bp_main_s02 IN USE - STOP")
return
end
if sl_bp_main_s01.active then
set_stop_aspect("TC_SIGNAL_D06 sl_bp_main_s01 IN USE - STOP")
set_stop_aspect("[TC_SIGNAL_D06] sl_bp_main_s01 IN USE - STOP")
return
end
Expand All @@ -233,17 +234,18 @@ function on_device_change(device)
end

-- We are heading down the helix
log_trace("[TC_SIGNAL_D06] heading down the helix")

-- is path blocked?
if hlx_t02.thrown then
set_stop_aspect("TC_SIGNAL_D06 hlx_t02 open - stop")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t02 thrown - path down helix blocked - stop")

return
end

-- is path toward helix exit?
if hlx_t01.closed then
set_stop_aspect("TC_SIGNAL_D06 hlx_t01 closed - stop")
set_stop_aspect("[TC_SIGNAL_D06] hlx_t01 closed - path set to staging entrance - stop")

return
end
Expand All @@ -253,20 +255,20 @@ function on_device_change(device)
-- if heading down the helix, ignore sensors...
if (signal_state == SIGNAL_STATES.helix_path_busy) or (signal_state == SIGNAL_STATES.helix_path_exiting) then
-- do not modify signal, wait for sensors
log_trace("TC_SIGNAL_D06 path is busy by helix, waiting sensors: " .. signal_state)
log_trace("[TC_SIGNAL_D06] path is busy by helix, waiting sensors: " .. signal_state)
return
end

-- is block ocupied?
if hlx_sensor_dtc02.active then
set_stop_aspect("TC_SIGNAL_D06 DTC02 ACTIVE - stop")
set_stop_aspect("[TC_SIGNAL_D06] DTC02 ACTIVE - path to Helix is ocupied - stop")

return
end

-- is block ocupied?
if hlx_sensor_dtc01.active then
set_stop_aspect("TC_SIGNAL_D06 DTC01 ACTIVE - stop")
set_stop_aspect("[TC_SIGNAL_D06] DTC01 ACTIVE - path to Helix is ocupied - stop")

return
end
Expand Down Expand Up @@ -297,4 +299,4 @@ sl_bp_main_d01:on_state_change(on_soledade_branch_exit_sensor)
-- set initial state
on_device_change(signal_d06)

log_info("TC_SIGNAL_D06 - init OK" .. signal_state)
log_info("[TC_SIGNAL_D06] - init OK " .. signal_state)
4 changes: 4 additions & 0 deletions src/BrokerLib/dcc/SignalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ namespace dcclite::broker
{
bool changed = false;

//
//we track those strings here because it is helpful for debbuging the CTC actions
if (m_strAspectRequester != requester)
{
m_strAspectRequester = requester;
Expand All @@ -204,6 +206,8 @@ namespace dcclite::broker

if (aspect == m_eCurrentAspect)
{
//just propagate the messages because it is helpful to understand the decisions made by the dispatcher
//but this should not affect anything else
if(changed)
m_rclManager.Decoder_OnStateChanged(*this);

Expand Down
4 changes: 2 additions & 2 deletions src/SharpTools/SharpTerminal/RemoteSignalDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private void ParseStateData(JsonValue objectDef)
{
CurrentAspect = (String)objectDef["currentAspectName"];
RequestedAspect = (String)objectDef["requestedAspectName"];
m_strAspectRequester = (String)objectDef["aspectRequester"];
m_strAspectReason = (String)objectDef["aspectReason"];
AspectRequester = (String)objectDef["aspectRequester"];
AspectReason = (String)objectDef["aspectReason"];
}

public override string TryGetIconName()
Expand Down

0 comments on commit fc525af

Please sign in to comment.