为什么我的VBScript代码中的所有方法都不能访问私有变量?

时间:2016-05-26 02:40:45

标签: oop vbscript

我希望有人可以帮我解决Diadem和VBScript的问题

Class TelltaleCycle中,私有变量p_FunctionType首次在Public Property Let TimestampCh(value2let)中进行了修改,然后在Public Property Get HowManyPeriods中进行了访问。虽然此变量应保留Public Property Let TimestampCh(value2let)中写入的值,但在Public Property Get HowManyPeriods中将其读为空。我无法弄清楚这种行为的原因! 在Class BeltminderCycle我做了几乎相同的事情,它按预期工作。

PS:在阅读我的代码时很明显,因为变量名p_FunctionType也在其他类中使用。

Seatbelt_Library.vbs:

Option Explicit  'Forces the explicit declaration of all the variables in a script.

Dim oUDI : Set oUDI = CreateUDI

Class BeltminderCycle

    Private  p_Index
    Private  p_FunctionType
    Private  p_OrderOfThisType
    Private  p_StartTime
    Private  p_EndTime
    Private  p_Duration
    Private p_TelltaleObjIndex
    Private p_ChimeObjIndex

    Dim timestamp_channel_number, amplitude_channel_number

   Private Sub Class_Initialize
        p_Index = 0
        p_FunctionType = ""
        p_OrderOfThisType = 0
        p_StartTime = 0
        p_EndTime = 0
        p_Duration = 0
        p_ChimeObjIndex = 0
        p_TelltaleObjIndex = 0
   End Sub

    Public Property Get Index
    Index = p_Index
    End Property
   Public Property Let Index(value2let)
      p_Index = value2let
   End Property

    Public Property Get FunctionType
        FunctionType = p_FunctionType
    End Property
    Public Property Let FunctionType(value2let)
        p_FunctionType = value2let
    End Property


    Public Property Get OrderOfThisType
        OrderOfThisType = p_OrderOfThisType
    End Property
    Public Property Let OrderOfThisType(value2let)
        p_OrderOfThisType = value2let
    End Property    

    Public Property Get StartTime
        StartTime = p_StartTime
    End Property
    Public Property Let StartTime(value2let)
        p_StartTime = value2let
    End Property

    Public Property Get EndTime
        EndTime = p_EndTime
    End Property
    Public Property Let EndTime(value2let)
        p_EndTime = value2let
    End Property

    Public Property Get Duration
        Duration = p_EndTime - p_StartTime
    End Property

    Public Property Get TelltaleObjIndex
        TelltaleObjIndex = p_TelltaleObjIndex
    End Property
    Public Property Let TelltaleObjIndex(value2let)
        p_TelltaleObjIndex = value2let
    End Property

        Public Property Get ChimeObjIndex
        ChimeObjIndex = p_ChimeObjIndex
    End Property
    Public Property Let ChimeObjIndex(value2let)
        p_ChimeObjIndex = value2let
    End Property


    Public Sub  Reinitialize
        p_Index = null
        p_TimestampCh = null
        p_AmplitudeCh = null
        p_FunctionType = null
        p_OrderOfThisType = null
        p_StartTime = null
        p_EndTime = null
        p_Duration = null
        p_ChimeObjIndex = null
        p_TelltaleObjIndex = null
        End Sub

End Class

