Пример #1
0
        /// <summary>
        /// Executes a homing sequence based on the settings within the HomingParams variable
        /// </summary>
        public void StartDoHome()
        {
            _Controller.SetUserData(_HomingParams.StatusBit, (int)HOMING_STATE.NOT_HOMED);
            string autofile = "";

            switch (_HomingParams.SourceType)
            {
            case HOMING_ROUTINE_SOURCE_TYPE.AUTO:
                autofile = WriteHomingToFile(GetAutoHomingFileSource());
                break;

            case HOMING_ROUTINE_SOURCE_TYPE.FROM_FILE:
                autofile = _HomingParams.Homing_c_Program;
                break;

            case HOMING_ROUTINE_SOURCE_TYPE.FROM_STRING:
                autofile = WriteHomingToFile(_HomingParams.Homing_c_Program);
                break;

            case HOMING_ROUTINE_SOURCE_TYPE.FROM_THREAD:
                _Controller.ExecuteProgram(_HomingParams.DefaultThread);
                return;

            default:
                break;
            }
            _Controller.ExecuteProgram(_HomingParams.DefaultThread, autofile, true);
        }
Пример #2
0
        /// <summary>
        /// Initialize Controller object and perfor tests
        /// </summary>
        /// <param name="args">N/A</param>
        static void Main(string[] args)
        {
            //Create an instance of the _Controller
            //The same instance should be used throughout the app 
            _Controller = new KMotion_dotNet.KM_Controller();
            //Add all various callbacks
            AddHandlers();
            Console.WriteLine(String.Format("Board Type = [{0}]", _Controller.BoardType));

 
            //Load a C program
            //
            
            // Figure out what directory we are installed into
            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri = new UriBuilder(codeBase);
            string path = Uri.UnescapeDataString(uri.Path);
            path = Path.GetDirectoryName(path);
            path = Path.GetDirectoryName(path);
            path = Path.GetDirectoryName(path); 

            // pick one of the examples
            String TheCFile = path  + @"\C Programs\KSTEP\InitKStep3Axis.c";
 
            //************NEW program execution model***********
            String result = _Controller.ExecuteProgram(1, TheCFile, false);
            if (result != "") MessageBox.Show(result);

            //Also have a look at these::
            //_Controller.ExecuteProgram(1); 
            //_Controller.WaitForThreadComplete(1, 400);
            //_Controller.KillProgramThreads(1);
            //_Controller.KillProgramThreads(3, 5, 6);

            // Put a 64 bit float value into KFLOP UserData
            // vars 26&27 and read it back.
            // in KFLOP read it with:
            //  printf("UserData %f\n", *(double*)&persist.UserData[13 * 2]);

            _Controller.SetUserDataDouble(13, 123.456789);
            double d = _Controller.GetUserDataDouble(13);

            //Get Firmware version
            Console.WriteLine(_Controller.GetCommandValue<string>("Version", false));
            

            RunMain_StatusExample();
            //RunHomingRoutineExample();
            RunIOExample();
            //RunAxisExample();
            RunCoordinatedMotionExample();
            //RunInterpreterExample(); 
            
            _Controller.Dispose();
            
            Console.ReadLine();
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            //Create an instance of the KM the same instance should be used throughout the app
            try
            {
                KM = new KMotion_dotNet.KM_Controller();
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to load KMotion_dotNet Libraries.  Check Windows PATH or .exe location\r\r" + e.Message);
                System.Windows.Application.Current.Shutdown();
                return;
            }
            //Add all various callbacks
            AddHandlers();

            //Load a C program, first figure out what directory we are installed into
            string     codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri      = new UriBuilder(codeBase);

            MainPath = Uri.UnescapeDataString(uri.Path);
            MainPath = System.IO.Path.GetDirectoryName(MainPath);
            MainPath = System.IO.Path.GetDirectoryName(MainPath);
            MainPath = System.IO.Path.GetDirectoryName(MainPath);

            // pick one of the examples to configure KFLOP
            String TheCFile = MainPath + @"\C Programs\KSTEP\InitKStep3Axis.c";

            //Execute it
            try
            {
                KM.ExecuteProgram(1, TheCFile, false);
            }
            catch (DMException e)
            {
                MessageBox.Show("Unable to Execute C Program in KFLOP\r\r" + e.InnerException.Message);
            }

            // default a simple GCode File
            GCodeFile.Text = MainPath + @"\GCode Programs\box.ngc";

            // Start a Timer for status updates
            System.Windows.Threading.DispatcherTimer Timer = new System.Windows.Threading.DispatcherTimer();
            Timer.Tick    += new EventHandler(dispatcherTimer_Tick);
            Timer.Interval = TimeSpan.FromMilliseconds(100);
            Timer.Tick    += dispatcherTimer_Tick;
            Timer.Start();

            SetMotionParameters(); // Set some motion Parameters
        }
Пример #4
0
        private void BtnCProgram_Click(object sender, RoutedEventArgs e)
        {
            // open a windows dialog to read in the cprogram
            var openFileDlg = new OpenFileDialog();

            openFileDlg.FileName = CFiles.KThread1;
            if (openFileDlg.ShowDialog() == true)
            {
                CFiles.KThread1 = openFileDlg.FileName; // save the filename for next time
                try
                {
                    KM.ExecuteProgram(1, openFileDlg.FileName, true);
                }
                catch (DMException ex)
                {
                    MessageBox.Show("Unable to execute C Program in KFLOP\r\r" + ex.InnerException.Message);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Initialize Controller object and perfor tests
        /// </summary>
        /// <param name="args">N/A</param>
        static void Main(string[] args)
        {
            //Create an instance of the _Controller
            //The same instance should be used throughout the app
            _Controller = new KMotion_dotNet.KM_Controller();
            //Add all various callbacks
            AddHandlers();
            Console.WriteLine(String.Format("Board Type = [{0}]", _Controller.BoardType));


            //Load a C program
            //

            // Figure out what directory we are installed into
            string     codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri      = new UriBuilder(codeBase);
            string     path     = Uri.UnescapeDataString(uri.Path);

            path = Path.GetDirectoryName(path);
            path = Path.GetDirectoryName(path);
            path = Path.GetDirectoryName(path);

            // pick one of the examples
            String TheCFile = path + @"\C Programs\KSTEP\InitKStep3Axis.c";

            //************NEW program execution model***********
            String result = _Controller.ExecuteProgram(1, TheCFile, false);

            if (result != "")
            {
                MessageBox.Show(result);
            }

            //Also have a look at these::
            //_Controller.ExecuteProgram(1);
            //_Controller.WaitForThreadComplete(1, 400);
            //_Controller.KillProgramThreads(1);
            //_Controller.KillProgramThreads(3, 5, 6);

            // Put a 64 bit float value into KFLOP UserData
            // vars 26&27 and read it back.
            // in KFLOP read it with:
            //  printf("UserData %f\n", *(double*)&persist.UserData[13 * 2]);

            _Controller.SetUserDataDouble(13, 123.456789);
            double d = _Controller.GetUserDataDouble(13);

            //Get Firmware version
            Console.WriteLine(_Controller.GetCommandValue <string>("Version", false));


            RunMain_StatusExample();
            //RunHomingRoutineExample();
            RunIOExample();
            //RunAxisExample();
            RunCoordinatedMotionExample();
            //RunInterpreterExample();

            _Controller.Dispose();

            Console.ReadLine();
        }