Attribute VB_Name = "LanRecv"
Option Explicit

'----------------------------------------------------------
'  Function     : UpdateStatus_OK
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub UpdateStatus_OK(ByVal PJIndex As Integer)

    Dim OpCode As Integer
    Dim Value As Integer
    Dim SelectPJIndex As Integer
    
    PJInfo(PJIndex).Status.Disconnect = False
    If (PJInfo(PJIndex).Connection.Kind = 0) Then
        CommTimeoutCount(PJIndex) = 0
    End If
    
    SelectPJIndex = TreePJIndex(MainForm.ProjectorTree.SelectedItem.Index)
    
    OpCode = CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(10)) * 256 + _
             CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(9))
    Value = CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(12)) * 256 + _
            CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(11))
             
    If (OpCode = OP_POWER_STATUS) Then
        Select Case Value
            Case 0
                If (PJInfo(PJIndex).Status.Power = 1) Then
                    PJInfo(PJIndex).Status.Power = 2    'Cooldown
                End If
            Case 1
                If (PJInfo(PJIndex).Status.Power = 0) Then
                    PJInfo(PJIndex).Status.Power = 1
                End If
            Case Else
                PJInfo(PJIndex).Status.Power = -1
        End Select
        Select Case CheckMainFormState
            Case GROUP_STATUS
                Call ShowPowerStatus_Group(PJIndex)
            Case PROJECTOR_STATUS
                If (SelectPJIndex = PJIndex) Then
                    Call ShowPowerStatus_Projector(PJIndex)
                End If
            Case PROJECTOR_CONTROL
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Power
                        Case 0  'Power OFF
                            MainForm.cmbPower(0).ListIndex = 0
                        Case 1  'Power ON
                            MainForm.cmbPower(0).ListIndex = 1
                        Case 2  'Cool Down
                            MainForm.cmbPower(0).ListIndex = 0
                        Case Else
                            MainForm.cmbPower(0).ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
        End Select
    End If
    
End Sub

'----------------------------------------------------------
'  Function     : UpdateStatus_NG
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub UpdateStatus_NG(ByVal PJIndex As Integer, ByVal TimeoutFlag As Boolean)

    Dim OpCode As Integer
    Dim Value As Integer
    Dim SelectPJIndex As Integer
    Dim i As Integer, j As Integer
    Dim tmp1 As String, tmp2 As String
    Dim bFlag As Boolean
    
    If (TimeoutFlag = False) Then
        PJInfo(PJIndex).Status.Disconnect = False
        If (PJInfo(PJIndex).Connection.Kind = 0) Then
            CommTimeoutCount(PJIndex) = 0
        End If
    End If
    
    SelectPJIndex = TreePJIndex(MainForm.ProjectorTree.SelectedItem.Index)
    
    OpCode = CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(10)) * 256 + _
             CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(9))
    Value = CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(12)) * 256 + _
            CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(11))

    If (CheckMainFormState = PROJECTOR_CONTROL) Then
        Select Case OpCode
            Case OP_POWER_STATUS
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Power
                        Case 0  'Power OFF
                            MainForm.cmbPower(0).ListIndex = 0
                        Case 1  'Power ON
                            MainForm.cmbPower(0).ListIndex = 1
                        Case 2  'Cool Down
                            MainForm.cmbPower(0).ListIndex = 0
                        Case Else
                            MainForm.cmbPower(0).ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            
            Case OP_INPUT_SOURCE
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    For i = 1 To ModelInfo.ModelNum
                        If (ModelInfo.Model(i).Name = PJInfo(PJIndex).ModelName) Then
                            For j = 1 To ModelInfo.Model(i).InputNum
                                tmp1 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 1)
                                tmp2 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 2)
                                If (PJInfo(PJIndex).Status.InputSource = Val(tmp1)) Then
                                    MainForm.cmbInputSource.ListIndex = j - 1
                                    bFlag = True
                                    Exit For
                                End If
                            Next j
                            Exit For
                        End If
                    Next i
                    If (bFlag = False) Then
                        MainForm.cmbInputSource.ListIndex = -1
                    End If
                    bOKFlag = False
                End If
            
            Case OP_ASPECT
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    For i = 1 To ModelInfo.ModelNum
                        If (ModelInfo.Model(i).Name = PJInfo(PJIndex).ModelName) Then
                            For j = 1 To ModelInfo.Model(i).AspectNum
                                tmp1 = CutParam(";", ModelInfo.Model(i).AspectDetails(j), 1)
                                tmp2 = CutParam(";", ModelInfo.Model(i).AspectDetails(j), 2)
                                If (PJInfo(PJIndex).Status.Aspect = Val(tmp1)) Then
                                    MainForm.cmbAspect.ListIndex = j - 1
                                    bFlag = True
                                    Exit For
                                End If
                            Next j
                            Exit For
                        End If
                    Next i
                    If (bFlag = False) Then
                        MainForm.cmbAspect.ListIndex = -1
                    End If
                    bOKFlag = False
                End If
            
            Case OP_WHISPER
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Whisper
                        Case 0  'Normal
                            MainForm.cmbWhisper.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbWhisper.ListIndex = 1
                        Case Else
                            MainForm.cmbWhisper.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            
            Case OP_MIRROR
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Mirror
                        Case 0  'Normal
                            MainForm.cmbMirror.ListIndex = 0
                        Case 1  'H Inverse
                            MainForm.cmbMirror.ListIndex = 1
                        Case 2  'V Inverse
                            MainForm.cmbMirror.ListIndex = 2
                        Case 3  'H&V Inverse
                            MainForm.cmbMirror.ListIndex = 3
                        Case Else
                            MainForm.cmbMirror.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            
            Case OP_BLANK
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Blank
                        Case 0  'Normal
                            MainForm.cmbBlank.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbBlank.ListIndex = 1
                        Case Else
                            MainForm.cmbBlank.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            
            Case OP_MUTE
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Mute
                        Case 0  'Normal
                            MainForm.cmbMute.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbMute.ListIndex = 1
                        Case Else
                            MainForm.cmbMute.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            
        End Select
    End If