Class TelltaleCycle

    Private  p_Index
    Private  p_TimestampCh
    Private  p_AmplitudeCh
    Private  p_FunctionType
    Private  p_OrderOfThisType
    Private  p_StartTime
    Private  p_EndTime
    Private  p_Duration
    Private p_HowManyPeriods
    Dim     Size

    Dim timestamp_channel_number, amplitude_channel_number, PeriodBeginningsTime, PeriodBeginningsAmplitude

  Private Sub Class_Initialize
        p_Index = 0
        p_TimestampCh = ""
        p_AmplitudeCh = ""
        p_FunctionType = ""
        p_OrderOfThisType = 0
        p_StartTime = 0
        p_EndTime = 0
        p_Duration = 0
        p_HowManyPeriods = 0
   End Sub

    Public Property Get Index
    Index = p_Index
    End Property

  Public Property Let Index(value2let)
      p_Index = value2let
   End Property

    Public Property Get TimestampCh
    TimestampCh = p_TimestampCh
    End Property

    Public Property Let TimestampCh(value2let)
        Dim oMyChn, aString
        p_TimestampCh  = value2let
        Set oMyChn = Data.GetChannel(value2let)
        p_TimestampCh = oMyChn.Name 
        aString = Split(oMyChn.Name, "_", -1, 1)
        p_FunctionType = aString(2) & "_" & aString(3)
        p_OrderOfThisType = aString(4)
        p_StartTime = CHDx(1,CNo(value2let))
        p_EndTime = CHDx(ChnLength(value2let),CNo(value2let))
        p_Duration = p_EndTime - p_StartTime        
    End Property

    Public Property Get AmplitudeCh
    AmplitudeCh = p_AmplitudeCh   
    End Property

    Public Property Let AmplitudeCh(value2let)
        Dim oMyChn
        p_AmplitudeCh  = value2let
        Set oMyChn = Data.GetChannel(value2let)
        p_AmplitudeCh = oMyChn.Name
    End Property

    Public Property Get FunctionType
        FunctionType = p_FunctionType
    End Property

    Public Property Get OrderOfThisType
        OrderOfThisType = p_OrderOfThisType
    End Property

    Public Property Get StartTime
        StartTime = p_StartTime
    End Property

    Public Property Get EndTime
        EndTime = p_EndTime
    End Property

    Public Property Get Duration
        Duration = p_Duration
    End Property

    Public Property Get HowManyPeriods

        Dim iLoop, TimeChnLength,PBT,PBA


        Call LogFileWrite("p_FunctionType: " & p_FunctionType)


    If ((p_FunctionType <> "NotFlashing_NA")) Then
      Call ChnDifferentiate("ProcessedChannels/Telltale_Timestamp_" & p_FunctionType & "_" & p_OrderOfThisType,"ProcessedChannels/Telltale_Amplitude_" & p_FunctionType & "_" & p_OrderOfThisType,"ProcessedChannels/DifferentiatedX","ProcessedChannels/DifferentiatedY")
      Call ChnPeakFind("ProcessedChannels/DifferentiatedX","ProcessedChannels/DifferentiatedY","ProcessedChannels/PeakX","ProcessedChannels/PeakY",10000,"Max.Peaks","Amplitude")  
      TimeChnLength = ChnLength(CNo("ProcessedChannels/PeakX"))

       Dim temp 
        reDim PBT(TimeChnLength), PBA(TimeChnLength)
        For iLoop = 1 to TimeChnLength
        PBT(iLoop - 1) = CHDx(iLoop,CNo("ProcessedChannels/PeakX"))
        PBA(iLoop - 1) = PNo(p_TimestampCh,PBT(iLoop - 1))
        temp = PBA(iLoop - 1)
        PBA(iLoop - 1) = CHDx(PBA(iLoop - 1),CNo(p_AmplitudeCh))
      Next

      PeriodBeginningsTime = PBT
      PeriodBeginningsAmplitude = PBA
        HowManyPeriods = Ubound(PeriodBeginningsTime)

      Call ChnDel("ProcessedChannels/DifferentiatedX")
      Call ChnDel("ProcessedChannels/DifferentiatedY")
      Call ChnDel("ProcessedChannels/PeakX")
      Call ChnDel("ProcessedChannels/PeakY")
    End If
    End Property

    Public Sub  Reinitialize
        p_Index = 0
        p_TimestampCh = ""
        p_AmplitudeCh = ""
        p_FunctionType = ""
        p_OrderOfThisType = 0
        p_StartTime = 0
        p_EndTime = 0
        p_Duration = 0
        p_HowManyPeriods = 0
   End Sub

End Class

