Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Debug channel refactoring #6908

Merged
merged 5 commits into from Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions AIDriver.lua
Expand Up @@ -141,8 +141,8 @@ AIDriver.myStates = {
--- Create a new driver (usage: aiDriver = AIDriver(vehicle)
-- @param vehicle to drive. Will set up a course to drive from vehicle.Waypoints
function AIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'AIDriver:init()')
self.debugChannel = courseplay.DBG_14
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'AIDriver:init()')
self.debugChannel = courseplay.DBG_MODE_5
self.mode = courseplay.MODE_TRANSPORT
self.states = {}
self:initStates(AIDriver.myStates)
Expand Down Expand Up @@ -1348,7 +1348,8 @@ function AIDriver:cleanUpMissedTriggerExit() -- at least that's what it seems to
-- This is used in case we already registered a tipTrigger but changed the direction and might not be in that tipTrigger when unloading. (Bug Fix)
local startReversing = self.course:switchingToReverseAt(self.ppc:getCurrentWaypointIx() - 1)
if startReversing then
courseplay:debug(string.format(2,"%s: Is starting to reverse. Tip trigger is reset.", nameNum(self.vehicle)), courseplay.DBG_13);
courseplay:debug(string.format(2,"%s: Is starting to reverse. Tip trigger is reset.",
nameNum(self.vehicle)), courseplay.DBG_REVERSE);
end

local isBGA = t.bunkerSilo ~= nil
Expand Down
3 changes: 2 additions & 1 deletion BaleCollectorAIDriver.lua
Expand Up @@ -37,10 +37,11 @@ BaleCollectorAIDriver.myStates = {
}

function BaleCollectorAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'BaleCollectorAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'BaleCollectorAIDriver:init()')
BaleLoaderAIDriver.init(self, vehicle)
self:initStates(BaleCollectorAIDriver.myStates)
self.mode = courseplay.MODE_BALE_COLLECTOR
self.debugChannel = courseplay.DBG_MODE_7
self.fieldId = 0
self.bales = {}
end
Expand Down
2 changes: 1 addition & 1 deletion BaleLoaderAIDriver.lua
Expand Up @@ -57,7 +57,7 @@ end


function BaleLoaderAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'BaleLoaderAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'BaleLoaderAIDriver:init()')
UnloadableFieldworkAIDriver.init(self, vehicle)
self.baleLoader = AIDriverUtil.getImplementWithSpecialization(vehicle, BaleLoader)
self:debug('baleloader %s', tostring(self.baleLoader))
Expand Down
2 changes: 1 addition & 1 deletion BaleWrapperAIDriver.lua
Expand Up @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
BaleWrapperAIDriver = CpObject(BalerAIDriver)

function BaleWrapperAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'BaleWrapperAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'BaleWrapperAIDriver:init()')
-- the only reason this is derived from BalerAIDriver is that some wrappers are also balers. Our concept
-- derived classes may not fly when there are multiple specializations to handle, if we had a bale loader
-- which is also a bale wrapper then we would probably have to put everything back into the baler.
Expand Down
2 changes: 1 addition & 1 deletion BalerAIDriver.lua
Expand Up @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
BalerAIDriver = CpObject(UnloadableFieldworkAIDriver)

function BalerAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'BalerAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'BalerAIDriver:init()')
UnloadableFieldworkAIDriver.init(self, vehicle)
self.baler = AIDriverUtil.getAIImplementWithSpecialization(vehicle, Baler)
if self.baler then
Expand Down
2 changes: 1 addition & 1 deletion BunkersiloManager.lua
@@ -1,7 +1,7 @@
---@class BunkerSiloManager
BunkerSiloManager = CpObject()

BunkerSiloManager.debugChannel = 10
BunkerSiloManager.debugChannel = courseplay.DBG_MODE_10