End Sub

'----------------------------------------------------------
'  Function     : UpdateStatus_GETSTATUS
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub UpdateStatus_GETSTATUS(PJIndex As Integer)

    Dim OpCode As Integer
    Dim Value As Integer
    Dim SelectPJIndex As Integer
    Dim i As Integer, j As Integer
    Dim tmp As String, tmp1 As String, tmp2 As String
    Dim bFlag As Boolean
    Dim tmp3 As Integer
    
    PJInfo(PJIndex).Status.Disconnect = False
    If (PJInfo(PJIndex).Connection.Kind = 0) Then
        CommTimeoutCount(PJIndex) = 0
    End If
    
    SelectPJIndex = TreePJIndex(MainForm.ProjectorTree.SelectedItem.Index)
    
    OpCode = CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(10)) * 256 + _
             CInt(Queue(PJIndex, QueueRP(PJIndex)).SendData(9))
    Value = CInt(Queue(PJIndex, QueueRP(PJIndex)).RecvData(2)) * 256 + _
            CInt(Queue(PJIndex, QueueRP(PJIndex)).RecvData(1))

    Select Case OpCode
        Case OP_POWER_STATUS
            Select Case Value
                Case 0 To 2
                    PJInfo(PJIndex).Status.Power = Value
                Case Else
                    PJInfo(PJIndex).Status.Power = -1
            End Select
            Select Case CheckMainFormState
                Case GROUP_STATUS
                    Call ShowPowerStatus_Group(PJIndex)
                Case PROJECTOR_STATUS
                    If (SelectPJIndex = PJIndex) Then
                        Call ShowPowerStatus_Projector(PJIndex)
                    End If
                Case PROJECTOR_CONTROL
                    If (SelectPJIndex = PJIndex) Then
                        bOKFlag = True
                        Select Case PJInfo(PJIndex).Status.Power
                            Case 0  'Power OFF
                                MainForm.cmbPower(0).ListIndex = 0
                            Case 1  'Power ON
                                MainForm.cmbPower(0).ListIndex = 1
                            Case 2  'Cool Down
                                MainForm.cmbPower(0).ListIndex = 0
                            Case Else
                                MainForm.cmbPower(0).ListIndex = -1
                        End Select
                        bOKFlag = False
                    End If
            End Select
        
        Case OP_INPUT_SOURCE
            Select Case Value
                '##### 2005.01.21 #####
                'Case 0 To 5
                Case 0 To 6
                '##### 2005.01.21 #####
                    PJInfo(PJIndex).Status.InputSource = Value
                Case Else
                    PJInfo(PJIndex).Status.InputSource = -1
            End Select
            Select Case CheckMainFormState
                Case GROUP_STATUS
                    Call ShowInputSourceStatus_Group(PJIndex)
                Case PROJECTOR_STATUS
                    If (SelectPJIndex = PJIndex) Then
                        Call ShowInputSourceStatus_Projector(PJIndex)
                    End If
                Case PROJECTOR_CONTROL
                    If (SelectPJIndex = PJIndex) Then
                        bOKFlag = True
                        For i = 1 To ModelInfo.ModelNum
                            If (ModelInfo.Model(i).Name = PJInfo(PJIndex).ModelName) Then
                                For j = 1 To ModelInfo.Model(i).InputNum
                                    tmp1 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 1)
                                    tmp2 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 2)
                                    If (PJInfo(PJIndex).Status.InputSource = Val(tmp1)) Then
                                        MainForm.cmbInputSource.ListIndex = j - 1
                                        bFlag = True
                                        Exit For
                                    End If
                                Next j
                                Exit For
                            End If
                        Next i
                        If (bFlag = False) Then
                            MainForm.cmbInputSource.ListIndex = -1
                        End If
                        bOKFlag = False
                    End If
            End Select
        
        Case OP_ERROR_STATUS
            Select Case Value
                Case 0  'Normal
                    'szErrorText = "Normal"
                Case 1  'CoverError
                    'szErrorText = "CoverError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.CoverError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.CoverError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 1) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.CoverError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.CoverError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 2  'FanError
                    'szErrorText = "FanError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.FanError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.FanError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 2) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.FanError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.FanError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 3  'LampError
                    'szErrorText = "LampError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.LampError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.LampError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 3) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.LampError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.LampError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 4  'TempError
                    'szErrorText = "TempError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.TempError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.TempError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 4) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.TempError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.TempError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 5  'AirFlowError
                    'szErrorText = "AirFlowError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.AirFlowError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.AirFlowError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 5) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.AirFlowError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.AirFlowError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 6  'LampTimeOver
                    'szErrorText = "LampTimeOver"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.LampTimeOver.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.LampTimeOver.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 6) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.LampTimeOver.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.LampTimeOver.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 7  'CoolError
                    'szErrorText = "CoolError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.CoolError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.CoolError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 7) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.CoolError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.CoolError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 8  'Filter Error
                    'szErrorText = "FilterError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.FilterError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.FilterError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 8) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.FilterError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.FilterError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 9  'OtherError1
                    'szErrorText = "OtherError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.OtherError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.OtherError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 9) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.OtherError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.OtherError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case 16 'OtherError2
                    'szErrorText = "OtherError"
                    If (MailSendKindFlag = 0) Then
                        If (PJInfo(PJIndex).Status.ErrorStatus = 0) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.OtherError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.OtherError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    Else
                        If (PJInfo(PJIndex).Status.ErrorStatus <> 16) Then
                            If (MailInfo.SendFlag = True And MailInfo.ErrorAlarm.SendFlag = True And _
                                MailInfo.ErrorAlarm.OtherError.SendFlag = True) Then
