diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4107 -> 4109 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/data-env.lua | 2 | ||||
-rw-r--r-- | tex/context/base/font-mis.lua | 2 | ||||
-rw-r--r-- | tex/context/base/font-otf.lua | 126 | ||||
-rw-r--r-- | tex/context/base/s-youless.mkiv | 193 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24516 -> 24550 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 222369 -> 222373 bytes | |||
-rw-r--r-- | tex/context/base/util-env.lua | 4 | ||||
-rw-r--r-- | tex/context/base/util-you.lua | 237 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 14 |
12 files changed, 328 insertions, 254 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index f535e1628..6f32d508d 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.11.13 16:21} +\newcontextversion{2013.11.14 13:34} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 10a349799..6e701ac85 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 355879aa1..e32ae7d2a 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.11.13 16:21} +\edef\contextversion{2013.11.14 13:34} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/data-env.lua b/tex/context/base/data-env.lua index 2ee25120e..58a081506 100644 --- a/tex/context/base/data-env.lua +++ b/tex/context/base/data-env.lua @@ -106,7 +106,7 @@ local relations = allocate { -- todo: handlers also here texmfscripts = { names = { "texmfscript", "texmfscripts", "script", "scripts" }, variable = 'TEXMFSCRIPTS', - suffixes = { 'rb', 'pl', 'py' }, + suffixes = { 'lua', 'rb', 'pl', 'py' }, }, lua = { names = { "lua" }, diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua index 6b6789481..5ac9d671c 100644 --- a/tex/context/base/font-mis.lua +++ b/tex/context/base/font-mis.lua @@ -22,7 +22,7 @@ local handlers = fonts.handlers handlers.otf = handlers.otf or { } local otf = handlers.otf -otf.version = otf.version or 2.747 +otf.version = otf.version or 2.748 otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true) function otf.loadcached(filename,format,sub) diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 5b10c1181..e2fd845a0 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -18,7 +18,7 @@ local utfbyte = utf.byte local format, gmatch, gsub, find, match, lower, strip = string.format, string.gmatch, string.gsub, string.find, string.match, string.lower, string.strip local type, next, tonumber, tostring = type, next, tonumber, tostring local abs = math.abs -local getn = table.getn +local insert = table.insert local lpegmatch = lpeg.match local reversed, concat, remove = table.reversed, table.concat, table.remove local ioflush = io.flush @@ -48,7 +48,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.747 -- beware: also sync font-mis.lua +otf.version = 2.748 -- beware: also sync font-mis.lua otf.cache = containers.define("fonts", "otf", otf.version, true) local fontdata = fonts.hashes.identifiers @@ -815,21 +815,21 @@ actions["check encoding"] = function(data,filename,raw) if parentdescription then local altuni = parentdescription.altuni if not altuni then - altuni = { { unicode = parent } } + altuni = { { unicode = unicode } } parentdescription.altuni = altuni duplicates[parent] = { unicode } else local done = false for i=1,#altuni do - if altuni[i].unicode == parent then + if altuni[i].unicode == unicode then done = true break end end if not done then -- let's assume simple cjk reuse - altuni[#altuni+1] = { unicode = parent } - table.insert(duplicates[parent],unicode) + insert(altuni,{ unicode = unicode }) + insert(duplicates[parent],unicode) end end if trace_loading then @@ -1552,118 +1552,6 @@ actions["reorganize glyph kerns"] = function(data,filename,raw) end end --- actions["merge kern classes"] = function(data,filename,raw) --- local gposlist = raw.gpos --- if gposlist then --- local descriptions = data.descriptions --- local resources = data.resources --- local unicodes = resources.unicodes --- local splitter = data.helpers.tounicodetable --- local ignored = 0 --- for gp=1,#gposlist do --- local gpos = gposlist[gp] --- local subtables = gpos.subtables --- if subtables then --- for s=1,#subtables do --- local subtable = subtables[s] --- local kernclass = subtable.kernclass -- name is inconsistent with anchor_classes --- if kernclass then -- the next one is quite slow --- local split = { } -- saves time --- for k=1,#kernclass do --- local kcl = kernclass[k] --- local firsts = kcl.firsts --- local seconds = kcl.seconds --- local offsets = kcl.offsets --- local lookups = kcl.lookup -- singular --- if type(lookups) ~= "table" then --- lookups = { lookups } --- end --- -- if offsets[1] == nil then --- -- offsets[1] = "" -- defaults ? --- -- end --- -- we can check the max in the loop --- -- local maxseconds = getn(seconds) --- for n, s in next, firsts do --- split[s] = split[s] or lpegmatch(splitter,s) --- end --- local maxseconds = 0 --- for n, s in next, seconds do --- if n > maxseconds then --- maxseconds = n --- end --- split[s] = split[s] or lpegmatch(splitter,s) --- end --- for l=1,#lookups do --- local lookup = lookups[l] --- for fk=1,#firsts do -- maxfirsts ? --- local fv = firsts[fk] --- local splt = split[fv] --- if splt then --- local extrakerns = { } --- local baseoffset = (fk-1) * maxseconds --- for sk=2,maxseconds do -- will become 1 based in future luatex --- local sv = seconds[sk] --- -- for sk, sv in next, seconds do --- local splt = split[sv] --- if splt then -- redundant test --- local offset = offsets[baseoffset + sk] --- if offset then --- for i=1,#splt do --- extrakerns[splt[i]] = offset --- end --- end --- end --- end --- for i=1,#splt do --- local first_unicode = splt[i] --- local description = descriptions[first_unicode] --- if description then --- local kerns = description.kerns --- if not kerns then --- kerns = { } -- unicode indexed ! --- description.kerns = kerns --- end --- local lookupkerns = kerns[lookup] --- if not lookupkerns then --- lookupkerns = { } --- kerns[lookup] = lookupkerns --- end --- if overloadkerns then --- for second_unicode, kern in next, extrakerns do --- lookupkerns[second_unicode] = kern --- end --- else --- for second_unicode, kern in next, extrakerns do --- local k = lookupkerns[second_unicode] --- if not k then --- lookupkerns[second_unicode] = kern --- elseif k ~= kern then --- if trace_loading then --- report_otf("lookup %a: ignoring overload of kern between %C and %C, rejecting %a, keeping %a",lookup,first_unicode,second_unicode,k,kern) --- end --- ignored = ignored + 1 --- end --- end --- end --- elseif trace_loading then --- report_otf("no glyph data for %U", first_unicode) --- end --- end --- end --- end --- end --- end --- subtable.kernclass = { } --- end --- end --- end --- end --- if ignored > 0 then --- report_otf("%s kern overloads ignored") --- end --- end --- end - actions["merge kern classes"] = function(data,filename,raw) local gposlist = raw.gpos if gposlist then @@ -1695,8 +1583,6 @@ actions["merge kern classes"] = function(data,filename,raw) -- if offsets[1] == nil then -- offsets[1] = "" -- defaults ? -- end - -- we can check the max in the loop - -- local maxseconds = getn(seconds) for n, s in next, firsts do split[s] = split[s] or lpegmatch(splitter,s) end diff --git a/tex/context/base/s-youless.mkiv b/tex/context/base/s-youless.mkiv index fbc60ba47..5fc6933e9 100644 --- a/tex/context/base/s-youless.mkiv +++ b/tex/context/base/s-youless.mkiv @@ -21,74 +21,16 @@ %D device using queries (currently we use json, but a more direct parsing of data might %D be more efficient). The data is converted into a proper \LUA\ table and saved (merged). -% mtxrun --script youless --collect --kwk -% mtxrun --script youless --collect --watt +% in cronjob on one of the servers: +% +% mtxrun --script youless --collect --host=192.168.2.50 --watt youless-watt.lua +% mtxrun --script youless --collect --host=192.168.2.50 --kwk youless-kwh.lua \startluacode - moduledata.youless = { } + require("util-you") - function moduledata.youless.enhance(data) - if data.years then - for y, year in next, data.years do - if year.months then - local a_year, n_year, m_year = 0, 0, 0 - for m, month in next, year.months do - if month.days then - n_year = n_year + 1 - local a_month, n_month = 0, 0 - for d, day in next, month.days do - if day.hours then - n_month = n_month + 1 - local a_day, n_day = 0, 0 - for h, hour in next, day.hours do - local a_hour, n_hour, m_hour = 0, 0, 0 - for k, v in next, hour do - if type(k) == "number" then - a_hour = a_hour + v - n_hour = n_hour + 1 - if v > m_hour then - m_hour = v - end - end - end - n_day = n_day + n_hour - a_day = a_day + a_hour - hour.maxwatt = m_hour - hour.watt = a_hour / n_hour - if m_hour > m_year then - m_year = m_hour - end - end - if n_day > 0 then - a_month = a_month + a_day - n_month = n_month + n_day - day.watt = a_day / n_day - else - day.watt = 0 - end - end - end - if n_month > 0 then - a_year = a_year + a_month - n_year = n_year + n_month - month.watt = a_month / n_month - else - month.watt = 0 - end - end - end - if n_year > 0 then - year.watt = a_year / n_year - year.maxwatt = m_year - else - year.watt = 0 - year.maxwatt = 0 - end - end - end - end - end + moduledata.youless = { } function moduledata.youless.kwh(specification) -- todo @@ -96,80 +38,87 @@ function moduledata.youless.watt(specification) - local y = tonumber(specification.year) or os.today().year + local year = tonumber(specification.year) or os.today().year local data = table.load(specification.filename or "youless-watt.lua") - if not data then + if not data or data.variant ~= "watt" then return end - moduledata.youless.enhance(data) + utilities.youless.analyze(data) - local year = data.years[y] - local scale = 10 + for y=year,year do - for m=1,12 do - local month = year.months[m] - if month then - context.startMPpage { offset = "10pt" } - context("linecap := butt; pickup pencircle scaled .5") + local year = data.years[y] + local scale = 20 - for i=0,(math.div(year.maxwatt,1000)+1)*1000,100 do - context("draw (%s,%s) -- (%s,%s) withcolor .6white ;",0,i/scale,31 * 24,i/scale) - end + for m=1,12 do + local month = year.months[m] + if month then + context.startMPpage { offset = "10pt" } + context("linecap := butt; pickup pencircle scaled .5") - context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(on 3 off 3) withcolor darkgreen withpen pencircle scaled 1 ;",year.watt /scale,year.watt /scale) - context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(off 3 on 3) withcolor darkred withpen pencircle scaled 1 ;",month.watt/scale,month.watt/scale) - - local days = month.days - if days then - local nd = os.nofdays(y,m) - for d=1,nd do - local day = days[d] - local xoffset = (d-1) * 24 - local wd = os.weekday(d,m,y) - local weekend = wd == 1 or wd == 2 or wd == 7 - if weekend then - context("draw (%s,%s) -- (%s,%s); ",xoffset,-12,xoffset,weekend and -30) - context("draw (%s,%s) -- (%s,%s); ",xoffset+24,-12,xoffset+24,weekend and -30) - end - context([[draw textext("%s") shifted (%s,%s) ; ]],d,xoffset + 12,-20) - if day then - for h=0,23 do - local hours = day.hours - if hours then - local hour = hours[h] - if hour then - local dx = xoffset + h - local dy = hour.watt/scale - local dm = hour.maxwatt/scale - context("draw (%s,%s) -- (%s,%s) withcolor darkblue ; ",dx,0,dx,dy) - context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",dx,dy,dx,dm) + for i=0,(math.div(year.maxwatt,1000)+1)*1000,100 do + context("draw (%s,%s) -- (%s,%s) withcolor .6white ;",0,i/scale,31 * 24,i/scale) + end + + context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(on 6 off 6) withcolor darkgreen withpen pencircle scaled 1 ;",year.watt /scale,year.watt /scale) + context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(off 6 on 6) withcolor darkred withpen pencircle scaled 1 ;",month.watt/scale,month.watt/scale) + + local days = month.days + if days then + local nd = os.nofdays(y,m) + for d=1,nd do + local day = days[d] + local xoffset = (d-1) * 24 + local wd = os.weekday(d,m,y) + local weekend = wd == 1 or wd == 7 + if weekend then + context("draw (%s,%s) -- (%s,%s); ",xoffset,-12,xoffset,weekend and -30) + context("draw (%s,%s) -- (%s,%s); ",xoffset+24,-12,xoffset+24,weekend and -30) + end + context([[draw textext("%s") shifted (%s,%s) ; ]],d,xoffset + 12,-20) + if day then + for h=0,23 do + local hours = day.hours + if hours then + local hour = hours[h] + if hour then + local dx = xoffset + h + local dy = hour.watt/scale + local dm = hour.maxwatt/scale + context("draw (%s,%s) -- (%s,%s) withcolor darkblue ; ",dx,0,dx,dy) + context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",dx,dy,dx,dm) + end end end end end + for d=1,31 do + local xoffset = d * 24 + context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+ 0,0,xoffset+ 0,-10) + context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+ 6,0,xoffset+ 6,-2.5) + context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+12,0,xoffset+12,-5) + context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+18,0,xoffset+18,-2.5) + end end - for d=1,31 do - local xoffset = d * 24 - context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset,0,xoffset,-10) - end - end - local max = (math.div(year.maxwatt,1000)+1) + local max = (math.div(year.maxwatt,1000)+1) - for i=0,max*1000,1000 do - context([[draw textext.lft("%s") shifted (%s,%s) ; ]],i,-10,i/scale) - context("draw (%s,%s) -- (%s,%s) withcolor .2white ;",0,i/scale,31 * 24,i/scale) - end + for i=0,max*1000,1000 do + context([[draw textext.lft("%s") shifted (%s,%s) ; ]],i,-10,i/scale) + context("draw (%s,%s) -- (%s,%s) withcolor .2white ;",0,i/scale,31 * 24,i/scale) + end - context([[draw textext("\strut\month{%s}\enspace%s") shifted (%s,%s) ; ]],m, y, 31 * 24 / 2, -50) - context([[draw textext("watt") rotated 90 shifted (%s,%s) ; ]],-15,50) + context([[draw textext("\strut\month{%s}\enspace%s") shifted (%s,%s) ; ]],m, y, 31 * 24 / 2, -50) + context([[draw textext.lft("watt") shifted (%s,%s) ; ]],-10,-20) - context.stopMPpage() - else - -- maybe placeholder + context.stopMPpage() + else + -- maybe placeholder + end end + end end @@ -190,11 +139,11 @@ \startluacode - os.execute([[mtxrun --script youless --collect --watt "c:/data/system/youless/data/youless-watt.lua"]]) - + -- os.execute([[mtxrun --script youless --collect --watt "c:/data/system/youless/data/youless-watt.lua"]]) -- os.execute([[mtxrun --script youless --collect --watt --nobackup "c:/data/system/youless/data/youless-watt.lua"]]) + -- moduledata.youless.watt { year = 2013, filename = "c:/data/system/youless/data/youless-watt.lua" } - moduledata.youless.watt { year = 2013, filename = "c:/data/system/youless/data/youless-watt.lua" } + moduledata.youless.watt { year = 2013, filename = "youless-watt.lua" } \stopluacode diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 34d4875da..b1312a8fa 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 9eb5052cc..b291e63b2 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/util-env.lua b/tex/context/base/util-env.lua index 1184c1d5b..0a708ea43 100644 --- a/tex/context/base/util-env.lua +++ b/tex/context/base/util-env.lua @@ -42,7 +42,7 @@ local basicengines = allocate { -- ["texluajit.exe"] = "luajittex", } -local luaengines=allocate { +local luaengines = allocate { ["lua"] = true, ["luajit"] = true, } @@ -66,6 +66,8 @@ elseif luaengines[file.removesuffix(arg[-1])] then -- arg[k-1] = arg[k] -- end -- remove(arg) -- last +-- +-- environment.used_as_library = true elseif validengines[file.removesuffix(arg[0])] then if arg[1] == "--luaonly" then arg[-1] = arg[0] diff --git a/tex/context/base/util-you.lua b/tex/context/base/util-you.lua new file mode 100644 index 000000000..f54e57cd5 --- /dev/null +++ b/tex/context/base/util-you.lua @@ -0,0 +1,237 @@ +if not modules then modules = { } end modules ['util-you'] = { + version = 1.002, + comment = "library for fetching data from youless kwk meter polling device", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE", + license = "see context related readme files" +} + +-- See mtx-youless.lua and s-youless.mkiv for examples of usage. + +require("util-jsn") + +-- the library variant: + +utilities = utilities or { } +local youless = { } +utilities.youless = youless + +local lpegmatch = lpeg.match +local formatters = string.formatters + +local http = socket.http + +-- maybe just a special parser but who cares about speed here + +local function fetch(url,what,i) + local url = formatters["http://%s/V?%s=%i&f=j"](url,what,i) + local data = http.request(url) + local result = data and utilities.json.tolua(data) + return result +end + +-- "123" " 1,234" + +local tovalue = lpeg.Cs((lpeg.R("09") + lpeg.P(1)/"")^1) / tonumber + +-- "2013-11-12T06:40:00" + +local totime = (lpeg.C(4) / tonumber) * lpeg.P("-") + * (lpeg.C(2) / tonumber) * lpeg.P("-") + * (lpeg.C(2) / tonumber) * lpeg.P("T") + * (lpeg.C(2) / tonumber) * lpeg.P(":") + * (lpeg.C(2) / tonumber) * lpeg.P(":") + * (lpeg.C(2) / tonumber) + +local function get(url,what,i,data,average,variant) + if not data then + data = { } + end + while true do + local d = fetch(url,what,i) + if d and next(d) then + local c_year, c_month, c_day, c_hour, c_minute, c_seconds = lpegmatch(totime,d.tm) + if c_year and c_seconds then + local delta = tonumber(d.dt) + local tnum = os.time { year = c_year, month = c_month, day = c_day, hour = c_hour, minute = c_minute } + local v = d.val + for i=1,#v do + local newvalue = lpegmatch(tovalue,v[i]) + if newvalue then + local t = tnum + (i-1)*delta + local current = os.date("%Y-%m-%dT%H:%M:%S",t) + local c_year, c_month, c_day, c_hour, c_minute, c_seconds = lpegmatch(totime,current) + if c_year and c_seconds then + local years = data.years if not years then years = { } data.years = years end + local d_year = years[c_year] if not d_year then d_year = { } years[c_year] = d_year end + local months = d_year.months if not months then months = { } d_year.months = months end + local d_month = months[c_month] if not d_month then d_month = { } months[c_month] = d_month end + local days = d_month.days if not days then days = { } d_month.days = days end + local d_day = days[c_day] if not d_day then d_day = { } days[c_day] = d_day end + if average then + d_day.average = newvalue + else + local hours = d_day.hours if not hours then hours = { } d_day.hours = hours end + local d_hour = hours[c_hour] if not d_hour then d_hour = { } hours[c_hour] = d_hour end + d_hour[c_minute] = newvalue + end + end + end + end + end + else + return data + end + i = i + 1 + end + return data +end + +-- day of month (kwh) +-- url = http://192.168.1.14/V?m=2 +-- m = the number of month (jan = 1, feb = 2, ..., dec = 12) + +-- hour of day (watt) +-- url = http://192.168.1.14/V?d=1 +-- d = the number of days ago (today = 0, yesterday = 1, etc.) + +-- 10 minutes (watt) +-- url = http://192.168.1.14/V?w=1 +-- w = 1 for the interval now till 8 hours ago. +-- w = 2 for the interval 8 till 16 hours ago. +-- w = 3 for the interval 16 till 24 hours ago. + +-- 1 minute (watt) +-- url = http://192.168.1.14/V?h=1 +-- h = 1 for the interval now till 30 minutes ago. +-- h = 2 for the interval 30 till 60 minutes ago + +function youless.collect(specification) + if type(specification) ~= "table" then + return + end + local host = specification.host or "" + local data = specification.data or { } + local filename = specification.filename or "" + local variant = specification.variant or "kwh" + local detail = specification.detail or false + local nobackup = specification.nobackup or false + if host == "" then + return + end + if name then + data = table.load(name) or data + end + if variant == "kwh" then + get(host,"m",1,data,true) + elseif variant == "watt" then + get(host,"d",0,data,true) + get(host,"w",1,data) + if detail then + get(host,"h",1,data) + end + end + if filename == "" then + return + end + local path = file.dirname(filename) + local base = file.basename(filename) + data.variant = variant + if nobackup then + -- saved but with checking + local tempname = file.join(path,"youless.tmp") + table.save(tempname,data) + local check = table.load(tempname) + if type(check) == "table" then + local keepname = file.replacesuffix(filename,"old") + os.remove(keepname) + if not lfs.isfile(keepname) then + os.rename(filename,keepname) + os.rename(tempname,filename) + end + end + else + local keepname = file.join(path,formatters["%s-%s"](os.date("%Y-%m-%d-%H-%M-%S",os.time()),base)) + os.rename(filename,keepname) + if not lfs.isfile(filename) then + table.save(filename,data) + end + end + return data +end + +-- local data = youless.collect { +-- host = "192.168.2.50", +-- variant = "watt", +-- filename = "youless-watt.lua" +-- } + +-- inspect(data) + +-- local data = youless.collect { +-- host = "192.168.2.50", +-- variant = "kwh", +-- filename = "youless-kwh.lua" +-- } + +-- inspect(data) + +function youless.analyze(data) + if data and data.variant == "watt" and data.years then + for y, year in next, data.years do + local a_year, n_year, m_year = 0, 0, 0 + if year.months then + for m, month in next, year.months do + local a_month, n_month = 0, 0 + if month.days then + for d, day in next, month.days do + local a_day, n_day = 0, 0 + if day.hours then + for h, hour in next, day.hours do + local a_hour, n_hour, m_hour = 0, 0, 0 + for k, v in next, hour do + if type(k) == "number" then + a_hour = a_hour + v + n_hour = n_hour + 1 + if v > m_hour then + m_hour = v + end + end + end + n_day = n_day + n_hour + a_day = a_day + a_hour + hour.maxwatt = m_hour + hour.watt = a_hour / n_hour + if m_hour > m_year then + m_year = m_hour + end + end + end + if n_day > 0 then + a_month = a_month + a_day + n_month = n_month + n_day + day.watt = a_day / n_day + else + day.watt = 0 + end + end + end + if n_month > 0 then + a_year = a_year + a_month + n_year = n_year + n_month + month.watt = a_month / n_month + else + month.watt = 0 + end + end + end + if n_year > 0 then + year.watt = a_year / n_year + year.maxwatt = m_year + else + year.watt = 0 + year.maxwatt = 0 + end + end + end +end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 202c24994..babbeb948 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 11/13/13 16:21:08 +-- merge date : 11/14/13 13:34:23 do -- begin closure to overcome local limits and interference @@ -6354,7 +6354,7 @@ local utfbyte=utf.byte local format,gmatch,gsub,find,match,lower,strip=string.format,string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip local type,next,tonumber,tostring=type,next,tonumber,tostring local abs=math.abs -local getn=table.getn +local insert=table.insert local lpegmatch=lpeg.match local reversed,concat,remove=table.reversed,table.concat,table.remove local ioflush=io.flush @@ -6378,7 +6378,7 @@ local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf otf.glists={ "gsub","gpos" } -otf.version=2.747 +otf.version=2.748 otf.cache=containers.define("fonts","otf",otf.version,true) local fontdata=fonts.hashes.identifiers local chardata=characters and characters.data @@ -7032,20 +7032,20 @@ actions["check encoding"]=function(data,filename,raw) if parentdescription then local altuni=parentdescription.altuni if not altuni then - altuni={ { unicode=parent } } + altuni={ { unicode=unicode } } parentdescription.altuni=altuni duplicates[parent]={ unicode } else local done=false for i=1,#altuni do - if altuni[i].unicode==parent then + if altuni[i].unicode==unicode then done=true break end end if not done then - altuni[#altuni+1]={ unicode=parent } - table.insert(duplicates[parent],unicode) + insert(altuni,{ unicode=unicode }) + insert(duplicates[parent],unicode) end end if trace_loading then |