Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2147

Reading from a single line instead of entire port using 6509 or 6501

$
0
0

Hi,

I am trying to read from a single line using either a 6509 or 6501. Below is my code:

 

Dim digitalReadAlarm1Task As New Task()
Dim digitalReadAlarm2Task As New Task()
Dim InputChannel As DIChannel
Dim bInvertLines As Boolean
Dim iPortBSlashPos As Integer = sPort(2).IndexOf("/")
Dim sPortBName As String = sPort(2).Substring(iPortBSlashPos + 1, sPort(2).Length - (iPortBSlashPos + 1))
Dim iPortCSlashPos As Integer = sPort(2).IndexOf("/")
Dim sPortCName As String = sPort(2).Substring(iPortCSlashPos + 1, sPort(2).Length - (iPortCSlashPos + 1))
Dim readDataAlarm1() As Boolean
Dim readDataAlarm2() As Boolean


Dim myDigitalReader As DigitalSingleChannelReader

InputChannel = digitalReadAlarm1Task.DIChannels.CreateChannel(sPort(1) & "/line7:7", sPortBName, ChannelLineGrouping.OneChannelForAllLines)
digitalReadAlarm1Task.Start()
bInvertLines = InputChannel.InvertLines
digitalReadAlarm1Task.Stop()
InputChannel.InvertLines = Not chkPortInversion.Checked
myDigitalReader = New DigitalSingleChannelReader(digitalReadAlarm1Task.Stream)
readDataAlarm1 = myDigitalReader.ReadSingleSampleMultiLine()

 

InputChannel = digitalReadAlarm2Task.DIChannels.CreateChannel(sPort(2) & "/line5:5", sPortCName, ChannelLineGrouping.OneChannelForAllLines)
digitalReadAlarm2Task.Start()
bInvertLines = InputChannel.InvertLines
digitalReadAlarm2Task.Stop()
InputChannel.InvertLines = Not chkPortInversion.Checked
myDigitalReader = New DigitalSingleChannelReader(digitalReadAlarm2Task.Stream)
readDataAlarm2 = myDigitalReader.ReadSingleSampleMultiLine()

 

digitalReadAlarm1Task.Dispose()
digitalReadAlarm2Task.Dispose()

 

In both cases I get only one line back but it is always false. Anything obviously wrong with my code?

 


Viewing all articles
Browse latest Browse all 2147

Trending Articles