'##### 2004.12.16 #####
                                'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                                tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                                tmp = tmp & ";" & CStr(PJIndex)
                                tmp = tmp & ";" & MailInfo.ErrorAlarm.OtherError.SendText
                                Call SetErrorQueue(tmp)
                                If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                    MailSendRetryCount = 0
                                    Timers.MailSendTimer.Enabled = True
                                End If
                            End If
                        End If
                    End If
                Case Else
                    'szErrorText = ""
            End Select
            Select Case Value
                Case 0 To 9, 16
                    PJInfo(PJIndex).Status.ErrorStatus = Value
                Case Else
                    PJInfo(PJIndex).Status.ErrorStatus = -1
            End Select
            Select Case CheckMainFormState
                Case GROUP_STATUS
                    Call ShowErrorStatus_Group(PJIndex)
                Case PROJECTOR_STATUS
                    If (SelectPJIndex = PJIndex) Then
                        Call ShowErrorStatus_Projector(PJIndex)
                    End If
            End Select
            
        Case OP_LAMP_TIME
            PJInfo(PJIndex).Status.LampTime = Value
            If (Value >= 0) Then
                If (MailInfo.SendFlag = True And MailInfo.LampAlarm.SendFlag = True) Then
                    If (PJInfo(PJIndex).Status.LampTime < MailInfo.LampAlarm.AlarmTime And _
                        Value >= MailInfo.LampAlarm.AlarmTime) Then
