%% Dummy Script for Define Data in the Generated Code
% Embedded Coder Getting Started.
%% Section 1 - set up 
load_system('roll')

temp = Simulink.Signal;
temp.CoderInfo.StorageClass = 'Custom';
temp.CoderInfo.CustomStorageClass = 'Struct';
temp.CoderInfo.CustomAttributes.StructName = 'sigStruct';
portHandles = get_param('roll/EngSwitch','portHandles');
outportHandle = portHandles.Outport;
set_param(outportHandle,'SignalObject',copy(temp))
portHandles = get_param('roll/ModeSwitch','portHandles');
outportHandle = portHandles.Outport;
set_param(outportHandle,'SignalObject',copy(temp))

UpThrParam = Simulink.Parameter(6);
UpThrParam.CoderInfo.StorageClass = 'Custom';
UpThrParam.CoderInfo.CustomStorageClass = 'ExportToFile';
UpThrParam.CoderInfo.CustomAttributes.HeaderFile = 'calParams.h';
UpThrParam.CoderInfo.CustomAttributes.DefinitionFile = 'calParamData.c';
LoThrParam = copy(UpThrParam);
LoThrParam.Value = -6;
set_param('roll/RollAngleReference/UpThr','Value','UpThrParam')
set_param('roll/RollAngleReference/LoThr','Value','LoThrParam')

rtwbuild('roll')
%% Section 2 - roll.h struct type
file = fullfile('roll_ert_rtw','roll.h');
rtwdemodbtype(file,'/* Type definition for custom storage class: Struct */','sigStruct_type',1,1)
%% Section 3 - roll.h sigStruct
rtwdemodbtype(file,'/* Declaration for custom storage class: Struct */','extern sigStruct_type sigStruct;',1,1)
%% Section 4 - calParams.h
file = fullfile('slprj','ert','_sharedutils','calParams.h');
rtwdemodbtype(file,'/* Declaration for custom storage class: ExportToFile */','extern real32_T UpThrParam;',1,1)
%% Section 5 - roll.c
file = fullfile('roll_ert_rtw','roll.c');
rtwdemodbtype(file,'/* Definition for custom storage class: Struct */','sigStruct_type sigStruct;',1,1)
%% Section 6 - calParamData.c
file = fullfile('roll_ert_rtw','calParamData.c');
rtwdemodbtype(file,'/* Definition for custom storage class: ExportToFile */','real32_T UpThrParam = 6.0F;',1,1)


%% 
% Copyright 2012 The MathWorks, Inc.