It is currently Wed May 24, 2017 7:30 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Mar 20, 2017 9:20 am 
Offline
Member
Member

Joined: Mon Mar 20, 2017 9:09 am
Posts: 2
Hi Team
I have a project which has been running fine on windows 10 and made in Visual Studio 2015 VB

After making same changers to to the app BUT NOT any thing to do with K8055N it has all stoped.

It seems that it will not opendevice any more, like it has lost the DLL but it is still there.

using some of the supplied demo apps the card is there and working

I have check the build options to make sure all is set to x86.

An one got any thoughts.

Ron B


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 5:42 pm 
Offline
User avatar
Velleman Support
Velleman Support

Joined: Mon Dec 11, 2006 12:03 pm
Posts: 4897
Location: Belgium
Is there same problem if you start a new project and try the opendevice?
What is the error message you get (if any)?
Can you post your code?


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 10:34 pm 
Offline
Member
Member

Joined: Mon Mar 20, 2017 9:09 am
Posts: 2
Thanks for your reply

Yes I can start a new project and it all works fine.

Imports Microsoft.VisualBasic
Imports Microsoft.Win32
Imports System
Imports System.Diagnostics
Imports System.Threading
Imports System.Drawing
Imports System.IO
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Columns
Imports System.Reflection
Imports System.ComponentModel
Imports System.Windows.Forms
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraEditors.Registrator
Imports DevExpress.XtraEditors.Drawing
Imports DevExpress.XtraGrid.Views.Grid
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.Globalization



Public Class AutoTiming
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function Version Lib "k8055d.dll" () As Integer
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)

Dim ci As CultureInfo = CultureInfo.InvariantCulture

Dim stopWatchCar1 As New Stopwatch()
Dim stopWatchCar2 As New Stopwatch()
Dim StopwatchNextCar As New Stopwatch()
Dim stopwatchStartDelay As New Stopwatch
Dim stopwatchFinishDelay As New Stopwatch

Dim tsCar1 As TimeSpan
Dim tsCar2 As TimeSpan
Dim MyNextCar As TimeSpan = StopwatchNextCar.Elapsed
Dim tStart As TimeSpan = stopwatchStartDelay.Elapsed
Dim tFinish As TimeSpan = stopwatchFinishDelay.Elapsed

Dim elapsedTimeCar1 As String
Dim elapsedTimeCar2 As String
Dim elapsedTimeNextCar As String
Dim elapsedTimeGap As String
Dim elapsedTimeStart As String
Dim elapsedTimeFinish As String
Dim Mypanelcount As Integer = 0
Dim xS As Integer = 0
Dim xF As Integer = 0
Dim MyTotalRuns As Integer = 0
Dim MyTriggerS As Boolean = False
Dim MyTriggerF As Boolean = False
Dim WaitingCarNumber As String = ""

Dim cn As SqlConnection
Dim cmd As SqlCommand



Private Sub AutoTiming_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PrintDocument1.PrinterSettings.PrinterName = "EPSON TM-T20 Log"


' TestConeect()

MyConnect()

Me.EntryListTableAdapter.FillByEventID(Me.ResultsDataSet1.EntryList, GetEventID)
Me.RunDataTableAdapter.Fill(Me.ResultsDataSet1.RunData)

cn = New SqlConnection(MySQLString)
Me.Slider1.Value = GetStartGap()
' Me.btnSwoopInputs.Image = Global.MotorSportResults_v1.My.Resources.RightRedArow2
Me.lblDelaySlider.Text = Slider1.Value.ToString
MyEventID = GetEventID()
MyLastRunUsed = GetLastRunID()
MyRunID = GetLastRunID()

Me.GridLookUpEdit1.EditValue = MyLastRunUsed
MyRedFromStartDelay = GetFromStarDelay()

'TODO: This line of code loads data into the 'MotorSportResulstsDataSet.RunData' table. You can move, or remove it, as needed.
Me.RunDataTableAdapter.Fill(Me.ResultsDataSet1.RunData)

Dim iRowCount As Integer = Me.ResultsDataSet1.RunData.Rows.Count