'##### 2004.12.16 #####
                            'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                            tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                            tmp = tmp & ";" & CStr(PJIndex)
                            tmp = tmp & ";" & "LampTime Alarm (" & CStr(MailInfo.LampAlarm.AlarmTime) & "h)"
                            Call SetErrorQueue(tmp)
                            If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                MailSendRetryCount = 0
                                Timers.MailSendTimer.Enabled = True
                            End If
                    End If
                End If
            End If
            Select Case CheckMainFormState
                Case GROUP_STATUS
                    Call ShowLampTime_Group(PJIndex)
                Case PROJECTOR_STATUS
                    If (SelectPJIndex = PJIndex) Then
                        Call ShowLampTime_Projector(PJIndex)
                    End If
            End Select
        
        Case OP_FILTER_TIME
            PJInfo(PJIndex).Status.FilterTime = Value
            If (Value >= 0) Then
                If (MailInfo.SendFlag = True And MailInfo.FilterAlarm.SendFlag = True) Then
                    If (PJInfo(PJIndex).Status.FilterTime < MailInfo.FilterAlarm.AlarmTime And _
                        Value >= MailInfo.FilterAlarm.AlarmTime) Then
'##### 2004.12.16 #####
                            'tmp = Format(Now, "yyyy/mm/dd hh:nn:ss")
                            tmp = GetDateTimeString(Now)
