Another Attempt With A Wrapper

ceaser

Active Member
Licensed User
Hi Everybody

I really need help....being battling now for over a week with this:BangHead:

I am attaching 3 files....one is the VB code where I am trying to read the Horizontal and Vertical angles and also the Slope Distance from the Nikon Total Station. The other file is the Basic4ppc file and the other is the Nikon.dll

All that I want to do is to read the 3 variables form the Total Station and use them in my program. The program uses these variables to calculate coordinates, fixing positions, setting out data, etc. I do not need the other functions in the file.

If somebody can please have a look at the attached and tell me please where I am going wrong.:sign0163:

Regards
Michael
 

Attachments

  • VS2008.txt
    1.9 KB · Views: 204
  • Nikon.sbp
    731 bytes · Views: 191

agraham

Expert
Licensed User
Longtime User
You need an instance of TSControl to play with. It's only constructor seems to need a Container, although it does nothing appart from add itself to it, so you need to give it one. I also think you will need to inherit Disposable. Try something like
B4X:
Imports NikonTrimble.Mobile.Communications.TSControl
Imports System.ComponentModel

Public Class TSControl Implements IDisposable

    Private WithEvents TStn As TSControl
    Private TStnContainer As Container

    Public Sub New()
        'Create new instance
        container  = new Container
        TStn = new TStn(TStnContainer)
        ' add the events
        ...
    End Sub

    ....
End Class
Now you have an instance in TStn you can call its methods, get and set its properties and intercept its events - non of which the rest of your code seems to try to do!
 

ceaser

Active Member
Licensed User
Hi Agraham

Thank you very much for your help:sign0188:

Only one thing: In your command "TStn = new TStn(TStnContainer)" VB2008 tells me that "TStn" next to the "New" command is undefined - "Type TStn is not defined" - any ideas?

Thanks once again for your help.

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

I really appreciate your help. I have changed things as follows:

mports NikonTrimble.Mobile.Communications.TSControl
Imports System.ComponentModel

Public Class Nikon
Implements IDisposable

Private WithEvents TStn As Nikon
Private TStnContainer As Container

Public Sub New()
'Create(New instance)
Dim Container As New Container
TStn = New Nikon(TStnContainer)
' add the events ...
' Ha = MeasureAngleRawData
' MsgBox(Ha)
End Sub

I have changed "TSControl" to "Nikon", but now it tells me "Too many arguments to Public Sub New" and the "(TStnContainer)" is underlined.


Thank you very much for your time.

Regards
Michael
 

ceaser

Active Member
Licensed User
Agraham

Now it tells me that "TSControl" is not defined. I am sorry bugging you like this, but there is no one I can turn to for any help.

Regards
Michael
 

ceaser

Active Member
Licensed User
Agraham

This is what I have:

Imports NikonTrimble.Mobile.Communications.TSControl
Imports System.ComponentModel

Public Class Nikon
Implements IDisposable

Private WithEvents TStn As Nikon
Private TStnContainer As Container

Public Sub New()
'Create(New instance)

TStnContainer = New Container
TStn = New TSControl(TStnContainer)

' add the events ...
' Ha = MeasureAngleRawData
' MsgBox(Ha)
End Sub

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

Thank you very much for your help.:sign0188:

When one is in a hurry, one tends to overlook things. I need your help in one more thing please......the three variables (Horizontal & Vertical angle and also the slope distance) that I need are all returning zeros. Do you perhaps have an idea?

This is my code:

Public Class Nikon

Private WithEvents TStn As TSControl
Private TStnContainer As Container

Public Sub New()
'Create new instance
TStnContainer = New Container
TStn = New TSControl(TStnContainer)
End Sub

#Region "*******************************Variables"

'Dim HAngle As NikonTrimble.Mobile.Communications.TSControl.TMeasureAngleData
'Dim VAngle As NikonTrimble.Mobile.Communications.TSControl.TMeasureAngleData
'Dim SDist As NikonTrimble.Mobile.Communications.TSControl.TMeasureDistData
'Dim SetHa As NikonTrimble.Mobile.Common.Angle
'Dim SetAngle As NikonTrimble.Mobile.Communications.TSControl.
Dim Ha As Double, Va As Double, SD As Double

