779
779
throw new ADEIException(translate("Control interface is not supported by the READER"));
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;
785
if (!$h) $h = new CSVHandler();
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
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)));
792
793
$data = $this->GetFilteredData($grp, $ivl->GetWindowStart(), $ivl->GetWindowEnd(), $filter);
794
795
$columns = sizeof($names);
796
797
$h->Start($columns);
797
$h->DataHeaders($names);
799
foreach ($data as $time => $row) {
800
$h->DataVector($time, $row);
798
$h->DataHeaders($names);
802
$current_time = $ivl->GetWindowStart();
803
$onepercent = ($ivl->GetWindowEnd() - $ivl->GetWindowStart()) / 100;
804
$download = call_user_func_array($dmcb, array($action, ""));
807
foreach ($data as $time => $row) {
808
$h->DataVector($time, $row);
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))) {
819
call_user_func_array($dmcb, array($action, "cancelled"));
829
call_user_func_array($dmcb, array($action, "", $download));
806
function Export(DATAHandler $h = NULL, LOGGROUP $grp = NULL, MASK $mask = NULL, INTERVAL $ivl = NULL, $resample = 0, $opts = 0) {
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());
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);
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);