'##### 2004.12.16 #####
                            tmp = tmp & ";" & CStr(PJIndex)
                            tmp = tmp & ";" & "FilterTime Alarm (" & CStr(MailInfo.FilterAlarm.AlarmTime) & "h)"
                            Call SetErrorQueue(tmp)
                            If (MailSending = False And Timers.MailSendTimer.Enabled = False) Then
                                MailSendRetryCount = 0
                                Timers.MailSendTimer.Enabled = True
                            End If
                    End If
                End If
            End If
            Select Case CheckMainFormState
                Case GROUP_STATUS
                    Call ShowFilterTime_Group(PJIndex)
                Case PROJECTOR_STATUS
                    If (SelectPJIndex = PJIndex) Then
                        Call ShowFilterTime_Projector(PJIndex)
                    End If
            End Select
        
        Case OP_ASPECT
            Select Case Value
                Case 0 To 7, 16
                    PJInfo(PJIndex).Status.Aspect = Value
                Case Else
                    PJInfo(PJIndex).Status.Aspect = -1
            End Select
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    For i = 1 To ModelInfo.ModelNum
                        If (ModelInfo.Model(i).Name = PJInfo(PJIndex).ModelName) Then
                            For j = 1 To ModelInfo.Model(i).AspectNum
                                tmp1 = CutParam(";", ModelInfo.Model(i).AspectDetails(j), 1)
                                tmp2 = CutParam(";", ModelInfo.Model(i).AspectDetails(j), 2)
                                If (PJInfo(PJIndex).Status.Aspect = Val(tmp1)) Then
                                    MainForm.cmbAspect.ListIndex = j - 1
                                    bFlag = True
                                    Exit For
                                End If
                            Next j
                            Exit For
                        End If
                    Next i
                    If (bFlag = False) Then
                        MainForm.cmbAspect.ListIndex = -1
                    End If
                    bOKFlag = False
                End If
            End If
        
        Case OP_WHISPER
            Select Case Value
                Case 0, 1
                    PJInfo(PJIndex).Status.Whisper = Value
                Case Else
                    PJInfo(PJIndex).Status.Whisper = -1
            End Select
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Whisper
                        Case 0  'Normal
                            MainForm.cmbWhisper.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbWhisper.ListIndex = 1
                        Case Else
                            MainForm.cmbWhisper.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            End If
        
        Case OP_MIRROR
            Select Case Value
                Case 0 To 3
                    PJInfo(PJIndex).Status.Mirror = Value
                Case Else
                    PJInfo(PJIndex).Status.Mirror = -1
            End Select
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Mirror
                        Case 0  'Normal
                            MainForm.cmbMirror.ListIndex = 0
                        Case 1  'H Inverse
                            MainForm.cmbMirror.ListIndex = 1
                        Case 2  'V Inverse
                            MainForm.cmbMirror.ListIndex = 2
                        Case 3  'H&V Inverse
                            MainForm.cmbMirror.ListIndex = 3
                        Case Else
                            MainForm.cmbMirror.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            End If
        
        Case OP_BLANK
            Select Case Value
                Case 0, 1
                    PJInfo(PJIndex).Status.Blank = Value
                Case Else
                    PJInfo(PJIndex).Status.Blank = -1
            End Select
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Blank
                        Case 0  'Normal
                            MainForm.cmbBlank.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbBlank.ListIndex = 1
                        Case Else
                            MainForm.cmbBlank.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            End If
        
        Case OP_MUTE
            Select Case Value
                Case 0, 1
                    PJInfo(PJIndex).Status.Mute = Value
                Case Else
                    PJInfo(PJIndex).Status.Mute = -1
            End Select
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    bOKFlag = True
                    Select Case PJInfo(PJIndex).Status.Mute
                        Case 0  'Normal
                            MainForm.cmbMute.ListIndex = 0
                        Case 1  'Whisper
                            MainForm.cmbMute.ListIndex = 1
                        Case Else
                            MainForm.cmbMute.ListIndex = -1
                    End Select
                    bOKFlag = False
                End If
            End If
        
        Case OP_BRIGHT
            PJInfo(PJIndex).Status.Bright = Value
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    tmp3 = Value - 128
                    If (tmp3 >= 0) Then
                        MainForm.lblBrightValue.Caption = "+" & CStr(tmp3)
                    Else
                        MainForm.lblBrightValue.Caption = CStr(tmp3)
                    End If
                End If
            End If
        
        Case OP_CONTRAST
            PJInfo(PJIndex).Status.Contrast = Value
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    tmp3 = Value - 128
                    If (tmp3 >= 0) Then
                        MainForm.lblContrastValue.Caption = "+" & CStr(tmp3)
                    Else
                        MainForm.lblContrastValue.Caption = CStr(tmp3)
                    End If
                End If
            End If
        
        Case OP_SHARPNESS
            PJInfo(PJIndex).Status.Sharpness = Value
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    tmp3 = Value - 125
                    If (tmp3 >= 0) Then
                        MainForm.lblSharpnessValue.Caption = "+" & CStr(tmp3)
                    Else
                        MainForm.lblSharpnessValue.Caption = CStr(tmp3)
                    End If
                End If
            End If
            
        Case OP_COLOR
            PJInfo(PJIndex).Status.Color = Value
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    tmp3 = Value - 128
                    If (tmp3 >= 0) Then
                        MainForm.lblColorValue.Caption = "+" & CStr(tmp3)
                    Else
                        MainForm.lblColorValue.Caption = CStr(tmp3)
                    End If
                End If
            End If
        
        Case OP_TINT
            PJInfo(PJIndex).Status.Tint = Value
            If (CheckMainFormState = PROJECTOR_CONTROL) Then
                If (SelectPJIndex = PJIndex) Then
                    tmp3 = Value - 128
                    If (tmp3 >= 0) Then
                        MainForm.lblTintValue.Caption = "+" & CStr(tmp3)
                    Else
                        MainForm.lblTintValue.Caption = CStr(tmp3)
                    End If
                End If
            End If
        
        'Case OP_AUTO_ADJUST
    
    End Select

End Sub

'----------------------------------------------------------
'  Function     : ShowPowerStatus_Projector
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowPowerStatus_Projector(ByVal nIndex As Integer)

    'Power
    Select Case PJInfo(nIndex).Status.Power
        Case 0  'Power OFF
            MainForm.lblPowerStatus.Caption = "OFF"
        Case 1  'Power ON
            MainForm.lblPowerStatus.Caption = "ON"
        Case 2  'Cool Down
            MainForm.lblPowerStatus.Caption = "COOLDOWN"
        Case Else
            MainForm.lblPowerStatus.Caption = "-"
    End Select

End Sub