Class ChimeCycle

    Private  p_Index
    Private  p_TimestampCh
    Private  p_AmplitudeCh
    Private  p_FunctionType
    Private  p_OrderOfThisType
    Private  p_StartTime
    Private  p_EndTime
    Private  p_Duration
    Private p_HowManyPeriods

    Dim timestamp_channel_number, amplitude_channel_number, Periods

   Private Sub Class_Initialize
        p_Index = 0
        p_TimestampCh = ""
        p_AmplitudeCh = ""
        p_FunctionType = ""
        p_OrderOfThisType = 0
        p_StartTime = 0
        p_EndTime = 0
        p_Duration = 0
        p_HowManyPeriods = 0
   End Sub

    Public Property Get Index
    Index = p_Index
    End Property
   Public Property Let Index(value2let)
      p_Index = value2let
   End Property

    Public Property Get TimestampCh
    TimestampCh = p_TimestampCh
    End Property
    Public Property Let TimestampCh(value2let)
        Dim oMyChn, aString, iLoop
        p_TimestampCh  = value2let
        Set oMyChn = Data.GetChannel(value2let)
        p_TimestampCh = oMyChn.Name 
        aString = Split(oMyChn.Name, "_", -1, 1)
        p_FunctionType = aString(2) & "_" & aString(3)
        p_OrderOfThisType = aString(4)
        p_StartTime = CHDx(1,CNO(value2let))
        p_EndTime = CHDx(ChnLength(value2let),CNo(value2let))
        p_Duration = p_EndTime - p_StartTime + 0.030
        Periods = p_Duration/1
    End Property

    Public Property Get AmplitudeCh
    AmplitudeCh = p_AmplitudeCh
    End Property
    Public Property Let AmplitudeCh(value2let)
        Dim oMyChn
        p_AmplitudeCh  = value2let
        Set oMyChn = Data.GetChannel(value2let)
        p_AmplitudeCh = oMyChn.Name
    End Property

    Public Property Get FunctionType
        FunctionType = p_FunctionType
    End Property

    Public Property Get OrderOfThisType
        OrderOfThisType = p_OrderOfThisType
    End Property

    Public Property Get StartTime
        StartTime = p_StartTime
    End Property

    Public Property Get EndTime
        EndTime = p_EndTime
    End Property

    Public Property Get Duration
        Duration = p_Duration
    End Property    

    Public Property Get HowManyPeriods
        HowManyPeriods = Periods
    End Property    

    Public Sub  Reinitialize
        p_Index = 0
        p_TimestampCh = ""
        p_AmplitudeCh = ""
        p_FunctionType = ""
        p_OrderOfThisType = 0
        p_StartTime = 0
        p_EndTime = 0
        p_Duration = 0
        p_HowManyPeriods = 0
   End Sub

End Class

Function GenerateTimestampChn(TimestampChnName,AmplitudeChn,Fs,NewGrp)
    Dim ChannelLength, ret, iLoop

    ChannelLength = ChnLength(AmplitudeChn)
    ret = ChnAlloc(TimestampChnName, ChannelLength, 1, DataTypeFloat64,"Numeric",NewGrp)

    For iLoop = 1 to ChannelLength
        CHD(iLoop,CNo(ret(0))) = iLoop/Fs
    Next

    GenerateTimestampChn = ret(0)

End Function

Function ProcessNoise(AmplitudeChn,TimestampChn,Threshold,NewGrp)
    Dim iLoop, NewChn, L_TimestampChn, L_AmplitudeChn, L_Threshold
    L_TimestampChn  = TimestampChn
    L_AmplitudeChn = AmplitudeChn
    L_Threshold = Threshold

    NewChn=ChnAlloc(ChnName(L_AmplitudeChn) & "_Processed", ChnLength(L_AmplitudeChn), 1, ChnValueDataType(L_AmplitudeChn),"Numeric",NewGrp)
    L_AmplitudeChn = ChnCopy(L_AmplitudeChn,NewChn(0))
    NewChn=ChnAlloc(ChnName(L_TimestampChn) & "_Processed", ChnLength(L_TimestampChn), 1, ChnValueDataType(L_TimestampChn),"Numeric",NewGrp)
    L_TimestampChn = ChnCopy(L_TimestampChn,NewChn(0))

    For iLoop = 1 to ChnLength(L_AmplitudeChn)
        If (CHDx(iLoop,CNo(L_AmplitudeChn))<L_Threshold) Then
            CHDx(iLoop,CNo(L_AmplitudeChn)) = NULL
            CHDx(iLoop,CNo(L_TimestampChn)) = NULL
        End If
    Next

    CHD(iLoop-1,L_AmplitudeChn) = 0
    CHD(iLoop-1,L_TimestampChn) = 0

    Call Portal.Refresh
    Call oUDI.Sleep(100)
    Call ChnNovHandle(L_TimestampChn,L_AmplitudeChn,"Delete","XY",1,0,0)

    NewChn = array(L_TimestampChn,L_AmplitudeChn)
    ProcessNoise = NewChn

