1
0
Fork 0
lvspec/task.sty

203 lines
4.8 KiB
TeX

% Task environment
\RequirePackage[usenames,dvipsnames]{xcolor}
\newcommand\taskname{Requisite}
% Tango Icon Theme Aluminum
\definecolor{taskrulecolor}{HTML}{2e3436}
\newcounter{taskc}
\setcounter{taskc}{0}
\renewcommand\thetaskc{\Roman{taskc}}
% stores the total low and high until reset
\newcounter{tasktmin}
\newcounter{tasktmax}
% added to after reset; all-encompassing time interval
\newcounter{taskamin}
\newcounter{taskamax}
\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
\setlength\taskspace{2ex}%
\refstepcounter{taskc}%
\vspace{-0.5\parskip}%
\textcolor{taskrulecolor}{%
\leavevmode\llap{\rule{\marginparwidth}{1pt}}%
\rule{\textwidth}{1pt}%
}%
\vspace{-0.5\baselineskip}%
\begin{@task}[#1]%
}%
{%
\end{@task}%
\vspace{-0.85\baselineskip}%
\textcolor{taskrulecolor}{%
\leavevmode\llap{\rule{\marginparwidth}{2pt}}%
\rule{\textwidth}{2pt}%
}%
\ignorespaces
}
\newenvironment{subtask}[1][]%
{%
\goodbreak
\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
\newenvironment{@task}[1][]%
{%
\def\@@h{#1}%
\goodbreak\leavevmode\@margin@sig
\llap{%
\raisebox{-1.8\baselineskip}[0em][0em]{%
\shortstack{%
{\sc\taskname}\space\thesubtaskc
\\
\vphantom{M}%
\ifx\@@h\empty\else
{\small\@task@h#1||\,h}%
\fi%
\\
\vphantom{M}%
\ifx\@@h\empty\else
\@task@setregs#1||%
{\scriptsize \the\@@hconf\% Confidence}%
% advance the total counters
\addtocounter{tasktmin}{\@@hmin}
\addtocounter{tasktmax}{\@@hmax}
\fi%
}%
\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
}
\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
}
% 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
}
\newcommand\tasksummary[1][]{{%
\vfill
\subsection{Summary}
\pnumoff
\edef\@@range{\arabic{tasktmin}-\arabic{tasktmax}}%
\par {\sc Time Interval:} \expandafter\@task@h\@@range|| Hours%
% determine confidence
\expandafter\@task@setregs\@@range||%
\expandafter\@task@setregs@vari\@@range||%
\par {\sc Confidence:} \the\@@hconf\%%
\par {\sc Variability:} \the\@@hvari\%%
% reset counters
\addtocounter{taskamin}{\value{tasktmin}}%
\addtocounter{taskamax}{\value{tasktmax}}%
\setcounter{tasktmin}{0}%
\setcounter{tasktmax}{0}%
% output any comments, if available
\def\@@comments{#1}%
\ifx\@@comments\empty\else
\par\@@comments
\fi
\pnumrest
}}
\newwrite\@taskstats
\newcommand\projectsummary{{%
\section{Project Summary}
\pnumoff
\edef\@@range{\arabic{taskamin}-\arabic{taskamax}}%
\par {\sc Non-Overlapping Time Interval:}%
\space\expandafter\@task@h\@@range|| Man Hours%
% determine confidence
\expandafter\@task@setregs\@@range||%
\expandafter\@task@setregs@vari\@@range||%
\par {\sc Confidence:} \the\@@hconf\%%
\par {\sc Variability:} \the\@@hvari\%%
% calculate median
\newcount\@@med
\advance\@@med \value{taskamin}%
\advance\@@med \value{taskamax}%
\divide\@@med 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 cp vp}%
\immediate\write\@taskstats{%
\arabic{taskamin} \arabic{taskamax} \the\@@med
\space\the\@@hconf \space\the\@@hvari
}%
\immediate\closeout\@taskstats
% reset counters
\setcounter{taskamin}{0}%
\setcounter{taskamax}{0}%
\pnumrest
}}