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
| Imports NationalInstruments.DAQmx
Imports System.Threading
Imports Microsoft.VisualBasic
PublicClass Form1
Inherits System.Windows.Forms.Form
Private myTask2 As Task
Private myTask4 As Task
Private myTask5 As Task
Private myDigitalReader2 As DigitalSingleChannelReader
Private myDigitalReader4 As DigitalSingleChannelReader
Private myDigitalReader5 As DigitalSingleChannelReader
Private firstEdge As CITwoEdgeSeparationFirstEdge
Private secondEdge As CITwoEdgeSeparationSecondEdge
Private myTask As Task
Private trigger1 As Task
Private counterInReader As CounterReader
Private _threadCalculs1 As Thread
Private _threadCalculs2 As Thread
Private _threadCalculs3 As Thread
Private _threadCalculs4 As Thread
Private _threadCalculs5 As Thread
Private _threadCalculs6 As Thread
Private _threadCalculs7 As Thread
Private _threadCalculs8 As Thread
#Region " Code généré par le Concepteur Windows Form "
#EndRegion
PublicSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Timer1.Enabled() = True
myTask2 = New Task
myTask2.DIChannels.CreateChannel("Dev1/port2/line0:7", "read2_digits", ChannelLineGrouping.OneChannelForAllLines)
myDigitalReader2 = New DigitalSingleChannelReader(myTask2.Stream)
myTask4 = New Task
myTask4.DIChannels.CreateChannel("Dev1/port4/line0:7", "read4_digits", ChannelLineGrouping.OneChannelForAllLines)
myDigitalReader4 = New DigitalSingleChannelReader(myTask4.Stream)
myTask5 = New Task
myTask5.DIChannels.CreateChannel("Dev1/port5/line0:7", "read5_digits", ChannelLineGrouping.OneChannelForAllLines)
myDigitalReader5 = New DigitalSingleChannelReader(myTask5.Stream)
EndSub
PrivateSub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
'Connection pci dio 96 port 2
Dim readData2() AsBoolean
readData2 = myDigitalReader2.ReadSingleSampleMultiLine()
Babord.Value = readData2(6)
Tribord.Value = readData2(5)
...blablabla
'Affichage du mode 3d ou 2d
If readData4(6) = TrueThen
Mode.Text = "3D"
ElseIf readData4(6) = FalseThen
Mode.Text = "2D"
EndIf
C1.Value = c1pret.Value
C2.Value = Not c2pret.Value
C3.Value = c3pret.Value
C4.Value = Not c4pret.Value
'crée un délégué et affiche le delai de manière asynchrone
StartThread()
StartThread1()
StartThread2()
StartThread3()
StartThread4()
StartThread5()
StartThread6()
StartThread7()
EndSub
'Programmation de fonction, une par délai, cette fonction est programmée 8 fois
PublicSub delais1()
Dim max AsDouble = 0.3
Dim min AsDouble = 0.001
Dim valeurdelai AsString
myTask = New Task
Dim channel AsString
myTask.CIChannels.CreateTwoEdgeSeparationChannel("Dev2/ctr0", "", min, _
max, CITwoEdgeSeparationFirstEdge.Rising, CITwoEdgeSeparationSecondEdge.Rising, CITwoEdgeSeparationUnits.Seconds)
counterInReader = New CounterReader(myTask.Stream)
Dim data AsDouble = counterInReader.ReadSingleSampleDouble()
valeurdelai = data.ToString
Delai1.Text = valeurdelai
EndSub
DelegateSub quitte()
PublicSub fermeture()
Me.Dispose()
Me.Close()
EndSub
PrivateSub StartThread()
_threadCalculs1 = New Thread(AddressOf delais1)
_threadCalculs1.Name = "Thread1"
_threadCalculs1.Start() ' Démarrage du thread.
EndSub
PrivateSub quitter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quitter.Click
Dim fermeture1 AsNew quitte(AddressOf fermeture)
fermeture1.BeginInvoke(Nothing, Nothing)
EndSub
EndClass
|
Partager