Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub tmrCheckMaster_Timer() ''ABL - LOL 25/04/2018
- Dim rsMasterCheck As ADODB.Recordset
- Set rsMasterCheck = DBA.OpenRecordset("SELECT * FROM HMI_MASTERCHECK WHERE MASTER IS NOT NULL")
- If rsMasterCheck.EOF Then
- ExecuteSQL ("UPDATE HMI_MASTERCHECK SET MASTER = 1 WHERE ID = " & currMastercheckID) 'I am the new master
- currMaster = True
- End If
- Set rsMasterCheck = Nothing
- Set rsMasterCheck = DBA.OpenRecordset("SELECT * FROM HMI_MASTERCHECK") 'Locate all dead nodes and remove from the database
- While Not rsMasterCheck.EOF
- If (((Now() - rsMasterCheck!REFRESHTIME) * 60 * 60 * 24) > mastercheckDeadtime) Then
- ExecuteSQL ("DELETE FROM HMI_MASTERCHECK WHERE ID = " & rsMasterCheck!id) 'This node is dead - remove it
- End If
- rsMasterCheck.MoveNext
- Wend
- Set rsMasterCheck = DBA.OpenRecordset("SELECT DEADTIME FROM HMI_MASTERCHECKCONFIG")
- mastercheckDeadtime = rsMasterCheck!DEADTIME 'Update deadtime (not used frequently)
- Set rsMasterCheck = Nothing
- ExecuteSQL ("UPDATE HMI_MASTERCHECK SET REFRESHTIME = TO_DATE('" & Now() & "', 'dd/mm/yyyy hh24:mi:ss') WHERE ID = " & currMastercheckID) 'I am still alive
- If currMaster Then
- Debug.Print ("I am: " & currMastercheckID & " and I am the master, my update rate is: " & frmMain.tmrCheckMaster.Interval)
- Else
- Debug.Print ("I am: " & currMastercheckID & " and I am not the master, my update rate is: " & frmMain.tmrCheckMaster.Interval)
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement