Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
This post has been edited 10 times, last edit by "IAO" (Jun 7th 2013, 2:54am)
This post has been edited 6 times, last edit by "IAO" (Jun 14th 2013, 7:20pm)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
'''====================================================================================== Option Explicit Import gnu#io#* '***Import RXTX gnu.io.*; Import java#io#* '***Import java.io.*; Import java#util#Collection Dim saludo1 As String = "Hello Jabaco! - TheButton" & vbCrLf '***Java: Static CommPortIdentifier portId; Dim portId As CommPortIdentifier '***Java: static SerialPort serialPort; Dim serialPort As SerialPort '***Java: Thread readThread; Dim readThread As Thread '***Java: InputStream inputStream; Dim inputStream As InputStream Dim outputStream As OutputStream '***Java: InputStream toin Dim toin As java#io#InputStream Dim str1 As String = "" Dim items1 As String Public Sub Form_Load() '***Java: Boolean portFound = False; Dim portFound As Boolean '***Java: String defaultPort = "COM1"; Dim defaultPort As String = "COM3" '''"COM1" "COM2" "COM4" '***Java: portList = CommPortIdentifier.getPortIdentifiers(); Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers() '***Java: while (portList.hasMoreElements()) { Do While portList.hasMoreElements() '***Java: portId = (CommPortIdentifier) portList.nextElement(); portId = Cast(portList.nextElement(), CommPortIdentifier) '***Java: If (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { If (portId.getPortType() = CommPortIdentifier.PORT_SERIAL) Then '***Java: If (portId.getName().equals(defaultPort)) { If portId.getName().equals(defaultPort) Then '***Java: System.out.println("Found port: " + defaultPort); Text1.Text = Text1.Text + "Found port: " + defaultPort + vbCrLf '***Java: portFound = True; portFound = True '***Java: SimpleRead reader = New SimpleRead(); 'reader = SimpleRead End If End If items1 = portId.getName() '*** Ports to combobox and listbox lstCommPorts.AddItem items1 ComboBox1.AddItem items1 str1 = str1 & items1 & vbCrLf Loop '***Coloca COM3 en ComboBox1 ComboBox1.Parent.setSelectedIndex(1) '(-1) '***Java: If (!portFound) { If portFound = "" Then '***Java: System.out.println("port " + defaultPort + " not found."); lstCommPorts.AddItem "no port found!" ComboBox1.AddItem "not found!" str1 = "no port found!" End If End Sub Public Sub Command1_Click() 'Command1.Caption = "Disable" 'Command1.Enabled = False items1 = portId.getName() Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers() Do While portList.hasMoreElements() '***Java: portId = (CommPortIdentifier) portList.nextElement(); portId = Cast(portList.nextElement(), CommPortIdentifier) '***Java: If (portId.getName().equals("COM3")) { If portId.getName().equals("COM3") Then '("COM3") Then '***Java: serialPort = (SerialPort) portId.open("SimpleWriteApp", 2000); serialPort = Cast(portId.open("SimpleWriteApp", 2000), SerialPort) outputStream = serialPort.getOutputStream() serialPort.setSerialPortParams(9600, serialPort.DATABITS_8, _ serialPort.STOPBITS_1, serialPort.PARITY_NONE) '***Send to serial port. outputStream.write(saludo1) End If Loop serialPort.close() End Sub Public Sub Command2_Click() '***Java: void connect ( String portName ) throws Exception Dim portName As String = "COM3" '***Java: CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); Dim portIdentifier As CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName) '***Java: if ( portIdentifier.isCurrentlyOwned() ) If portIdentifier.isCurrentlyOwned() Then MsgBox "Error: Port is currently in use" Else '***Java: CommPort commPort = portIdentifier.open(this.getClass().getName(),2000); Dim commPort As CommPort commPort = portIdentifier.open(getClass().getName(),2000) '***Java: if( commPort instanceof SerialPort ) '***java.util.Collection java#util#Collection If IsClass(commPort, SerialPort) Then 'commPort = CommPort.getName() Then '***Java: SerialPort serialPort = (SerialPort) commPort; serialPort = Cast(commPort, SerialPort) '***Java: serialPort.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); serialPort.setSerialPortParams(57600, serialPort.DATABITS_8, _ serialPort.STOPBITS_1, serialPort.PARITY_NONE) '***Java: InputStream toin = serialPort.getInputStream(); '***toin = serialPort.getInputStream() toin = serialPort.getInputStream() Else MsgBox "Error: Only serial ports are handled by this example." End If End If Dim leido As Integer '***Java: while ( ( len = this.toin.read(buffer)) > -1 ) Do While(toin.available() > 0) leido = toin.read() List1.AddItem CChar(leido) '***If you want To change the BackColor of an Shape, be sure, '***that you have Set the BackStyle To vbSolid before. If CChar(leido) = "1" Then Shape1.BackColor = RGB(0, 255, 0) If CChar(leido) = "0" Then Shape1.BackColor = RGB(128, 128, 128) 'java#lang#System.out.println(New String(buffer,0,len1)) Text1.Text = Text1.Text & toin.read() & vbCrLf Loop End Sub Public Sub Command3_Click() On Error Resume Next serialPort.close() End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next '***Here you need jabaco_rev103.jar or higher If MsgBox ("Quit?", vbCritical Or vbOKCancel,"Title") = 2 Then Exit Sub Me.Parent.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) '*** serialPort.close() CAll End system.exit(0) End Sub |
This post has been edited 7 times, last edit by "IAO" (Jun 27th 2013, 6:21am)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
Option Explicit '***NOTE: Important!! '***Copy Inpout32.dll to \Windows\system32\ '*** Here worked well. '***VB6: Declare Sub Out Lib "Inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer) Private Winapi Function Out Lib "Inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer) '***VB6: Declare Function Inp Lib "Inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Private Winapi Function Inp Lib "Inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Dim Puerto As Integer Dim BE(0 To 7) As Integer Private Sub Form_Load() '***Genera el contenido del combo. Port.AddItem "LPT1 - (378)" Port.AddItem "LPT2 - (278)" Port.AddItem "LPT3 - (3BC)" Port.ListIndex = 0 End Sub Private Sub Port_Click() '***Apunta el puerto a utilizar. If Port.ListIndex = 0 Then Puerto = &H378 If Port.ListIndex = 1 Then Puerto = &H278 If Port.ListIndex = 2 Then Puerto = &H3BC End Sub Private Sub Timer1_Timer() '***Lee el dato del puerto. Dim x As Integer x = Inp(Puerto) '***Desglosa los bits restantes. If x > 127 Then BE(7) = 1: x = x - 128 Else BE(7) = 0 '0 'Invertido If x > 63 Then BE(6) = 1: x = x - 64 Else BE(6) = 0 '1 If x > 31 Then BE(5) = 1: x = x - 32 Else BE(5) = 0 '1 If x > 15 Then BE(4) = 1: x = x - 16 Else BE(4) = 0 '1 If x > 7 Then BE(3) = 1: x = x - 8 Else BE(3) = 0 '1 '***Agregado por mi If x > 3 Then BE(2) = 1: x = x - 4 Else BE(2) = 0 '1 If x > 1 Then BE(1) = 1: x = x - 2 Else BE(1) = 0 '1 If x > 0 Then BE(0) = 1: x = x - 1 Else BE(0) = 0 '1 '***Controla los Led's. Dim ciclo As Integer For ciclo = 0 To 7 If BE(ciclo) = 0 Then '***VB6: LE(Ciclo).Picture = LoadPicture(App.Path + "\res\lg1.png") LE(ciclo).Picture = Lg1Png '***you have to add lg1.png as Jabaco-resource Leer_lpt.Refresh '***a future framework-version will refresh it automatically Else '***VB6: LE(Ciclo).Picture = LoadPicture(App.Path + "\res\lr1.png") LE(ciclo).Picture = Lr1Png '***you have to add lr1.png as Jabaco-resource Leer_lpt.Refresh '***a future framework-version will refresh it automatically End If Next Ciclo End Sub |
This post has been edited 6 times, last edit by "IAO" (Jun 29th 2013, 2:56am)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Option Explicit Import org#jawin#COMException Import org#jawin#FuncPtr Import org#jawin#ReturnFlags Private Sub Form_Load() '*** LPT1=(&H378)(888), LPT2=(&H278)(632), LPT3=(&H3BC)(956) Dim g As Integer Dim metodo1 As FuncPtr metodo1 = Null metodo1 = New FuncPtr("Inpout32.dll","Out32") '***Los dos trabajan bien 'g = metodo1.invoke_I(888,255,ReturnFlags.CHECK_HRESULT) 'En Decimal g = metodo1.invoke_I(&H378,15,ReturnFlags.CHECK_HRESULT) 'En Hexadecimal System.exit(0) End Sub |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
mport org.jawin.COMException; import org.jawin.FuncPtr; import org.jawin.ReturnFlags; //***FUNCIONANDO BIEN. public class JawinDLL { /*** @param args the command line arguments */ public static void main(String[] args) throws COMException{ //***TODO code application logic here FuncPtr metodo = null; metodo = new FuncPtr("Inpout32.dll","Out32"); //***Los dos trabajan bien //Integer g = metodo.invoke_I(888,15,ReturnFlags.CHECK_HRESULT); //En Decimal Integer g = metodo.invoke_I(0x378,1,ReturnFlags.CHECK_HRESULT); //En Hexadecimal //System.out.println(g); //****VB6:(&H378 = 888) } } |
This post has been edited 6 times, last edit by "IAO" (Jun 29th 2013, 4:16am)
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
//***name the file: Resources.java import VBA.VBEnumClass; public class Resources extends VBEnumClass { public Resources() { } public Resources(int i) { super(i); } public Resources(long l) { super(l); } public Resources(String s) { super(s); } } |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//***name the file: Module1.java import VB.AbstractForm; import VBA.VBArray; public class Module1 { public static Form1 Form1 = new Form1(); public static void main(String args[]) { Throwable Err = null; VBA.VBArrayString myArgs = new VBArray(); //myArgs = VBArray.createVBArray(args); Form1.SetDefaultClose(); Form1.Show(); } public Module1() { } } |
Source code |
|
1 |
//***name the file: Form1.java |
This post has been edited 4 times, last edit by "IAO" (Jul 1st 2013, 11:34pm)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
Option Explicit Dim cx As Integer, cy As Integer Dim cx1 As Integer, cy1 As Integer Dim i As Integer, j As Long Dim dato(1000) As Long '***Const pi = 3.14159265358979 Const pi = Atn(1)*4 Private Sub Command1_Click() j = 0 Command1.Caption = "Draw && Send " Command1.Enabled = False For i = 0 To cx j = cy * Sin(12 * i * (pi / cx)) dato(i + 1) = (cy / 2) - (j / 2) '***VB6: Picture1.Line (i, dato(i))-(i, dato(i + 1)), vbBlue '((&HFFFFFF / (i + 1))) Picture1.ForeColor = RGB(255,0,0) '***color red Picture1.Line(i, dato(i), i, dato(i + 1), False, RGB(255,0,0)) Form1.Refresh Next i Command1.Enabled = True Command1.Caption = "Dibuje" End Sub Private Sub Form_Load() cy = Picture1.ScaleHeight cx = Picture1.ScaleWidth '***Axes x,y Picture1.ForeColor = RGB(0,0,0) '***color black Picture1.Line(120,2,120,118,False) Picture1.Line(2,60,230,60,False) Command1.Caption = "Dibuje" End Sub Private Sub Form_Terminate() 'End System.exit(0) End Sub |
This post has been edited 1 times, last edit by "IAO" (Jul 6th 2013, 8:34pm)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
Option Explicit Import gnu#io#* '***Import RXTX gnu.io.*; Import java#io#* '***Import java.io.*; Import java#util#* Import java#util#Collection#* Dim greeting As String = "Hello Jabaco forum!!! " & vbCrLf Dim portId As CommPortIdentifier Dim serialPort As SerialPort Dim readThread As Thread Dim inputStream As InputStream Dim outputStream As OutputStream Dim scanner As Scanner Dim printStream As PrintStream '***============================================================================= Private Sub Form_Load() MsgBox "Remember click on SearchPort&Connect Buttom" End Sub Public Sub Command1_Click() Command1.Caption = "Disable" Command1.Enabled = False Dim puerto As CommPort Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers() portId = Null Do While portList.hasMoreElements() portId = Cast(portList.nextElement(), CommPortIdentifier) If portId.getName().equals("COM3") Then '***Break Exit Do End If Loop serialPort = Cast(portId.open("PuertoSerial", 2000), SerialPort) serialPort.setSerialPortParams(9600, serialPort.DATABITS_8, _ serialPort.STOPBITS_1, serialPort.PARITY_NONE) scanner = New Scanner(serialPort.getInputStream()) printStream = New PrintStream(serialPort.getOutputStream()) End Sub Public Sub Command2_Click() '***Envía cadena por puerto serial. If Text1.Text = "" Then MsgBox "Write Something and Send" Else printStream.write(Text1.Text) + vbCrLf End If End Sub Public Sub Command3_Click() Do While(Not scanner.hasNextInt()) scanner.close() scanner = Null scanner = New Scanner(serialPort.getInputStream()) Loop Dim valor As Integer valor = scanner.nextInt() Label1.setText(valor) End Sub |
This post has been edited 3 times, last edit by "IAO" (Jul 8th 2013, 2:36pm)
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
Option Explicit 'Import com#jacob#activeX#ActiveXComponent Import com#jacob#activeX#* Import com#jacob#com#* Dim oInBufferCount As String Dim MSComm1 As ActiveXComponent '***========================================================================================== Private Sub Form_Load() '***Funcionando así Set MSComm1 = New ActiveXComponent("MSCOMMLib.MSComm.1") Dispatch.put(MSComm1, "RThreshold", 1) Dispatch.put(MSComm1, "InputLen", 0) '***read the entire contents of the receive buffer. Dispatch.put(MSComm1, "InputMode", 0) '0 TextMode, 1 BinarieMode Dispatch.put(MSComm1, "InBufferSize", 512) Dispatch.put(MSComm1, "CommPort", 3) '***Select comm port to open Dispatch.put(MSComm1, "Settings", "57600,N,8,1") '***Make sure DTR line is low to prevent Stamp reset Dispatch.put(MSComm1, "DTREnable", False) Dispatch.put(MSComm1, "RTSEnable", True) '***Aquí abre el PuertoSerial Dispatch.put(MSComm1, "PortOpen", True) 'Dispatch.put(MSComm1, "Output", "Holaaaa" & vbCrLf) '***<====To Send puerto serial End Sub Public Sub Command1_Click() Dispatch.put(MSComm1, "PortOpen", False) '***<====Aquí Close SerialPort System.exit(0) End Sub Public Sub Command2_Click() oInBufferCount = Dispatch.call(MSComm1, "InBufferCount") If oInBufferCount > 0 Then Dim a As String = Dispatch.call(MSComm1, "Input") 'TextMode String. Working!. Variant not work. Text1.Text = Text1.Text & a & vbCrLf '***OK Label1 = Label1 & a & vbCrLf '***OK RichTextBox1.Text = RichTextBox1.Text & a & vbNewLine '***OK End If Dispatch.put(MSComm1, "InBufferCount", 0) End Sub |
This post has been edited 8 times, last edit by "IAO" (Jul 14th 2013, 8:44pm)