Skip to content
Snippets Groups Projects
Commit 3698c1e0 authored by Cristian Galperti's avatar Cristian Galperti
Browse files

template marte2cfg generator heavily refactored

parent fd1a967f
No related branches found
No related tags found
No related merge requests found
>MDSPARAMS< >MDSPARAMS1<
>RTAPPPRESL< >RTAPPPRESL<
>RTAPPSL< >RTAPPSL<
>RTAPPPOSTSL< >RTAPPPOSTSL<
>DATASTATES< >DATA<
>STATES<
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
% tunable waveforms MDSplus link via MDSObjWavegen instantiation % tunable waveforms MDSplus link via MDSObjWavegen instantiation
% single realtime thread, LinuxTimer synched at 1kHz % single realtime thread, LinuxTimer synched at 1kHz
% algorithms output MDSplus link via standard MDSWriter % algorithms output MDSplus link via standard MDSWriter
%
% it is assumend that a template algorithm decritpion object
% has already been siccessfully defined, inited and setup, via:
% obj=algo_template; obj.init; obj.setup;
%% Parameters %% Parameters
% source MDSplus shotnumber % source MDSplus shotnumber
...@@ -15,97 +19,71 @@ mdsdstshot=-1; ...@@ -15,97 +19,71 @@ mdsdstshot=-1;
% verbosity level % verbosity level
verbosity=2; verbosity=2;
% MDS writer period % MDS writer period
%mdsperiod=1;
mdsperiod=0.001; mdsperiod=0.001;
% MDSWriter segment length
mdsseglen=2000;
startpath=pwd; startpath=pwd;
fcnpath=fileparts(mfilename('fullpath')); fcnpath=fileparts(mfilename('fullpath'));
eval(sprintf('cd %s',fcnpath)); eval(sprintf('cd %s',fcnpath));
%% MDSParameters part generation %% MDSParameters stub
system('rm -rf mdsparameters.cfg'); fid=fopen('MDSPARAMS1.cfg','w');
diary mdsparameters.cfg obj.printMARTe2parconfig(-1,fid);
obj.printMARTe2parconfig(-1); fclose(fid);
diary off system('sed -i ''s/obj1.printMARTe2parconfig(-1);//g'' MDSPARAMS1.cfg');
system('sed -i ''s/obj.printMARTe2parconfig(-1);//g'' mdsparameters.cfg'); system('sed -i ''s/MDSParameters/MDSParamLoader1/g'' MDSPARAMS1.cfg');
system('sed -i ''s/MDSParameters/MDSParamLoader1/g'' mdsparameters.cfg');
%% MDSWavegen stub
%% MDSWavegen datasource part generation fid=fopen('MDSWAVEGEN1.cfg','w');
system('rm -rf mdswavegen.cfg'); wg1dim=obj.printMARTe2wgbusconfig(-1,'algo_template_inBus',1000,fid);
diary mdswavegen.cfg fclose(fid);
wg0dim=obj.printMARTe2wgbusconfig(-1,'algo_template_inBus',1000); system('sed -i ''s/obj.printMARTe2wgbusconfig(-1,''algo_template_inBus'',1000);//g'' MDSWAVEGEN1.cfg');
diary off system('sed -i ''s/MDSWavegen_algo_template_inBus_1/MDSWavegen_1/g'' MDSWAVEGEN1.cfg');
system('sed -i ''s/obj.printMARTe2wgbusconfig(-1,''algo_template_inBus'',1000);//g'' mdswavegen.cfg'); system('sed -i ''s/wavegen_algo_template_inBus_1/wavegen_1/g'' MDSWAVEGEN1.cfg');
system('sed -i ''s/MDSWavegen_algo_template_inBus_1/MDSWavegen_0/g'' mdswavegen.cfg');
system('sed -i ''s/wavegen_algo_template_inBus_1/wavegen_0/g'' mdswavegen.cfg'); %% Structured bus stubs
%% Input bus expansion algo_template_inbus =Simulink.data.evalinGlobal('algo_template','algo_template_inBus');
system('rm -rf inputbusexp.cfg'); inputbusflat =genbusstructstub('INPUTBUSSTRUCT1.cfg',algo_template_inbus,'input','DDB1');
inbus=Simulink.data.evalinGlobal('algo_template','algo_template_inBus');
diary inputbusexp.cfg algo_template_outbus=Simulink.data.evalinGlobal('algo_template','algo_template_outBus');
insignals=bus2marte2cfg(inbus,'input','DDB1'); outputbusflat=genbusstructstub('OUTPUTBUSSTRUCT1.cfg',algo_template_outbus,'output','DDB1');
diary off
system('sed -i ''s/bus2marte2cfg(inbus,''input'',''DDB1'');//g'' inputbusexp.cfg');
clear inbus
%% Output bus expansion
system('rm -rf outputbusexp.cfg');
outbus=Simulink.data.evalinGlobal('algo_template','algo_template_outBus');
diary outputbusexp.cfg
outsignals=bus2marte2cfg(outbus,'output','DDB1');
diary off
system('sed -i ''s/bus2marte2cfg(outbus,''output'',''DDB1'');//g'' outputbusexp.cfg');
clear outbus
%% Wavegen input stubs %% Wavegen input stubs
system('rm -rf wavegenbroker1.cfg');
diary wavegenbroker1.cfg genbusflatstub1('INPUTBUSFLAT1.cfg',inputbusflat,'DDB1')
for i=1:numel(insignals)
fprintf("%s = { DataSource = DDB1 Type = %s }\n", char(insignals{i}{1}),char(insignals{i}{2}));
end
diary off
%% StorageBroker output stubs %% StorageBroker output stubs
system('rm -rf storagebroker1.cfg');
diary storagebroker1.cfg genbusflatstub1('OUTPUTBUSFLAT1DDB1.cfg',outputbusflat,'DDB1')
for i=1:numel(outsignals) genbusflatstub1('OUTPUTBUSFLAT1MDS1.cfg',outputbusflat,'MDSWriter_1')
fprintf("%s = { DataSource = DDB1 Type = %s }\n", char(outsignals{i}{1}),char(outsignals{i}{2}));
end
diary off
system('rm -rf storagebroker2.cfg');
diary storagebroker2.cfg
for i=1:numel(outsignals)
fprintf("%s = { DataSource = MDSWriter_0 Type = %s }\n", char(outsignals{i}{1}),char(outsignals{i}{2}));
end
diary off
%% MDSWriter stubs %% MDSWriter stubs
system('rm -rf mdswriter1.cfg');
diary mdswriter1.cfg genbusflatstub2('OUTPUTBUSMDSWRITER1.cfg',outputbusflat,'template.outputs','MDSW1PERIOD','MDSW1SEGLEN');
for i=1:numel(outsignals)
fprintf("%s = { NodeName =""template.outputs.%s"" Period = MDSW0PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } \n", char(outsignals{i}{1}),char(outsignals{i}{5}));
end
diary off
%% cfg build %% cfg build
system('cp algo_template.cfgsrc algo_template.cfg'); system('cp algo_template.cfgsrc algo_template.cfg');
system('sed -i -e "/>MDSPARAMS</r mdsparameters.cfg" -e "/>MDSPARAMS</d" algo_template.cfg'); system('sed -i -e "/>MDSPARAMS1</r MDSPARAMS1.cfg" -e "/>MDSPARAMS1</d" algo_template.cfg');
system('sed -i -e "/>RTAPPPRESL</r rtapp-presl.cfgsrc" -e "/>RTAPPPRESL</d" algo_template.cfg'); system('sed -i -e "/>RTAPPPRESL</r rtapp-presl.cfgsrc" -e "/>RTAPPPRESL</d" algo_template.cfg');
system('sed -i -e "/>RTAPPSL</r rtapp-simulinkwrapper.cfgsrc" -e "/>RTAPPSL</d" algo_template.cfg'); system('sed -i -e "/>RTAPPSL</r rtapp-simulinkwrapper.cfgsrc" -e "/>RTAPPSL</d" algo_template.cfg');
system('sed -i -e "/>RTAPPPOSTSL</r rtapp-postsl.cfgsrc" -e "/>RTAPPPOSTSL</d" algo_template.cfg'); system('sed -i -e "/>RTAPPPOSTSL</r rtapp-postsl.cfgsrc" -e "/>RTAPPPOSTSL</d" algo_template.cfg');
system('sed -i -e "/>DATASTATES</r data_states.cfgsrc" -e "/>DATASTATES</d" algo_template.cfg'); system('sed -i -e "/>DATA</r data.cfgsrc" -e "/>DATA</d" algo_template.cfg');
system('sed -i -e "/>INPUTBUSFLAT</r wavegenbroker1.cfg" -e "/>INPUTBUSFLAT</d" algo_template.cfg'); system('sed -i -e "/>STATES</r states.cfgsrc" -e "/>STATES</d" algo_template.cfg');
system('sed -i -e "/>INPUTBUSSTRUCT</r inputbusexp.cfg" -e "/>INPUTBUSSTRUCT</d" algo_template.cfg'); system('sed -i -e "/>INPUTBUSFLAT1</r INPUTBUSFLAT1.cfg" -e "/>INPUTBUSFLAT1</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSSTRUCT</r outputbusexp.cfg" -e "/>OUTPUTBUSSTRUCT</d" algo_template.cfg'); system('sed -i -e "/>INPUTBUSSTRUCT1</r INPUTBUSSTRUCT1.cfg" -e "/>INPUTBUSSTRUCT1</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSFLAT</r storagebroker1.cfg" -e "/>OUTPUTBUSFLAT</d" algo_template.cfg'); system('sed -i -e "/>OUTPUTBUSSTRUCT1</r OUTPUTBUSSTRUCT1.cfg" -e "/>OUTPUTBUSSTRUCT1</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSFLATMDS</r storagebroker2.cfg" -e "/>OUTPUTBUSFLATMDS</d" algo_template.cfg'); system('sed -i -e "/>OUTPUTBUSFLAT1DDB1</r OUTPUTBUSFLAT1DDB1.cfg" -e "/>OUTPUTBUSFLAT1DDB1</d" algo_template.cfg');
system('sed -i -e "/>MDSWAVEGEN0</r mdswavegen.cfg" -e "/>MDSWAVEGEN0</d" algo_template.cfg'); system('sed -i -e "/>OUTPUTBUSFLAT1MDS1</r OUTPUTBUSFLAT1MDS1.cfg" -e "/>OUTPUTBUSFLAT1MDS1</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSMDSWRITER</r mdswriter1.cfg" -e "/>OUTPUTBUSMDSWRITER</d" algo_template.cfg'); system('sed -i -e "/>MDSWAVEGEN1</r MDSWAVEGEN1.cfg" -e "/>MDSWAVEGEN1</d" algo_template.cfg');
system(sprintf('sed -i "s/>WAVEGEN0_ELEMS</%d/g" algo_template.cfg',wg0dim)); system('sed -i -e "/>OUTPUTBUSMDSWRITER1</r OUTPUTBUSMDSWRITER1.cfg" -e "/>OUTPUTBUSMDSWRITER1</d" algo_template.cfg');
system(sprintf('sed -i "s/>WAVEGEN1_ELEMS</%d/g" algo_template.cfg',wg1dim));
%% cfg adapt %% cfg adapt
system(sprintf('sed -i "s/MDSSRCSHOT/%d/g" algo_template.cfg',mdssrcshot)); system(sprintf('sed -i "s/MDSSRCSHOT/%d/g" algo_template.cfg',mdssrcshot));
system(sprintf('sed -i "s/MDSDSTSHOT/%d/g" algo_template.cfg',mdsdstshot)); system(sprintf('sed -i "s/MDSDSTSHOT/%d/g" algo_template.cfg',mdsdstshot));
system(sprintf('sed -i "s/VERBOSITY/%d/g" algo_template.cfg',verbosity)); system(sprintf('sed -i "s/VERBOSITY/%d/g" algo_template.cfg',verbosity));
system(sprintf('sed -i "s/MDSW0PERIOD/%d/g" algo_template.cfg',mdsperiod)); system(sprintf('sed -i "s/MDSW1PERIOD/%d/g" algo_template.cfg',mdsperiod));
system(sprintf('sed -i "s/MDSW1SEGLEN/%d/g" algo_template.cfg',mdsseglen));
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
Time = { Type = uint32 } Time = { Type = uint32 }
} }
} }
>MDSWAVEGEN0< >MDSWAVEGEN1<
+MDSWriter_0 = { +MDSWriter_1 = {
Class = MDSWriter Class = MDSWriter
NumberOfBuffers = 2000 //Compulsory. Number of buffers in the circular buffer defined above. Each buffer is capable of holding a copy of all the DataSourceI signals. NumberOfBuffers = 10000 //Compulsory. Number of buffers in the circular buffer defined above. Each buffer is capable of holding a copy of all the DataSourceI signals.
CPUMask = 0x8 //Compulsory. Affinity assigned to the threads responsible for asynchronously flush data into the MDSplus database. CPUMask = 0x8 //Compulsory. Affinity assigned to the threads responsible for asynchronously flush data into the MDSplus database.
StackSize = 10000000 //Compulsory. Stack size of the thread above. StackSize = 10000000 //Compulsory. Stack size of the thread above.
TreeName = "scdds" //Compulsory. Name of the MDSplus tree. TreeName = "scdds" //Compulsory. Name of the MDSplus tree.
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
TimeSignalMultiplier = 1e-6 //Default = 1e-6. Multiplier to convert the time signal units into seconds, TimeSignalMultiplier = 1e-6 //Default = 1e-6. Multiplier to convert the time signal units into seconds,
} }
Thread1_Cycletime = { NodeName = "template.system.CH01" Period = MDSW0PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } Thread1_Cycletime = { NodeName = "template.system.CH01" Period = MDSW1PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = MDSW1SEGLEN SamplePhase = 0 }
GAMSimulink1_ReadTime = { NodeName = "template.system.CH02" Period = MDSW0PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } GAMSimulink1_ReadTime = { NodeName = "template.system.CH02" Period = MDSW1PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = MDSW1SEGLEN SamplePhase = 0 }
GAMSimulink1_ExecTime = { NodeName = "template.system.CH03" Period = MDSW0PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } GAMSimulink1_ExecTime = { NodeName = "template.system.CH03" Period = MDSW1PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = MDSW1SEGLEN SamplePhase = 0 }
GAMSimulink1_WriteTime = { NodeName = "template.system.CH04" Period = MDSW0PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } GAMSimulink1_WriteTime = { NodeName = "template.system.CH04" Period = MDSW1PERIOD AutomaticSegmentation = 0 MakeSegmentAfterNWrites = MDSW1SEGLEN SamplePhase = 0 }
>OUTPUTBUSMDSWRITER< >OUTPUTBUSMDSWRITER1<
} }
/* /*
+Messages = { //Optional. If set a message will be fired every time one of the events below occur +Messages = { //Optional. If set a message will be fired every time one of the events below occur
...@@ -73,31 +73,4 @@ ...@@ -73,31 +73,4 @@
*/ */
} }
} }
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
CPUs = 0x4
Functions = {
GAMTimer
TimeConversion
Constants
Wavegen0TimeBroker
Wavegen0DataBroker
GAMSimulink1
StorageBroker
//LoggerBroker
}
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
GAMSimulink1_ReadTime = { DataSource = Timings Type = uint32 } GAMSimulink1_ReadTime = { DataSource = Timings Type = uint32 }
GAMSimulink1_ExecTime = { DataSource = Timings Type = uint32 } GAMSimulink1_ExecTime = { DataSource = Timings Type = uint32 }
GAMSimulink1_WriteTime = { DataSource = Timings Type = uint32 } GAMSimulink1_WriteTime = { DataSource = Timings Type = uint32 }
>OUTPUTBUSFLAT< >OUTPUTBUSFLAT1DDB1<
} }
OutputSignals = { OutputSignals = {
Trigger = { DataSource = MDSWriter_0 Type = uint8 } Trigger = { DataSource = MDSWriter_1 Type = uint8 }
Time = { DataSource = MDSWriter_0 Type = uint32 } Time = { DataSource = MDSWriter_1 Type = uint32 }
Thread1_Cycletime = { DataSource = MDSWriter_0 Type = uint32 } Thread1_Cycletime = { DataSource = MDSWriter_1 Type = uint32 }
GAMSimulink1_ReadTime = { DataSource = MDSWriter_0 Type = uint32 } GAMSimulink1_ReadTime = { DataSource = MDSWriter_1 Type = uint32 }
GAMSimulink1_ExecTime = { DataSource = MDSWriter_0 Type = uint32 } GAMSimulink1_ExecTime = { DataSource = MDSWriter_1 Type = uint32 }
GAMSimulink1_WriteTime = { DataSource = MDSWriter_0 Type = uint32 } GAMSimulink1_WriteTime = { DataSource = MDSWriter_1 Type = uint32 }
>OUTPUTBUSFLATMDS< >OUTPUTBUSFLAT1MDS1<
} }
} }
} }
...@@ -29,22 +29,22 @@ $TestApp = { ...@@ -29,22 +29,22 @@ $TestApp = {
Trigger = { DataSource = DDB1 Type = uint8 NumberOfElements = 1 NumberOfDimensions=0 Default=1 } Trigger = { DataSource = DDB1 Type = uint8 NumberOfElements = 1 NumberOfDimensions=0 Default=1 }
} }
} }
+Wavegen0TimeBroker = { +Wavegen1TimeBroker = {
Class = IOGAM Class = IOGAM
InputSignals = { InputSignals = {
Time = { DataSource = DDB1 Type = uint32 } Time = { DataSource = DDB1 Type = uint32 }
} }
OutputSignals = { OutputSignals = {
time = { DataSource = MDSWavegen_0 Type = int32 } time = { DataSource = MDSWavegen_1 Type = int32 }
} }
} }
+Wavegen0DataBroker = { +Wavegen1DataBroker = {
Class = IOGAM Class = IOGAM
InputSignals = { InputSignals = {
wavegen_0 = { DataSource = MDSWavegen_0 Type = float32 NumberOfElements = >WAVEGEN0_ELEMS< } wavegen_1 = { DataSource = MDSWavegen_1 Type = float32 NumberOfElements = >WAVEGEN1_ELEMS< }
} }
OutputSignals = { OutputSignals = {
>INPUTBUSFLAT< >INPUTBUSFLAT1<
} }
} }
\ No newline at end of file
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
InputSignals = { InputSignals = {
realtime = { DataSource = DDB1 Type = float32 NumberOfElements = 1 NumberOfDimensions=0 Alias = TimeSec } realtime = { DataSource = DDB1 Type = float32 NumberOfElements = 1 NumberOfDimensions=0 Alias = TimeSec }
>INPUTBUSSTRUCT< >INPUTBUSSTRUCT1<
} }
OutputSignals = { OutputSignals = {
>OUTPUTBUSSTRUCT< >OUTPUTBUSSTRUCT1<
} }
/* /*
Parameters = { Parameters = {
......
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
CPUs = 0x4
Functions = {
GAMTimer
TimeConversion
Constants
Wavegen1TimeBroker
Wavegen1DataBroker
GAMSimulink1
StorageBroker
//LoggerBroker
}
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment