├── .gitignore ├── LICENSE ├── README.md ├── demo-imgs ├── attack_controller.png ├── attack_controller_config.png ├── attack_simulation_result.png ├── benign_simulation_result.png ├── simulator_attack_xmeas.png ├── simulator_attack_xmv.png └── simulator_benign.png ├── demo-instructions.md ├── process_matlab_TEP.py └── temexd_mod ├── Mode1SkogeInit.mat ├── Mode1xInitial.mat ├── Mode_1_Init.m ├── MultiLoop_mode1.mdl ├── MultiLoop_mode1.mdl.original ├── MultiLoop_mode1.mdl.r2014b ├── MultiLoop_mode1.mdl.r2020b ├── R12_ExampleScript.m ├── README.txt ├── TElib.mdl ├── TEplot.m ├── matlab.mat ├── temexd_mod.c ├── temexd_mod.mexa64 ├── temexd_mod.mexw64 ├── teprob_mod.h └── tesys.mdl /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | **/*.mat 3 | **/*.xml 4 | **/*.slxc 5 | **/slprj 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright � 2015 Alexander Isakov. Contact: 2 | Copyright � 2015 Marina Krotofil. Contact: 3 | Copyright � 2015 TUHH-SVA Security in Distributed Applications. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of DVCP-TE nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## TEP Attack Simulator 2 | 3 | This repository contains files to run a manipulated version of the Tennesee Eastman Process (TEP) -- an ICS simulator. 4 | This simulator is heavily based on two prior iterations, which may serve as useful references: 5 | - [Tennesee Eastman MATLAB implementation (2015)](https://depts.washington.edu/control/LARRY/TE/download.html) 6 | - [DVCP-TE (2015)](https://github.com/satejnik/DVCP-TE) 7 | 8 | This simulator contains modifications to the original MATLAB implementation, which allows the user to inject manipulations into the TE process, and observe/record their impacts. 9 | 10 | The outputs of this simulator are used in the paper: "Attributions for ML-based ICS anomaly detection: From theory to practice", 11 | to appear at the 31st Network and Distributed System Security Symposium (NDSS 2024). 12 | 13 | ### Bibtex 14 | 15 | [![DOI](https://zenodo.org/badge/661335861.svg)](https://zenodo.org/badge/latestdoi/661335861) 16 | 17 | ``` 18 | @inproceedings{icsanomaly:ndss2024, 19 | title = {Attributions for {ML}-based {ICS} Anomaly Detection: {From} Theory to Practice}, 20 | author = {Clement Fung and Eric Zeng and Lujo Bauer}, 21 | booktitle = {Proceedings of the 31st Network and Distributed System Security Symposium}, 22 | publisher = {Internet Society}, 23 | year = 2024, 24 | } 25 | ``` 26 | 27 | ### Dependencies 28 | Like the original TEP implementation, our simulator is built in MATLAB Simulink. 29 | For our experiments, we use [MATLAB R2021a](https://www.mathworks.com/products/new_products/release2021a.html). 30 | 31 | ### Step-by-step demo instructions 32 | A full set of instructions, with screenshots, can be found in [the demo instructions](demo-instructions.md). 33 | The final outcomes of the demo are shown below. 34 | 35 | | Benign simulation result | Attack simulation result (manipulating D Feed sensor) | 36 | | --- | --- | 37 | |![image](demo-imgs/benign_simulation_result.png)|![image](demo-imgs/attack_simulation_result.png)| 38 | 39 | ### Access to the complete dataset 40 | As described in our paper, we use the simulator to execute each attack condition (location, magnitude, pattern) in the TE process. 41 | The full set of 286 manipulations can be found here: [https://doi.org/10.1184/R1/23805552](https://doi.org/10.1184/R1/23805552). 42 | -------------------------------------------------------------------------------- /demo-imgs/attack_controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/attack_controller.png -------------------------------------------------------------------------------- /demo-imgs/attack_controller_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/attack_controller_config.png -------------------------------------------------------------------------------- /demo-imgs/attack_simulation_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/attack_simulation_result.png -------------------------------------------------------------------------------- /demo-imgs/benign_simulation_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/benign_simulation_result.png -------------------------------------------------------------------------------- /demo-imgs/simulator_attack_xmeas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/simulator_attack_xmeas.png -------------------------------------------------------------------------------- /demo-imgs/simulator_attack_xmv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/simulator_attack_xmv.png -------------------------------------------------------------------------------- /demo-imgs/simulator_benign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/demo-imgs/simulator_benign.png -------------------------------------------------------------------------------- /demo-instructions.md: -------------------------------------------------------------------------------- 1 | 2 | ### Opening the environment 3 | 1. After cloning this repository, load MATLAB, and set the MATLAB workspace to `temexd_mod`. 4 | 2. Initialize the environment by executing `Mode_1_Init.m`. 5 | 3. Open the Simulink environment: `MultiLoop_mode1.mdl`. 6 | 7 | ### Configuring the environment 8 | The default configuration of the environment will show the system in a benign state. 9 | | Benign Simulator State | 10 | |---| 11 | |![image](demo-imgs/simulator_benign.png)| 12 | 13 | To execute an attack, modify the Simulink arrows such that the inputs or outputs of the `temexd_mod` process pass through one of the attack controllers. 14 | | Attacking sensors | Attacking XMVs (actuators) | 15 | | --- | --- | 16 | |![image](demo-imgs/simulator_attack_xmeas.png)|![image](demo-imgs/simulator_attack_xmv.png)| 17 | 18 | Double click the attack controller to configure how the attack is performed. Our demo uses the `Generic Attack Controller XMeas` to manipulate a sensor value. 19 | To modify which feature is attacked, modify the `Pick Attack Feat`, `Pick !Attack Feat`, and `Maintain Order` modules to select the desired feature from the input. 20 | Since the TE process expects the feature ordering to be the same, when writing the manipulated feature value back to the output, the indices must be re-ordered correctly. 21 | | Configuring attack location | 22 | |---| 23 | |![image](demo-imgs/attack_controller.png)| 24 | 25 | To execute a constant manipulation, double click the `Constant Attack` module. 26 | The start, end and set-point values can be configured within this module. 27 | | Configuring attack value | 28 | |---| 29 | |![image](demo-imgs/attack_controller_config.png)| 30 | 31 | To execute the manipulation, press the Run button in Simulink. 32 | Our experiments were conducted with a Stop Time of 48. 33 | 34 | ### Processing the simulation results 35 | 36 | A plotting module will open when the simulation has completed. 37 | Use the dropdown menu to select different sensors and actuators (MVs). 38 | 39 | | Benign simulation result | Attack simulation result (manipulating D Feed sensor) | 40 | | --- | --- | 41 | |![image](demo-imgs/benign_simulation_result.png)|![image](demo-imgs/attack_simulation_result.png)| 42 | 43 | To save the simulation outputs to a readable format, we use the following Matlab commands to save the simulation sensors and acuators: 44 | ``` 45 | csvwrite('simout_example.csv', simout) 46 | csvwrite('xmv_example.csv', xmv) 47 | ``` 48 | 49 | Each output can be processed with the following [helper script](process_matlab_TEP.py) to create a easily-readable format for ML models. 50 | 51 | -------------------------------------------------------------------------------- /process_matlab_TEP.py: -------------------------------------------------------------------------------- 1 | # What needs to be done: 2 | # 1) Merge each simout and xmv file 3 | # 2) Label the attacks for each time duration 4 | 5 | import numpy as np 6 | import pandas as pd 7 | 8 | ### Setup column names from MATLAB script. First 40 are sensors, last 11 are actuators. 9 | column_names = ['A Feed', 10 | 'D Feed', 11 | 'E Feed', 12 | 'A and C Feed', 13 | 'Recycle Flow', 14 | 'Reactor Feed Rate', 15 | 'Reactor Pressure', 16 | 'Reactor Level', 17 | 'Reactor Temperature', 18 | 'Purge Rate', 19 | 'Product Sep Temp', 20 | 'Product Sep Level', 21 | 'Product Sep Pressure', 22 | 'Product Sep Underflow', 23 | 'Stripper Level', 24 | 'Stripper Pressure', 25 | 'Stripper Underflow', 26 | 'Stripper Temp', 27 | 'Stripper Steam Flow', 28 | 'Compressor Work', 29 | 'Reactor Coolant Temp', 30 | 'Separator Coolant Temp', 31 | 'Comp A to Reactor', 32 | 'Comp B to Reactor', 33 | 'Comp C to Reactor', 34 | 'Comp D to Reactor', 35 | 'Comp E to Reactor', 36 | 'Comp F to Reactor', 37 | 'Comp A in Purge', 38 | 'Comp B in Purge', 39 | 'Comp C in Purge', 40 | 'Comp D in Purge', 41 | 'Comp E in Purge', 42 | 'Comp F in Purge', 43 | 'Comp G in Purge', 44 | 'Comp H in Purge', 45 | 'Comp D in Product', 46 | 'Comp E in Product', 47 | 'Comp F in Product', 48 | 'Comp G in Product', 49 | 'Comp H in Product', 50 | 'D Feed (MV)', 51 | 'E Feed (MV)', 52 | 'A Feed (MV)', 53 | 'A and C Feed (MV)', 54 | 'Recycle (MV)', 55 | 'Purge (MV)', 56 | 'Separator (MV)', 57 | 'Stripper (MV)', 58 | 'Steam (MV)', 59 | 'Reactor Coolant (MV)', 60 | 'Condenser Coolant (MV)', 61 | 'Agitator (MV)'] 62 | 63 | # These attacks did not execute properly in the MATLAB simulator and should be skipped 64 | skip_list = [ 65 | 'cons_p2s_s4', 66 | 'cons_p2s_s9', 67 | 'cons_p2s_a11', 68 | 'cons_p3s_s4', 69 | 'cons_p3s_s9', 70 | 'cons_p3s_a11', 71 | 'cons_p5s_s4', 72 | 'cons_p5s_s9', 73 | 'cons_p5s_a11', 74 | 'cons_p5s_s3', 75 | 'cons_p5s_s17', 76 | 'line_p3s_s9', 77 | 'line_p5s_s9', 78 | 'line_p5s_a11', 79 | ] 80 | 81 | hour = 2000 82 | 83 | ## Process benign dataset 84 | sim_benign = np.loadtxt('simout_benign.csv', delimiter=',') 85 | xmv_benign = np.loadtxt('xmv_benign.csv', delimiter=',') 86 | 87 | Xbenign = np.hstack((sim_benign, xmv_benign)) 88 | df = pd.DataFrame(Xbenign, columns = column_names) 89 | df.to_csv('TEP_train.csv', header=True, index=False) 90 | 91 | ## Add attack column, since we're done with training set 92 | column_names.append('Atk') 93 | 94 | attack_patterns = ['cons', 'csum', 'line'] 95 | attack_types = ['p2s', 'm2s', 'p3s', 'p5s'] 96 | 97 | pid_attack_numbers = ['s1', 's2', 's3', 's4', 's5', 's6', 's7', 's8', 's9', 's10', 's11', 's12', 's13', 's14', 's15', 's16', 's17', 's18', 's19', 's20', 's23', 's25', 's40'] 98 | xmv_attack_numbers = ['a1', 'a2', 'a3', 'a4', 'a6', 'a7', 'a8', 'a10', 'a11'] 99 | 100 | for an in xmv_attack_numbers: 101 | for ap in attack_patterns: 102 | for at in attack_types: 103 | 104 | if f'{ap}_{at}_{an}' in skip_list: 105 | print(f'Skipping invalid attack {ap} {at} {an}!') 106 | continue 107 | 108 | print(f'Processing {ap} {at} {an}') 109 | 110 | ## Process attack 111 | sim_attack = np.loadtxt(f'simout_{ap}_{at}_{an}.csv', delimiter=',') 112 | xmv_attack = np.loadtxt(f'xmv_{ap}_{at}_{an}.csv', delimiter=',') 113 | 114 | Yattack = np.zeros((len(sim_attack), 1)) 115 | Yattack[5*hour : 7*hour] = 1 116 | 117 | Xattack = np.hstack((sim_attack, xmv_attack, Yattack)) 118 | 119 | df1 = pd.DataFrame(Xattack, columns = column_names) 120 | df1.to_csv(f'TEP_test_{ap}_{at}_{an}.csv', header=True, index=False) 121 | 122 | print('Done') 123 | -------------------------------------------------------------------------------- /temexd_mod/Mode1SkogeInit.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/Mode1SkogeInit.mat -------------------------------------------------------------------------------- /temexd_mod/Mode1xInitial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/Mode1xInitial.mat -------------------------------------------------------------------------------- /temexd_mod/Mode_1_Init.m: -------------------------------------------------------------------------------- 1 | % Base case initialization 2 | 3 | u0=[63.053, 53.98, 24.644, 61.302, 22.21, 40.064, 38.10, 46.534, 47.446, 41.106, 18.114, 50]; 4 | 5 | for i=1:12; 6 | iChar=int2str(i); 7 | eval(['xmv',iChar,'_0=u0(',iChar,');']); 8 | end 9 | 10 | Fp_0=100; 11 | 12 | r1_0=0.251/Fp_0; 13 | r2_0=3664/Fp_0; 14 | r3_0=4509/Fp_0; 15 | r4_0=9.35/Fp_0; 16 | r5_0=0.337/Fp_0; 17 | r6_0=25.16/Fp_0; 18 | r7_0=22.95/Fp_0; 19 | 20 | Eadj_0=0; 21 | SP17_0=80.1; 22 | 23 | % Note: The values of xmv_0 and r_0 specified above get overridden 24 | % by the initial conditions specified in the xInitial variable, 25 | % loaded in the following statement. The above statements are 26 | % only needed when starting from a new condition where xInitial 27 | % doesn't apply. 28 | 29 | load Mode1xInitial 30 | 31 | % TS_base is the sampling period of most discrete PI controllers used 32 | % in the simulation. 33 | Ts_base=0.0005; 34 | 35 | % TS_save is the sampling period for saving results. The following 36 | % variables are saved at the end of a run: 37 | % tout - the elapsed time (hrs), length N. 38 | % simout - the TE plant outputs, N by 41 matrix 39 | % OpCost - the instantaneous operating cost, $/hr, length N 40 | % xmv - the TE plant manipulated variables, N by 12 matrix 41 | % idv - the TE plant disturbances, N by 20 matrix 42 | Ts_save=0.0005; 43 | 44 | atk_start = 5; 45 | atk_end = 7; 46 | 47 | ini_lim_xmeas9 = 130.0; 48 | -------------------------------------------------------------------------------- /temexd_mod/R12_ExampleScript.m: -------------------------------------------------------------------------------- 1 | % This script runs the process in open loop. After about 1 hour of 2 | % simulated time, the reactor pressure violates its specified upper limit 3 | % and the simulation shuts down automatically. 4 | % You should see an error message to that effect in the Command window. 5 | % Key variables will still be plotted. 6 | 7 | % NOTE: to illustrate the ability of the new code to use a 8 | % variable-step-size integration method, model tesys.mdl is configured to 9 | % use the ode45 method. 10 | 11 | u0=[63.53, 53.98, 24.644, 61.302, 22.21, ... 12 | 40.064, 38.1, 46.534, 47.446, 41.106, ... 13 | 18.114, 50]; % Base case inputs (XMV variables). 14 | u0(10)=38; % Specifies a step in XMV(10) 15 | u0 = [u0, zeros(1,28)]; % New code requires disturbances as inputs 16 | 17 | 18 | % Set up for integration: 19 | 20 | tspan = [0 5]; % Starting and ending time (hours). 21 | ut = [tspan' [u0;u0] ]; % Specifies constant inputs. 22 | 23 | % Integrate over specified time period: 24 | options = simset('Solver' ,'ode45'); 25 | [tt,xt,yt]=sim('tesys',tspan,options,ut); 26 | 27 | % Plot results: 28 | 29 | figure 30 | subplot(221) 31 | plot(tt,yt(:,6)),title('Reactor Feed'),xlabel('Time (hours)') 32 | subplot(222) 33 | plot(tt,yt(:,7)),title('Reac Pressure'),xlabel('Time (hours)') 34 | subplot(223) 35 | plot(tt,yt(:,8)),title('Reac Level'),xlabel('Time (hours)') 36 | subplot(224) 37 | plot(tt,yt(:,9)),title('Reac Temp'),xlabel('Time (hours)') 38 | 39 | 40 | figure 41 | subplot(221) 42 | plot(tt,yt(:,11)),title('Prod Sep Temp'),xlabel('Time (hours)') 43 | subplot(222) 44 | plot(tt,yt(:,12)),title('Prod Sep Level'),xlabel('Time (hours)') 45 | subplot(223) 46 | plot(tt,yt(:,10)),title('Purge Rate'),xlabel('Time (hours)') 47 | subplot(224) 48 | plot(tt,yt(:,18)),title('Stripper Temp'),xlabel('Time (hours)') 49 | 50 | 51 | -------------------------------------------------------------------------------- /temexd_mod/README.txt: -------------------------------------------------------------------------------- 1 | See end of file for installation and use instructions. 2 | 3 | Contents of this Zip archive: 4 | 5 | ADCHEM15_0010.pdf A paper submitted to ADCHEM 2015 providing details and 6 | describing advantages of the modified code. 7 | 8 | temexd_mod.c C source code for compiling TEMEX mex file. Note that this 9 | version requires the disturbance flags to be input signals, 10 | not parameters. Thus, they can change with time. See 11 | comments at the beginning of the source code for details 12 | of model requirements and options. 13 | 14 | teprob_mod.h C header file needed when compiling. 15 | 16 | temexd_mod.mexw64 Mex file ready for use on a Windows 64-bit system. 17 | It was compiled using the MATLAB mex command with the 18 | Microsoft Visual Studio 2013 c compiler and tested 19 | in MATLAB/Simulink release R2014b. 20 | 21 | R12_Example.m MATLAB test script that runs the plant in an open-loop 22 | manner. 23 | 24 | tesys.mdl Open-loop Simulink model called by R12_ExampleScript.m. 25 | 26 | teplot.m Script that plots the results at the end of some simulations. 27 | 28 | MultiLoop_mode1.mdl Simulink model of the control strategy described in 29 | "Decentralized control of the Tennessee Eastman Challenge 30 | Process", N. L. Ricker, J. Proc. Cont., Vol. 6, No. 4, 31 | pp. 205-221, 1996. It is set up to initialize and run with 32 | constant setpoints at the "Mode 1" operating condition. NOTE: 33 | override loops are not included. 34 | 35 | The .mdl file calls two custom scripts (lines 34 and 35): 36 | 37 | PreLoadFcn "Mode_1_Init" 38 | StopFcn "TEplot" 39 | 40 | These initialize the simulation variables and plot the results 41 | at the end of the run. See the files "Mode_1_Init.m" and 42 | "TEplot.m" for more details. 43 | 44 | MultiLoop_mode3.mdl Similar to MultiLoop_mode1.mdl, but designed to run at 45 | Mode 3 conditions. Includes an additional override 46 | that reduces the recycle valve % open when the 47 | separator coolant valve goes above 90%. If this 48 | is not included, the coolant valve saturates and 49 | the system loses control of reactor level. 50 | 51 | MultiLoop_Skoge_mode1.mdl Similar to above, but uses the control strategy 52 | described in "Self-Optimizing control of a large-scale plant: 53 | the Tennessee Eastman process" Larsson, T., et al., Ind. Eng. 54 | Chem. Res., Vol. 40, pp. 4889-4901, 2001. 55 | 56 | It automatically runs "Skoge_Mode1_Init.m" and "TEplot.m". 57 | 58 | Mode_1_Init.m Script file executed automatically when you run 59 | "MultiLoop_mode1.mdl". 60 | 61 | Mode_3_Init.m Script file executed automatically when you run 62 | "MultiLoop_mode3.mdl". 63 | 64 | Skoge_Mode1_Init.m As above, but for "MultiLoop_Skoge_mode1.mdl". 65 | 66 | Mode1xInitial.mat Contains initial conditions for "MultiLoop_model.mdl". 67 | It is loaded by the script file "Mode_1_Init.m", which is 68 | executed automatically when "MultiLoop_model.mdl" is opened. 69 | 70 | Mode3xInitial.mat Contains initial conditions for "MultiLoop_mode3.mdl". 71 | It is loaded by the script file "Mode_3_Init.m", which is 72 | executed automatically when "MultiLoop_mode3.mdl" is opened. 73 | 74 | Mode1SkogeInit.mat As above, but for "MultiLoop_Skoge_mode1.mdl". 75 | 76 | TElib.mdl A Simulink library containing two controller blocks. These are 77 | used in the two "MultiLoop" simulations. 78 | 79 | 80 | 81 | System Requirements: 82 | 83 | Tested using MATLAB/Simulink release R2014b. Extent of compatibility with 84 | older releases is unknown. 85 | 86 | Installation: 87 | 88 | 1) Unzip the archive into a new directory. 89 | 90 | 2) Start MATLAB and make the above new directory the default. 91 | 92 | 3) If your system is other than a Windows 64-bit machine, you will need to 93 | use the MATLAB mex command to compile the C source code and create a mex file. 94 | See instructions at the beginning of the C source code. In order to run the 95 | simulation examples, the mex function must be named temexd_mod. NOTE: 96 | the code contains ~4000 lines and may take several minutes to compile. 97 | 98 | Testing the code: 99 | 100 | 4) Try running the R12_ExampleScript.m file. This illustrates a situation in 101 | which the plant is running open-loop. The specified simulation time is 5 hours 102 | but at about 1 hour the plant, which is open-loop unstable, exceeds the maximum 103 | reactor pressure and the simulation terminates automatically. Plots show 104 | transients of some key variables. If this works, your installation should 105 | be OK. 106 | 107 | 5) Try running one of the closed-loop models. If you get a "file not found" 108 | or "variable undefined" error from MATLAB, 109 | make sure the initialization scripts described above are on the MATLAB 110 | path. The simplest approach is to put all of the files in a 111 | single directory and make it the MATLAB default directory. 112 | 113 | 114 | Mode_3_Init.m Initial model states needed for the above. 115 | 116 | Mode3xInitial.mat Contains initial conditions for "MultiLoop_mode3.mdl". 117 | It is loaded by the script file "Mode_3_Init.m", which is 118 | executed automatically when the model is opened. 119 | 120 | 121 | -------------------------------------------------------------------------------- /temexd_mod/TElib.mdl: -------------------------------------------------------------------------------- 1 | Library { 2 | Name "TElib" 3 | Version 5.0 4 | SaveDefaultBlockParams on 5 | LibraryLinkDisplay "none" 6 | ShowLoopsOnError on 7 | IgnoreBidirectionalLines off 8 | CovSaveName "covdata" 9 | CovMetricSettings "dw" 10 | CovNameIncrementing off 11 | CovHtmlReporting on 12 | covSaveCumulativeToWorkspaceVar on 13 | CovSaveSingleToWorkspaceVar on 14 | CovCumulativeReport off 15 | BlockNameDataTip off 16 | BlockParametersDataTip off 17 | BlockDescriptionStringDataTip off 18 | ToolBar on 19 | StatusBar on 20 | BrowserShowLibraryLinks off 21 | BrowserLookUnderMasks off 22 | Created "Fri Nov 22 18:25:06 2002" 23 | UpdateHistory "UpdateHistoryNever" 24 | ModifiedByFormat "%" 25 | LastModifiedBy "Administrator" 26 | ModifiedDateFormat "%" 27 | LastModifiedDate "Mon Nov 25 14:53:09 2002" 28 | ModelVersionFormat "1.%" 29 | ConfigurationManager "None" 30 | SimParamPage "Solver" 31 | LinearizationMsg "none" 32 | Profile off 33 | ParamWorkspaceSource "MATLABWorkspace" 34 | ExtModeMexFile "ext_comm" 35 | ExtModeBatchMode off 36 | ExtModeTrigType "manual" 37 | ExtModeTrigMode "normal" 38 | ExtModeTrigPort "1" 39 | ExtModeTrigElement "any" 40 | ExtModeTrigDuration 1000 41 | ExtModeTrigHoldOff 0 42 | ExtModeTrigDelay 0 43 | ExtModeTrigDirection "rising" 44 | ExtModeTrigLevel 0 45 | ExtModeArchiveMode "off" 46 | ExtModeAutoIncOneShot off 47 | ExtModeIncDirWhenArm off 48 | ExtModeAddSuffixToVar off 49 | ExtModeWriteAllDataToWs off 50 | ExtModeArmWhenConnect on 51 | ExtModeSkipDownloadWhenConnect off 52 | ExtModeLogAll on 53 | ExtModeAutoUpdateStatusClock on 54 | SimulationMode "normal" 55 | ConsistencyChecking "none" 56 | ArrayBoundsChecking "none" 57 | AlgebraicLoopMsg "warning" 58 | BlockPriorityViolationMsg "warning" 59 | MinStepSizeMsg "warning" 60 | InheritedTsInSrcMsg "warning" 61 | DiscreteInheritContinuousMsg "warning" 62 | MultiTaskRateTransMsg "error" 63 | SingleTaskRateTransMsg "none" 64 | CheckForMatrixSingularity "none" 65 | IntegerOverflowMsg "warning" 66 | Int32ToFloatConvMsg "warning" 67 | ParameterDowncastMsg "error" 68 | ParameterOverflowMsg "error" 69 | ParameterPrecisionLossMsg "warning" 70 | UnderSpecifiedDataTypeMsg "none" 71 | UnnecessaryDatatypeConvMsg "none" 72 | VectorMatrixConversionMsg "none" 73 | InvalidFcnCallConnMsg "error" 74 | SignalLabelMismatchMsg "none" 75 | UnconnectedInputMsg "warning" 76 | UnconnectedOutputMsg "warning" 77 | UnconnectedLineMsg "warning" 78 | SfunCompatibilityCheckMsg "none" 79 | ProdHWDeviceType "Microprocessor" 80 | ProdHWWordLengths "8,16,32,32" 81 | RTWMakeCommand "make_rtw" 82 | RTWGenerateCodeOnly off 83 | RTWRetainRTWFile off 84 | TLCProfiler off 85 | TLCDebug off 86 | TLCCoverage off 87 | TLCAssertion off 88 | BlockDefaults { 89 | Orientation "right" 90 | ForegroundColor "black" 91 | BackgroundColor "white" 92 | DropShadow off 93 | NamePlacement "normal" 94 | FontName "Helvetica" 95 | FontSize 10 96 | FontWeight "normal" 97 | FontAngle "normal" 98 | ShowName on 99 | } 100 | BlockParameterDefaults { 101 | Block { 102 | BlockType Gain 103 | Gain "1" 104 | Multiplication "Element-wise(K.*u)" 105 | ShowAdditionalParam off 106 | ParameterDataTypeMode "Same as input" 107 | ParameterDataType "sfix(16)" 108 | ParameterScalingMode "Best Precision: Matrix-wise" 109 | ParameterScaling "2^0" 110 | OutDataTypeMode "Same as input" 111 | OutDataType "sfix(16)" 112 | OutScaling "2^0" 113 | LockScale off 114 | RndMeth "Floor" 115 | SaturateOnIntegerOverflow on 116 | } 117 | Block { 118 | BlockType Inport 119 | Port "1" 120 | PortDimensions "-1" 121 | SampleTime "-1" 122 | ShowAdditionalParam off 123 | LatchInput off 124 | DataType "auto" 125 | OutDataType "sfix(16)" 126 | OutScaling "2^0" 127 | SignalType "auto" 128 | SamplingMode "auto" 129 | Interpolate on 130 | } 131 | Block { 132 | BlockType Outport 133 | Port "1" 134 | OutputWhenDisabled "held" 135 | InitialOutput "[]" 136 | } 137 | Block { 138 | BlockType Saturate 139 | UpperLimit "0.5" 140 | LowerLimit "-0.5" 141 | LinearizeAsGain on 142 | ZeroCross on 143 | } 144 | Block { 145 | BlockType SubSystem 146 | ShowPortLabels on 147 | Permissions "ReadWrite" 148 | RTWSystemCode "Auto" 149 | RTWFcnNameOpts "Auto" 150 | RTWFileNameOpts "Auto" 151 | SimViewingDevice off 152 | DataTypeOverride "UseLocalSettings" 153 | MinMaxOverflowLogging "UseLocalSettings" 154 | } 155 | Block { 156 | BlockType Sum 157 | IconShape "rectangular" 158 | Inputs "++" 159 | ShowAdditionalParam off 160 | InputSameDT on 161 | OutDataTypeMode "Same as first input" 162 | OutDataType "sfix(16)" 163 | OutScaling "2^0" 164 | LockScale off 165 | RndMeth "Floor" 166 | SaturateOnIntegerOverflow on 167 | } 168 | Block { 169 | BlockType UnitDelay 170 | X0 "0" 171 | SampleTime "1" 172 | RTWStateStorageClass "Auto" 173 | } 174 | Block { 175 | BlockType ZeroOrderHold 176 | SampleTime "1" 177 | } 178 | } 179 | AnnotationDefaults { 180 | HorizontalAlignment "center" 181 | VerticalAlignment "middle" 182 | ForegroundColor "black" 183 | BackgroundColor "white" 184 | DropShadow off 185 | FontName "Helvetica" 186 | FontSize 10 187 | FontWeight "normal" 188 | FontAngle "normal" 189 | } 190 | LineDefaults { 191 | FontName "Helvetica" 192 | FontSize 9 193 | FontWeight "normal" 194 | FontAngle "normal" 195 | } 196 | System { 197 | Name "TElib" 198 | Location [11, 78, 258, 333] 199 | Open on 200 | ModelBrowserVisibility off 201 | ModelBrowserWidth 200 202 | ScreenColor "white" 203 | PaperOrientation "landscape" 204 | PaperPositionMode "auto" 205 | PaperType "usletter" 206 | PaperUnits "inches" 207 | ZoomFactor "100" 208 | ReportName "simulink-default.rpt" 209 | Block { 210 | BlockType SubSystem 211 | Name "Discrete PI" 212 | Ports [2, 1] 213 | Position [85, 43, 160, 112] 214 | TreatAsAtomicUnit off 215 | MaskPromptString "Kc|Ti|Ts|x0|Hi|Lo" 216 | MaskStyleString "edit,edit,edit,edit,edit,edit" 217 | MaskTunableValueString "on,on,on,on,on,on" 218 | MaskCallbackString "|||||" 219 | MaskEnableString "on,on,on,on,on,on" 220 | MaskVisibilityString "on,on,on,on,on,on" 221 | MaskToolTipString "on,on,on,on,on,on" 222 | MaskVarAliasString ",,,,," 223 | MaskVariables "Kc=@1;Ti=@2;Ts=@3;x0=@4;Hi=@5;Lo=@6;" 224 | MaskIconFrame on 225 | MaskIconOpaque on 226 | MaskIconRotate "none" 227 | MaskIconUnits "autoscale" 228 | MaskValueString "0|inf|1|0|1|-1" 229 | System { 230 | Name "Discrete PI" 231 | Location [433, 403, 890, 589] 232 | Open off 233 | ModelBrowserVisibility off 234 | ModelBrowserWidth 200 235 | ScreenColor "white" 236 | PaperOrientation "landscape" 237 | PaperPositionMode "auto" 238 | PaperType "usletter" 239 | PaperUnits "inches" 240 | ZoomFactor "100" 241 | Block { 242 | BlockType Inport 243 | Name "Setpoint" 244 | Position [20, 53, 50, 67] 245 | } 246 | Block { 247 | BlockType Inport 248 | Name "Meas" 249 | Position [20, 93, 50, 107] 250 | Port "2" 251 | } 252 | Block { 253 | BlockType Saturate 254 | Name "Saturation" 255 | Position [260, 70, 290, 100] 256 | UpperLimit "Hi" 257 | LowerLimit "Lo" 258 | } 259 | Block { 260 | BlockType Sum 261 | Name "Sum" 262 | Ports [2, 1] 263 | Position [205, 75, 225, 95] 264 | ShowName off 265 | IconShape "round" 266 | Inputs "|++" 267 | InputSameDT off 268 | OutDataTypeMode "Inherit via internal rule" 269 | } 270 | Block { 271 | BlockType UnitDelay 272 | Name "Unit Delay" 273 | Position [320, 65, 355, 105] 274 | X0 "x0" 275 | SampleTime "Ts" 276 | } 277 | Block { 278 | BlockType SubSystem 279 | Name "Vel PI" 280 | Ports [2, 1] 281 | Position [90, 54, 170, 116] 282 | TreatAsAtomicUnit off 283 | MaskPromptString "Kc|Ti|Ts" 284 | MaskStyleString "edit,edit,edit" 285 | MaskTunableValueString "on,on,on" 286 | MaskCallbackString "||" 287 | MaskEnableString "on,on,on" 288 | MaskVisibilityString "on,on,on" 289 | MaskToolTipString "on,on,on" 290 | MaskVarAliasString ",," 291 | MaskVariables "Kc=@1;Ti=@2;Ts=@3;" 292 | MaskIconFrame on 293 | MaskIconOpaque on 294 | MaskIconRotate "none" 295 | MaskIconUnits "autoscale" 296 | MaskValueString "Kc|Ti|Ts" 297 | System { 298 | Name "Vel PI" 299 | Location [56, 364, 610, 534] 300 | Open off 301 | ModelBrowserVisibility off 302 | ModelBrowserWidth 200 303 | ScreenColor "white" 304 | PaperOrientation "landscape" 305 | PaperPositionMode "auto" 306 | PaperType "usletter" 307 | PaperUnits "inches" 308 | ZoomFactor "100" 309 | Block { 310 | BlockType Inport 311 | Name "Setpoint" 312 | Position [25, 53, 55, 67] 313 | } 314 | Block { 315 | BlockType Inport 316 | Name "Meas" 317 | Position [25, 108, 55, 122] 318 | Port "2" 319 | } 320 | Block { 321 | BlockType Gain 322 | Name "Gain" 323 | Position [395, 45, 425, 75] 324 | Gain "Kc" 325 | } 326 | Block { 327 | BlockType Gain 328 | Name "Gain1" 329 | Position [215, 45, 265, 75] 330 | Gain "Ts/Ti" 331 | } 332 | Block { 333 | BlockType Sum 334 | Name "Sum" 335 | Ports [2, 1] 336 | Position [95, 50, 115, 70] 337 | ShowName off 338 | IconShape "round" 339 | Inputs "|+-" 340 | InputSameDT off 341 | OutDataTypeMode "Inherit via internal rule" 342 | } 343 | Block { 344 | BlockType Sum 345 | Name "Sum1" 346 | Ports [3, 1] 347 | Position [335, 50, 355, 70] 348 | ShowName off 349 | IconShape "round" 350 | Inputs "++-" 351 | InputSameDT off 352 | OutDataTypeMode "Inherit via internal rule" 353 | } 354 | Block { 355 | BlockType UnitDelay 356 | Name "Unit Delay" 357 | Position [220, 100, 255, 140] 358 | SampleTime "Ts" 359 | } 360 | Block { 361 | BlockType ZeroOrderHold 362 | Name "Zero-Order\nHold" 363 | Position [140, 41, 175, 79] 364 | SampleTime "Ts" 365 | } 366 | Block { 367 | BlockType Outport 368 | Name "Delta Output" 369 | Position [475, 53, 505, 67] 370 | } 371 | Line { 372 | SrcBlock "Setpoint" 373 | SrcPort 1 374 | DstBlock "Sum" 375 | DstPort 1 376 | } 377 | Line { 378 | SrcBlock "Meas" 379 | SrcPort 1 380 | Points [45, 0] 381 | DstBlock "Sum" 382 | DstPort 2 383 | } 384 | Line { 385 | SrcBlock "Gain" 386 | SrcPort 1 387 | DstBlock "Delta Output" 388 | DstPort 1 389 | } 390 | Line { 391 | SrcBlock "Sum1" 392 | SrcPort 1 393 | DstBlock "Gain" 394 | DstPort 1 395 | } 396 | Line { 397 | SrcBlock "Gain1" 398 | SrcPort 1 399 | DstBlock "Sum1" 400 | DstPort 2 401 | } 402 | Line { 403 | SrcBlock "Unit Delay" 404 | SrcPort 1 405 | Points [85, 0] 406 | DstBlock "Sum1" 407 | DstPort 3 408 | } 409 | Line { 410 | SrcBlock "Sum" 411 | SrcPort 1 412 | DstBlock "Zero-Order\nHold" 413 | DstPort 1 414 | } 415 | Line { 416 | SrcBlock "Zero-Order\nHold" 417 | SrcPort 1 418 | Points [10, 0] 419 | Branch { 420 | DstBlock "Gain1" 421 | DstPort 1 422 | } 423 | Branch { 424 | Points [0, 60] 425 | DstBlock "Unit Delay" 426 | DstPort 1 427 | } 428 | Branch { 429 | Points [0, -40; 155, 0] 430 | DstBlock "Sum1" 431 | DstPort 1 432 | } 433 | } 434 | } 435 | } 436 | Block { 437 | BlockType Outport 438 | Name "Output" 439 | Position [400, 78, 430, 92] 440 | } 441 | Line { 442 | SrcBlock "Sum" 443 | SrcPort 1 444 | DstBlock "Saturation" 445 | DstPort 1 446 | } 447 | Line { 448 | SrcBlock "Vel PI" 449 | SrcPort 1 450 | DstBlock "Sum" 451 | DstPort 1 452 | } 453 | Line { 454 | SrcBlock "Saturation" 455 | SrcPort 1 456 | DstBlock "Unit Delay" 457 | DstPort 1 458 | } 459 | Line { 460 | SrcBlock "Unit Delay" 461 | SrcPort 1 462 | Points [0, 0; 10, 0] 463 | Branch { 464 | Points [0, 65; -155, 0] 465 | DstBlock "Sum" 466 | DstPort 2 467 | } 468 | Branch { 469 | DstBlock "Output" 470 | DstPort 1 471 | } 472 | } 473 | Line { 474 | SrcBlock "Meas" 475 | SrcPort 1 476 | DstBlock "Vel PI" 477 | DstPort 2 478 | } 479 | Line { 480 | SrcBlock "Setpoint" 481 | SrcPort 1 482 | Points [10, 0; 0, 10] 483 | DstBlock "Vel PI" 484 | DstPort 1 485 | } 486 | } 487 | } 488 | Block { 489 | BlockType Reference 490 | Name "Vel PI" 491 | Ports [2, 1] 492 | Position [80, 154, 160, 216] 493 | SourceBlock "TElib/Discrete PI/Vel PI" 494 | SourceType "" 495 | Kc "Kc" 496 | Ti "Ti" 497 | Ts "Ts" 498 | } 499 | } 500 | } 501 | -------------------------------------------------------------------------------- /temexd_mod/TEplot.m: -------------------------------------------------------------------------------- 1 | 2 | % Plots data from TE problem simulation. Assumes 3 | % that simulation time is in vector "tout", 4 | % plant outputs are in matrix "simout", 5 | % plant MVs are in matrix "xmv". 6 | 7 | TEdata.xy=[tout(:) simout(:,1:41)]; 8 | TEdata.iy=cell(1,41); for i=1:41; TEdata.iy{i}=i; end 9 | TEdata.title=cell(1,41); TEdata.ylabel=cell(1,41); 10 | TEdata.xlabel=cell(1,41); for i=1:41; TEdata.xlabel{i}='Hours'; end 11 | TEdata.layout='2x2'; 12 | TEdata.title{1}='A Feed'; 13 | TEdata.ylabel{1}='kscmh'; 14 | TEdata.title{2}='D Feed'; 15 | TEdata.ylabel{2}='kg/hr'; 16 | TEdata.title{3}='E Feed'; 17 | TEdata.ylabel{3}='kg/hr'; 18 | TEdata.title{4}='A and C Feed'; 19 | TEdata.ylabel{4}='kscmh'; 20 | TEdata.title{5}='Recycle Flow'; 21 | TEdata.ylabel{5}='kscmh'; 22 | TEdata.title{6}='Reactor Feed Rate'; 23 | TEdata.ylabel{6}='kscmh'; 24 | TEdata.title{7}='Reactor Pressure'; 25 | TEdata.ylabel{7}='kPa gauge'; 26 | TEdata.title{8}='Reactor Level'; 27 | TEdata.ylabel{8}='%'; 28 | TEdata.title{9}='Reactor Temperature'; 29 | TEdata.ylabel{9}='Deg C'; 30 | TEdata.title{10}='Purge Rate'; 31 | TEdata.ylabel{10}='kscmh'; 32 | TEdata.title{11}='Product Sep Temp'; 33 | TEdata.ylabel{11}='Deg C'; 34 | TEdata.title{12}='Product Sep Level'; 35 | TEdata.ylabel{12}='%'; 36 | TEdata.title{13}='Product Sep Pressure'; 37 | TEdata.ylabel{13}='kPa gauge'; 38 | TEdata.title{14}='Product Sep Underflow'; 39 | TEdata.ylabel{14}='m3/hr'; 40 | TEdata.title{15}='Stripper Level'; 41 | TEdata.ylabel{15}='%'; 42 | TEdata.title{16}='Stripper Pressure'; 43 | TEdata.ylabel{16}='kPa gauge'; 44 | TEdata.title{17}='Stripper Underflow'; 45 | TEdata.ylabel{17}='m3/hr'; 46 | TEdata.title{18}='Stripper Temp'; 47 | TEdata.ylabel{18}='Deg C'; 48 | TEdata.title{19}='Stripper Steam Flow'; 49 | TEdata.ylabel{19}='kg/h'; 50 | TEdata.title{20}='Compressor Work'; 51 | TEdata.ylabel{20}='kW'; 52 | TEdata.title{21}='Reactor Coolant Temp'; 53 | TEdata.ylabel{21}='Deg C'; 54 | TEdata.title{22}='Separator Coolant Temp'; 55 | TEdata.ylabel{22}='Deg C'; 56 | for i=23:41, TEdata.ylabel{i}='Mole %'; end 57 | comps=['A','B','C','D','E','F','G','H']; 58 | for i=23:28, TEdata.title{i}=['Component ',comps(i-22),' to Reactor']; end 59 | for i=29:36, TEdata.title{i}=['Component ',comps(i-28),' in Purge']; end 60 | for i=37:41, TEdata.title{i}=['Component ',comps(i-33),' in Product']; end 61 | 62 | 63 | TEmvs.xy=[tout(:) xmv(:,1:12)]; 64 | TEmvs.iy=cell(1,12); for i=1:12; TEmvs.iy{i}=i; end 65 | TEmvs.title=cell(1,12); TEmvs.ylabel=cell(1,12); 66 | TEmvs.xlabel=cell(1,12); for i=1:41; TEmvs.xlabel{i}='Hours'; end 67 | TEmvs.layout='2x2'; 68 | TEmvs.title{1}='D feed'; 69 | TEmvs.ylabel{1}='%'; 70 | TEmvs.title{2}='E Feed'; 71 | TEmvs.ylabel{2}='%'; 72 | TEmvs.title{3}='A Feed'; 73 | TEmvs.ylabel{3}='%'; 74 | TEmvs.title{4}='A and C Feed'; 75 | TEmvs.ylabel{4}='%'; 76 | TEmvs.title{5}='Recycle'; 77 | TEmvs.ylabel{5}='%'; 78 | TEmvs.title{6}='Purge'; 79 | TEmvs.ylabel{6}='%'; 80 | TEmvs.title{7}='Separator'; 81 | TEmvs.ylabel{7}='%'; 82 | TEmvs.title{8}='Stripper'; 83 | TEmvs.ylabel{8}='%'; 84 | TEmvs.title{9}='Steam'; 85 | TEmvs.ylabel{9}='%'; 86 | TEmvs.title{10}='Reactor Coolant'; 87 | TEmvs.ylabel{10}='%'; 88 | TEmvs.title{11}='Condenser Coolant'; 89 | TEmvs.ylabel{11}='%'; 90 | TEmvs.title{12}='Agitator'; 91 | TEmvs.ylabel{12}='%'; 92 | 93 | if exist('FIg1') 94 | close(FIg1); 95 | end 96 | if exist('FIg2') 97 | close(FIg2) 98 | end 99 | 100 | if ~exist('FIg1') 101 | FIg1=figure; 102 | set(FIg1,'Units','points',... 103 | 'CloseRequestFcn','delete([FIg, FIg1]); clear FIg FIg1'); 104 | Pos=get(gcf,'Position'); 105 | end 106 | figure(FIg1); 107 | plot(tout,simout(:,7)); 108 | xlabel('Hours'); ylabel(TEdata.ylabel(7)); 109 | title(TEdata.title(7)); 110 | 111 | % Set up GUI 112 | if ~exist('FIg') 113 | FIg=figure('Units','points',... 114 | 'CloseRequestFcn','delete([FIg, FIg1]); clear FIg FIg1',... 115 | 'MenuBar','none',... 116 | 'Position',[Pos(1:2)+[20 -60] 180 40],... 117 | 'Name','Signal Selection',... 118 | 'NumberTitle','off'); % Figure window 119 | CALLback=['Sig=get(gcbo,''Value''); figure(FIg1);'... 120 | 'plot(tout,simout(:,Sig)); title(TEdata.title(Sig));',... 121 | 'xlabel(''Hours''); ylabel(TEdata.ylabel(Sig));',... 122 | 'figure(FIg)']; 123 | uicontrol('Parent',FIg,'Units','points', ... 124 | 'callback',CALLback,... 125 | 'Position',[20 5 150 20],'String',TEdata.title,... 126 | 'Value',7,'Style','popup'); % Inactive block edit box 127 | else 128 | figure(FIg) 129 | end 130 | if ~exist('FIg2') 131 | FIg2=figure; 132 | set(FIg2,'Units','points',... 133 | 'CloseRequestFcn','delete([FIgM, FIg2]); clear FIgM FIg2'); 134 | Pos=get(gcf,'Position'); 135 | end 136 | figure(FIg2) 137 | plot(tout,xmv(:,10)); 138 | xlabel('Hours'); ylabel(TEmvs.ylabel(10)); 139 | title(TEmvs.title(10)); 140 | 141 | % Set up GUI 142 | if ~exist('FIgM') 143 | FIgM=figure('Units','points',... 144 | 'CloseRequestFcn','delete([FIgM, FIg2]); clear FIgM FIg2',... 145 | 'MenuBar','none',... 146 | 'Position',[Pos(1:2)+[20 -60] 180 40],... 147 | 'Name','MV Selection',... 148 | 'NumberTitle','off'); % Figure window 149 | CALLback=['Sig=get(gcbo,''Value''); figure(FIg2);'... 150 | 'plot(tout,xmv(:,Sig)); title(TEmvs.title(Sig));',... 151 | 'xlabel(''Hours''); ylabel(TEmvs.ylabel(Sig));',... 152 | 'figure(FIgM)']; 153 | uicontrol('Parent',FIgM,'Units','points', ... 154 | 'callback',CALLback,... 155 | 'Position',[20 5 150 20],'String',TEmvs.title,... 156 | 'Value',10,'Style','popup'); % Inactive block edit box 157 | end -------------------------------------------------------------------------------- /temexd_mod/matlab.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/matlab.mat -------------------------------------------------------------------------------- /temexd_mod/temexd_mod.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/temexd_mod.c -------------------------------------------------------------------------------- /temexd_mod/temexd_mod.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/temexd_mod.mexa64 -------------------------------------------------------------------------------- /temexd_mod/temexd_mod.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pwwl/tep-attack-simulator/2bbead7ffcaa844bae2c7743c231e9c8f80b27c1/temexd_mod/temexd_mod.mexw64 -------------------------------------------------------------------------------- /temexd_mod/teprob_mod.h: -------------------------------------------------------------------------------- 1 | /* f2c.h -- Standard Fortran to C header file */ 2 | 3 | /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." 4 | 5 | - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ 6 | 7 | #ifndef F2C_INCLUDE 8 | #define F2C_INCLUDE 9 | 10 | typedef long int integer; 11 | typedef unsigned long uinteger; 12 | typedef char *address; 13 | typedef short int shortint; 14 | typedef float real; 15 | typedef double doublereal; 16 | typedef struct { real r, i; } complex; 17 | typedef struct { doublereal r, i; } doublecomplex; 18 | typedef long int logical; 19 | typedef short int shortlogical; 20 | typedef char logical1; 21 | typedef char integer1; 22 | #if 0 /* Adjust for integer*8. */ 23 | typedef long long longint; /* system-dependent */ 24 | typedef unsigned long long ulongint; /* system-dependent */ 25 | #define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b))) 26 | #define qbit_set(a,b) ((a) | ((ulongint)1 << (b))) 27 | #endif 28 | 29 | #define TRUE_ (1) 30 | #define FALSE_ (0) 31 | 32 | /* Extern is for use with -E */ 33 | #ifndef Extern 34 | #define Extern extern 35 | #endif 36 | 37 | /* I/O stuff */ 38 | 39 | #ifdef f2c_i2 40 | /* for -i2 */ 41 | typedef short flag; 42 | typedef short ftnlen; 43 | typedef short ftnint; 44 | #else 45 | typedef long int flag; 46 | typedef long int ftnlen; 47 | typedef long int ftnint; 48 | #endif 49 | 50 | /*external read, write*/ 51 | typedef struct 52 | { flag cierr; 53 | ftnint ciunit; 54 | flag ciend; 55 | char *cifmt; 56 | ftnint cirec; 57 | } cilist; 58 | 59 | /*internal read, write*/ 60 | typedef struct 61 | { flag icierr; 62 | char *iciunit; 63 | flag iciend; 64 | char *icifmt; 65 | ftnint icirlen; 66 | ftnint icirnum; 67 | } icilist; 68 | 69 | /*open*/ 70 | typedef struct 71 | { flag oerr; 72 | ftnint ounit; 73 | char *ofnm; 74 | ftnlen ofnmlen; 75 | char *osta; 76 | char *oacc; 77 | char *ofm; 78 | ftnint orl; 79 | char *oblnk; 80 | } olist; 81 | 82 | /*close*/ 83 | typedef struct 84 | { flag cerr; 85 | ftnint cunit; 86 | char *csta; 87 | } cllist; 88 | 89 | /*rewind, backspace, endfile*/ 90 | typedef struct 91 | { flag aerr; 92 | ftnint aunit; 93 | } alist; 94 | 95 | /* inquire */ 96 | typedef struct 97 | { flag inerr; 98 | ftnint inunit; 99 | char *infile; 100 | ftnlen infilen; 101 | ftnint *inex; /*parameters in standard's order*/ 102 | ftnint *inopen; 103 | ftnint *innum; 104 | ftnint *innamed; 105 | char *inname; 106 | ftnlen innamlen; 107 | char *inacc; 108 | ftnlen inacclen; 109 | char *inseq; 110 | ftnlen inseqlen; 111 | char *indir; 112 | ftnlen indirlen; 113 | char *infmt; 114 | ftnlen infmtlen; 115 | char *inform; 116 | ftnint informlen; 117 | char *inunf; 118 | ftnlen inunflen; 119 | ftnint *inrecl; 120 | ftnint *innrec; 121 | char *inblank; 122 | ftnlen inblanklen; 123 | } inlist; 124 | 125 | #define VOID void 126 | 127 | union Multitype { /* for multiple entry points */ 128 | integer1 g; 129 | shortint h; 130 | integer i; 131 | /* longint j; */ 132 | real r; 133 | doublereal d; 134 | complex c; 135 | doublecomplex z; 136 | }; 137 | 138 | typedef union Multitype Multitype; 139 | 140 | /*typedef long int Long;*/ /* No longer used; formerly in Namelist */ 141 | 142 | struct Vardesc { /* for Namelist */ 143 | char *name; 144 | char *addr; 145 | ftnlen *dims; 146 | int type; 147 | }; 148 | typedef struct Vardesc Vardesc; 149 | 150 | struct Namelist { 151 | char *name; 152 | Vardesc **vars; 153 | int nvars; 154 | }; 155 | typedef struct Namelist Namelist; 156 | 157 | #define abs(x) ((x) >= 0 ? (x) : -(x)) 158 | #define dabs(x) (doublereal)abs(x) 159 | //#define min(a,b) ((a) <= (b) ? (a) : (b)) 160 | //#define max(a,b) ((a) >= (b) ? (a) : (b)) 161 | #define dmin(a,b) (doublereal)min(a,b) 162 | #define dmax(a,b) (doublereal)max(a,b) 163 | #define bit_test(a,b) ((a) >> (b) & 1) 164 | #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) 165 | #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) 166 | 167 | /* procedure parameter types for -A and -C++ */ 168 | 169 | #define F2C_proc_par_types 1 170 | #ifdef __cplusplus 171 | typedef int /* Unknown procedure type */ (*U_fp)(...); 172 | typedef shortint (*J_fp)(...); 173 | typedef integer (*I_fp)(...); 174 | typedef real (*R_fp)(...); 175 | typedef doublereal (*D_fp)(...), (*E_fp)(...); 176 | typedef /* Complex */ VOID (*C_fp)(...); 177 | typedef /* Double Complex */ VOID (*Z_fp)(...); 178 | typedef logical (*L_fp)(...); 179 | typedef shortlogical (*K_fp)(...); 180 | typedef /* Character */ VOID (*H_fp)(...); 181 | typedef /* Subroutine */ int (*S_fp)(...); 182 | #else 183 | typedef int /* Unknown procedure type */ (*U_fp)(); 184 | typedef shortint (*J_fp)(); 185 | typedef integer (*I_fp)(); 186 | typedef real (*R_fp)(); 187 | typedef doublereal (*D_fp)(), (*E_fp)(); 188 | typedef /* Complex */ VOID (*C_fp)(); 189 | typedef /* Double Complex */ VOID (*Z_fp)(); 190 | typedef logical (*L_fp)(); 191 | typedef shortlogical (*K_fp)(); 192 | typedef /* Character */ VOID (*H_fp)(); 193 | typedef /* Subroutine */ int (*S_fp)(); 194 | #endif 195 | /* E_fp is for real functions when -R is not specified */ 196 | typedef VOID C_f; /* complex function */ 197 | typedef VOID H_f; /* character function */ 198 | typedef VOID Z_f; /* double complex function */ 199 | typedef doublereal E_f; /* real function with -R not specified */ 200 | 201 | /* undef any lower-case symbols that your C compiler predefines, e.g.: */ 202 | 203 | #ifndef Skip_f2c_Undefs 204 | #undef cray 205 | #undef gcos 206 | #undef mc68010 207 | #undef mc68020 208 | #undef mips 209 | #undef pdp11 210 | #undef sgi 211 | #undef sparc 212 | #undef sun 213 | #undef sun2 214 | #undef sun3 215 | #undef sun4 216 | #undef u370 217 | #undef u3b 218 | #undef u3b2 219 | #undef u3b5 220 | #undef unix 221 | #undef vax 222 | #endif 223 | #endif 224 | 225 | 226 | // Prototypes 227 | static void setidv(SimStruct *S); 228 | static doublereal getcurr(doublereal x[], SimStruct *S, shortint Callflag); 229 | static int teinit(void *ModelData, const integer *nn, doublereal *time, 230 | doublereal *yy, doublereal *yp, doublereal *rseed, 231 | doublereal *MSFlag); 232 | static int tefunc(void *ModelData, const integer *nn, doublereal *time, 233 | doublereal *yy, doublereal *yp, shortint Callflag); 234 | static int tesub1_(void *ModelData, doublereal *z__, doublereal *t, 235 | doublereal *h__, const integer *ity); 236 | static int tesub2_(void *ModelData, doublereal *z__, doublereal *t, 237 | doublereal *h__, const integer *ity); 238 | static int tesub3_(void *ModelData, doublereal *z__, doublereal *t, 239 | doublereal *dh, const integer *ity); 240 | static int tesub4_(void *ModelData, doublereal *x, doublereal *t, 241 | doublereal *r__); 242 | static int tesub5_(void *ModelData, doublereal *s, doublereal *sp, 243 | doublereal *adist, doublereal *bdist, doublereal *cdist, 244 | doublereal *ddist, doublereal *tlast, doublereal *tnext, 245 | doublereal *hspan, doublereal *hzero, doublereal *sspan, 246 | doublereal *szero, doublereal *spspan, 247 | doublereal *idvflag); 248 | static int tesub6_(void *ModelData, doublereal *std, doublereal *x); 249 | static doublereal tesub7_(void *ModelData, integer *i__); 250 | static doublereal tesub8_(void *ModelData, const integer *i__, 251 | doublereal *t); 252 | double pow_dd(doublereal *ap, const doublereal *bp); 253 | double d_mod(doublereal *x, doublereal *y); 254 | -------------------------------------------------------------------------------- /temexd_mod/tesys.mdl: -------------------------------------------------------------------------------- 1 | Model { 2 | Name "tesys" 3 | Version 8.4 4 | MdlSubVersion 0 5 | SavedCharacterEncoding "windows-1252" 6 | GraphicalInterface { 7 | NumRootInports 1 8 | Inport { 9 | Name "In1" 10 | BusObject "" 11 | } 12 | NumRootOutports 1 13 | Outport { 14 | Name "Out1" 15 | BusObject "" 16 | BusOutputAsStruct "off" 17 | } 18 | ParameterArgumentNames "" 19 | ComputedModelVersion "1.3" 20 | NumModelReferences 0 21 | NumTestPointedSignals 0 22 | } 23 | ScopeRefreshTime 0.035000 24 | OverrideScopeRefreshTime on 25 | DisableAllScopes off 26 | DataTypeOverride "UseLocalSettings" 27 | DataTypeOverrideAppliesTo "AllNumericTypes" 28 | MinMaxOverflowLogging "UseLocalSettings" 29 | MinMaxOverflowArchiveMode "Overwrite" 30 | FPTRunName "Run 1" 31 | MaxMDLFileLineLength 120 32 | Object { 33 | $PropName "BdWindowsInfo" 34 | $ObjectID 1 35 | $ClassName "Simulink.BDWindowsInfo" 36 | Object { 37 | $PropName "WindowsInfo" 38 | $ObjectID 2 39 | $ClassName "Simulink.WindowInfo" 40 | IsActive [1] 41 | Location [450.0, 52.0, 636.0, 485.0] 42 | Object { 43 | $PropName "ModelBrowserInfo" 44 | $ObjectID 3 45 | $ClassName "Simulink.ModelBrowserInfo" 46 | Visible [0] 47 | DockPosition "Left" 48 | Width [50] 49 | Height [50] 50 | Filter [8] 51 | } 52 | Object { 53 | $PropName "ExplorerBarInfo" 54 | $ObjectID 4 55 | $ClassName "Simulink.ExplorerBarInfo" 56 | Visible [1] 57 | } 58 | Object { 59 | $PropName "EditorsInfo" 60 | $ObjectID 5 61 | $ClassName "Simulink.EditorInfo" 62 | IsActive [1] 63 | ViewObjType "SimulinkTopLevel" 64 | LoadSaveID "0" 65 | Extents [586.0, 311.0] 66 | ZoomFactor [1.0] 67 | Offset [0.0, 0.0] 68 | } 69 | } 70 | } 71 | Created "Tue Oct 29 16:51:38 2002" 72 | Creator "ricker" 73 | UpdateHistory "UpdateHistoryNever" 74 | ModifiedByFormat "%" 75 | LastModifiedBy "ricker" 76 | ModifiedDateFormat "%" 77 | LastModifiedDate "Thu Nov 13 20:41:46 2014" 78 | RTWModifiedTimeStamp 337812065 79 | ModelVersionFormat "1.%" 80 | ConfigurationManager "none" 81 | SampleTimeColors off 82 | SampleTimeAnnotations off 83 | LibraryLinkDisplay "none" 84 | WideLines off 85 | ShowLineDimensions off 86 | ShowPortDataTypes off 87 | ShowDesignRanges off 88 | ShowLoopsOnError on 89 | IgnoreBidirectionalLines off 90 | ShowStorageClass off 91 | ShowTestPointIcons on 92 | ShowSignalResolutionIcons on 93 | ShowViewerIcons on 94 | SortedOrder off 95 | ExecutionContextIcon off 96 | ShowLinearizationAnnotations on 97 | ShowMarkup on 98 | BlockNameDataTip off 99 | BlockParametersDataTip off 100 | BlockDescriptionStringDataTip off 101 | ToolBar on 102 | StatusBar on 103 | BrowserShowLibraryLinks off 104 | BrowserLookUnderMasks off 105 | SimulationMode "normal" 106 | PauseTimes "5" 107 | NumberOfSteps 1 108 | SnapshotBufferSize 10 109 | SnapshotInterval 10 110 | NumberOfLastSnapshots 0 111 | LinearizationMsg "none" 112 | Profile off 113 | ParamWorkspaceSource "MATLABWorkspace" 114 | AccelSystemTargetFile "accel.tlc" 115 | AccelTemplateMakefile "accel_default_tmf" 116 | AccelMakeCommand "make_rtw" 117 | TryForcingSFcnDF off 118 | Object { 119 | $PropName "DataLoggingOverride" 120 | $ObjectID 6 121 | $ClassName "Simulink.SimulationData.ModelLoggingInfo" 122 | model_ "tesys" 123 | Array { 124 | Type "Cell" 125 | Dimension 1 126 | Cell "tesys" 127 | PropName "logAsSpecifiedByModels_" 128 | } 129 | Array { 130 | Type "Cell" 131 | Dimension 1 132 | Cell "" 133 | PropName "logAsSpecifiedByModelsSSIDs_" 134 | } 135 | } 136 | RecordCoverage off 137 | CovPath "/" 138 | CovSaveName "covdata" 139 | CovMetricSettings "dw" 140 | CovNameIncrementing off 141 | CovHtmlReporting on 142 | CovForceBlockReductionOff on 143 | CovEnableCumulative on 144 | covSaveCumulativeToWorkspaceVar on 145 | CovSaveSingleToWorkspaceVar on 146 | CovCumulativeVarName "covCumulativeData" 147 | CovCumulativeReport off 148 | CovReportOnPause on 149 | CovModelRefEnable "Off" 150 | CovExternalEMLEnable off 151 | CovSFcnEnable off 152 | CovBoundaryAbsTol 0.000010 153 | CovBoundaryRelTol 0.010000 154 | CovUseTimeInterval off 155 | CovStartTime 0 156 | CovStopTime 0 157 | ExtModeBatchMode off 158 | ExtModeEnableFloating on 159 | ExtModeTrigType "manual" 160 | ExtModeTrigMode "normal" 161 | ExtModeTrigPort "1" 162 | ExtModeTrigElement "any" 163 | ExtModeTrigDuration 1000 164 | ExtModeTrigDurationFloating "auto" 165 | ExtModeTrigHoldOff 0 166 | ExtModeTrigDelay 0 167 | ExtModeTrigDirection "rising" 168 | ExtModeTrigLevel 0 169 | ExtModeArchiveMode "off" 170 | ExtModeAutoIncOneShot off 171 | ExtModeIncDirWhenArm off 172 | ExtModeAddSuffixToVar off 173 | ExtModeWriteAllDataToWs off 174 | ExtModeArmWhenConnect on 175 | ExtModeSkipDownloadWhenConnect off 176 | ExtModeLogAll on 177 | ExtModeAutoUpdateStatusClock on 178 | BufferReuse on 179 | ShowModelReferenceBlockVersion off 180 | ShowModelReferenceBlockIO off 181 | Array { 182 | Type "Handle" 183 | Dimension 1 184 | Simulink.ConfigSet { 185 | $ObjectID 7 186 | Version "1.14.3" 187 | Array { 188 | Type "Handle" 189 | Dimension 8 190 | Simulink.SolverCC { 191 | $ObjectID 8 192 | Version "1.14.3" 193 | StartTime "0.0" 194 | StopTime "10.0" 195 | AbsTol "auto" 196 | FixedStep "auto" 197 | InitialStep "auto" 198 | MaxNumMinSteps "-1" 199 | MaxOrder 5 200 | ZcThreshold "auto" 201 | ConsecutiveZCsStepRelTol "10*128*eps" 202 | MaxConsecutiveZCs "1000" 203 | ExtrapolationOrder 4 204 | NumberNewtonIterations 1 205 | MaxStep "auto" 206 | MinStep "auto" 207 | MaxConsecutiveMinStep "1" 208 | RelTol "1e-3" 209 | SolverMode "Auto" 210 | EnableConcurrentExecution off 211 | ConcurrentTasks off 212 | Solver "ode45" 213 | SolverName "ode45" 214 | SolverJacobianMethodControl "auto" 215 | ShapePreserveControl "DisableAll" 216 | ZeroCrossControl "UseLocalSettings" 217 | ZeroCrossAlgorithm "Nonadaptive" 218 | AlgebraicLoopSolver "TrustRegion" 219 | SolverResetMethod "Fast" 220 | PositivePriorityOrder off 221 | AutoInsertRateTranBlk off 222 | SampleTimeConstraint "Unconstrained" 223 | InsertRTBMode "Whenever possible" 224 | } 225 | Simulink.DataIOCC { 226 | $ObjectID 9 227 | Version "1.14.3" 228 | Decimation "1" 229 | ExternalInput "[t, u]" 230 | FinalStateName "xFinal" 231 | InitialState "xInitial" 232 | LimitDataPoints on 233 | MaxDataPoints "1000" 234 | LoadExternalInput off 235 | LoadInitialState off 236 | SaveFinalState off 237 | SaveCompleteFinalSimState off 238 | SaveFormat "Array" 239 | SignalLoggingSaveFormat "ModelDataLogs" 240 | SaveOutput on 241 | SaveState off 242 | SignalLogging on 243 | DSMLogging on 244 | InspectSignalLogs off 245 | VisualizeSimOutput on 246 | SaveTime on 247 | ReturnWorkspaceOutputs off 248 | StateSaveName "xout" 249 | TimeSaveName "tout" 250 | OutputSaveName "yout" 251 | SignalLoggingName "sigsOut" 252 | DSMLoggingName "dsmout" 253 | OutputOption "RefineOutputTimes" 254 | OutputTimes "[]" 255 | ReturnWorkspaceOutputsName "out" 256 | Refine "1" 257 | } 258 | Simulink.OptimizationCC { 259 | $ObjectID 10 260 | Version "1.14.3" 261 | Array { 262 | Type "Cell" 263 | Dimension 8 264 | Cell "BooleansAsBitfields" 265 | Cell "PassReuseOutputArgsAs" 266 | Cell "PassReuseOutputArgsThreshold" 267 | Cell "ZeroExternalMemoryAtStartup" 268 | Cell "ZeroInternalMemoryAtStartup" 269 | Cell "OptimizeModelRefInitCode" 270 | Cell "NoFixptDivByZeroProtection" 271 | Cell "UseSpecifiedMinMax" 272 | PropName "DisabledProps" 273 | } 274 | BlockReduction on 275 | BooleanDataType on 276 | ConditionallyExecuteInputs on 277 | InlineParams off 278 | UseDivisionForNetSlopeComputation "Off" 279 | UseFloatMulNetSlope off 280 | DefaultUnderspecifiedDataType "double" 281 | UseSpecifiedMinMax off 282 | InlineInvariantSignals off 283 | OptimizeBlockIOStorage on 284 | BufferReuse on 285 | EnhancedBackFolding off 286 | CachingGlobalReferences off 287 | GlobalBufferReuse on 288 | StrengthReduction off 289 | ExpressionFolding on 290 | BooleansAsBitfields off 291 | BitfieldContainerType "uint_T" 292 | EnableMemcpy on 293 | MemcpyThreshold 64 294 | PassReuseOutputArgsAs "Structure reference" 295 | ExpressionDepthLimit 128 296 | FoldNonRolledExpr on 297 | LocalBlockOutputs on 298 | RollThreshold 5 299 | SystemCodeInlineAuto off 300 | StateBitsets off 301 | DataBitsets off 302 | ActiveStateOutputEnumStorageType "Native Integer" 303 | UseTempVars off 304 | ZeroExternalMemoryAtStartup on 305 | ZeroInternalMemoryAtStartup on 306 | InitFltsAndDblsToZero off 307 | NoFixptDivByZeroProtection off 308 | EfficientFloat2IntCast off 309 | EfficientMapNaN2IntZero on 310 | OptimizeModelRefInitCode off 311 | LifeSpan "inf" 312 | MaxStackSize "Inherit from target" 313 | BufferReusableBoundary on 314 | SimCompilerOptimization "Off" 315 | AccelVerboseBuild off 316 | ParallelExecutionInRapidAccelerator on 317 | } 318 | Simulink.DebuggingCC { 319 | $ObjectID 11 320 | Version "1.14.3" 321 | RTPrefix "error" 322 | ConsistencyChecking "none" 323 | ArrayBoundsChecking "none" 324 | SignalInfNanChecking "none" 325 | SignalRangeChecking "none" 326 | ReadBeforeWriteMsg "UseLocalSettings" 327 | WriteAfterWriteMsg "UseLocalSettings" 328 | WriteAfterReadMsg "UseLocalSettings" 329 | AlgebraicLoopMsg "warning" 330 | ArtificialAlgebraicLoopMsg "warning" 331 | SaveWithDisabledLinksMsg "warning" 332 | SaveWithParameterizedLinksMsg "none" 333 | CheckSSInitialOutputMsg on 334 | UnderspecifiedInitializationDetection "Classic" 335 | MergeDetectMultiDrivingBlocksExec "none" 336 | CheckExecutionContextPreStartOutputMsg off 337 | CheckExecutionContextRuntimeOutputMsg off 338 | SignalResolutionControl "TryResolveAllWithWarning" 339 | BlockPriorityViolationMsg "warning" 340 | MinStepSizeMsg "warning" 341 | TimeAdjustmentMsg "none" 342 | MaxConsecutiveZCsMsg "error" 343 | MaskedZcDiagnostic "warning" 344 | IgnoredZcDiagnostic "warning" 345 | SolverPrmCheckMsg "none" 346 | InheritedTsInSrcMsg "warning" 347 | DiscreteInheritContinuousMsg "warning" 348 | MultiTaskDSMMsg "warning" 349 | MultiTaskCondExecSysMsg "none" 350 | MultiTaskRateTransMsg "error" 351 | SingleTaskRateTransMsg "none" 352 | TasksWithSamePriorityMsg "warning" 353 | SigSpecEnsureSampleTimeMsg "warning" 354 | CheckMatrixSingularityMsg "none" 355 | IntegerOverflowMsg "warning" 356 | Int32ToFloatConvMsg "warning" 357 | ParameterDowncastMsg "error" 358 | ParameterOverflowMsg "error" 359 | ParameterUnderflowMsg "none" 360 | ParameterPrecisionLossMsg "warning" 361 | ParameterTunabilityLossMsg "warning" 362 | FixptConstUnderflowMsg "none" 363 | FixptConstOverflowMsg "none" 364 | FixptConstPrecisionLossMsg "none" 365 | UnderSpecifiedDataTypeMsg "none" 366 | UnnecessaryDatatypeConvMsg "none" 367 | VectorMatrixConversionMsg "none" 368 | InvalidFcnCallConnMsg "error" 369 | FcnCallInpInsideContextMsg "EnableAllAsError" 370 | SignalLabelMismatchMsg "none" 371 | UnconnectedInputMsg "warning" 372 | UnconnectedOutputMsg "warning" 373 | UnconnectedLineMsg "warning" 374 | SFcnCompatibilityMsg "none" 375 | FrameProcessingCompatibilityMsg "warning" 376 | UniqueDataStoreMsg "none" 377 | BusObjectLabelMismatch "warning" 378 | RootOutportRequireBusObject "warning" 379 | AssertControl "UseLocalSettings" 380 | EnableOverflowDetection off 381 | ModelReferenceIOMsg "none" 382 | ModelReferenceMultiInstanceNormalModeStructChecksumCheck "error" 383 | ModelReferenceVersionMismatchMessage "none" 384 | ModelReferenceIOMismatchMessage "none" 385 | ModelReferenceCSMismatchMessage "none" 386 | UnknownTsInhSupMsg "warning" 387 | ModelReferenceDataLoggingMessage "warning" 388 | ModelReferenceSymbolNameMessage "warning" 389 | ModelReferenceExtraNoncontSigs "error" 390 | StateNameClashWarn "none" 391 | SimStateInterfaceChecksumMismatchMsg "warning" 392 | SimStateOlderReleaseMsg "error" 393 | InitInArrayFormatMsg "warning" 394 | StrictBusMsg "None" 395 | BusNameAdapt "WarnAndRepair" 396 | NonBusSignalsTreatedAsBus "none" 397 | LoggingUnavailableSignals "error" 398 | BlockIODiagnostic "none" 399 | SFUnusedDataAndEventsDiag "warning" 400 | SFUnexpectedBacktrackingDiag "warning" 401 | SFInvalidInputDataAccessInChartInitDiag "warning" 402 | SFNoUnconditionalDefaultTransitionDiag "warning" 403 | SFTransitionOutsideNaturalParentDiag "warning" 404 | SFUnconditionalTransitionShadowingDiag "warning" 405 | SFUndirectedBroadcastEventsDiag "warning" 406 | SFTransitionActionBeforeConditionDiag "warning" 407 | IntegerSaturationMsg "warning" 408 | } 409 | Simulink.HardwareCC { 410 | $ObjectID 12 411 | Version "1.14.3" 412 | ProdBitPerChar 8 413 | ProdBitPerShort 16 414 | ProdBitPerInt 32 415 | ProdBitPerLong 32 416 | ProdBitPerLongLong 64 417 | ProdBitPerFloat 32 418 | ProdBitPerDouble 64 419 | ProdBitPerPointer 32 420 | ProdLargestAtomicInteger "Char" 421 | ProdLargestAtomicFloat "None" 422 | ProdIntDivRoundTo "Undefined" 423 | ProdEndianess "Unspecified" 424 | ProdWordSize 32 425 | ProdShiftRightIntArith on 426 | ProdLongLongMode off 427 | ProdHWDeviceType "32-bit Generic" 428 | TargetBitPerChar 8 429 | TargetBitPerShort 16 430 | TargetBitPerInt 32 431 | TargetBitPerLong 32 432 | TargetBitPerLongLong 64 433 | TargetBitPerFloat 32 434 | TargetBitPerDouble 64 435 | TargetBitPerPointer 32 436 | TargetLargestAtomicInteger "Char" 437 | TargetLargestAtomicFloat "None" 438 | TargetShiftRightIntArith on 439 | TargetLongLongMode off 440 | TargetIntDivRoundTo "Undefined" 441 | TargetEndianess "Unspecified" 442 | TargetWordSize 32 443 | TargetTypeEmulationWarnSuppressLevel 0 444 | TargetPreprocMaxBitsSint 32 445 | TargetPreprocMaxBitsUint 32 446 | TargetHWDeviceType "Specified" 447 | TargetUnknown on 448 | ProdEqTarget on 449 | } 450 | Simulink.ModelReferenceCC { 451 | $ObjectID 13 452 | Version "1.14.3" 453 | UpdateModelReferenceTargets "IfOutOfDateOrStructuralChange" 454 | CheckModelReferenceTargetMessage "error" 455 | EnableParallelModelReferenceBuilds off 456 | ParallelModelReferenceErrorOnInvalidPool on 457 | ParallelModelReferenceMATLABWorkerInit "None" 458 | ModelReferenceNumInstancesAllowed "Multi" 459 | PropagateVarSize "Infer from blocks in model" 460 | ModelReferencePassRootInputsByReference on 461 | ModelReferenceMinAlgLoopOccurrences off 462 | PropagateSignalLabelsOutOfModel off 463 | SupportModelReferenceSimTargetCustomCode off 464 | } 465 | Simulink.SFSimCC { 466 | $ObjectID 14 467 | Version "1.14.3" 468 | SFSimEnableDebug on 469 | SFSimOverflowDetection on 470 | SFSimEcho on 471 | SimBlas on 472 | SimCtrlC on 473 | SimExtrinsic on 474 | SimIntegrity on 475 | SimUseLocalCustomCode off 476 | SimParseCustomCode on 477 | SimBuildMode "sf_incremental_build" 478 | SimGenImportedTypeDefs off 479 | } 480 | Simulink.RTWCC { 481 | $BackupClass "Simulink.RTWCC" 482 | $ObjectID 15 483 | Version "1.14.3" 484 | Array { 485 | Type "Cell" 486 | Dimension 15 487 | Cell "IncludeHyperlinkInReport" 488 | Cell "GenerateTraceInfo" 489 | Cell "GenerateTraceReport" 490 | Cell "GenerateTraceReportSl" 491 | Cell "GenerateTraceReportSf" 492 | Cell "GenerateTraceReportEml" 493 | Cell "PortableWordSizes" 494 | Cell "GenerateWebview" 495 | Cell "GenerateCodeMetricsReport" 496 | Cell "GenerateCodeReplacementReport" 497 | Cell "GenerateErtSFunction" 498 | Cell "CreateSILPILBlock" 499 | Cell "CodeExecutionProfiling" 500 | Cell "CodeProfilingSaveOptions" 501 | Cell "CodeProfilingInstrumentation" 502 | PropName "DisabledProps" 503 | } 504 | SystemTargetFile "grt.tlc" 505 | TLCOptions "" 506 | GenCodeOnly off 507 | MakeCommand "make_rtw" 508 | GenerateMakefile on 509 | PackageGeneratedCodeAndArtifacts off 510 | PackageName "" 511 | TemplateMakefile "grt_default_tmf" 512 | PostCodeGenCommand "" 513 | Description "" 514 | GenerateReport off 515 | SaveLog off 516 | RTWVerbose on 517 | RetainRTWFile off 518 | ProfileTLC off 519 | TLCDebug off 520 | TLCCoverage off 521 | TLCAssert off 522 | ProcessScriptMode "Default" 523 | ConfigurationMode "Optimized" 524 | ProcessScript "" 525 | ConfigurationScript "" 526 | ConfigAtBuild off 527 | RTWUseLocalCustomCode off 528 | RTWUseSimCustomCode off 529 | CustomSourceCode "" 530 | CustomHeaderCode "" 531 | CustomInclude "" 532 | CustomSource "" 533 | CustomLibrary "" 534 | CustomInitializer "" 535 | CustomTerminator "" 536 | Toolchain "Automatically locate an installed toolchain" 537 | BuildConfiguration "Faster Builds" 538 | IncludeHyperlinkInReport off 539 | LaunchReport off 540 | PortableWordSizes off 541 | CreateSILPILBlock "None" 542 | CodeExecutionProfiling off 543 | CodeExecutionProfileVariable "executionProfile" 544 | CodeProfilingSaveOptions "SummaryOnly" 545 | CodeProfilingInstrumentation off 546 | SILDebugging off 547 | TargetLang "C" 548 | IncludeBusHierarchyInRTWFileBlockHierarchyMap off 549 | IncludeERTFirstTime on 550 | GenerateTraceInfo off 551 | GenerateTraceReport off 552 | GenerateTraceReportSl off 553 | GenerateTraceReportSf off 554 | GenerateTraceReportEml off 555 | GenerateCodeInfo off 556 | GenerateWebview off 557 | GenerateCodeMetricsReport off 558 | GenerateCodeReplacementReport off 559 | RTWCompilerOptimization "Off" 560 | RTWCustomCompilerOptimizations "" 561 | CheckMdlBeforeBuild "Off" 562 | CustomRebuildMode "OnUpdate" 563 | DataInitializer "" 564 | SharedConstantsCachingThreshold 1024 565 | Array { 566 | Type "Handle" 567 | Dimension 2 568 | Simulink.CodeAppCC { 569 | $ObjectID 16 570 | Version "1.14.3" 571 | Array { 572 | Type "Cell" 573 | Dimension 24 574 | Cell "IgnoreCustomStorageClasses" 575 | Cell "ParameterTuningSideEffectCode" 576 | Cell "IgnoreTestpoints" 577 | Cell "InsertBlockDesc" 578 | Cell "InsertPolySpaceComments" 579 | Cell "SFDataObjDesc" 580 | Cell "MATLABFcnDesc" 581 | Cell "SimulinkDataObjDesc" 582 | Cell "DefineNamingRule" 583 | Cell "SignalNamingRule" 584 | Cell "ParamNamingRule" 585 | Cell "InternalIdentifier" 586 | Cell "InlinedPrmAccess" 587 | Cell "CustomSymbolStr" 588 | Cell "CustomSymbolStrGlobalVar" 589 | Cell "CustomSymbolStrType" 590 | Cell "CustomSymbolStrField" 591 | Cell "CustomSymbolStrFcn" 592 | Cell "CustomSymbolStrFcnArg" 593 | Cell "CustomSymbolStrBlkIO" 594 | Cell "CustomSymbolStrTmpVar" 595 | Cell "CustomSymbolStrMacro" 596 | Cell "CustomSymbolStrUtil" 597 | Cell "ReqsInCode" 598 | PropName "DisabledProps" 599 | } 600 | ForceParamTrailComments off 601 | GenerateComments on 602 | CommentStyle "Auto" 603 | IgnoreCustomStorageClasses on 604 | IgnoreTestpoints off 605 | IncHierarchyInIds off 606 | MaxIdLength 31 607 | PreserveName off 608 | PreserveNameWithParent off 609 | ShowEliminatedStatement off 610 | OperatorAnnotations off 611 | IncAutoGenComments off 612 | SimulinkDataObjDesc off 613 | SFDataObjDesc off 614 | MATLABFcnDesc off 615 | IncDataTypeInIds off 616 | MangleLength 1 617 | CustomSymbolStrGlobalVar "$R$N$M" 618 | CustomSymbolStrType "$N$R$M_T" 619 | CustomSymbolStrField "$N$M" 620 | CustomSymbolStrFcn "$R$N$M$F" 621 | CustomSymbolStrFcnArg "rt$I$N$M" 622 | CustomSymbolStrBlkIO "rtb_$N$M" 623 | CustomSymbolStrTmpVar "$N$M" 624 | CustomSymbolStrMacro "$R$N$M" 625 | CustomSymbolStrUtil "$N$C" 626 | DefineNamingRule "None" 627 | ParamNamingRule "None" 628 | SignalNamingRule "None" 629 | InsertBlockDesc off 630 | InsertPolySpaceComments off 631 | SimulinkBlockComments on 632 | MATLABSourceComments off 633 | EnableCustomComments off 634 | InternalIdentifier "Shortened" 635 | InlinedPrmAccess "Literals" 636 | ReqsInCode off 637 | UseSimReservedNames off 638 | } 639 | Simulink.GRTTargetCC { 640 | $BackupClass "Simulink.TargetCC" 641 | $ObjectID 17 642 | Version "1.14.3" 643 | Array { 644 | Type "Cell" 645 | Dimension 14 646 | Cell "GeneratePreprocessorConditionals" 647 | Cell "IncludeMdlTerminateFcn" 648 | Cell "CombineOutputUpdateFcns" 649 | Cell "SuppressErrorStatus" 650 | Cell "ERTCustomFileBanners" 651 | Cell "GenerateSampleERTMain" 652 | Cell "GenerateTestInterfaces" 653 | Cell "ModelStepFunctionPrototypeControlCompliant" 654 | Cell "GenerateAllocFcn" 655 | Cell "PurelyIntegerCode" 656 | Cell "SupportComplex" 657 | Cell "SupportAbsoluteTime" 658 | Cell "SupportContinuousTime" 659 | Cell "SupportNonInlinedSFcns" 660 | PropName "DisabledProps" 661 | } 662 | TargetFcnLib "ansi_tfl_table_tmw.mat" 663 | TargetLibSuffix "" 664 | TargetPreCompLibLocation "" 665 | GenFloatMathFcnCalls "NOT IN USE" 666 | TargetLangStandard "C89/C90 (ANSI)" 667 | CodeReplacementLibrary "None" 668 | UtilityFuncGeneration "Auto" 669 | ERTMultiwordTypeDef "System defined" 670 | ERTMultiwordLength 256 671 | MultiwordLength 2048 672 | GenerateFullHeader on 673 | GenerateSampleERTMain off 674 | GenerateTestInterfaces off 675 | ModelReferenceCompliant on 676 | ParMdlRefBuildCompliant on 677 | CompOptLevelCompliant on 678 | ConcurrentExecutionCompliant on 679 | IncludeMdlTerminateFcn on 680 | GeneratePreprocessorConditionals "Disable all" 681 | CombineOutputUpdateFcns off 682 | CombineSignalStateStructs off 683 | SuppressErrorStatus off 684 | ERTFirstTimeCompliant off 685 | IncludeFileDelimiter "Auto" 686 | ERTCustomFileBanners off 687 | SupportAbsoluteTime on 688 | LogVarNameModifier "rt_" 689 | MatFileLogging on 690 | MultiInstanceERTCode off 691 | CodeInterfacePackaging "Nonreusable function" 692 | SupportNonFinite on 693 | SupportComplex on 694 | PurelyIntegerCode off 695 | SupportContinuousTime on 696 | SupportNonInlinedSFcns on 697 | SupportVariableSizeSignals off 698 | EnableShiftOperators on 699 | ParenthesesLevel "Nominal" 700 | CastingMode "Nominal" 701 | MATLABClassNameForMDSCustomization "Simulink.SoftwareTarget.GRTCustomization" 702 | ModelStepFunctionPrototypeControlCompliant off 703 | CPPClassGenCompliant on 704 | AutosarCompliant off 705 | GRTInterface on 706 | GenerateAllocFcn off 707 | GenerateSharedConstants on 708 | UseMalloc off 709 | ExtMode off 710 | ExtModeStaticAlloc off 711 | ExtModeTesting off 712 | ExtModeStaticAllocSize 1000000 713 | ExtModeTransport 0 714 | ExtModeMexFile "ext_comm" 715 | ExtModeIntrfLevel "Level1" 716 | RTWCAPISignals off 717 | RTWCAPIParams off 718 | RTWCAPIStates off 719 | RTWCAPIRootIO off 720 | GenerateASAP2 off 721 | MultiInstanceErrorCode "Error" 722 | } 723 | PropName "Components" 724 | } 725 | } 726 | PropName "Components" 727 | } 728 | Name "Configuration" 729 | CurrentDlgPage "Solver" 730 | ConfigPrmDlgPosition [ 412, 250, 1508, 928 ] 731 | } 732 | PropName "ConfigurationSets" 733 | } 734 | Simulink.ConfigSet { 735 | $PropName "ActiveConfigurationSet" 736 | $ObjectID 7 737 | } 738 | Object { 739 | $PropName "DataTransfer" 740 | $ObjectID 18 741 | $ClassName "Simulink.GlobalDataTransfer" 742 | DefaultTransitionBetweenSyncTasks "Ensure deterministic transfer (maximum delay)" 743 | DefaultTransitionBetweenAsyncTasks "Ensure data integrity only" 744 | DefaultTransitionBetweenContTasks "Ensure deterministic transfer (minimum delay)" 745 | DefaultExtrapolationMethodBetweenContTasks "None" 746 | AutoInsertRateTranBlk [0] 747 | } 748 | ExplicitPartitioning off 749 | BlockDefaults { 750 | ForegroundColor "black" 751 | BackgroundColor "white" 752 | DropShadow off 753 | NamePlacement "normal" 754 | FontName "Helvetica" 755 | FontSize 10 756 | FontWeight "normal" 757 | FontAngle "normal" 758 | ShowName on 759 | BlockRotation 0 760 | BlockMirror off 761 | } 762 | AnnotationDefaults { 763 | HorizontalAlignment "center" 764 | VerticalAlignment "middle" 765 | ForegroundColor "black" 766 | BackgroundColor "white" 767 | DropShadow off 768 | FontName "Helvetica" 769 | FontSize 10 770 | FontWeight "normal" 771 | FontAngle "normal" 772 | UseDisplayTextAsClickCallback off 773 | } 774 | LineDefaults { 775 | FontName "Helvetica" 776 | FontSize 9 777 | FontWeight "normal" 778 | FontAngle "normal" 779 | } 780 | MaskDefaults { 781 | SelfModifiable "off" 782 | IconFrame "on" 783 | IconOpaque "on" 784 | RunInitForIconRedraw "off" 785 | IconRotate "none" 786 | PortRotate "default" 787 | IconUnits "autoscale" 788 | } 789 | MaskParameterDefaults { 790 | Evaluate "on" 791 | Tunable "on" 792 | NeverSave "off" 793 | Internal "off" 794 | ReadOnly "off" 795 | Enabled "on" 796 | Visible "on" 797 | ToolTip "on" 798 | } 799 | BlockParameterDefaults { 800 | Block { 801 | BlockType Inport 802 | Port "1" 803 | OutputFunctionCall off 804 | OutMin "[]" 805 | OutMax "[]" 806 | OutDataTypeStr "Inherit: auto" 807 | LockScale off 808 | BusOutputAsStruct off 809 | PortDimensions "-1" 810 | VarSizeSig "Inherit" 811 | SampleTime "-1" 812 | SignalType "auto" 813 | SamplingMode "auto" 814 | LatchByDelayingOutsideSignal off 815 | LatchInputForFeedbackSignals off 816 | Interpolate on 817 | } 818 | Block { 819 | BlockType Outport 820 | Port "1" 821 | OutMin "[]" 822 | OutMax "[]" 823 | OutDataTypeStr "Inherit: auto" 824 | LockScale off 825 | BusOutputAsStruct off 826 | PortDimensions "-1" 827 | VarSizeSig "Inherit" 828 | SampleTime "-1" 829 | SignalType "auto" 830 | SamplingMode "auto" 831 | SourceOfInitialOutputValue "Dialog" 832 | OutputWhenDisabled "held" 833 | InitialOutput "[]" 834 | } 835 | Block { 836 | BlockType S-Function 837 | FunctionName "system" 838 | SFunctionModules "''" 839 | PortCounts "[]" 840 | SFunctionDeploymentMode off 841 | } 842 | } 843 | System { 844 | Name "tesys" 845 | Location [450, 52, 1086, 537] 846 | Open on 847 | ModelBrowserVisibility off 848 | ModelBrowserWidth 200 849 | ScreenColor "white" 850 | PaperOrientation "landscape" 851 | PaperPositionMode "auto" 852 | PaperType "usletter" 853 | PaperUnits "inches" 854 | TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000] 855 | TiledPageScale 1 856 | ShowPageBoundaries off 857 | ZoomFactor "100" 858 | ReportName "simulink-default.rpt" 859 | SIDHighWatermark "3" 860 | Block { 861 | BlockType Inport 862 | Name "In1" 863 | SID "1" 864 | Position [210, 113, 240, 127] 865 | ZOrder -1 866 | IconDisplay "Port number" 867 | } 868 | Block { 869 | BlockType S-Function 870 | Name "TE Code" 871 | SID "2" 872 | Ports [1, 1] 873 | Position [280, 105, 355, 135] 874 | ZOrder -2 875 | FunctionName "temexd_mod" 876 | Parameters "[], [], 0" 877 | EnableBusSupport off 878 | } 879 | Block { 880 | BlockType Outport 881 | Name "Out1" 882 | SID "3" 883 | Position [405, 113, 435, 127] 884 | ZOrder -3 885 | IconDisplay "Port number" 886 | } 887 | Line { 888 | ZOrder 1 889 | SrcBlock "In1" 890 | SrcPort 1 891 | DstBlock "TE Code" 892 | DstPort 1 893 | } 894 | Line { 895 | ZOrder 2 896 | SrcBlock "TE Code" 897 | SrcPort 1 898 | DstBlock "Out1" 899 | DstPort 1 900 | } 901 | } 902 | } 903 | --------------------------------------------------------------------------------