使用API访问公共(部件程序)变量
硬件:Okuma OSP-P200L使用API访问公共(部件程序)变量,api,variables,get,set,okuma,Api,Variables,Get,Set,Okuma,硬件:Okuma OSP-P200L API版本:1.15.0.0 如何读取和写入常用变量的值? 我在帮助文件中找到了示例代码,但它没有解释如何设置当前子系统。另外,我对AddCommonVariableValue()和SetCommonVariableValue()之间的区别感到困惑,有人能给出一个清晰的例子/解释吗 ===获取=== Me.varValue.Text=objVariables.GetCommonVariableValue(CInt(Me.varCommonVarNumber.
API版本:1.15.0.0
如何读取和写入常用变量的值?
我在帮助文件中找到了示例代码,但它没有解释如何设置当前子系统。另外,我对
AddCommonVariableValue()
和SetCommonVariableValue()
之间的区别感到困惑,有人能给出一个清晰的例子/解释吗
===获取===Me.varValue.Text=objVariables.GetCommonVariableValue(CInt(Me.varCommonVarNumber.Text))
===设置===objVariables.SetCommonVariableValue(CInt(Me.varCommonVarNumber.Text)、Dbl(Me.varValueUpdate.Text))
示例(VB.NET):
Private Sub UpdateCommonVariable(ByVal iIndex As Integer, _
ByVal enSubSystem As Okuma.CLDATAPI.Enumerations.SubSystemEnum)
Try
' Assumptions: iIndex = 1
' Current Value of Common Variable 1 is 0
' enSubSystem = Okuma.CLDATAPI.Enumerations.SubSystemEnu.NC_AL,
' which is Left Spindle, A-Turret
' return Type from a Common Variable is always a Double
Dim _dCommonVariableValue As Double
' declare
Dim _cVariables As New Okuma.CLDATAPI.DataAPI.CVariables
'------------------------------------------------------------------------
' this sets the current SubSystem on the cVariable object
_cVariables.SetSubSystem(enSubSystem)
' and this gets the value currently held by the Common Variable at the
' speicified Index, in the specified SubSystem
_dCommonVariableValue = _cVariables.GetCommonVariableValue(iIndex)
' the return is a Double, with value of 0
'------------------------------------------------------------------------
'------------------------------------------------------------------------
' these add a specified value to the value already held by the specified
' Common Variable
_cVariables.AddCommonVariableValue(iIndex, 1.5)
' the value at Common Variable 1 += 1.5, or = 1.5
Dim _addValue As Double = 0.001
_cVariables.AddCommonVariableValue(iIndex, 0.001)
' the value at Common Variable 1 += .001, or = 1.501
'------------------------------------------------------------------------
'------------------------------------------------------------------------
' SetCommonVariableValue
_cVariables.SetCommonVariableValue(iIndex, 1.0)
' the value at Common Variable 1 is set to 1.0, overriding all
' previous edits
Dim _setValue As Double = 12345.001
_cVariables.SetCommonVariableValue(iIndex, _setValue)
' the value at Common Variable 1 is set to 12345.001, overriding all
' previous edits
'------------------------------------------------------------------------
Catch ex As Exception
Throw
End Try
End Sub