Click here to Skip to main content
15,908,112 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: DGV with duplicate rows Pin
Luc Pattyn21-Jun-09 15:08
sitebuilderLuc Pattyn21-Jun-09 15:08 
GeneralRe: DGV with duplicate rows Pin
cstrader23221-Jun-09 15:32
cstrader23221-Jun-09 15:32 
GeneralRe: DGV with duplicate rows Pin
Christian Graus21-Jun-09 15:56
protectorChristian Graus21-Jun-09 15:56 
AnswerRe: DGV with duplicate rows Pin
Christian Graus21-Jun-09 15:57
protectorChristian Graus21-Jun-09 15:57 
GeneralRe: DGV with duplicate rows Pin
cstrader23221-Jun-09 17:00
cstrader23221-Jun-09 17:00 
GeneralRe: DGV with duplicate rows Pin
Luc Pattyn21-Jun-09 17:06
sitebuilderLuc Pattyn21-Jun-09 17:06 
GeneralRe: DGV with duplicate rows Pin
Christian Graus21-Jun-09 19:35
protectorChristian Graus21-Jun-09 19:35 
QuestionGROUND CONTROL STATION for UAV in VB.NET , Help needed [modified] Pin
umarsaeed99921-Jun-09 11:13
umarsaeed99921-Jun-09 11:13 
Hi everyone, im working on the GCS part of our autopilot project. I have developed it in visual basic.net 2005 , what the software basically does is that it receives the values byte by byte, convert them into type double and then displays it on the gauges attached in the design window, im attaching my code below, can someone please tell me if whatever i have done here is correct ?? I would be really grateful Smile | :) thank you (also anyone knows if there is an opensource gcs availible that can receive the serial states serially).

VB.NET CODE:

'Enlisting the classes that could be inherited by this class'


Imports System
Imports System.Drawing
Imports System.Windows.Forms
'Class for the main GCS form

Public Class Form1
Inherits System.Windows.Forms.Form 'Inheritance
'----------------Initializations----------------------------------------'
Dim WithEvents serialportx As New System.IO.Ports.SerialPort 'Declaring serial port form'

Public Delegate Sub throttle()
Public Delegate Sub airspeed()
Public Delegate Sub altitude()
Public Delegate Sub orientation()
Public Delegate Sub direction()
Public Delegate Sub direction2()
Public Delegate Sub rollorientation()
Public Delegate Sub latitude()
Public Delegate Sub longitude()
Dim incomingspeed As Boolean
Dim incomingheight As Boolean
Dim incomingangle As Boolean
Dim incomingposition As Boolean
Dim incomingrollangle As Boolean
Dim incominglatitude As Boolean
Dim incominglongitude As Boolean
Dim receive(,) As Byte
Dim singlearray() As Single
Dim temp() As Byte


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load



'--------Loading Serial Port Form--------
If serialportx.IsOpen Then
serialportx.Close()
End If
Try
With serialportx 'setting serial comm. parameters
.PortName = "COM2"
.BaudRate = 115200
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
' .ReadBufferSize = 4

End With
serialportx.Open() 'opening serial port
Catch ex As Exception
MsgBox(ex.ToString)


End Try
'------------------------------------------

'--Adding Gauges & Map Controls

Me.Controls.Add(airspeedx)
'Me.Controls.Add(mmap1)
Me.Controls.Add(orientationx)
Me.Controls.Add(directionx)
Me.Controls.Add(altitudex)
'------------------------------------------

End Sub

Public Sub SerialPortX_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialportx.DataReceived
Dim length As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer


If serialportx.BytesToRead > 0 Then



length = receive.Length()
For i = 0 To 14
For j = 0 To 3


receive(i, j) = serialportx.ReadByte()
temp(j + i * 4) = receive(i, j)
Next
Next
If temp(0) = 102 And temp(1) = 105 And temp(2) = 105 And temp(3) = 105 Then
For k = 0 To 14
singlearray(k) = BitConverter.ToDouble(temp, 4 * k)
Next

End If


End If


