Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access common (part program) variable using API

Hardware: Okuma OSP-P200L
API Version: 1.15.0.0
How can I read and write the values of common variables?
I found the example code in the help file, but it doesn't explain how to set the current sub system. Also I am confused about the difference between AddCommonVariableValue() and SetCommonVariableValue() Could someone please give a clear example / explanation?

===GET===
Me.varValue.Text = objVariables.GetCommonVariableValue(CInt(Me.varCommonVarNumber.Text))

===SET===
objVariables.SetCommonVariableValue(CInt(Me.varCommonVarNumber.Text), Dbl(Me.varValueUpdate.Text))

like image 979
Scott Solmer Avatar asked Sep 09 '13 12:09

Scott Solmer


People also ask

What is an API endpoint example?

Software programs typically have multiple API endpoints. For example, Instagram's endpoints include one that allows businesses and creators to measure media and profile interactions; one that allows them to moderate comments and their replies; and a third that allows them to discover hashtagged media.


1 Answers

Example (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
like image 52
user2761401 Avatar answered Oct 20 '22 12:10

user2761401