Exemplo n.º 1
0
 /// <summary>
 /// Primary Construtor for IO object
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="id">Bit Number</param>
 /// <param name="name">Call Name</param>
 /// <param name="iotype">Sets the IO direction</param>
 public KM_IO(KM_Controller controller, int id, string name, IO_TYPE iotype)
 {
     _Controller = controller;
     _ID         = id;
     _Name       = name;
     _IOType     = iotype;
     UpdateIOType();
 }
Exemplo n.º 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();
        }
Exemplo n.º 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
        }
Exemplo n.º 4
0
 /// <summary>
 /// Default constructor for the Axis Object
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="id"></param>
 /// <param name="name"></param>
 public KM_Axis(KM_Controller controller, int id, string name)
 {
     _Controller   = controller;
     _ID           = id;
     _Name         = name;
     _TuningParams = new KM_Axis_TuningParams(controller, id);
     _HomingParams = new KM_Axis_HomingParams();
     _HomingParams.DefaultThread = (id > 5) ? 1 : id;
     while (_HomingParams.DefaultThread < 1)
     {
         _HomingParams.DefaultThread++;
     }
 }
Exemplo n.º 5
0
        private void TestBoard2_click(object sender, EventArgs e)
        {
            KM_Controller KM2;

            KM2 = new KMotion_dotNet.KM_Controller(530);
            if (KM2.WriteLineReadLine("ReadBit47") == "0")
            {
                KM2.WriteLine("SetBit47");
            }
            else
            {
                KM2.WriteLine("ClearBit47");
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Creates group of axes
 /// </summary>
 public KM_AxisGroup(KM_Controller controller, params KM_Axis[] axislist)
 {
     _Controller = controller;
     if (axislist != null)
     {
         for (int i = 0; i < axislist.Length; i++)
         {
             if (axislist[i] == null)
             {
                 _AxisList.Add(new KM_Axis(_Controller, -1, "not used"));
             }
             else
             {
                 _AxisList.Add(axislist[i]);
             }
         }
     }
 }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();

            // create an instance of the KM controller - same instance is used in the entire app
            // ******** VERY IMPORTANT *********
            // inorder to make this work properly
            // the following files needed to be copied to the Debug1/Release1 directories
            // -- and the build output directories need to be changed to Debug1/Release1 - or at least something besides Debug/Release
            // KMotionDLL.dll
            // KMotion_dotNet.dll
            // KMotion_dotNet_Interop.dll
            // GCodeInterpreter.dll
            // KMotionServer.exe
            // TCC67.exe(This is the compiler for their DSP C code)
            // emc.var
            // \DSP_KFLOP Sub directory.
            //
            // also copy the DSP_KFLOP folder into Debug1/Release1
            // reference this wiki page https://www.dynomotion.com/wiki/index.php?title=PC_Example_Applications
            try
            {
                KM = new KMotion_dotNet.KM_Controller();
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to load KMotion_dotNet Libraries.  Check Windows PATH or .exe location " + e.Message);
                System.Windows.Application.Current.Shutdown();  // and shut down the application...
                return;
            }

            // copy of the motion parameters that the JSON reader can use.
            Xparam = new MotionParams_Copy();
            // get the configuration file names
            CFiles = new ConfigFiles();
            // check if the the config file exists
            if (File.Exists("KTestConfig.json") == true)
            {
                JsonSerializer Jser    = new JsonSerializer();
                StreamReader   sr      = new StreamReader("KTestConfig.json");
                JsonReader     Jreader = new JsonTextReader(sr);
                CFiles = Jser.Deserialize <ConfigFiles>(Jreader);
                sr.Close();
            }
            else
            {
                MessageBox.Show("No configureation file found");
                // what to do here?
                // Initialize the strings to null and save the file for next time
                SaveConfig(CFiles);
            }
            if (File.Exists(CFiles.MotionParams) == true)
            {
                JsonSerializer Jser    = new JsonSerializer();
                StreamReader   sr      = new StreamReader(CFiles.MotionParams);
                JsonReader     Jreader = new JsonTextReader(sr);
                Xparam = Jser.Deserialize <MotionParams_Copy>(Jreader);
                sr.Close();
                Xparam.CopyParams(KM.CoordMotion.MotionParams); // copy the motion parameters to the KM instance
            }

            // add the callbacks
            AddHandlers();

            // start a timer for the status update
            var Timer = new DispatcherTimer();

            Timer.Interval = TimeSpan.FromMilliseconds(100);    // timer tick every 100 ms (1/10 sec)
            Timer.Tick    += dispatchTimer_Tick;
            Timer.Start();
        }
Exemplo n.º 9
0
 /// <summary>
 /// Associate KFLOP Axis Channel with Parameters
 /// </summary>
 public KM_Axis_TuningParams(KM_Controller controller, int id)
 {
     _Controller = controller;
     _ID         = id;
 }
Exemplo n.º 10
0
 private void TestBoard2_click(object sender, EventArgs e)
 {
     KM_Controller KM2;
     KM2 = new KMotion_dotNet.KM_Controller(530);
     if (KM2.WriteLineReadLine("ReadBit47")=="0")
         KM2.WriteLine("SetBit47");
     else
         KM2.WriteLine("ClearBit47");
 }