1
0
Fork 0
lvspec/task.sty

257 lines
6.2 KiB
Plaintext
Raw Normal View History

2013-08-14 15:32:46 -04:00
% Task environment
2013-08-15 12:04:54 -04:00
\RequirePackage[usenames,dvipsnames]{xcolor}
2013-08-29 13:03:27 -04:00
\RequirePackage{etex}
2013-08-15 12:04:54 -04:00
\newif\ifshowtasktime
2013-08-14 15:32:46 -04:00
\newcommand\taskname{Requisite}
2013-08-15 12:04:54 -04:00
% Tango Icon Theme Aluminum
\definecolor{taskrulecolor}{HTML}{2e3436}
2013-08-14 15:32:46 -04:00
\newcounter{taskc}
\setcounter{taskc}{0}
\renewcommand\thetaskc{\Roman{taskc}}
2013-08-15 13:33:21 -04:00
% stores the total low and high until reset
\newcounter{tasktmin}
\newcounter{tasktmax}
% added to after reset; all-encompassing time interval
\newcounter{taskamin}
\newcounter{taskamax}
2013-08-29 13:03:27 -04:00
% all-encompassing overlap interval
\newcounter{taskaomin}
\newcounter{taskaomax}
2013-08-14 15:32:46 -04:00
\newcounter{subtaskc}[taskc]
\setcounter{subtaskc}{0}
\renewcommand\thesubtaskc{%
\thetaskc\thesubtaskc@part
}
\def\thesubtaskc@part{%
\expandafter\ifnum\value{subtaskc}>0
-\alph{subtaskc}%
\fi
}
\newlength\taskspace
\newenvironment{task}[1][]%
{%
\goodbreak
2013-08-14 15:32:46 -04:00
\setlength\taskspace{2ex}%
\refstepcounter{taskc}%
\vspace{-0.5\parskip}%
2013-08-15 12:04:54 -04:00
\textcolor{taskrulecolor}{%
2013-08-15 14:12:39 -04:00
\leavevmode\llap{\rule{\marginparwidth}{1pt}}%
\rule{\textwidth}{1pt}%
2013-08-15 12:04:54 -04:00
}%
\vspace{-0.5\baselineskip}%
2013-08-14 15:32:46 -04:00
\begin{@task}[#1]%
}%
{%
\end{@task}%
\vspace{-0.85\baselineskip}%
2013-08-15 12:04:54 -04:00
\textcolor{taskrulecolor}{%
2013-08-15 14:12:39 -04:00
\leavevmode\llap{\rule{\marginparwidth}{2pt}}%
\rule{\textwidth}{2pt}%
2013-08-15 12:04:54 -04:00
}%
\ignorespaces
}
2013-08-14 15:32:46 -04:00
\newenvironment{subtask}[1][]%
{%
\goodbreak
2013-08-14 15:32:46 -04:00
\list{}{%
\leftmargin4ex
\item\relax
}%
\setlength\taskspace{6ex}%
\refstepcounter{subtaskc}%
\begin{@task}[#1]%
}%
{%
\end{@task}%
\endlist
\ignorespaces
}
\newlength\@@subtaskcl
\newcount\@@hmin \newcount\@@hmax \newcount\@@hdiff
\newcount\@@hconf \newcount\@@hvari
2013-08-14 15:32:46 -04:00
\newenvironment{@task}[1][]%
{%
\def\@@h{#1}%
\goodbreak\leavevmode\@margin@sig
2013-08-29 13:03:27 -04:00
% enable overlap command
\let\overlap\@task@overlap
2013-08-30 16:10:55 -04:00
\let\complete\@task@complete
2013-08-29 13:03:27 -04:00
% typeset
2013-08-14 15:32:46 -04:00
\llap{%
\raisebox{-1.8\baselineskip}[0em][0em]{%
2013-08-14 15:32:46 -04:00
\shortstack{%
{\sc\taskname}\space\thesubtaskc
\\
\vphantom{M}%
\ifx\@@h\empty\else
\ifshowtasktime
{\small\@task@h#1||\,h}%
\fi
2013-08-14 15:32:46 -04:00
\fi%
\\
\vphantom{M}%
\ifx\@@h\empty\else
\@task@setregs#1||%
\ifshowtasktime
{\scriptsize \the\@@hconf\% Confidence}%
\fi
2013-08-15 13:33:21 -04:00
% advance the total counters
2013-08-30 16:10:55 -04:00
\addtocounter{tasktmin}{\@@hmin}%
\addtocounter{tasktmax}{\@@hmax}%
\fi%
2013-08-14 15:32:46 -04:00
}%
\hspace{\the\taskspace}%
% adjust width of the subtask text so that the task number lines up
\settowidth\@@subtaskcl{\thesubtaskc@part}%
\hspace{-\the\@@subtaskcl}%
}%
}%
\ignorespaces
}%
{\goodbreak\ignorespaces}
\def\@task@h#1-#2||{%
#1%
\ifnum#1=#2\else
--#2%
\fi
}
2013-08-29 13:03:27 -04:00
\def\@task@overlap#1{%
\def\@@hoverlap{#1}%
\@task@setregs#1||%
\addtocounter{taskaomin}{\@@hmin}%
\addtocounter{taskaomax}{\@@hmax}%
}
2013-08-30 16:10:55 -04:00
\def\@task@complete#1{%
\ifx\@@h\empty\else
\expandafter\@task@setregs\@@h||%
% undo previous operation
\addtocounter{tasktmin}{-\@@hmin}%
\addtocounter{tasktmax}{-\@@hmax}%
% add exact time
\addtocounter{tasktmin}{#1}%
\addtocounter{tasktmax}{#1}%
\fi
}
\def\@task@setregs#1-#2||{%
\@@hmin#1\relax
\@@hmax#2\relax
% perform calculation (be sure to multiply by 100 before dividing, otherwise
% we lose everything through integer truncation); the calculation is:
% 100 - ((|N-M|/M)*100)
\@@hdiff#2\relax \advance\@@hdiff-#1\relax
\@@hconf\@@hdiff
\multiply\@@hconf by 100\relax
\divide\@@hconf by-\@@hmax
\advance\@@hconf by 100\relax
}
2013-08-15 13:33:21 -04:00
% for variability
\def\@task@setregs@vari#1-#2||{%
\@@hmin#1\relax
\@@hmax#2\relax
% ((|N-M|/N)*100)
\@@hdiff#2\relax \advance\@@hdiff-#1\relax
\@@hvari\@@hdiff
\multiply\@@hvari by 100\relax
\divide\@@hvari by \@@hmin
}
2013-08-15 13:33:21 -04:00
\newcommand\tasksummary[1][]{{%
\edef\@@range{\arabic{tasktmin}-\arabic{tasktmax}}%
% determine confidence
\expandafter\@task@setregs\@@range||%
\expandafter\@task@setregs@vari\@@range||%
\ifshowtasktime
\vfill
\subsection{Summary}
\pnumoff
\par {\sc Time Interval:} \expandafter\@task@h\@@range|| Hours%
\par {\sc Confidence:} \the\@@hconf\%%
\par {\sc Variability:} \the\@@hvari\%%
% output any comments, if available
\def\@@comments{#1}%
\ifx\@@comments\empty\else
\par\@@comments
\fi
\pnumrest
\fi
% reset counters
\addtocounter{taskamin}{\value{tasktmin}}%
\addtocounter{taskamax}{\value{tasktmax}}%
\setcounter{tasktmin}{0}%
\setcounter{tasktmax}{0}%
2013-08-15 13:33:21 -04:00
}}
2013-08-28 13:56:10 -04:00
\newwrite\@taskstats
\newcommand\projectsummary{{%
\edef\@@range{\arabic{taskamin}-\arabic{taskamax}}%
% determine confidence
\expandafter\@task@setregs\@@range||%
\expandafter\@task@setregs@vari\@@range||%
% only output if requested
\ifshowtasktime
\section{Project Summary}
\pnumoff
\par {\sc Non-Overlapping Time Interval:}%
\space\expandafter\@task@h\@@range|| Man Hours%
\par {\sc Confidence:} \the\@@hconf\%%
\par {\sc Variability:} \the\@@hvari\%%
\pnumrest
\fi
% calculate median
\newcount\@@med
\advance\@@med \value{taskamin}%
\advance\@@med \value{taskamax}%
\divide\@@med by 2\relax
% calculate non-overlap
\newcount\@@nomin \newcount\@@nomax
\advance\@@nomin \value{taskamin}%
\advance\@@nomax \value{taskamax}%
\advance\@@nomin -\value{taskaomin}%
\advance\@@nomax -\value{taskaomax}%
% calculate overlap median
\newcount\@@omed
\advance\@@omed\@@nomin
\advance\@@omed\@@nomax
\divide\@@omed by 2\relax
% write task stats to file (can be used for reporting by building consecutive
% versions, concatenating the data, taking the last row for each date and
% plotting, for example)
\immediate\openout\@taskstats=taskstats.dat
\immediate\write\@taskstats{min max med omin omax omed cp vp}%
\immediate\write\@taskstats{%
\arabic{taskamin} \arabic{taskamax} \the\@@med
\space\the\@@nomin \space \the\@@nomax \space\the\@@omed
\space\the\@@hconf \space\the\@@hvari
}%
\immediate\closeout\@taskstats
% reset counters
\setcounter{taskamin}{0}\setcounter{taskamax}{0}%
\setcounter{taskaomin}{0}\setcounter{taskaomax}{0}%
}}