Пример #1
0
        public MagnetDriveControl()
        {
            InitializeComponent();

            txtComPort.LostFocus   += settingsComponentUpdate;
            nudBaudRate.LostFocus  += settingsComponentUpdate;
            nudAxisID.LostFocus    += settingsComponentUpdate;
            txtSetupFile.LostFocus += settingsComponentUpdate;
            nudRampRate.LostFocus  += settingsComponentUpdate;

            txtComPort.KeyUp   += settingsComponentKeyUp;
            nudBaudRate.KeyUp  += settingsComponentKeyUp;
            nudAxisID.KeyUp    += settingsComponentKeyUp;
            txtSetupFile.KeyUp += settingsComponentKeyUp;
            nudRampRate.KeyUp  += settingsComponentKeyUp;


            if (File.Exists(settingsFile))
            {
                magSettings = SerializeData.DeSerializeObject <MagnetDriveSettings>(settingsFile);
            }
            else
            {
                magSettings = new MagnetDriveSettings(1);
            }

            if (File.Exists(calibrationFile + "_xvals.xml"))
            {
                double[] calibX = SerializeData.DeSerializeObject <double[]>(calibrationFile + "_xvals.xml");
                double[] calibY = SerializeData.DeSerializeObject <double[]>(calibrationFile + "_yvals.xml");
                calibration = new double[calibX.Length, 2];
                for (int i = 0; i < calibX.Length; i++)
                {
                    calibration[i, 0] = calibX[i];
                    calibration[i, 1] = calibY[i];
                }
            }
            else
            {
                calibration = new double[2, 2];
            }

            updateGUI();

            setup = new MagnetDriveDriver.MagnetMotorSetup(magSettings.gearRatio, magSettings.nLines, magSettings.slowLoopTime);
        }
Пример #2
0
 private void loadSettings()
 {
     settings = SerializeData.DeSerializeObject <DataFilterSettings>(settingsFile);
 }