End Function

Function IdentifyChime(TimestampChn, AmplitudeChn, ChimesThreshold,NewGrp)

    Dim ChimesCounter, InitialWarningCounter, BeltminderACounter, BeltminderBCounter, UndefinedChimeCounter
    Dim iLoop, iLoop2, max, I
    Dim MyChannels(1), elements(), aux2(), ChnNumber
    Dim Timestamp, Amplitude, AmplitudeChnLength
    Dim InitialWarningThreshold, BeltminderAThreshold, BeltminderBThreshold

    TimestampChn = CNo(TimestampChn)
    AmplitudeChn = CNo(AmplitudeChn)

    InitialWarningCounter = 0
    BeltminderACounter = 0
    BeltminderBCounter = 0
    UndefinedChimeCounter = 0

    InitialWarningThreshold = ChimesThreshold(0)
    BeltminderAThreshold = ChimesThreshold(1)
    BeltminderBThreshold = ChimesThreshold(2)

    AmplitudeChnLength = ChnLength(AmplitudeChn)

    reDim chime(1,AmplitudeChnLength)
    reDim aux(AmplitudeChnLength,1)

    For iLoop = 1 to AmplitudeChnLength

        Call oUDI.Sleep(100)

        max = 0
        iLoop2=0

        If (iLoop<AmplitudeChnLength) Then
        Do 
            Timestamp = CHDx(iLoop,TimestampChn)
            Amplitude = CHDx(iLoop,AmplitudeChn)
            If (Amplitude <> 0) Then
        chime(0,iLoop2) = Timestamp
                chime(1,iLoop2) = Amplitude
                If (Amplitude>max) Then
                    max=Amplitude
                End If
            End If

            iLoop2=iLoop2+1
            iLoop=iLoop+1

        Loop While((iLoop<AmplitudeChnLength) AND ((CHDx(iLoop,TimestampChn)-chime(0,iLoop2-1))<2))

        End If

    If(max>BeltminderBThreshold) Then
        InitialWarningCounter=InitialWarningCounter+1
        MyChannels(0) = "Chime_Timestamp_InitialWarning_NA_" & InitialWarningCounter
        MyChannels(1) = "Chime_Amplitude_InitialWarning_NA_" & InitialWarningCounter
    ElseIf((max<BeltminderBThreshold) AND (max>BeltminderAThreshold)) Then
        BeltminderBCounter=BeltminderBCounter+1 
        MyChannels(0) = "Chime_Timestamp_Beltminder_B_" & BeltminderBCounter
        MyChannels(1) = "Chime_Amplitude_Beltminder_B_" & BeltminderBCounter
    ElseIf(max<BeltminderAThreshold) Then
        BeltminderACounter=BeltminderACounter+1 
        MyChannels(0) = "Chime_Timestamp_Beltminder_A_" & BeltminderACounter
        MyChannels(1) = "Chime_Amplitude_Beltminder_A_" & BeltminderACounter
    Else
        UndefinedChimeCounter=UndefinedChimeCounter+1
        MyChannels(0) = "Chime_Timestamp_UndefinedChimeThreshold_NA_" & UndefinedChimeCounter
        MyChannels(1) = "Chime_Amplitude_UndefinedChimeThreshold_NA_" & UndefinedChimeCounter
    End If

    reDim aux2(1,iLoop2-1)
    For I=0 to Ubound(aux2,2)
        aux2(0,I) = chime(0,I)
        aux2(1,I) = chime(1,I)
    Next
    Erase chime
    reDim chime(1,AmplitudeChnLength)

    ChnNumber = ArrayToChannels(aux2,MyChannels)
    Call ChnMove(ChnNumber(0), NewGrp)
    Call ChnMove(ChnNumber(1), NewGrp)
    ChnNumber(0) = "[" & NewGrp & "]/" & MyChannels(0)
    ChnNumber(1) = "[" & NewGrp & "]/" & MyChannels(1)


    Erase aux2

    ChimesCounter = InitialWarningCounter + BeltminderACounter + BeltminderBCounter + UndefinedChimeCounter

    aux(ChimesCounter-1,0) = ChnNumber(0)
    aux(ChimesCounter-1,1) = ChnNumber(1)

    Next

    reDim elements(ChimesCounter-1,1)

    For I=0 to Ubound(elements)
        elements(I,0) = aux(I,0)
        elements(I,1) = aux(I,1)
    Next

    IdentifyChime = elements 'Returns a channel list as a vector. The return are numbers.

    Erase aux
    Erase elements

