summaryrefslogtreecommitdiff
path: root/js/Misc/HYSTHERESIS.js
blob: 01e90b54af46272dd3eac39a2b800e65410720f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* autogenerated from "macros/Misc/HYSTHERESIS.sci" */
function HYSTHERESIS() {
    HYSTHERESIS.prototype.define = function HYSTHERESIS() {
        var in1 = 1;
        var ipar = [0];
        this.nzz = 2;
        var rpar = [[1],[0],[1],[0]];
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["hystheresis"]), new ScilabDouble([4]));
        this.model.in = new ScilabDouble([in1]);
        this.model.out = new ScilabDouble([1]);
        this.model.rpar = new ScilabDouble(rpar);
        this.model.nzcross = new ScilabDouble([this.nzz]);
        this.model.nmode = new ScilabDouble([1]);
        this.model.blocktype = new ScilabString(["c"]);
        this.model.dep_ut = new ScilabBoolean([true,false]);
        var exprs = [[string(rpar)],[string(sign(this.nzz))]];
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"HYSTHERESIS\",sz(1),sz(2));"]);
        this.x = new standard_define(new ScilabDouble([2,2]),this.model,new ScilabDouble(exprs),gr_i);
        return new BasicBlock(this.x);
    }
    HYSTHERESIS.prototype.details = function HYSTHERESIS() {
        return this.x;
    }
    HYSTHERESIS.prototype.get = function HYSTHERESIS() {
        var exprs = this.graphics.exprs;
        this.set_param_popup_title = "Set parameters";
        var options = {
            high_lim:["switch on at",this.high_lim],
            low_lim:["switch off at",this.low_lim],
            out_high:["output when on",this.out_high],
            out_low:["output when off",this.out_low],
            nzz:["use zero crossing: yes (1), no (0)",this.nzz],
        }
        return options;
    }
    HYSTHERESIS.prototype.set = function HYSTHERESIS() {
        var exprs = this.graphics.exprs;
        while (true) {
            var ok = true;
            this.high_lim = arguments[0]["high_lim"];
            this.low_lim = arguments[0]["low_lim"];
            this.out_high = arguments[0]["out_high"];
            this.out_low = arguments[0]["out_low"];
            this.nzz = parseFloat(arguments[0]["nzz"]);
            var exprs = [arguments[0]["high_lim"], arguments[0]["low_lim"], arguments[0]["out_high"], arguments[0]["out_low"], arguments[0]["nzz"]];
            if (!ok) {
                break;
            }
            if (this.low_lim>this.high_lim) {
                message("switch on value must be larger than switch off value");
                throw "user error";
            } else {
                this.graphics.exprs = new ScilabDouble([exprs]);
                this.model.rpar = new ScilabDouble(transpose([this.high_lim,this.low_lim,this.out_high,this.out_low]));
                if (this.nzz>0) {
                    this.nzz = 2;
                }
                this.model.nzcross = new ScilabDouble([this.nzz]);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
    HYSTHERESIS.prototype.get_popup_title = function HYSTHERESIS() {
        return this.set_param_popup_title;
    }
    HYSTHERESIS.prototype.importset = function HYSTHERESIS() {
        var graphics = this.x.graphics;
        var ary = getData(graphics.exprs);
        this.high_lim = ary[0];
        this.low_lim = ary[1];
        this.out_high = ary[2];
        this.out_low = ary[3];
        this.nzz = ary[4];
    }
    HYSTHERESIS.prototype.getContainer = function HYSTHERESIS() { return new BasicBlock(this.x); }
}