Ti自带的usecase生成工具里有很多link,以满足大部分的需求,但有时候与实际项目还是有一定出入的,这就需要我们修改工具软件和Ti的软件框架,本篇只讲工具软件的修改,软件框架links_fw的修改留在下一篇讲。
Ti提供的usecase生成工具是开源的,非常方便修改,其路径在/vision_sdk/apps/tools/vision_sdk_usecase_gen。修改方法Ti也提供了参考文档,文档名为VisionSDK_UserGuide_UsecaseGen.pdf,在第四章讲了如果修改。下面结合文档中的步骤和我自己的修改内容,把步骤走一遍。
1. In link.h create new class in following format:
class LinkName: public Link {
~LinkName ();
public:
LinkName(string nm);
void genIncludes(ostream &fp);
void genLinkID(ostream &fp);
void genCreatePrms(ostream &fp);
void genResetLinkPrms(ostream &fp, string obj);
void genSetLinkPrms(ostream &fp, string obj);
int setInLink(Link* obj);
int setOutLink(Link* obj);
};
在link.h文件的最后添加了如下代码,我要新建的link是readfile
/*********************jshb20190107**********************************/
class Readfile: public Link {
~Readfile();
public:
Readfile(string nm);
void genIncludes(ostream &fp);
void genLinkID(ostream &fp);
void genCreatePrms(ostream &fp);
void genResetLinkPrms(ostream &fp, string obj);
void genSetLinkPrms(ostream &fp, string obj);
int setInLink(Link* obj); //returns QueueID
int setOutLink(Link* obj); //return QueueID
};
2. In processor.h, introduce extra enum in ClassType, cLinkName
在枚举ClassType中ClassCount的上面添加如下项
cReadfile,//jshb20190107
3. Implement the functions in link.cpp file
在link.cpp文件的最后添加
/*********************************jshb***********************************************/
Readfile::Readfile(string nm) {
cType = cReadfile;
name = nm;
linkIDName = name + string("LinkID");
prmName = name + string("Prm");
execPos = -1;
procID = -1;
pType = IPU1_0;
mulInQue = false;
mulOutQue = false;
}
Readfile::~Readfile() {
}
void Readfile::genIncludes(ostream &fp) {
CHECK_ERROR_ABORT(inLink.size() == 0, "Error: Link ["+name+"] must have NO incoming link !!!");
// CHECK_ERROR_ABORT(outLink.size() == 0, "Error: Link ["+name+"] must have NO outgoing link !!!");
fp << "#include <include/link_api/readfileLink.h>"<< endl;
}
void Readfile::genLinkID(ostream &fp) {
fp << BLOCK_SPACE << setw(IDTYPE_WIDTH) << left << "UInt32" << linkIDName << ";" << endl;
}
void Readfile::genCreatePrms(ostream &fp)
{
fp << BLOCK_SPACE << setw(TYPENAME_WIDTH) << left << "ReadfileLink_CreateParams"
<< prmName << ";" << endl;
}
void Readfile::genResetLinkPrms(ostream &fp, string obj)
{
fp << BLOCK_SPACE << "ReadfileLink_CreateParams_Init(&" << obj << "->"
<< prmName << ");" << endl;
}
int Readfile::setInLink(Link* obj) {
CHECK_ERROR_ABORT(SHOULD_NOT_REACH, "Error: Link ["+name+"] must have NO incoming link !!!");
return -1;
}
int Readfile::setOutLink(Link* obj) {
outLink.push_back(make_pair(obj, -1));
return (outLink.size() - 1);
}
void Readfile::genSetLinkPrms(ostream &fp, string obj)
{
}
4. In processor.cpp getLinkID function, introduce an extra case in switch. Replace ID with LinkID
which needs to be assigned. Other switch cases serve as an example.
case cDecode:
linkIDName = ID;
linkIDAsgn[cType]++;
break;
在函数string Processor::getLinkID(ProcType pType, ClassType cType, int procID, string name)中添加
case cReadfile:
linkIDName = pName + string("_LINK (SYSTEM_LINK_ID_READFILE)");
linkIDAsgn[cType]++;
break;
5. In usecase.cpp in createNewObj function, include a new condition. Where “NewLinkBase” is the
base name and NewLink is the class created.
else if (root == "NewLinkBase")
Page 9 of 9
obj = new NewLink(name);
在函数Link* Usecase::createObject(string name)中添加
else if (root == "Readfile")
obj = new Readfile(name);
6. In options.cpp in process_Options function, add a new text string for the newly added link. Where
“NewLinkBase” is the new link that is added
string usage =
…
" Supported Links: \n"
…
“ NewLinkBase\n”
在函数int Options::process_Options(int argc, char * argv[])的字符串usage中添加
" Readfile\n"
至此修改完成,make 就可以生成新的vsdk_linux.out,编译如果提示非语法的报错,应该就是依赖库没有安装,按照提示安装好依赖库就可以了。