End Function

Function IdentifyTelltale(TimestampChn, AmplitudeChn, TelltaleBeltminderAMinPeriodOn, TelltaleBeltminderABMaxPeriodOn,NewGrp)

    Dim TelltalesCounter, NotFlashingCounter, BeltminderACounter, BeltminderBCounter, UndefinedTelltaleCounter
    Dim iLoop, iLoop2, iLoop3, NoChangeLength, diff, I
   Dim Change, NoChange, LastValley, aux2, LastValley2
    Dim MyChannels(1), elements(), ChnNumber, TelltaleLength, Falling, Rising
    Dim Timestamp, Amplitude, AmplitudeChnLength, NoChangeLengthMax

    TimestampChn = CNo(TimestampChn)
    AmplitudeChn = CNo(AmplitudeChn)

    NotFlashingCounter = 0
    BeltminderACounter = 0
    BeltminderBCounter = 0
    UndefinedTelltaleCounter = 0
    NoChangeLengthMax = 0

    AmplitudeChnLength = ChnLength(AmplitudeChn)

    reDim Telltale(1,AmplitudeChnLength)
    reDim cycle(1,AmplitudeChnLength)
    reDim aux(AmplitudeChnLength,1)

    for iLoop3 = 1 to AmplitudeChnLength
   Telltale(0,iLoop3 - 1) = CHDx(iLoop3,TimestampChn)
    Telltale(1,iLoop3 - 1) = CHDx(iLoop3,AmplitudeChn)
    next
    TelltaleLength = Ubound(telltale,2)

    iLoop3 = 0
    Do While (Telltale(1,iLoop3)=0)
    iLoop3=iLoop3+1
    Loop
    iLoop3=iLoop3+1

    For iLoop = iLoop3 to TelltaleLength

        Call oUDI.Sleep(100)

        NoChangeLength = 0
        NoChangeLengthMax = 0 
        Change = 0
        iLoop2 = 0

        If (iLoop < AmplitudeChnLength) Then
            Do While((iLoop < AmplitudeChnLength) AND (Telltale(1,iLoop) = 0))
                iLoop = iLoop + 1
            Loop  
        End If

        If (iLoop < AmplitudeChnLength) Then
            Do  While((iLoop < AmplitudeChnLength) AND (NoChangeLength < (1+0.4)*TelltaleBeltminderABMaxPeriodOn))

                cycle(0,iLoop2) = Telltale(0,iLoop)
                cycle(1,iLoop2) = Telltale(1,iLoop)

               If (iLoop <> 0) Then
                    If (Telltale(1,iLoop - 1) <> Telltale(1,iLoop)) Then
                        Change = Telltale(0,iLoop)
                        LastValley = iLoop2
                        LastValley2 = iLoop
                            If (Telltale(1,iLoop) = 1) Then
                                Rising =  Telltale(0,iLoop)
                            Else
                                Falling =  Telltale(0,iLoop)
                                If (NoChangeLengthMax < (Falling - Rising)) Then
                                    NoChangeLengthMax = Falling - Rising
                                End If
                            End If
                    ElseIf ((Change <> 0) AND (Telltale(1,iLoop - 1) = Telltale(1,iLoop))) Then
                        NoChange = Telltale(0,iLoop)
                        NoChangeLength = NoChange - Change
                    End If
                End If

                iLoop = iLoop + 1
            iLoop2 = iLoop2 + 1     
            Loop 

            aux2 = cycle
            redim preserve aux2(1,LastValley-1)
            iLoop = LastValley2

            If(NoChangeLengthMax > (1+0.4)*TelltaleBeltminderABMaxPeriodOn) Then 'Above 40% of Beltminder A or B maximum period it is considered not flashing state 
                NotFlashingCounter = NotFlashingCounter + 1
                MyChannels(0) = "Telltale_Timestamp_NotFlashing_NA_" & NotFlashingCounter
                MyChannels(1) = "Telltale_Amplitude_NotFlashing_NA_" & NotFlashingCounter
            ElseIf((NoChangeLengthMax > (1-0.1)*TelltaleBeltminderAMinPeriodOn)) Then '10% of error is acceptable
                BeltminderACounter = BeltminderACounter + 1 
                MyChannels(0) = "Telltale_Timestamp_Beltminder_A_" & BeltminderACounter
                MyChannels(1) = "Telltale_Amplitude_Beltminder_A_" & BeltminderACounter
            ElseIf(NoChangeLengthMax < (1-0.1)*TelltaleBeltminderAMinPeriodOn) Then '10% of error is acceptable
                BeltminderBCounter = BeltminderBCounter + 1 
                MyChannels(0) = "Telltale_Timestamp_Beltminder_B_" & BeltminderBCounter
                MyChannels(1) = "Telltale_Amplitude_Beltminder_B_" & BeltminderBCounter
            Else
                UndefinedTelltaleCounter = UndefinedTelltaleCounter + 1
                MyChannels(0) = "Telltale_Timestamp_UndefinedTelltaleThreshold_NA_" & UndefinedTelltaleCounter
                MyChannels(1) = "Telltale_Amplitude_UndefinedTelltaleThreshold_NA_" & UndefinedTelltaleCounter
            End If

            aux2(1,0) = 0      
            aux2(1,Ubound(aux2)) = 0

            ChnNumber = ArrayToChannels(aux2,MyChannels,true)
            Call ChnMove(ChnNumber(0), NewGrp)
            Call ChnMove(ChnNumber(1), NewGrp)
            ChnNumber(0) = "[" & NewGrp & "]/" & MyChannels(0)
            ChnNumber(1) = "[" & NewGrp & "]/" & MyChannels(1)

            TelltalesCounter = NotFlashingCounter + BeltminderACounter + BeltminderBCounter + UndefinedTelltaleCounter

            aux(TelltalesCounter - 1,0) = ChnNumber(0)
            aux(TelltalesCounter - 1,1) = ChnNumber(1)

        End If
    Next

    reDim elements(TelltalesCounter - 1,1)

    For I = 0 to Ubound(elements)
        elements(I,0) = aux(I,0)
        elements(I,1) = aux(I,1)
    Next

    IdentifyTelltale = elements 'Returns a channel list as a vector. The return are numbers.

    Erase aux
    Erase elements