'----------------------------------------------------------
'  Function     : ShowInputSourceStatus_Projector
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowInputSourceStatus_Projector(ByVal nIndex As Integer)

    Dim bFlag As Boolean
    Dim i As Integer, j As Integer
    Dim tmp1 As String, tmp2 As String
    
    bFlag = False
    For i = 1 To ModelInfo.ModelNum
        If (ModelInfo.Model(i).Name = PJInfo(nIndex).ModelName) Then
            For j = 1 To ModelInfo.Model(i).InputNum
                tmp1 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 1)
                tmp2 = CutParam(";", ModelInfo.Model(i).InputDetails(j), 2)
                If (PJInfo(nIndex).Status.InputSource = Val(tmp1)) Then
                    MainForm.lblInputSource.Caption = tmp2
                    bFlag = True
                    Exit For
                End If
            Next j
            Exit For
        End If
    Next i
    If (bFlag = False) Then
        MainForm.lblInputSource.Caption = "-"
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowErrorStatus_Projector
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowErrorStatus_Projector(ByVal nIndex As Integer)

    'Error Statys
    Select Case PJInfo(nIndex).Status.ErrorStatus
        Case 0  'Normal
            MainForm.lblErrorStatus.Caption = "Normal"
        Case 1  'CoverError
            MainForm.lblErrorStatus.Caption = "Cover Error"
        Case 2  'FanError
            MainForm.lblErrorStatus.Caption = "Fan Error"
        Case 3  'LampError
            MainForm.lblErrorStatus.Caption = "Lamp Error"
        Case 4  'TempError
            MainForm.lblErrorStatus.Caption = "Temp Error"
        Case 5  'AirFlowError
            MainForm.lblErrorStatus.Caption = "Air Flow Error"
        Case 6  'LampTimeOver
            MainForm.lblErrorStatus.Caption = "Lamp Time Over"
        Case 7  'CoolError
            MainForm.lblErrorStatus.Caption = "Cool Error"
        Case 8  'FilterError
            MainForm.lblErrorStatus.Caption = "Filter Error"
        Case 9, 16
            MainForm.lblErrorStatus.Caption = "Other Error"
        Case Else
            MainForm.lblErrorStatus.Caption = "-"
    End Select

End Sub

