Hello!
I'm writing a program where it scanns the differnt values from an OPC-server
which is connect to several PLC-systems.
For each PLC-system I have to read 16 differnt values and there are around
40 systems.
The scan have to keep on till it finds a value different from "0" and then
sends an SMS to our internal phone-system. So far there is no problem.
The thingis that I am using and timer and have put all the scanning routines
under the sub-routine of the timer. As I mentioned there are 40 systems and
the programs stopps responding since they are all under one timer.
My question is: "Are there any better way to trigger the scan without using
the TIMER-function?"
Since the program stopps responsing I can't do anything else with it while
the timer is executing.
I have enclosed part of the TIMER-rouitine. As you can see the TIMER-SUB is
far too long and it will be larger as I fill it with more systems.
Is it a good idé of making each system as it own SUB and call it or how do
you think I should better write the code?!
Please help. I'm so close, but still far away...
Thanx in advance!
//Kashif
******************
Private Sub timerScan_Timer()
LogToPrioWindow (Now & " Customer Care Lina 2 START")
'************* START SCANNING LARM TILL CC-LINE 2 *************
For intCC2 = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_CC2(intCC2) = "CC2_SMS" & intCC2 'Talar om vilken tag som skall
läsas
eda_err = eda_get_one_float(Node, TAGNAMN_CC2(intCC2), Field,
fValue_CC2(intCC2)) 'Läser av statusen i SCADA-DB
If fValue_CC2(intCC2) = 1 And Not cycle_CC2(intCC2) Then
cycle_CC2(intCC2) = True
RunLog ("Customer Care 2 = CC2 " & intCC2 & " aktiv") 'Skriver till
log-fil
'Sänder ut larmet via SENDMAIL
For intCC2Tel = 1 To intAntCC2
LogToSentWindow (Now & " " & TelNrCC2(intCC2Tel) & " " &
TextCC2(intCC2))
'temp_CC2(intCC2Tel) = Shell("d:\Mail\Sendmail /I /" &
TelNrCC2(intCC2Tel) & " /" & TextCC2(intCC2))
'Wait 0.6
Next intCC2Tel
ElseIf fValue_CC2(intCC2) = 0 Then
cycle_CC2(intCC2) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
LogToErrorWindow ("CC2 " & ErrorText)
Next intCC2
LogToPrioWindow (Now & " Customer Care Lina 2 STOPP")
''************* SLUT SCANNING LARM TILL CC-LINE 2 *************
'
'
''************* START SCANNING LARM TILL Trim 1 ************
LogToPrioWindow (Now & " Trim 1 START")
For intBT1 = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BT1(intBT1) = "BT1_SMS" & intBT1 'Talar om vilken tag som skall
läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BT1(intBT1), Field,
fValue_BT1(intBT1)) 'Läser av statusen i SCADA-DB
If fValue_BT1(intBT1) = 1 And Not cycle_BT1(intBT1) Then
cycle_BT1(intBT1) = True
RunLog ("Trim 1 = BT1 " & intBT1 & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBT1Tel = 1 To intAntBT1
LogToSentWindow (Now & " " & TelNrBT1(intBT1Tel) & " " &
TextBT1(intBT1))
'temp_BT1(intBT1Tel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBT1(intBT1Tel) & " /" & TextBT1(intBT1))
'Wait 0.6
Next intBT1Tel
ElseIf fValue_BT1(intBT1) = 0 Then
cycle_BT1(intBT1) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText & "BT1"
LogToErrorWindow ("Trim 1 " & ErrorText)
Next intBT1
LogToPrioWindow (Now & " Trim 1 STOPP")
''************* SLUT SCANNING LARM TILL Trim 1 *************
''************* START SCANNING LARM TILL Trim 2 ************
LogToPrioWindow (Now & " Trim 2 START")
For intBT2 = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BT2(intBT2) = "BT2_SMS" & intBT2 'Talar om vilken tag som skall
läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BT2(intBT2), Field,
fValue_BT2(intBT2)) 'Läser av statusen i SCADA-DB
If fValue_BT2(intBT2) = 1 And Not cycle_BT2(intBT2) Then
cycle_BT2(intBT2) = True
RunLog ("Trim 1 = BT2 " & intBT2 & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBT2Tel = 1 To intAntBT2
LogToSentWindow (Now & " " & TelNrBT2(intBT2Tel) & " " &
TextBT2(intBT2))
'temp_BT2(intBT2Tel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBT2(intBT2Tel) & " /" & TextBT2(intBT2))
'Wait 0.6
Next intBT2Tel
ElseIf fValue_BT2(intBT2) = 0 Then
cycle_BT2(intBT2) = False
LogToErrorWindow ("Trim 2 " & ErrorText)
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
Next intBT2
LogToPrioWindow (Now & " Trim 2 STOPP")
''************* SLUT SCANNING LARM TILL Trim 2 *************
''************* START SCANNING LARM TILL Ergo 1 ************
LogToPrioWindow (Now & " Ergo 1 START")
For intBER1 = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BER1(intBER1) = "BER1_SMS" & intBER1 'Talar om vilken tag som
skall läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BER1(intBER1), Field,
fValue_BER1(intBER1)) 'Läser av statusen i SCADA-DB
If fValue_BER1(intBER1) = 1 And Not cycle_BER1(intBER1) Then
cycle_BER1(intBER1) = True
RunLog ("Ergo 1 = BER1 " & intBER1 & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBER1Tel = 1 To intAntBER1
LogToSentWindow (Now & " " & TelNrBER1(intBER1Tel) & " " &
TextBER1(intBER1))
'temp_BER1(intBER1Tel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBER1(intBER1Tel) & " /" & TextBER1(intBER1))
'Wait 0.6
Next intBER1Tel
ElseIf fValue_BER1(intBER1) = 0 Then
cycle_BER1(intBER1) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
LogToErrorWindow ("Ergo 1 " & ErrorText)
Next intBER1
LogToPrioWindow (Now & " Ergo 1 STOPP")
''************* SLUT SCANNING LARM TILL Ergo 1 *************
''************* START SCANNING LARM TILL Ergo 2 ************
LogToPrioWindow (Now & " Ergo 2 START")
For intBER2 = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BER2(intBER2) = "BER2_SMS" & intBER2 'Talar om vilken tag som
skall läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BER2(intBER2), Field,
fValue_BER2(intBER2)) 'Läser av statusen i SCADA-DB
If fValue_BER2(intBER2) = 1 And Not cycle_BER2(intBER2) Then
cycle_BER2(intBER2) = True
RunLog ("Ergo 1 = BER2 " & intBER2 & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBER2Tel = 1 To intAntBER2
LogToSentWindow (Now & " " & TelNrBER2(intBER2Tel) & " " &
TextBER2(intBER2))
'temp_BER2(intBER2Tel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBER2(intBER2Tel) & " /" & TextBER2(intBER2))
'Wait 0.6
Next intBER2Tel
ElseIf fValue_BER2(intBER2) = 0 Then
cycle_BER2(intBER2) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
LogToErrorWindow ("Ergo 2 " & ErrorText)
Next intBER2
LogToPrioWindow (Now & " Ergo 2 STOPP")
''************* SLUT SCANNING LARM TILL Ergo 2 *************
''************* START SCANNING LARM TILL Over-Head ************
LogToPrioWindow (Now & " Over-Head START")
For intBOH = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BOH(intBOH) = "BOH_SMS" & intBOH 'Talar om vilken tag som skall
läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BOH(intBOH), Field,
fValue_BOH(intBOH)) 'Läser av statusen i SCADA-DB
If fValue_BOH(intBOH) = 1 And Not cycle_BOH(intBOH) Then
cycle_BOH(intBOH) = True
RunLog ("Ergo 1 = BOH " & intBOH & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBOHTel = 1 To intAntBOH
LogToSentWindow (Now & " " & TelNrBOH(intBOHTel) & " " &
TextBOH(intBOH))
'temp_BOH(intBOHTel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBOH(intBOHTel) & " /" & TextBOH(intBOH))
'Wait 0.6
Next intBOHTel
ElseIf fValue_BOH(intBOH) = 0 Then
cycle_BOH(intBOH) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
LogToErrorWindow ("Over-Head " & ErrorText)
Next intBOH
LogToPrioWindow (Now & " Over-Head STOPP")
''************* SLUT SCANNING LARM TILL Over-Head *************
''************* START SCANNING LARM TILL DressUp ************
LogToPrioWindow (Now & " DressUp START")
For intBDU = 1 To 16 'Antal larm som skall läsas av per system
TAGNAMN_BDU(intBDU) = "BDU_SMS" & intBDU 'Talar om vilken tag som skall
läsas
eda_err = eda_get_one_float(Node, TAGNAMN_BDU(intBDU), Field,
fValue_BDU(intBDU)) 'Läser av statusen i SCADA-DB
If fValue_BDU(intBDU) = 1 And Not cycle_BDU(intBDU) Then
cycle_BDU(intBDU) = True
RunLog ("DressUpp = BDU " & intBDU & " aktiv") 'Skriver till log-fil
'Sänder ut larmet via SENDMAIL
For intBDUTel = 1 To intAntBDU
LogToSentWindow (Now & " " & TelNrBDU(intBDUTel) & " " &
TextBDU(intBDU))
'temp_BDU(intBDUTel) = Shell("d:\Mail\Sendmail /I /" &
TelNrBDU(intBDUTel) & " /" & TextBDU(intBDU))
'Wait 0.6
Next intBDUTel
ElseIf fValue_BDU(intBDU) = 0 Then
cycle_BDU(intBDU) = False
End If
Call NlsGetText(eda_err, ErrorText, 79)
Label7.Caption = ErrorText
LogToErrorWindow ("DressUp " & ErrorText)
Next intBDU
LogToPrioWindow (Now & " DressUp STOPP")
''************* SLUT SCANNING LARM TILL DressUp *************
End Sub
Archived from group: microsoft>public>vb>syntax