2

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?

4

1 回答 1

1

简短回答:在您的命名空间内

在“入门”部分的帮助文件中应该有一个示例。我从(在 C# 中)开始的模板是:

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();
        }
    }
}
于 2013-07-19T13:41:24.347 回答