public static void CodeGenTest() { //打开控制台 AllocConsole(); MHalCodeGen mpmGen = new MHalCodeGen("MPM"); mpmGen.AddEMHalPublishRes("EMHalPPCResource"); mpmGen.AddEMHalSubscribeRes("EMHalZynqResource0"); mpmGen.AddEMHalSubscribeRes("EMHalZynqResource1"); mpmGen.GenEMHalCode(); mpmGen.AddRMHalPublishRes("RMHalPPCResource", 0x10000, 4); mpmGen.AddRMHalSubscribeRes("RMHalFpgaResource0"); mpmGen.AddRMHalSubscribeRes("RMHalFpgaResource1"); mpmGen.GenRMHalPpcCode(true); MHalCodeGen smpaGen = new MHalCodeGen("SMPA"); smpaGen.AddEMHalPublishRes("EMHalZynqResource0"); smpaGen.AddEMHalSubscribeRes("EMHalPPCResource"); smpaGen.GenEMHalCode(); smpaGen.AddRMHalPublishRes("RMHalFpgaResource0", 0x10000, 4); smpaGen.AddRMHalSubscribeRes("RMHalPPCResource"); smpaGen.GenRMHalFpgaCode(); smpaGen.GenLMHalFpgaCode(); smpaGen.GenAMHalFpgaCode(); MHalCodeGen smpbGen = new MHalCodeGen("SMPB"); smpbGen.AddEMHalPublishRes("EMHalZynqResource1"); smpbGen.AddEMHalSubscribeRes("EMHalPPCResource"); smpbGen.GenEMHalCode(); smpbGen.AddRMHalPublishRes("RMHalFpgaResource1", 0x10000, 4); smpbGen.AddRMHalSubscribeRes("RMHalPPCResource"); smpbGen.GenRMHalFpgaCode(); smpbGen.GenLMHalFpgaCode(); smpbGen.GenAMHalFpgaCode(); FreeConsole(); }
/// <summary> /// 形成资源文件 /// </summary> private void GenerateSourceFile() { string cmpName = this._typeTB.Text; //构件名称 MainForm.SetOutPutText(string.Format("生成构件({0})相关节点资源文件!", cmpName)); try { foreach (var node in _nodeArray) { string nodeName = node.Name; //EtherNet资源 if (node.EthPbSources.Count > 0 || node.EthSubSources.Count > 0) { MHalCodeGen egen = new MHalCodeGen(string.Format("{0}_{1}_Emhal", cmpName, nodeName)); foreach (var eSource in node.EthPbSources) { egen.AddEMHalPublishRes(eSource.SourceName); } foreach (var eSource in node.EthSubSources) { egen.AddEMHalSubscribeRes(eSource.SourceName); } egen.GenEMHalCode(); MainForm.SetOutPutText(string.Format("生成资源文件:{0}_{1}_Emhal", cmpName, nodeName)); } //RapidIO资源 if (node.RioPbSources.Count > 0 || node.RioSubSources.Count > 0) { MHalCodeGen rgen = new MHalCodeGen(string.Format("{0}_{1}_Rmhal", cmpName, nodeName)); foreach (var rSource in node.RioPbSources) { rgen.AddRMHalPublishRes(rSource.SourceName, (uint)rSource.PackMaxLen, (uint)rSource.BufSize); } foreach (var rSource in node.RioSubSources) { rgen.AddRMHalSubscribeRes(rSource.SourceName); } rgen.GenRMHalPpcCode(false); MainForm.SetOutPutText(string.Format("生成资源文件:{0}_{1}_Rmhal", cmpName, nodeName)); } } } catch (Exception e) { MessageBox.Show("GenerateSourceFile" + e.Message); } }