初始化提交
仓库转移到Gitea,初始化提交,可能丢失以前的git版本日志
This commit is contained in:
31
AUTS_DataService/UtsGroup/ServiceGroup.vb
Normal file
31
AUTS_DataService/UtsGroup/ServiceGroup.vb
Normal file
@@ -0,0 +1,31 @@
|
||||
Public Class ServiceGroup
|
||||
Sub New()
|
||||
'Fileds = New Dictionary(Of String, String)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 当前服务所属子网组
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property ServiceGroup As String
|
||||
|
||||
''' <summary>
|
||||
''' 当前服务索引
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property ServiceIndex As Integer
|
||||
|
||||
''' <summary>
|
||||
''' 当前命令类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Type As String
|
||||
|
||||
''' <summary>
|
||||
''' 当前包号
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Index As Integer
|
||||
|
||||
Public Property GroupInfo As New Dictionary(Of String, String)
|
||||
End Class
|
||||
116
AUTS_DataService/UtsGroup/ServiceGroupManager.vb
Normal file
116
AUTS_DataService/UtsGroup/ServiceGroupManager.vb
Normal file
@@ -0,0 +1,116 @@
|
||||
Imports System.Text
|
||||
|
||||
Public Class ServiceGroupManager
|
||||
''' <summary>历史通讯数据服务集合</summary>
|
||||
Private _groupService As Dictionary(Of Integer, OtherService)
|
||||
|
||||
Sub New()
|
||||
_groupService = New Dictionary(Of Integer, OtherService)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 添加网上邻居,已存在则更新存活时间与状态
|
||||
''' </summary>
|
||||
''' <param name="other"></param>
|
||||
Public Sub Add(other As OtherService)
|
||||
If _groupService.ContainsKey(other.ServiceIndex) Then
|
||||
_groupService(other.ServiceIndex).LastTime = Now
|
||||
_groupService(other.ServiceIndex).IsAlive = True
|
||||
Else
|
||||
_groupService.Add(other.ServiceIndex, other)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 校验其他服务的当前发送包索引是否与上一包索引重复,相同返回True,不相同返回False
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function CheckServiceSendIndex(serviceId As Integer, sendId As Integer) As Boolean
|
||||
If _groupService.ContainsKey(serviceId) Then
|
||||
If _groupService(serviceId).LastPacketIndex = sendId Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 校验服务是否存活
|
||||
''' </summary>
|
||||
Public Sub CheckAliveService()
|
||||
For Each other As KeyValuePair(Of Integer, OtherService) In _groupService
|
||||
If (Now - other.Value.LastTime).TotalSeconds > 30 Then
|
||||
other.Value.IsAlive = False
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 获取存活状态的所有网上邻居的索引字符串,以逗号分割
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function GetAliveServiceIndexString() As String
|
||||
'排序后输出
|
||||
Dim sb As New StringBuilder
|
||||
Dim bt() As Integer = _groupService.Keys.ToArray()
|
||||
Array.Sort(bt)
|
||||
For i As Integer = 0 To bt.Length - 1
|
||||
If _groupService(bt(i)).IsAlive = False Then Continue For
|
||||
If sb.Length = 0 Then
|
||||
sb.Append(bt(i))
|
||||
Else
|
||||
sb.Append("," & bt(i))
|
||||
End If
|
||||
Next
|
||||
|
||||
Return sb.ToString
|
||||
|
||||
|
||||
'原来的顺序输出
|
||||
'For Each other As KeyValuePair(Of Integer, OtherService) In _groupService
|
||||
' If other.Value.IsAlive = False Then Continue For
|
||||
' If sb.Length = 0 Then
|
||||
' sb.Append(other.Key)
|
||||
' Else
|
||||
' sb.Append("," & other.Key)
|
||||
' End If
|
||||
'Next
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
Public Class OtherService
|
||||
Sub New(index As Integer, packetIndex As Integer)
|
||||
ServiceIndex = index
|
||||
LastPacketIndex = packetIndex
|
||||
LastTime = Now
|
||||
IsAlive = True
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 最后通讯时间
|
||||
''' </summary>
|
||||
Public Property LastTime As DateTime
|
||||
|
||||
''' <summary>
|
||||
''' 最后通讯包ID
|
||||
''' </summary>
|
||||
Public Property LastPacketIndex As Integer
|
||||
|
||||
''' <summary>
|
||||
''' 服务索引
|
||||
''' </summary>
|
||||
Public Property ServiceIndex As Integer
|
||||
|
||||
''' <summary>
|
||||
''' 是否判定为在线
|
||||
''' </summary>
|
||||
Public Property IsAlive As Boolean
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user