├── +AUTOSAR4 ├── @Parameter │ └── Parameter.m ├── @Signal │ └── Signal.m └── csc_registration.m ├── .gitignore ├── Autosar_configuration.m ├── ERT_configuration.m ├── LICENSE ├── README.MD ├── add_sig_parameter.m ├── auto_sf_par_type.m ├── change_parameter.m ├── change_port_property.m ├── clear_propagate.m ├── clear_resolve.m ├── creat_all_in_one_file.py ├── creat_p_files.m ├── default_port_property.m ├── fix_stateflow_parameter_type.m ├── git命令大全.txt ├── hide_name_blocks.m ├── hide_name_ports.m ├── list_parameter.m ├── propagate_signals.m ├── rename_port_to_sig.m ├── rename_sig_to_port.m ├── resolve_signals.m ├── select_c_h.py ├── show_name_blocks.m ├── show_name_ports.m ├── test_case_convert.py ├── toto.fig ├── toto.m ├── toto.mlappinstall ├── 基于Autosar的模型配置说明文档.md └── 调试记录.md /+AUTOSAR4/@Parameter/Parameter.m: -------------------------------------------------------------------------------- 1 | classdef Parameter < Simulink.Parameter 2 | %SimulinkDemos.Parameter Class definition. 3 | 4 | % Copyright 2009-2013 The MathWorks, Inc. 5 | 6 | properties 7 | GenericProperty = []; 8 | end 9 | 10 | properties(PropertyType = 'double scalar') 11 | DoubleProperty = 0; 12 | end 13 | 14 | properties(PropertyType = 'int32 scalar') 15 | Int32Property = int32(0); 16 | end 17 | 18 | properties(PropertyType = 'logical scalar') 19 | LogicalProperty = false; 20 | end 21 | 22 | properties(PropertyType = 'char') 23 | StringProperty = ''; 24 | end 25 | 26 | properties(PropertyType = 'char', AllowedValues = {'on'; 'off'}) 27 | OnOffStringProperty = 'off'; 28 | end 29 | 30 | properties(PropertyType = 'char', ... 31 | AllowedValues = {'red'; 'green'; 'blue'; 'white'; 'black'}) 32 | ColorStringProperty = 'red'; 33 | end 34 | 35 | %--------------------------------------------------------------------------- 36 | % NOTE: 37 | % ----- 38 | % By default this class will use the custom storage classes from its 39 | % superclass. To define your own custom storage classes: 40 | % - Uncomment the following method and specify the correct package name. 41 | % - Launch the cscdesigner for this package. 42 | % >> cscdesigner('AUTOSAR4'); 43 | % 44 | methods 45 | function setupCoderInfo(h) 46 | % Use custom storage classes from this package 47 | useLocalCustomStorageClasses(h, 'AUTOSAR4'); 48 | end 49 | end % methods 50 | 51 | methods 52 | %--------------------------------------------------------------------------- 53 | function h = Parameter(varargin) 54 | %PARAMETER Class constructor. 55 | 56 | % Call superclass constructor with variable arguments 57 | h@Simulink.Parameter(varargin{:}); 58 | end % End of constructor 59 | 60 | end % End of Public methods 61 | 62 | methods (Access=protected) 63 | %--------------------------------------------------------------------------- 64 | function retVal = copyElement(obj) 65 | %COPYELEMENT Define special copy behavior for properties of this class. 66 | % See matlab.mixin.Copyable for more details. 67 | retVal = copyElement@Simulink.Parameter(obj); 68 | if isobject(obj.GenericProperty) 69 | retVal.GenericProperty = copy(obj.GenericProperty); 70 | end 71 | end 72 | end % Protected methods 73 | 74 | end % classdef 75 | -------------------------------------------------------------------------------- /+AUTOSAR4/@Signal/Signal.m: -------------------------------------------------------------------------------- 1 | classdef Signal < Simulink.Signal 2 | %SimulinkDemos.Signal Class definition. 3 | 4 | % Copyright 2009-2013 The MathWorks, Inc. 5 | 6 | properties 7 | GenericProperty = []; 8 | end 9 | 10 | properties(PropertyType = 'double scalar') 11 | DoubleProperty = 0; 12 | end 13 | 14 | properties(PropertyType = 'int32 scalar') 15 | Int32Property = int32(0); 16 | end 17 | 18 | properties(PropertyType = 'logical scalar') 19 | LogicalProperty = false; 20 | end 21 | 22 | properties(PropertyType = 'char') 23 | StringProperty = ''; 24 | end 25 | 26 | properties(PropertyType = 'char', AllowedValues = {'on'; 'off'}) 27 | OnOffStringProperty = 'off'; 28 | end 29 | 30 | properties(PropertyType = 'char', ... 31 | AllowedValues = {'red'; 'green'; 'blue'; 'white'; 'black'}) 32 | ColorStringProperty = 'red'; 33 | end 34 | 35 | %--------------------------------------------------------------------------- 36 | % NOTE: 37 | % ----- 38 | % By default this class will use the custom storage classes from its 39 | % superclass. To define your own custom storage classes: 40 | % - Uncomment the following method and specify the correct package name. 41 | % - Launch the cscdesigner for this package. 42 | % >> cscdesigner('AUTOSAR4'); 43 | % 44 | methods 45 | function setupCoderInfo(h) 46 | % Use custom storage classes from this package 47 | useLocalCustomStorageClasses(h, 'AUTOSAR4'); 48 | end 49 | end % methods 50 | 51 | methods (Access=protected) 52 | %--------------------------------------------------------------------------- 53 | function retVal = copyElement(obj) 54 | %COPYELEMENT Define special copy behavior for properties of this class. 55 | % See matlab.mixin.Copyable for more details. 56 | retVal = copyElement@Simulink.Signal(obj); 57 | if isobject(obj.GenericProperty) 58 | retVal.GenericProperty = copy(obj.GenericProperty); 59 | end 60 | end 61 | end % Protected methods 62 | 63 | methods 64 | 65 | function h = Signal() 66 | % SIGNAL Class constructor. 67 | end % End of Constructor 68 | 69 | end % End of Public methods 70 | end % classdef 71 | -------------------------------------------------------------------------------- /+AUTOSAR4/csc_registration.m: -------------------------------------------------------------------------------- 1 | function defs = csc_registration(action) 2 | 3 | % Copyright 1994-2021 The MathWorks, Inc. 4 | % $Revision: $ $Date: $ 5 | 6 | 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 | % NOTE: 9 | % - This file was automatically generated by the Simulink custom storage class 10 | % designer. 11 | % - The contents of this file are arranged so that the Simulink custom storage 12 | % class designer can load the associated classes for editing. 13 | % - Hand modification of this file is not recommended as it may prevent the 14 | % Simulink custom storage class designer from loading the associated classes. 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % - Generated on: 28-Oct-2021 17:20:33 17 | % - MATLAB version: 9.3.0.713579 (R2017b) 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | 20 | 21 | switch action 22 | 23 | case 'CSCDefn' 24 | defs = []; 25 | 26 | h = Simulink.CSCDefn; 27 | set(h, 'Name', 'StaticNoIRam'); 28 | set(h, 'OwnerPackage', 'AUTOSAR4'); 29 | set(h, 'CSCType', 'Unstructured'); 30 | set(h, 'MemorySection', 'APP_NOIRAM'); 31 | set(h, 'IsMemorySectionInstanceSpecific', false); 32 | set(h, 'IsGrouped', false); 33 | set(h.DataUsage, 'IsParameter', true); 34 | set(h.DataUsage, 'IsSignal', true); 35 | set(h, 'DataScope', 'Exported'); 36 | set(h, 'IsDataScopeInstanceSpecific', false); 37 | set(h, 'IsAutosarPerInstanceMemory', false); 38 | set(h, 'DataInit', 'None'); 39 | set(h, 'IsDataInitInstanceSpecific', false); 40 | set(h, 'DataAccess', 'Direct'); 41 | set(h, 'IsDataAccessInstanceSpecific', false); 42 | set(h, 'HeaderFile', ''); 43 | set(h, 'IsHeaderFileInstanceSpecific', true); 44 | set(h, 'DefinitionFile', ''); 45 | set(h, 'IsDefinitionFileInstanceSpecific', false); 46 | set(h, 'Owner', ''); 47 | set(h, 'IsOwnerInstanceSpecific', false); 48 | set(h, 'IsReusable', false); 49 | set(h, 'IsReusableInstanceSpecific', false); 50 | set(h, 'CommentSource', 'Default'); 51 | set(h, 'TypeComment', ''); 52 | set(h, 'DeclareComment', ''); 53 | set(h, 'DefineComment', ''); 54 | set(h, 'CSCTypeAttributesClassName', ''); 55 | set(h, 'CSCTypeAttributes', []); 56 | set(h, 'TLCFileName', 'Unstructured.tlc'); 57 | defs = [defs; h]; 58 | 59 | h = Simulink.CSCDefn; 60 | set(h, 'Name', 'CalData'); 61 | set(h, 'OwnerPackage', 'AUTOSAR4'); 62 | set(h, 'CSCType', 'Unstructured'); 63 | set(h, 'MemorySection', 'APP_CAL'); 64 | set(h, 'IsMemorySectionInstanceSpecific', false); 65 | set(h, 'IsGrouped', false); 66 | set(h.DataUsage, 'IsParameter', true); 67 | set(h.DataUsage, 'IsSignal', false); 68 | set(h, 'DataScope', 'Exported'); 69 | set(h, 'IsDataScopeInstanceSpecific', false); 70 | set(h, 'IsAutosarPerInstanceMemory', false); 71 | set(h, 'DataInit', 'Auto'); 72 | set(h, 'IsDataInitInstanceSpecific', false); 73 | set(h, 'DataAccess', 'Direct'); 74 | set(h, 'IsDataAccessInstanceSpecific', false); 75 | set(h, 'HeaderFile', ''); 76 | set(h, 'IsHeaderFileInstanceSpecific', true); 77 | set(h, 'DefinitionFile', ''); 78 | set(h, 'IsDefinitionFileInstanceSpecific', false); 79 | set(h, 'Owner', ''); 80 | set(h, 'IsOwnerInstanceSpecific', true); 81 | set(h, 'IsReusable', false); 82 | set(h, 'IsReusableInstanceSpecific', false); 83 | set(h, 'CommentSource', 'Default'); 84 | set(h, 'TypeComment', ''); 85 | set(h, 'DeclareComment', ''); 86 | set(h, 'DefineComment', ''); 87 | set(h, 'CSCTypeAttributesClassName', ''); 88 | set(h, 'CSCTypeAttributes', []); 89 | set(h, 'TLCFileName', 'Unstructured.tlc'); 90 | defs = [defs; h]; 91 | 92 | h = Simulink.CSCDefn; 93 | set(h, 'Name', 'StaticNoIRamSafe'); 94 | set(h, 'OwnerPackage', 'AUTOSAR4'); 95 | set(h, 'CSCType', 'Unstructured'); 96 | set(h, 'MemorySection', 'APP_NOIRAM_SAFE'); 97 | set(h, 'IsMemorySectionInstanceSpecific', false); 98 | set(h, 'IsGrouped', false); 99 | set(h.DataUsage, 'IsParameter', true); 100 | set(h.DataUsage, 'IsSignal', true); 101 | set(h, 'DataScope', 'Exported'); 102 | set(h, 'IsDataScopeInstanceSpecific', false); 103 | set(h, 'IsAutosarPerInstanceMemory', false); 104 | set(h, 'DataInit', 'None'); 105 | set(h, 'IsDataInitInstanceSpecific', false); 106 | set(h, 'DataAccess', 'Direct'); 107 | set(h, 'IsDataAccessInstanceSpecific', false); 108 | set(h, 'HeaderFile', ''); 109 | set(h, 'IsHeaderFileInstanceSpecific', false); 110 | set(h, 'DefinitionFile', ''); 111 | set(h, 'IsDefinitionFileInstanceSpecific', false); 112 | set(h, 'Owner', ''); 113 | set(h, 'IsOwnerInstanceSpecific', false); 114 | set(h, 'IsReusable', false); 115 | set(h, 'IsReusableInstanceSpecific', false); 116 | set(h, 'CommentSource', 'Default'); 117 | set(h, 'TypeComment', ''); 118 | set(h, 'DeclareComment', ''); 119 | set(h, 'DefineComment', ''); 120 | set(h, 'CSCTypeAttributesClassName', ''); 121 | set(h, 'CSCTypeAttributes', []); 122 | set(h, 'TLCFileName', 'Unstructured.tlc'); 123 | defs = [defs; h]; 124 | 125 | h = Simulink.CSCDefn; 126 | set(h, 'Name', 'GlobalDisp'); 127 | set(h, 'OwnerPackage', 'AUTOSAR4'); 128 | set(h, 'CSCType', 'Unstructured'); 129 | set(h, 'MemorySection', 'APP_DISP'); 130 | set(h, 'IsMemorySectionInstanceSpecific', false); 131 | set(h, 'IsGrouped', false); 132 | set(h.DataUsage, 'IsParameter', false); 133 | set(h.DataUsage, 'IsSignal', true); 134 | set(h, 'DataScope', 'Exported'); 135 | set(h, 'IsDataScopeInstanceSpecific', false); 136 | set(h, 'IsAutosarPerInstanceMemory', false); 137 | set(h, 'DataInit', 'Auto'); 138 | set(h, 'IsDataInitInstanceSpecific', false); 139 | set(h, 'DataAccess', 'Direct'); 140 | set(h, 'IsDataAccessInstanceSpecific', false); 141 | set(h, 'HeaderFile', ''); 142 | set(h, 'IsHeaderFileInstanceSpecific', true); 143 | set(h, 'DefinitionFile', ''); 144 | set(h, 'IsDefinitionFileInstanceSpecific', true); 145 | set(h, 'Owner', ''); 146 | set(h, 'IsOwnerInstanceSpecific', true); 147 | set(h, 'IsReusable', false); 148 | set(h, 'IsReusableInstanceSpecific', true); 149 | set(h, 'CommentSource', 'Default'); 150 | set(h, 'TypeComment', ''); 151 | set(h, 'DeclareComment', ''); 152 | set(h, 'DefineComment', ''); 153 | set(h, 'CSCTypeAttributesClassName', ''); 154 | set(h, 'CSCTypeAttributes', []); 155 | set(h, 'TLCFileName', 'Unstructured.tlc'); 156 | defs = [defs; h]; 157 | 158 | h = Simulink.CSCDefn; 159 | set(h, 'Name', 'GlobalDispSafe'); 160 | set(h, 'OwnerPackage', 'AUTOSAR4'); 161 | set(h, 'CSCType', 'Unstructured'); 162 | set(h, 'MemorySection', 'APP_DISP_SAFE'); 163 | set(h, 'IsMemorySectionInstanceSpecific', false); 164 | set(h, 'IsGrouped', false); 165 | set(h.DataUsage, 'IsParameter', false); 166 | set(h.DataUsage, 'IsSignal', true); 167 | set(h, 'DataScope', 'Exported'); 168 | set(h, 'IsDataScopeInstanceSpecific', false); 169 | set(h, 'IsAutosarPerInstanceMemory', false); 170 | set(h, 'DataInit', 'Auto'); 171 | set(h, 'IsDataInitInstanceSpecific', false); 172 | set(h, 'DataAccess', 'Direct'); 173 | set(h, 'IsDataAccessInstanceSpecific', false); 174 | set(h, 'HeaderFile', ''); 175 | set(h, 'IsHeaderFileInstanceSpecific', true); 176 | set(h, 'DefinitionFile', ''); 177 | set(h, 'IsDefinitionFileInstanceSpecific', true); 178 | set(h, 'Owner', ''); 179 | set(h, 'IsOwnerInstanceSpecific', true); 180 | set(h, 'IsReusable', false); 181 | set(h, 'IsReusableInstanceSpecific', true); 182 | set(h, 'CommentSource', 'Default'); 183 | set(h, 'TypeComment', ''); 184 | set(h, 'DeclareComment', ''); 185 | set(h, 'DefineComment', ''); 186 | set(h, 'CSCTypeAttributesClassName', ''); 187 | set(h, 'CSCTypeAttributes', []); 188 | set(h, 'TLCFileName', 'Unstructured.tlc'); 189 | defs = [defs; h]; 190 | 191 | h = Simulink.CSCDefn; 192 | set(h, 'Name', 'GlobalNvm'); 193 | set(h, 'OwnerPackage', 'AUTOSAR4'); 194 | set(h, 'CSCType', 'Unstructured'); 195 | set(h, 'MemorySection', 'APP_NVM'); 196 | set(h, 'IsMemorySectionInstanceSpecific', false); 197 | set(h, 'IsGrouped', false); 198 | set(h.DataUsage, 'IsParameter', true); 199 | set(h.DataUsage, 'IsSignal', true); 200 | set(h, 'DataScope', 'Exported'); 201 | set(h, 'IsDataScopeInstanceSpecific', false); 202 | set(h, 'IsAutosarPerInstanceMemory', false); 203 | set(h, 'DataInit', 'Auto'); 204 | set(h, 'IsDataInitInstanceSpecific', false); 205 | set(h, 'DataAccess', 'Direct'); 206 | set(h, 'IsDataAccessInstanceSpecific', false); 207 | set(h, 'HeaderFile', ''); 208 | set(h, 'IsHeaderFileInstanceSpecific', true); 209 | set(h, 'DefinitionFile', ''); 210 | set(h, 'IsDefinitionFileInstanceSpecific', true); 211 | set(h, 'Owner', ''); 212 | set(h, 'IsOwnerInstanceSpecific', true); 213 | set(h, 'IsReusable', false); 214 | set(h, 'IsReusableInstanceSpecific', false); 215 | set(h, 'CommentSource', 'Default'); 216 | set(h, 'TypeComment', ''); 217 | set(h, 'DeclareComment', ''); 218 | set(h, 'DefineComment', ''); 219 | set(h, 'CSCTypeAttributesClassName', ''); 220 | set(h, 'CSCTypeAttributes', []); 221 | set(h, 'TLCFileName', 'Unstructured.tlc'); 222 | defs = [defs; h]; 223 | 224 | h = Simulink.CSCDefn; 225 | set(h, 'Name', 'GlobalNvmSafe'); 226 | set(h, 'OwnerPackage', 'AUTOSAR4'); 227 | set(h, 'CSCType', 'Unstructured'); 228 | set(h, 'MemorySection', 'APP_NVM_SAFE'); 229 | set(h, 'IsMemorySectionInstanceSpecific', false); 230 | set(h, 'IsGrouped', false); 231 | set(h.DataUsage, 'IsParameter', true); 232 | set(h.DataUsage, 'IsSignal', true); 233 | set(h, 'DataScope', 'Exported'); 234 | set(h, 'IsDataScopeInstanceSpecific', false); 235 | set(h, 'IsAutosarPerInstanceMemory', false); 236 | set(h, 'DataInit', 'Auto'); 237 | set(h, 'IsDataInitInstanceSpecific', false); 238 | set(h, 'DataAccess', 'Direct'); 239 | set(h, 'IsDataAccessInstanceSpecific', false); 240 | set(h, 'HeaderFile', ''); 241 | set(h, 'IsHeaderFileInstanceSpecific', true); 242 | set(h, 'DefinitionFile', ''); 243 | set(h, 'IsDefinitionFileInstanceSpecific', true); 244 | set(h, 'Owner', ''); 245 | set(h, 'IsOwnerInstanceSpecific', true); 246 | set(h, 'IsReusable', false); 247 | set(h, 'IsReusableInstanceSpecific', false); 248 | set(h, 'CommentSource', 'Default'); 249 | set(h, 'TypeComment', ''); 250 | set(h, 'DeclareComment', ''); 251 | set(h, 'DefineComment', ''); 252 | set(h, 'CSCTypeAttributesClassName', ''); 253 | set(h, 'CSCTypeAttributes', []); 254 | set(h, 'TLCFileName', 'Unstructured.tlc'); 255 | defs = [defs; h]; 256 | 257 | h = Simulink.CSCDefn; 258 | set(h, 'Name', 'Custom'); 259 | set(h, 'OwnerPackage', 'AUTOSAR4'); 260 | set(h, 'CSCType', 'Unstructured'); 261 | set(h, 'MemorySection', 'Default'); 262 | set(h, 'IsMemorySectionInstanceSpecific', true); 263 | set(h, 'IsGrouped', false); 264 | set(h.DataUsage, 'IsParameter', true); 265 | set(h.DataUsage, 'IsSignal', true); 266 | set(h, 'DataScope', 'Auto'); 267 | set(h, 'IsDataScopeInstanceSpecific', false); 268 | set(h, 'IsAutosarPerInstanceMemory', false); 269 | set(h, 'DataInit', 'Auto'); 270 | set(h, 'IsDataInitInstanceSpecific', false); 271 | set(h, 'DataAccess', 'Direct'); 272 | set(h, 'IsDataAccessInstanceSpecific', false); 273 | set(h, 'HeaderFile', ''); 274 | set(h, 'IsHeaderFileInstanceSpecific', true); 275 | set(h, 'DefinitionFile', ''); 276 | set(h, 'IsDefinitionFileInstanceSpecific', false); 277 | set(h, 'Owner', ''); 278 | set(h, 'IsOwnerInstanceSpecific', false); 279 | set(h, 'IsReusable', false); 280 | set(h, 'IsReusableInstanceSpecific', false); 281 | set(h, 'CommentSource', 'Default'); 282 | set(h, 'TypeComment', ''); 283 | set(h, 'DeclareComment', ''); 284 | set(h, 'DefineComment', ''); 285 | set(h, 'CSCTypeAttributesClassName', ''); 286 | set(h, 'CSCTypeAttributes', []); 287 | set(h, 'TLCFileName', 'Unstructured.tlc'); 288 | defs = [defs; h]; 289 | 290 | case 'MemorySectionDefn' 291 | defs = []; 292 | 293 | h = Simulink.MemorySectionRefDefn; 294 | set(h, 'Name', 'APP_RUN'); 295 | set(h, 'OwnerPackage', 'AUTOSAR4'); 296 | set(h, 'RefPackageName', 'AUTOSAR'); 297 | set(h, 'RefDefnName', 'SwAddrMethod'); 298 | defs = [defs; h]; 299 | 300 | h = Simulink.MemorySectionRefDefn; 301 | set(h, 'Name', 'APP_RUN_SAFE'); 302 | set(h, 'OwnerPackage', 'AUTOSAR4'); 303 | set(h, 'RefPackageName', 'AUTOSAR'); 304 | set(h, 'RefDefnName', 'SwAddrMethod'); 305 | defs = [defs; h]; 306 | 307 | h = Simulink.MemorySectionRefDefn; 308 | set(h, 'Name', 'APP_NOIRAM'); 309 | set(h, 'OwnerPackage', 'AUTOSAR4'); 310 | set(h, 'RefPackageName', 'AUTOSAR'); 311 | set(h, 'RefDefnName', 'SwAddrMethod'); 312 | defs = [defs; h]; 313 | 314 | h = Simulink.MemorySectionRefDefn; 315 | set(h, 'Name', 'APP_NOIRAM_SAFE'); 316 | set(h, 'OwnerPackage', 'AUTOSAR4'); 317 | set(h, 'RefPackageName', 'AUTOSAR'); 318 | set(h, 'RefDefnName', 'SwAddrMethod'); 319 | defs = [defs; h]; 320 | 321 | h = Simulink.MemorySectionRefDefn; 322 | set(h, 'Name', 'APP_NVM'); 323 | set(h, 'OwnerPackage', 'AUTOSAR4'); 324 | set(h, 'RefPackageName', 'AUTOSAR'); 325 | set(h, 'RefDefnName', 'SwAddrMethod'); 326 | defs = [defs; h]; 327 | 328 | h = Simulink.MemorySectionRefDefn; 329 | set(h, 'Name', 'APP_NVM_SAFE'); 330 | set(h, 'OwnerPackage', 'AUTOSAR4'); 331 | set(h, 'RefPackageName', 'Simulink'); 332 | set(h, 'RefDefnName', 'Default'); 333 | defs = [defs; h]; 334 | 335 | h = Simulink.MemorySectionRefDefn; 336 | set(h, 'Name', 'APP_DISP'); 337 | set(h, 'OwnerPackage', 'AUTOSAR4'); 338 | set(h, 'RefPackageName', 'AUTOSAR'); 339 | set(h, 'RefDefnName', 'SwAddrMethod'); 340 | defs = [defs; h]; 341 | 342 | h = Simulink.MemorySectionRefDefn; 343 | set(h, 'Name', 'APP_CAL'); 344 | set(h, 'OwnerPackage', 'AUTOSAR4'); 345 | set(h, 'RefPackageName', 'AUTOSAR'); 346 | set(h, 'RefDefnName', 'SwAddrMethod_Const_Volatile'); 347 | defs = [defs; h]; 348 | 349 | h = Simulink.MemorySectionRefDefn; 350 | set(h, 'Name', 'APP_DISP_SAFE'); 351 | set(h, 'OwnerPackage', 'AUTOSAR4'); 352 | set(h, 'RefPackageName', 'AUTOSAR'); 353 | set(h, 'RefDefnName', 'SwAddrMethod'); 354 | defs = [defs; h]; 355 | 356 | otherwise 357 | DAStudio.error('Simulink:dialog:CSCRegInvalidAction', action); 358 | end % switch action 359 | 360 | 361 | %EOF 362 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore these files 2 | *.p 3 | *.jpg 4 | *.JPG 5 | *.prj 6 | *.PNG 7 | *.png 8 | 9 | # ignore these floder 10 | package 11 | toto_resources 12 | toto_gui_linux 13 | toto_gui_windows 14 | -------------------------------------------------------------------------------- /Autosar_configuration.m: -------------------------------------------------------------------------------- 1 | %--------------------------------------------------------------------------- 2 | % Simulink scrip for Autosar configuration set 3 | % MATLAB version: R2017a 4 | % Please read the document <基于Autosar配置说明文档 v0.9> to learn details. 5 | % Shibo Jiang 2018/11/3 6 | % Version: 1.3 7 | % Instructions: Run this scrip in matlab command,and one model should be 8 | % opened at least. 9 | %--------------------------------------------------------------------------- 10 | 11 | function Configurate = Autosar_configuration() 12 | 13 | paraModel = bdroot; 14 | 15 | % Original matalb version is R2017a 16 | % 检查Matlab版本是否为R2017a 17 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 18 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 19 | CurrentVersion = version; 20 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 21 | strcmp(CorrectVersion_linux, CurrentVersion)) 22 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 23 | end 24 | 25 | 26 | % Original environment character encoding: GBK 27 | % 脚本编码环境是否为GBK 28 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 29 | % warning('Simulink:EncodingUnMatched', 'The target character... 30 | % encoding (%s) is different from the original (%s).',... 31 | % get_param(0, 'CharacterEncoding'), 'GBK'); 32 | % end 33 | 34 | % Original configuration set target is autosar.tlc 35 | % 将代码生成目标模板设置为 autosar.tlc 36 | myConfigObj=getActiveConfigSet(paraModel); 37 | try 38 | switchTarget(myConfigObj, 'autosar.tlc', ''); 39 | catch 40 | disp(ME.message); 41 | disp('Setting ''System target file'' to ''ert.tlc''.'); 42 | switchTarget(myConfigObj, 'ert.tlc', ''); 43 | end 44 | 45 | % Set [Display > Signals & Ports > Wide Nonscalar Lines] as on 46 | set_param(paraModel, 'WideLines', 'on'); 47 | % Set [Display > Signals & Ports > Viewer Indicator] as on 48 | set_param(paraModel, 'ShowViewerIcons', 'on'); 49 | % Set [Display > Signals & Ports > Test point & Logging Indicator] as on 50 | set_param(paraModel, 'ShowTestPointIcons', 'on'); 51 | % Set [Display > Signals & Ports > Linearization Indicators] as on 52 | set_param(paraModel, 'ShowLinearizationAnnotations', 'on'); 53 | % Set [Display > Library Links] as none 54 | set_param(paraModel,'LibraryLinkDisplay', 'none'); 55 | % Set font style as Arial 56 | set_param(paraModel,'DefaultAnnotationFontName', 'Arial'); 57 | set_param(paraModel,'DefaultBlockFontName', 'Arial'); 58 | set_param(paraModel,'DefaultLineFontName', 'Arial'); 59 | 60 | set_param(paraModel,'DefaultAnnotationFontSize', '10'); 61 | set_param(paraModel,'DefaultBlockFontSize', '10'); 62 | set_param(paraModel,'DefaultLineFontSize', '10'); 63 | 64 | % Do not change the order of the following commands. There are dependencies between the parameters. 65 | % 不要修改如下命令行的顺序,相互之间有依赖关系 66 | 67 | set_param(paraModel, 'HardwareBoard', 'None'); % Hardware board 68 | 69 | % Solver 70 | set_param(paraModel, 'StartTime', '0.0'); % Start time 71 | set_param(paraModel, 'StopTime', '10'); % Stop time 72 | set_param(paraModel, 'SolverType', 'Fixed-step'); % Type 73 | set_param(paraModel, 'EnableConcurrentExecution', 'off'); % Show concurrent execution options 74 | set_param(paraModel, 'SampleTimeConstraint', 'Unconstrained'); % Periodic sample time constraint 75 | set_param(paraModel, 'Solver', 'FixedStepDiscrete'); % Solver 76 | set_param(paraModel, 'FixedStep', 'auto'); % Fixed-step size (fundamental sample time) 77 | set_param(paraModel, 'EnableMultiTasking', 'on'); % Treat each discrete rate as a separate task 78 | set_param(paraModel, 'AutoInsertRateTranBlk', 'off'); % Automatically handle rate transition for data transfer 79 | set_param(paraModel, 'PositivePriorityOrder', 'off'); % Higher priority value indicates higher task priority 80 | 81 | % Data Import/Export 82 | set_param(paraModel, 'LoadExternalInput', 'off'); % Load external input 83 | set_param(paraModel, 'LoadInitialState', 'off'); % Load initial state 84 | set_param(paraModel, 'SaveTime', 'off'); % Save time 85 | set_param(paraModel, 'SaveState', 'off'); % Save states 86 | set_param(paraModel, 'SaveFormat', 'Dataset'); % Format 87 | set_param(paraModel, 'SaveOutput', 'off'); % Save output 88 | set_param(paraModel, 'SaveFinalState', 'off'); % Save final state 89 | set_param(paraModel, 'SignalLogging', 'on'); % Signal logging 90 | set_param(paraModel, 'SignalLoggingName', 'logsout'); % Signal logging name 91 | set_param(paraModel, 'DSMLogging', 'on'); % Data stores 92 | set_param(paraModel, 'DSMLoggingName', 'dsmout'); % Data stores logging name 93 | set_param(paraModel, 'LoggingToFile', 'off'); % Log Dataset data to file 94 | set_param(paraModel, 'DatasetSignalFormat', 'timeseries'); % DatasetSignalFormat 95 | set_param(paraModel, 'ReturnWorkspaceOutputs', 'off'); % Single simulation output 96 | set_param(paraModel, 'InspectSignalLogs', 'off'); % Record logged workspace data in Simulation Data Inspector 97 | set_param(paraModel, 'LimitDataPoints', 'on'); % Limit data points 98 | set_param(paraModel, 'MaxDataPoints', '1000'); % Maximum number of data points 99 | set_param(paraModel, 'Decimation', '1'); % Decimation 100 | 101 | % Optimization 102 | set_param(paraModel, 'BlockReduction', 'on'); % Block reduction 103 | set_param(paraModel, 'ConditionallyExecuteInputs', 'on'); % Conditional input branch execution 104 | set_param(paraModel, 'BooleanDataType', 'on'); % Implement logic signals as Boolean data (vs. double) 105 | set_param(paraModel, 'LifeSpan', 'inf'); % Application lifespan (days) 106 | set_param(paraModel, 'UseDivisionForNetSlopeComputation', 'on'); % Use division for fixed-point net slope computation 107 | set_param(paraModel, 'UseFloatMulNetSlope', 'off'); % Use floating-point multiplication to handle net slope corrections 108 | set_param(paraModel, 'DefaultUnderspecifiedDataType', 'single'); % Default for underspecified data type 109 | set_param(paraModel, 'UseSpecifiedMinMax', 'off'); % Optimize using the specified minimum and maximum values 110 | set_param(paraModel, 'ZeroExternalMemoryAtStartup', 'off'); % Remove root level I/O zero initialization 111 | set_param(paraModel, 'InitFltsAndDblsToZero', 'off'); % Use memset to initialize floats and doubles to 0.0 112 | set_param(paraModel, 'ZeroInternalMemoryAtStartup', 'on'); % Remove internal data zero initialization 113 | set_param(paraModel, 'EfficientFloat2IntCast', 'on'); % Remove code from floating-point to integer conversions that wraps out-of-range values 114 | set_param(paraModel, 'EfficientMapNaN2IntZero', 'off'); % Remove code from floating-point to integer conversions with saturation that maps NaN to zero 115 | set_param(paraModel, 'NoFixptDivByZeroProtection', 'off'); % Remove code that protects against division arithmetic exceptions 116 | set_param(paraModel, 'SimCompilerOptimization', 'off'); % Compiler optimization level 117 | set_param(paraModel, 'AccelVerboseBuild', 'off'); % Verbose accelerator builds 118 | set_param(paraModel, 'DefaultParameterBehavior', 'Inlined'); % Default parameter behavior 119 | set_param(paraModel, 'OptimizeBlockIOStorage', 'on'); % Signal storage reuse 120 | set_param(paraModel, 'LocalBlockOutputs', 'on'); % Enable local block outputs 121 | set_param(paraModel, 'ExpressionFolding', 'on'); % Eliminate superfluous local variables (expression folding) 122 | set_param(paraModel, 'BufferReuse', 'on'); % Reuse local block outputs 123 | set_param(paraModel, 'GlobalBufferReuse', 'on'); % Reuse global block outputs 124 | set_param(paraModel, 'GlobalVariableUsage', 'Use global to hold temporary results'); % Optimize global data access 125 | set_param(paraModel, 'OptimizeBlockOrder', 'off'); % Optimize block operation order in the generated code 126 | set_param(paraModel, 'OptimizeDataStoreBuffers', 'on'); % Reuse buffers for Data Store Read and Data Store Write blocks 127 | set_param(paraModel, 'BusAssignmentInplaceUpdate', 'on'); % Perform inplace updates for Bus Assignment blocks 128 | set_param(paraModel, 'StrengthReduction', 'off'); % Simplify array indexing 129 | set_param(paraModel, 'EnableMemcpy', 'on'); % Use memcpy for vector assignment 130 | set_param(paraModel, 'MemcpyThreshold', 64); % Memcpy threshold (bytes) 131 | set_param(paraModel, 'BooleansAsBitfields', 'off'); % Pack Boolean data into bitfields 132 | set_param(paraModel, 'InlineInvariantSignals', 'off'); % Inline invariant signals 133 | set_param(paraModel, 'RollThreshold', 5); % Loop unrolling threshold 134 | set_param(paraModel, 'MaxStackSize', 'Inherit from target'); % Maximum stack size (bytes) 135 | set_param(paraModel, 'PassReuseOutputArgsAs', 'Individual arguments'); % Pass reusable subsystem outputs as 136 | set_param(paraModel, 'StateBitsets', 'off'); % Use bitsets for storing state configuration 137 | set_param(paraModel, 'DataBitsets', 'off'); % Use bitsets for storing Boolean data 138 | set_param(paraModel, 'ActiveStateOutputEnumStorageType', 'Native Integer'); % Base storage type for automatically created enumerations 139 | set_param(paraModel, 'AdvancedOptControl', ''); % AdvancedOptControl 140 | set_param(paraModel, 'BufferReusableBoundary', 'off'); % BufferReusableBoundary 141 | set_param(paraModel, 'PassReuseOutputArgsThreshold', 12); % Threshold 142 | 143 | % Diagnostics 144 | set_param(paraModel, 'AlgebraicLoopMsg', 'error'); % Algebraic loop 145 | set_param(paraModel, 'ArtificialAlgebraicLoopMsg', 'error'); % Minimize algebraic loop 146 | set_param(paraModel, 'BlockPriorityViolationMsg', 'error'); % Block priority violation 147 | set_param(paraModel, 'MinStepSizeMsg', 'warning'); % Min step size violation 148 | set_param(paraModel, 'TimeAdjustmentMsg', 'none'); % Sample hit time adjusting 149 | set_param(paraModel, 'MaxConsecutiveZCsMsg', 'error'); % Consecutive zero crossings violation 150 | set_param(paraModel, 'UnknownTsInhSupMsg', 'warning'); % Unspecified inheritability of sample time 151 | set_param(paraModel, 'ConsistencyChecking', 'none'); % Solver data inconsistency 152 | set_param(paraModel, 'SolverPrmCheckMsg', 'none'); % Automatic solver parameter selection 153 | set_param(paraModel, 'ModelReferenceExtraNoncontSigs', 'error'); % Extraneous discrete derivative signals 154 | set_param(paraModel, 'StateNameClashWarn', 'warning'); % State name clash 155 | set_param(paraModel, 'SimStateInterfaceChecksumMismatchMsg', 'warning'); % SimState interface checksum mismatch 156 | set_param(paraModel, 'SimStateOlderReleaseMsg', 'error'); % SimState object from earlier release 157 | set_param(paraModel, 'InheritedTsInSrcMsg', 'warning'); % Source block specifies -1 sample time 158 | set_param(paraModel, 'MultiTaskRateTransMsg', 'error'); % Multitask rate transition 159 | set_param(paraModel, 'SingleTaskRateTransMsg', 'warning'); % Single task rate transition 160 | set_param(paraModel, 'MultiTaskCondExecSysMsg', 'error'); % Multitask conditionally executed subsystem 161 | set_param(paraModel, 'TasksWithSamePriorityMsg', 'warning'); % Tasks with equal priority 162 | set_param(paraModel, 'SigSpecEnsureSampleTimeMsg', 'warning'); % Enforce sample times specified by Signal Specification blocks 163 | set_param(paraModel, 'SignalResolutionControl', 'UseLocalSettings'); % Signal resolution 164 | set_param(paraModel, 'CheckMatrixSingularityMsg', 'warning'); % Division by singular matrix 165 | set_param(paraModel, 'IntegerSaturationMsg', 'error'); % Saturate on overflow 166 | set_param(paraModel, 'UnderSpecifiedDataTypeMsg', 'warning'); % Underspecified data types 167 | set_param(paraModel, 'SignalRangeChecking', 'error'); % Simulation range checking 168 | set_param(paraModel, 'IntegerOverflowMsg', 'error'); % Wrap on overflow 169 | set_param(paraModel, 'SignalInfNanChecking', 'warning'); % Inf or NaN block output 170 | set_param(paraModel, 'RTPrefix', 'warning'); % "rt" prefix for identifiers 171 | set_param(paraModel, 'ParameterDowncastMsg', 'warning'); % Detect downcast 172 | set_param(paraModel, 'ParameterOverflowMsg', 'warning'); % Detect overflow 173 | set_param(paraModel, 'ParameterUnderflowMsg', 'warning'); % Detect underflow 174 | set_param(paraModel, 'ParameterPrecisionLossMsg', 'warning'); % Detect precision loss 175 | set_param(paraModel, 'ParameterTunabilityLossMsg', 'warning'); % Detect loss of tunability 176 | set_param(paraModel, 'ReadBeforeWriteMsg', 'EnableAllAsWarning'); % Detect read before write 177 | set_param(paraModel, 'WriteAfterReadMsg', 'EnableAllAsWarning'); % Detect write after read 178 | set_param(paraModel, 'WriteAfterWriteMsg', 'EnableAllAsWarning'); % Detect write after write 179 | set_param(paraModel, 'MultiTaskDSMMsg', 'error'); % Multitask data store 180 | set_param(paraModel, 'UniqueDataStoreMsg', 'warning'); % Duplicate data store names 181 | set_param(paraModel, 'UnderspecifiedInitializationDetection', 'Simplified'); % Underspecified initialization detection 182 | set_param(paraModel, 'ArrayBoundsChecking', 'none'); % Array bounds exceeded 183 | set_param(paraModel, 'AssertControl', 'DisableAll'); % Model Verification block enabling 184 | set_param(paraModel, 'AllowSymbolicDim', 'off'); % Allow symbolic dimension specification 185 | set_param(paraModel, 'UnnecessaryDatatypeConvMsg', 'warning'); % Unnecessary type conversions 186 | set_param(paraModel, 'VectorMatrixConversionMsg', 'warning'); % Vector/matrix block input conversion 187 | set_param(paraModel, 'Int32ToFloatConvMsg', 'warning'); % 32-bit integer to single precision float conversion 188 | set_param(paraModel, 'FixptConstUnderflowMsg', 'warning'); % Detect underflow 189 | set_param(paraModel, 'FixptConstOverflowMsg', 'warning'); % Detect overflow 190 | set_param(paraModel, 'FixptConstPrecisionLossMsg', 'warning'); % Detect precision loss 191 | set_param(paraModel, 'SignalLabelMismatchMsg', 'warning'); % Signal label mismatch 192 | set_param(paraModel, 'UnconnectedInputMsg', 'warning'); % Unconnected block input ports 193 | set_param(paraModel, 'UnconnectedOutputMsg', 'warning'); % Unconnected block output ports 194 | set_param(paraModel, 'UnconnectedLineMsg', 'warning'); % Unconnected line 195 | set_param(paraModel, 'RootOutportRequireBusObject', 'warning'); % Unspecified bus object at root Outport block 196 | set_param(paraModel, 'BusObjectLabelMismatch', 'warning'); % Element name mismatch 197 | set_param(paraModel, 'StrictBusMsg', 'ErrorOnBusTreatedAsVector'); % Bus signal treated as vector 198 | set_param(paraModel, 'NonBusSignalsTreatedAsBus', 'warning'); % Non-bus signals treated as bus signals 199 | set_param(paraModel, 'BusNameAdapt', 'WarnAndRepair'); % Repair bus selections 200 | set_param(paraModel, 'InvalidFcnCallConnMsg', 'error'); % Invalid function-call connection 201 | set_param(paraModel, 'FcnCallInpInsideContextMsg', 'error'); % Context-dependent inputs 202 | set_param(paraModel, 'SFcnCompatibilityMsg', 'warning'); % S-function upgrades needed 203 | set_param(paraModel, 'FrameProcessingCompatibilityMsg', 'error'); % Block behavior depends on frame status of signal 204 | set_param(paraModel, 'ModelReferenceVersionMismatchMessage', 'warning'); % Model block version mismatch 205 | set_param(paraModel, 'ModelReferenceIOMismatchMessage', 'warning'); % Port and parameter mismatch 206 | set_param(paraModel, 'ModelReferenceIOMsg', 'warning'); % Invalid root Inport/Outport block connection 207 | set_param(paraModel, 'ModelReferenceDataLoggingMessage', 'warning'); % Unsupported data logging 208 | set_param(paraModel, 'SaveWithDisabledLinksMsg', 'warning'); % Block diagram contains disabled library links 209 | set_param(paraModel, 'SaveWithParameterizedLinksMsg', 'warning'); % Block diagram contains parameterized library links 210 | set_param(paraModel, 'SFUnusedDataAndEventsDiag', 'warning'); % Unused data, events, messages and functions 211 | set_param(paraModel, 'SFUnexpectedBacktrackingDiag', 'error'); % Unexpected backtracking 212 | set_param(paraModel, 'SFInvalidInputDataAccessInChartInitDiag', 'warning'); % Invalid input data access in chart initialization 213 | set_param(paraModel, 'SFNoUnconditionalDefaultTransitionDiag', 'error'); % No unconditional default transitions 214 | set_param(paraModel, 'SFTransitionOutsideNaturalParentDiag', 'warning'); % Transition outside natural parent 215 | set_param(paraModel, 'SFUnreachableExecutionPathDiag', 'warning'); % Unreachable execution path 216 | set_param(paraModel, 'SFUndirectedBroadcastEventsDiag', 'warning'); % Undirected event broadcasts 217 | set_param(paraModel, 'SFTransitionActionBeforeConditionDiag', 'warning'); % Transition action specified before condition action 218 | set_param(paraModel, 'SFOutputUsedAsStateInMooreChartDiag', 'error'); % Read-before-write to output in Moore chart 219 | set_param(paraModel, 'SFTemporalDelaySmallerThanSampleTimeDiag', 'warning'); % Absolute time temporal value shorter than sampling period 220 | set_param(paraModel, 'SFSelfTransitionDiag', 'warning'); % Self-transition on leaf state 221 | set_param(paraModel, 'SFExecutionAtInitializationDiag', 'warning'); % 'Execute-at-initialization' disabled in presence of input events 222 | set_param(paraModel, 'SFMachineParentedDataDiag', 'warning'); % Use of machine-parented data instead of Data Store Memory 223 | set_param(paraModel, 'IgnoredZcDiagnostic', 'warning'); % IgnoredZcDiagnostic 224 | set_param(paraModel, 'InitInArrayFormatMsg', 'warning'); % InitInArrayFormatMsg 225 | set_param(paraModel, 'MaskedZcDiagnostic', 'warning'); % MaskedZcDiagnostic 226 | set_param(paraModel, 'ModelReferenceSymbolNameMessage', 'warning'); % ModelReferenceSymbolNameMessage 227 | set_param(paraModel, 'AllowedUnitSystems', 'all'); % Allowed unit systems 228 | set_param(paraModel, 'UnitsInconsistencyMsg', 'warning'); % Units inconsistency messages 229 | set_param(paraModel, 'AllowAutomaticUnitConversions', 'on'); % Allow automatic unit conversions 230 | 231 | % Hardware Implementation 232 | set_param(paraModel, 'ProdHWDeviceType', 'Infineon->TriCore'); % Production device vendor and type 233 | set_param(paraModel, 'ProdLongLongMode', 'off'); % Support long long in production hardware 234 | set_param(paraModel, 'ProdLargestAtomicInteger', 'Char'); % Production hardware largest atomic integer size 235 | set_param(paraModel, 'ProdLargestAtomicFloat', 'Float'); % Production hardware largest atomic floating-point size 236 | set_param(paraModel, 'ProdIntDivRoundTo', 'Zero'); % Production hardware signed integer division rounds to 237 | set_param(paraModel, 'ProdEqTarget', 'on'); % Test hardware is the same as production hardware 238 | set_param(paraModel, 'TargetPreprocMaxBitsSint', 32); % TargetPreprocMaxBitsSint 239 | set_param(paraModel, 'TargetPreprocMaxBitsUint', 32); % TargetPreprocMaxBitsUint 240 | 241 | % Model Referencing 242 | set_param(paraModel, 'UpdateModelReferenceTargets', 'IfOutOfDateOrStructuralChange'); % Rebuild 243 | set_param(paraModel, 'EnableParallelModelReferenceBuilds', 'off'); % Enable parallel model reference builds 244 | set_param(paraModel, 'ModelReferenceNumInstancesAllowed', 'Single'); % Total number of instances allowed per top model 245 | set_param(paraModel, 'PropagateVarSize', 'Infer from blocks in model'); % Propagate sizes of variable-size signals 246 | set_param(paraModel, 'ModelReferenceMinAlgLoopOccurrences', 'off'); % Minimize algebraic loop occurrences 247 | set_param(paraModel, 'EnableRefExpFcnMdlSchedulingChecks', 'on'); % Enable strict scheduling checks for referenced export-function models 248 | set_param(paraModel, 'PropagateSignalLabelsOutOfModel', 'on'); % Propagate all signal labels out of the model 249 | set_param(paraModel, 'ModelReferencePassRootInputsByReference', 'off'); % Pass fixed-size scalar root inputs by value for code generation 250 | set_param(paraModel, 'ModelDependencies', ''); % Model dependencies 251 | set_param(paraModel, 'ParallelModelReferenceErrorOnInvalidPool', 'on'); % ParallelModelReferenceErrorOnInvalidPool 252 | set_param(paraModel, 'SupportModelReferenceSimTargetCustomCode', 'off'); % SupportModelReferenceSimTargetCustomCode 253 | 254 | % Simulation Target 255 | set_param(paraModel, 'MATLABDynamicMemAlloc', 'off'); % Dynamic memory allocation in MATLAB Function blocks 256 | set_param(paraModel, 'CompileTimeRecursionLimit', 50); % Compile-time recursion limit for MATLAB functions 257 | set_param(paraModel, 'EnableRuntimeRecursion', 'on'); % Enable run-time recursion for MATLAB functions 258 | set_param(paraModel, 'SFSimEcho', 'on'); % Echo expressions without semicolons 259 | set_param(paraModel, 'SimCtrlC', 'on'); % Ensure responsiveness 260 | set_param(paraModel, 'SimIntegrity', 'on'); % Ensure memory integrity 261 | set_param(paraModel, 'SimGenImportedTypeDefs', 'off'); % Generate typedefs for imported bus and enumeration types 262 | set_param(paraModel, 'SimBuildMode', 'sf_incremental_build'); % Simulation target build mode 263 | set_param(paraModel, 'SimReservedNameArray', []); % Reserved names 264 | % set_param(paraModel, 'SimParseCustomCode', 'off'); % Parse custom code symbols 265 | % set_param(paraModel, 'SimCustomSourceCode', ''); % Source file 266 | % set_param(paraModel, 'SimCustomHeaderCode', ''); % Header file 267 | % set_param(paraModel, 'SimCustomInitializer', ''); % Initialize function 268 | % set_param(paraModel, 'SimCustomTerminator', ''); % Terminate function 269 | % set_param(paraModel, 'SimUserIncludeDirs', ''); % Include directories 270 | % set_param(paraModel, 'SimUserSources', ''); % Source files 271 | % set_param(paraModel, 'SimUserLibraries', ''); % Libraries 272 | % set_param(paraModel, 'SimUserDefines', ''); % Defines 273 | set_param(paraModel, 'SFSimEnableDebug', 'off'); % Allow setting breakpoints during simulation 274 | 275 | % Code Generation 276 | set_param(paraModel, 'RemoveResetFunc', 'on'); % Remove reset function 277 | set_param(paraModel, 'ExistingSharedCode', ''); % Existing shared code 278 | set_param(paraModel, 'TargetLang', 'C'); % Language 279 | set_param(paraModel, 'CompOptLevelCompliant', 'on'); % CompOptLevelCompliant 280 | set_param(paraModel, 'Toolchain', 'Automatically locate an installed toolchain'); % Toolchain 281 | set_param(paraModel, 'BuildConfiguration', 'Faster Builds'); % Build configuration 282 | set_param(paraModel, 'ObjectivePriorities', []); % Prioritized objectives 283 | set_param(paraModel, 'CheckMdlBeforeBuild', 'off'); % Check model before generating code 284 | set_param(paraModel, 'SILDebugging', 'off'); % Enable source-level debugging for SIL 285 | set_param(paraModel, 'GenCodeOnly', 'on'); % Generate code only 286 | set_param(paraModel, 'PackageGeneratedCodeAndArtifacts', 'off'); % Package code and artifacts 287 | set_param(paraModel, 'RTWVerbose', 'off'); % Verbose build 288 | set_param(paraModel, 'RetainRTWFile', 'off'); % Retain .rtw file 289 | set_param(paraModel, 'ProfileTLC', 'off'); % Profile TLC 290 | set_param(paraModel, 'TLCDebug', 'off'); % Start TLC debugger when generating code 291 | set_param(paraModel, 'TLCCoverage', 'off'); % Start TLC coverage when generating code 292 | set_param(paraModel, 'TLCAssert', 'off'); % Enable TLC assertion 293 | % set_param(paraModel, 'RTWUseSimCustomCode', 'off'); % Use the same custom code settings as Simulation Target 294 | % set_param(paraModel, 'CustomSourceCode', ''); % Source file 295 | % set_param(paraModel, 'CustomHeaderCode', ''); % Header file 296 | % set_param(paraModel, 'CustomInclude', ''); % Include directories 297 | % set_param(paraModel, 'CustomSource', ''); % Source files 298 | % set_param(paraModel, 'CustomLibrary', ''); % Libraries 299 | % set_param(paraModel, 'CustomLAPACKCallback', ''); % Custom LAPACK library callback 300 | % set_param(paraModel, 'CustomDefine', ''); % Defines 301 | % set_param(paraModel, 'CustomInitializer', ''); % Initialize function 302 | % set_param(paraModel, 'CustomTerminator', ''); % Terminate function 303 | set_param(paraModel, 'CodeExecutionProfiling', 'off'); % Measure task execution time 304 | set_param(paraModel, 'CodeProfilingInstrumentation', 'off'); % Measure function execution times 305 | set_param(paraModel, 'CodeCoverageSettings', coder.coverage.CodeCoverageSettings([],'off','off','None')); % Third-party tool 306 | set_param(paraModel, 'CreateSILPILBlock', 'None'); % Create block 307 | set_param(paraModel, 'PortableWordSizes', 'on'); % Enable portable word sizes 308 | set_param(paraModel, 'PostCodeGenCommand', ''); % Post code generation command 309 | set_param(paraModel, 'SaveLog', 'off'); % Save build log 310 | set_param(paraModel, 'TLCOptions', ''); % TLC command line options 311 | set_param(paraModel, 'GenerateReport', 'on'); % Create code generation report 312 | set_param(paraModel, 'LaunchReport', 'on'); % Open report automatically 313 | set_param(paraModel, 'IncludeHyperlinkInReport', 'on'); % Code-to-model 314 | set_param(paraModel, 'GenerateTraceInfo', 'on'); % Model-to-code 315 | set_param(paraModel, 'GenerateWebview', 'off'); % Generate model Web view 316 | set_param(paraModel, 'GenerateTraceReport', 'on'); % Eliminated / virtual blocks 317 | set_param(paraModel, 'GenerateTraceReportSl', 'on'); % Traceable Simulink blocks 318 | set_param(paraModel, 'GenerateTraceReportSf', 'on'); % Traceable Stateflow objects 319 | set_param(paraModel, 'GenerateTraceReportEml', 'on'); % Traceable MATLAB functions 320 | set_param(paraModel, 'GenerateCodeMetricsReport', 'on'); % Static code metrics 321 | set_param(paraModel, 'GenerateCodeReplacementReport', 'on'); % Summarize which blocks triggered code replacements 322 | set_param(paraModel, 'GenerateComments', 'on'); % Include comments 323 | set_param(paraModel, 'SimulinkBlockComments', 'on'); % Simulink block / Stateflow object comments 324 | set_param(paraModel, 'MATLABSourceComments', 'on'); % MATLAB source code as comments 325 | set_param(paraModel, 'ShowEliminatedStatement', 'on'); % Show eliminated blocks 326 | set_param(paraModel, 'ForceParamTrailComments', 'on'); % Verbose comments for SimulinkGlobal storage class 327 | set_param(paraModel, 'OperatorAnnotations', 'on'); % Operator annotations 328 | set_param(paraModel, 'InsertBlockDesc', 'on'); % Simulink block descriptions 329 | set_param(paraModel, 'SFDataObjDesc', 'on'); % Stateflow object descriptions 330 | set_param(paraModel, 'SimulinkDataObjDesc', 'on'); % Simulink data object descriptions 331 | set_param(paraModel, 'ReqsInCode', 'off'); % Requirements in block comments 332 | set_param(paraModel, 'EnableCustomComments', 'off'); % Custom comments (MPT objects only) 333 | set_param(paraModel, 'MATLABFcnDesc', 'on'); % MATLAB function help text 334 | set_param(paraModel, 'CustomSymbolStrGlobalVar', '$R$N$M'); % Global variables 335 | set_param(paraModel, 'CustomSymbolStrType', '$N$R$M_T'); % Global types 336 | set_param(paraModel, 'CustomSymbolStrField', '$N$M'); % Field name of global types 337 | set_param(paraModel, 'CustomSymbolStrFcn', '$R$N$M$F'); % Subsystem methods 338 | set_param(paraModel, 'CustomSymbolStrFcnArg', 'rt$I$N$M'); % Subsystem method arguments 339 | set_param(paraModel, 'CustomSymbolStrTmpVar', '$N$M'); % Local temporary variables 340 | set_param(paraModel, 'CustomSymbolStrBlkIO', 'rtb_$N$M'); % Local block output variables 341 | set_param(paraModel, 'CustomSymbolStrMacro', '$R$N$M'); % Constant macros 342 | set_param(paraModel, 'CustomSymbolStrUtil', '$N$C'); % Shared utilities 343 | set_param(paraModel, 'CustomSymbolStrEmxType', 'emxArray_$M$N'); % EMX array types identifier format 344 | set_param(paraModel, 'CustomSymbolStrEmxFcn', 'emx$M$N'); % EMX array utility functions identifier format 345 | set_param(paraModel, 'MangleLength', 4); % Minimum mangle length 346 | set_param(paraModel, 'MaxIdLength', 128); % Maximum identifier length 347 | set_param(paraModel, 'InternalIdentifier', 'Shortened'); % System-generated identifiers 348 | set_param(paraModel, 'InlinedPrmAccess', 'Literals'); % Generate scalar inlined parameters as 349 | set_param(paraModel, 'SignalNamingRule', 'None'); % Signal naming 350 | set_param(paraModel, 'ParamNamingRule', 'None'); % Parameter naming 351 | set_param(paraModel, 'DefineNamingRule', 'None'); % #define naming 352 | set_param(paraModel, 'UseSimReservedNames', 'off'); % Use the same reserved names as Simulation Target 353 | set_param(paraModel, 'ReservedNameArray', []); % Reserved names 354 | set_param(paraModel, 'IgnoreCustomStorageClasses', 'off'); % Ignore custom storage classes 355 | set_param(paraModel, 'IgnoreTestpoints', 'on'); % Ignore test point signals 356 | set_param(paraModel, 'CommentStyle', 'Auto'); % Comment style 357 | set_param(paraModel, 'IncAutoGenComments', 'off'); % IncAutoGenComments 358 | set_param(paraModel, 'IncDataTypeInIds', 'off'); % IncDataTypeInIds 359 | set_param(paraModel, 'IncHierarchyInIds', 'off'); % IncHierarchyInIds 360 | set_param(paraModel, 'InsertPolySpaceComments', 'off'); % Insert Polyspace comments 361 | set_param(paraModel, 'PreserveName', 'off'); % PreserveName 362 | set_param(paraModel, 'PreserveNameWithParent', 'off'); % PreserveNameWithParent 363 | set_param(paraModel, 'CustomUserTokenString', ''); % Custom token text 364 | set_param(paraModel, 'TargetLangStandard', 'C89/C90 (ANSI)'); % Standard math library 365 | set_param(paraModel, 'CodeReplacementLibrary', 'None'); % Code replacement library 366 | set_param(paraModel, 'UtilityFuncGeneration', 'Shared location'); % Shared code placement 367 | set_param(paraModel, 'CodeInterfacePackaging', 'Nonreusable function'); % Code interface packaging 368 | set_param(paraModel, 'GRTInterface', 'off'); % Classic call interface 369 | set_param(paraModel, 'PurelyIntegerCode', 'off'); % Support floating-point numbers 370 | set_param(paraModel, 'SupportNonFinite', 'off'); % Support non-finite numbers 371 | set_param(paraModel, 'SupportComplex', 'off'); % Support complex numbers 372 | set_param(paraModel, 'SupportAbsoluteTime', 'off'); % Support absolute time 373 | set_param(paraModel, 'SupportContinuousTime', 'off'); % Support continuous time 374 | set_param(paraModel, 'SupportNonInlinedSFcns', 'off'); % Support non-inlined S-functions 375 | set_param(paraModel, 'SupportVariableSizeSignals', 'off'); % Support variable-size signals 376 | set_param(paraModel, 'MultiwordTypeDef', 'System defined'); % Multiword type definitions 377 | set_param(paraModel, 'CombineOutputUpdateFcns', 'on'); % Single output/update function 378 | set_param(paraModel, 'IncludeMdlTerminateFcn', 'off'); % Terminate function required 379 | set_param(paraModel, 'MatFileLogging', 'off'); % MAT-file logging 380 | set_param(paraModel, 'SuppressErrorStatus', 'on'); % Remove error status field in real-time model data structure 381 | set_param(paraModel, 'CombineSignalStateStructs', 'off'); % Combine signal/state structures 382 | set_param(paraModel, 'ParenthesesLevel', 'Maximum'); % Parentheses level 383 | set_param(paraModel, 'CastingMode', 'Standards'); % Casting modes 384 | set_param(paraModel, 'GenerateSampleERTMain', 'off'); % Generate an example main program 385 | set_param(paraModel, 'IncludeFileDelimiter', 'UseQuote'); % #include file delimiter 386 | set_param(paraModel, 'CPPClassGenCompliant', 'on'); % CPPClassGenCompliant 387 | set_param(paraModel, 'ConcurrentExecutionCompliant', 'off'); % ConcurrentExecutionCompliant 388 | set_param(paraModel, 'ERTCustomFileBanners', 'on'); % ERTCustomFileBanners 389 | set_param(paraModel, 'ERTFirstTimeCompliant', 'on'); % ERTFirstTimeCompliant 390 | set_param(paraModel, 'GenerateFullHeader', 'on'); % GenerateFullHeader 391 | set_param(paraModel, 'InferredTypesCompatibility', 'off'); % InferredTypesCompatibility 392 | set_param(paraModel, 'GenerateSharedConstants', 'off'); % Generate shared constants 393 | set_param(paraModel, 'ModelReferenceCompliant', 'on'); % ModelReferenceCompliant 394 | set_param(paraModel, 'ModelStepFunctionPrototypeControlCompliant', 'off'); % ModelStepFunctionPrototypeControlCompliant 395 | set_param(paraModel, 'ParMdlRefBuildCompliant', 'on'); % ParMdlRefBuildCompliant 396 | set_param(paraModel, 'TargetFcnLib', 'ansi_tfl_table_tmw.mat'); % TargetFcnLib 397 | set_param(paraModel, 'TargetLibSuffix', ''); % TargetLibSuffix 398 | set_param(paraModel, 'TargetPreCompLibLocation', ''); % TargetPreCompLibLocation 399 | set_param(paraModel, 'UseToolchainInfoCompliant', 'on'); % UseToolchainInfoCompliant 400 | set_param(paraModel, 'RemoveDisableFunc', 'off'); % Remove disable function 401 | set_param(paraModel, 'MemSecPackage', '--- None ---'); % Memory sections package for model data and functions 402 | set_param(paraModel, 'GlobalDataDefinition', 'Auto'); % Data definition 403 | set_param(paraModel, 'GlobalDataReference', 'Auto'); % Data declaration 404 | set_param(paraModel, 'ExtMode', 'off'); % External mode 405 | set_param(paraModel, 'EnableUserReplacementTypes', 'on'); % Replace data type names in the generated code 406 | set_param(paraModel, 'ConvertIfToSwitch', 'on'); % Convert if-elseif-else patterns to switch-case statements 407 | set_param(paraModel, 'ERTCustomFileTemplate', 'example_file_process.tlc'); % File customization template 408 | set_param(paraModel, 'ERTDataHdrFileTemplate', 'ert_code_template.cgt'); % Header file template 409 | set_param(paraModel, 'ERTDataSrcFileTemplate', 'ert_code_template.cgt'); % Source file template 410 | set_param(paraModel, 'ERTFilePackagingFormat', 'Compact'); % File packaging format 411 | set_param(paraModel, 'ERTHdrFileBannerTemplate', 'ert_code_template.cgt'); % Header file template 412 | set_param(paraModel, 'ERTSrcFileBannerTemplate', 'ert_code_template.cgt'); % Source file template 413 | set_param(paraModel, 'EnableDataOwnership', 'off'); % Use owner from data object for data definition placement 414 | set_param(paraModel, 'GenerateASAP2', 'on'); % ASAP2 interface 415 | set_param(paraModel, 'IndentSize', '4'); % Indent size 416 | set_param(paraModel, 'IndentStyle', 'Allman'); % Indent style 417 | set_param(paraModel, 'InlinedParameterPlacement', 'Hierarchical'); % Parameter structure 418 | set_param(paraModel, 'MemSecDataConstants', 'Default'); % Memory section for constants 419 | set_param(paraModel, 'MemSecDataIO', 'Default'); % Memory section for inputs/outputs 420 | set_param(paraModel, 'MemSecDataInternal', 'Default'); % Memory section for internal data 421 | set_param(paraModel, 'MemSecDataParameters', 'Default'); % Memory section for parameters 422 | set_param(paraModel, 'MemSecFuncExecute', 'Default'); % Memory section for execution functions 423 | set_param(paraModel, 'MemSecFuncInitTerm', 'Default'); % Memory section for initialize/terminate functions 424 | set_param(paraModel, 'MemSecFuncSharedUtil', 'Default'); % Memory section for shared utility functions 425 | set_param(paraModel, 'ParamTuneLevel', 10); % Parameter tune level 426 | set_param(paraModel, 'EnableSignedLeftShifts', 'off'); % Replace multiplications by powers of two with signed bitwise shifts 427 | set_param(paraModel, 'EnableSignedRightShifts', 'off'); % Allow right shifts on signed integers 428 | set_param(paraModel, 'PreserveExpressionOrder', 'on'); % Preserve operand order in expression 429 | set_param(paraModel, 'PreserveExternInFcnDecls', 'on'); % Preserve extern keyword in function declarations 430 | set_param(paraModel, 'PreserveIfCondition', 'on'); % Preserve condition expression in if statement 431 | set_param(paraModel, 'RTWCAPIParams', 'off'); % Generate C API for parameters 432 | set_param(paraModel, 'RTWCAPIRootIO', 'off'); % Generate C API for root-level I/O 433 | set_param(paraModel, 'RTWCAPISignals', 'off'); % Generate C API for signals 434 | set_param(paraModel, 'RTWCAPIStates', 'off'); % Generate C API for states 435 | set_param(paraModel, 'RateGroupingCode', 'on'); % RateGroupingCode 436 | set_param(paraModel, 'ReplacementTypes', struct('double','','single','','int32','','int16','','int8','','uint32','','uint16','','uint8','','boolean','','int','','uint','','char','')); % Data type names 437 | set_param(paraModel, 'SignalDisplayLevel', 10); % Signal display level 438 | set_param(paraModel, 'SuppressUnreachableDefaultCases', 'off'); % Suppress generation of default cases for Stateflow switch statements if unreachable 439 | set_param(paraModel, 'BooleanTrueId', 'true'); % Boolean true identifier 440 | set_param(paraModel, 'BooleanFalseId', 'false'); % Boolean false identifier 441 | set_param(paraModel, 'MaxIdInt32', 'MAX_int32_T'); % 32-bit integer maximum identifier 442 | set_param(paraModel, 'MinIdInt32', 'MIN_int32_T'); % 32-bit integer minimum identifier 443 | set_param(paraModel, 'MaxIdUint32', 'MAX_uint32_T'); % 32-bit unsigned integer maximum identifier 444 | set_param(paraModel, 'MaxIdInt16', 'MAX_int16_T'); % 16-bit integer maximum identifier 445 | set_param(paraModel, 'MinIdInt16', 'MIN_int16_T'); % 16-bit integer minimum identifier 446 | set_param(paraModel, 'MaxIdUint16', 'MAX_uint16_T'); % 16-bit unsigned integer maximum identifier 447 | set_param(paraModel, 'MaxIdInt8', 'MAX_int8_T'); % 8-bit integer maximum identifier 448 | set_param(paraModel, 'MinIdInt8', 'MIN_int8_T'); % 8-bit integer minimum identifier 449 | set_param(paraModel, 'MaxIdUint8', 'MAX_uint8_T'); % 8-bit unsigned integer maximum identifier 450 | set_param(paraModel, 'TypeLimitIdReplacementHeaderFile', ''); % Type limit identifier replacement header file 451 | set_param(paraModel, 'AutosarCompilerAbstraction', 'off'); % Use AUTOSAR compiler abstraction macros 452 | set_param(paraModel, 'AutosarMatrixIOAsArray', 'off'); % Support root-level matrix I/O using one-dimensional arrays 453 | set_param(paraModel, 'AutosarMaxShortNameLength', 128); % Maximum SHORT-NAME length 454 | set_param(paraModel, 'AutosarSchemaVersion', '4.2'); % Generate XML file for schema version 455 | 456 | % Simulink Coverage 457 | set_param(paraModel, 'CovModelRefEnable', 'off'); % Record coverage for referenced models 458 | set_param(paraModel, 'RecordCoverage', 'off'); % Record coverage for this model 459 | set_param(paraModel, 'CovEnable', 'off'); % Enable coverage analysis 460 | set_param(paraModel, 'CovEnableCumulative', 'on'); % Enable cumulative data collection 461 | set_param(paraModel, 'CovSaveCumulativeToWorkspaceVar', 'on'); % Save cumulative coverage results in workspace variable 462 | set_param(paraModel, 'CovCumulativeVarName', 'covCumulativeData'); % Cumulative coverage variable name 463 | set_param(paraModel, 'CovSaveName', 'covdata'); % Last coverage run variable name 464 | set_param(paraModel, 'CovNameIncrementing', 'off'); % Increment cvdata variable name with each simulation 465 | set_param(paraModel, 'CovReportOnPause', 'on'); % Update coverage results on pause 466 | set_param(paraModel, 'CovHTMLOptions', ''); % Coverage report options 467 | set_param(paraModel, 'CovCumulativeReport', 'off'); % Include cumulative data in coverage report 468 | set_param(paraModel, 'CovCompData', ''); % Additional data to include in coverage report 469 | set_param(paraModel, 'CovFilter', ''); % Coverage filter filename 470 | set_param(paraModel, 'CovSaveOutputData', 'on'); % Save output data 471 | 472 | % HDL Coder 473 | hdlset_param(paraModel,'GenerateHDLCode','off'); % Generate HDL code 474 | 475 | Configurate = 'Autosar config successful, script version 1.3'; 476 | end 477 | -------------------------------------------------------------------------------- /ERT_configuration.m: -------------------------------------------------------------------------------- 1 | %--------------------------------------------------------------------------- 2 | % Simulink scrip for ERT configuration set 3 | % MATLAB version: R2017a 4 | % Please read the document <基于Autosar配置说明文档 v0.9> to learn details. 5 | % Shibo Jiang 2018/11/3 6 | % Version: 1.3 7 | % Instructions: Run this scrip in matlab command,and one model should be 8 | % opened at least. 9 | %--------------------------------------------------------------------------- 10 | 11 | function Configurate = ERT_configuration() 12 | 13 | paraModel = bdroot; 14 | 15 | % Original matalb version is R2017a 16 | % 检查Matlab版本是否为R2017a 17 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 18 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 19 | CurrentVersion = version; 20 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 21 | strcmp(CorrectVersion_linux, CurrentVersion)) 22 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 23 | end 24 | 25 | % Original environment character encoding: GBK 26 | % 脚本编码环境是否为GBK 27 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 28 | % warning('Simulink:EncodingUnMatched', 'The target character... 29 | % encoding (%s) is different from the original (%s).', ... 30 | % get_param(0, 'CharacterEncoding'), 'GBK'); 31 | % end 32 | 33 | % Original configuration set target is autosar.tlc 34 | % 将代码生成目标模板设置为 autosar.tlc 35 | myConfigObj=getActiveConfigSet(paraModel); 36 | try 37 | switchTarget(myConfigObj, 'ert.tlc', ''); 38 | catch 39 | % Do nothing 40 | end 41 | 42 | % Set [Display > Signals & Ports > Wide Nonscalar Lines] as on 43 | set_param(paraModel, 'WideLines', 'on'); 44 | % Set [Display > Signals & Ports > Viewer Indicator] as on 45 | set_param(paraModel, 'ShowViewerIcons', 'on'); 46 | % Set [Display > Signals & Ports > Test point & Logging Indicator] as on 47 | set_param(paraModel, 'ShowTestPointIcons', 'on'); 48 | % Set [Display > Signals & Ports > Linearization Indicators] as on 49 | set_param(paraModel, 'ShowLinearizationAnnotations', 'on'); 50 | % Set [Display > Library Links] as none 51 | set_param(paraModel,'LibraryLinkDisplay', 'none'); 52 | % Set font style as Arial 53 | set_param(paraModel,'DefaultAnnotationFontName', 'Arial'); 54 | set_param(paraModel,'DefaultBlockFontName', 'Arial'); 55 | set_param(paraModel,'DefaultLineFontName', 'Arial'); 56 | 57 | set_param(paraModel,'DefaultAnnotationFontSize', '10'); 58 | set_param(paraModel,'DefaultBlockFontSize', '10'); 59 | set_param(paraModel,'DefaultLineFontSize', '10'); 60 | 61 | % Do not change the order of the following commands. There are dependencies between the parameters. 62 | % 不要修改如下命令行的顺序,相互之间有依赖关系 63 | 64 | set_param(paraModel, 'HardwareBoard', 'None'); % Hardware board 65 | 66 | % Solver 67 | set_param(paraModel, 'StartTime', '0.0'); % Start time 68 | set_param(paraModel, 'StopTime', '10'); % Stop time 69 | set_param(paraModel, 'SolverType', 'Fixed-step'); % Type 70 | set_param(paraModel, 'EnableConcurrentExecution', 'off'); % Show concurrent execution options 71 | set_param(paraModel, 'SampleTimeConstraint', 'Unconstrained'); % Periodic sample time constraint 72 | set_param(paraModel, 'Solver', 'FixedStepDiscrete'); % Solver 73 | set_param(paraModel, 'FixedStep', '0.002'); % Fixed-step size (fundamental sample time) 74 | set_param(paraModel, 'EnableMultiTasking', 'on'); % Treat each discrete rate as a separate task 75 | set_param(paraModel, 'AutoInsertRateTranBlk', 'off'); % Automatically handle rate transition for data transfer 76 | set_param(paraModel, 'PositivePriorityOrder', 'off'); % Higher priority value indicates higher task priority 77 | 78 | % Data Import/Export 79 | set_param(paraModel, 'LoadExternalInput', 'off'); % Load external input 80 | set_param(paraModel, 'LoadInitialState', 'off'); % Load initial state 81 | set_param(paraModel, 'SaveTime', 'off'); % Save time 82 | set_param(paraModel, 'SaveState', 'off'); % Save states 83 | set_param(paraModel, 'SaveFormat', 'Dataset'); % Format 84 | set_param(paraModel, 'SaveOutput', 'off'); % Save output 85 | set_param(paraModel, 'SaveFinalState', 'off'); % Save final state 86 | set_param(paraModel, 'SignalLogging', 'on'); % Signal logging 87 | set_param(paraModel, 'SignalLoggingName', 'logsout'); % Signal logging name 88 | set_param(paraModel, 'DSMLogging', 'on'); % Data stores 89 | set_param(paraModel, 'DSMLoggingName', 'dsmout'); % Data stores logging name 90 | set_param(paraModel, 'LoggingToFile', 'off'); % Log Dataset data to file 91 | set_param(paraModel, 'DatasetSignalFormat', 'timeseries'); % DatasetSignalFormat 92 | set_param(paraModel, 'ReturnWorkspaceOutputs', 'off'); % Single simulation output 93 | set_param(paraModel, 'InspectSignalLogs', 'off'); % Record logged workspace data in Simulation Data Inspector 94 | set_param(paraModel, 'LimitDataPoints', 'on'); % Limit data points 95 | set_param(paraModel, 'MaxDataPoints', '1000'); % Maximum number of data points 96 | set_param(paraModel, 'Decimation', '1'); % Decimation 97 | 98 | % Optimization 99 | set_param(paraModel, 'BlockReduction', 'on'); % Block reduction 100 | set_param(paraModel, 'ConditionallyExecuteInputs', 'on'); % Conditional input branch execution 101 | set_param(paraModel, 'BooleanDataType', 'on'); % Implement logic signals as Boolean data (vs. double) 102 | set_param(paraModel, 'LifeSpan', 'inf'); % Application lifespan (days) 103 | set_param(paraModel, 'UseDivisionForNetSlopeComputation', 'on'); % Use division for fixed-point net slope computation 104 | set_param(paraModel, 'UseFloatMulNetSlope', 'off'); % Use floating-point multiplication to handle net slope corrections 105 | set_param(paraModel, 'DefaultUnderspecifiedDataType', 'single'); % Default for underspecified data type 106 | set_param(paraModel, 'UseSpecifiedMinMax', 'off'); % Optimize using the specified minimum and maximum values 107 | set_param(paraModel, 'ZeroExternalMemoryAtStartup', 'off'); % Remove root level I/O zero initialization 108 | set_param(paraModel, 'InitFltsAndDblsToZero', 'off'); % Use memset to initialize floats and doubles to 0.0 109 | set_param(paraModel, 'ZeroInternalMemoryAtStartup', 'on'); % Remove internal data zero initialization 110 | set_param(paraModel, 'EfficientFloat2IntCast', 'on'); % Remove code from floating-point to integer conversions that wraps out-of-range values 111 | set_param(paraModel, 'EfficientMapNaN2IntZero', 'off'); % Remove code from floating-point to integer conversions with saturation that maps NaN to zero 112 | set_param(paraModel, 'NoFixptDivByZeroProtection', 'off'); % Remove code that protects against division arithmetic exceptions 113 | set_param(paraModel, 'SimCompilerOptimization', 'off'); % Compiler optimization level 114 | set_param(paraModel, 'AccelVerboseBuild', 'off'); % Verbose accelerator builds 115 | set_param(paraModel, 'DefaultParameterBehavior', 'Inlined'); % Default parameter behavior 116 | set_param(paraModel, 'OptimizeBlockIOStorage', 'on'); % Signal storage reuse 117 | set_param(paraModel, 'LocalBlockOutputs', 'on'); % Enable local block outputs 118 | set_param(paraModel, 'ExpressionFolding', 'on'); % Eliminate superfluous local variables (expression folding) 119 | set_param(paraModel, 'BufferReuse', 'on'); % Reuse local block outputs 120 | set_param(paraModel, 'GlobalBufferReuse', 'on'); % Reuse global block outputs 121 | set_param(paraModel, 'GlobalVariableUsage', 'Use global to hold temporary results'); % Optimize global data access 122 | set_param(paraModel, 'OptimizeBlockOrder', 'off'); % Optimize block operation order in the generated code 123 | set_param(paraModel, 'OptimizeDataStoreBuffers', 'on'); % Reuse buffers for Data Store Read and Data Store Write blocks 124 | set_param(paraModel, 'BusAssignmentInplaceUpdate', 'on'); % Perform inplace updates for Bus Assignment blocks 125 | set_param(paraModel, 'StrengthReduction', 'off'); % Simplify array indexing 126 | set_param(paraModel, 'EnableMemcpy', 'on'); % Use memcpy for vector assignment 127 | set_param(paraModel, 'MemcpyThreshold', 64); % Memcpy threshold (bytes) 128 | set_param(paraModel, 'BooleansAsBitfields', 'off'); % Pack Boolean data into bitfields 129 | set_param(paraModel, 'InlineInvariantSignals', 'off'); % Inline invariant signals 130 | set_param(paraModel, 'RollThreshold', 5); % Loop unrolling threshold 131 | set_param(paraModel, 'MaxStackSize', 'Inherit from target'); % Maximum stack size (bytes) 132 | set_param(paraModel, 'PassReuseOutputArgsAs', 'Individual arguments'); % Pass reusable subsystem outputs as 133 | set_param(paraModel, 'StateBitsets', 'off'); % Use bitsets for storing state configuration 134 | set_param(paraModel, 'DataBitsets', 'off'); % Use bitsets for storing Boolean data 135 | set_param(paraModel, 'ActiveStateOutputEnumStorageType', 'Native Integer'); % Base storage type for automatically created enumerations 136 | set_param(paraModel, 'AdvancedOptControl', ''); % AdvancedOptControl 137 | set_param(paraModel, 'BufferReusableBoundary', 'off'); % BufferReusableBoundary 138 | set_param(paraModel, 'PassReuseOutputArgsThreshold', 12); % Threshold 139 | 140 | % Diagnostics 141 | set_param(paraModel, 'AlgebraicLoopMsg', 'error'); % Algebraic loop 142 | set_param(paraModel, 'ArtificialAlgebraicLoopMsg', 'error'); % Minimize algebraic loop 143 | set_param(paraModel, 'BlockPriorityViolationMsg', 'error'); % Block priority violation 144 | set_param(paraModel, 'MinStepSizeMsg', 'warning'); % Min step size violation 145 | set_param(paraModel, 'TimeAdjustmentMsg', 'none'); % Sample hit time adjusting 146 | set_param(paraModel, 'MaxConsecutiveZCsMsg', 'error'); % Consecutive zero crossings violation 147 | set_param(paraModel, 'UnknownTsInhSupMsg', 'warning'); % Unspecified inheritability of sample time 148 | set_param(paraModel, 'ConsistencyChecking', 'none'); % Solver data inconsistency 149 | set_param(paraModel, 'SolverPrmCheckMsg', 'none'); % Automatic solver parameter selection 150 | set_param(paraModel, 'ModelReferenceExtraNoncontSigs', 'error'); % Extraneous discrete derivative signals 151 | set_param(paraModel, 'StateNameClashWarn', 'warning'); % State name clash 152 | set_param(paraModel, 'SimStateInterfaceChecksumMismatchMsg', 'warning'); % SimState interface checksum mismatch 153 | set_param(paraModel, 'SimStateOlderReleaseMsg', 'error'); % SimState object from earlier release 154 | set_param(paraModel, 'InheritedTsInSrcMsg', 'warning'); % Source block specifies -1 sample time 155 | set_param(paraModel, 'MultiTaskRateTransMsg', 'error'); % Multitask rate transition 156 | set_param(paraModel, 'SingleTaskRateTransMsg', 'warning'); % Single task rate transition 157 | set_param(paraModel, 'MultiTaskCondExecSysMsg', 'error'); % Multitask conditionally executed subsystem 158 | set_param(paraModel, 'TasksWithSamePriorityMsg', 'warning'); % Tasks with equal priority 159 | set_param(paraModel, 'SigSpecEnsureSampleTimeMsg', 'warning'); % Enforce sample times specified by Signal Specification blocks 160 | set_param(paraModel, 'SignalResolutionControl', 'UseLocalSettings'); % Signal resolution 161 | set_param(paraModel, 'CheckMatrixSingularityMsg', 'warning'); % Division by singular matrix 162 | set_param(paraModel, 'IntegerSaturationMsg', 'error'); % Saturate on overflow 163 | set_param(paraModel, 'UnderSpecifiedDataTypeMsg', 'warning'); % Underspecified data types 164 | set_param(paraModel, 'SignalRangeChecking', 'error'); % Simulation range checking 165 | set_param(paraModel, 'IntegerOverflowMsg', 'error'); % Wrap on overflow 166 | set_param(paraModel, 'SignalInfNanChecking', 'warning'); % Inf or NaN block output 167 | set_param(paraModel, 'RTPrefix', 'warning'); % "rt" prefix for identifiers 168 | set_param(paraModel, 'ParameterDowncastMsg', 'warning'); % Detect downcast 169 | set_param(paraModel, 'ParameterOverflowMsg', 'warning'); % Detect overflow 170 | set_param(paraModel, 'ParameterUnderflowMsg', 'warning'); % Detect underflow 171 | set_param(paraModel, 'ParameterPrecisionLossMsg', 'warning'); % Detect precision loss 172 | set_param(paraModel, 'ParameterTunabilityLossMsg', 'warning'); % Detect loss of tunability 173 | set_param(paraModel, 'ReadBeforeWriteMsg', 'EnableAllAsWarning'); % Detect read before write 174 | set_param(paraModel, 'WriteAfterReadMsg', 'EnableAllAsWarning'); % Detect write after read 175 | set_param(paraModel, 'WriteAfterWriteMsg', 'EnableAllAsWarning'); % Detect write after write 176 | set_param(paraModel, 'MultiTaskDSMMsg', 'error'); % Multitask data store 177 | set_param(paraModel, 'UniqueDataStoreMsg', 'warning'); % Duplicate data store names 178 | set_param(paraModel, 'UnderspecifiedInitializationDetection', 'Simplified'); % Underspecified initialization detection 179 | set_param(paraModel, 'ArrayBoundsChecking', 'none'); % Array bounds exceeded 180 | set_param(paraModel, 'AssertControl', 'DisableAll'); % Model Verification block enabling 181 | set_param(paraModel, 'AllowSymbolicDim', 'off'); % Allow symbolic dimension specification 182 | set_param(paraModel, 'UnnecessaryDatatypeConvMsg', 'warning'); % Unnecessary type conversions 183 | set_param(paraModel, 'VectorMatrixConversionMsg', 'warning'); % Vector/matrix block input conversion 184 | set_param(paraModel, 'Int32ToFloatConvMsg', 'warning'); % 32-bit integer to single precision float conversion 185 | set_param(paraModel, 'FixptConstUnderflowMsg', 'warning'); % Detect underflow 186 | set_param(paraModel, 'FixptConstOverflowMsg', 'warning'); % Detect overflow 187 | set_param(paraModel, 'FixptConstPrecisionLossMsg', 'warning'); % Detect precision loss 188 | set_param(paraModel, 'SignalLabelMismatchMsg', 'warning'); % Signal label mismatch 189 | set_param(paraModel, 'UnconnectedInputMsg', 'warning'); % Unconnected block input ports 190 | set_param(paraModel, 'UnconnectedOutputMsg', 'warning'); % Unconnected block output ports 191 | set_param(paraModel, 'UnconnectedLineMsg', 'warning'); % Unconnected line 192 | set_param(paraModel, 'RootOutportRequireBusObject', 'warning'); % Unspecified bus object at root Outport block 193 | set_param(paraModel, 'BusObjectLabelMismatch', 'warning'); % Element name mismatch 194 | set_param(paraModel, 'StrictBusMsg', 'ErrorOnBusTreatedAsVector'); % Bus signal treated as vector 195 | set_param(paraModel, 'NonBusSignalsTreatedAsBus', 'warning'); % Non-bus signals treated as bus signals 196 | set_param(paraModel, 'BusNameAdapt', 'WarnAndRepair'); % Repair bus selections 197 | set_param(paraModel, 'InvalidFcnCallConnMsg', 'error'); % Invalid function-call connection 198 | set_param(paraModel, 'FcnCallInpInsideContextMsg', 'error'); % Context-dependent inputs 199 | set_param(paraModel, 'SFcnCompatibilityMsg', 'warning'); % S-function upgrades needed 200 | set_param(paraModel, 'FrameProcessingCompatibilityMsg', 'error'); % Block behavior depends on frame status of signal 201 | set_param(paraModel, 'ModelReferenceVersionMismatchMessage', 'warning'); % Model block version mismatch 202 | set_param(paraModel, 'ModelReferenceIOMismatchMessage', 'warning'); % Port and parameter mismatch 203 | set_param(paraModel, 'ModelReferenceIOMsg', 'warning'); % Invalid root Inport/Outport block connection 204 | set_param(paraModel, 'ModelReferenceDataLoggingMessage', 'warning'); % Unsupported data logging 205 | set_param(paraModel, 'SaveWithDisabledLinksMsg', 'warning'); % Block diagram contains disabled library links 206 | set_param(paraModel, 'SaveWithParameterizedLinksMsg', 'warning'); % Block diagram contains parameterized library links 207 | set_param(paraModel, 'SFUnusedDataAndEventsDiag', 'warning'); % Unused data, events, messages and functions 208 | set_param(paraModel, 'SFUnexpectedBacktrackingDiag', 'error'); % Unexpected backtracking 209 | set_param(paraModel, 'SFInvalidInputDataAccessInChartInitDiag', 'warning'); % Invalid input data access in chart initialization 210 | set_param(paraModel, 'SFNoUnconditionalDefaultTransitionDiag', 'error'); % No unconditional default transitions 211 | set_param(paraModel, 'SFTransitionOutsideNaturalParentDiag', 'warning'); % Transition outside natural parent 212 | set_param(paraModel, 'SFUnreachableExecutionPathDiag', 'warning'); % Unreachable execution path 213 | set_param(paraModel, 'SFUndirectedBroadcastEventsDiag', 'warning'); % Undirected event broadcasts 214 | set_param(paraModel, 'SFTransitionActionBeforeConditionDiag', 'warning'); % Transition action specified before condition action 215 | set_param(paraModel, 'SFOutputUsedAsStateInMooreChartDiag', 'error'); % Read-before-write to output in Moore chart 216 | set_param(paraModel, 'SFTemporalDelaySmallerThanSampleTimeDiag', 'warning'); % Absolute time temporal value shorter than sampling period 217 | set_param(paraModel, 'SFSelfTransitionDiag', 'warning'); % Self-transition on leaf state 218 | set_param(paraModel, 'SFExecutionAtInitializationDiag', 'warning'); % 'Execute-at-initialization' disabled in presence of input events 219 | set_param(paraModel, 'SFMachineParentedDataDiag', 'warning'); % Use of machine-parented data instead of Data Store Memory 220 | set_param(paraModel, 'IgnoredZcDiagnostic', 'warning'); % IgnoredZcDiagnostic 221 | set_param(paraModel, 'InitInArrayFormatMsg', 'warning'); % InitInArrayFormatMsg 222 | set_param(paraModel, 'MaskedZcDiagnostic', 'warning'); % MaskedZcDiagnostic 223 | set_param(paraModel, 'ModelReferenceSymbolNameMessage', 'warning'); % ModelReferenceSymbolNameMessage 224 | set_param(paraModel, 'AllowedUnitSystems', 'all'); % Allowed unit systems 225 | set_param(paraModel, 'UnitsInconsistencyMsg', 'warning'); % Units inconsistency messages 226 | set_param(paraModel, 'AllowAutomaticUnitConversions', 'on'); % Allow automatic unit conversions 227 | 228 | % Hardware Implementation 229 | set_param(paraModel, 'ProdHWDeviceType', 'Infineon->TriCore'); % Production device vendor and type 230 | set_param(paraModel, 'ProdLongLongMode', 'off'); % Support long long in production hardware 231 | set_param(paraModel, 'ProdLargestAtomicInteger', 'Char'); % Production hardware largest atomic integer size 232 | set_param(paraModel, 'ProdLargestAtomicFloat', 'Float'); % Production hardware largest atomic floating-point size 233 | set_param(paraModel, 'ProdIntDivRoundTo', 'Zero'); % Production hardware signed integer division rounds to 234 | set_param(paraModel, 'ProdEqTarget', 'on'); % Test hardware is the same as production hardware 235 | set_param(paraModel, 'TargetPreprocMaxBitsSint', 32); % TargetPreprocMaxBitsSint 236 | set_param(paraModel, 'TargetPreprocMaxBitsUint', 32); % TargetPreprocMaxBitsUint 237 | 238 | % Model Referencing 239 | set_param(paraModel, 'UpdateModelReferenceTargets', 'IfOutOfDateOrStructuralChange'); % Rebuild 240 | set_param(paraModel, 'EnableParallelModelReferenceBuilds', 'off'); % Enable parallel model reference builds 241 | set_param(paraModel, 'ModelReferenceNumInstancesAllowed', 'Multi'); % Total number of instances allowed per top model 242 | set_param(paraModel, 'PropagateVarSize', 'Infer from blocks in model'); % Propagate sizes of variable-size signals 243 | set_param(paraModel, 'ModelReferenceMinAlgLoopOccurrences', 'off'); % Minimize algebraic loop occurrences 244 | set_param(paraModel, 'EnableRefExpFcnMdlSchedulingChecks', 'on'); % Enable strict scheduling checks for referenced export-function models 245 | set_param(paraModel, 'PropagateSignalLabelsOutOfModel', 'on'); % Propagate all signal labels out of the model 246 | set_param(paraModel, 'ModelReferencePassRootInputsByReference', 'off'); % Pass fixed-size scalar root inputs by value for code generation 247 | set_param(paraModel, 'ModelDependencies', ''); % Model dependencies 248 | set_param(paraModel, 'ParallelModelReferenceErrorOnInvalidPool', 'on'); % ParallelModelReferenceErrorOnInvalidPool 249 | set_param(paraModel, 'SupportModelReferenceSimTargetCustomCode', 'off'); % SupportModelReferenceSimTargetCustomCode 250 | 251 | % Simulation Target 252 | set_param(paraModel, 'MATLABDynamicMemAlloc', 'off'); % Dynamic memory allocation in MATLAB Function blocks 253 | set_param(paraModel, 'CompileTimeRecursionLimit', 50); % Compile-time recursion limit for MATLAB functions 254 | set_param(paraModel, 'EnableRuntimeRecursion', 'on'); % Enable run-time recursion for MATLAB functions 255 | set_param(paraModel, 'SFSimEcho', 'on'); % Echo expressions without semicolons 256 | set_param(paraModel, 'SimCtrlC', 'on'); % Ensure responsiveness 257 | set_param(paraModel, 'SimIntegrity', 'on'); % Ensure memory integrity 258 | set_param(paraModel, 'SimGenImportedTypeDefs', 'off'); % Generate typedefs for imported bus and enumeration types 259 | set_param(paraModel, 'SimBuildMode', 'sf_incremental_build'); % Simulation target build mode 260 | set_param(paraModel, 'SimReservedNameArray', []); % Reserved names 261 | % set_param(paraModel, 'SimParseCustomCode', 'off'); % Parse custom code symbols 262 | % set_param(paraModel, 'SimCustomSourceCode', ''); % Source file 263 | % set_param(paraModel, 'SimCustomHeaderCode', ''); % Header file 264 | % set_param(paraModel, 'SimCustomInitializer', ''); % Initialize function 265 | % set_param(paraModel, 'SimCustomTerminator', ''); % Terminate function 266 | % set_param(paraModel, 'SimUserIncludeDirs', ''); % Include directories 267 | % set_param(paraModel, 'SimUserSources', ''); % Source files 268 | % set_param(paraModel, 'SimUserLibraries', ''); % Libraries 269 | % set_param(paraModel, 'SimUserDefines', ''); % Defines 270 | set_param(paraModel, 'SFSimEnableDebug', 'off'); % Allow setting breakpoints during simulation 271 | 272 | % Code Generation 273 | set_param(paraModel, 'RemoveResetFunc', 'on'); % Remove reset function 274 | set_param(paraModel, 'ExistingSharedCode', ''); % Existing shared code 275 | set_param(paraModel, 'TargetLang', 'C'); % Language 276 | set_param(paraModel, 'CompOptLevelCompliant', 'on'); % CompOptLevelCompliant 277 | set_param(paraModel, 'Toolchain', 'Automatically locate an installed toolchain'); % Toolchain 278 | set_param(paraModel, 'BuildConfiguration', 'Faster Builds'); % Build configuration 279 | set_param(paraModel, 'ObjectivePriorities', []); % Prioritized objectives 280 | set_param(paraModel, 'CheckMdlBeforeBuild', 'off'); % Check model before generating code 281 | set_param(paraModel, 'SILDebugging', 'off'); % Enable source-level debugging for SIL 282 | set_param(paraModel, 'GenCodeOnly', 'on'); % Generate code only 283 | set_param(paraModel, 'PackageGeneratedCodeAndArtifacts', 'off'); % Package code and artifacts 284 | set_param(paraModel, 'RTWVerbose', 'off'); % Verbose build 285 | set_param(paraModel, 'RetainRTWFile', 'off'); % Retain .rtw file 286 | set_param(paraModel, 'ProfileTLC', 'off'); % Profile TLC 287 | set_param(paraModel, 'TLCDebug', 'off'); % Start TLC debugger when generating code 288 | set_param(paraModel, 'TLCCoverage', 'off'); % Start TLC coverage when generating code 289 | set_param(paraModel, 'TLCAssert', 'off'); % Enable TLC assertion 290 | % set_param(paraModel, 'RTWUseSimCustomCode', 'off'); % Use the same custom code settings as Simulation Target 291 | % set_param(paraModel, 'CustomSourceCode', ''); % Source file 292 | % set_param(paraModel, 'CustomHeaderCode', ''); % Header file 293 | % set_param(paraModel, 'CustomInclude', ''); % Include directories 294 | % set_param(paraModel, 'CustomSource', ''); % Source files 295 | % set_param(paraModel, 'CustomLibrary', ''); % Libraries 296 | % set_param(paraModel, 'CustomLAPACKCallback', ''); % Custom LAPACK library callback 297 | % set_param(paraModel, 'CustomDefine', ''); % Defines 298 | % set_param(paraModel, 'CustomInitializer', ''); % Initialize function 299 | % set_param(paraModel, 'CustomTerminator', ''); % Terminate function 300 | set_param(paraModel, 'CodeExecutionProfiling', 'off'); % Measure task execution time 301 | set_param(paraModel, 'CodeProfilingInstrumentation', 'off'); % Measure function execution times 302 | set_param(paraModel, 'CodeCoverageSettings', coder.coverage.CodeCoverageSettings([],'off','off','None')); % Third-party tool 303 | set_param(paraModel, 'CreateSILPILBlock', 'None'); % Create block 304 | set_param(paraModel, 'PortableWordSizes', 'on'); % Enable portable word sizes 305 | set_param(paraModel, 'PostCodeGenCommand', ''); % Post code generation command 306 | set_param(paraModel, 'SaveLog', 'off'); % Save build log 307 | set_param(paraModel, 'TLCOptions', ''); % TLC command line options 308 | set_param(paraModel, 'GenerateReport', 'on'); % Create code generation report 309 | set_param(paraModel, 'LaunchReport', 'on'); % Open report automatically 310 | set_param(paraModel, 'IncludeHyperlinkInReport', 'on'); % Code-to-model 311 | set_param(paraModel, 'GenerateTraceInfo', 'on'); % Model-to-code 312 | set_param(paraModel, 'GenerateWebview', 'off'); % Generate model Web view 313 | set_param(paraModel, 'GenerateTraceReport', 'on'); % Eliminated / virtual blocks 314 | set_param(paraModel, 'GenerateTraceReportSl', 'on'); % Traceable Simulink blocks 315 | set_param(paraModel, 'GenerateTraceReportSf', 'on'); % Traceable Stateflow objects 316 | set_param(paraModel, 'GenerateTraceReportEml', 'on'); % Traceable MATLAB functions 317 | set_param(paraModel, 'GenerateCodeMetricsReport', 'on'); % Static code metrics 318 | set_param(paraModel, 'GenerateCodeReplacementReport', 'on'); % Summarize which blocks triggered code replacements 319 | set_param(paraModel, 'GenerateComments', 'on'); % Include comments 320 | set_param(paraModel, 'SimulinkBlockComments', 'on'); % Simulink block / Stateflow object comments 321 | set_param(paraModel, 'MATLABSourceComments', 'on'); % MATLAB source code as comments 322 | set_param(paraModel, 'ShowEliminatedStatement', 'on'); % Show eliminated blocks 323 | set_param(paraModel, 'ForceParamTrailComments', 'on'); % Verbose comments for SimulinkGlobal storage class 324 | set_param(paraModel, 'OperatorAnnotations', 'on'); % Operator annotations 325 | set_param(paraModel, 'InsertBlockDesc', 'on'); % Simulink block descriptions 326 | set_param(paraModel, 'SFDataObjDesc', 'on'); % Stateflow object descriptions 327 | set_param(paraModel, 'SimulinkDataObjDesc', 'on'); % Simulink data object descriptions 328 | set_param(paraModel, 'ReqsInCode', 'off'); % Requirements in block comments 329 | set_param(paraModel, 'EnableCustomComments', 'off'); % Custom comments (MPT objects only) 330 | set_param(paraModel, 'MATLABFcnDesc', 'on'); % MATLAB function help text 331 | set_param(paraModel, 'CustomSymbolStrGlobalVar', '$R$N$M'); % Global variables 332 | set_param(paraModel, 'CustomSymbolStrType', '$N$R$M_T'); % Global types 333 | set_param(paraModel, 'CustomSymbolStrField', '$N$M'); % Field name of global types 334 | set_param(paraModel, 'CustomSymbolStrFcn', '$R$N$M$F'); % Subsystem methods 335 | set_param(paraModel, 'CustomSymbolStrFcnArg', 'rt$I$N$M'); % Subsystem method arguments 336 | set_param(paraModel, 'CustomSymbolStrTmpVar', '$N$M'); % Local temporary variables 337 | set_param(paraModel, 'CustomSymbolStrBlkIO', 'rtb_$N$M'); % Local block output variables 338 | set_param(paraModel, 'CustomSymbolStrMacro', '$R$N$M'); % Constant macros 339 | set_param(paraModel, 'CustomSymbolStrUtil', '$N$C'); % Shared utilities 340 | set_param(paraModel, 'CustomSymbolStrEmxType', 'emxArray_$M$N'); % EMX array types identifier format 341 | set_param(paraModel, 'CustomSymbolStrEmxFcn', 'emx$M$N'); % EMX array utility functions identifier format 342 | set_param(paraModel, 'MangleLength', 4); % Minimum mangle length 343 | set_param(paraModel, 'MaxIdLength', 128); % Maximum identifier length 344 | set_param(paraModel, 'InternalIdentifier', 'Shortened'); % System-generated identifiers 345 | set_param(paraModel, 'InlinedPrmAccess', 'Literals'); % Generate scalar inlined parameters as 346 | set_param(paraModel, 'SignalNamingRule', 'None'); % Signal naming 347 | set_param(paraModel, 'ParamNamingRule', 'None'); % Parameter naming 348 | set_param(paraModel, 'DefineNamingRule', 'None'); % #define naming 349 | set_param(paraModel, 'UseSimReservedNames', 'off'); % Use the same reserved names as Simulation Target 350 | set_param(paraModel, 'ReservedNameArray', []); % Reserved names 351 | set_param(paraModel, 'IgnoreCustomStorageClasses', 'off'); % Ignore custom storage classes 352 | set_param(paraModel, 'IgnoreTestpoints', 'on'); % Ignore test point signals 353 | set_param(paraModel, 'CommentStyle', 'Auto'); % Comment style 354 | set_param(paraModel, 'IncAutoGenComments', 'off'); % IncAutoGenComments 355 | set_param(paraModel, 'IncDataTypeInIds', 'off'); % IncDataTypeInIds 356 | set_param(paraModel, 'IncHierarchyInIds', 'off'); % IncHierarchyInIds 357 | set_param(paraModel, 'InsertPolySpaceComments', 'off'); % Insert Polyspace comments 358 | set_param(paraModel, 'PreserveName', 'off'); % PreserveName 359 | set_param(paraModel, 'PreserveNameWithParent', 'off'); % PreserveNameWithParent 360 | set_param(paraModel, 'CustomUserTokenString', ''); % Custom token text 361 | set_param(paraModel, 'TargetLangStandard', 'C89/C90 (ANSI)'); % Standard math library 362 | set_param(paraModel, 'CodeReplacementLibrary', 'None'); % Code replacement library 363 | set_param(paraModel, 'UtilityFuncGeneration', 'Shared location'); % Shared code placement 364 | set_param(paraModel, 'CodeInterfacePackaging', 'Nonreusable function'); % Code interface packaging 365 | set_param(paraModel, 'GRTInterface', 'off'); % Classic call interface 366 | set_param(paraModel, 'PurelyIntegerCode', 'off'); % Support floating-point numbers 367 | set_param(paraModel, 'SupportNonFinite', 'off'); % Support non-finite numbers 368 | set_param(paraModel, 'SupportComplex', 'off'); % Support complex numbers 369 | set_param(paraModel, 'SupportAbsoluteTime', 'off'); % Support absolute time 370 | set_param(paraModel, 'SupportContinuousTime', 'off'); % Support continuous time 371 | set_param(paraModel, 'SupportNonInlinedSFcns', 'off'); % Support non-inlined S-functions 372 | set_param(paraModel, 'SupportVariableSizeSignals', 'off'); % Support variable-size signals 373 | set_param(paraModel, 'MultiwordTypeDef', 'System defined'); % Multiword type definitions 374 | set_param(paraModel, 'CombineOutputUpdateFcns', 'on'); % Single output/update function 375 | set_param(paraModel, 'IncludeMdlTerminateFcn', 'off'); % Terminate function required 376 | set_param(paraModel, 'MatFileLogging', 'off'); % MAT-file logging 377 | set_param(paraModel, 'SuppressErrorStatus', 'on'); % Remove error status field in real-time model data structure 378 | set_param(paraModel, 'CombineSignalStateStructs', 'off'); % Combine signal/state structures 379 | set_param(paraModel, 'ParenthesesLevel', 'Maximum'); % Parentheses level 380 | set_param(paraModel, 'CastingMode', 'Standards'); % Casting modes 381 | set_param(paraModel, 'GenerateSampleERTMain', 'on'); % Generate an example main program 382 | set_param(paraModel, 'IncludeFileDelimiter', 'UseQuote'); % #include file delimiter 383 | set_param(paraModel, 'CPPClassGenCompliant', 'on'); % CPPClassGenCompliant 384 | set_param(paraModel, 'ConcurrentExecutionCompliant', 'on'); % ConcurrentExecutionCompliant 385 | set_param(paraModel, 'ERTCustomFileBanners', 'on'); % ERTCustomFileBanners 386 | set_param(paraModel, 'ERTFirstTimeCompliant', 'on'); % ERTFirstTimeCompliant 387 | set_param(paraModel, 'GenerateFullHeader', 'on'); % GenerateFullHeader 388 | set_param(paraModel, 'InferredTypesCompatibility', 'off'); % InferredTypesCompatibility 389 | set_param(paraModel, 'GenerateSharedConstants', 'off'); % Generate shared constants 390 | set_param(paraModel, 'ModelReferenceCompliant', 'on'); % ModelReferenceCompliant 391 | set_param(paraModel, 'ModelStepFunctionPrototypeControlCompliant', 'on'); % ModelStepFunctionPrototypeControlCompliant 392 | set_param(paraModel, 'ParMdlRefBuildCompliant', 'on'); % ParMdlRefBuildCompliant 393 | set_param(paraModel, 'TargetFcnLib', 'ansi_tfl_table_tmw.mat'); % TargetFcnLib 394 | set_param(paraModel, 'TargetLibSuffix', ''); % TargetLibSuffix 395 | set_param(paraModel, 'TargetPreCompLibLocation', ''); % TargetPreCompLibLocation 396 | set_param(paraModel, 'UseToolchainInfoCompliant', 'on'); % UseToolchainInfoCompliant 397 | set_param(paraModel, 'RemoveDisableFunc', 'off'); % Remove disable function 398 | set_param(paraModel, 'MemSecPackage', '--- None ---'); % Memory sections package for model data and functions 399 | set_param(paraModel, 'GlobalDataDefinition', 'Auto'); % Data definition 400 | set_param(paraModel, 'GlobalDataReference', 'Auto'); % Data declaration 401 | set_param(paraModel, 'ExtMode', 'off'); % External mode 402 | set_param(paraModel, 'EnableUserReplacementTypes', 'on'); % Replace data type names in the generated code 403 | set_param(paraModel, 'ConvertIfToSwitch', 'on'); % Convert if-elseif-else patterns to switch-case statements 404 | set_param(paraModel, 'ERTCustomFileTemplate', 'example_file_process.tlc'); % File customization template 405 | set_param(paraModel, 'ERTDataHdrFileTemplate', 'ert_code_template.cgt'); % Header file template 406 | set_param(paraModel, 'ERTDataSrcFileTemplate', 'ert_code_template.cgt'); % Source file template 407 | set_param(paraModel, 'ERTFilePackagingFormat', 'Compact'); % File packaging format 408 | set_param(paraModel, 'ERTHdrFileBannerTemplate', 'ert_code_template.cgt'); % Header file template 409 | set_param(paraModel, 'ERTSrcFileBannerTemplate', 'ert_code_template.cgt'); % Source file template 410 | set_param(paraModel, 'EnableDataOwnership', 'off'); % Use owner from data object for data definition placement 411 | set_param(paraModel, 'GenerateASAP2', 'on'); % ASAP2 interface 412 | set_param(paraModel, 'IndentSize', '4'); % Indent size 413 | set_param(paraModel, 'IndentStyle', 'Allman'); % Indent style 414 | set_param(paraModel, 'InlinedParameterPlacement', 'Hierarchical'); % Parameter structure 415 | set_param(paraModel, 'MemSecDataConstants', 'Default'); % Memory section for constants 416 | set_param(paraModel, 'MemSecDataIO', 'Default'); % Memory section for inputs/outputs 417 | set_param(paraModel, 'MemSecDataInternal', 'Default'); % Memory section for internal data 418 | set_param(paraModel, 'MemSecDataParameters', 'Default'); % Memory section for parameters 419 | set_param(paraModel, 'MemSecFuncExecute', 'Default'); % Memory section for execution functions 420 | set_param(paraModel, 'MemSecFuncInitTerm', 'Default'); % Memory section for initialize/terminate functions 421 | set_param(paraModel, 'MemSecFuncSharedUtil', 'Default'); % Memory section for shared utility functions 422 | set_param(paraModel, 'ParamTuneLevel', 10); % Parameter tune level 423 | set_param(paraModel, 'EnableSignedLeftShifts', 'off'); % Replace multiplications by powers of two with signed bitwise shifts 424 | set_param(paraModel, 'EnableSignedRightShifts', 'off'); % Allow right shifts on signed integers 425 | set_param(paraModel, 'PreserveExpressionOrder', 'on'); % Preserve operand order in expression 426 | set_param(paraModel, 'PreserveExternInFcnDecls', 'on'); % Preserve extern keyword in function declarations 427 | set_param(paraModel, 'PreserveIfCondition', 'on'); % Preserve condition expression in if statement 428 | set_param(paraModel, 'RTWCAPIParams', 'off'); % Generate C API for parameters 429 | set_param(paraModel, 'RTWCAPIRootIO', 'off'); % Generate C API for root-level I/O 430 | set_param(paraModel, 'RTWCAPISignals', 'off'); % Generate C API for signals 431 | set_param(paraModel, 'RTWCAPIStates', 'off'); % Generate C API for states 432 | set_param(paraModel, 'RateGroupingCode', 'on'); % RateGroupingCode 433 | set_param(paraModel, 'ReplacementTypes', struct('double','','single','','int32','','int16','','int8','','uint32','','uint16','','uint8','','boolean','','int','','uint','','char','')); % Data type names 434 | set_param(paraModel, 'SignalDisplayLevel', 10); % Signal display level 435 | set_param(paraModel, 'SuppressUnreachableDefaultCases', 'off'); % Suppress generation of default cases for Stateflow switch statements if unreachable 436 | set_param(paraModel, 'TargetOS', 'BareBoardExample'); % Target operating system 437 | set_param(paraModel, 'BooleanTrueId', 'true'); % Boolean true identifier 438 | set_param(paraModel, 'BooleanFalseId', 'false'); % Boolean false identifier 439 | set_param(paraModel, 'MaxIdInt32', 'MAX_int32_T'); % 32-bit integer maximum identifier 440 | set_param(paraModel, 'MinIdInt32', 'MIN_int32_T'); % 32-bit integer minimum identifier 441 | set_param(paraModel, 'MaxIdUint32', 'MAX_uint32_T'); % 32-bit unsigned integer maximum identifier 442 | set_param(paraModel, 'MaxIdInt16', 'MAX_int16_T'); % 16-bit integer maximum identifier 443 | set_param(paraModel, 'MinIdInt16', 'MIN_int16_T'); % 16-bit integer minimum identifier 444 | set_param(paraModel, 'MaxIdUint16', 'MAX_uint16_T'); % 16-bit unsigned integer maximum identifier 445 | set_param(paraModel, 'MaxIdInt8', 'MAX_int8_T'); % 8-bit integer maximum identifier 446 | set_param(paraModel, 'MinIdInt8', 'MIN_int8_T'); % 8-bit integer minimum identifier 447 | set_param(paraModel, 'MaxIdUint8', 'MAX_uint8_T'); % 8-bit unsigned integer maximum identifier 448 | set_param(paraModel, 'TypeLimitIdReplacementHeaderFile', ''); % Type limit identifier replacement header file 449 | 450 | % Simulink Coverage 451 | set_param(paraModel, 'CovModelRefEnable', 'off'); % Record coverage for referenced models 452 | set_param(paraModel, 'RecordCoverage', 'off'); % Record coverage for this model 453 | set_param(paraModel, 'CovEnable', 'off'); % Enable coverage analysis 454 | set_param(paraModel, 'CovEnableCumulative', 'on'); % Enable cumulative data collection 455 | set_param(paraModel, 'CovSaveCumulativeToWorkspaceVar', 'on'); % Save cumulative coverage results in workspace variable 456 | set_param(paraModel, 'CovCumulativeVarName', 'covCumulativeData'); % Cumulative coverage variable name 457 | set_param(paraModel, 'CovSaveName', 'covdata'); % Last coverage run variable name 458 | set_param(paraModel, 'CovNameIncrementing', 'off'); % Increment cvdata variable name with each simulation 459 | set_param(paraModel, 'CovReportOnPause', 'on'); % Update coverage results on pause 460 | set_param(paraModel, 'CovHTMLOptions', ''); % Coverage report options 461 | set_param(paraModel, 'CovCumulativeReport', 'off'); % Include cumulative data in coverage report 462 | set_param(paraModel, 'CovCompData', ''); % Additional data to include in coverage report 463 | set_param(paraModel, 'CovFilter', ''); % Coverage filter filename 464 | set_param(paraModel, 'CovSaveOutputData', 'on'); % Save output data 465 | 466 | % HDL Coder 467 | hdlset_param(paraModel,'GenerateHDLCode','off'); % Generate HDL code 468 | 469 | Configurate = 'ERT config successful,script version 1.3'; 470 | end 471 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 木兰宽松许可证, 第2版 2 | 3 | 木兰宽松许可证, 第2版 4 | 2020年1月 http://license.coscl.org.cn/MulanPSL2 5 | 6 | 7 | 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 8 | 9 | 0. 定义 10 | 11 | “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 12 | 13 | “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 14 | 15 | “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 16 | 17 | “法人实体”是指提交贡献的机构及其“关联实体”。 18 | 19 | “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 20 | 21 | 1. 授予版权许可 22 | 23 | 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 24 | 25 | 2. 授予专利许可 26 | 27 | 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 28 | 29 | 3. 无商标许可 30 | 31 | “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 32 | 33 | 4. 分发限制 34 | 35 | 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 36 | 37 | 5. 免责声明与责任限制 38 | 39 | “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 40 | 41 | 6. 语言 42 | “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 43 | 44 | 条款结束 45 | 46 | 如何将木兰宽松许可证,第2版,应用到您的软件 47 | 48 | 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 49 | 50 | 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 51 | 52 | 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 53 | 54 | 3, 请将如下声明文本放入每个源文件的头部注释中。 55 | 56 | Copyright (c) [Year] [name of copyright holder] 57 | [Software Name] is licensed under Mulan PSL v2. 58 | You can use this software according to the terms and conditions of the Mulan PSL v2. 59 | You may obtain a copy of Mulan PSL v2 at: 60 | http://license.coscl.org.cn/MulanPSL2 61 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 62 | See the Mulan PSL v2 for more details. 63 | 64 | 65 | Mulan Permissive Software License,Version 2 66 | 67 | Mulan Permissive Software License,Version 2 (Mulan PSL v2) 68 | January 2020 http://license.coscl.org.cn/MulanPSL2 69 | 70 | Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 71 | 72 | 0. Definition 73 | 74 | Software means the program and related documents which are licensed under this License and comprise all Contribution(s). 75 | 76 | Contribution means the copyrightable work licensed by a particular Contributor under this License. 77 | 78 | Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. 79 | 80 | Legal Entity means the entity making a Contribution and all its Affiliates. 81 | 82 | Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 83 | 84 | 1. Grant of Copyright License 85 | 86 | Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 87 | 88 | 2. Grant of Patent License 89 | 90 | Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 91 | 92 | 3. No Trademark License 93 | 94 | No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 95 | 96 | 4. Distribution Restriction 97 | 98 | You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 99 | 100 | 5. Disclaimer of Warranty and Limitation of Liability 101 | 102 | THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 103 | 104 | 6. Language 105 | 106 | THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. 107 | 108 | END OF THE TERMS AND CONDITIONS 109 | 110 | How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software 111 | 112 | To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: 113 | 114 | i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; 115 | 116 | ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; 117 | 118 | iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. 119 | 120 | 121 | Copyright (c) [Year] [name of copyright holder] 122 | [Software Name] is licensed under Mulan PSL v2. 123 | You can use this software according to the terms and conditions of the Mulan PSL v2. 124 | You may obtain a copy of Mulan PSL v2 at: 125 | http://license.coscl.org.cn/MulanPSL2 126 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 127 | See the Mulan PSL v2 for more details. 128 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # toto 工具箱 2 | 3 | > toto pro 工具在本项目 [toto_pro](https://gitee.com/qq353838430/toto/tree/toto_pro/) 分支上 ,该工具为商业版 4 | 5 | 6 | 7 | - [toto 工具箱](#toto-工具箱) 8 | - [1. 安装说明](#1-安装说明) 9 | - [2. 使用说明](#2-使用说明) 10 | - [2.1 ERT](#21-ert) 11 | - [2.2 AutoSAR](#22-autosar) 12 | - [2.3 隐藏模块名称](#23-隐藏模块名称) 13 | - [2.4 隐藏端口名称](#24-隐藏端口名称) 14 | - [2.5 显示模块名称](#25-显示模块名称) 15 | - [2.6 显示端口名称](#26-显示端口名称) 16 | - [2.7 SF变量类型定义](#27-sf变量类型定义) 17 | - [2.8 添加信号线变量](#28-添加信号线变量) 18 | - [2.9 勾选resolve](#29-勾选resolve) 19 | - [2.10 勾选信号广播](#210-勾选信号广播) 20 | - [2.11 端口重命名](#211-端口重命名) 21 | - [2.12 清除resolve](#212-清除resolve) 22 | - [2.13 清除信号广播](#213-清除信号广播) 23 | - [2.14 p文件生成](#214-p文件生成) 24 | - [2.15 修改端口属性](#215-修改端口属性) 25 | - [2.16 恢复端口属性](#216-恢复端口属性) 26 | - [2.17 信号线重命名](#217-信号线重命名) 27 | - [2.18 变量列表](#218-变量列表) 28 | - [2.19 修改变量](#219-修改变量) 29 | - [2.20 SF变量类型自动](#220-sf变量类型自动) 30 | 31 | 32 | 33 | 版本| 内容| 修改时间| 修改人 34 | ----|---|--------|-------- 35 | 0.1| 创建文档| 2017/9/12 | 姜世博 36 | 0.2|适配toto 0.2,增加自动修改stateflow中,变量数据类型功能| 2017/9/18 | 姜世博 37 | 0.3|适配toto 0.3,修改模型配置,ERT和AutoSAR配置脚本升级为v0.9|2017/9/23 | 姜世博 38 | 0.4|适配toto 0.4,增加 修改端口属性 和 恢复端口属性两个功能|2017/9/25 | 姜世博 39 | 0.5|ERT和AutoSAR配置脚本升级为v0.9.3 |2017/10/10 |姜世博 40 | 0.6|适配ERT和AutoSAR配置脚本 v0.9.4,更改`修改端口属性`和`恢复端口属性`两个按钮的策略,具体查看`2.15 修改端口属性`|2017/10/16 |姜世博 41 | 0.7|适配ERT和AutoSAR配置脚本 v0.9.5; 修复`修改端口属性`功能bug,在检测到模型配置中采样模式设为连续时,将端口采样时间时间设为默认的`-1`; 增加`信号线重命名`功能,此功能会将端口的名字命名到连接端口的信号线上,具体查看`2.17 信号线重命名`|2017/10/25|姜世博 42 | 0.8|适配ERT和AutoSAR配置脚本 v0.9.6; 修复`修改端口属性`功能bug,当模型设为非连续采样,但采样时间设为auto时,此功能将端口采样时间设为默认的`-1` |2017/11/2|姜世博 43 | 0.9|增加`变量列表`,和`修改变量`两个功能,可以对模型关联的数据字典和 信号线、端口、Constant模块、查表模块进行批量式名称修改;还可以将当前模型关联的数据字典,相关变量数值和数据类型列到excel中进行管理和修改,当前版本仅支持普通一维变量和 最高2维的查表数据变量。具体功能描述查看本文相应章节|2017/11/21| 姜世博 44 | 0.9.1|修改`变量列表`、`修改变量`两个功能,适用于一个模型挂载多个数据字典的情况;增加`SF变量类型自动`功能,该功能将stateflow中的变量,数据类型设为[Inherit: Same as Simulink],即可以使用数据字典中的定义控制state flow中的变量|2017/11/24|姜世博 45 | 0.9.2|适配ERT和AutoSAR配置脚本 v0.9.7; 修改`SF变量类型定义`,修改为将所有state flow 中变量进行数据类型自动定义,原策略为不包括输入输出变量;修改`变量列表`、`修改变量`两个功能,增加MyPkg类变量识别和修改,增加State flow 中变量识别和修改|2017/11/28|姜世博 46 | 0.9.3|适配AutoSAR配置 v0.9.7.1脚本| 2017/12/1| 姜世博 47 | 0.9.4|适配ERT和AutoSAR配置脚本 v0.9.8; 修改`变量列表`功能一些情况下出现的bug| 2017/12/8| 姜世博 48 | 0.9.5|适配ERT和AutoSAR配置脚本 v0.9.9| 2017/12/19 | 姜世博 49 | 0.9.6|增加 `修改变量`,`信号线重命名`,`端口重命名`,三个功能 对Goto 和From模块的支持| 2017/12/20|姜世博 50 | 0.9.7|适配ERT和AutoSAR配置脚本 V1.3 | 2018/11/3 | 姜世博 51 | 52 | -------------------------------------------- 53 | 54 | ## 1. 安装说明 55 | 56 | 1. 按照下图指示进行安装 57 | 58 | ![输入图片说明](https://gitee.com/uploads/images/2017/1124/222801_02612f42_1424277.png "深度截图_选择区域_20171124222641.png") 59 | 60 | 2. 安装完成后出现如下图标,点开即可使用 61 | 62 | ![输入图片说明](https://gitee.com/uploads/images/2017/1124/222828_3c7d4b6a_1424277.png "深度截图_选择区域_20171124222737.png") 63 | 64 | ## 2. 使用说明 65 | 66 | toto工具需要在**打开模型**时才能作为辅助工具进行使用,下图为工具界面概览 67 | 68 | ![输入图片说明](https://gitee.com/uploads/images/2017/1124/222919_c6a6648e_1424277.png "深度截图_选择区域_20171124222856.png") 69 | 70 | ### 2.1 ERT 71 | 72 | 将所打开的模型配置设为适合生成ERT(Embedded Coder)。 73 | 74 | ### 2.2 AutoSAR 75 | 76 | 将所打开的模型配置设为适合生成AutoSAR。 77 | 78 | ### 2.3 隐藏模块名称 79 | 80 | 隐藏如下模块的名称: 81 | MinMax,UnitDelay,Sqrt,Merge,Product,Logic,RelationalOperator,Switch,MultiPortSwitch,Goto,From,Terminator,ModelReference 82 | 83 | ### 2.4 隐藏端口名称 84 | 85 | 隐藏inport和outport输入输出模块的名称。 86 | 87 | ### 2.5 显示模块名称 88 | 89 | 显示可隐藏名称的模块的名字。 90 | 91 | ### 2.6 显示端口名称 92 | 93 | 显示inport和outport输入输出模块的名称。 94 | 95 | ### 2.7 SF变量类型定义 96 | 97 | 查找stateflow中所有定义的变量,如果为input/output,数据类型就设置为与simulink保持一致;如果为其它形式的变量,则会读取变量名字的末尾,并根据末尾定义成相应的数据类型,如果没有按照命名规范,则会定义成`uint8`的数据类型。 98 | 99 | ### 2.8 添加信号线变量 100 | 101 | 会根据信号线上的名字,在matlab workspace中添加相应数据类型的信号变量,自动添加的变量储存类型为Auto,如下为示例,需要注意信号线命名需要符合命名规范,末尾为数据类型简写才能实现此功能。 102 | 103 | 1. 原模型 104 | 105 | ![输入图片说明](https://gitee.com/uploads/images/2017/1124/223331_0d412512_1424277.png "深度截图_选择区域_20171124223313.png") 106 | 107 | 2. 点击添加信号线变量后 108 | 109 | ![输入图片说明](https://gitee.com/uploads/images/2017/1124/223442_14c69f68_1424277.png "深度截图_选择区域_20171124223426.png") 110 | 111 | 命名规范表格: 112 | 113 | 后缀| 数据类型 114 | ----|------------- 115 | _u8 | uint8 116 | _u16 | uint16 117 | _u32 | uint32 118 | _f32 | single 119 | _f64 | double 120 | _s8 | int8 121 | _s16 | int16 122 | _s32 | int32 123 | _bl | boolean 124 | 125 | ### 2.9 勾选resolve 126 | 127 | 在有名字的信号线上勾选`Signal name must resolve to Simulink signal object`选项。 128 | 129 | ### 2.10 勾选信号广播 130 | 131 | 勾选信号线`Show propagated signals`选项。 132 | 133 | ### 2.11 端口重命名 134 | 135 | 对于inport和outport模块,如果连接的信号线上定义了名字,则将这个端口模块重命名成信号线上定义的名字。 136 | 137 | ### 2.12 清除resolve 138 | 139 | 信号线上清除`Signal name must resolve to Simulink signal object`选项的勾选。 140 | 141 | ### 2.13 清除信号广播 142 | 143 | 清除信号线`Show propagated signals`选项的勾选。 144 | 145 | ### 2.14 p文件生成 146 | 147 | 将当前工作目录下(不包括子目录),所有.m的脚本文件生成一份.p文件的副本。 148 | 149 | ### 2.15 修改端口属性 150 | 151 | 根据端口所连接的信号线上,定义的信号名称,读取该名称末尾数据类型的定义,并根据所读到的数据类型,将inport 和outport端口的 数据维度,数据类型,数据范围,采样时间属性进行修改。仅更改模型root层的输入和输出端口属性,不对子系统进行修改,在遇到线上没有数据类型端口,不进行数据类型改写,当线上没有数据类型时,检测端口是否已经定义数据类型,如定义则根据所 定义的数据类型自动补全数据范围等其它属性 152 | 153 | ### 2.16 恢复端口属性 154 | 155 | 将inport和outport端口的数据维度,数据类型,数据范围,采样时间属性设置为默认选项。 156 | 157 | ### 2.17 信号线重命名 158 | 159 | 将连接输入输出端口的信号线,重命名成端口的名称,忽略掉已经勾选了信号广播的信号线。 160 | 161 | ### 2.18 变量列表 162 | 163 | 把数据字典和模型一些信息转成Excel表格,创建[model name]_list.xlsx的表格 164 | 165 | - 将当前模型所关联的数据字典中,所有变量名称 和 所关联的数据字典名称,写入名为dict的工作表中。 166 | - 将当前模型信号线上定义的名字,且该名字没有在数据字典中进行定义,写入only_line工作表中。 167 | - 将当前模型所有普通一维变量的名称,源数据字典,数据类型,数值,放入simu_parameter工作表中。 168 | - 将当前模型所有查表变量(最高2维)的名称,源数据字典,数据类型,表格维度,数值,放入simu_table工作表中。 169 | - 将当前模型所有state flow 变量 名称,范围,数据类型,放入sf_parameter工作表中。 170 | 171 | 自动生成的Excel如下图所示: 172 | ![2_18_001.jpg](http://p6ij1j575.bkt.clouddn.com/%E6%95%B0%E6%8D%AE%E5%AD%97%E5%85%B8%E8%BD%ACExcel.PNG) 173 | 174 | 注意,如果使用WPS,则需要开启wps表格的宏定义,并将matlab中的Excel link添加到宏定义中,相关教程如下: 175 | - [Excel 安装 Excel link][ExcelLink] 176 | - [Wps 安装 Excel link][WpsLink] 177 | 178 | ### 2.19 修改变量 179 | 180 | 根据Excel表格中的信息对模型和数据字典进行修改 181 | 182 | - 读取当前工作目录下`[model name]_list.xlsx`文件 183 | - 并读取其中dict、only_line、simu_parameter、simu_table、sf_parameter 五个工作表,并根据表中的命名情况和数据赋值情况 进行对模型中相应的名称进行修改。 184 | - 需注意,修改支持 重命名 和 新添加变量,为了进行保护,不支持删除原数据字典中的变量,如若删除需要到数据字典界面进行操作。 185 | - 模型中可进行修改的模块包括:数据字典,信号线,输入输出端口,Constant模块,查表模块。 186 | - 注意,如果当前工作目录下没有[model name]_list.xlsx这个文件,或格式不正确,则运行此条命令会报错,此时需要使用`变量列表`按钮生成一份标准的变量列表后,才能使用此按键。 187 | 188 | ### 2.20 SF变量类型自动 189 | 190 | 读取当前模型state flow中变量,并将这些变量数据类型设为 `[Inherit: Same as Simulink]`。 191 | 192 | -------------------------------------- 193 | 194 | [ExcelLink]:https://blog.csdn.net/zhangkaihang/article/details/7519783 195 | [WpsLink]:https://blog.csdn.net/u011511601/article/details/64921268 -------------------------------------------------------------------------------- /add_sig_parameter.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for patameters adding as defined. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.2 6 | % Instructions : 7 | %------------------------------------------------------------------------------ 8 | 9 | function add_parameter_result = add_sig_parameter() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R2017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character encoding... 27 | % (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | all_line = find_system(paraModel,'FindAll','on','type','line'); 32 | % Parameters define 33 | k = 1; 34 | named_flag = 0; 35 | length_line = length(all_line); 36 | % Find the line which have name 37 | for i = 1:length_line 38 | % Detect 'Signal name' 39 | current_line_name = get(all_line(i),'Name'); 40 | % judge whether signal has name 41 | if 1 == isempty(current_line_name) 42 | % no name 43 | ne_flag = 1; 44 | else 45 | % have name 46 | ne_flag = 0; 47 | end 48 | % collect signals name 49 | if 0 == ne_flag 50 | named_signals_line(k) = all_line(i); 51 | k = k + 1; 52 | named_flag = 1; 53 | else 54 | % Do nothing,keep named_flag = 0; 55 | end 56 | end 57 | 58 | % find simulink's variables 59 | simulink_var_space = get_param(paraModel,'ModelWorkspace'); 60 | simulink_var = simulink_var_space.whos; 61 | if 1 == isempty(simulink_var) 62 | % no variable defined 63 | simulink_var_flag = 0; 64 | else 65 | % have some variables defined 66 | simulink_var_flag = 1; 67 | end 68 | 69 | % judge whether signal's name have been defined to variables 70 | var_define_enable = 0; 71 | % have signal names and have some variables defined 72 | if (1 == named_flag)&&(1 == simulink_var_flag) 73 | length_named_line = length(named_signals_line); 74 | length_var = length(simulink_var); 75 | k = 1; 76 | for i = 1:length_named_line 77 | signal_name = get(named_signals_line(i),'Name'); 78 | for j = 1:length_var 79 | var_name = simulink_var(j).name; 80 | if 1 == strcmp(signal_name,var_name) 81 | break; 82 | else 83 | % collect name which need be defined 84 | if length_var == j 85 | var_need_defined{k} = signal_name; 86 | k = k + 1; 87 | var_define_enable = 1; 88 | else 89 | % Do nothing ,wrong state 90 | end 91 | end 92 | end 93 | end 94 | % have signal names and have no variables defined 95 | elseif (1 == named_flag)&&(0 == simulink_var_flag) 96 | length_named_line = length(named_signals_line); 97 | k = 1; 98 | for i = 1:length_named_line 99 | var_need_defined{k} = get(named_signals_line(i),'Name'); 100 | k = k + 1; 101 | end 102 | var_define_enable = 1; 103 | % have no signal names, do not auto define variables 104 | else 105 | % Do nothing 106 | end 107 | 108 | % auto add variables in simulink workspace 109 | if 1 == var_define_enable 110 | length_add_var = length(var_need_defined); 111 | for i = 1:length_add_var 112 | name_defined = var_need_defined{i}; 113 | % get the parameter datatpye 114 | data_type = name_defined(end-2:end); 115 | % translate the upper to lower 116 | data_type = lower(data_type); 117 | 118 | % calculate the data type config 119 | switch data_type 120 | case '_u8' 121 | data_type_cfg = 'uint8'; 122 | case 'u16' 123 | data_type_cfg = 'uint16'; 124 | case 'u32' 125 | data_type_cfg = 'uint32'; 126 | case 'f32' 127 | data_type_cfg = 'single'; 128 | case 'f64' 129 | data_type_cfg = 'double'; 130 | case '_s8' 131 | data_type_cfg = 'int8'; 132 | case 's16' 133 | data_type_cfg = 'int16'; 134 | case 's32' 135 | data_type_cfg = 'int32'; 136 | case '_bl' 137 | data_type_cfg = 'boolean'; 138 | otherwise 139 | data_type_cfg = 'uint8'; 140 | end 141 | % add the parameter 142 | try 143 | temp_defined = Simulink.Signal; 144 | temp_defined.DataType = data_type_cfg; 145 | assignin('base',name_defined,temp_defined); 146 | catch 147 | % do nothing 148 | end 149 | end 150 | % report configurate results 151 | add_parameter_result = 'Add signal parameters successful'; 152 | else 153 | % report configurate results 154 | add_parameter_result = 'No signal line have names'; 155 | end 156 | end 157 | -------------------------------------------------------------------------------- /auto_sf_par_type.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for define stateflow parameter's type as 3 | % 'Inherit: Same as Simulink'. 4 | % MATLAB : R2017a 5 | % Author : Shibo Jiang 6 | % Version : 0.2 7 | % Time : 2017/11/23 8 | % Instructions : Fix bugs -0.2 9 | %------------------------------------------------------------------------------ 10 | 11 | function result = auto_sf_par_type() 12 | 13 | paraModel = bdroot; 14 | 15 | % Original matalb version is R2017a 16 | % 检查Matlab版本是否为R2017a 17 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 18 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 19 | CurrentVersion = version; 20 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 21 | strcmp(CorrectVersion_linux, CurrentVersion)) 22 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 23 | end 24 | 25 | % Original environment character encoding: GBK 26 | % 脚本编码环境是否为GBK 27 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 28 | % warning('Simulink:EncodingUnMatched', 'The target character encoding (%s) is different from the original (%s).',... 29 | % get_param(0, 'CharacterEncoding'), 'GBK'); 30 | % end 31 | 32 | % find all stateflow parameter 33 | sf = sfroot; 34 | all_sf_parameter = sf.find('-isa','Stateflow.Data'); 35 | 36 | if isempty(all_sf_parameter) 37 | % report the result 38 | result = 'There is no stateflow parameter in this model.'; 39 | else 40 | % define the input/output parameter's data type 41 | length_sf_par = length(all_sf_parameter); 42 | for i = 1:length_sf_par 43 | set(all_sf_parameter(i),'DataType','Inherit: Same as Simulink'); 44 | end 45 | result = 'Define stateflow parameters datatype as [Inherit: Same as Simulink] successful'; 46 | 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /change_parameter.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for rename parameters and change parameter's value. 3 | % MATLAB : R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.7 6 | % Time : 2017/12/20 7 | % Instructions : Add change stateflow parameter function. 8 | % Add creat new parameter function. - 0.3 9 | % Fix bugs ,message can report clearly - 0.4 10 | % Code refactoring - 0.5 11 | % Add state flow parameter changed 12 | % Add storge calss change - 0.6 13 | % Support goto & from block - 0.7 14 | % Support under masked block changing name - 0.8 15 | %------------------------------------------------------------------------------ 16 | function output = change_parameter() 17 | 18 | paraModel = bdroot; 19 | 20 | % Original matalb version is R2017a 21 | % 检查Matlab版本是否为R202017a 22 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 23 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 24 | CurrentVersion = version; 25 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 26 | strcmp(CorrectVersion_linux, CurrentVersion)) 27 | warning(['Matlab version mismatch, this scrip should be' ... 28 | 'used for Matlab R2017a']); 29 | end 30 | 31 | % % Get inter parameter which defined in model workspace 32 | % simulink_var_space = get_param(paraModel,'ModelWorkspace'); 33 | % simulink_par_inter = simulink_var_space.whos; 34 | 35 | % Define list file's name 36 | filename = [paraModel,'_list.xlsx']; 37 | 38 | % Open outlink parameter which defined in data dictionary 39 | data_dictionary = get_param(paraModel, 'DataDictionary'); 40 | current_dic = Simulink.data.dictionary.open(data_dictionary); 41 | dic_entry = getSection(current_dic, 'Design Data'); 42 | 43 | % Find data in dictionary&model and change name 44 | % Import excel file's data 45 | [number_par, name_par] = xlsread(filename, 'dict'); 46 | [number_line, name_line] = xlsread(filename, 'only_line'); 47 | NAME_START_ROW = 2; 48 | STR_COLUMN_END = 3; 49 | 50 | % Jduge only_line & dict sheet is empty? 51 | if isempty(number_par) 52 | temp_judge_par = 2; 53 | else 54 | temp_judge_par = 0; 55 | end 56 | 57 | if isempty(number_line) 58 | temp_judge_line = 1; 59 | else 60 | temp_judge_line = 0; 61 | end 62 | 63 | switch (temp_judge_line + temp_judge_par) 64 | case 0 65 | name_all = [name_par(NAME_START_ROW:end,1:STR_COLUMN_END);... 66 | name_line(NAME_START_ROW:end,1:STR_COLUMN_END)]; 67 | number_all = number_par(end,1) + number_line(end,1); 68 | case 1 69 | name_all = name_par(NAME_START_ROW:end,1:STR_COLUMN_END); 70 | number_all = number_par(end,1); 71 | case 2 72 | name_all = name_line(NAME_START_ROW:end,1:STR_COLUMN_END); 73 | number_all = number_line(end,1); 74 | case 3 75 | name_all = []; 76 | end 77 | 78 | % Whether writing paramter's name 79 | OLD_NAME_COL = 2; 80 | NEW_NAME_COL = 3; 81 | if ~isempty(name_all) 82 | i_diff_name = 1; 83 | for i = 1:number_all(end) 84 | temp_old = name_all{i, OLD_NAME_COL}; 85 | temp_new = name_all{i, NEW_NAME_COL}; 86 | if ~strcmp(temp_new, temp_old) 87 | % Find the parameter name in dict 88 | par_dict = find(dic_entry, 'Name', temp_old); 89 | % Find the parameter name in signal line 90 | par_signal = find_system(paraModel,'FindAll','on',... 91 | 'LookUnderMasks','on','FollowLinks','on','type','line', 'Name',temp_old); 92 | 93 | % % Find the parameter name in constant block 94 | % par_const = find_system(paraModel,'FindAll','on',... 95 | % 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Constant','Value', temp_old); 96 | 97 | % Find the paremeter name in constant which include dict constant 98 | par_const = []; 99 | dict_const_block = find_system(paraModel,'FindAll','on',... 100 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Constant'); 101 | if ~isempty(dict_const_block) 102 | par_const = zeros(1,length(dict_const_block)); 103 | for temp_index = 1:length(dict_const_block) 104 | temp_const_name = get(dict_const_block(temp_index),'Value'); 105 | if strcmp(temp_old, temp_const_name) 106 | par_const(temp_index) = dict_const_block(temp_index); 107 | break; 108 | end 109 | end 110 | end 111 | % Find the parameter name in table block 112 | par_nd_table = find_system(paraModel,'FindAll','on',... 113 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Lookup_n-D','Table', temp_old); 114 | par_direct_table = find_system(paraModel,'FindAll','on',... 115 | 'LookUnderMasks','on','FollowLinks','on','BlockType','LookupNDDirect',... 116 | 'Table', temp_old); 117 | % Find the parameter name in port block 118 | par_inport = find_system(paraModel,'FindAll','on',... 119 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Inport','Name', temp_old); 120 | par_outport = find_system(paraModel,'FindAll','on',... 121 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Outport','Name', temp_old); 122 | % Find the parameter name in stateflow 123 | sf = sfroot; 124 | par_sf_data = sf.find('-isa','Stateflow.Data',... 125 | 'Name', temp_old); 126 | % Find the goto block 127 | par_goto = find_system(paraModel,'FindAll','on',... 128 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'Goto','GotoTag', temp_old); 129 | % Find the from block 130 | par_from = find_system(paraModel,'FindAll','on',... 131 | 'LookUnderMasks','on','FollowLinks','on','BlockType', 'From','GotoTag', temp_old); 132 | 133 | 134 | % Set new name 135 | try 136 | par_dict.Name = temp_new; 137 | end 138 | SetNewName(par_signal, 'Name', temp_new); 139 | SetNewName(par_inport, 'Name', temp_new); 140 | SetNewName(par_outport, 'Name', temp_new); 141 | SetNewName(par_const, 'Value', temp_new); 142 | SetNewName(par_nd_table, 'Table', temp_new); 143 | SetNewName(par_direct_table, 'Table', temp_new); 144 | SetNewName(par_sf_data, 'Name', temp_new); 145 | SetNewName(par_goto, 'GotoTag', temp_new); 146 | SetNewName(par_from, 'GotoTag', temp_new); 147 | 148 | % Store diff name for changing value 149 | old_name{i_diff_name} = temp_old; 150 | new_name{i_diff_name} = temp_new; 151 | i_diff_name = i_diff_name + 1; 152 | else 153 | % Do nothing 154 | end 155 | end 156 | output = 'Rename parameter successful.' 157 | else 158 | output = 'No parameter name changed.' 159 | end 160 | 161 | % Find simulink parameter in list and change the datatype&value 162 | [num_simu_par, str_simu_par] = xlsread(filename, 'simu_parameter'); 163 | SIMU_PAR_NAME_COL = 2; 164 | SIMU_PAR_DATATYPE_COL = 4; 165 | SIMU_PAR_STORGE = 5; 166 | SIMU_PAR_VALUE = 6; 167 | if ~isempty(num_simu_par) 168 | for i = 1:num_simu_par(end,1) 169 | temp_simu_par_name = str_simu_par(i+1, SIMU_PAR_NAME_COL); 170 | temp_simu_par_datatype = str_simu_par(i+1, SIMU_PAR_DATATYPE_COL); 171 | temp_simu_par_storge = str_simu_par(i+1, SIMU_PAR_STORGE); 172 | temp_simu_par_value = num_simu_par(i, SIMU_PAR_VALUE); 173 | % Set new property 174 | temp_return = SetDictParameter(dic_entry,... 175 | temp_simu_par_name{1},... 176 | temp_simu_par_datatype{1},... 177 | temp_simu_par_storge{1},... 178 | temp_simu_par_value); 179 | % Report whether set successful 180 | if strcmp('Invalid name', temp_return) 181 | % Use new name to try again 182 | % Judge whether need find new name 183 | if 1 < i_diff_name 184 | % Find new name 185 | for i = 1:(i_diff_name-1) 186 | if strcmp(old_name{i}, temp_simu_par_name{1}) 187 | temp_simu_par_name{1} = new_name{i}; 188 | break; 189 | end 190 | end 191 | end 192 | % Creat new entry in dict 193 | initial_value = Simulink.Parameter; 194 | % Try creat new ,if parameter does not exit. 195 | try 196 | addEntry(dic_entry, temp_simu_par_name{1}, initial_value); 197 | end 198 | % Set entry's property 199 | SetDictParameter(dic_entry,... 200 | temp_simu_par_name{1},... 201 | temp_simu_par_datatype{1},... 202 | temp_simu_par_storge{1},... 203 | temp_simu_par_value); 204 | output = ['The parameter "' ,... 205 | temp_simu_par_name{1},... 206 | '" does not exit, have already created it.'] 207 | end 208 | end 209 | output = 'Change simulink parameter successful.' 210 | else 211 | output = 'No simulink parameter need changed.' 212 | end 213 | 214 | % Find table in list and change the datatype&value 215 | [num_simu_table, str_simu_table] = xlsread(filename, 'simu_table'); 216 | TABLE_NAME_COL = 2; 217 | TABLE_DATATYPE_COL = 4; 218 | TABLE_STORGE_COL = 5; 219 | TABLE_ROW_SPACE_COL = 6; 220 | TABLE_COL_SPACE_COL = 7; 221 | TABLE_VALUE_COL = 8; 222 | % Judge whether need writing talbe data 223 | if ~isempty(num_simu_table) 224 | len_simu_table_temp = length(num_simu_table(:,1)); 225 | % Calculate cycle time 226 | for i = 1: len_simu_table_temp 227 | if ~strcmp('NaN', num2str(num_simu_table(len_simu_table_temp+1-i,1))) 228 | cycle_time_tale = num_simu_table(len_simu_table_temp+1-i,1); 229 | break; 230 | end 231 | end 232 | % Read tabel data and write to dict 233 | temp_row = 1; 234 | for i = 1: cycle_time_tale 235 | temp_table_name = str_simu_table(1+temp_row, TABLE_NAME_COL); 236 | temp_table_datatype = str_simu_table(1+temp_row, TABLE_DATATYPE_COL); 237 | temp_table_storge = str_simu_table(1+temp_row, TABLE_STORGE_COL); 238 | temp_row_spacing = num_simu_table(temp_row, TABLE_ROW_SPACE_COL); 239 | temp_column_spacing = num_simu_table(temp_row, TABLE_COL_SPACE_COL); 240 | temp_table_data = num_simu_table(temp_row:... 241 | (temp_row + temp_row_spacing - 1),... 242 | TABLE_VALUE_COL:(TABLE_VALUE_COL + temp_column_spacing - 1)); 243 | 244 | % Set new property 245 | temp_return = SetDictParameter(dic_entry,... 246 | temp_table_name{1},... 247 | temp_table_datatype{1},... 248 | temp_table_storge{1},... 249 | temp_table_data); 250 | % Report whether creat new parameter 251 | if strcmp('Invalid name', temp_return) 252 | % Use new name to try again 253 | % Judge whether need find new name 254 | if 1 < i_diff_name 255 | % Find new name 256 | for i = 1:(i_diff_name-1) 257 | if strcmp(old_name{i}, temp_table_name{1}) 258 | temp_table_name{1} = new_name{i}; 259 | break; 260 | end 261 | end 262 | end 263 | % Creat new entry in dict 264 | initial_value = Simulink.Parameter; 265 | % Try creat new ,if parameter does not exit. 266 | try 267 | addEntry(dic_entry, temp_table_name{1}, initial_value); 268 | end 269 | % Set entry's property 270 | SetDictParameter(dic_entry,... 271 | temp_table_name{1},... 272 | temp_table_datatype{1},... 273 | temp_table_storge{1},... 274 | temp_table_data); 275 | output = ['The parameter "' ,... 276 | temp_table_name{1},... 277 | '" does not exit, have already created it.'] 278 | end 279 | temp_row = temp_row + temp_row_spacing; 280 | end 281 | output = 'Change table data successful.' 282 | else 283 | output = 'No table data changed.' 284 | end 285 | 286 | % Find stateflow in the excel,and change it. 287 | [num_sf_par, str_sf_par] = xlsread(filename, 'sf_parameter'); 288 | SF_NAME_COL = 2; 289 | SF_SCOPE_COL = 3; 290 | SF_DATATYPE_COL = 4; 291 | if isempty(num_sf_par) 292 | output = 'No state flow parameter need changed.' 293 | else 294 | for i = 1:num_sf_par(end,1) 295 | temp_sf_name = str_sf_par(i+1, SF_NAME_COL); 296 | temp_sf_scope = str_sf_par(i+1, SF_SCOPE_COL); 297 | temp_sf_datatype = str_sf_par(i+1, SF_DATATYPE_COL); 298 | % Find state flow parameter in model 299 | sf = sfroot; 300 | temp_sf_par = sf.find('-isa','Stateflow.Data','Name',temp_sf_name{1}); 301 | if isempty(temp_sf_par) 302 | % Report this state flow need defined in matlab 303 | output = ['The parameter "', temp_sf_name{1},... 304 | '" does not exit, it needs be defined in state flow'] 305 | else 306 | % Change sf parameter 307 | set(temp_sf_par, 'Scope', temp_sf_scope{1},... 308 | 'DataType', temp_sf_datatype{1}); 309 | end 310 | end 311 | output = 'Change state flow parameter successful.' 312 | end 313 | 314 | % Save changes to the dictionary and close it. 315 | saveChanges(current_dic); 316 | close(current_dic); 317 | 318 | % Report 319 | output = output; 320 | end 321 | %-----------------End of function---------------------------------------------- 322 | 323 | %-----------Start of function-------------------------------------------------- 324 | function SetNewName(input, item, new_name) 325 | if isempty(input) 326 | % Do Nothing 327 | else 328 | if 1 < length(input) 329 | for i = 1:length(input) 330 | try 331 | set_param(input(i), item, new_name); 332 | catch 333 | try 334 | set(input(i), item, new_name); 335 | end 336 | end 337 | end 338 | else 339 | try 340 | set_param(input, item, new_name); 341 | catch 342 | try 343 | set(input, item, new_name); 344 | end 345 | end 346 | end 347 | end 348 | end 349 | %-----------------End of function---------------------------------------------- 350 | 351 | %-----------Start of function-------------------------------------------------- 352 | function output = SetDictParameter(entry, name, data_type, storge, value) 353 | % Find the parameter name in dict 354 | simu_par = find(entry, 'Name', name); 355 | if isempty(simu_par) 356 | output = 'Invalid name'; 357 | else 358 | output = 'Valid name'; 359 | temp_change = getValue(simu_par); 360 | temp_change.DataType = data_type; 361 | temp_change.CoderInfo.StorageClass = storge; 362 | temp_change.Value = value; 363 | % Write dict 364 | setValue(simu_par, temp_change); 365 | end 366 | end 367 | %-----------------End of function---------------------------------------------- 368 | -------------------------------------------------------------------------------- /change_port_property.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for change ports property 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.6 6 | % Time : 2018/1/6 7 | % Instructions : fix bugs 8 | % 修改bug,仅更改模型root层的输入和输出端口属性,不对子系统进行修改 - 0.2 9 | % 修改脚本,在遇到线上没有数据类型端口,不进行默认为uint8的类型改写, 10 | % 当线上没有数据类型时,检测端口是否已经定义数据类型,如定义则根据所 11 | % 定义的数据类型自动补全数据范围等其它属性 - 0.3 12 | % 修改bug,在检测到模型配置中采样时间设为连续时,将端口的采样时间设 13 | % 为 默认的 -1 - 0.4 14 | % 修改bug,当设为不连续采样,但是采样时间设为auto时,将端口采样时间 15 | % 设为默认的 -1 - 0.5 16 | % 修复bug,当输入输出端口连接线上没有定义信号名称的时候,之前的版本 17 | % 无法修改该端口的属性值,当前版本改掉了这个bug; 18 | % 增加自定义数据类型uint8...float32等识别; - 0.6 19 | %------------------------------------------------------------------------------ 20 | 21 | function change_ports_result = change_port_property() 22 | 23 | paraModel = bdroot; 24 | 25 | % Original matalb version is R2017a 26 | % 检查Matlab版本是否为R2017a 27 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 28 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 29 | CurrentVersion = version; 30 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 31 | strcmp(CorrectVersion_linux, CurrentVersion)) 32 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 33 | end 34 | 35 | % Original environment character encoding: GBK 36 | % 脚本编码环境是否为GBK 37 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 38 | % warning('Simulink:EncodingUnMatched', 'The target character... 39 | % encoding (%s) is different from the original (%s).',... 40 | % get_param(0, 'CharacterEncoding'), 'GBK'); 41 | % end 42 | 43 | ChangePortProperty(paraModel, 'Inport') 44 | ChangePortProperty(paraModel, 'Outport') 45 | 46 | change_ports_result = 'change port property successful'; 47 | end 48 | %-----------End of function---------------------------------------------------- 49 | 50 | %-----------Start of function-------------------------------------------------- 51 | function ChangePortProperty(paraModel, block) 52 | % find all block 53 | inport_block = find_system(paraModel,'SearchDepth', '1','FindAll',... 54 | 'on','BlockType',block); 55 | % Calculate get parameter 56 | length_inport = length(inport_block); 57 | if strcmp('Inport', block) 58 | SigNamePar = 'OutputSignalNames'; 59 | elseif strcmp('Outport', block) 60 | SigNamePar = 'InputSignalNames'; 61 | else 62 | % Do nothing 63 | end 64 | % rename inport blocks to signals' name 65 | for i = 1:length_inport 66 | current_out_sig_name = get(inport_block(i),SigNamePar); 67 | % translate cell to string 68 | current_out_sig_name = cell2mat(current_out_sig_name); 69 | if 1 == isempty(current_out_sig_name) 70 | % Only try change property. output line has no name defined. 71 | set_datatype = 'byblock'; 72 | else 73 | % find if tag symbol '<' exit 74 | if strcmp('<',current_out_sig_name(1)) 75 | % remove the tag symbol '< >' 76 | current_out_sig_name = current_out_sig_name(2:end-1); 77 | else 78 | % Do nothing 79 | end 80 | % change ports property and name 81 | try 82 | set(inport_block(i),'Name',current_out_sig_name); 83 | % get parameters datatype 84 | inport_datatype = current_out_sig_name(end-2:end); 85 | [set_min, set_max,... 86 | set_datatype] = CalculateDataType(inport_datatype); 87 | catch 88 | % Do nothing 89 | end 90 | end 91 | % Calculate correct datatype 92 | disable_flag = 0; 93 | if strcmp('None',set_datatype) 94 | set_datatype = get(inport_block(i),'OutDataTypeStr'); 95 | set_datatype = TranslateDatatype(set_datatype); 96 | if strcmp('StillNone',set_datatype) 97 | % do not set port's property 98 | disable_flag = 1; 99 | else 100 | % get new set value 101 | [set_min, set_max, ... 102 | set_datatype] = CalculateDataType(set_datatype); 103 | end 104 | 105 | elseif strcmp('byblock',set_datatype) 106 | set_datatype = get(inport_block(i),'OutDataTypeStr'); 107 | set_datatype = TranslateDatatype(set_datatype); 108 | if strcmp('StillNone',set_datatype) 109 | % do not set port's property 110 | disable_flag = 1; 111 | else 112 | % get new set value 113 | [set_min, set_max, ... 114 | ~] = CalculateDataType(set_datatype); 115 | set_datatype = get(inport_block(i),'OutDataTypeStr'); 116 | end 117 | else 118 | % do nothing 119 | end 120 | % Set property 121 | try 122 | % judge whether set port's property 123 | if 0 == disable_flag 124 | % get cfg 125 | if strcmp('Fixed-step', get_param(paraModel, 'SolverType')) 126 | sample_time = get_param(paraModel,'FixedStep'); 127 | % Fix bug , step set Auto and use fixed-step mode 128 | if strcmp('auto', sample_time) 129 | sample_time = '-1'; 130 | end 131 | else 132 | sample_time = '-1'; 133 | end 134 | % define inport block property 135 | port_dimension = '1'; 136 | SetPortProperty(inport_block(i), set_min, set_max,... 137 | set_datatype, sample_time, port_dimension) 138 | % clear port signal resolved 139 | inport_signal_line = find_system(paraModel,'FindAll',... 140 | 'on','type','line','Name',current_out_sig_name); 141 | set(inport_signal_line,'MustResolveToSignalObject',0); 142 | else 143 | % do nothing 144 | end 145 | catch 146 | 147 | end 148 | end 149 | end 150 | %-----------------End of function---------------------------------------------- 151 | 152 | %-----------Start of function-------------------------------------------------- 153 | function [set_min, set_max, set_datatype] = CalculateDataType(data_type_in) 154 | % translate the upper to lower 155 | data_type_in = lower(data_type_in); 156 | % calculate the data type config 157 | switch data_type_in 158 | case '_u8' 159 | set_datatype = 'uint8'; 160 | set_min = '0'; 161 | set_max = '255'; 162 | case 'u16' 163 | set_datatype = 'uint16'; 164 | set_min = '0'; 165 | set_max = '65535'; 166 | case 'u32' 167 | set_datatype = 'uint32'; 168 | set_min = '0'; 169 | set_max = '4294967295'; 170 | case 'f32' 171 | set_datatype = 'single'; 172 | set_min = '-200000000'; 173 | set_max = '200000000'; 174 | case 'f64' 175 | set_datatype = 'double'; 176 | set_min = '-200000000'; 177 | set_max = '200000000'; 178 | case '_s8' 179 | set_datatype = 'int8'; 180 | set_min = '-128'; 181 | set_max = '127'; 182 | case 's16' 183 | set_datatype = 'int16'; 184 | set_min = '-32768'; 185 | set_max = '32767'; 186 | case 's32' 187 | set_datatype = 'int32'; 188 | set_min = '-2147483648'; 189 | set_max = '2147483647'; 190 | case '_bl' 191 | set_datatype = 'boolean'; 192 | set_min = '0'; 193 | set_max = '1'; 194 | otherwise 195 | set_datatype = 'None'; 196 | set_min = '[]'; 197 | set_max = '[]'; 198 | end 199 | end 200 | %-----------------End of function---------------------------------------------- 201 | 202 | %-----------Start of function-------------------------------------------------- 203 | function set_datatype = TranslateDatatype(datatype) 204 | switch datatype 205 | case 'uint8' 206 | set_datatype = '_u8'; 207 | case 'uint16' 208 | set_datatype = 'u16'; 209 | case 'uint32' 210 | set_datatype = 'u32'; 211 | case {'single', 'float32'} 212 | set_datatype = 'f32'; 213 | case {'double', 'float64'} 214 | set_datatype = 'f64'; 215 | case {'int8', 'sint8'} 216 | set_datatype = '_s8'; 217 | case {'int16', 'sint16'} 218 | set_datatype = 's16'; 219 | case {'int32', 'sint32'} 220 | set_datatype = 's32'; 221 | case 'boolean' 222 | set_datatype = '_bl'; 223 | otherwise 224 | set_datatype = 'StillNone'; 225 | end 226 | end 227 | %-----------------End of function---------------------------------------------- 228 | 229 | %-----------Start of function-------------------------------------------------- 230 | function SetPortProperty(port_block, set_min, set_max, ... 231 | set_datatype, sample_time, port_dimension) 232 | set(port_block,'OutDataTypeStr',set_datatype); 233 | set(port_block,'OutMin',set_min); 234 | set(port_block,'OutMax',set_max); 235 | set(port_block,'SampleTime',sample_time); 236 | set(port_block,'PortDimensions',port_dimension); 237 | end 238 | %-----------------End of function---------------------------------------------- -------------------------------------------------------------------------------- /clear_propagate.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for clear propagated signals. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : 7 | %------------------------------------------------------------------------------ 8 | 9 | function clear_propagae_result = clear_propagate() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R202017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character ... 27 | % encoding (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | all_line = find_system(paraModel,'FindAll','on','type','line'); 32 | length_ps_line = length(all_line); 33 | for i = 1:length_ps_line 34 | try 35 | set(all_line(i),'SignalPropagation','off'); 36 | catch 37 | 38 | end 39 | end 40 | % report configurate results 41 | clear_propagae_result = 'Clear propagated successful'; 42 | end -------------------------------------------------------------------------------- /clear_resolve.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for resolve to signals. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : 7 | %------------------------------------------------------------------------------ 8 | 9 | function clear_resolve_result = clear_resolve() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R202017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character... 27 | % encoding (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | all_line = find_system(paraModel,'FindAll','on','type','line'); 32 | 33 | length_rs_line = length(all_line); 34 | for i = 1:length_rs_line 35 | try 36 | set(all_line(i),'MustResolveToSignalObject',0); 37 | catch 38 | % do nothing 39 | end 40 | end 41 | % report configurate results 42 | clear_resolve_result = 'Clear resolve successful'; 43 | end 44 | -------------------------------------------------------------------------------- /creat_all_in_one_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | #------------------------------------------------------------------------------ 5 | # Function : This scrip is used to creat sl_customization.m with all .m files 6 | # Enviroment : python 3 7 | # Author : Shibo Jiang 8 | # Time : 2018.3.23 9 | # Version : 0.1 10 | # Notes : None 11 | #------------------------------------------------------------------------------ 12 | 13 | import os 14 | 15 | # Start of find_files function------------------------------------------------- 16 | def find_files(path, search, default_result, exclude = None): 17 | for x_path in os.listdir(path): 18 | if x_path != exclude: 19 | x_path = os.path.join(path, x_path) 20 | if os.path.isdir(x_path): 21 | find_files(x_path, search, default_result, exclude = None) 22 | elif (os.path.splitext(x_path)[1]).lower() == search: 23 | default_result.append(x_path) 24 | # End of find_files function--------------------------------------------------- 25 | 26 | # Start of main function------------------------------------------------------- 27 | def main(): 28 | # Config constant value 29 | MAIN_FILE = 'sl_customization.m' 30 | TARGET_FILE = 'sl_customization_all.m' 31 | PWD_PATH = os.path.abspath('.') 32 | 33 | # Delete exit target files 34 | if TARGET_FILE in os.listdir(PWD_PATH): 35 | delete_file = os.path.join(PWD_PATH,TARGET_FILE) 36 | os.remove(delete_file) 37 | 38 | # Parameters 39 | m_files = [os.path.join(PWD_PATH, MAIN_FILE)] 40 | find_files(PWD_PATH, '.m', m_files) 41 | 42 | # Copy files content 43 | done_file = [] 44 | repeat_file = [] 45 | with open(TARGET_FILE, 'w', encoding='gbk') as tar_file: 46 | for x_file in m_files: 47 | # Judge whether file is repeat 48 | if not x_file in done_file: 49 | # Read file's content 50 | with open(x_file, 'r', encoding='gbk') as src_file: 51 | while True: 52 | content = src_file.readline() 53 | # Write content to target file 54 | tar_file.write(content) 55 | if not content: 56 | tar_file.write('\n'+'\n') 57 | break 58 | # Add file's name to done_file which already copied 59 | done_file.append(x_file) 60 | print(str(os.path.split(x_file)[1]) + ' --already copied!') 61 | else: 62 | if str(os.path.split(x_file)[1]) != MAIN_FILE: 63 | repeat_file.append(x_file) 64 | # Report repeat files 65 | print('These files are repeated:' + str(repeat_file)) 66 | # End of main function--------------------------------------------------------- 67 | 68 | # Run script 69 | main() 70 | -------------------------------------------------------------------------------- /creat_p_files.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Matlab scrip for p file created. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Time : 2017/8/28 6 | % Version : 0.1 7 | % Instructions : Use this scrip and the *.m files which need translating 8 | % to *.p files in the same folder. 9 | %------------------------------------------------------------------------------ 10 | 11 | %-----Start of creat_p_files--------------------------------------------------- 12 | function output = creat_p_files() 13 | % get work floder path 14 | the_path = cd; 15 | % get all files in this floder 16 | files = dir(the_path); 17 | % find the .m files' name 18 | length_all_files = length(files); 19 | select_type = '.m'; 20 | for i = 1:length_all_files 21 | current_name = files(i).name; 22 | % protect from wrong state running 23 | try 24 | current_type = current_name(end-1:end); 25 | if 1 == strcmp(select_type,current_type) 26 | % creat .p file 27 | pcode (current_name); 28 | else 29 | % not .m file, do nothing 30 | end 31 | catch 32 | % do nothing 33 | end 34 | end 35 | output = 'Creat P files successful'; 36 | end -------------------------------------------------------------------------------- /default_port_property.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for change ports property to default 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.4 6 | % Time : 2018/1/8 7 | % Instructions : 修改bug,仅对模型root层输入输出端口进行修改 - 0.2 8 | % 策略修改,仅还原能够使用信号线上后缀名字定义的数据 9 | % 类型的端口 - 0.3 10 | % 修改策略,针对上一版本修改的策略,这版同时恢复其它 11 | % 端口的非数据类型 选项,例如 最大最小值范围等 - 0.4 12 | %------------------------------------------------------------------------------ 13 | 14 | function default_ports_result = default_port_property() 15 | 16 | paraModel = bdroot; 17 | 18 | % Original matalb version is R2017a 19 | % 检查Matlab版本是否为R2017a 20 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 21 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 22 | CurrentVersion = version; 23 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 24 | strcmp(CorrectVersion_linux, CurrentVersion)) 25 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 26 | end 27 | 28 | % Original environment character encoding: GBK 29 | % 脚本编码环境是否为GBK 30 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 31 | % warning('Simulink:EncodingUnMatched', 'The target character... 32 | % encoding (%s) is different from the original (%s).',... 33 | % get_param(0, 'CharacterEncoding'), 'GBK'); 34 | % end 35 | 36 | DefaultPortProperty(paraModel, 'Inport'); 37 | DefaultPortProperty(paraModel, 'Outport'); 38 | DefaultPortProperty2(paraModel, 'Inport'); 39 | DefaultPortProperty2(paraModel, 'Outport'); 40 | 41 | default_ports_result = 'change port property to default value successful'; 42 | end 43 | %-----------End of function---------------------------------------------------- 44 | 45 | %-----------Start of function-------------------------------------------------- 46 | function DefaultPortProperty(paraModel, block) 47 | % find all inport block 48 | inport_block = find_system(paraModel,'SearchDepth', '1','FindAll','on',... 49 | 'BlockType',block); 50 | % Calculate parameter 51 | if strcmp('Inport', block) 52 | SigNamePar = 'OutputSignalNames'; 53 | elseif strcmp('Outport', block) 54 | SigNamePar = 'InputSignalNames'; 55 | else 56 | % Do nothing 57 | end 58 | % rename inport blocks to signals' name 59 | length_inport = length(inport_block); 60 | for i = 1:length_inport 61 | current_out_sig_name = get(inport_block(i),SigNamePar); 62 | % translate cell to string 63 | current_out_sig_name = cell2mat(current_out_sig_name); 64 | if 1 == isempty(current_out_sig_name) 65 | % Do nothing. output line has no name defined. 66 | else 67 | % find if tag symbol '<' exit 68 | if strcmp('<',current_out_sig_name(1)) 69 | % remove the tag symbol '< >' 70 | current_out_sig_name = current_out_sig_name(2:end-1); 71 | else 72 | % Do nothing 73 | end 74 | % change ports property 75 | try 76 | % get parameters datatype 77 | inport_datatype = current_out_sig_name(end-2:end); 78 | set_datatype = CalculateDataType(inport_datatype); 79 | if ~strcmp('None',set_datatype) 80 | % define inport block property 81 | set(inport_block(i),'OutDataTypeStr','Inherit: auto'); 82 | set(inport_block(i),'OutMin','[]'); 83 | set(inport_block(i),'OutMax','[]'); 84 | set(inport_block(i),'SampleTime','-1'); 85 | set(inport_block(i),'PortDimensions','-1'); 86 | else 87 | set(inport_block(i),'OutMin','[]'); 88 | set(inport_block(i),'OutMax','[]'); 89 | set(inport_block(i),'SampleTime','-1'); 90 | set(inport_block(i),'PortDimensions','-1'); 91 | end 92 | catch 93 | % Do nothing 94 | end 95 | end 96 | end 97 | end 98 | %-----------End of function---------------------------------------------------- 99 | 100 | %-----------Start of function-------------------------------------------------- 101 | function set_datatype = CalculateDataType(data_type_in) 102 | % translate the upper to lower 103 | data_type_in = lower(data_type_in); 104 | % calculate the data type config 105 | switch data_type_in 106 | case '_u8' 107 | set_datatype = 'uint8'; 108 | case 'u16' 109 | set_datatype = 'uint16'; 110 | case 'u32' 111 | set_datatype = 'uint32'; 112 | case 'f32' 113 | set_datatype = 'single'; 114 | case 'f64' 115 | set_datatype = 'double'; 116 | case '_s8' 117 | set_datatype = 'int8'; 118 | case 's16' 119 | set_datatype = 'int16'; 120 | case 's32' 121 | set_datatype = 'int32'; 122 | case '_bl' 123 | set_datatype = 'boolean'; 124 | otherwise 125 | set_datatype = 'None'; 126 | end 127 | end 128 | %-----------------End of function---------------------------------------------- 129 | 130 | %-----------Start of function-------------------------------------------------- 131 | function DefaultPortProperty2(paraModel, block) 132 | % Find the block 133 | block = find_system(paraModel,'SearchDepth', '1','FindAll','on',... 134 | 'BlockType',block); 135 | if ~isempty(block) 136 | for i = 1:length(block) 137 | try 138 | % Set the block's porperty to default value 139 | set(block(i),'OutMin','[]'); 140 | set(block(i),'OutMax','[]'); 141 | set(block(i),'SampleTime','-1'); 142 | set(block(i),'PortDimensions','-1'); 143 | catch 144 | % Do nothing 145 | end 146 | end 147 | end 148 | end 149 | %-----------------End of function---------------------------------------------- -------------------------------------------------------------------------------- /fix_stateflow_parameter_type.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for retype stateflow patameters 3 | % MATLAB version: R2017a 4 | % Author: Shibo Jiang 5 | % Time: 2017/11/28 6 | % Version: 0.2 7 | % Instructions: Change functions that can fix input/output - 0.2 8 | %------------------------------------------------------------------------------ 9 | 10 | function fix_result = fix_stateflow_parameter_type() 11 | 12 | paraModel = bdroot; 13 | 14 | % Original matalb version is R2017a 15 | % 检查Matlab版本是否为R2017a 16 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 17 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 18 | CurrentVersion = version; 19 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 20 | strcmp(CorrectVersion_linux, CurrentVersion)) 21 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 22 | end 23 | 24 | % Original environment character encoding: GBK 25 | % 脚本编码环境是否为GBK 26 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 27 | % warning('Simulink:EncodingUnMatched', 'The target character... 28 | % encoding (%s) is different from the original (%s).',... 29 | % get_param(0, 'CharacterEncoding'), 'GBK'); 30 | % end 31 | 32 | % find all stateflow parameter 33 | sf = sfroot; 34 | all_sf_parameter = sf.find('-isa','Stateflow.Data'); 35 | j = 1; 36 | 37 | if isempty(all_sf_parameter) 38 | % report the result 39 | fix_result = 'There is on stateflow parameter in this model.'; 40 | else 41 | % define the input/output parameter's data type 42 | % length_sf_par = length(all_sf_parameter); 43 | % for i = 1:length_sf_par 44 | % % whether the paremeter is input/outport or others 45 | % sf_par_scope = all_sf_parameter(i).Scope; 46 | % switch sf_par_scope 47 | % case 'Input' 48 | % set(all_sf_parameter(i),'DataType','Inherit: Same as Simulink'); 49 | % case 'Output' 50 | % set(all_sf_parameter(i),'DataType','Inherit: Same as Simulink'); 51 | % otherwise 52 | % other_sf_par(j) = all_sf_parameter(i); 53 | % j = j + 1; 54 | % end 55 | % end 56 | other_sf_par = all_sf_parameter; 57 | end 58 | 59 | % define other stateflow parameters datatype 60 | if isempty(other_sf_par) 61 | if isempty(fix_result) 62 | % report the result 63 | fix_result = 'Define stateflow parameters datatype successful'; 64 | else 65 | % keep last fix_result 66 | end 67 | else 68 | length_other_sf_par = length(other_sf_par); 69 | for i = 1:length_other_sf_par 70 | % get stateflow parameter's name 71 | sf_par_name = other_sf_par(i).Name; 72 | try 73 | % get parameters datatype 74 | sf_par_datatype = sf_par_name(end-2:end); 75 | % translate the upper to lower 76 | sf_par_datatype = lower(sf_par_datatype); 77 | % calculate the data type config 78 | switch sf_par_datatype 79 | case '_u8' 80 | sf_par_datatype_cfg = 'uint8'; 81 | case 'u16' 82 | sf_par_datatype_cfg = 'uint16'; 83 | case 'u32' 84 | sf_par_datatype_cfg = 'uint32'; 85 | case 'f32' 86 | sf_par_datatype_cfg = 'single'; 87 | case 'f64' 88 | sf_par_datatype_cfg = 'double'; 89 | case '_s8' 90 | sf_par_datatype_cfg = 'int8'; 91 | case 's16' 92 | sf_par_datatype_cfg = 'int16'; 93 | case 's32' 94 | sf_par_datatype_cfg = 'int32'; 95 | case '_bl' 96 | sf_par_datatype_cfg = 'boolean'; 97 | otherwise 98 | sf_par_datatype_cfg = 'uint8'; 99 | end 100 | % define the stateflow parameter data type 101 | set(other_sf_par(i),'DataType',sf_par_datatype_cfg) 102 | catch 103 | 104 | end 105 | end 106 | fix_result = 'Define stateflow parameters datatype successful'; 107 | end 108 | end 109 | -------------------------------------------------------------------------------- /git命令大全.txt: -------------------------------------------------------------------------------- 1 | 创建文件夹: mkdir 2 | 进入文件夹: cd 3 | 显示当前目录: pwd 4 | 把当前目录变成Git: git init 5 | 显示隐藏目录: ls -ah 6 | 查看git仓库状态: git status 7 | 把文件添加到git仓库: git add 8 | 把文件提交到仓库: git commit -m "说明" 9 | 查看修改后的不同: git diff 10 | 查看提交历史: git log --pretty=oneline 11 | 回退到上一个版本: git reset --hard HEAD^ 12 | 回退到某个版本: git reset --hard 13 | 查看命令历史: git reflog 14 | 工作区和暂存区对比: git diff 15 | 暂存区和分区对比: git diff -- cached 16 | 工作区和分支对比: git diff -- 17 | 丢弃工作区的修改: git checkout -- 18 | 撤销暂存区的修改: git reset HEAD + git checkout -- 或 git reset --hard HEAD 19 | 删除工作区文件: rm 20 | 从版本库删除该文件: git rm + git commit -m "说明" 21 | 撤销工作区文件的删除: git checkout -- 22 | 撤销暂存区文件的删除: git reset HEAD + git checkout -- 或 git reset --hard HEAD 23 | 创建SSH Key: ssh-keygen -t rsa -C "15521232672@163.com" 24 | 关联一个远程库: git remote add origin git@github.com:RaymondHww/learngit.git 25 | 推送master分支的内容: git push -u origin master (第一次推送要参数 -u ,之后就不用了) 26 | 从远程克隆仓库到本地: git clone git@github.com:RaymondHww/gitskills.git 27 | 查看分支: git branch 28 | 创建分支: git branch 29 | 切换分支: git checkout 30 | 创建+切换分支: git checkout -b 31 | 合并某分支到当前分支: git merge 32 | 删除分支: git branch -d 33 | 查看分支合并情况: git log --graph --pretty=oneline --abbrev-commit 34 | 使用普通模式合并: git merge --no-ff -m "说明" dev 35 | 把工作现场储藏: git stash 36 | 查看储藏的工作现场: git stash list 37 | 恢复储藏的工作现场: git stash apply stash@{0} 38 | 删除stash内容: git stash drop stash@{0} 39 | 恢复并删除stash内容: git stash pop 40 | 强行删除未合并的分支: git branch -D 41 | 显示详细的远程库信息: git remote -v 42 | 推送分支到远程库: git push origin master 或 git push origin dev 43 | 44 | 克隆远程库到本地后只有master分支 45 | 在本地创建和远程分支对应的分支:git checkout -b branch-name origin/branch-name 46 | 建立本地分支和远程分支的关联: git branch --set-upstream branch-name origin/branch-name 47 | 48 | 因此,多人协作的工作模式通常是这样: 49 | 首先,可以试图用git push origin branch-name推送自己的修改; 50 | 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; 51 | 如果合并有冲突,则解决冲突,并在本地提交; 52 | 没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! 53 | 如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建, 54 | 用命令git branch --set-upstream branch-name origin/branch-name。 55 | 56 | tag就是一个让人容易记住的有意义的名字,它跟某个commit绑在一起。 57 | 打一个新标签到最新的提交上: git tag v1.0 58 | 打一个新标签到历史的提交上: git tag v1.1 59 | 查看所有标签: git tag 60 | 查看标签信息: git show v1.0 61 | 创建带有说明的标签: git tag -a v1.2 -m "说明" 62 | 通过-s用私钥签名一个标签: git tag -s v1.3 -m "说明" 63 | 删除本地标签: git tag -d v1.0 64 | 推送某个标签到远程: git push origin 65 | 一次性推送全部尚未推送到远程的标签:git push origin --tags 66 | 删除已经推送到远程的标签: git tag -d v1.0 然后 git push origin :refs/tags/v1.0 67 | 自定义git命令如下: git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" 68 | 69 | 70 | -------------------------------------------------------------------------------- /hide_name_blocks.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for hiding block names. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : the blocks include MinMax,UnitDelay,Sqrt,Merge,Product, 7 | % Logic,RelationalOperator,Switch,MultiPortSwitch,Goto, 8 | % From,Terminator,ModelReference 9 | %------------------------------------------------------------------------------ 10 | 11 | function hide_block_name_result = hide_name_blocks() 12 | 13 | paraModel = bdroot; 14 | 15 | % Original matalb version is R2017a 16 | % 检查Matlab版本是否为R202017a 17 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 18 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 19 | CurrentVersion = version; 20 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 21 | strcmp(CorrectVersion_linux, CurrentVersion)) 22 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 23 | end 24 | 25 | % Original environment character encoding: GBK 26 | % 脚本编码环境是否为GBK 27 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 28 | % warning('Simulink:EncodingUnMatched', 'The target character... 29 | % encoding (%s) is different from the original (%s).',... 30 | % get_param(0, 'CharacterEncoding'), 'GBK'); 31 | % end 32 | 33 | % find MinMax blocks 34 | min_max_blocks = find_system(paraModel,'FindAll',... 35 | 'on','BlockType','MinMax'); 36 | % find UnitDelay blocks 37 | uint_delay_blocks = find_system(paraModel,'FindAll',... 38 | 'on','BlockType','UnitDelay'); 39 | % find Sqrt blocks 40 | sqrt_blocks = find_system(paraModel,'FindAll',... 41 | 'on','BlockType','Sqrt'); 42 | % find Merge blocks 43 | merge_blocks = find_system(paraModel,'FindAll','on',... 44 | 'BlockType','Merge'); 45 | % find Product blocks 46 | product_blocks = find_system(paraModel,'FindAll',... 47 | 'on','BlockType','Product'); 48 | % find Logic blocks 49 | logic_blocks = find_system(paraModel,'FindAll',... 50 | 'on','BlockType','Logic'); 51 | % find RelationalOperator blocks 52 | relational_operator_blocks = find_system(paraModel,'FindAll',... 53 | 'on','BlockType','RelationalOperator'); 54 | % find Switch blocks 55 | switch_blocks = find_system(paraModel,'FindAll',... 56 | 'on','BlockType','Switch'); 57 | % find MultiPortSwitch blocks 58 | multi_switch_blocks = find_system(paraModel,'FindAll',... 59 | 'on','BlockType','MultiPortSwitch'); 60 | % find Goto blocks 61 | goto_blocks = find_system(paraModel,'FindAll',... 62 | 'on','BlockType','Goto'); 63 | % find From blocks 64 | from_blocks = find_system(paraModel,'FindAll',... 65 | 'on','BlockType','From'); 66 | % find Terminator blocks 67 | terminator_blocks = find_system(paraModel,'FindAll',... 68 | 'on','BlockType','Terminator'); 69 | % find ModelReference blocks 70 | model_reference_blocks = find_system(paraModel,'FindAll',... 71 | 'on','BlockType','ModelReference'); 72 | % find Switch blocks 73 | switch_blocks = find_system(paraModel,'FindAll',... 74 | 'on','BlockType','Switch'); 75 | 76 | % all blocks which need hiding names 77 | hide_name_blocks = [min_max_blocks',uint_delay_blocks',sqrt_blocks',... 78 | merge_blocks',product_blocks',logic_blocks'... 79 | ,relational_operator_blocks',switch_blocks',... 80 | multi_switch_blocks',goto_blocks',from_blocks'... 81 | ,terminator_blocks',model_reference_blocks',... 82 | switch_blocks']; 83 | 84 | length_hide_name_line = length(hide_name_blocks); 85 | for i = 1:length_hide_name_line 86 | try 87 | set_param(hide_name_blocks(i),'ShowName','off'); 88 | catch 89 | % do nothing 90 | end 91 | end 92 | % report configurate results 93 | hide_block_name_result = 'Hide block name successful'; 94 | end 95 | -------------------------------------------------------------------------------- /hide_name_ports.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for hiding port names. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : the blocks include Inport,Outport 7 | %------------------------------------------------------------------------------ 8 | 9 | function hide_port_name_result = hide_name_ports() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R202017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character... 27 | % encoding (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | % find inport blocks 32 | Inport_blocks = find_system(paraModel,'FindAll',... 33 | 'on','BlockType','Inport'); 34 | % find Outport blocks 35 | Outport_blocks = find_system(paraModel,'FindAll',... 36 | 'on','BlockType','Outport'); 37 | 38 | % all blocks which need hiding names 39 | hide_name_ports = [Inport_blocks',Outport_blocks']; 40 | 41 | length_hide_name_line = length(hide_name_ports); 42 | for i = 1:length_hide_name_line 43 | try 44 | set_param(hide_name_ports(i),'ShowName','off'); 45 | catch 46 | % do nothing 47 | end 48 | end 49 | % report configurate results 50 | hide_port_name_result = 'Hide port name successful'; 51 | end 52 | -------------------------------------------------------------------------------- /list_parameter.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for listing dictionary parameters 3 | % MATLAB : R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.7 6 | % Time : 2017/12/7 7 | % Instructions : Fix bugs ,modify temp name as '____' - 0.4 8 | % Add datasource information - 0.5 9 | % Fix bugs, messeage can report clearly - 0.6 10 | % Code refactoring. 11 | % Adapt to MyPkg class searching - 0.7 12 | % Add stateflow parameter - 0.8 13 | % Fix bugs - 0.9 14 | %------------------------------------------------------------------------------ 15 | function output = list_parameter() 16 | 17 | paraModel = bdroot; 18 | 19 | % Original matalb version is R2017a 20 | % 检查Matlab版本是否为R202017a 21 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 22 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 23 | CurrentVersion = version; 24 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 25 | strcmp(CorrectVersion_linux, CurrentVersion)) 26 | warning(['Matlab version mismatch, this scrip should be' ... 27 | 'used for Matlab R2017a']); 28 | end 29 | 30 | % % Get inter parameter which defined in model workspace 31 | % simulink_var_space = get_param(paraModel,'ModelWorkspace'); 32 | % simulink_par_inter = simulink_var_space.whos; 33 | 34 | % Get outlink parameter which defined in data dictionary 35 | data_dictionary = get_param(paraModel, 'DataDictionary'); 36 | current_dic = Simulink.data.dictionary.open(data_dictionary); 37 | dic_entry = getSection(current_dic, 'Design Data'); 38 | simulink_par_database = find(dic_entry); 39 | 40 | % Get all parameter's name and mark the line which has same name 41 | len_dict = length(simulink_par_database); 42 | for index = 1:len_dict 43 | par_name{index} = simulink_par_database(index).Name; 44 | par_name_source{index} = simulink_par_database(index).DataSource; 45 | % Mark the line 46 | line_marked{index} = find_system(paraModel,'FindAll','on','type'... 47 | ,'line','Name',par_name{index}); 48 | set_param(line_marked{index}, 'Name', [par_name{index},'____']); 49 | end 50 | par_name = par_name'; 51 | 52 | % Get line's name which is not defined in dictionary 53 | all_line = find_system(paraModel,'FindAll','on','type','line'); 54 | j = 1; 55 | APPEND_LENGTH = 4; 56 | for i = 1:length(all_line) 57 | current_line_name = get(all_line(i), 'Name'); 58 | try 59 | if strcmp('____', current_line_name((end-APPEND_LENGTH+1):end)) 60 | % Revert the line's name 61 | set_param(all_line(i), 'Name', ... 62 | current_line_name(1:(end - (APPEND_LENGTH)))); 63 | else 64 | only_line_name{j} = current_line_name; 65 | j = j + 1; 66 | end 67 | end 68 | end 69 | 70 | % Find and mark the simulink parameter & table 71 | simu_par = find(dic_entry,'-value','-class','Simulink.Parameter'); 72 | mypkg_par = find(dic_entry,'-value','-class','MyPkg.Parameter'); 73 | simulink_par = [simu_par; mypkg_par]; 74 | len_simu_par = length(simulink_par); 75 | index_table = 1; 76 | index_par = 1; 77 | % Macro define which used in table 78 | TABLE_NAME = 1; 79 | TABLE_SOURCE = 2; 80 | TABLE_DATATYPE = 3; 81 | TABLE_STORAGE = 4; 82 | TABLE_DIM = 5; 83 | TABLE_VALUE = 6; 84 | if 0 < len_simu_par 85 | for i = 1:len_simu_par 86 | simu_par_temp = getValue(simulink_par(i)); 87 | simu_par_temp_name = simulink_par(i).Name; 88 | simu_par_temp_source = simulink_par(i).DataSource; 89 | simu_par_temp_datatype = simu_par_temp.DataType; 90 | simu_par_temp_stor = simu_par_temp.CoderInfo.StorageClass; 91 | simu_par_temp_dim = simu_par_temp.Dimensions; 92 | simu_par_temp_value = simu_par_temp.Value; 93 | 94 | if [1, 1] == simu_par_temp_dim 95 | simu_par_name{index_par} = simu_par_temp_name; 96 | simu_par_source{index_par} = simu_par_temp_source; 97 | simu_par_datatype{index_par} = simu_par_temp_datatype; 98 | simu_par_storage{index_par} = simu_par_temp_stor; 99 | simu_par_value{index_par} = simu_par_temp_value; 100 | index_par = index_par + 1; 101 | else 102 | simu_table{index_table} = {simu_par_temp_name, ... 103 | simu_par_temp_source,... 104 | simu_par_temp_datatype, ... 105 | simu_par_temp_stor, ... 106 | simu_par_temp_dim, ... 107 | simu_par_temp_value}; 108 | index_table = index_table + 1; 109 | end 110 | end 111 | end 112 | 113 | output = 'Listing is running.' 114 | 115 | % Find stateflow parameter 116 | sf = sfroot; 117 | sf_parameter = sf.find('-isa','Stateflow.Data'); 118 | len_sf = 0; 119 | if isempty(sf_parameter) 120 | output = 'There is no state flow parameter in this model' 121 | else 122 | len_sf = length(sf_parameter); 123 | for i = 1:len_sf 124 | sf_par_name{i} = sf_parameter(i).Name; 125 | sf_par_datatype{i} = sf_parameter(i).DataType; 126 | sf_par_scope{i} = sf_parameter(i).Scope; 127 | end 128 | end 129 | 130 | % Define table name 131 | filename = [paraModel,'_list.xlsx']; 132 | table_name_change_history = {'Version', 'Change History', 'Name', 'Notes'}; 133 | warning off MATLAB:xlswrite:AddSheet; 134 | xlswrite(filename, table_name_change_history, 1, 'A1'); 135 | table_name_dict = {'No.', 'Old Name', 'New Name', 'Data Source'}; 136 | xlswrite(filename, table_name_dict, 'dict', 'A1'); 137 | table_name_only_line = {'No.', 'Old Name', 'New Name'}; 138 | xlswrite(filename, table_name_only_line, 'only_line', 'A1') 139 | table_name_simu_par = {'No.', 'Name', 'Data Source','Data Type',... 140 | 'Storage Class', 'Value'}; 141 | xlswrite(filename, table_name_simu_par, 'simu_parameter', 'A1'); 142 | table_name_table = {'No.', 'Name','Data Source', 'Data Type',... 143 | 'Storage Class', 'Row', 'Column','Value'}; 144 | xlswrite(filename, table_name_table, 'simu_table', 'A1'); 145 | table_name_sf = {'No.', 'Name', 'Scope', 'Data Type'}; 146 | xlswrite(filename, table_name_sf, 'sf_parameter', 'A1'); 147 | 148 | % Write parameters to excel 149 | if 0 < len_dict 150 | number_par = [1:1:len_dict]'; 151 | xlswrite(filename, number_par, 'dict', 'A2'); 152 | xlswrite(filename, par_name, 'dict', 'B2'); 153 | xlswrite(filename, par_name, 'dict', 'C2'); 154 | xlswrite(filename, par_name_source', 'dict', 'D2'); 155 | else 156 | output = 'This model has no dictionary.' 157 | end 158 | 159 | % Write only line's name to excel 160 | if 1 < j 161 | number_only_line = [1:1:(j-1)]'; 162 | only_line_name = only_line_name'; 163 | xlswrite(filename, number_only_line, 'only_line', 'A2'); 164 | xlswrite(filename, only_line_name, 'only_line', 'B2'); 165 | xlswrite(filename, only_line_name, 'only_line', 'C2'); 166 | else 167 | output = ['This model has no ',... 168 | 'name which defined on line only.'] 169 | end 170 | 171 | % Write simulink parameters to excel 172 | if 1 < index_par 173 | number_simu_par = [1:1:(index_par-1)]'; 174 | xlswrite(filename, number_simu_par, 'simu_parameter', 'A2'); 175 | xlswrite(filename, simu_par_name', 'simu_parameter', 'B2'); 176 | xlswrite(filename, simu_par_source', 'simu_parameter', 'C2'); 177 | xlswrite(filename, simu_par_datatype', 'simu_parameter', 'D2'); 178 | xlswrite(filename, simu_par_storage', 'simu_parameter', 'E2') 179 | xlswrite(filename, simu_par_value', 'simu_parameter', 'F2'); 180 | else 181 | output = 'This model has no simulink parameter defined in dictionary.' 182 | end 183 | 184 | % Write table data to excel 185 | if 1 < index_table 186 | temp_dim = 1; 187 | for i = 1:(index_table-1) 188 | % Calculate write position 189 | temp_pos = num2str(1 + temp_dim); 190 | table_num_position = ['A' temp_pos]; 191 | table_name_position = ['B' temp_pos]; 192 | table_source_position = ['C' temp_pos]; 193 | table_datatype_position = ['D' temp_pos]; 194 | table_storage_position = ['E' temp_pos]; 195 | table_dim_position = ['F' temp_pos]; 196 | % table_dim_column_position = ['G' temp_pos]; 197 | table_value_position = ['H' temp_pos]; 198 | % Start writing 199 | xlswrite(filename, i, 'simu_table', ... 200 | table_num_position); 201 | xlswrite(filename, simu_table{i}(TABLE_NAME),... 202 | 'simu_table', table_name_position); 203 | xlswrite(filename, simu_table{i}(TABLE_SOURCE),... 204 | 'simu_table', table_source_position); 205 | xlswrite(filename, simu_table{i}(TABLE_DATATYPE),... 206 | 'simu_table', table_datatype_position); 207 | xlswrite(filename, simu_table{i}(TABLE_STORAGE),... 208 | 'simu_table', table_storage_position); 209 | xlswrite(filename, simu_table{i}{TABLE_DIM},... 210 | 'simu_table', table_dim_position); 211 | try 212 | xlswrite(filename, simu_table{i}{TABLE_VALUE},... 213 | 'simu_table', table_value_position); 214 | end 215 | 216 | temp_dim = temp_dim + simu_table{i}{TABLE_DIM}(1); 217 | end 218 | else 219 | output = 'This model has no table parameter.' 220 | end 221 | 222 | % Write stateflow parameter to Excel 223 | if 0 < len_sf 224 | number_sf = [1:1:len_sf]'; 225 | xlswrite(filename, number_sf, 'sf_parameter', 'A2'); 226 | xlswrite(filename, sf_par_name', 'sf_parameter', 'B2'); 227 | xlswrite(filename, sf_par_scope', 'sf_parameter', 'C2'); 228 | xlswrite(filename, sf_par_datatype', 'sf_parameter', 'D2'); 229 | end 230 | 231 | % close the dictionary 232 | close(current_dic); 233 | output = 'Listing name successful.'; 234 | 235 | end -------------------------------------------------------------------------------- /propagate_signals.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for propagating signals. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : 7 | %------------------------------------------------------------------------------ 8 | 9 | function propagae_signals_result = propagate_signals() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R202017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character... 27 | % encoding (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | all_line = find_system(paraModel,'FindAll','on','type','line'); 32 | % Parameters define 33 | j = 1; 34 | % k = 1; 35 | enable_pg_flag = 0; 36 | length_line = length(all_line); 37 | 38 | % Find the line which need propagating signals 39 | for i = 1:length_line 40 | % Detect 'Show propagated signals' state 41 | current_line_sp = get(all_line(i),'SignalPropagation'); 42 | % Detect 'Signal name' 43 | current_line_name = get(all_line(i),'Name'); 44 | 45 | % judge whether signal has name 46 | if 1 == isempty(current_line_name) 47 | % no name 48 | ne_flag = 1; 49 | else 50 | % have name 51 | ne_flag = 0; 52 | end 53 | % judge whether 'Show propagated signals' is 'on' 54 | if 0 == strcmp(current_line_sp,'on') 55 | sp_flag = 2; 56 | else 57 | sp_flag = 0; 58 | end 59 | line_a_flag = bitor(sp_flag,ne_flag); 60 | if 3 == line_a_flag 61 | propagated_signals_line(j) = all_line(i); 62 | j = j + 1; 63 | enable_pg_flag = 1; 64 | else 65 | % Do nothing 66 | end 67 | end 68 | 69 | % set signal propagation to on 70 | if 1 == enable_pg_flag 71 | length_ps_line = length(propagated_signals_line); 72 | for i = 1:length_ps_line 73 | try 74 | set(propagated_signals_line(i),'SignalPropagation','on'); 75 | catch 76 | warning('This line',propagated_signals_line(i),... 77 | 'can not set the propagated signals on,',... 78 | ' it should define name first'); 79 | end 80 | end 81 | % report configurate results 82 | propagae_signals_result = 'Propagate signals successful'; 83 | else 84 | % report configurate results 85 | propagae_signals_result = 'No signal line need propagating signal'; 86 | end 87 | end 88 | 89 | -------------------------------------------------------------------------------- /rename_port_to_sig.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for rename the blocks' name to signals' name 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Time : 2017/12/20 6 | % Version : Initial -0.1 7 | % Support goto & from block 8 | % Code refactoring -0.2 9 | % Instructions : 10 | %------------------------------------------------------------------------------ 11 | 12 | function rename_ports_result = rename_port_to_sig() 13 | 14 | paraModel = bdroot; 15 | 16 | % Original matalb version is R2017a 17 | % 检查Matlab版本是否为R202017a 18 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 19 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 20 | CurrentVersion = version; 21 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 22 | strcmp(CorrectVersion_linux, CurrentVersion)) 23 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 24 | end 25 | 26 | % Original environment character encoding: GBK 27 | % 脚本编码环境是否为GBK 28 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 29 | % warning('Simulink:EncodingUnMatched', 'The target character... 30 | % encoding (%s) is different from the original (%s).',... 31 | % get_param(0, 'CharacterEncoding'), 'GBK'); 32 | % end 33 | 34 | % find all inport block 35 | inport_block = find_system(paraModel,'FindAll','on','BlockType','Inport'); 36 | % find all outport block 37 | outport_block = find_system(paraModel,'FindAll','on',... 38 | 'BlockType','Outport'); 39 | % Find all Goto block 40 | goto_block = find_system(paraModel, 'FindAll','on','BlockType','Goto'); 41 | % Find all From block 42 | from_block = find_system(paraModel,'FindAll','on','BlockType','From'); 43 | 44 | % rename inport blocks to signals' name 45 | SetPortName(inport_block, 'OutputSignalNames', 'Name'); 46 | % rename outport blocks to signals' name 47 | SetPortName(outport_block, 'InputSignalNames', 'Name'); 48 | % Rename Goto blocks to signals's name 49 | SetPortName(goto_block, 'InputSignalNames','GotoTag'); 50 | % Rename From blocks to signals's name 51 | SetPortName(from_block, 'OutputSignalNames','GotoTag'); 52 | 53 | 54 | 55 | rename_ports_result = 'rename port to signal name successful'; 56 | end 57 | %-----------------End of function---------------------------------------------- 58 | 59 | %-----------Start of function-------------------------------------------------- 60 | function SetPortName(block, get_type, set_type) 61 | if isempty(block) 62 | % Do nothing 63 | else 64 | length_block = length(block); 65 | for i = 1:length_block 66 | current_sig_name = get(block(i), get_type); 67 | % translate cell to string 68 | current_sig_name = cell2mat(current_sig_name); 69 | if 1 == isempty(current_sig_name) 70 | % Do nothing. output line has no name defined. 71 | else 72 | % find if tag symbol '<' exit 73 | if strcmp('<',current_sig_name(1)) 74 | % remove the tag symbol '< >' 75 | current_sig_name = current_sig_name(2:end-1); 76 | else 77 | % Do nothing 78 | end 79 | % rename 80 | try 81 | set(block(i), set_type, current_sig_name); 82 | catch 83 | 84 | end 85 | end 86 | end 87 | end 88 | end 89 | %-----------------End of function---------------------------------------------- 90 | -------------------------------------------------------------------------------- /rename_sig_to_port.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for rename the blocks' name to signals' name 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Time : 2017/12/20 6 | % Version : Creat as initial - 0.1 7 | % Support goto & from block 8 | % Code refactoring - 0.2 9 | % Instructions : 10 | %------------------------------------------------------------------------------ 11 | 12 | function rename_sig_result = rename_sig_to_port() 13 | 14 | paraModel = bdroot; 15 | 16 | % Original matalb version is R2017a 17 | % 检查Matlab版本是否为R202017a 18 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 19 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 20 | CurrentVersion = version; 21 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 22 | strcmp(CorrectVersion_linux, CurrentVersion)) 23 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 24 | end 25 | 26 | % find all blocks which needed 27 | inport_block = find_system(paraModel,'FindAll','on','BlockType','Inport'); 28 | outport_block = find_system(paraModel,'FindAll','on','BlockType','Outport'); 29 | goto_block = find_system(paraModel, 'FindAll','on','BlockType','Goto'); 30 | from_block = find_system(paraModel,'FindAll','on','BlockType','From'); 31 | 32 | all_line = find_system(paraModel,'FindAll','on','type','line'); 33 | 34 | % filter lines which can be named 35 | n = 0; 36 | for i = 1:length(all_line) 37 | current_cfg = get(all_line(i),'SignalPropagation'); 38 | if strcmp('off', current_cfg) 39 | n = n + 1; 40 | filter_lines(n) = all_line(i); 41 | end 42 | end 43 | % Rename them 44 | RenameSigName(goto_block, filter_lines, 'DstBlockHandle', 'GotoTag'); 45 | RenameSigName(from_block, filter_lines, 'SrcBlockHandle', 'GotoTag'); 46 | RenameSigName(inport_block, filter_lines, 'SrcBlockHandle', 'Name'); 47 | RenameSigName(outport_block, filter_lines, 'DstBlockHandle', 'Name'); 48 | 49 | rename_sig_result = 'Rename signal lines successful'; 50 | end 51 | %-----------End of function---------------------------------------------------- 52 | 53 | %-----------Start of function-------------------------------------------------- 54 | function RenameSigName(blocks, lines, connect_handle, name_par) 55 | length_lines = length(lines); 56 | % Judge whether block is empty 57 | if isempty(blocks) 58 | % Do Nothing 59 | else 60 | length_block = length(blocks); 61 | % find block links and rename them 62 | for i = 1:length_block 63 | current_handle = num2str(get_param(blocks(i),'Handle')); 64 | for j = 1:length_lines 65 | % calculate reference handle 66 | reference_handle = num2str(get_param(lines(j), ... 67 | connect_handle)); 68 | if strcmp(current_handle, reference_handle) 69 | target_name = get_param(blocks(i), name_par); 70 | set_param(lines(j), 'Name', target_name); 71 | break; 72 | end 73 | end 74 | end 75 | end 76 | end 77 | %-----------End of function---------------------------------------------------- -------------------------------------------------------------------------------- /resolve_signals.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for resolve to signals. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.1 6 | % Instructions : 7 | %------------------------------------------------------------------------------ 8 | 9 | function resolve_signals_result = resolve_signals() 10 | 11 | paraModel = bdroot; 12 | 13 | % Original matalb version is R2017a 14 | % 检查Matlab版本是否为R202017a 15 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 16 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 17 | CurrentVersion = version; 18 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 19 | strcmp(CorrectVersion_linux, CurrentVersion)) 20 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 21 | end 22 | 23 | % Original environment character encoding: GBK 24 | % 脚本编码环境是否为GBK 25 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 26 | % warning('Simulink:EncodingUnMatched', 'The target character ... 27 | % encoding (%s) is different from the original (%s).',... 28 | % get_param(0, 'CharacterEncoding'), 'GBK'); 29 | % end 30 | 31 | all_line = find_system(paraModel,'FindAll','on','type','line'); 32 | % Parameters define 33 | k = 1; 34 | enable_rs_flag = 0; 35 | length_line = length(all_line); 36 | 37 | % Find the line which need propagating signals 38 | for i = 1:length_line 39 | % Detect 'Signal name' 40 | current_line_name = get(all_line(i),'Name'); 41 | % Detect 'Signal name must resolve to Simulink signal object' state 42 | current_line_rs = get(all_line(i),'MustResolveToSignalObject'); 43 | 44 | % judge whether signal has name 45 | if 1 == isempty(current_line_name) 46 | % no name 47 | ne_flag = 1; 48 | else 49 | % have name 50 | ne_flag = 0; 51 | end 52 | % judge whether signal set must resolve to signal object 53 | if 0 == current_line_rs 54 | rs_flag = 4; 55 | else 56 | rs_flag = 0; 57 | end 58 | % Mark the line which both resolve to signal and Name are disabled 59 | line_b_flag = bitor(rs_flag,ne_flag); 60 | if 4 == line_b_flag 61 | resolve_singals_line(k) = all_line(i); 62 | k = k + 1; 63 | enable_rs_flag = 1; 64 | else 65 | % Do nothing 66 | end 67 | end 68 | 69 | % set 'Signal name must resolve to Simulink signal object' to on 70 | if 1 == enable_rs_flag 71 | length_rs_line = length(resolve_singals_line); 72 | for i = 1:length_rs_line 73 | try 74 | set(resolve_singals_line(i),'MustResolveToSignalObject',1); 75 | catch 76 | % do nothing 77 | end 78 | end 79 | % report configurate results 80 | resolve_signals_result = 'resolve signals successful'; 81 | else 82 | % report configurate results 83 | resolve_signals_result = 'No signal line need resovling to signal'; 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /select_c_h.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | #------------------------------------------------------------------------------ 5 | # Function : This scrip is used for selecting .c and .h files 6 | # Enviroment : python 3.6.2 7 | # Author : Shibo Jiang 8 | # Time : 2017.10.6 9 | # Version : 0.1 10 | # Notes : None 11 | #------------------------------------------------------------------------------ 12 | import os 13 | import shutil 14 | 15 | #creat folder named 'select_result' to store select results 16 | abs_path = os.path.join(os.path.abspath('.'), 'select_result') 17 | 18 | # #judge whether folder is exist,and creat a stand folder 19 | # folder_number = 0 20 | # temp_path = abs_path 21 | # exclude_path = [abs_path] 22 | # while 1: 23 | # if (os.path.split(abs_path))[1] in os.listdir(os.path.abspath('.')): 24 | # folder_number = folder_number + 1 25 | # abs_path = temp_path + '_' + str(folder_number) 26 | # exclude_path.append(abs_path) 27 | # else: 28 | # break 29 | 30 | #delete older folder and creat new 31 | if (os.path.split(abs_path))[1] in os.listdir(os.path.abspath('.')): 32 | shutil.rmtree(abs_path) 33 | 34 | #search c&h files function 35 | def find_files(path, search, default_result, exclude = None): 36 | for x_path in os.listdir(path): 37 | if x_path != exclude: 38 | x_path = os.path.join(path, x_path) 39 | if os.path.isdir(x_path): 40 | find_files(x_path, search, default_result, exclude = None) 41 | elif (os.path.splitext(x_path)[1]).lower() == search: 42 | default_result.append(x_path) 43 | 44 | #find .h files and store the path in a list 45 | h_files = ['0'] 46 | find_files(os.path.abspath('.'), '.h', h_files) 47 | 48 | #find .c files and store the path in a list 49 | c_files = ['0'] 50 | find_files(os.path.abspath('.'), '.c', c_files) 51 | 52 | #creat new folder named files_c & file_h in select_result 53 | os.mkdir(abs_path) 54 | new_dir = [0, 0] 55 | C = 0 56 | H = 1 57 | new_dir[C] = os.path.join(abs_path, 'files_c') 58 | new_dir[H] = os.path.join(abs_path, 'files_h') 59 | for i in range(2): 60 | os.mkdir(new_dir[i]) 61 | 62 | #copy .h files to the folder named files_h 63 | repeat_name_file = [] 64 | if len(h_files) > 1: 65 | for x_file in h_files[1:]: 66 | if (os.path.split(x_file))[1] in os.listdir(new_dir[H]): 67 | repeat_name_file.append(x_file) 68 | else: 69 | shutil.copy(x_file, new_dir[H]) 70 | 71 | #copy .c files to the folder named files_c 72 | if len(c_files) > 1: 73 | for x_file in c_files[1:]: 74 | if (os.path.split(x_file))[1] in os.listdir(new_dir[C]): 75 | repeat_name_file.append(x_file) 76 | else: 77 | shutil.copy(x_file, new_dir[C]) 78 | 79 | #report files need rename 80 | if len(repeat_name_file) > 0: 81 | print('These files have duplicate names and are not \ 82 | copied to result floder.- \n' + str(repeat_name_file)) 83 | 84 | #-End of file------------------------------------------------------------------ 85 | -------------------------------------------------------------------------------- /show_name_blocks.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for show block names. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Version : 0.2 6 | % Time : 2017/11/29 7 | % Instructions: the blocks include MinMax,UnitDelay,Sqrt,Merge,Product,Logic 8 | % ,RelationalOperator,Switch,MultiPortSwitch,Goto,From 9 | % ,Terminator,ModelReference - 0.1 10 | % Fix bugs - 0.2 11 | %------------------------------------------------------------------------------ 12 | 13 | function show_block_name_result = show_name_blocks() 14 | 15 | paraModel = bdroot; 16 | 17 | % Original matalb version is R2017a 18 | % 检查Matlab版本是否为R202017a 19 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 20 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 21 | CurrentVersion = version; 22 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 23 | strcmp(CorrectVersion_linux, CurrentVersion)) 24 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 25 | end 26 | 27 | % Original environment character encoding: GBK 28 | % 脚本编码环境是否为GBK 29 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 30 | % warning('Simulink:EncodingUnMatched', 'The target character ... 31 | % encoding (%s) is different from the original (%s).',... 32 | % get_param(0, 'CharacterEncoding'), 'GBK'); 33 | % end 34 | 35 | % find MinMax blocks 36 | min_max_blocks = find_system(paraModel,'FindAll',... 37 | 'on','BlockType','MinMax'); 38 | % find UnitDelay blocks 39 | uint_delay_blocks = find_system(paraModel,'FindAll',... 40 | 'on','BlockType','UnitDelay'); 41 | % find Sqrt blocks 42 | sqrt_blocks = find_system(paraModel,'FindAll',... 43 | 'on','BlockType','Sqrt'); 44 | % find Merge blocks 45 | merge_blocks = find_system(paraModel,'FindAll',... 46 | 'on','BlockType','Merge'); 47 | % find Product blocks 48 | product_blocks = find_system(paraModel,'FindAll','on',... 49 | 'BlockType','Product'); 50 | % find Logic blocks 51 | logic_blocks = find_system(paraModel,'FindAll',... 52 | 'on','BlockType','Logic'); 53 | % find RelationalOperator blocks 54 | relational_operator_blocks = find_system(paraModel,'FindAll',... 55 | 'on','BlockType','RelationalOperator'); 56 | % find Switch blocks 57 | % switch_blocks = find_system(paraModel,'FindAll',... 58 | % 'on','BlockType','Switch'); 59 | % find MultiPortSwitch blocks 60 | multi_switch_blocks = find_system(paraModel,'FindAll',... 61 | 'on','BlockType','MultiPortSwitch'); 62 | % find Goto blocks 63 | goto_blocks = find_system(paraModel,'FindAll',... 64 | 'on','BlockType','Goto'); 65 | % find From blocks 66 | from_blocks = find_system(paraModel,'FindAll','on',... 67 | 'BlockType','From'); 68 | % find Terminator blocks 69 | terminator_blocks = find_system(paraModel,'FindAll',... 70 | 'on','BlockType','Terminator'); 71 | % find ModelReference blocks 72 | model_reference_blocks = find_system(paraModel,'FindAll',... 73 | 'on','BlockType','ModelReference'); 74 | % find Switch blocks 75 | switch_blocks = find_system(paraModel,'FindAll','on',... 76 | 'BlockType','Switch'); 77 | 78 | % all blocks which need hiding names 79 | show_name_blocks = [min_max_blocks',uint_delay_blocks',sqrt_blocks',... 80 | merge_blocks',product_blocks',logic_blocks'... 81 | ,relational_operator_blocks',switch_blocks',... 82 | multi_switch_blocks',goto_blocks',from_blocks'... 83 | ,terminator_blocks',model_reference_blocks',... 84 | switch_blocks']; 85 | 86 | length_show_name_line = length(show_name_blocks); 87 | for i = 1:length_show_name_line 88 | try 89 | set_param(show_name_blocks(i),'ShowName','on') 90 | catch 91 | % do nothing 92 | end 93 | end 94 | % report configurate results 95 | show_block_name_result = 'show block name successful'; 96 | end 97 | -------------------------------------------------------------------------------- /show_name_ports.m: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------------ 2 | % Simulink scrip for show port names. 3 | % MATLAB version: R2017a 4 | % Author : Shibo Jiang 5 | % Time : 2017/11/29 6 | % Version : 0.2 7 | % Instructions : the blocks include Inport,Outport - 0.1 8 | % Fix bugs - 0.2 9 | %------------------------------------------------------------------------------ 10 | 11 | function show_port_name_result = show_name_ports() 12 | 13 | paraModel = bdroot; 14 | 15 | % Original matalb version is R2017a 16 | % 检查Matlab版本是否为R202017a 17 | CorrectVersion_win = '9.2.0.556344 (R2017a)'; % windows 18 | CorrectVersion_linux = '9.2.0.538062 (R2017a)'; % linux 19 | CurrentVersion = version; 20 | if 1 ~= bitor(strcmp(CorrectVersion_win, CurrentVersion),... 21 | strcmp(CorrectVersion_linux, CurrentVersion)) 22 | warning('Matlab version mismatch, this scrip should be used for Matlab R2017a'); 23 | end 24 | 25 | % Original environment character encoding: GBK 26 | % 脚本编码环境是否为GBK 27 | % if ~strcmpi(get_param(0, 'CharacterEncoding'), 'GBK') 28 | % warning('Simulink:EncodingUnMatched', 'The target... 29 | % character encoding (%s) is different from the original (%s).',... 30 | % get_param(0, 'CharacterEncoding'), 'GBK'); 31 | % end 32 | 33 | % find inport blocks 34 | Inport_blocks = find_system(paraModel,'FindAll','on',... 35 | 'BlockType','Inport'); 36 | % find Outport blocks 37 | Outport_blocks = find_system(paraModel,'FindAll','on',... 38 | 'BlockType','Outport'); 39 | 40 | % all blocks which need hiding names 41 | show_name_ports = [Inport_blocks',Outport_blocks']; 42 | 43 | length_show_name_line = length(show_name_ports); 44 | for i = 1:length_show_name_line 45 | try 46 | set_param(show_name_ports(i),'ShowName','on') 47 | catch 48 | % do nothing 49 | end 50 | end 51 | % report configurate results 52 | show_port_name_result = 'show port name successful'; 53 | end 54 | -------------------------------------------------------------------------------- /test_case_convert.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | #------------------------------------------------------------------------------ 5 | # Function : This scrip is used for convert testcase's macro to number 6 | # Enviroment : python 3.6.2 7 | # Author : Shibo Jiang 8 | # Time : 2018.4.4 9 | # Version : 0.1 10 | # Notes : None 11 | #------------------------------------------------------------------------------ 12 | import xlrd 13 | import openpyxl 14 | 15 | # Maro define 16 | FILE = 'CANSigRec_TestCase.xlsx' 17 | SHEET_DEF = 'TestCase_MacroDef' 18 | SHEET_OUT = 'TestCase_convert' 19 | SHEET_ORGIN = 'TestCase_orgin' 20 | 21 | def test_case_convert(): 22 | # Get excel files and sheets 23 | work_book = xlrd.open_workbook(FILE) 24 | macro_sheet = work_book.sheet_by_name(SHEET_DEF) 25 | orgin_sheet = work_book.sheet_by_name(SHEET_ORGIN) 26 | 27 | # Get macro_sheet data and creat dict 28 | macro_dict = dict() 29 | for i in range(macro_sheet.nrows): 30 | data = macro_sheet.row_values(i) 31 | # Set dict 32 | macro_dict[str(data[0])] = data[1] 33 | 34 | # Get orgin sheet and use dict's value to replace out sheet 35 | w_row = list() 36 | w_col = list() 37 | w_value = list() 38 | for temp_row in range(orgin_sheet.nrows): 39 | temp_list = orgin_sheet.row_values(temp_row) 40 | temp_col = 0 41 | for temp_data in temp_list: 42 | if temp_data in macro_dict: 43 | w_row.append(temp_row) 44 | w_col.append(temp_col) 45 | w_value.append(macro_dict[temp_data]) 46 | temp_col = temp_col + 1 47 | 48 | # Write new value to out sheet 49 | write_book = openpyxl.load_workbook(FILE) 50 | out_sheet = write_book.get_sheet_by_name(SHEET_OUT) 51 | for i in range(len(w_row)): 52 | out_sheet.cell(row = w_row[i],column = w_col[i]).value = w_value[i] 53 | 54 | # Run script 55 | test_case_convert() 56 | -------------------------------------------------------------------------------- /toto.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShiboJiang/Simulink_Model_Tools/3b25dc13e80fc41540bc8e3615995b6aa7b7ddee/toto.fig -------------------------------------------------------------------------------- /toto.m: -------------------------------------------------------------------------------- 1 | function varargout = toto(varargin) 2 | % TOTO MATLAB code for toto.fig 3 | % TOTO, by itself, creates a new TOTO or raises the existing 4 | % singleton*. 5 | % 6 | % H = TOTO returns the handle to a new TOTO or the handle to 7 | % the existing singleton*. 8 | % 9 | % TOTO('CALLBACK',hObject,eventData,handles,...) calls the local 10 | % function named CALLBACK in TOTO.M with the given input arguments. 11 | % 12 | % TOTO('Property','Value',...) creates a new TOTO or raises the 13 | % existing singleton*. Starting from the left, property value pairs are 14 | % applied to the GUI before toto_OpeningFcn gets called. An 15 | % unrecognized property name or invalid value makes property application 16 | % stop. All inputs are passed to toto_OpeningFcn via varargin. 17 | % 18 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 19 | % instance to run (singleton)". 20 | % 21 | % See also: GUIDE, GUIDATA, GUIHANDLES 22 | 23 | % Edit the above text to modify the response to help toto 24 | 25 | % Last Modified by GUIDE v2.5 03-Nov-2018 22:07:41 26 | 27 | % Begin initialization code - DO NOT EDIT 28 | gui_Singleton = 1; 29 | gui_State = struct('gui_Name', mfilename, ... 30 | 'gui_Singleton', gui_Singleton, ... 31 | 'gui_OpeningFcn', @toto_OpeningFcn, ... 32 | 'gui_OutputFcn', @toto_OutputFcn, ... 33 | 'gui_LayoutFcn', [] , ... 34 | 'gui_Callback', []); 35 | if nargin && ischar(varargin{1}) 36 | gui_State.gui_Callback = str2func(varargin{1}); 37 | end 38 | 39 | if nargout 40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 41 | else 42 | gui_mainfcn(gui_State, varargin{:}); 43 | end 44 | % End initialization code - DO NOT EDIT 45 | 46 | 47 | % --- Executes just before toto is made visible. 48 | function toto_OpeningFcn(hObject, eventdata, handles, varargin) 49 | % This function has no output args, see OutputFcn. 50 | % hObject handle to figure 51 | % eventdata reserved - to be defined in a future version of MATLAB 52 | % handles structure with handles and user data (see GUIDATA) 53 | % varargin command line arguments to toto (see VARARGIN) 54 | 55 | % Choose default command line output for toto 56 | handles.output = hObject; 57 | 58 | % Update handles structure 59 | guidata(hObject, handles); 60 | 61 | % UIWAIT makes toto wait for user response (see UIRESUME) 62 | % uiwait(handles.figure1); 63 | 64 | 65 | % --- Outputs from this function are returned to the command line. 66 | function varargout = toto_OutputFcn(hObject, eventdata, handles) 67 | % varargout cell array for returning output args (see VARARGOUT); 68 | % hObject handle to figure 69 | % eventdata reserved - to be defined in a future version of MATLAB 70 | % handles structure with handles and user data (see GUIDATA) 71 | 72 | % Get default command line output from handles structure 73 | varargout{1} = handles.output; 74 | 75 | 76 | % --- Executes on button press in add_sig_parameter. 77 | function add_sig_parameter_Callback(hObject, eventdata, handles) 78 | % hObject handle to add_sig_parameter (see GCBO) 79 | % eventdata reserved - to be defined in a future version of MATLAB 80 | % handles structure with handles and user data (see GUIDATA) 81 | add_sig_parameter() 82 | 83 | 84 | % --- Executes on button press in resolve_signals. 85 | function resolve_signals_Callback(hObject, eventdata, handles) 86 | % hObject handle to resolve_signals (see GCBO) 87 | % eventdata reserved - to be defined in a future version of MATLAB 88 | % handles structure with handles and user data (see GUIDATA) 89 | resolve_signals() 90 | 91 | 92 | % --- Executes on button press in propagate_signals. 93 | function propagate_signals_Callback(hObject, eventdata, handles) 94 | % hObject handle to propagate_signals (see GCBO) 95 | % eventdata reserved - to be defined in a future version of MATLAB 96 | % handles structure with handles and user data (see GUIDATA) 97 | propagate_signals() 98 | 99 | 100 | % --- Executes on button press in rename_port. 101 | function rename_port_Callback(hObject, eventdata, handles) 102 | % hObject handle to rename_port (see GCBO) 103 | % eventdata reserved - to be defined in a future version of MATLAB 104 | % handles structure with handles and user data (see GUIDATA) 105 | rename_port_to_sig() 106 | 107 | 108 | % --- Executes on button press in clear_resolve. 109 | function clear_resolve_Callback(hObject, eventdata, handles) 110 | % hObject handle to clear_resolve (see GCBO) 111 | % eventdata reserved - to be defined in a future version of MATLAB 112 | % handles structure with handles and user data (see GUIDATA) 113 | clear_resolve() 114 | 115 | 116 | % --- Executes on button press in clear_propagate. 117 | function clear_propagate_Callback(hObject, eventdata, handles) 118 | % hObject handle to clear_propagate (see GCBO) 119 | % eventdata reserved - to be defined in a future version of MATLAB 120 | % handles structure with handles and user data (see GUIDATA) 121 | clear_propagate() 122 | 123 | 124 | % --- Executes on button press in creat_p_files. 125 | function creat_p_files_Callback(hObject, eventdata, handles) 126 | % hObject handle to creat_p_files (see GCBO) 127 | % eventdata reserved - to be defined in a future version of MATLAB 128 | % handles structure with handles and user data (see GUIDATA) 129 | creat_p_files() 130 | 131 | 132 | % -------------------------------------------------------------------- 133 | function Untitled_1_Callback(hObject, eventdata, handles) 134 | % hObject handle to Untitled_1 (see GCBO) 135 | % eventdata reserved - to be defined in a future version of MATLAB 136 | % handles structure with handles and user data (see GUIDATA) 137 | 138 | 139 | % --- Executes on button press in ERT. 140 | function ERT_Callback(hObject, eventdata, handles) 141 | % hObject handle to ERT (see GCBO) 142 | % eventdata reserved - to be defined in a future version of MATLAB 143 | % handles structure with handles and user data (see GUIDATA) 144 | ERT_configuration() 145 | 146 | 147 | % --- Executes on button press in AUTOSAR. 148 | function AUTOSAR_Callback(hObject, eventdata, handles) 149 | % hObject handle to AUTOSAR (see GCBO) 150 | % eventdata reserved - to be defined in a future version of MATLAB 151 | % handles structure with handles and user data (see GUIDATA) 152 | Autosar_configuration() 153 | 154 | 155 | % --- Executes on button press in HideNameBlock. 156 | function HideNameBlock_Callback(hObject, eventdata, handles) 157 | % hObject handle to HideNameBlock (see GCBO) 158 | % eventdata reserved - to be defined in a future version of MATLAB 159 | % handles structure with handles and user data (see GUIDATA) 160 | hide_name_blocks() 161 | 162 | 163 | % --- Executes on button press in ShowNameBlock. 164 | function ShowNameBlock_Callback(hObject, eventdata, handles) 165 | % hObject handle to ShowNameBlock (see GCBO) 166 | % eventdata reserved - to be defined in a future version of MATLAB 167 | % handles structure with handles and user data (see GUIDATA) 168 | show_name_blocks() 169 | 170 | 171 | % --- Executes on button press in HideNamePort. 172 | function HideNamePort_Callback(hObject, eventdata, handles) 173 | % hObject handle to HideNamePort (see GCBO) 174 | % eventdata reserved - to be defined in a future version of MATLAB 175 | % handles structure with handles and user data (see GUIDATA) 176 | hide_name_ports() 177 | 178 | 179 | % --- Executes on button press in ShowNamePort. 180 | function ShowNamePort_Callback(hObject, eventdata, handles) 181 | % hObject handle to ShowNamePort (see GCBO) 182 | % eventdata reserved - to be defined in a future version of MATLAB 183 | % handles structure with handles and user data (see GUIDATA) 184 | show_name_ports() 185 | 186 | 187 | % --- Executes on button press in FixSFParType. 188 | function FixSFParType_Callback(hObject, eventdata, handles) 189 | % hObject handle to FixSFParType (see GCBO) 190 | % eventdata reserved - to be defined in a future version of MATLAB 191 | % handles structure with handles and user data (see GUIDATA) 192 | fix_stateflow_parameter_type() 193 | 194 | 195 | % --- Executes on button press in ChangePortProperty. 196 | function ChangePortProperty_Callback(hObject, eventdata, handles) 197 | % hObject handle to ChangePortProperty (see GCBO) 198 | % eventdata reserved - to be defined in a future version of MATLAB 199 | % handles structure with handles and user data (see GUIDATA) 200 | change_port_property() 201 | 202 | 203 | % --- Executes on button press in DefaultPortProperty. 204 | function DefaultPortProperty_Callback(hObject, eventdata, handles) 205 | % hObject handle to DefaultPortProperty (see GCBO) 206 | % eventdata reserved - to be defined in a future version of MATLAB 207 | % handles structure with handles and user data (see GUIDATA) 208 | default_port_property() 209 | 210 | 211 | % --- Executes on button press in sf_par_type_auto. 212 | function sf_par_type_auto_Callback(hObject, eventdata, handles) 213 | % hObject handle to sf_par_type_auto (see GCBO) 214 | % eventdata reserved - to be defined in a future version of MATLAB 215 | % handles structure with handles and user data (see GUIDATA) 216 | auto_sf_par_type() 217 | 218 | 219 | % --- Executes on button press in list_parameter. 220 | function list_parameter_Callback(hObject, eventdata, handles) 221 | % hObject handle to list_parameter (see GCBO) 222 | % eventdata reserved - to be defined in a future version of MATLAB 223 | % handles structure with handles and user data (see GUIDATA) 224 | out = list_parameter() 225 | 226 | % --- Executes on button press in change_parameter. 227 | function change_parameter_Callback(hObject, eventdata, handles) 228 | % hObject handle to change_parameter (see GCBO) 229 | % eventdata reserved - to be defined in a future version of MATLAB 230 | % handles structure with handles and user data (see GUIDATA) 231 | out = change_parameter() 232 | 233 | 234 | % --- Executes on button press in rename_line. 235 | function rename_line_Callback(hObject, eventdata, handles) 236 | % hObject handle to rename_line (see GCBO) 237 | % eventdata reserved - to be defined in a future version of MATLAB 238 | % handles structure with handles and user data (see GUIDATA) 239 | out = rename_sig_to_port() 240 | -------------------------------------------------------------------------------- /toto.mlappinstall: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShiboJiang/Simulink_Model_Tools/3b25dc13e80fc41540bc8e3615995b6aa7b7ddee/toto.mlappinstall -------------------------------------------------------------------------------- /调试记录.md: -------------------------------------------------------------------------------- 1 | [TOC] 2 | 3 | # 1. add_sig_parameter_u8 脚本 4 | 5 | - 目的为自动在MATLAB workspace中添加 模型中信号线上有名字的变量,将该名字作为变量名,储存类型为Auto,数据类型为 uint8 6 | - 使用`find_system(paraModel,'FindAll','on','type','line');`,找到所有信号线 7 | - 使用`simulink_var_space = get_param(paraModel,'ModelWorkspace');`和`simulink_var = simulink_var_space.whos;`两条语句获得modelspace中定义的变量 8 | - 使用`temp = Simulink.Signal;`和`temp.DataType = 'uint8'`来创建一个simulink信号,然后使用`eval([SigName '= temp']); clear temp`来将信号名指定为SigName所代表的字符串。 9 | - 发现第三条没法实现工作区的变量添加,后续查找使用这条命令`assignin('base',name_defined,temp_defined);`,可以创建。 10 | 11 | # 2. creat_p_files 脚本 12 | 13 | - 自动索引当前工作目录,然后找到所有.m文件,加密成.p文件 14 | - 使用`cd`命令得到当前目录 15 | - 使用`files = dir(the_path);`得到当前目录下所有文件 16 | - 使用`current_name = files(i).name;`得到某个文件的文件名 17 | - 使用`current_type = current_name(end-1:end);`截取文件名后两位,代表该文件类型 18 | - 使用`pcode (current_name);`进行.m文件的封装 19 | 20 | # 3. rename_port_to_sig 脚本 21 | 22 | - 使用`find_system(paraModel,'FindAll','on','BlockType','Inport');`找出inport模块,同理找出outport模块 23 | - 使用`get(inport_block(i),'OutputSignalNames');`得到inport模块输出信号的名字 24 | - 使用`get(outport_block(i),'InputSignalNames');`得到Outport模块输入信号的名字 25 | - 使用`cell2mat(current_in_sig_name)`将获得的信号名字转为字符串 26 | - 使用`set(inport_block(i),'Name',current_out_sig_name);`设置模块名称 27 | 28 | # 4. fix_stateflow_parameter_type 脚本 29 | 30 | - 使用`sf = sfroot;`,`all_sf_parameter = sf.find('-isa','Stateflow.Data');`两条命令获得stateflow中所使用的变量 31 | - 使用`all_sf_parameter(i).Scope`获得stateflow中变量的范围类型,来区分是否为input/output 32 | - 使用`set(other_sf_par(i),'DataType',sf_par_datatype_cfg)`语句来写入变量的数据类型 33 | 34 | # 5. change_port_property 脚本 35 | 36 | - 使用`find_system(paraModel,'FindAll','on','type','line','Name',current_out_sig_name);`命令找到特定名字的信号线 37 | - 使用`set(inport_signal_line,'MustResolveToSignalObject',0);`命令将信号线resolve选项清掉 --------------------------------------------------------------------------------