End Function

Function BeltminderFunction(Arg)

Dim ret, iLoop, iLoop2, BeltminderCounter
Dim Fs 'Sample rate (log sample rate = 100Hz)
Dim Threshold 'NoChangeLengthimum noise amplitude
Dim TimestampChn, TimestampChn2, ChimeAmplitudeChn, ProcessedTimestampChn, ProcessedChimeAmplitudeChn, GeneratedChns, NewGrp
Dim TelltaleAmplitudeChn
Dim chime1, telltale
Dim TelltaleBeltminderAMinPeriodOn, TelltaleBeltminderABMaxPeriodOn
Dim ChimesThreshold(3)

Fs = BeltminderFunctionArgs(0)
TimestampChn = BeltminderFunctionArgs(1)
ChimeAmplitudeChn = BeltminderFunctionArgs(2)


NewGrp = GroupIndexGet(GroupCreate("ProcessedChannels"))

TimestampChn = GenerateTimestampChn(TimestampChn,ChimeAmplitudeChn,Fs,NewGrp)
TimestampChn2 = TimestampChn

''''''''''''''''''''''''''''''''''''''''''''''''''
'CHIME PROCESSING
''''''''''''''''''''''''''''''''''''''''''''''''''
Threshold = BeltminderFunctionArgs(3) 
ret = ProcessNoise(ChimeAmplitudeChn,TimestampChn,Threshold,NewGrp)
ProcessedTimestampChn = ret(0)
ProcessedChimeAmplitudeChn = ret(1)

