示例#1
0
        private void GenerateDataMapFiles(CodeGeneratorContext context)
        {
            using (TextWriter
                   __H = File.CreateText(context.Settings.OutputPath + "\\DataMap.h"),
                   __CPP = File.CreateText(context.Settings.OutputPath + "\\DataMap.cpp"))
            {
                __H.WriteLine("#ifndef _DATAMAP_H_");
                __H.WriteLine("#define _DATAMAP_H_");
                __H.WriteLine();
                __H.WriteLine("#include <arduino.h> ");
                __H.WriteLine("#include <EEPROM.h> ");
                __H.WriteLine("#include \"Config.h\" ");
                __H.WriteLine("#include \"LCD.h\" ");
                __H.WriteLine("#include \"Def.h\" ");
                __H.WriteLine("#include \"Joystick.h\" ");
                __H.WriteLine("#include \"XBeeWriter.h\"");
                __H.WriteLine("#include \"ppmGen.h\" ");
                __H.WriteLine("#include \"SerialCommander.h\" ");
                __H.WriteLine();
                __H.WriteLine("extern uint16_t ppm_data[];");
                __H.WriteLine("extern axis_t CalcData[];");


                __CPP.WriteLine("#include \"DataMap.h\" ");
                __CPP.WriteLine();

                JoyInfo.GenerateDataMap(__H, __CPP);
                Settings.GenerateDataMap(__H, __CPP);

                foreach (var panel in Panels)
                {
                    panel.GenerateDataMap(context, __H, __CPP);
                }

                __CPP.WriteLine("uint16_t ppm_data[PPM_CHANNELS];");
                __CPP.WriteLine("axis_t CalcData[DATA_LENGTH];");
                __CPP.WriteLine();
                __CPP.WriteLine("void InitData()");
                __CPP.WriteLine("{");

                foreach (var panel in Panels)
                {
                    panel.GenerateInit(context, __CPP);
                }

                __CPP.WriteLine("}");
                __CPP.WriteLine();



                __CPP.WriteLine("void Calculate()");
                __CPP.WriteLine("{");
                __CPP.WriteLine("axis_t p0, p1, p2;");

                Settings.GeneratePreCalculator(__CPP);
                JoyInfo.GenerateCalculator(__CPP);

                foreach (var panel in Panels)
                {
                    panel.GeneratePreCalculator(context, __CPP);
                }

                foreach (var panel in Panels)
                {
                    panel.GenerateCalculator(context, __CPP);
                }

                Settings.GeneratePostCalculator(__CPP);

                __CPP.WriteLine("}");

                __H.WriteLine("extern void InitData();");
                __H.WriteLine("extern void Calculate();");

                __H.WriteLine("#endif");
            }
        }