/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to classes/reader.php

  • Committer: Suren A. Chilingaryan
  • Date: 2011-03-15 02:47:05 UTC
  • mfrom: (210.1.3 adei)
  • Revision ID: csa@dside.dyndns.org-20110315024705-qljn30gwin8yrkne
Integration of work of students with fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
779
779
    throw new ADEIException(translate("Control interface is not supported by the READER"));
780
780
 }
781
781
 
782
 
 protected function ExportData(DATAHandler $h = NULL, LOGGROUP $grp, MASK $mask, INTERVAL $ivl = NULL, $resample = 0, array &$names, $opts = 0) {
783
 
    global $DEFAULT_MISSING_VALUE;
784
 
 
785
 
    if (!$h) $h = new CSVHandler();
786
 
 
 
782
 protected function ExportData(DATAHandler $h = NULL, LOGGROUP $grp, MASK $mask, INTERVAL $ivl = NULL, $resample = 0, array &$names, $opts = 0, $dmcb = NULL) {
 
783
    global $DEFAULT_MISSING_VALUE;  
 
784
    $dm = new DOWNLOADMANAGER();
 
785
    $dm->Logit("Callback -- $dmcb");
 
786
    if (!$h) $h = new CSVHandler();    
 
787
    
787
788
    $filter = $this->CreateDataFilter($grp, $mask, $resample, $ivl->GetItemLimit());
788
789
    if (!$h->nullwriter) {
789
790
        $filter->AddFilter(new NULLCorrector($this->GetGroupOption($grp, "null_value", $DEFAULT_MISSING_VALUE)));
790
791
    }
791
 
    
 
792
   
792
793
    $data = $this->GetFilteredData($grp, $ivl->GetWindowStart(), $ivl->GetWindowEnd(), $filter);
793
794
 
794
795
    $columns = sizeof($names);
795
796
    
796
797
    $h->Start($columns);
797
 
    $h->DataHeaders($names);
798
 
 
799
 
    foreach ($data as $time => $row) {
800
 
        $h->DataVector($time, $row);
801
 
    }
802
 
    
 
798
    $h->DataHeaders($names);    
 
799
    
 
800
    if($dmcb != NULL) {
 
801
      $action = "start";
 
802
      $current_time = $ivl->GetWindowStart();        
 
803
      $onepercent = ($ivl->GetWindowEnd() - $ivl->GetWindowStart()) / 100;
 
804
      $download = call_user_func_array($dmcb, array($action, ""));      
 
805
    }      
 
806
    
 
807
    foreach ($data as $time => $row) {  
 
808
      $h->DataVector($time, $row);     
 
809
      if($dmcb != NULL) {
 
810
        $action = "progress";
 
811
        $thisupdate = time();
 
812
        $updateinterval = $thisupdate - $lastupdate;
 
813
        if($time >= $current_time + $onepercent && $updateinterval >= 2) {                  
 
814
          $current_time = $time;
 
815
          $lastupdate = time();
 
816
          $prog = round(($time - $ivl->GetWindowStart()) / $onepercent, 0);     
 
817
          if(!call_user_func_array($dmcb, array($action, $prog, $download))) {
 
818
            $action = "finish";
 
819
            call_user_func_array($dmcb, array($action, "cancelled"));
 
820
            unset($dmcb);
 
821
            break;
 
822
          }
 
823
        }
 
824
      }
 
825
    }     
 
826
    
 
827
    if($dmcb != NULL){
 
828
      $action = "finish";      
 
829
      call_user_func_array($dmcb, array($action, "", $download));       
 
830
    }    
 
831
  
803
832
    $h->End();
 
833
    
804
834
 }
805
 
 
806
 
 function Export(DATAHandler $h = NULL, LOGGROUP $grp = NULL, MASK $mask = NULL, INTERVAL $ivl = NULL, $resample = 0, $opts = 0) {
 
835
 
 
836
 
 
837
 
 
838
 function Export(DATAHandler $h = NULL, LOGGROUP $grp = NULL, MASK $mask = NULL, INTERVAL $ivl = NULL, $resample = 0, $opts = 0, $dmcb = NULL) {
807
839
    $grp = $this->CheckGroup($grp);
808
840
    if (!$mask) $mask = $this->CreateMask($grp, $minfo = array());
809
 
 
 
841
   
810
842
    $names = $this->GetItemList($grp, $mask);
811
 
    return $this->ExportData($h, $grp, $mask, $ivl, $resample, $names, $opts);
 
843
    return $this->ExportData($h, $grp, $mask, $ivl, $resample, $names, $opts, $dmcb);
812
844
 
813
845
 }
814
846
 
815
847
 function ExportCSV(STRINGHandler $h = NULL, LOGGROUP $grp = NULL, MASK $mask = NULL, INTERVAL $ivl = NULL, $resample = 0, $opts = 0) {
816
848
    return $this->Export(new CSVHandler($h), $grp, $msk, $ivl, $resample, $opts);
817
849
 }
 
850
 
818
851
}
819
852
 
820
853
 
926
959
}
927
960
 
928
961
require($ADEI_ROOTDIR . "/classes/readers/dbreader.php");
929
 
 
 
962
require($ADEI_ROOTDIR . "/classes/download.php");
930
963
?>
 
 
b'\\ No newline at end of file'