コード例 #1
0
ファイル: ScpUtil.cs プロジェクト: zw5/WiinUPro
        public Boolean Save()
        {
            Boolean Saved = true;

            try
            {
                XmlNode Node;

                m_Doc.RemoveAll();

                Node = m_Doc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
                m_Doc.AppendChild(Node);

                Node = m_Doc.CreateComment(String.Format(" ScpControl Configuration Data. {0} ", DateTime.Now));
                m_Doc.AppendChild(Node);

                Node = m_Doc.CreateWhitespace("\r\n");
                m_Doc.AppendChild(Node);

                Node = m_Doc.CreateNode(XmlNodeType.Element, "ScpControl", null);
                {
                    CreateTextNode(Node, "Idle", Idle.ToString());

                    CreateTextNode(Node, "LX", LX.ToString());
                    CreateTextNode(Node, "LY", LY.ToString());
                    CreateTextNode(Node, "RX", RX.ToString());
                    CreateTextNode(Node, "RY", RY.ToString());

                    CreateTextNode(Node, "LED", LED.ToString());
                    CreateTextNode(Node, "Rumble", Rumble.ToString());
                    CreateTextNode(Node, "Triggers", Triggers.ToString());

                    CreateTextNode(Node, "Latency", Latency.ToString());
                    CreateTextNode(Node, "DeadL", DeadL.ToString());
                    CreateTextNode(Node, "DeadR", DeadR.ToString());

                    CreateTextNode(Node, "Native", Native.ToString());
                    CreateTextNode(Node, "SSP", SSP.ToString());

                    CreateTextNode(Node, "Brightness", Brightness.ToString());
                    CreateTextNode(Node, "Bus", Bus.ToString());
                    CreateTextNode(Node, "Force", Repair.ToString());
                }
                m_Doc.AppendChild(Node);

                m_Doc.Save(m_File);
            }
            catch { Saved = false; }

            return(Saved);
        }
コード例 #2
0
        static void vJoyDataPack(float ROLL, float PITCH, float YAW, float THROTTLE, Frame thisFrame, Form1 sender)
        {
            //Display raw values
            sender.rollTXT.Text   = ROLL.ToString();
            sender.pitchTXT.Text  = PITCH.ToString();
            sender.yawTXT.Text    = YAW.ToString();
            sender.heightTXT.Text = THROTTLE.ToString();


            //Display raw values
            sender.rollJOY.Text   = RX.ToString();
            sender.pitchJOY.Text  = RY.ToString();
            sender.yawJOY.Text    = X.ToString();
            sender.heightJOY.Text = Y.ToString();

            sender.yawProg.Value    = (int)X;
            sender.rollProg.Value   = (int)RX;
            sender.pitchProg.Value  = (int)RY;
            sender.heightProg.Value = (int)Y;

            HandValue thisHand = new HandValue();

            thisHand.Roll      = RX;
            thisHand.Pitch     = RY;
            thisHand.Yaw       = X;
            thisHand.Height    = Y;
            thisHand.Timestamp = thisFrame.Timestamp;

            myLog.LogHand(thisHand);

            if (sender.chartCheckBox.Checked)
            {
                if ((thisFrame.Id % 3) == 0)
                {
                    myCircularBuff.Add(thisHand);
                }
            }
        }
