安装 Steam
登录
|
语言
繁體中文(繁体中文)
日本語(日语)
한국어(韩语)
ไทย(泰语)
български(保加利亚语)
Čeština(捷克语)
Dansk(丹麦语)
Deutsch(德语)
English(英语)
Español-España(西班牙语 - 西班牙)
Español - Latinoamérica(西班牙语 - 拉丁美洲)
Ελληνικά(希腊语)
Français(法语)
Italiano(意大利语)
Bahasa Indonesia(印度尼西亚语)
Magyar(匈牙利语)
Nederlands(荷兰语)
Norsk(挪威语)
Polski(波兰语)
Português(葡萄牙语 - 葡萄牙)
Português-Brasil(葡萄牙语 - 巴西)
Română(罗马尼亚语)
Русский(俄语)
Suomi(芬兰语)
Svenska(瑞典语)
Türkçe(土耳其语)
Tiếng Việt(越南语)
Українська(乌克兰语)
报告翻译问题








-- 输入1: 实时负载 (kW)
-- 输入2: 实时功率 (kW)
-- 输入3: 最大反应堆功率 (kW)
-- 输入4: 反应堆温度 (0-100000)
-- 输出1: 裂变速率控制 (%)
-- 输出2: 涡轮输出功率 (%)
-- 控制器配置参数
local config = {
minFissionRate = 10, -- 最小裂变速率(%)
maxFissionRate = 100, -- 最大裂变速率(%)
responseDelay = 0.5, -- 响应延迟(秒)
powerSmoothing = 0.1, -- 功率平滑系数
loadStableThreshold = 5, -- 负载稳定阈值(kW)
efficiencyTarget = 0.95, -- 目标效率值
tempEmergencyThreshold = 5100,-- 温度紧急阈值,超过此值裂变速率设为0
tempStableRange = 5000 -- 温度稳定范围
}
-- 状态变量
local currentLoad = 0
local currentPower = 0
local currentTemperature = 0
local maxReactorPower = 3100 -- 默认值3100kW
local targetFissionRate = config.minFissionRate
local currentFissionRate = config.minFissionRate
local lastUpdateTime = 0
local loadHistory = {}
local powerHistory = {}
local maxHistorySize = 10
local emergencyShutdown = false -- 紧急关闭状态
-- 初始化控制器
function initialize()
print("反应堆控制器启动完成 - 最大功率: " .. maxReactorPower .. "kW")
print("温度紧急阈值: " .. config.tempEmergencyThreshold)
print("温度稳定范围: " .. config.tempStableRange)
end
-- 输入处理函数
function inp(pin, value)
if pin == 1 then
-- 实时负载输入 (kW)
currentLoad = tonumber(value) or 0
recordHistory(loadHistory, currentLoad)
elseif pin == 2 then
-- 实时功率输入 (kW)
currentPower = tonumber(value) or 0
recordHistory(powerHistory, currentPower)
elseif pin == 3 then
-- 最大反应堆功率输入 (kW)
local newMaxPower = tonumber(value) or 3100
if newMaxPower ~= maxReactorPower then
maxReactorPower = newMaxPower
print("更新最大反应堆功率: " .. maxReactorPower .. "kW")
end
elseif pin == 4 then
-- 反应堆温度输入 (0-100000)
currentTemperature = tonumber(value) or 0
-- 检查温度紧急阈值
if currentTemperature >= config.tempEmergencyThreshold then
if not emergencyShutdown then
emergencyShutdown = true
print("紧急关闭: 温度超过" .. config.tempEmergencyThreshold .. "!")
end
elseif currentTemperature < config.tempEmergencyThreshold then
if emergencyShutdown then
emergencyShutdown = false
print("紧急关闭解除: 温度低于" .. config.tempEmergencyThreshold)
end
end
end
end
-- 主更新函数
function update(deltaTime)
-- 控制逻辑执行
local currentTime = os.time()
if currentTime - lastUpdateTime >= config.responseDelay then
-- 如果处于紧急关闭状态,强制裂变速率为0
if emergencyShutdown then
out[1] = 0 -- 裂变速率设为0
out[2] = 0 -- 涡轮输出设为0
print("紧急关闭状态: 裂变速率和涡轮输出已设为0")
else
-- 正常控制逻辑
if performSafetyCheck() then
adjustFissionRate()
local turbineOutputPercent = calculateTurbineOutputPercent()
-- 输出控制信号
out[1] = currentFissionRate
out[2] = turbineOutputPercent
-- 调试输出
print(string.format("负载: %.1fkW, 功率: %.1fkW, 温度: %.0f, 裂变: %.1f%%, 涡轮: %.1f%%",
currentLoad, currentPower, currentTemperature, currentFissionRate, turbineOutputPercent))
else
-- 安全模式:最低输出
out[1] = config.minFissionRate
out[2] = 5 -- 5% 最低涡轮输出
end
end
lastUpdateTime = currentTime
end
end
-- 记录历史数据用于趋势分析
function recordHistory(historyTable, value)
table.insert(historyTable, value)
if #historyTable > maxHistorySize then
table.remove(historyTable, 1)
end
end
-- 计算负载变化趋势 (kW/秒)
function calculateLoadTrend()
if #loadHistory < 2 then return 0 end
local sum = 0
for i = 2, #loadHistory do
sum = sum + (loadHistory - loadHistory[i-1])
end
return sum / (#loadHistory - 1)
end
-- 计算当前功率效率
function calculateEfficiency()
if currentLoad <= 0 then return 0 end
return math.min(1.0, currentPower / currentLoad)
end
-- 检查负载是否稳定
function isLoadStable()
if #loadHistory < 2 then return true end
local variance = 0
local average = 0
for _, value in ipairs(loadHistory) do
average = average + value
end
average = average / #loadHistory
for _, value in ipairs(loadHistory) do
variance = variance + math.abs(value - average)
end
variance = variance / #loadHistory
return variance < config.loadStableThreshold
end
-- 温度稳定控制 - 维持温度在5000左右
function applyTemperatureStabilization(baseTarget)
-- 计算与目标温度的偏差
local tempDeviation = math.abs(currentTemperature - config.tempStableRange)
-- 如果温度偏离目标值,调整裂变速率
if tempDeviation > 100 then -- 允许100的偏差范围
local stabilizationFactor = 1.0
-- 温度过高,降低裂变速率
if currentTemperature > config.tempStableRange then
stabilizationFactor = 1.0 - (tempDeviation / 1000) * 0.5 -- 最大降低50%
print(string.format("温度稳定控制: 温度%.0f过高, 控制因子%.2f", currentTemperature, stabilizationFactor))
-- 温度过低,提高裂变速率
else
stabilizationFactor = 1.0 + (tempDeviation / 1000) * 0.3 -- 最大提高30%
print(string.format("温度稳定控制: 温度%.0f过低, 控制因子%.2f", currentTemperature, stabilizationFactor))
end
baseTarget = baseTarget * stabilizationFactor
end
return baseTarget
end
-- 自适应裂变速率控制
function adjustFissionRate()
local loadRatio = currentLoad / maxReactorPower
local efficiency = calculateEfficiency()
local trend = calculateLoadTrend()
-- 基础计算
local baseTarget = loadRatio * config.maxFissionRate
-- 效率修正
local efficiencyFactor = 1.0
if efficiency < config.efficiencyTarget - 0.1 then
efficiencyFactor = 1.05 -- 效率低,提高裂变速率
elseif efficiency > config.efficiencyTarget + 0.1 then
efficiencyFactor = 0.95 -- 效率过高,降低裂变速率
end
-- 趋势预测 (kW/秒)
local trendFactor = 1.0
if math.abs(trend) > 50 then -- 负载变化超过50kW/秒
trendFactor = trend > 0 and 1.03 or 0.97
end
-- 负载稳定性调整
local stabilityFactor = 1.0
if not isLoadStable() then
stabilityFactor = 0.98 -- 负载不稳定时保守调节
end
-- 合并所有因素
baseTarget = baseTarget * efficiencyFactor * trendFactor * stabilityFactor
-- 应用温度稳定控制 - 维持温度在5000左右
baseTarget = applyTemperatureStabilization(baseTarget)
-- 应用限制
targetFissionRate = math.max(config.minFissionRate,
math.min(config.maxFissionRate, baseTarget))
-- 平滑过渡到目标值
currentFissionRate = currentFissionRate + (targetFissionRate - currentFissionRate) * config.powerSmoothing
end
-- 计算涡轮输出功率百分比 (%)
function calculateTurbineOutputPercent()
local turbineOutputPercent = 0
if currentFissionRate > config.minFissionRate then
-- 基础输出基于裂变速率
local baseOutputPercent = currentFissionRate -- 直接使用裂变速率作为基础百分比
if currentLoad > 0 then
-- 根据负载需求微调
local loadAdjustment = ((currentLoad - currentPower) / maxReactorPower) * 20
local efficiencyAdjustment = (config.efficiencyTarget - calculateEfficiency()) * 10
turbineOutputPercent = baseOutputPercent + loadAdjustment + efficiencyAdjustment
else
-- 空载时降低输出
turbineOutputPercent = baseOutputPercent * 0.3
end
-- 限制输出范围 (0%到100%)
turbineOutputPercent = math.max(0, math.min(100, turbineOutputPercent))
end
return turbineOutputPercent
end
-- 安全检查
function performSafetyCheck()
local loadRatio = currentLoad / maxReactorPower
-- 负载安全检查
if loadRatio > 1.1 then
-- 严重过载 (超过最大功率10%),紧急降低输出
targetFissionRate = config.minFissionRate
print("警告: 反应堆严重过载! 紧急降低输出")
return false
elseif loadRatio > 0.95 then
-- 高负载 (超过最大功率95%),保守调节
targetFissionRate = math.min(targetFissionRate, config.maxFissionRate * 0.9)
end
return true
end
-- 保存和加载函数
function onItemLoaded()
local savedData = readMemory()
if savedData then
print("控制器状态已加载")
end
end
function onSave()
local saveData = string.format("%f,%f", config.minFissionRate, config.maxFissionRate)
writeMemory(saveData)
end
-- 初始化控制器
initialize()