Public MustInherit Class ClsBaseAnimCom
    Implements IAnimCom


    Private mFileAttente As AnimateurModbus

    Private mState As IAnimCom.EState


    Protected Sub New()
        mFileAttente = New AnimateurModbus
    End Sub


    Public Sub CheckLockAdd(ByVal pFrame As SendingFrame) Implements IAnimateur.CheckLockAdd
        mFileAttente.CheckLockAdd(pFrame)
    End Sub

    Public Sub CheckLockRmv(ByVal pFrame As SendingFrame) Implements IAnimateur.CheckLockRmv
        mFileAttente.CheckLockRmv(pFrame)
    End Sub

    Public Sub ClearCyclic(ByVal pSlave As Integer) Implements IAnimateur.ClearCyclic
        mFileAttente.ClearCyclic(pSlave)
    End Sub

    Public Sub ClearNonCyclic(ByVal pSlave As Integer) Implements IAnimateur.ClearNonCyclic
        mFileAttente.ClearNonCyclic(pSlave)
    End Sub

    Public Sub CyclicAdd(ByVal pFrame As SendingFrame) Implements IAnimateur.CyclicAdd
        mFileAttente.CyclicAdd(pFrame)
    End Sub

    Public Sub CyclicAdd(ByVal pFrame() As SendingFrame) Implements IAnimateur.CyclicAdd
        mFileAttente.CyclicAdd(pFrame)
    End Sub

    Public ReadOnly Property GetFrameCyclicCount() As Integer(,) Implements IAnimateur.GetFrameCyclicCount
        Get
            Return mFileAttente.GetFrameCyclicCount
        End Get
    End Property

    Public ReadOnly Property GetFrameCyclicCount(ByVal pSlave As Integer) As Integer Implements IAnimateur.GetFrameCyclicCount
        Get
            Return mFileAttente.GetFrameCyclicCount(pSlave)
        End Get
    End Property

    Public ReadOnly Property GetFrameNonCyclicCount() As Integer(,) Implements IAnimateur.GetFrameNonCyclicCount
        Get
            Return mFileAttente.GetFrameNonCyclicCount
        End Get
    End Property

    Public ReadOnly Property GetFrameNonCyclicCount(ByVal pSlave As Integer) As Integer Implements IAnimateur.GetFrameNonCyclicCount
        Get
            Return mFileAttente.GetFrameNonCyclicCount(pSlave)
        End Get
    End Property

    Public Function GetNextFrame() As SendingFrame Implements IAnimateur.GetNextFrame
        Return mFileAttente.GetNextFrame
    End Function

    Public Sub NonCyclicAdd(ByVal pFrame As SendingFrame, ByVal pPriority As Integer) Implements IAnimateur.NonCyclicAdd
        mFileAttente.NonCyclicAdd(pFrame, pPriority)
    End Sub

    Public Sub NonCyclicAdd(ByVal pFrame() As SendingFrame, ByVal pPriority As Integer) Implements IAnimateur.NonCyclicAdd
        mFileAttente.NonCyclicAdd(pFrame, pPriority)
    End Sub

    Public ReadOnly Property UserBlockedCyclics() As Integer() Implements IAnimateur.UserBlockedCyclics
        Get
            Return mFileAttente.UserBlockedCyclics
        End Get
    End Property

    Public Property UserBlockedCyclics(ByVal pNumSlave As Integer) As Boolean Implements IAnimateur.UserBlockedCyclics
        Get
            Return mFileAttente.UserBlockedCyclics(pNumSlave)
        End Get
        Set(ByVal value As Boolean)
            mFileAttente.UserBlockedCyclics(pNumSlave) = value
        End Set
    End Property

    Public ReadOnly Property UserBlockedNonCyclics() As Integer() Implements IAnimateur.UserBlockedNonCyclics
        Get
            Return mFileAttente.UserBlockedNonCyclics
        End Get
    End Property

    Public Property UserBlockedNonCyclics(ByVal pNumSlave As Integer) As Boolean Implements IAnimateur.UserBlockedNonCyclics
        Get
            Return mFileAttente.UserBlockedNonCyclics(pNumSlave)
        End Get
        Set(ByVal value As Boolean)
            mFileAttente.UserBlockedNonCyclics(pNumSlave) = value
        End Set
    End Property

    Public Overridable Sub Close() Implements IAnimCom.Close
        mState = IAnimCom.EState.NotConnectedConnectable
        Try
            RaiseEvent StopConnexion(Me)
        Catch ex As Exception
#If DEBUG Then
            Stop
#End If
        End Try
    End Sub

    Public MustOverride ReadOnly Property ConnexionType() As IAnimCom.EConnexType Implements IAnimCom.ConnexionType

    Public Overridable Function Open() As Boolean Implements IAnimCom.Open
        mFileAttente = New AnimateurModbus
        mState = IAnimCom.EState.AutoConnect Or IAnimCom.EState.NotConnectedConnectable
        Try
            RaiseEvent StartConnexion(Me)
        Catch ex As Exception
#If DEBUG Then
            Stop
#End If
        End Try
        Return True
    End Function

    Public Event ReStartConnexion(ByVal pSender As IAnimCom) Implements IAnimCom.ReStartConnexion

    Public Event StartConnexion(ByVal pSender As IAnimCom) Implements IAnimCom.StartConnexion

    Protected Sub RestartedConnexion()
        Try
            RaiseEvent ReStartConnexion(Me)
        Catch ex As Exception
#If DEBUG Then
            Stop
#End If
        End Try
    End Sub

    Public ReadOnly Property State() As IAnimCom.EState Implements IAnimCom.State
        Get
            Return mState
        End Get
    End Property

    Protected Sub SetState(ByVal pState As IAnimCom.EState)
        mState = pState
    End Sub

    Public Event StopConnexion(ByVal pSender As IAnimCom) Implements IAnimCom.StopConnexion

    Public MustOverride ReadOnly Property StringParam() As String Implements IAnimCom.StringParam

    Public Event LooseConnexion(ByVal pSender As IAnimCom) Implements IAnimCom.LooseConnexion

    Protected Sub LostConnexion()
        Try
            RaiseEvent LooseConnexion(Me)
        Catch ex As Exception
#If DEBUG Then
            Stop
#End If
        End Try
    End Sub
End Class
