Do While Not stopFlag
'pmCon.QueryMe("Select * from DELL_OPC_ADDRESS where processing <> 1 and Active=1", DTOPCAddress)
pmCon.QueryMe("Select * from DELL_OPC_ADDRESS where processing <> 1 and Active=1 and OPCServer=" & OPCServerNo2Scan, DTOPCAddress)
If DTOPCAddress.Rows.Count <> 0 Then
For Each DR In DTOPCAddress.Rows
If Not OPCFunc.ReadOPCTag(DR("Address"), tmpValue) Then
'Log(DR("LifterId"), "*OPCtriggerSMS - Error reading data type (" & DR("triggerDataType") & ") address (" & DR("triggerAddress") & ")!")
Log(DR("LifterId"), "*OPCtriggerSMS - Error reading address (" & DR("Address") & ")!")
Application.DoEvents()
Continue For
End If
'Need to update RealTimeData so that this value can be reset. It is important for Address where OPC ResetValue='NO ACTION'
If tmpValue <> cNULL(DR("RealTimeData")) Then
pmCon.UpdateMe("Update DELL_OPC_ADDRESS set RealTimeData='" & tmpValue & "' where Address='" & DR("Address") & "'")
End If
If Not tmpValue Is Nothing Then
Dim NeedTrigger As Boolean = False
Select Case DR("triggerValue")
Case "EMPTY"
If CStr(tmpValue).Trim = "" Then NeedTrigger = True
Case "NONEMPTY"
If CStr(tmpValue).Trim <> "" Then NeedTrigger = True
Case "TRUE", "FALSE"
Try
If CBool(tmpValue) = CBool(DR("triggerValue")) Then
NeedTrigger = True
End If
Catch ex As Exception
End Try
Case "NONZERO"
If IsNumeric(tmpValue) Then
If CDbl(tmpValue) <> 0 Then NeedTrigger = True
End If
Case "0", "1", "2"
If tmpValue = DR("triggerValue") Then NeedTrigger = True
End Select
'Check if the TriggerValue stays there forever (due to ResetValue='NO ACTION').
'If yes, then make sure TriggerValue <> RealTimeData
If NeedTrigger And DR("ResetValue") = "NO ACTION" Then
If tmpValue = DR("RealTimeData") Then NeedTrigger = False
End If
If NeedTrigger Then 'If tmpValue.ToUpper = CType(DR("triggerValue"), String).ToUpper Then
Dim NewThread As New clsThread
NewThread.AssignValue(DR, tmpValue)
Dim T As New System.Threading.Thread(AddressOf NewThread.InvokeMethod)
T.Start()
End If
End If
'If Counter > 200 Then
' If InStr(MainForm.lblTnDTriggerSMS.BackColor.ToString.ToUpper, "BLUE") > 0 Then
' MainForm.lblTnDTriggerSMS.BackColor = Color.Gray
' Else
' MainForm.lblTnDTriggerSMS.BackColor = Color.Blue
' End If
' Counter = 0
' Application.DoEvents()
' '10-Nov-2004 Reset the processing=F when the permitted time is over.
pmCon.UpdateMe("Update DELL_OPC_ADDRESS set processing=0 where processing=1 and LastUpdateDT <= '" & _
Format(DateAdd(DateInterval.Minute, -1 * CDbl(MinB4ResetToFalse), Now), "dd-MMM-yyyy hh:mm:ss tt") & "'", True)
'Else
' Counter += 1
'End If
Application.DoEvents()
FlushMemory()
'ContinueNext:
'DTOPCAddress.Dispose()
Next
End If