milo stats
This commit is contained in:
@@ -67,6 +67,7 @@ local context = {
|
|||||||
tasks = { },
|
tasks = { },
|
||||||
queue = { },
|
queue = { },
|
||||||
plugins = { },
|
plugins = { },
|
||||||
|
loggers = { },
|
||||||
|
|
||||||
storage = Storage(),
|
storage = Storage(),
|
||||||
turtleInventory = {
|
turtleInventory = {
|
||||||
@@ -187,4 +188,17 @@ os.queueEvent(
|
|||||||
context.storage:isOnline() and 'storage_online' or 'storage_offline',
|
context.storage:isOnline() and 'storage_online' or 'storage_offline',
|
||||||
context.storage:isOnline())
|
context.storage:isOnline())
|
||||||
|
|
||||||
UI:pullEvents()
|
local oldDebug = _G._debug
|
||||||
|
_G._debug = function(...)
|
||||||
|
for _,v in pairs(context.loggers) do
|
||||||
|
v(...)
|
||||||
|
end
|
||||||
|
oldDebug(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local s, m = pcall(function()
|
||||||
|
UI:pullEvents()
|
||||||
|
end)
|
||||||
|
|
||||||
|
_G._debug = oldDebug
|
||||||
|
if not s then error(m) end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local colors = _G.colors
|
|||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
local term = _G.term
|
||||||
|
|
||||||
--[[ Configuration Page ]]--
|
--[[ Configuration Page ]]--
|
||||||
local template =
|
local template =
|
||||||
@@ -136,7 +137,13 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
sortColumn = 'name',
|
sortColumn = 'name',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
[5] = UI.Tab {
|
||||||
|
tabTitle = 'Activity',
|
||||||
|
term = UI.Embedded {
|
||||||
|
--visible = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
timestamp = os.clock(),
|
timestamp = os.clock(),
|
||||||
}
|
}
|
||||||
@@ -145,6 +152,7 @@ local function createPage(node)
|
|||||||
local statsTab = page.tabs[2]
|
local statsTab = page.tabs[2]
|
||||||
local usageTab = page.tabs[3]
|
local usageTab = page.tabs[3]
|
||||||
local stateTab = page.tabs[4]
|
local stateTab = page.tabs[4]
|
||||||
|
local activityTab = page.tabs[5]
|
||||||
|
|
||||||
local function getStorageStats()
|
local function getStorageStats()
|
||||||
local stats, totals = { }, { usedSlots = 0, totalSlots = 0, totalChests = 0 }
|
local stats, totals = { }, { usedSlots = 0, totalSlots = 0, totalChests = 0 }
|
||||||
@@ -302,7 +310,7 @@ Nodes : %d
|
|||||||
self:draw()
|
self:draw()
|
||||||
self:sync()
|
self:sync()
|
||||||
end)
|
end)
|
||||||
Event.on({ 'milo_resume', 'milo_pause', 'storage_offline', 'storage_online' }, function()
|
self.ehandle = Event.on({ 'milo_resume', 'milo_pause', 'storage_offline', 'storage_online' }, function()
|
||||||
self:draw()
|
self:draw()
|
||||||
self:sync()
|
self:sync()
|
||||||
end)
|
end)
|
||||||
@@ -311,8 +319,20 @@ Nodes : %d
|
|||||||
|
|
||||||
function overviewTab:disable()
|
function overviewTab:disable()
|
||||||
Event.off(self.handle)
|
Event.off(self.handle)
|
||||||
|
Event.off(self.ehandle)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert(context.loggers, function(...)
|
||||||
|
local oterm = term.redirect(activityTab.term.win)
|
||||||
|
activityTab.term.win.scrollBottom()
|
||||||
|
Util.print(...)
|
||||||
|
_G._p = activityTab.term
|
||||||
|
term.redirect(oterm)
|
||||||
|
if activityTab.enabled then
|
||||||
|
activityTab:sync()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
return page
|
return page
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user