altitudex.Invoke(New altitude(AddressOf updatealtitude), New Object() {})
airspeedx.Invoke(New airspeed(AddressOf updateairspeed), New Object() {})
orientationx.Invoke(New orientation(AddressOf updatepitch), New Object() {})
orientationx.Invoke(New rollorientation(AddressOf updateroll), New Object() {})
altitudex.Invoke(New altitude(AddressOf updatealtitude), New Object() {})


End Sub

Public Sub updatealtitude()
With altitudex
.Altitude = singlearray(5)
.AltBarometer = singlearray(5) / 1000
End With
End Sub
Public Sub updateairspeed()
With airspeedx
.Airspeed = singlearray(1)
End With
End Sub
Public Sub updatepitch()
With orientationx
.AHPitch = singlearray(4)
End With
End Sub
Public Sub updateposition()
With directionx
.HeadingIndicator = singlearray(3)


End With
End Sub
' Public Sub updateposition2()
'With mmap1
'.ObjectID = 0
' .ObjectOrientation = receive(4)
' End With
' End Sub
Public Sub updateroll()
With orientationx
.AHRoll = singlearray(9)

End With
End Sub
'Public Sub updatelatitude()
'With mmap1
' .ObjectID = 0
' .ObjectX = receive(6)
' End With
' End Sub
' Public Sub updatelongitude()
'With mmap1
' .ObjectID = 0
' .ObjectY = receive(7)
'End With
' End Sub
End Class

modified on Sunday, June 21, 2009 5:25 PM

AnswerRe: GROUND CONTROL STATION for UAV in VB.NET , Help needed Pin
Christian Graus21-Jun-09 15:02
protectorChristian Graus21-Jun-09 15:02 
GeneralRe: GROUND CONTROL STATION for UAV in VB.NET , Help needed Pin
umarsaeed99921-Jun-09 21:17
umarsaeed99921-Jun-09 21:17 
QuestionOpen Files Pin
sarthakganguly21-Jun-09 0:07
sarthakganguly21-Jun-09 0:07 
AnswerRe: Open Files Pin
dan!sh 21-Jun-09 0:12
professional dan!sh 21-Jun-09 0:12 
AnswerRe: Open Files Pin
0x3c021-Jun-09 0:15
0x3c021-Jun-09 0:15 
AnswerRe: Open Files Pin
Dave Kreskowiak21-Jun-09 7:58
mveDave Kreskowiak21-Jun-09 7:58 
AnswerRe: Open Files [modified] Pin
Henry Minute21-Jun-09 8:28
Henry Minute21-Jun-09 8:28 
QuestionHow to open file on Existing Workbook. Pin
Musa Biralo20-Jun-09 15:32
Musa Biralo20-Jun-09 15:32 
AnswerRe: How to open file on Existing Workbook. Pin
Dave Kreskowiak20-Jun-09 18:44
mveDave Kreskowiak20-Jun-09 18:44 
GeneralRe: How to open file on Existing Workbook. Pin
Musa Biralo4-Jul-09 15:12
Musa Biralo4-Jul-09 15:12 
QuestionMP3 to Wav? Pin
rspercy6520-Jun-09 7:26
rspercy6520-Jun-09 7:26 
AnswerRe: MP3 to Wav? Pin
0x3c020-Jun-09 7:36
0x3c020-Jun-09 7:36 
GeneralRe: MP3 to Wav? Pin
rspercy6520-Jun-09 8:14
rspercy6520-Jun-09 8:14 
GeneralRe: MP3 to Wav? Pin
TheMrProgrammer20-Jun-09 20:25
TheMrProgrammer20-Jun-09 20:25 
QuestionClickOnce Deployment Pin
Ovais Memon19-Jun-09 23:11
Ovais Memon19-Jun-09 23:11 
AnswerRe: ClickOnce Deployment Pin
miguelfreirejunior22-Oct-09 10:33
miguelfreirejunior22-Oct-09 10:33 
QuestionPlz help me in developing win32 application" Pin
sweety200619-Jun-09 22:01
sweety200619-Jun-09 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.