BunkerSiloManager.MODE = {}
BunkerSiloManager.MODE.COMPACTING = 0 --LevelCompactAIDriver compacting without shield
Expand Down
2 changes: 1 addition & 1 deletion CombineAIDriver.lua
Expand Up @@ -57,7 +57,7 @@ CombineAIDriver.turnTypes = {
CombineAIDriver.isACombineAIDriver = true

function CombineAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11, vehicle, 'CombineAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER, vehicle, 'CombineAIDriver:init()')
UnloadableFieldworkAIDriver.init(self, vehicle)
self:initStates(CombineAIDriver.myStates)
self.fruitLeft, self.fruitRight = 0, 0
Expand Down
4 changes: 2 additions & 2 deletions CombineUnloadAIDriver.lua
Expand Up @@ -115,10 +115,10 @@ CombineUnloadAIDriver.myStates = {

--- Constructor
function CombineUnloadAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'CombineUnloadAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'CombineUnloadAIDriver:init()')
self.assignedCombinesSetting = AssignedCombinesSetting(vehicle)
AIDriver.init(self, vehicle)
self.debugChannel = courseplay.DBG_MODE_2_3
self.debugChannel = courseplay.DBG_MODE_2
self.mode = courseplay.MODE_COMBI
self:initStates(CombineUnloadAIDriver.myStates)
self.combineOffset = 0
Expand Down
13 changes: 9 additions & 4 deletions CombineUnloadManager.lua
Expand Up @@ -40,8 +40,6 @@ at the moment.
---@class CombineUnloadmanager
CombineUnloadManager = CpObject()

CombineUnloadManager.debugChannel = 4

-- Constructor
function CombineUnloadManager:init()
self.combines = {}
Expand All @@ -61,8 +59,15 @@ function CombineUnloadManager:addNewCombines()
end
end

--- Debug is enabled in mode 2 and 3
function CombineUnloadManager:debugEnabled()
return courseplay.debugChannels[courseplay.DBG_MODE_2] or courseplay.debugChannels[courseplay.DBG_MODE_3]
end

function CombineUnloadManager:debug(...)
courseplay.debugFormat(self.debugChannel, 'CombineUnloadManager: ' .. string.format( ... ))
if self:debugEnabled() then
courseplay.debugFormat(courseplay.DBG_MODE_2, 'CombineUnloadManager: ' .. string.format( ... ))
end
end

function CombineUnloadManager:debugSparse(...)
Expand Down Expand Up @@ -354,7 +359,7 @@ function CombineUnloadManager:updateCombinesAttributes()
attributes.fillLevelPct = self:getCombinesFillLevelPercent(combine)
attributes.fillLevel = self:getCombinesFillLevel(combine)
self:updateFillSpeed(combine,attributes)
if courseplay.debugChannels[self.debugChannel] then
if self:debugEnabled() then
renderText(0.1,0.175+(0.02*number) ,0.015,
string.format("%s: leftOK: %s; rightOK:%s numUnloaders:%d",
nameNum(combine), tostring(attributes.leftOkToDrive), tostring(attributes.rightOKToDrive),
Expand Down
4 changes: 1 addition & 3 deletions CpManager.lua
Expand Up @@ -890,12 +890,10 @@ end;
--FieldScan startup dialog and github info
function CpManager:showYesNoDialogue(title, text, callbackFn)
-- don't show anything if the tutorial dialog is open (it takes a while until is isOpen shows true after startup, hence the clock)
--courseplay.debugFormat(courseplay.DBG_12, "clock %d %s", courseplay.clock, tostring(g_gui.guis.YesNoDialog.target and g_gui.guis.YesNoDialog.target.isOpen))
if courseplay.clock < 2000 or (g_gui.guis.YesNoDialog.target and g_gui.guis.YesNoDialog.target.isOpen) then
return
end
--courseplay.debugFormat(courseplay.DBG_12, text)
local text =string.format("%s\n %s",courseplay:loc('COURSEPLAY_YES_NO_FIELDSCAN'),courseplay:loc('COURSEPLAY_SUPPORT_INFO'))
local text =string.format("%s\n %s",courseplay:loc('COURSEPLAY_YES_NO_FIELDSCAN'),courseplay:loc('COURSEPLAY_SUPPORT_INFO'))
g_gui:showYesNoDialog({text=text, title=title, callback=callbackFn, target=self})
end;

Expand Down
3 changes: 2 additions & 1 deletion FieldSupplyAIDriver.lua
Expand Up @@ -39,7 +39,8 @@ function FieldSupplyAIDriver:init(vehicle)
self.triggerHandler.driveOnAtFillLevel = settings.driveOnAtFillLevel
self:initStates(FieldSupplyAIDriver.myStates)
self.supplyState = self.states.ON_REFILL_COURSE
self.mode=courseplay.MODE_FIELD_SUPPLY
self.mode=courseplay.MODE_FIELD_SUPPLY
self.debugChannel = courseplay.DBG_MODE_8
self:setHudContent()
end

Expand Down
4 changes: 2 additions & 2 deletions FieldworkAIDriver.lua
Expand Up @@ -49,10 +49,10 @@ FieldworkAIDriver.myStates = {
-- through multiple level of inheritances therefore we must explicitly call
-- the base class ctr.
function FieldworkAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'FieldworkAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'FieldworkAIDriver:init()')
AIDriver.init(self, vehicle)
self:initStates(FieldworkAIDriver.myStates)
self.debugChannel = courseplay.DBG_14
self.debugChannel = courseplay.DBG_MODE_4
-- waypoint index on main (fieldwork) course where we aborted the work before going on
-- an unload/refill course
self.aiDriverData.continueFieldworkAtWaypoint = 1
Expand Down
3 changes: 2 additions & 1 deletion FillableFieldworkAIDriver.lua
Expand Up @@ -33,10 +33,11 @@ FillableFieldworkAIDriver.myStates = {
}

function FillableFieldworkAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'FillableFieldworkAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'FillableFieldworkAIDriver:init()')
FieldworkAIDriver.init(self, vehicle)
self:initStates(FillableFieldworkAIDriver.myStates)
self.mode = courseplay.MODE_SEED_FERTILIZE
self.debugChannel = courseplay.DBG_MODE_4
self.refillState = self.states.TO_BE_REFILLED
self.lastTotalFillLevel = math.huge
end
Expand Down
3 changes: 2 additions & 1 deletion GrainTransportAIDriver.lua
Expand Up @@ -21,9 +21,10 @@ GrainTransportAIDriver = CpObject(AIDriver)

--- Constructor
function GrainTransportAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'GrainTransportAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'GrainTransportAIDriver:init()')
AIDriver.init(self, vehicle)
self.mode = courseplay.MODE_GRAIN_TRANSPORT
self.debugChannel = courseplay.DBG_MODE_1
self.totalFillCapacity = 0
end

Expand Down
14 changes: 7 additions & 7 deletions LevelCompactAIDriver.lua
Expand Up @@ -48,11 +48,11 @@ LevelCompactAIDriver.myStates = {

--- Constructor
function LevelCompactAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'LevelCompactAIDriver:init')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'LevelCompactAIDriver:init')
AIDriver.init(self, vehicle)
self:initStates(LevelCompactAIDriver.myStates)
self.mode = courseplay.MODE_BUNKERSILO_COMPACTER
self.debugChannel = courseplay.DBG_10
self.debugChannel = courseplay.DBG_MODE_10
self.refSpeed = 10
self.fillUpState = self.states.PUSH
self:setLevelerWorkWidth()
Expand Down Expand Up @@ -428,9 +428,9 @@ function LevelCompactAIDriver:isStuck()
if self:doesNotMove() then
if self.vehicle.cp.timers.slipping == nil or self.vehicle.cp.timers.slipping == 0 then
courseplay:setCustomTimer(self.vehicle, 'slipping', 3);
--courseplay:debug(('%s: setCustomTimer(..., "slippingStage", courseplay.DBG_TRAFFIC)'):format(nameNum(self.vehicle)), courseplay.DBG_10);
--courseplay:debug(('%s: setCustomTimer(..., "slippingStage", courseplay.DBG_TRAFFIC)'):format(nameNum(self.vehicle)), courseplay.DBG_MODE_10);
elseif courseplay:timerIsThrough(self.vehicle, 'slipping') then
--courseplay:debug(('%s: timerIsThrough(..., "slippingStage") -> return isStuck(), reset timer'):format(nameNum(self.vehicle)), courseplay.DBG_10);
--courseplay:debug(('%s: timerIsThrough(..., "slippingStage") -> return isStuck(), reset timer'):format(nameNum(self.vehicle)), courseplay.DBG_MODE_10);
courseplay:resetCustomTimer(self.vehicle, 'slipping');
self:debug("dropout isStuck")
return true
Expand Down Expand Up @@ -553,7 +553,7 @@ function LevelCompactAIDriver:getSpeed()
end

function LevelCompactAIDriver:debug(...)
courseplay.debugVehicle(courseplay.DBG_10, self.vehicle, ...)
courseplay.debugVehicle(courseplay.DBG_MODE_10, self.vehicle, ...)
end

function LevelCompactAIDriver:checkSilo()
Expand Down Expand Up @@ -609,7 +609,7 @@ function LevelCompactAIDriver:getLevelerNode(blade)
end

function LevelCompactAIDriver:printMap()
if courseplay.debugChannels[courseplay.DBG_10] and self.bunkerSiloManager.siloMap then
if courseplay.debugChannels[courseplay.DBG_MODE_10] and self.bunkerSiloManager.siloMap then
for _, line in pairs(self.bunkerSiloManager.siloMap) do
local printString = ""
for _, fillUnit in pairs(line) do
Expand Down Expand Up @@ -761,7 +761,7 @@ function LevelCompactAIDriver:getValidBackImplement()
end

function LevelCompactAIDriver:isDebugActive()
return courseplay.debugChannels[courseplay.DBG_10]
return courseplay.debugChannels[courseplay.DBG_MODE_10]
end


Expand Down
3 changes: 2 additions & 1 deletion OverloaderAIDriver.lua
Expand Up @@ -30,8 +30,9 @@ function OverloaderAIDriver:init(vehicle)
--there seems to be a bug, where "vehicle" is not always set once start is pressed
CombineUnloadAIDriver.init(self, vehicle)
self:initStates(OverloaderAIDriver.myStates)
self:debug('OverloaderAIDriver:init()')
self.mode = courseplay.MODE_OVERLOADER
self.debugChannel = courseplay.DBG_MODE_3
self:debug('OverloaderAIDriver:init()')
self.unloadCourseState = self.states.ENROUTE
self.nearOverloadPoint = false
end
Expand Down
3 changes: 2 additions & 1 deletion PlowAIDriver.lua
Expand Up @@ -30,10 +30,11 @@ PlowAIDriver.myStates = {
}

function PlowAIDriver:init(vehicle)
courseplay.debugVehicle(courseplay.DBG_11,vehicle,'PlowAIDriver:init()')
courseplay.debugVehicle(courseplay.DBG_AI_DRIVER,vehicle,'PlowAIDriver:init()')
FieldworkAIDriver.init(self, vehicle)
self:initStates(PlowAIDriver.myStates)
self.mode = courseplay.MODE_FIELDWORK
self.debugChannel = courseplay.DBG_MODE_6
self.plow = AIDriverUtil.getAIImplementWithSpecialization(vehicle, Plow)
self:setOffsetX()
if self:hasRotatablePlow() then
Expand Down
8 changes: 4 additions & 4 deletions ProximitySensor.lua
Expand Up @@ -68,7 +68,7 @@ function ProximitySensor:update()
--bitOR(AIVehicleUtil.COLLISION_MASK, 0x1f0))
--cpDebug:drawLine(x, y + self.height, z, 0, 1, 0, x + 5 * nx, y + self.height + 5 * ny, z + 5 * nz)
end
if courseplay.debugChannels[courseplay.DBG_12] and self.distanceOfClosestObject <= self.range then
if courseplay.debugChannels[courseplay.DBG_TRAFFIC] and self.distanceOfClosestObject <= self.range then
local green = self.distanceOfClosestObject / self.range
local red = 1 - green
cpDebug:drawLine(x, y + self.height, z, red, green, 0, self.closestObjectX, self.closestObjectY, self.closestObjectZ)
Expand Down Expand Up @@ -105,7 +105,7 @@ function ProximitySensor:getClosestRootVehicle()
end

function ProximitySensor:showDebugInfo()
if not courseplay.debugChannels[courseplay.DBG_12] then return end
if not courseplay.debugChannels[courseplay.DBG_TRAFFIC] then return end
local text = string.format('%.1f ', self.distanceOfClosestObject)
if self.objectId then
local object = g_currentMission:getNodeObject(self.objectId)
Expand Down Expand Up @@ -167,7 +167,7 @@ function ProximitySensorPack:init(name, vehicle, ppc, node, range, height, direc
end

function ProximitySensorPack:debug(...)
courseplay.debugVehicle(courseplay.DBG_12, self.vehicle, ...)
courseplay.debugVehicle(courseplay.DBG_TRAFFIC, self.vehicle, ...)
end

function ProximitySensorPack:adjustForwardPosition()
Expand Down Expand Up @@ -210,7 +210,7 @@ function ProximitySensorPack:update()
self:callForAllSensors(ProximitySensor.update)

-- show the position of the pack
if courseplay.debugChannels[courseplay.DBG_12] then
if courseplay.debugChannels[courseplay.DBG_TRAFFIC] then
local x, y, z = getWorldTranslation(self.node)
local x1, y1, z1 = localToWorld(self.node, 0, 0, 0.5)
cpDebug:drawLine(x, y, z, 0, 0, 1, x, y + 3, z)
Expand Down
10 changes: 5 additions & 5 deletions PurePursuitController.lua
Expand Up @@ -109,7 +109,7 @@ function PurePursuitController:delete()
end

function PurePursuitController:debug(...)
courseplay.debugVehicle(courseplay.DBG_12, self.vehicle, 'PPC: ' .. string.format( ... ))
courseplay.debugVehicle(courseplay.DBG_PPC, self.vehicle, 'PPC: ' .. string.format( ... ))
end

function PurePursuitController:debugSparse(...)
Expand Down Expand Up @@ -372,7 +372,7 @@ function PurePursuitController:findRelevantSegment()
self:debug('relevant waypoint: %d, crosstrack error: %.1f', self.relevantWpNode.ix, self.crossTrackError)
end
end
if courseplay.debugChannels[courseplay.DBG_12] then
if courseplay.debugChannels[courseplay.DBG_PPC] then
cpDebug:drawLine(px, py + 3, pz, 1, 1, 0, px, py + 1, pz);
DebugUtil.drawDebugNode(self.relevantWpNode.node, string.format('ix = %d\nrelevant\nnode', self.relevantWpNode.ix))
DebugUtil.drawDebugNode(self.projectedPosNode, 'projected\nvehicle\nposition')
Expand Down Expand Up @@ -435,7 +435,7 @@ function PurePursuitController:findGoalPoint()
self:showGoalpointDiag(2, 'common case, ix=%d, q1=%.1f, q2=%.1f la=%.1f', ix, q1, q2, self.lookAheadDistance)
-- current waypoint is the waypoint at the end of the path segment
self:setCurrentWaypoint(ix + 1)
--courseplay.debugVehicle(courseplay.DBG_12, self.vehicle, "PPC: %d, p=%.1f", self.currentWpNode.ix, p)
--courseplay.debugVehicle(courseplay.DBG_PPC, self.vehicle, "PPC: %d, p=%.1f", self.currentWpNode.ix, p)
break
end

Expand Down Expand Up @@ -484,7 +484,7 @@ function PurePursuitController:findGoalPoint()
node1:destroy()
node2:destroy()

if courseplay.debugChannels[courseplay.DBG_12] then
if courseplay.debugChannels[courseplay.DBG_PPC] then
local gx, gy, gz = localToWorld(self.goalWpNode.node, 0, 0, 0)
cpDebug:drawLine(gx, gy + 3, gz, 0, 1, 0, gx, gy + 1, gz);
DebugUtil.drawDebugNode(self.currentWpNode.node, string.format('ix = %d\ncurrent\nwaypoint', self.currentWpNode.ix))
Expand Down Expand Up @@ -525,7 +525,7 @@ end

function PurePursuitController:showGoalpointDiag(case, ...)
local diagText = string.format(...)
if courseplay.debugChannels[courseplay.DBG_12] then
if courseplay.debugChannels[courseplay.DBG_PPC] then
DebugUtil.drawDebugNode(self.goalWpNode.node, diagText)
DebugUtil.drawDebugNode(self.controlledNode, 'controlled')
end
Expand Down