Call oUDI.Sleep(100)

ChimesThreshold(0) = BeltminderFunctionArgs(7) 'Initial warning chime threshold
ChimesThreshold(1) = BeltminderFunctionArgs(8) 'Beltminder A chime threshold
ChimesThreshold(2) = BeltminderFunctionArgs(9) 'Beltminder B chime threshold

GeneratedChns = IdentifyChime(ProcessedTimestampChn,ProcessedChimeAmplitudeChn, ChimesThreshold,NewGrp)

ReDim chime1 (Ubound(GeneratedChns,1))
For iLoop = 0 to Ubound(chime1)
    Set chime1(iLoop) = New ChimeCycle

    chime1(iLoop).Index = iLoop
    chime1(iLoop).TimestampCh = GeneratedChns(iLoop,0)
    chime1(iLoop).AmplitudeCh = GeneratedChns(iLoop,1)
Next
''''''''''''''''''''''''''''''''''''''''''''''''''
'TELLTALE PROCESSING
''''''''''''''''''''''''''''''''''''''''''''''''''
TelltaleAmplitudeChn = BeltminderFunctionArgs(4)
TelltaleBeltminderAMinPeriodOn = BeltminderFunctionArgs(5)
TelltaleBeltminderABMaxPeriodOn = BeltminderFunctionArgs(6)

GeneratedChns = IdentifyTelltale(TimestampChn,TelltaleAmplitudeChn, TelltaleBeltminderAMinPeriodOn, TelltaleBeltminderABMaxPeriodOn,NewGrp)

ReDim telltale1 (Ubound(GeneratedChns,1))
For iLoop = 0 to Ubound(telltale1)
    Set telltale1(iLoop) = New TelltaleCycle

    telltale1(iLoop).Index = iLoop
    telltale1(iLoop).TimestampCh = GeneratedChns(iLoop,0)
    telltale1(iLoop).AmplitudeCh = GeneratedChns(iLoop,1)
Next
''''''''''''''''''''''''''''''''''''''''''''''''''
'BELTMINDER WARNING FUNCTION PROCESSING
''''''''''''''''''''''''''''''''''''''''''''''''''
Dim telltale1_Temp, chime1_Temp, NoFlashingNoChimeOrder
telltale1_Temp = telltale1
chime1_Temp = chime1