'----------------------------------------------------------
'  Function     : ShowLampTime_Projector
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowLampTime_Projector(ByVal nIndex As Integer)

    'Lamp Time
    If (PJInfo(nIndex).Status.LampTime >= 0) Then
        MainForm.lblLampTime.Caption = CStr(PJInfo(nIndex).Status.LampTime) & " h"
    Else
        MainForm.lblLampTime.Caption = "-"
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowFilterTime_Projector
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowFilterTime_Projector(ByVal nIndex As Integer)

    'Filter Time
    If (PJInfo(nIndex).Status.FilterTime >= 0) Then
        MainForm.lblFilterTime.Caption = CStr(PJInfo(nIndex).Status.FilterTime) & " h"
    Else
        MainForm.lblFilterTime.Caption = "-"
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowPowerStatus_Group
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowPowerStatus_Group(ByVal PJIndex As Integer)

    On Error Resume Next
    
    Dim nIndex As Integer
    Dim FirstIndex As Integer
    Dim LastIndex As Integer
    Dim i As Integer
    Dim ListIndex As Integer

    ListIndex = 0
    FirstIndex = 0: LastIndex = 0
    FirstIndex = MainForm.ProjectorTree.SelectedItem.Child.FirstSibling.Index
    LastIndex = MainForm.ProjectorTree.SelectedItem.Child.LastSibling.Index
                
    If Not (FirstIndex = 0 And LastIndex = 0) Then
        For i = FirstIndex To LastIndex
            If (MainForm.ProjectorTree.SelectedItem.Key = MainForm.ProjectorTree.Nodes(i).Parent.Key) Then
                ListIndex = ListIndex + 1
                If (TreePJIndex(i) = PJIndex) Then
                    'Power
                    Select Case PJInfo(PJIndex).Status.Power
                        Case 0  'Power OFF
                            MainForm.ListView1.ListItems(ListIndex).SubItems(3) = "OFF"
                        Case 1  'Power ON
                            MainForm.ListView1.ListItems(ListIndex).SubItems(3) = "ON"
                        Case 2  'Cool Down
                            MainForm.ListView1.ListItems(ListIndex).SubItems(3) = "COOLDOWN"
                        Case Else
                            MainForm.ListView1.ListItems(ListIndex).SubItems(3) = "-"
                    End Select
                    If (PJInfo(PJIndex).Connection.Kind = 1) Then
                        If (MainForm.ListView1.ListItems(ListIndex).SubItems(2) = "" And _
                           PJInfo(PJIndex).Connection.Network.MACAddress <> "") Then
                           MainForm.ListView1.ListItems(ListIndex).SubItems(2) = PJInfo(PJIndex).Connection.Network.MACAddress
                        End If
                    End If
                End If
            End If
        Next i
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowInputSourceStatus_Group
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowInputSourceStatus_Group(ByVal PJIndex As Integer)

    On Error Resume Next
    
    Dim nIndex As Integer
    Dim FirstIndex As Integer
    Dim LastIndex As Integer
    Dim i As Integer, j As Integer, k As Integer
    Dim ListIndex As Integer
    Dim bFlag As Boolean
    Dim tmp1 As String, tmp2 As String

    ListIndex = 0
    FirstIndex = 0: LastIndex = 0
    FirstIndex = MainForm.ProjectorTree.SelectedItem.Child.FirstSibling.Index
    LastIndex = MainForm.ProjectorTree.SelectedItem.Child.LastSibling.Index
                
    Dim nInputNum As Integer
    
    If Not (FirstIndex = 0 And LastIndex = 0) Then
        For i = FirstIndex To LastIndex
            If (MainForm.ProjectorTree.SelectedItem.Key = MainForm.ProjectorTree.Nodes(i).Parent.Key) Then
                ListIndex = ListIndex + 1
                If (TreePJIndex(i) = PJIndex) Then
                    bFlag = False
                    For j = 1 To ModelInfo.ModelNum
                        If (ModelInfo.Model(j).Name = PJInfo(PJIndex).ModelName) Then
                            For k = 1 To ModelInfo.Model(j).InputNum
                                tmp1 = CutParam(";", ModelInfo.Model(j).InputDetails(k), 1)
                                tmp2 = CutParam(";", ModelInfo.Model(j).InputDetails(k), 2)
                                If (PJInfo(PJIndex).Status.InputSource = Val(tmp1)) Then
                                    MainForm.ListView1.ListItems(ListIndex).SubItems(4) = tmp2
                                    bFlag = True
                                    Exit For
                                End If
                            Next k
                            Exit For
                        End If
                    Next j
                    If (bFlag = False) Then
                        MainForm.ListView1.ListItems(ListIndex).SubItems(4) = "-"
                    End If
                    If (PJInfo(PJIndex).Connection.Kind = 1) Then
                        If (MainForm.ListView1.ListItems(ListIndex).SubItems(2) = "" And _
                           PJInfo(PJIndex).Connection.Network.MACAddress <> "") Then
                           MainForm.ListView1.ListItems(ListIndex).SubItems(2) = PJInfo(PJIndex).Connection.Network.MACAddress
                        End If
                    End If
                End If
            End If
        Next i
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowErrorStatus_Group
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowErrorStatus_Group(ByVal PJIndex As Integer)

    On Error Resume Next
    
    Dim nIndex As Integer
    Dim FirstIndex As Integer
    Dim LastIndex As Integer
    Dim i As Integer
    Dim ListIndex As Integer
    
    ListIndex = 0
    FirstIndex = 0: LastIndex = 0
    FirstIndex = MainForm.ProjectorTree.SelectedItem.Child.FirstSibling.Index
    LastIndex = MainForm.ProjectorTree.SelectedItem.Child.LastSibling.Index
    
    If Not (FirstIndex = 0 And LastIndex = 0) Then
        For i = FirstIndex To LastIndex
            If (MainForm.ProjectorTree.SelectedItem.Key = MainForm.ProjectorTree.Nodes(i).Parent.Key) Then
                ListIndex = ListIndex + 1
                If (TreePJIndex(i) = PJIndex) Then
                    'Error Status
                    If (PJInfo(PJIndex).Status.Disconnect = False) Then
                        Select Case PJInfo(PJIndex).Status.ErrorStatus
                            Case 0  'Normal
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Normal"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &H80000008
                            Case 1  'CoverError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Cover Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 2  'FanError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Fan Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 3  'LampError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Lamp Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 4  'TempError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Temp Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 5  'AirFlowError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Air Flow Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 6  'LampTimeOver
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Lamp Time Over"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 7  'CoolError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Cool Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 8  'FilterError
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Filter Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case 9, 16  'Other Error
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Other Error"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                            Case Else
                                MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "-"
                                MainForm.ListView1.ListItems(ListIndex).ForeColor = &H80000008
                        End Select
                        If (PJInfo(PJIndex).Connection.Kind = 1) Then
                            If (MainForm.ListView1.ListItems(ListIndex).SubItems(2) = "" And _
                               PJInfo(PJIndex).Connection.Network.MACAddress <> "") Then
                               MainForm.ListView1.ListItems(ListIndex).SubItems(2) = PJInfo(PJIndex).Connection.Network.MACAddress
                            End If
                        End If
                    Else
                        MainForm.ListView1.ListItems(ListIndex).SubItems(5) = "Disconnect"
                        MainForm.ListView1.ListItems(ListIndex).ForeColor = &HFF&
                    End If
                End If
            End If
        Next i
    End If
    
