Ejemplo n.º 1
0
    void ParseLog(string inFilename, string outFilename)
    {
        string header = "Attack ID," +
                        "Joystick Type (1 = Conventional)," +
                        "Input Gesture ID," +
                        "Times Done this Input Gesture ID," +
                        "Target Gesture ID," +
                        "Success," +
                        "Time Spent," +
                        "Total Distance," +
                        "Total Area";

        XmlDocument doc = new XmlDocument();

        doc.PreserveWhitespace = true;

        try { doc.Load(inFilename); }
        catch
        {
            Console.WriteLine("File not found!");
        }

        XmlNode     root = doc.DocumentElement;
        XmlNodeList dataItems;
        XmlNodeList positionDataItems;

        dataItems         = root["LogDataItems"].ChildNodes;
        positionDataItems = root["inputBufferTouchLogs"].SelectNodes("InputBufferTouchLog");

        using (StreamWriter sw = new StreamWriter(outFilename))
        {
            List <InputPositionLog> positionLogs = new List <InputPositionLog>();
            foreach (XmlNode childNode in positionDataItems)
            {
                InputPositionLog ipl = GetInputPositionLog(childNode);
                if (ipl.timestamp > 0)
                {
                    positionLogs.Add(ipl);
                }
            }

            InputPositionLog[] touchPositionLogs = positionLogs.ToArray();

            sw.WriteLine(header);
            foreach (XmlNode childNode in dataItems)
            {
                ParseNode(childNode, sw, touchPositionLogs);
            }

            WriteResult(sw);
        }
    }
Ejemplo n.º 2
0
    static InputPositionLog GetInputPositionLog(XmlNode currentNode)
    {
        InputPositionLog result = new InputPositionLog();

        //Console.Write(currentNode.Name + ", ");
        XmlNode timeStampNode = currentNode["globalTimestamp"];

        if (timeStampNode == null)
        {
            Console.WriteLine("timestamp node was null");
            result.timestamp = -1;
            return(result);
        }

        //Console.WriteLine(currentNode.Name);

        result.timestamp = Convert.ToSingle(timeStampNode.InnerText, usCulture);
        result.inputID   = Convert.ToInt32(currentNode["inputID"].InnerText);

        Vector2     pos       = new Vector2();
        XmlNodeList positions = currentNode["touchPositions"].ChildNodes;

        foreach (XmlNode childNode in positions)
        {
            XmlNode x = childNode["x"];
            XmlNode y = childNode["y"];
            if (x != null && y != null)
            {
                float posX = Convert.ToSingle(x.InnerText, usCulture);
                float posY = Convert.ToSingle(y.InnerText, usCulture);

                if (posX > 1000 || posY > 1000)
                {
                    continue;
                }

                pos.x = posX;
                pos.y = posY;
            }
        }

        result.joystickFingerPos = pos;

        return(result);
    }
Ejemplo n.º 3
0
    public static void Main(string[] args)
    {
        string outFilename = "";
        string header      = "Attack ID," +
                             "Joystick Type (1 = Conventional)," +
                             "Input Gesture ID," +
                             "Times Done this Input Gesture ID," +
                             "Target Gesture ID," +
                             "Success," +
                             "Time Spent," +
                             "Total Distance," +
                             "Total Area";

        XmlDocument doc = new XmlDocument();

        doc.PreserveWhitespace = true;

        if (args.Length < 1)
        {
            Console.WriteLine("Usage: log_parser.exe UserLog*.xml [UserLog*.csv]");
        }
        else if (args.Length < 2)
        {
            outFilename = Path.GetFileNameWithoutExtension(args[0]) + ".csv";
            Console.WriteLine("Writing to default filename " + outFilename);
        }
        else
        {
            outFilename = args[1];
        }

        try { doc.Load(args[0]); }
        catch
        {
            Console.WriteLine("File not found!");
        }

        XmlNode     root = doc.DocumentElement;
        XmlNodeList dataItems;
        XmlNodeList positionDataItems;

        LogParser parser = new LogParser();

        dataItems         = root["LogDataItems"].ChildNodes;
        positionDataItems = root["inputBufferTouchLogs"].SelectNodes("InputBufferTouchLog");

        using (StreamWriter sw = new StreamWriter(outFilename))
        {
            List <InputPositionLog> positionLogs = new List <InputPositionLog>();
            Console.WriteLine("xml count: " + positionDataItems.Count);
            foreach (XmlNode childNode in positionDataItems)
            {
                InputPositionLog ipl = GetInputPositionLog(childNode);
                if (ipl.timestamp > 0)
                {
                    positionLogs.Add(ipl);
                }
            }

            Console.WriteLine("COUNT:" + positionLogs.Count);

            InputPositionLog[] touchPositionLogs = positionLogs.ToArray();

            sw.WriteLine(header);
            foreach (XmlNode childNode in dataItems)
            {
                parser.Parse(childNode, sw, touchPositionLogs);
            }

            parser.WriteResults(sw);
        }
    }