/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to classes/resampler.php

  • Committer: Suren A. Chilingaryan
  • Date: 2020-02-06 06:07:51 UTC
  • Revision ID: csa@suren.me-20200206060751-n4lbi25y4wh10f3u
Generalize data filtering/resampling in the VIEWs and provide common tools for secondary time series plots (based on work of Jalal)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
interface RESAMPLERInterface {
 
4
 function Resample($data, $flags = 0);
 
5
};
 
6
 
 
7
abstract class RESAMPLER implements RESAMPLERInterface {
 
8
  var $options;
 
9
  
 
10
  function __construct(REQUEST $req  = NULL, array $options = NULL , $sampling = false) {
 
11
    $this->options = $options?$options:array();
 
12
  }
 
13
 
 
14
 function GetOption($opt, $default = false) {
 
15
    if (isset($this->options[$opt])) return $this->options[$opt];
 
16
    return $default;
 
17
 }
 
18
 
 
19
  function GetNumberOfChannels($data) {
 
20
        // We can compute later
 
21
    return $data['info']['n_channels'];
 
22
  }
 
23
 
 
24
  static function IsApplicable($sampling = false) {
 
25
    if ($sampling) 
 
26
        return false;
 
27
 
 
28
    return true;
 
29
  }
 
30
 
 
31
  static function GetResampler(REQUEST $req  = NULL, $resampler, $sampling = false) {
 
32
    global $ADEI_RESAMPLERS;
 
33
 
 
34
    $cfg = $ADEI_RESAMPLERS[$resampler];
 
35
    if (!$cfg) throw new ADEIException(translate("Unsupported resampler (%s) is configured", $resampler));
 
36
 
 
37
    ADEI::RequireClass("resamplers/" . strtolower($cfg['handler']), true);
 
38
    $r = new $cfg['handler']($req, $cfg['opts'], $sampling);
 
39
    return $r;
 
40
 }
 
41
 
 
42
 static function GetSelectList($sampling = false) {
 
43
    global $ADEI;
 
44
    global $ADEI_RESAMPLERS;
 
45
 
 
46
    $res = array();
 
47
    foreach ($ADEI_RESAMPLERS as $name => $cfg) {
 
48
        ADEI::RequireClass("resamplers/" . strtolower($cfg['handler']), true);
 
49
 
 
50
        if ($cfg['handler']::IsApplicable($sampling)) {
 
51
            array_push($res, array(
 
52
                'value' => $name,
 
53
                'label' => $cfg['title'],
 
54
            ));
 
55
        }
 
56
    }
 
57
    return $res;
 
58
  }
 
59
 
 
60
/*
 
61
  static function GetMethods() {
 
62
    global $ADEI_RESAMPLERS;
 
63
 
 
64
    $root = ADEI::GetRootDir();
 
65
    $setup = ADEI::GetSetupDir();
 
66
 
 
67
    $names = array_merge(glob("$setup/classes/resamplers/*.php"), glob("$root/classes/resamplers/*.php"));
 
68
    foreach ($names as &$name) {
 
69
        $name = basename($name, ".php");
 
70
    }
 
71
    $names = array_uniq($names);
 
72
 
 
73
    foreach $names as $name {
 
74
        ADEI::RequireClass("resamplers/$name");
 
75
    }
 
76
*/
 
77
}
 
78
 
 
79
?>
 
 
b'\\ No newline at end of file'