summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-11-13 16:21:00 +0100
committerHans Hagen <pragma@wxs.nl>2013-11-13 16:21:00 +0100
commitba6d55e408dce923fc22263f410fbfbceb845595 (patch)
tree34f437bfad0ee5124f93cb0344a1fd82005b800f /tex
parent2f74ac54a35a75f5840f6b955abdb38baebfd3d0 (diff)
downloadcontext-ba6d55e408dce923fc22263f410fbfbceb845595.tar.gz
beta 2013.11.13 16:21
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4112 -> 4107 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/core-con.lua2
-rw-r--r--tex/context/base/core-con.mkiv14
-rw-r--r--tex/context/base/s-youless.mkiv201
-rw-r--r--tex/context/base/status-files.pdfbin24519 -> 24516 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin222448 -> 222369 bytes
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
9 files changed, 212 insertions, 11 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 0506dce5d..f535e1628 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 12:28}
+\newcontextversion{2013.11.13 16:21}
%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
index 853950cd3..10a349799 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index f945319dd..355879aa1 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 12:28}
+\edef\contextversion{2013.11.13 16:21}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 315a34f39..dad24a7d4 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -971,7 +971,7 @@ local days = { -- not variables.sunday
"saturday",
}
-local months = { -- not variables.januari
+local months = { -- not variables.january
"january",
"february",
"march",
diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv
index 375d77072..a43473ced 100644
--- a/tex/context/base/core-con.mkiv
+++ b/tex/context/base/core-con.mkiv
@@ -206,8 +206,8 @@
%D
%D Anyhow, the conversion looks like:
-\def\monthlong #1{\ctxcommand{monthname(#1)}}
-\def\monthshort#1{\ctxcommand{monthmnem(#1)}}
+\unexpanded\def\monthlong #1{\ctxcommand{monthname(#1)}}
+\unexpanded\def\monthshort#1{\ctxcommand{monthmnem(#1)}}
\let\convertmonth\monthlong % for old times sake
@@ -218,9 +218,9 @@
\let\month \monthlong
-\def\MONTH #1{\WORD{\month {#1}}}
-\def\MONTHLONG #1{\WORD{\monthlong {#1}}}
-\def\MONTHSHORT#1{\WORD{\monthshort{#1}}}
+\unexpanded\def\MONTH #1{\WORD{\month {#1}}}
+\unexpanded\def\MONTHLONG #1{\WORD{\monthlong {#1}}}
+\unexpanded\def\MONTHSHORT#1{\WORD{\monthshort{#1}}}
%D We never explicitly needed this, but Tobias Burnus pointed out that it would be
%D handy to convert to the day of the week. In doing so, we have to calculate the
@@ -240,8 +240,8 @@
%D \showsetup{weekday}
%D \showsetup{WEEKDAY}
-\def\weekday#1{\ctxcommand{day(#1)}}
-\def\WEEKDAY#1{\WORD{\weekday{#1}}}
+\unexpanded\def\weekday#1{\ctxcommand{day(#1)}}
+\unexpanded\def\WEEKDAY#1{\WORD{\weekday{#1}}}
%D \macros
%D {getdayoftheweek, dayoftheweek}
diff --git a/tex/context/base/s-youless.mkiv b/tex/context/base/s-youless.mkiv
new file mode 100644
index 000000000..fbc60ba47
--- /dev/null
+++ b/tex/context/base/s-youless.mkiv
@@ -0,0 +1,201 @@
+%D \module
+%D [ file=s-youless,
+%D version=2013.11.12,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Youless Graphics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is experimental code. When I have collected enough data I will make the
+%D graphics nicer and provide some more.
+%D
+%D The Jouless can serve web pages but there is not much detail in them. They also are
+%D somewhat bad \HTML, like unquoted attributes and so. We don't need this anyway as we
+%D can also fetch data directly. The data is collected using a dedicated helper script
+%D (of course we could just call it as module too). The data is fetched from the Jouless
+%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
+
+\startluacode
+
+ moduledata.youless = { }
+
+ 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
+
+ function moduledata.youless.kwh(specification)
+ -- todo
+ end
+
+ function moduledata.youless.watt(specification)
+
+ local y = tonumber(specification.year) or os.today().year
+ local data = table.load(specification.filename or "youless-watt.lua")
+
+ if not data then
+ return
+ end
+
+ moduledata.youless.enhance(data)
+
+ local year = data.years[y]
+ local scale = 10
+
+ for m=1,12 do
+ local month = year.months[m]
+ if month then
+ context.startMPpage { offset = "10pt" }
+ context("linecap := butt; pickup pencircle scaled .5")
+
+ 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 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)
+ end
+ end
+ end
+ 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)
+
+ 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.stopMPpage()
+ else
+ -- maybe placeholder
+ end
+ end
+
+ end
+
+\stopluacode
+
+\continueifinputfile{s-youless.mkiv}
+
+\setupbodyfont[dejavu]
+
+% printer (oce) : > 3000 W startup (900 W idle, 2000 W printing)
+% coffeemaker : 1500 W when heating
+
+% baseline day : 2250 W (servers, airco, workstations, routers, switches, heating, etc)
+% baseline night : 1750 W
+
+\starttext
+
+ \startluacode
+
+ 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" }
+
+ \stopluacode
+
+\stoptext
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index ce269173a..34d4875da 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 3ac4ca292..9eb5052cc 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index f6e95a000..202c24994 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 12:28:55
+-- merge date : 11/13/13 16:21:08
do -- begin closure to overcome local limits and interference