public GeneratePTypes ( |
||
mavlink | ||
outputFile | string | |
리턴 | void |
static void Main(string[] args) { string xmlInput = null; string outputFolder = null; if (args.Length == 0) { Console.WriteLine("USAGE: -xml:<pathToXML> -out:<pathToOutDir>"); return; } for (int i = 0; i < args.Length; i++) { string arg = args[i]; string colonArg = null; if (arg.StartsWith("/") || arg.StartsWith("-")) { var colonIndex = arg.IndexOf(':'); if (colonIndex >= 0) { arg = args[i].Substring(1, colonIndex - 1); colonArg = args[i].Substring(colonIndex + 1); } switch (arg) { case "xml": xmlInput = colonArg; break; case "out": outputFolder = colonArg; break; default: Console.WriteLine("USAGE: -xml:<pathToXML> -out:<pathToOutDir>"); return; } } } if (!File.Exists(xmlInput)) { Console.WriteLine("File not found: {0}", xmlInput); return; } if (!Directory.Exists(outputFolder)) { Console.WriteLine("Output directory not found: {0}", outputFolder); return; } string pTypeFileName = String.Format("\\P_{0}_MessageTypes.p", Path.GetFileNameWithoutExtension(xmlInput)); string pTypeFunctionsFileName = String.Format("\\P_{0}_MessageTypeFunctions.h", Path.GetFileNameWithoutExtension(xmlInput)); string pEnumsFileName = String.Format("\\P_{0}_Enums.p", Path.GetFileNameWithoutExtension(xmlInput)); //parse the XML var parser = new MavXMLParser(); MavLink mavlink = parser.Parse(xmlInput); //generate the P type for each message var generator = new PCodeGenerator(); generator.GeneratePTypes(mavlink, outputFolder + pTypeFileName); generator.GeneratePEnums(mavlink, outputFolder + pEnumsFileName, outputFolder); //generate the two functions for encoding and decoding P Message types generator.GeneratePTypeHelperFun(mavlink.messages, outputFolder + pTypeFunctionsFileName); }
static void Main(string[] args) { string xmlInput = null; string outputFolder = null; if (args.Length == 0) { Console.WriteLine("USAGE: -xml:<pathToXML> -out:<pathToOutDir>"); return; } for (int i = 0; i < args.Length; i++) { string arg = args[i]; string colonArg = null; if (arg.StartsWith("/") || arg.StartsWith("-")) { var colonIndex = arg.IndexOf(':'); if (colonIndex >= 0) { arg = args[i].Substring(1, colonIndex - 1); colonArg = args[i].Substring(colonIndex + 1); } switch (arg) { case "xml": xmlInput = colonArg; break; case "out": outputFolder = colonArg; break; default: Console.WriteLine("USAGE: -xml:<pathToXML> -out:<pathToOutDir>"); return; } } } if (!File.Exists(xmlInput)) { Console.WriteLine("File not found: {0}", xmlInput); return; } if (!Directory.Exists(outputFolder)) { Console.WriteLine("Output directory not found: {0}", outputFolder); return; } string pTypeFileName = String.Format("\\P_{0}_MessageTypes.p", Path.GetFileNameWithoutExtension(xmlInput)); string pTypeFunctionsFileName = String.Format("\\P_{0}_MessageTypeFunctions.h", Path.GetFileNameWithoutExtension(xmlInput)); string pEnumsFileName = String.Format("\\P_{0}_Enums.p", Path.GetFileNameWithoutExtension(xmlInput)); //parse the XML var parser = new MavXMLParser(); MavLink mavlink = parser.Parse(xmlInput); //generate the P type for each message var generator = new PCodeGenerator(); generator.GeneratePTypes(mavlink, outputFolder + pTypeFileName); generator.GeneratePEnums(mavlink, outputFolder + pEnumsFileName, outputFolder); //generate the two functions for encoding and decoding P Message types generator.GeneratePTypeHelperFun(mavlink.messages, outputFolder + pTypeFunctionsFileName); }