home *** CD-ROM | disk | FTP | other *** search
/ Lighthouse Design Suite / LIGHTHOUSE.mdf / Quantrix_1.2 / Application / FilterServicer.service / mp2tm < prev    next >
Text File  |  1993-09-02  |  5KB  |  211 lines

  1. #
  2. #  mp2tm 
  3. #
  4. #  This file when used as input to perl will take a file in the PXF file 
  5. #  format from MacProject and translate it into a TaskMaster project file.
  6. #
  7. #  Copyright (C) 1993 Lighthouse Design Ltd.
  8. #
  9. #  You may freely copy, distribute, and reuse the code in
  10. #  this example provided this copyright legend and disclaimer
  11. #  are preserved in all copies and derivative work.
  12. #
  13. #  Lighthouse Design disclaims any warranty of any kind,
  14. #  expressed or implied, as to this code's fitness
  15. #  for any particular use.
  16. #
  17.  
  18. if($ARGV[0] eq "-t"){
  19.     require "writetm.pl";
  20.     foreach $file (@ARGV) {
  21.     print "Trying $file...\n";
  22.     if (! open(TEXTFILE,"< $file")) {
  23.         printf(STDERR "$file not readable. Skipping $file\n");
  24.         next;
  25.     }
  26.         
  27.     $dirName = ".";
  28.     if ($file =~ /\//) {
  29.         $dirName = $file;
  30.         $dirName =~ s/\/[^\/]$//;
  31.     }
  32.  
  33.     $tmFilename = "/tmp/TEST.taskmaster";
  34.     $interfaceFilename = "";
  35.  
  36.     &doFile();
  37.     close(TEXTFILE);
  38.     }                   
  39. }else{                
  40.     require "$ARGV[2]/writetm.pl";
  41.     if (!open(TEXTFILE,"< $ARGV[0]")) {
  42.     printf(STDERR "$ARGV[0] not readable. Skipping $ARGV[0]\n");
  43.     exit 0;
  44.     }
  45.  
  46.     $tmFilename = $ARGV[1];
  47.     $interfaceFilename = "$ARGV[2]/ObjectArchive.tmoa";
  48.     
  49.     &doFile();
  50.     close(TEXTFILE);
  51. }
  52.  
  53.  
  54. sub doFile  {
  55.  
  56.     $inMacProject = 0;
  57.     $lineNumber = 1;
  58.     $inTasks = 0;
  59.     $inResources = 0;
  60.     $inDependencies = 0;
  61.     $inAssignments = 0;
  62.     $skipNextRow = 0;
  63.     $taskCounter = 1;
  64.     $resourceCounter = 3;
  65.     $dependencyCounter = 0;
  66.     $assignmentCounter = 0;
  67.  
  68.     select((select(STDERR), $| = 1)[0]);
  69.     $| = 1;
  70.  
  71.     while ($separator ne "\015" && $separator ne "\012"){
  72.     if(!read(TEXTFILE, $separator, 1)){
  73.         print STDERR "\n\n";
  74.         print "Couldn't find line separator.\n\n";
  75.         exit 0;
  76.     }
  77.     }
  78.     $/ = $separator;
  79.     while(<TEXTFILE>){
  80.  
  81.     $skipNextRow == 1 && do {
  82.         $skipNextRow = 0;
  83.         next;
  84.     };
  85.  
  86.     /^Project Table\t([0-9]+)\t([0-9]+)/ && !$inTasks  && do{
  87.         $inTasks = 1;
  88.         $numTasks = 0;
  89.         $numColumns = $1;
  90.         $skipNextRow = 1;
  91.         print "Tasks...\n\n" unless $silent;
  92.         next;
  93.     };
  94.  
  95.     /^Resource Table\t([0-9]+)\t([0-9]+)/ && !$inResources  && do{
  96.         $inTasks = 0;
  97.         $inResources = 1;
  98.         $numColumns = $1;
  99.         $skipNextRow = 1;
  100.         print "Resources...\n\n" unless $silent;
  101.         next;
  102.     };
  103.  
  104.     /^Dependency Table\t([0-9]+)\t([0-9]+)/ && !$inDependencies  && do{
  105.         $inResources = 0;
  106.         $inDependencies = 1;
  107.         $numColumns = $1;
  108.         $skipNextRow = 1;
  109.         print "Dependencies...\n\n" unless $silent;
  110.         next;
  111.     };
  112.  
  113.     /^Allocation Table\t([0-9]+)\t([0-9]+)/ && !$inAssignments  && do{
  114.         $inDependencies = 0;
  115.         $inAssignments = 1;
  116.         $numColumns = $1;
  117.         $skipNextRow = 1;
  118.         print "Assignments...\n\n" unless $silent;
  119.         next;
  120.     };
  121.  
  122.     /^Calendars/ && $inAssignments && do {
  123.         $inAssignments = 0;
  124.         $inCalendars = 1;
  125.         $skipNextRow = 1;
  126.         print "Calendars...\n\n" unless $silent;
  127.         next;
  128.     };
  129.  
  130.  
  131.  
  132.     if($inTasks){
  133.         @currentRow = split(/\t\t/);
  134.         if($currentRow[35] eq "Outline Summary"){
  135.         $currentRow[35] = "Group";
  136.         }else{
  137.         $currentRow[35] = "Task";
  138.         }
  139.         if($currentRow[42]){
  140.         if($currentRow[42] eq "Start On"){
  141.             $constraint = "StartOn";
  142.         }elsif($currentRow[42] eq "Start No Earlier Than"){
  143.             $constraint = "StartEarliestAfter";
  144.         }elsif($currentRow[42] eq "Start No Later Than"){
  145.             $constraint = "StartOn";
  146.         }elsif($currentRow[42] eq "Early Start"){
  147.             $constraint = "Earliest";
  148.         }
  149.         $constraintDate = $currentRow[6];
  150.         }elsif($currentRow[43]){
  151.         if($currentRow[43] eq "Finish On"){
  152.             $constraint = "EndOn";
  153.         }elsif($currentRow[43] eq "Finish No Earlier Than"){
  154.             $constraint = "EndOn";
  155.         }elsif($currentRow[43] eq "Finish No Later Than"){
  156.             $constraint = "EndEarliestBefore";
  157.         }elsif($currentRow[43] eq "Late Finish"){
  158.             $constraint = "Latest";
  159.         }
  160.         $constraintDate = $currentRow[7];
  161.         }else{
  162.         $constraint = "Earliest";
  163.         $constraintDate = "1/1/1970 0:00:00";
  164.         }
  165.         &addTask($currentRow[3], $currentRow[0], $currentRow[35], $currentRow[5], $currentRow[22], $currentRow[12], $constraint, $constraintDate, $currentRow[25], $currentRow[38]-99, $curretRow[40], $currentRow[1]);
  166.     };
  167.  
  168.     if($inResources){
  169.         @currentRow = split(/\t\t/);
  170.         &addResource($currentRow[0], $currentRow[0], $currentRow[2], $currentRow[1], 0, $currentRow[3]);
  171.     };
  172.  
  173.     if($inDependencies){
  174.         @currentRow = split(/\t\t/);
  175.         &addDependency($currentRow[1], $currentRow[3]);
  176.     };
  177.     
  178.     if($inAssignments){
  179.         @currentRow = split(/\t\t/);
  180.         &addAssignment($currentRow[2], $currentRow[5], $currentRow[6], $currentRow[7], $currentRow[8]/100.0);
  181.     };
  182.  
  183.     if($inCalendars){
  184.         @currentRow = split(/\t/);
  185.         if ($currentRow[0] eq "\n"){
  186.         next;
  187.         }
  188.         $index = 0;
  189.         for($ct = 1; $ct <= 19; $ct += 3){
  190.         if($currentRow[$ct] eq "True"){
  191.             $hours[$index] = $currentRow[$ct+1];
  192.         }
  193.         $index++;
  194.         }
  195.         @holidays = ();
  196.         for($ct = 22; $ct < $#currentRow; $ct++){
  197.         if($currentRow[$ct]){
  198.             push(@holidays, $currentRow[$ct]);
  199.         }
  200.         }
  201.         &addCalendar($currentRow[0], $hours[0], $hours[1], $hours[2], $hours[3], $hours[4], $hours[5], $hours[6], @holidays);
  202.         if($currentRow[0] eq "Default Calendar"){
  203.         &setDefaultCalendar($currentRow[0]);
  204.         }
  205.     }
  206.     next;
  207.     };
  208.  
  209.     &outputToFile($tmFilename, $interfaceFilename);
  210. }
  211.