Advertisement
Guest User

smoethingbasnda

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. Private Sub tmrCheckMaster_Timer() ''ABL - LOL 25/04/2018
  2. Dim rsMasterCheck As ADODB.Recordset
  3. Set rsMasterCheck = DBA.OpenRecordset("SELECT * FROM HMI_MASTERCHECK WHERE MASTER IS NOT NULL")
  4. If rsMasterCheck.EOF Then
  5. ExecuteSQL ("UPDATE HMI_MASTERCHECK SET MASTER = 1 WHERE ID = " & currMastercheckID) 'I am the new master
  6. currMaster = True
  7. End If
  8. Set rsMasterCheck = Nothing
  9.  
  10. Set rsMasterCheck = DBA.OpenRecordset("SELECT * FROM HMI_MASTERCHECK") 'Locate all dead nodes and remove from the database
  11. While Not rsMasterCheck.EOF
  12. If (((Now() - rsMasterCheck!REFRESHTIME) * 60 * 60 * 24) > mastercheckDeadtime) Then
  13. ExecuteSQL ("DELETE FROM HMI_MASTERCHECK WHERE ID = " & rsMasterCheck!id) 'This node is dead - remove it
  14. End If
  15. rsMasterCheck.MoveNext
  16. Wend
  17.  
  18. Set rsMasterCheck = DBA.OpenRecordset("SELECT DEADTIME FROM HMI_MASTERCHECKCONFIG")
  19. mastercheckDeadtime = rsMasterCheck!DEADTIME 'Update deadtime (not used frequently)
  20. Set rsMasterCheck = Nothing
  21.  
  22. ExecuteSQL ("UPDATE HMI_MASTERCHECK SET REFRESHTIME = TO_DATE('" & Now() & "', 'dd/mm/yyyy hh24:mi:ss') WHERE ID = " & currMastercheckID) 'I am still alive
  23. If currMaster Then
  24. Debug.Print ("I am: " & currMastercheckID & " and I am the master, my update rate is: " & frmMain.tmrCheckMaster.Interval)
  25. Else
  26. Debug.Print ("I am: " & currMastercheckID & " and I am not the master, my update rate is: " & frmMain.tmrCheckMaster.Interval)
  27. End If
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement