public Calibration(Player player, Rewired.Joystick joystick, CalibrationMap calibrationMap)
     : base(ControlRemappingDemo1.QueueActionType.Calibrate)
 {
     this.player = player;
     this.joystick = joystick;
     this.calibrationMap = calibrationMap;
     this.selectedElementIdentifierId = -1;
 }
 public Calibration(
     Player player,
     Joystick joystick,
     CalibrationMap calibrationMap
 )
     : base(QueueActionType.Calibrate) {
         this.player = player;
         this.joystick = joystick;
         this.calibrationMap = calibrationMap;
         selectedElementIdentifierId = -1;
 }
Exemple #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet_Parameters;
            Excel.Worksheet   xlWorkSheet_Signals;
            Excel.Worksheet   xlWorkSheet_Defines;
            Excel.Worksheet   xlWorkSheet_States;
            string            Line;
            int  LineNum;
            int  RetVal = 0;
            int  index;
            bool ScalingExists = false;
            bool GroupExists   = false;

            XLSECTParameter       XLSECTParameter1       = new XLSECTParameter();
            XLSECTSignal          XLSECTSignal1          = new XLSECTSignal();
            SignalValue           SignalValue1           = new SignalValue();
            CalibrationValue      CalibrationValue1      = new CalibrationValue();
            CalibrationSharedAxis CalibrationSharedAxis1 = new CalibrationSharedAxis();
            CalibrationCurve      CalibrationCurve1      = new CalibrationCurve();
            CalibrationMap        CalibrationMap1        = new CalibrationMap();

            System.IO.StreamWriter fileXML;
            /* Scaling IDs */
            CalibrationScaling CScalingNew = new CalibrationScaling();
            //            CalibrationScaling CS;
            Group GroupNew = new Group();


            GroupList    = new List <Group>();
            CScalingList = new List <CalibrationScaling>();

            object misValue = System.Reflection.Missing.Value;

            xlApp                  = new Excel.Application();
            xlWorkBook             = xlApp.Workbooks.Open(filePath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet_Parameters = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            xlWorkSheet_Signals    = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
            xlWorkSheet_Defines    = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(3);
            xlWorkSheet_States     = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(4);

            if (File.Exists(BasefilePath))
            {
                // Copy the XML base file as a header for the new file

                CopyBaseFileToTarget();

                fileXML = new System.IO.StreamWriter(XMLfilePath, true);

                // Generate the signals and write them in the new XML file
                Line    = "2";
                LineNum = 2;
                while (-2 != RetVal)
                {
                    // Elaborate the signals sheet
                    RetVal = XLSECTSignal1.upload(ref xlWorkSheet_Signals, Line);

                    // Build the Scaling IDs list

                    CScalingNew.upload(ref XLSECTSignal1);
                    ScalingExists = false;

                    foreach (CalibrationScaling CS in CScalingList)
                    {
                        if (CS.ID == CScalingNew.ID)
                        {
                            ScalingExists = true;
                        }
                    }

                    if (ScalingExists == false)
                    {
                        CScalingList.Add(CScalingNew);
                        CScalingNew = new CalibrationScaling();
                    }

                    // Build the Group IDs list
                    GroupNew.upload(ref XLSECTSignal1);
                    GroupExists = false;

                    foreach (Group GP in GroupList)
                    {
                        if (GP.ID == GroupNew.ID)
                        {
                            GroupExists = true;
                        }
                    }

                    if (GroupExists == false)
                    {
                        GroupList.Add(GroupNew);
                        GroupNew = new Group();
                    }

                    // If it is a Signal (Channel in ECT XML nomenclature)
                    if ((RetVal == 0) || (RetVal == 123456789))
                    {
                        SignalValue1.upload(ref XLSECTSignal1, false, 0, ref Containr);
                        SignalValue1.AppendToFile(ref fileXML);
                        //                        SignalValue1.Show();
                    }
                    else
                    {
                        if (RetVal > 1)
                        {
                            if (RetVal > 123456789)
                            {
                                RetVal -= 123456789;
                            }
                            for (index = 0; index < RetVal; index++)
                            {
                                SignalValue1.upload(ref XLSECTSignal1, true, index, ref Containr);
                                SignalValue1.AppendToFile(ref fileXML);
                            }
                        }
                    }
                    LineNum++;
                    Line = Convert.ToString(LineNum);
                }

                // Generate the calibrations and write them in the new XML file
                Line    = "2";
                LineNum = 2;
                RetVal  = 0;
                while (-2 != RetVal)
                {
                    // Elaborate the parameters sheet
                    RetVal = XLSECTParameter1.upload(ref xlWorkSheet_Parameters, Line);

                    CScalingNew.upload(ref XLSECTParameter1);
                    ScalingExists = false;

                    foreach (CalibrationScaling CS in CScalingList)
                    {
                        if (CS.ID == CScalingNew.ID)
                        {
                            ScalingExists = true;
                        }
                    }

                    if (ScalingExists == false)
                    {
                        CScalingList.Add(CScalingNew);
                        CScalingNew = new CalibrationScaling();
                    }

                    // Build the Group IDs list
                    GroupNew.upload(ref XLSECTParameter1);
                    GroupExists = false;

                    foreach (Group GP in GroupList)
                    {
                        if (GP.ID == GroupNew.ID)
                        {
                            GroupExists = true;
                        }
                    }

                    if (GroupExists == false)
                    {
                        GroupList.Add(GroupNew);
                        GroupNew = new Group();
                    }

                    // If it is a CalibrationValue
                    if (RetVal == 0)
                    {
                        CalibrationValue1.upload(ref XLSECTParameter1, ref Containr);
                        CalibrationValue1.AppendToFile(ref fileXML);
                        //                        CalibrationValue1.Show();
                    }

                    // If it is a CalibrationSharedAxis
                    if (RetVal == 1)
                    {
                        CalibrationSharedAxis1.upload(ref XLSECTParameter1, ref Containr);
                        CalibrationSharedAxis1.AppendToFile(ref fileXML);
                        //                        CalibrationSharedAxis1.Show();
                    }

                    // If it is a CalibrationCurve
                    if (RetVal == 2)
                    {
                        CalibrationCurve1.upload(ref XLSECTParameter1, ref Containr);
                        CalibrationCurve1.AppendToFile(ref fileXML);
                        //                        CalibrationCurve1.Show();
                    }

                    // If it is a CalibrationMap
                    if (RetVal == 3)
                    {
                        CalibrationMap1.upload(ref XLSECTParameter1, ref Containr);
                        CalibrationMap1.AppendToFile(ref fileXML);
                        //                        CalibrationMap1.Show();
                    }

                    LineNum++;
                    Line = Convert.ToString(LineNum);
                }
                foreach (Group GP in GroupList)
                {
                    GP.AppendToFile(ref fileXML);
                }

                foreach (CalibrationScaling CS in CScalingList)
                {
                    CS.AppendToFile(ref fileXML);
                }

                fileXML.WriteLine("</LIE00V12PARTIAL>");
                fileXML.Close();
            }
            else
            {
                MessageBox.Show(" Base File doesn't exist");
            }


            /*
             *
             *          MessageBox.Show(
             *              xlWorkSheet_Parameters.get_Range("A2", "A2").Value2.ToString() + "\r\n" +
             *              xlWorkSheet_Parameters.get_Range("A3", "A3").Value2.ToString() + "\r\n" +
             *              xlWorkSheet_Parameters.get_Range("A4", "A4").Value2.ToString() + "\r\n" +
             *              xlWorkSheet_Parameters.get_Range("A5", "A5").Value2.ToString() + "\r\n" +
             *              xlWorkSheet_Parameters.get_Range("A6", "A6").Value2.ToString() + "\r\n"
             *                         );
             */
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet_Parameters);
            releaseObject(xlWorkSheet_Signals);
            releaseObject(xlWorkSheet_Defines);
            releaseObject(xlWorkSheet_States);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
            MessageBox.Show("Finished!");
        }