77 lines
1.6 KiB
Plaintext
77 lines
1.6 KiB
Plaintext
-- @include /koptilnya/libs/watcher.txt
|
|
-- @include ./base.txt
|
|
require('/koptilnya/libs/watcher.txt')
|
|
require('./base.txt')
|
|
|
|
ManualGearbox = class('ManualGearbox', Gearbox)
|
|
|
|
function ManualGearbox:initialize(config, clutch)
|
|
Gearbox.initialize(self, config, clutch)
|
|
|
|
-- self.ratios = config.Ratios
|
|
-- self.reverse = config.Reverse
|
|
|
|
-- self.rpm = 0
|
|
-- self.torque = 0
|
|
-- self.gear = 0
|
|
|
|
-- self:recalcRatio()
|
|
|
|
-- self.axles = {}
|
|
-- self.clutch = nil
|
|
|
|
-- self.torque = 0
|
|
|
|
-- self.shiftWatcher = watcher(function()
|
|
-- return wire.ports.Upshift - wire.ports.Downshift
|
|
-- end, function(val)
|
|
-- if val ~= 0 then
|
|
-- self:shift(val)
|
|
-- end
|
|
-- end)
|
|
end
|
|
|
|
function ManualGearbox:recalcRatio()
|
|
if self.gear == -1 then
|
|
self.ratio = -self.reverse
|
|
elseif self.gear == 0 then
|
|
self.ratio = 0
|
|
else
|
|
self.ratio = self.ratios[self.gear]
|
|
end
|
|
end
|
|
|
|
function ManualGearbox:getInputs()
|
|
return {
|
|
Upshift = 'number',
|
|
Downshift = 'number'
|
|
}
|
|
end
|
|
|
|
function ManualGearbox:getOutputs()
|
|
return {
|
|
Gearbox_RPM = 'number',
|
|
Gearbox_Torque = 'number'
|
|
}
|
|
end
|
|
|
|
function ManualGearbox:updateOutputs()
|
|
|
|
end
|
|
|
|
function ManualGearbox:update()
|
|
-- if self.clutch ~= nil then
|
|
-- self.torque = self.clutch.torque * self.ratio
|
|
-- end
|
|
|
|
-- local axlesRPM = table.map(self.axles, function(diff)
|
|
-- return diff.avgRPM
|
|
-- end)
|
|
|
|
-- local maxAxlesRPM = math.max(unpack(axlesRPM))
|
|
|
|
-- self.rpm = maxAxlesRPM * self.ratio
|
|
|
|
-- self.shiftWatcher()
|
|
end
|