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

files for autocreating MARTe2 cfg file

parent 5c37f4ae
No related branches found
No related tags found
No related merge requests found
>MDSPARAMS<
>RTAPPPRESL<
>RTAPPSL<
>RTAPPPOSTSL<
>DATASTATES<
......@@ -7,29 +7,101 @@
% single realtime thread, LinuxTimer synched at 1kHz
% algorithms output MDSplus link via standard MDSWriter
%% Parameters
% source MDSplus shotnumber
mdssrcshot=-1;
% destination MDSplus shotnumber (-1 stands for increment current by 1)
mdsdstshot=2;
% verbosity level
verbosity=2;
startpath=pwd;
fcnpath=fileparts(mfilename('fullpath'));
eval(sprintf('cd %s',fcnpath));
%% Preclean
system('rm -rf mdsparameters.cfg');
system('rm -rf mdswavegen.cfg');
%% MDSParameters part generation
system('rm -rf mdsparameters.cfg');
diary mdsparameters.cfg
obj.printMARTe2parconfig(-1);
diary off
system('sed -i ''s/obj.printMARTe2parconfig(-1);//g'' mdsparameters.cfg');
system('sed -i ''s/MDSParameters/MDSParamLoader1/g'' mdsparameters.cfg');
%% MDSWavegen datasource part generation
system('rm -rf mdswavegen.cfg');
diary mdswavegen.cfg
obj.printMARTe2wgbusconfig(-1,'algo_template_inBus',1000);
wg0dim=obj.printMARTe2wgbusconfig(-1,'algo_template_inBus',1000);
diary off
system('sed -i ''s/obj.printMARTe2wgbusconfig(-1,''algo_template_inBus'',1000);//g'' mdswavegen.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');
%% Input bus expansion
system('rm -rf inputbusexp.cfg');
inbus=Simulink.data.evalinGlobal('algo_template','algo_template_inBus');
diary inputbusexp.cfg
insignals=bus2marte2cfg(inbus,'input','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
system('rm -rf wavegenbroker1.cfg');
diary wavegenbroker1.cfg
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
system('rm -rf storagebroker1.cfg');
diary storagebroker1.cfg
for i=1:numel(outsignals)
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
system('rm -rf mdswriter1.cfg');
diary mdswriter1.cfg
for i=1:numel(outsignals)
fprintf("%s = { NodeName =""template.outputs.%s"" Period = 1 AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 } \n", char(outsignals{i}{1}),char(outsignals{i}{5}));
end
diary off
%% cfg build
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 "/>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 "/>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 "/>INPUTBUSFLAT</r wavegenbroker1.cfg" -e "/>INPUTBUSFLAT</d" algo_template.cfg');
system('sed -i -e "/>INPUTBUSSTRUCT</r inputbusexp.cfg" -e "/>INPUTBUSSTRUCT</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSSTRUCT</r outputbusexp.cfg" -e "/>OUTPUTBUSSTRUCT</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSFLAT</r storagebroker1.cfg" -e "/>OUTPUTBUSFLAT</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSFLATMDS</r storagebroker2.cfg" -e "/>OUTPUTBUSFLATMDS</d" algo_template.cfg');
system('sed -i -e "/>MDSWAVEGEN0</r mdswavegen.cfg" -e "/>MDSWAVEGEN0</d" algo_template.cfg');
system('sed -i -e "/>OUTPUTBUSMDSWRITER</r mdswriter1.cfg" -e "/>OUTPUTBUSMDSWRITER</d" algo_template.cfg');
system(sprintf('sed -i "s/>WAVEGEN0_ELEMS</%d/g" algo_template.cfg',wg0dim));
%% cfg adapt
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/VERBOSITY/%d/g" algo_template.cfg',verbosity));
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+DDB1 = { Class = GAMDataSource }
+LoggerDataSource = { Class = LoggerDataSource }
+Timings = { Class = TimingDataSource }
+Timer = {
Class = LinuxTimer
SleepNature = "Busy" // Default | Busy
ExecutionMode = RealTimeThread // IndependentThread | RealTimeThread
CPUMask = 0x8 // IndependentThread CPU mask
Signals = {
Counter = { Type = uint32 }
Time = { Type = uint32 }
}
}
>MDSWAVEGEN0<
+MDSWriter_0 = {
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.
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.
TreeName = "scdds" //Compulsory. Name of the MDSplus tree.
PulseNumber = MDSDSTSHOT //Optional. If -1 a new pulse will be created and the MDSplus pulse number incremented.
StoreOnTrigger = 0 //Compulsory. If 0 all the data in the circular buffer is continuously stored. If 1 data is stored when the Trigger signal is 1 (see below).
EventName = "updatejScope" //Compulsory. Event sent to jScope when TimeRefresh seconds have elapsed.
TimeRefresh = 5 //Compulsory. An event with the name set in the property EventName is sent to jScope when TimeRefresh seconds have elapsed.
NumberOfPreTriggers = 0 //Compulsory iff StoreOnTrigger = 1. Number of cycles to store before the trigger.
NumberOfPostTriggers = 0 //Compulsory iff StoreOnTrigger = 1. Number of cycles to store after the trigger.
Signals = {
/*
Trigger = { //Compulsory when StoreOnTrigger = 1. Must be set in index 0 of the Signals node. When the value of this signal is 1 data will be stored.
Type = uint8 //Type must be uint8
}
Time = { //Compulsory when StoreOnTrigger = 1. Can be store in any index, but TimeSignal must be set = 1
Type = uint32 //Type must be uint32 or int32
TimeSignal = 1 //When set, this signal will be considered as the time source against which all signals will be stored.
TimeSignalMultiplier = 1e-9 //Default = 1e-6. Multiplier to convert the time signal units into seconds,
}
*/
Thread1_Cycletime = { NodeName = "ST.CH01" Period = 1 AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 }
GAMSimulink1_ReadTime = { NodeName = "ST.CH02" Period = 1 AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 }
GAMSimulink1_ExecTime = { NodeName = "ST.CH03" Period = 1 AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 }
GAMSimulink1_WriteTime = { NodeName = "ST.CH04" Period = 1 AutomaticSegmentation = 0 MakeSegmentAfterNWrites = 2000 SamplePhase = 0 }
>OUTPUTBUSMDSWRITER<
}
/*
+Messages = { //Optional. If set a message will be fired every time one of the events below occur
Class = ReferenceContainer
+TreeOpenedOK = { //Optional, but if set, the name of the Object shall be TreeOpenedOK. If set a message containing a ConfigurationDatabase with param1=PULSE_NUMBER will be sent to the Destination, every time the Tree is successfully opened
Class = Message
Destination = SomeObject
Function = SomeFunction
Mode = ExpectsReply
}
+TreeOpenedFail = { //Optional, but if set, the name of the Object shall be TreeOpenedFail. If set a message will be sent to the Destination, every time the Tree cannot be successfully opened
Class = Message
Destination = SomeObject
Function = SomeFunction
Mode = ExpectsReply
}
+TreeFlushed = { //Optional, but if set, the name of the Object shall be TreeFlushed. If set a message will be sent to the Destination, every time the Tree is flushed.
Class = Message
Destination = SomeObject
Function = SomeFunction
Mode = ExpectsReply
}
}
*/
}
}
+States = {
Class = ReferenceContainer
+State1 = {
Class = RealTimeState
+Threads = {
Class = ReferenceContainer
+Thread1 = {
Class = RealTimeThread
CPUs = 0x4
Functions = {
GAMTimer
Constants
Wavegen0TimeBroker
Wavegen0DataBroker
GAMSimulink1
StorageBroker
//LoggerBroker
}
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timings
}
}
+StorageBroker = {
Class = IOGAM
InputSignals = {
Thread1_CycleTime = { DataSource = Timings Type = uint32 Alias = State1.Thread1_CycleTime }
GAMSimulink1_ReadTime = { DataSource = Timings Type = uint32 }
GAMSimulink1_ExecTime = { DataSource = Timings Type = uint32 }
GAMSimulink1_WriteTime = { DataSource = Timings Type = uint32 }
>OUTPUTBUSFLAT<
}
OutputSignals = {
Thread1_Cycletime = { DataSource = MDSWriter_0 Type = uint32 }
GAMSimulink1_ReadTime = { DataSource = MDSWriter_0 Type = uint32 }
GAMSimulink1_ExecTime = { DataSource = MDSWriter_0 Type = uint32 }
GAMSimulink1_WriteTime = { DataSource = MDSWriter_0 Type = uint32 }
>OUTPUTBUSFLATMDS<
}
}
}
$TestApp = {
Class = RealTimeApplication
+Functions = {
Class = ReferenceContainer
+GAMTimer = {
Class = IOGAM
InputSignals = {
Counter = { DataSource = Timer Type = uint32 }
Time = { Frequency = 1000 DataSource = Timer Type = uint32 }
}
OutputSignals = {
Counter = { DataSource = DDB1 Type = uint32 }
Time = { DataSource = DDB1 Type = uint32 }
}
}
+Constants = {
Class = ConstantGAM
OutputSignals = {
zero = { DataSource = DDB1 Type = float32 NumberOfElements = 1 NumberOfDimensions=0 Default=0 }
}
}
+Wavegen0TimeBroker = {
Class = IOGAM
InputSignals = {
Time = { DataSource = DDB1 Type = uint32 }
}
OutputSignals = {
time = { DataSource = MDSWavegen_0 Type = int32 }
}
}
+Wavegen0DataBroker = {
Class = IOGAM
InputSignals = {
wavegen_0 = { DataSource = MDSWavegen_0 Type = float32 NumberOfElements = >WAVEGEN0_ELEMS< }
}
OutputSignals = {
>INPUTBUSFLAT<
}
}
\ No newline at end of file
+GAMSimulink1 = {
Class = SimulinkWrapperGAM
Library = "/root/algo_template.so"
SymbolPrefix = "algo_template"
Verbosity = VERBOSITY
SkipInvalidTunableParams = 0
TunableParamExternalSource= "MDSParamLoader1"
//NonVirtualBusMode = "ByteArray" // NOTE: homogeneus buses are not handled correctly, wrong
// handling of NumberOfElements = 1
NonVirtualBusMode = "Structured"
InputSignals = {
realtime = { DataSource = DDB1 Type = float32 NumberOfElements = 1 NumberOfDimensions=0 Alias = wavegen_0 }
>INPUTBUSSTRUCT<
}
OutputSignals = {
>OUTPUTBUSSTRUCT<
}
/*
Parameters = {
k1 = (float32) 2.5
}
*/
}
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