コード例 #3
0
        static void serialCommData_pack(float ROLL, float PITCH, float YAW, float THROTTLE, Frame thisFrame, Form1 sender)
        {
            if (sender.serialPort1.IsOpen)
            {
                //Display raw values
                sender.rollTXT.Text   = ROLL.ToString();
                sender.pitchTXT.Text  = PITCH.ToString();
                sender.yawTXT.Text    = YAW.ToString();
                sender.heightTXT.Text = THROTTLE.ToString();

                //Display raw values
                sender.rollJOY.Text   = RX.ToString();
                sender.pitchJOY.Text  = RY.ToString();
                sender.yawJOY.Text    = X.ToString();
                sender.heightJOY.Text = Y.ToString();

                sender.yawProg.Value    = (int)X;
                sender.rollProg.Value   = (int)RX;
                sender.pitchProg.Value  = (int)RY;
                sender.heightProg.Value = (int)Y;

                HandValue thisHand = new HandValue();
                thisHand.Roll      = RX;
                thisHand.Pitch     = RY;
                thisHand.Yaw       = X;
                thisHand.Height    = Y;
                thisHand.Timestamp = thisFrame.Timestamp;

                if (ball_motion)
                {
                    int Roll_to_send  = (int)(((float)(RX >> 7)) / 1.422f);
                    int Pitch_to_send = (int)(((float)(RY >> 7)) / 1.422f);
                    dataOUT[0]  = (byte)'$';
                    dataOUT[1]  = (byte)'Y';
                    dataOUT[2]  = (byte)(((Roll_to_send % 1000) / 100) + 48);
                    dataOUT[3]  = (byte)(((Roll_to_send % 100) / 10) + 48);
                    dataOUT[4]  = (byte)((Roll_to_send % 10) + 48);
                    dataOUT[5]  = (byte)'#';
                    dataOUT[6]  = (byte)'$';
                    dataOUT[7]  = (byte)'X';
                    dataOUT[8]  = (byte)(((Pitch_to_send % 1000) / 100) + 48);
                    dataOUT[9]  = (byte)(((Pitch_to_send % 100) / 10) + 48);
                    dataOUT[10] = (byte)((Pitch_to_send % 10) + 48);
                    dataOUT[11] = (byte)'#';
                }
                else
                {
                    //scrittura nella seriale
                    dataOUT[0] = (byte)'$';
                    dataOUT[1] = 85;

                    uint Roll_to_send   = (uint)((float)((uint)RX >> 5) / 1.28f); // CH1
                    uint Pitch_to_send  = (uint)((float)((uint)RY >> 5) / 1.28f);
                    uint Height_to_send = (uint)((float)((uint)Y >> 5) / 1.28f);
                    uint Yaw_to_send    = (uint)((float)((uint)X >> 5) / 1.28f);
                    uint arm_disarm     = 800;
                    uint Air_mode       = 0;
                    uint Flight_mode    = (uint)sender.FlightMode;
                    uint CH8            = 0;

                    if (AirMode)
                    {
                        Air_mode = 800;
                    }
                    else
                    {
                        Air_mode = 0;
                    }


                    if (run)
                    {
                        arm_disarm = 0;     // armed
                    }
                    else
                    {
                        arm_disarm = 800;   // disarmed
                    }

                    dataOUT[2]  = (byte)(Roll_to_send >> 2);
                    dataOUT[3]  = (byte)((Roll_to_send << 6) | (Pitch_to_send >> 4));
                    dataOUT[4]  = (byte)((Pitch_to_send << 4) | (Height_to_send >> 6));
                    dataOUT[5]  = (byte)((Height_to_send << 2) | (Yaw_to_send >> 8));
                    dataOUT[6]  = (byte)(Yaw_to_send);
                    dataOUT[7]  = (byte)(arm_disarm >> 2);
                    dataOUT[8]  = (byte)((arm_disarm << 6) | (Air_mode >> 4));
                    dataOUT[9]  = (byte)((Air_mode << 4) | (Flight_mode >> 6));
                    dataOUT[10] = (byte)((Flight_mode << 2) | (CH8 >> 8));
                    dataOUT[11] = (byte)(CH8);
                    dataOUT[12] = (byte)'#';
                }
            }
        }
コード例 #4
0
        public Boolean Save()
        {
            Boolean Saved = true;

            try
            {
                XmlNode Node, Entry;

                m_Xdoc.RemoveAll();

                Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
                m_Xdoc.AppendChild(Node);

                Node = m_Xdoc.CreateComment(String.Format(" ScpControl Configuration Data. {0} ", DateTime.Now));
                m_Xdoc.AppendChild(Node);

                Node = m_Xdoc.CreateWhitespace("\r\n");
                m_Xdoc.AppendChild(Node);

                Node = m_Xdoc.CreateNode(XmlNodeType.Element, "ScpControl", null);

                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "Idle", null); Entry.InnerText = Idle.ToString(); Node.AppendChild(Entry);

                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "LX", null); Entry.InnerText = LX.ToString(); Node.AppendChild(Entry);
                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "LY", null); Entry.InnerText = LY.ToString(); Node.AppendChild(Entry);
                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "RX", null); Entry.InnerText = RX.ToString(); Node.AppendChild(Entry);
                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "RY", null); Entry.InnerText = RY.ToString(); Node.AppendChild(Entry);

                Entry = m_Xdoc.CreateNode(XmlNodeType.Element, "LED", null); Entry.InnerText = LED.ToString(); Node.AppendChild(Entry);

                m_Xdoc.AppendChild(Node);

                m_Xdoc.Save(m_File);
            }
            catch { Saved = false; }

            return(Saved);
        }