MyTotalRuns = iRowCount.ToString
Me.lblTotalRuns.Text = GetTotalRuns(GetEventID)
Me.lblVersion.Text = MyVersion
Me.GridLookUpEdit1.EditValue = MyLastRunUsed
Me.lblStartedToStop.Text = GetStartToStop()
Me.lblEventID.Text = GetEventID()
Me.lblEventName.Text = GetEventName(MyEventID)
' Me.PictureBoxInput1.Image = My.Resources.StartButton
' Me.PictureBoxInput4.Image = My.Resources.StopButton

MyStartBounceDelay = GetStartDelay()
MyFinishBounceDelay = GetFinishDelay()

Me.lblStartDelay.Text = MyStartBounceDelay & " Sec"
Me.lblFinishDelay.Text = MyFinishBounceDelay & " Sec"



' MyConnect()


ShowBeam()


ShowInputSetting()

' Me.btnSwoopInputs.Image = Global.MotorSportResults_v1.My.Resources.RightRedArow2



' ============================ On Screen Lights =======================================
Me.lblStop.BackColor = Color.Red
Me.lblReady.BackColor = Color.Transparent
Me.lblStarted.BackColor = Color.Transparent
Me.lblfinished.BackColor = Color.Transparent
' =====================================================================================
MyLoadIamge()
' PrtStartHearder(GetLastRunID)

GetStill2Run()
If GetUsePOSPrinter() = True Then

DoMyHeader()

End If
End Sub


Private Sub TestConeect()


MsgBox("This Is Just inside MyConnect ")

Dim CardAddress As Integer = 3

Dim h As Integer
h = OpenDevice(CardAddress)

Select Case h
Case 0
MsgBox("This 0 ")
Case 1
MsgBox("This 1 ")
Case 2
MsgBox("This 2 ")
Case 3
MsgBox("This is 3 Connected")

Case -1

MsgBox("This is NOT Connected")



End Select

End Sub

Private Sub MyConnect()


MsgBox("This Is Just inside MyConnect ")


Dim CardAddress As Integer = 3
Dim MyResult As String = ""
Dim h As Integer
h = OpenDevice(CardAddress)
Select Case h
Case 0, 1, 2, 3
MyResult = "Card Is connected"

Me.lblCard.BackColor = Color.LightGreen
Me.lblCard.ForeColor = Color.Black
ClearDigitalChannel(1) ' ready
ClearDigitalChannel(2) ' Started
ClearDigitalChannel(3) ' Finished
ClearDigitalChannel(4) ' stop
Me.TimerInputs.Enabled = True
Case -1
Me.lblCard.BackColor = Color.Yellow
Me.lblCard.ForeColor = Color.Red
MyResult = "Card was Not found"
Me.TimerInputs.Enabled = False
End Select
Me.lblCard.Text = MyResult
End Sub


Top
 Profile  
 
PostPosted: Tue Mar 21, 2017 10:09 am 
Offline
User avatar
Velleman Support
Velleman Support

Joined: Mon Dec 11, 2006 12:03 pm
Posts: 4897
Location: Belgium
I checked your code.
I didn't get the code running if the MyConnect() call occurs outside a procedure.
Instead this seems to work fine:
Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MyConnect()
    End Sub
In other case I got error message "Declaration expected".
Here is the whole code I tested:
Code:
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 Function Version Lib "k8055d.dll" () As Integer
    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)

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MyConnect()
    End Sub


    Private Sub MyConnect()
        MsgBox("This Is Just inside MyConnect ")
        Dim CardAddress As Integer = 3
        Dim MyResult As String = ""
        Dim h As Integer
        h = OpenDevice(CardAddress)
        Select Case h
            Case 0, 1, 2, 3
                MyResult = "Card Is connected"

                Me.lblCard.BackColor = Color.LightGreen
                Me.lblCard.ForeColor = Color.Black
                ClearDigitalChannel(1) ' ready
                ClearDigitalChannel(2) ' Started
                ClearDigitalChannel(3) ' Finished
                ClearDigitalChannel(4) ' stop
                'Me.TimerInputs.Enabled = True
            Case -1
                Me.lblCard.BackColor = Color.Yellow
                Me.lblCard.ForeColor = Color.Red
                MyResult = "Card was Not found"
                'Me.TimerInputs.Enabled = False
        End Select
        Me.lblCard.Text = MyResult
    End Sub
End Class


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group