Tuesday, December 16, 2014

Gantt - mgmt tool

Gantt chart is a type of bar chart, developed by Henry Gantt in the 1910s, that illustrates a project schedule. Gantt charts illustrate the start and finish dates of the terminal elements and summary elements of a project. Terminal elements and summary elements comprise the work breakdown structure of the project.




Here is some code to play with:

[code]
rem n - number of steps including start and stopping points.
READ N
DATA 7

rem get data
DIM J$(N), L(N), S(N)
FOR J = 1 TO N
    READ J$(J), L(J), S(J)
NEXT J

rem process, length ,start time
rem start
DATA Begin,1,0 

rem processes
DATA Shop,12,1
DATA Prep,6,14
DATA Salad,7,14
DATA Cook,8,19
DATA Serve,2,27

rem stop
DATA End,0,29

rem report
CLS
PRINT
PRINT
PRINT TAB(30); "Time (in minutes)"
PRINT "Job"; TAB(11); "0         50       100       150       200"
PRINT "   "; TAB(11); "+----+----+----+----+----+----+----+----+"
FOR J = 2 TO N - 1
    PRINT J$(J); TAB(11); "|";
    FOR K = S(J) TO (S(J) + L(J) - 1)
        PRINT TAB(11 + K); "X";
    NEXT K
    PRINT
NEXT J
PRINT
PRINT
PRINT "Legend: XXX planned"
END
[/code]



The I tried to convert it to bash sort of staying close to the original code.
you need two data files and then the code:

numfile:
7

ganttdata:
Begin 1 10
Shop 12 1
Prep 6 14
Salad 7 14
Cook 8 19
Serve 2 27
End 0 29

[code]

# number of steps including start and stopping points.
datafile="ganttdata"
numfile="numberfile"
read items < $numfile
#---------------
ils="%"
let j=1
# get data
let items=$items+1
echo "Raw data"
while [ $j -lt $items ]
do
    let j=$j+1
    read job[$j] length[$j] starttime[$j]
    echo ${job[$j]} ${length[$j]} ${starttime[$j]}
done < $datafile
# report
#clear
echo
echo "Gantt report"
echo
echo -e "\t\tTime in (minutes)"
echo -e "Job\t0         50       100       150       200"
echo -e "\t+----+----+----+----+----+----+----+----+"
let j=2
let items=$items-1
while [ $j -lt $items ] 
do
    let j=j+1
    zstring=""
    for ((x=1; x <= ${length[$j]}; x++)); do
        zstring=$zstring"x"
    done
    ystring=""
    for ((x=2; x <= ${starttime[$j]}; x++)); do
        ystring=$ystring" "
    done
    printf "${job[$j]}\t|$ystring$zstring";
    echo
done
echo
echo "Legend: XXX planned"

[/code]

No comments:

Post a Comment