mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Patch from Kenn to speed up matlab parsing by preallocating arrays
This commit is contained in:
parent
b56c11d1d9
commit
99201d152a
@ -3,6 +3,17 @@ function [] = OPLogConvert(logfile)
|
||||
% THIS FILE IS AUTOMATICALLY GENERATED.
|
||||
$(ALLOCATIONCODE)
|
||||
|
||||
if nargin==0
|
||||
%%
|
||||
if (exist('uigetfile'))
|
||||
[FileName, PathName]=uigetfile;
|
||||
logfile=fullfile(PathName, FileName);
|
||||
|
||||
else
|
||||
error('Your technical computing program does not support file choosers. Please input the file name in the argument. ')
|
||||
end
|
||||
end
|
||||
|
||||
fid = fopen(logfile);
|
||||
|
||||
% Parse log file, entry by entry
|
||||
@ -46,6 +57,9 @@ end
|
||||
%% Clean Up and Save mat file
|
||||
fclose(fid);
|
||||
|
||||
% Trim output structs
|
||||
$(CLEANUPCODE)
|
||||
|
||||
matfile = strrep(logfile,'opl','mat');
|
||||
save(matfile $(SAVEOBJECTSCODE));
|
||||
|
||||
|
@ -51,6 +51,7 @@ bool UAVObjectGeneratorMatlab::generate(UAVObjectParser* parser,QString template
|
||||
|
||||
matlabCodeTemplate.replace( QString("$(ALLOCATIONCODE)"), matlabAllocationCode);
|
||||
matlabCodeTemplate.replace( QString("$(SWITCHCODE)"), matlabSwitchCode);
|
||||
matlabCodeTemplate.replace( QString("$(CLEANUPCODE)"), matlabCleanupCode);
|
||||
matlabCodeTemplate.replace( QString("$(SAVEOBJECTSCODE)"), matlabSaveObjectsCode);
|
||||
matlabCodeTemplate.replace( QString("$(FUNCTIONSCODE)"), matlabFunctionsCode);
|
||||
|
||||
@ -127,7 +128,17 @@ bool UAVObjectGeneratorMatlab::process_object(ObjectInfo* info)
|
||||
matlabSwitchCode.append("\t\tcase " + objectTableName.toUpper() + "_OBJID\n");
|
||||
matlabSwitchCode.append("\t\t\t" + objectTableName + "(" + tableIdxName +") = " + functionCall + ";\n");
|
||||
matlabSwitchCode.append("\t\t\t" + tableIdxName + " = " + tableIdxName +" + 1;\n");
|
||||
|
||||
matlabSwitchCode.append("\t\t\tif " + tableIdxName + " > length(" + objectTableName +")\n");
|
||||
matlabSwitchCode.append("\t\t\t\t" + objectTableName + "(" + tableIdxName + "+100+1) = " + objectTableName +"(end);\n");
|
||||
matlabSwitchCode.append("\t\t\t\t" + objectTableName +"(end)=[];\n");
|
||||
matlabSwitchCode.append("\t\t\tend\n");
|
||||
|
||||
|
||||
//=============================================================//
|
||||
// Generate 'Cleanup:' code (will replace the $(CLEANUP) tag) //
|
||||
//=============================================================//
|
||||
matlabCleanupCode.append(objectTableName + "(" + tableIdxName +":end) = [];\n");
|
||||
|
||||
|
||||
//=============================================================================//
|
||||
// Generate objects saving code code (will replace the $(SAVEOBJECTSCODE) tag) //
|
||||
|
@ -38,6 +38,7 @@ private:
|
||||
bool process_object(ObjectInfo* info);
|
||||
QString matlabAllocationCode;
|
||||
QString matlabSwitchCode;
|
||||
QString matlabCleanupCode;
|
||||
QString matlabSaveObjectsCode;
|
||||
QString matlabFunctionsCode;
|
||||
QStringList fieldTypeStrMatlab;
|
||||
|
Loading…
x
Reference in New Issue
Block a user