summaryrefslogtreecommitdiff
path: root/Origin/tools/scilab/windows/macros/post_xcos_simulate.sci
blob: c29807011d9b0123c2ebf9c9ae57d2c07cc31f71 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
//
//

function []=post_xcos_simulate(%cpr, scs_m, needcompile)
    global port_com port_TCL;

    callXcos_Param_Var=%f //Définit s'il faut appeler la fonction de variation paramètrique
    callXcos_Param_Freq = %f;
    callRep_freq = %f;   // Lance la fonction de tracés des réponses fréquentielles.
    presence_param_var=%f // indique la présence d'un bloc param_var
    presence_rep_freq=%f  //idem pour rep freq
    presence_imprimante=%f  //indique la presence d'un bloc imprimante
    presence_bloc_end=%f    //indique la presence d'un bloc END (pour faire une reponse temporelle)
    presence_scope=%f   //indique la presence d'un bloc scope personnalisé
    presence_rep_temp=%f   //indique la presence d'un bloc pour faire une reponse temporelle
    presence_irep_temp=%f   //indique la presence d'un bloc pour faire une reponse temporelle IREP TEMP
    presence_arduino=%f   //indique la presence d'un bloc pour faire une reponse temporelle ARDUINO

    for i = 1:size(scs_m.objs)
        curObj= scs_m.objs(i);
        if (typeof(curObj) == "Block" & curObj.gui == "PARAM_VAR")
            presence_param_var=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "REP_FREQ")
            presence_rep_freq=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "IMPRIMANTE")
            disp("ok post")
            presence_imprimante=%t
            values= "P" + ascii(0) + ascii(0)
            writeserial(port_TCL,values);
            sleep(100)
            values= "P" + ascii(0) + ascii(0)
            writeserial(port_TCL,values);
            sleep(100)
            closeserial(port_TCL);
        elseif (typeof(curObj) == "Block" & curObj.gui == "ENDBLK")
            presence_bloc_end=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "REP_TEMP")
            presence_rep_temp=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "SCOPE")
            presence_scope=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "IREP_TEMP") then
            presence_irep_temp=%t
        elseif (typeof(curObj) == "Block" & curObj.gui == "ARDUINO_SETUP") then
            presence_arduino=%t
        end
    end

    if presence_arduino then
        ARDUINO_post_simulate(scs_m)
        return
    end

    if presence_irep_temp then
        SIMM_post_simulate(scs_m)
        return
    end

    if  presence_rep_temp then
        REP_TEMP_post_simulate(scs_m);
    end

    if  presence_param_var & ~presence_rep_freq
        callXcos_Param_Var = %t;
    end

    if  presence_param_var & presence_rep_freq
        callXcos_Param_Freq = %t;
    end

    if ~presence_param_var & presence_rep_freq
        callRep_freq = %t;
    end

    if ~presence_scope & ~presence_rep_freq then
        // On ajuste les scopes
        nicescope()
    end

    if presence_rep_freq & ~presence_param_var
        REP_FREQ_pre_simulate(scs_m, needcompile);
    end

if  presence_imprimante==%t then
    //global inc;
    //PIC_end_of_simul() //deconnexion prealable du port serie au cas où.
end

endfunction