BeltminderCounter = 0
NoFlashingNoChimeOrder = 1
For iLoop = 0 to Ubound(telltale1_Temp)
    For iLoop2 = 0 to Ubound(chime1_Temp)

        If((chime1_Temp(iLoop2).FunctionType <> "InitialWarning_NA") AND (telltale1_Temp(iLoop).FunctionType = "NotFlashing_NA")) Then
            ReDim Preserve beltminder1(BeltminderCounter)
            Set beltminder1(BeltminderCounter) = New BeltminderCycle
            beltminder1(BeltminderCounter).Index = BeltminderCounter
            beltminder1(BeltminderCounter).FunctionType = telltale1_Temp(iLoop).FunctionType
            beltminder1(BeltminderCounter).OrderOfThisType = NoFlashingNoChimeOrder
            beltminder1(BeltminderCounter).StartTime = telltale1_Temp(iLoop).StartTime
            beltminder1(BeltminderCounter).EndTime = telltale1_Temp(iLoop).EndTime
            beltminder1(BeltminderCounter).ChimeObjIndex = "N/A"
            beltminder1(BeltminderCounter).TelltaleObjIndex = telltale1_Temp(iLoop).Index
            BeltminderCounter = BeltminderCounter + 1
            NoFlashingNoChimeOrder = NoFlashingNoChimeOrder + 1
            chime1_Temp(iLoop2).Reinitialize
            telltale1_Temp(iLoop).Reinitialize

        End If

        If((chime1_Temp(iLoop2).FunctionType = "InitialWarning_NA") AND (telltale1_Temp(iLoop).FunctionType = "NotFlashing_NA")) Then
            ReDim Preserve beltminder1(BeltminderCounter)
            Set beltminder1(BeltminderCounter) = New BeltminderCycle
            beltminder1(BeltminderCounter).Index = BeltminderCounter
            beltminder1(BeltminderCounter).FunctionType = chime1_Temp(iLoop2).FunctionType
            beltminder1(BeltminderCounter).OrderOfThisType = chime1_Temp(iLoop2).OrderOfThisType
            If(telltale1_Temp(iLoop).StartTime < chime1_Temp(iLoop2).StartTime) Then
                beltminder1(BeltminderCounter).StartTime = telltale1_Temp(iLoop).StartTime  
            Else beltminder1(BeltminderCounter).StartTime = chime1_Temp(iLoop2).StartTime
            End If  
            If(telltale1_Temp(iLoop).EndTime > chime1_Temp(iLoop2).EndTime) Then
                beltminder1(BeltminderCounter).EndTime = telltale1_Temp(iLoop).EndTime
            Else beltminder1(BeltminderCounter).EndTime = chime1_Temp(iLoop2).EndTime
            End If
            beltminder1(BeltminderCounter).ChimeObjIndex = chime1_Temp(iLoop2).Index
            beltminder1(BeltminderCounter).TelltaleObjIndex = telltale1_Temp(iLoop).Index
            BeltminderCounter = BeltminderCounter + 1
            chime1_Temp(iLoop2).Reinitialize
            telltale1_Temp(iLoop).Reinitialize
        End If

        If((telltale1_Temp(iLoop).FunctionType <> "") AND (telltale1_Temp(iLoop).FunctionType = chime1_Temp(iLoop2).FunctionType) AND (telltale1_Temp(iLoop).OrderOfThisType = chime1_Temp(iLoop2).OrderOfThisType)) Then
            ReDim Preserve beltminder1(BeltminderCounter)
            Set beltminder1(BeltminderCounter) = New BeltminderCycle
            beltminder1(BeltminderCounter).Index = BeltminderCounter
            beltminder1(BeltminderCounter).FunctionType = chime1_Temp(iLoop2).FunctionType
            beltminder1(BeltminderCounter).OrderOfThisType = chime1_Temp(iLoop2).OrderOfThisType
            If(telltale1_Temp(iLoop).StartTime < chime1_Temp(iLoop2).StartTime) Then
                beltminder1(BeltminderCounter).StartTime = telltale1_Temp(iLoop).StartTime  
            Else beltminder1(BeltminderCounter).StartTime = chime1_Temp(iLoop2).StartTime
            End If  
            If(telltale1_Temp(iLoop).EndTime > chime1_Temp(iLoop2).EndTime) Then
                beltminder1(BeltminderCounter).EndTime = telltale1_Temp(iLoop).EndTime
            Else beltminder1(BeltminderCounter).EndTime = chime1_Temp(iLoop2).EndTime
            End If
            beltminder1(BeltminderCounter).ChimeObjIndex = chime1_Temp(iLoop2).Index
            beltminder1(BeltminderCounter).TelltaleObjIndex = telltale1_Temp(iLoop).Index
            BeltminderCounter = BeltminderCounter + 1
            chime1_Temp(iLoop2).Reinitialize
            telltale1_Temp(iLoop).Reinitialize
        End IF
    Next
Next

Erase telltale1_Temp
Erase chime1_Temp

'For iLoop2 = 0 to Ubound(beltminder1)
'   Call LogFileWrite( "Index: " & beltminder1(iLoop2).Index & vbCrLf &"FunctionType: " & beltminder1(iLoop2).FunctionType & vbCrLf & "OrderOfThisType: " & beltminder1(iLoop2).OrderOfThisType  & vbCrLf & "StartTime: " & beltminder1(iLoop2).StartTime  & vbCrLf & "EndTime: " & beltminder1(iLoop2).EndTime  & vbCrLf & "Duration: " & beltminder1(iLoop2).Duration  & vbCrLf & "ChimeObjIndex: " & beltminder1(iLoop2).ChimeObjIndex  & vbCrLf & "TelltaleObjIndex: " & beltminder1(iLoop2).TelltaleObjIndex)
'Next

BeltminderFunction = Array (chime1, telltale1, beltminder1,TimestampChn2)

End Function

0 个答案:

没有答案