Search code examples
initializationokuma

Initialization of the Okuma ThincAPI


I've installed the Okuma THINC_API. To use it in my program I know I need to put Dim objMachine As Okuma.CMDATAPI.DataAPI.CMachine somewhere. Does it go up at the top with the 'using' directives? Or does it need to be inside my namespace?


Solution

  • Short answer: Inside your namespace

    There should be an example in the help file in the "Getting Started" section. The template I start from (in C#) is:

    using Okuma.CMDATAPI;
    using Okuma.CMCMDAPI;
    
    namespace BasicAPIReferenceApp
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                Okuma.CMDATAPI.DataAPI.CMachine objMachine;
                Okuma.CMDATAPI.DataAPI.CVariables objVariables;
    
                // Create an instance of CMachine class
                objMachine = new Okuma.CMDATAPI.DataAPI.CMachine();
    
                //Call the Init method of CMachine class to initialize the library once for the entire application.
                objMachine.Init();
                MessageBox.Show(
                    System.Enum.GetNames(typeof(Okuma.CMDATAPI.Enumerations.OperationModeEnum)).
                    GetValue((int)objMachine.GetOperationMode()).
                    ToString());
    
                // Create other classes in the library for your need.
                objVariables = new Okuma.CMDATAPI.DataAPI.CVariables();
    
                // Set common variable 1 to value 10;
                objVariables.SetCommonVariableValue(1, 10);
    
                // When your application exits (finalize, onClose(), etc) you must
                //  release the connections to the thinc api using the following code:
                objMachine.Close();
            }
        }
    }