Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

porting a VB.net app over


  • Please log in to reply
2 replies to this topic

#1 rbby258

rbby258

    New Member

  • Members
  • Pip
  • 2 posts

Posted 30 March 2013 - 05:58 PM

i have a vb.net app that plays converted midi files and sends the data to a k8055 to trigger relays. i want to make the system all in one so i dont need a pc to control it so i will need to be able to play them from a sd card. Heres the vb.net source

 

 

 

Public Class Form1   Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer   Private Declare Sub CloseDevice Lib "k8055d.dll" ()   Private Declare Sub Version Lib "k8055d.dll" ()   Private Declare Function SearchDevices Lib "k8055d.dll" () As Integer   Private Declare Function SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer   Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer   Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByRef Data1 As Integer, ByRef Data2 As Integer)   Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer, ByVal Data As Integer)   Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Integer, ByVal Data2 As Integer)   Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)   Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()   Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()   Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)   Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)   Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)   Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()   Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)   Private Declare Sub SetAllDigital Lib "k8055d.dll" ()   Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Boolean   Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer   Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Integer) As Integer   Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Integer)   Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Integer, ByVal DebounceTime As Integer)   Const gGreen As Integer = 1   Const gRed As Integer = 2   Const gYellow As Integer = 4   Const gBlue As Integer = 8   Const gOrange As Integer = 16   Const gStar As Integer = 32   Const gStrum As Integer = 64   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click   Dim CardAddress As Integer   Dim h As Integer   Console.Write("Connecting to card 0...")   CardAddress = 0   h = OpenDevice(CardAddress)   Select Case h   Case 0, 1, 2, 3   ListBox1.Items.Add("Connected")   Case -1   ListBox1.Items.Add("Card not found!")   GoTo nd   Case -2   ListBox1.Items.Add("EXE NOT FOUND?!")   GoTo nd   End Select   WriteAllDigital(0)   Dim cs As String = (OpenFileDialog1.FileName)   ListBox1.Items.Add("Loading File..." & cs)   FileOpen(1, cs, OpenMode.Input)   Dim Data(10000, 3) As Double   Dim n As Integer = 0   Dim s As Double = -1   Do Until EOF(1)   Dim d As String = ""   Input(1, d)   If d <> "" And Microsoft.VisualBasic.Left(d, 1) <> "#" Then   n += 1   Dim ds() As String = Split(d, "|")   Data(n, 0) = ds(0)   If s = -1 Then s = ds(0)   Data(n, 1) = Play(Mid(ds(1), 1, 1), Mid(ds(1), 2, 1), Mid(ds(1), 3, 1), Mid(ds(1), 4, 1), Mid(ds(1), 5, 1), Mid(ds(1), 6, 1))   Data(n, 3) = Play(Mid(ds(1), 1, 1), Mid(ds(1), 2, 1), Mid(ds(1), 3, 1), Mid(ds(1), 4, 1), Mid(ds(1), 5, 1), 0)   Data(n, 2) = Mid(ds(1), 6, 1)   End If   Loop   FileClose(1)   ListBox1.Items.Add(n & " lines of data read.")   Dim b As Double   Dim c As Integer = 1   ListBox1.Items.Add("Press enter to start")   Console.ReadLine()   Dim OldTicks As Long = Now.Ticks - 100000   Do Until c > n   b = Now.Ticks - OldTicks   If b >= Data(c, 0) - s Then   ListBox1.Items.Add("Beat (ticks): " & b & ", Data: " & Data(c, 1))   WriteAllDigital(Data(c, 1))   c += 1   End If   If Data(c, 2) = 1 And Data(c - 1, 2) = 1 And b >= Data(c - 1, 0) + ((Data(c, 0) - Data(c - 1, 0)) / 2) - s Then WriteAllDigital(Data(c - 1, 3))   Loop   Threading.Thread.Sleep(1000)   WriteAllDigital(Data(c - 1, 3)) nd:   ListBox1.Items.Add("Done, press enter to exit")   WriteAllDigital(0)   CloseDevice()   End Sub   Function Play(ByVal Green As Boolean, ByVal Red As Boolean, ByVal Yellow As Boolean, ByVal Blue As Boolean, ByVal Orange As Boolean, ByVal Strum As Boolean) As Integer   Dim d As Integer = 0   If Green Then d = d + gGreen   If Red Then d = d + gRed   If Yellow Then d = d + gYellow   If Blue Then d = d + gBlue   If Orange Then d = d + gOrange   If Strum Then d = d + gStrum + gStar   Play = d   End Function   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click   OpenFileDialog1.ShowDialog()   End Sub End Class

 

 

and this is the files it reads then sends to the k8055

 

 

 

5012750|000011 5531310|000101 6049871|001001 6568431|010001 7086991|100001 7605552|010001 8124112|001001 8642672|000101 9161233|000011 9679793|000101 10198353|001001 10716914|010001 11235474|100001 11754034|000101 12272595|000011 12791155|000101 13309716|001001 13828276|010001 14346836|100001 14865397|000101 15383957|000011 15902517|000101 16421078|001001 16939638|010001 17458198|100001 17976759|000101 18495319|000011 19013879|000101 19532440|001001 20051000|010001 20569560|100001 21088121|000101 21606681|000011 22125241|000101 22643802|001001 23162362|010001 23680922|100001 24199483|000101 24718043|000011 25236603|000101 25755164|001001 26273724|010001 26792284|100001

 

 

and so on, the numbers before the "|" are the ticks for when to trigger the relay. the numbers after the "|" are what relay to trigger so "100001" would be 1 and 6 on and 2, 3, 4 and 5 off. ive never coded in C sharp and i dont know what to do

 



#2 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 31 March 2013 - 12:43 PM

There are a ton of VB to C# conversion sites and apps out there.  http://www.developer...t/vb-to-csharp/

 

or Download SharpDevelop http://www.icsharpco.../opensource/sd/



#3 rbby258

rbby258

    New Member

  • Members
  • Pip
  • 2 posts

Posted 02 April 2013 - 02:02 PM

There are a ton of VB to C# conversion sites and apps out there.  http://www.developer...t/vb-to-csharp/

 

or Download SharpDevelop http://www.icsharpco.../opensource/sd/

 

its not just as simple as converting from vb.net to c sharp i have to remove and replace the k8055 commands and replace them with whatever will work, and what will Sharpdevelop help with, im confussed. I have visual basic 2010 and used it to make the original app






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.