End Sub

'----------------------------------------------------------
'  Function     : ShowLampTime_Group
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowLampTime_Group(ByVal PJIndex As Integer)

    On Error Resume Next
    
    Dim FirstIndex As Integer
    Dim LastIndex As Integer
    Dim i As Integer
    Dim ListIndex As Integer

    ListIndex = 0
    FirstIndex = 0: LastIndex = 0
    FirstIndex = MainForm.ProjectorTree.SelectedItem.Child.FirstSibling.Index
    LastIndex = MainForm.ProjectorTree.SelectedItem.Child.LastSibling.Index

    If Not (FirstIndex = 0 And LastIndex = 0) Then
        For i = FirstIndex To LastIndex
            If (MainForm.ProjectorTree.SelectedItem.Key = MainForm.ProjectorTree.Nodes(i).Parent.Key) Then
                ListIndex = ListIndex + 1
                If (TreePJIndex(i) = PJIndex) Then
                    'Lamp Time
                    If (PJInfo(PJIndex).Status.LampTime <> -1) Then
                        MainForm.ListView1.ListItems(ListIndex).SubItems(6) = CStr(PJInfo(PJIndex).Status.LampTime) & " h"
                    Else
                        MainForm.ListView1.ListItems(ListIndex).SubItems(6) = "-"
                    End If
                    If (PJInfo(PJIndex).Connection.Kind = 1) Then
                        If (MainForm.ListView1.ListItems(ListIndex).SubItems(2) = "" And _
                           PJInfo(PJIndex).Connection.Network.MACAddress <> "") Then
                           MainForm.ListView1.ListItems(ListIndex).SubItems(2) = PJInfo(PJIndex).Connection.Network.MACAddress
                        End If
                    End If
                End If
            End If
        Next i
    End If

End Sub

'----------------------------------------------------------
'  Function     : ShowFilterTime_Group
'  Return value :
'  Argument     :
'  Feature      :
'  Description  :
'  Remarks      :
'----------------------------------------------------------
Sub ShowFilterTime_Group(ByVal PJIndex As Integer)

    On Error Resume Next

    Dim FirstIndex As Integer
    Dim LastIndex As Integer
    Dim i As Integer
    Dim ListIndex As Integer

    ListIndex = 0
    FirstIndex = 0: LastIndex = 0
    FirstIndex = MainForm.ProjectorTree.SelectedItem.Child.FirstSibling.Index
    LastIndex = MainForm.ProjectorTree.SelectedItem.Child.LastSibling.Index

    If Not (FirstIndex = 0 And LastIndex = 0) Then
        For i = FirstIndex To LastIndex
            If (MainForm.ProjectorTree.SelectedItem.Key = MainForm.ProjectorTree.Nodes(i).Parent.Key) Then
                ListIndex = ListIndex + 1
                If (TreePJIndex(i) = PJIndex) Then
                    'Filter Time
                    If (PJInfo(PJIndex).Status.FilterTime <> -1) Then
                        MainForm.ListView1.ListItems(ListIndex).SubItems(7) = CStr(PJInfo(PJIndex).Status.FilterTime) & " h"
                    Else
                        MainForm.ListView1.ListItems(ListIndex).SubItems(7) = "-"
                    End If
                    If (PJInfo(PJIndex).Connection.Kind = 1) Then
                        If (MainForm.ListView1.ListItems(ListIndex).SubItems(2) = "" And _
                           PJInfo(PJIndex).Connection.Network.MACAddress <> "") Then
                           MainForm.ListView1.ListItems(ListIndex).SubItems(2) = PJInfo(PJIndex).Connection.Network.MACAddress
                        End If
                    End If
                End If
            End If
        Next i
    End If

End Sub

