Skip to content

Commit

Permalink
Merge pull request #2404 from Courseplay/BalerSilageAdditive
Browse files Browse the repository at this point in the history
Added silage additives for balers
  • Loading branch information
schwiti6190 committed Mar 23, 2023
2 parents 0a5792f + 7533d1a commit c045d5e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/VehicleSettingsSetup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
isDisabled = "isToolOffsetDisabled" vehicleConfiguration="toolOffsetX"/>
<!--Tool Offset Z-->
<Setting classType="AIParameterSettingList" name="toolOffsetZ" min="-10" max="10" incremental="0.1" default="0" unit="2"
onChangeCallback="cpShowWorkWidth" isDisabled = "isToolOffsetDisabled" />
onChangeCallback="cpShowWorkWidth" isDisabled = "isToolOffsetDisabled" isVisible="areCombineUnloaderSettingsVisible" />
<!-- Full threshold -->
<Setting classType="AIParameterSettingList" name="fullThreshold" min="40" max="100" incremental="5" default="85" unit="4"/>
<Setting classType="AIParameterSettingList" name="fullThreshold" min="40" max="100" incremental="5" default="85" unit="4" isVisible="areCombineUnloaderSettingsVisible"/>
<!--Silage additives needed?-->
<Setting classType="AIParameterBooleanSetting" name="useAdditiveFillUnit" defaultBool="false" isVisible="isAdditiveFillUnitSettingVisible" isExpertModeOnly="true"/>
</SettingSubTitle>
Expand Down
12 changes: 12 additions & 0 deletions scripts/ai/controllers/BalerController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ function BalerController:getDriveData()
return nil, nil, nil, maxSpeed
end

function BalerController:update()
if self.settings.useAdditiveFillUnit:getValue() then
--- If the silage additive is empty, then stop the driver.
if self.balerSpec.additives.available then
if self.implement:getFillUnitFillLevelPercentage(self.balerSpec.additives.fillUnitIndex) <= 0 then
self:debug("Stopped Cp, as the additive fill unit is empty.")
self.vehicle:stopCurrentAIJob(AIMessageErrorOutOfFill.new())
end
end
end
end

function BalerController:handleBaler()
if self.driveStrategy:isTurning() then
--- Waits for the bale wrapping and unload at the start of a turn.
Expand Down
8 changes: 8 additions & 0 deletions scripts/specializations/CpVehicleSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,17 @@ end
function CpVehicleSettings:isAdditiveFillUnitSettingVisible()
local combines, _ = AIUtil.getAllChildVehiclesWithSpecialization(self, Combine)
local forageWagons, _ = AIUtil.getAllChildVehiclesWithSpecialization(self, ForageWagon)
local balers, _ = AIUtil.getAllChildVehiclesWithSpecialization(self, Baler)
local hasAdditiveTank
if #combines > 0 then
hasAdditiveTank = combines[1].spec_combine.additives.available
end
if #forageWagons > 0 then
hasAdditiveTank = hasAdditiveTank or forageWagons[1].spec_forageWagon.additives.available
end
if #balers > 0 then
hasAdditiveTank = hasAdditiveTank or balers[1].spec_baler.additives.available
end
return hasAdditiveTank
end

Expand All @@ -359,6 +363,10 @@ function CpVehicleSettings:areBunkerSiloSettingsVisible()
return self:getCanStartCpBunkerSiloWorker()
end

function CpVehicleSettings:areCombineUnloaderSettingsVisible()
return self:getCanStartCpCombineUnloader()
end

function CpVehicleSettings:setAutomaticBunkerSiloWorkWidth(ignoreObject)
local spec = self.spec_cpVehicleSettings
local width = WorkWidthUtil.getAutomaticWorkWidthAndOffset(self, nil, ignoreObject)
Expand Down

0 comments on commit c045d5e

Please sign in to comment.