#End Region

#Region "************************************** Properties"

Public ReadOnly Property MeasureHAngleData() As Double 'NikonTrimble.Mobile.Communications.TSControl.TMeasureAngleData
Get
Return TStn.MeasureAngleRawData.HA
End Get
End Property

Public ReadOnly Property MeasureVAngleData() As Double 'As NikonTrimble.Mobile.Communications.TSControl.TMeasureAngleData
Get
Return TStn.MeasureAngleRawData.VA
End Get
End Property

Public ReadOnly Property MeasureDist() As Double 'As NikonTrimble.Mobile.Communications.TSControl.MeasureAngleData
Get
Return TStn.MeasureDistData.SD
End Get
End Property

#End Region

#Region "****************************** Methods"

Public Sub MeasureHAngle()
Ha = MeasureHAngleData
MsgBox(Ha)
End Sub

Sub MeasureVAngle()
Va = MeasureVAngleData
MsgBox(Va)
End Sub

Sub Dist()
SD = MeasureDist
MsgBox(SD)
End Sub

Public Sub SetHAngle(ByVal Ha As Double)

End Sub

#End Region

#Region "*********************************** Events"

'Public Event EventHandler(ByVal AngleChanged)
'Public TSControl(1)

#End Region

End Class

Another question: how do I read the variables in the basic4ppc code?

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

Attached is my code.

I do not know how to thank you enough for your help.

Regards
Michael
 

agraham

Expert
Licensed User
Longtime User
You need to know what the methods and properties of the TStn object do. I don't know that. There is a property called ReceiveAngleRawData that seems to need to be True to get the angle data. See if it is and if not set it.
B4X:
Public Property ReceiveAngleRawData As Boolean
        Get
            Return TStn.ReceiveAngleRawData
        End Get

        Set(value As Boolean)
            TStn.ReceiveAngleRawData = value
        End Set
    End Property
 

ceaser

Active Member
Licensed User
Hi Agraham

If I could, I would give you another medal:sign0188:

Now I only need another help in reading the distance and setting an Horizontal on the Total Station.

Code:

mports NikonTrimble.Mobile.Communications
Imports NikonTrimble.Mobile.Common
Imports System.ComponentModel

Public Class Nikon

Private WithEvents TStn As TSControl
Private TStnContainer As Container

Public Sub New()
'Create new instance
TStnContainer = New Container
TStn = New TSControl(TStnContainer)
TStn.ReceiveAngleRawData = True
'TStn.
End Sub

#Region "*******************************Variables"

Dim Ha As Double, Va As Double, SD As Double

#End Region

Public Property ReceiveAngleRawData() As Boolean
Get
Return TStn.ReceiveAngleRawData
End Get
Set(ByVal value As Boolean)
TStn.ReceiveAngleRawData = value
End Set
End Property

#Region "****************************** Methods"

Public Sub MeasureHAngle()
TStn.ReceiveAngleRawData = True
Ha = TStn.MeasureAngleData.HA.ToDms
MsgBox(Int(Ha))
End Sub

Sub MeasureVAngle()
TStn.ReceiveAngleRawData = True
Va = TStn.MeasureAngleData.VA.ToDms
MsgBox(Int(Va))
End Sub

Sub Dist()
SD = MeasureDist
MsgBox(SD)
End Sub

Public Sub SetHAngle(ByVal Ha As Double)

End Sub

#End Region

End Class

What methods must I use in Basic4ppc to read the 3 variables (Ha, Va & Dist)?

Thank you very much again

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

Another help please.

Do you perhaps see how I can read the distance and set the Horizontal angle on the Instrument? I went through the 2 DLL's, but I fail to see them.

Thank you very much on the last Post....I can get the angles from the Nikon Dll into my program.

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

I have used the following function to read the distance, but it is giving me a zero answer:

SDist=Tstn.MeasureDistData.SD

Regards
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

Thank you very much for your help.:sign0188:

Just one more advise please.:sign0013:

Looking at the following 2 functions ("MeasureStartDist" and "MeasureDistData"), logic tells me that I should use them to make the Nikon read.....could you please help me in nudging me in the right direction?

Regards
Michael
 
Top