Hello all.
I'm building a class, admittedly it's my first almost serious attempt.
Anyway, here it is
And here are the problems
1)
if i declare a new object as axis3, like
then
works as expected, assigning the values at each of the member of the structure.
If i do the same for the InertialModel class, like
it doesn't work. As you can see at the end of the class definition i had to add my own sub to set the values. The one inherited from the axis3 structure doesn't work. And i can't understand why.
Right now what i do is
2)axis3 constructor
how can i do something like
???
Right now i can't figure a way to allow for inline declaration and assignment for the axis3 structure...
And finally a more general question: how could i go to send instances of my class through a socket? Or should i not use sockets?
I'm building a class, admittedly it's my first almost serious attempt.
Anyway, here it is
VB.NET:
Imports System.Timers
Imports System.Text
Imports GMap.NET
Public Class InertialModel
Private _mass As Single
Private _attitude As New axis3
Private _speed As Single
Private _heading As Single
Private _position As PointLatLng
Private _timestamp As Integer
Private _name As String
Private WithEvents _timer As Timer
Public Property position As PointLatLng
Get
Return _position
End Get
Set(ByVal value As PointLatLng)
_position = value
End Set
End Property
Public Property mass() As Double
Get
Return _mass
End Get
Set(ByVal value As Double)
_mass = value
End Set
End Property
Public Property attitude() As axis3
Get
Return _attitude
End Get
Set(ByVal value As axis3)
_attitude = value
End Set
End Property
Public Property speed() As Single
Get
Return _speed
End Get
Set(ByVal value As Single)
_speed = value
End Set
End Property
Public Function GpsUpdate() As Boolean
'read gps
Return True
End Function
Public Function SensorUpdate() As Boolean
'read sensors
Return True
End Function
Public Sub New()
Dim builder As New StringBuilder()
Dim random As New Random()
Dim ch As Char
Dim i As Integer
For i = 0 To 9
ch = Convert.ToChar(Convert.ToInt32((26 * random.NextDouble() + 65)))
builder.Append(ch)
Next
_name = builder.ToString
_position.Lat = 41.8273388828218
_position.Lng = 12.4710702896118
_speed = 0
_heading = 0
_mass = 10
_attitude = New axis3
'_timer.AutoReset = True
'_timer.Interval = 50
'_timer.Start()
End Sub
Public Sub New(ByVal name As String, ByVal lat As Double, ByVal lng As Double, ByVal heading As Single, ByVal speed As Single, ByVal mass As Single)
_name = name
_position.Lat = lat
_position.Lng = lng
_heading = heading
_speed = speed
_mass = mass
End Sub
Private Sub _timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _timer.Elapsed
End Sub
Public Overrides Function ToString() As String
Return String.Format(System.Globalization.CultureInfo.CurrentCulture, "{{Name={0},Lat={1},Lng={2},speed={3},hdg={4}}}", _name, _position.Lat, _position.Lng, _speed, _heading)
End Function
Public Sub AttitudeSet(ByVal val1 As Single, ByVal val2 As Single, ByVal val3 As Single)
_attitude.AngleX = val1
_attitude.AngleY = val2
_attitude.AngleZ = val3
End Sub
End Class
Public Structure axis3
Private _angleX As Single
Private _angleY As Single
Private _angleZ As Single
Public Sub axis3(ByVal val1 As Single, ByVal val2 As Single, ByVal val3 As Single)
_angleX = val1
_angleY = val2
_angleZ = val3
End Sub
Public Function IsEmpty() As Boolean
Return ((_angleX And 0) And (_angleY And 0) And (_angleZ And 0))
End Function
Public Property AngleX As Single
Get
Return _angleX
End Get
Set(ByVal value As Single)
_angleX = value
End Set
End Property
Public Property AngleY As Single
Get
Return _angleY
End Get
Set(ByVal value As Single)
_angleY = value
End Set
End Property
Public Property AngleZ As Single
Get
Return _angleZ
End Get
Set(ByVal value As Single)
_angleZ = value
End Set
End Property
Public Sub Empty()
_angleX = 0
_angleY = 0
_angleZ = 0
End Sub
End Structure
And here are the problems
1)
if i declare a new object as axis3, like
VB.NET:
dim myobj as new axis3
VB.NET:
myobj.axis3(3,3,3)
If i do the same for the InertialModel class, like
VB.NET:
dim myobj as new interialmodel
myobj.attitude.axis3(3,3,3)
Right now what i do is
VB.NET:
Dim temp As New axis3
temp.axis3(3, 3, 3)
state.attitude = temp
2)axis3 constructor
how can i do something like
VB.NET:
dim myobj as newtype = newtype(value1, value2)
Right now i can't figure a way to allow for inline declaration and assignment for the axis3 structure...
And finally a more general question: how could i go to send instances of my class through a socket? Or should i not use sockets?