Author: titmuss
Date: Wed Apr 23 09:34:50 2008
New Revision: 2324
URL: http://svn.slimdevices.com?rev=2324&root=Jive&view=rev
Log:
Bug: N/A
Description:
Added count down/status screen when running autostart macros.
Added:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/fail.png
(with props)
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/pass.png
(with props)
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/Makefile.am
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/strings.txt
Modified: 7.1/trunk/squeezeplay/src/squeezeplay/Makefile.am
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/Makefile.am?rev=2324&root=Jive&r1=2323&r2=2324&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/Makefile.am (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/Makefile.am Wed Apr 23 09:34:50 2008
@@ -301,6 +301,8 @@
dist_applets_macroplay_DATA = \
share/applets/MacroPlay/MacroPlayApplet.lua \
share/applets/MacroPlay/MacroPlayMeta.lua \
+ share/applets/MacroPlay/pass.png \
+ share/applets/MacroPlay/fail.png \
share/applets/MacroPlay/strings.txt
# Data: now playing
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua?rev=2324&root=Jive&r1=2323&r2=2324&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
Wed Apr 23 09:34:50 2008
@@ -13,7 +13,7 @@
-- stuff we use
-local assert, getfenv, loadfile, ipairs, package, pairs, require, setfenv,
setmetatable, tostring = assert, getfenv, loadfile, ipairs, package, pairs,
require, setfenv, setmetatable, tostring
+local assert, getfenv, loadfile, ipairs, package, pairs, require, setfenv,
setmetatable, tostring, type = assert, getfenv, loadfile, ipairs, package,
pairs, require, setfenv, setmetatable, tostring, type
local oo = require("loop.simple")
local io = require("io")
@@ -27,6 +27,7 @@
local Applet = require("jive.Applet")
local Event = require("jive.ui.Event")
local Framework = require("jive.ui.Framework")
+local Icon = require("jive.ui.Icon")
local Menu = require("jive.ui.Menu")
local SimpleMenu = require("jive.ui.SimpleMenu")
local Surface = require("jive.ui.Surface")
@@ -48,15 +49,12 @@
-- macro (global) state
-local task = false
-local timer = false
-local macro = false
-local macrodir = false
+local instance = false
function init(self)
self.config = {}
- self:loadconfig()
+ self:loadConfig()
end
@@ -81,7 +79,7 @@
end
-function loadconfig(self)
+function loadConfig(self)
-- Load macro configuration
local f, dirorerr = loadmacro("Macros.lua")
if f then
@@ -93,10 +91,91 @@
end
-function saveconfig(self)
+function saveConfig(self)
local file = assert(io.open(self.configFile, "w"))
file:write(dumper.dump(self.config, nil, false))
file:close()
+end
+
+
+function autoplayShow(self, countdown)
+ -- Create window
+ local window = Window("window", self:string("MACRO_AUTOSTART"))
+ local menu = SimpleMenu("menu", items)
+ local help = Textarea("textarea", "")
+
+ window:addWidget(help)
+ window:addWidget(menu)
+
+ menu:addItem({
+ text = self:string("MACRO_START"),
+ sound = "WINDOWSHOW",
+ callback = function(event, menuItem)
+ if self.config.auto == false then
+ self:autoplayReset()
+ end
+ self:autoplay()
+ end,
+ })
+ menu:addItem({
+ text = self:string("MACRO_CANCEL"),
+ sound = "WINDOWSHOW",
+ callback = function(event, menuItem)
+ window:hide()
+ end,
+ })
+
+ for i, key in ipairs(self.config.autostart) do
+ local macro = self.config.macros[key]
+
+ local item = {
+ text = self:string(macro.name),
+ sound = "BUMP",
+ }
+
+ debug.dump(macro, -1)
+
+ if macro.passed then
+ item.icon = Icon("macroPass")
+ end
+ if macro.failed then
+ item.icon = Icon("macroFail")
+ end
+
+ debug.dump(item, -1)
+
+ menu:addItem(item)
+ end
+
+ if self.config.auto > #self.config.autostart then
+ -- test finished
+ self.config.auto = false
+ self:saveConfig()
+
+ help:setValue(self:string("MACRO_AUTOSTART_COMPLETE"))
+ else
+ -- countdown to tests
+ local timer = countdown or 30
+ help:setValue(self:string("MACRO_AUTOSTART_HELP", timer))
+
+ window:addTimer(1000,
+ function()
+ if timer == 1 then
+ window:hide()
+
+ self:autoplay()
+ end
+
+ timer = timer - 1
+
help:setValue(self:string("MACRO_AUTOSTART_HELP", timer))
+ end)
+ end
+
+ window:setAllowScreensaver(false)
+ window:setAlwaysOnTop(true)
+ window:setAutoHide(false)
+
+ window:show()
end
@@ -114,44 +193,50 @@
-- Macro menus
if self.config.autostart then
local item = {
- text = self:string("MACRO_PLAY_AUTOSTART"),
+ text = self:string("MACRO_AUTOPLAY"),
sound = "WINDOWSHOW",
callback = function(event, menuItem)
- self.config.auto = true
- self:autoplay()
+ self:autoplayReset()
+ self:autoplayShow()
end,
focusGained = function()
-
help:setValue(self:string("MACRO_PLAY_AUTOSTART_HELP"))
+
help:setValue(self:string("MACRO_AUTOPLAY_HELP"))
end,
weight = 1,
}
menu:addItem(item)
end
- for k, v in pairs(self.config.macros) do
+ for key, macro in pairs(self.config.macros) do
local item = {
- text = self:string(v.name),
+ text = self:string(macro.name),
sound = "WINDOWSHOW",
callback = function(event, menuItem)
- self.auto = false
- self:play(v)
+ self.config.auto = false
+ self:play(macro)
end,
focusGained = function()
- help:setValue(v.desc)
+ help:setValue(macro.desc)
end,
weight = 5,
}
- if v.passed then
- log:warn("SETTING STYLE")
- item.style = "checked"
- end
-
menu:addItem(item)
end
-- FIXME can't tie applet due to global macro state
window:show()
+end
+
+
+-- reset autoplay
+function autoplayReset(self)
+ self.config.auto = 1
+
+ for key, macro in pairs(self.config.macros) do
+ macro.passed = nil
+ macro.failed = nil
+ end
end
@@ -163,10 +248,6 @@
return
end
- if config.auto == true then
- config.auto = 1
- end
-
if config.auto > #config.autostart then
log:info("Macro Autoplay FINISHED")
config.auto = false
@@ -178,38 +259,44 @@
self:play(macro)
end
- self:saveconfig()
+ self:saveConfig()
end
-- play the macro
function play(self, _macro)
- task = Task("MacroPlay", self,
+ local task = Task("MacroPlay", self,
function()
local f, dirorerr = loadmacro(_macro.file)
if f then
- macro = _macro
- macrodir = dirorerr
-
- log:info("Macro starting: ", macro.file)
+ self.macro = _macro
+ self.macrodir = dirorerr
+
+ instance = self
+
+ log:info("Macro starting: ", _macro.file)
f()
- self:autoplay()
+ if self.config.auto then
+ self:autoplayShow(5)
+ end
else
log:warn("Macro error: ", dirorerr)
end
end)
task:addTask()
- timer = Timer(0, function()
- task:addTask()
- end, true)
+ self.timer = Timer(0, function()
+ task:addTask()
+ end, true)
end
-- delay macro for interval ms
function macroDelay(interval)
- timer:restart(interval)
+ local self = instance
+
+ self.timer:restart(interval)
Task:yield(false)
end
@@ -267,6 +354,7 @@
-- capture or verify a screenshot
function macroScreenshot(interval, file, limit)
+ local self = instance
local pass = false
limit = limit or 100
@@ -279,7 +367,7 @@
local screen = Surface:newRGB(w, h)
window:draw(screen, LAYER_ALL)
- local reffile = macrodir .. file .. ".bmp"
+ local reffile = self.macrodir .. file .. ".bmp"
if lfs.attributes(reffile, "mode") == "file" then
-- verify screenshot
log:debug("Loading reference screenshot " .. reffile)
@@ -290,7 +378,7 @@
if match < limit then
-- failure
log:warn("Macro Screenshot " .. file .. " FAILED
match=" .. match .. " limt=" .. limit)
- failfile = macrodir .. file .. "_fail.bmp"
+ failfile = self.macrodir .. file .. "_fail.bmp"
screen:saveBMP(failfile)
else
log:info("Macro Screenshot " .. file .. " PASSED")
@@ -307,18 +395,36 @@
function macroPass(msg)
- log:warn("Macro PASS ", macro.name, ": ", msg)
-
- macro.passed = os.date()
- macro.failed = nil
+ local self = instance
+
+ log:warn("Macro PASS ", self.macro.name, ": ", msg)
+
+ self.macro.passed = os.date()
+ self.macro.failed = nil
+
+ self:saveConfig()
end
function macroFail(msg)
- log:warn("Macro FAIL ", macro.name, ": ", msg)
-
- macro.passed = nil
- macro.failed = os.date()
+ local self = instance
+
+ log:warn("Macro FAIL ", self.macro.name, ": ", msg)
+
+ self.macro.passed = nil
+ self.macro.failed = os.date()
+
+ self:saveConfig()
+end
+
+
+function skin(self, s)
+ s.macroPass = {
+ img = Surface:loadImage("applets/MacroPlay/pass.png")
+ }
+ s.macroFail = {
+ img = Surface:loadImage("applets/MacroPlay/fail.png")
+ }
end
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua?rev=2324&root=Jive&r1=2323&r2=2324&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
Wed Apr 23 09:34:50 2008
@@ -48,14 +48,12 @@
end
if applet.config.auto then
- Timer(30000,
- function()
- applet:autoplay()
- end,
- true):start()
+ applet:autoplayShow()
end
-- menu item to start
jiveMain:addItem(meta:menuItem('macroPlay', 'extras', 'MACRO_PLAY',
function(applet, ...) applet:settingsShow(...) end))
+
+ jiveMain:loadSkin("MacroPlay", "skin")
end
Added: 7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/fail.png
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/fail.png?rev=2324&root=Jive&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/fail.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: 7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/pass.png
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/pass.png?rev=2324&root=Jive&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/pass.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/strings.txt
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/strings.txt?rev=2324&root=Jive&r1=2323&r2=2324&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/strings.txt
(original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/strings.txt
Wed Apr 23 09:34:50 2008
@@ -1,10 +1,24 @@
MACRO_PLAY
- DA Makro for afspil
- EN Play Macro
+ EN Test macros
-MACRO_PLAY_AUTOSTART
+MACRO_AUTOPLAY
EN Automatic tests
-MACRO_PLAY_AUTOSTART_HELP
+MACRO_AUTOPLAY_HELP
EN Start automatic tests.
+
+MACRO_AUTOSTART
+ EN Automatic tests
+
+MACRO_AUTOSTART_HELP
+ EN Starting in %s seconds.
+
+MACRO_AUTOSTART_COMPLETE
+ EN Tests complete.
+
+MACRO_START
+ EN Start
+
+MACRO_CANCEL
+ EN Cancel
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins