예제 #1
0
    //find the position of the first big tf of the chunk
    private int findTfPosOfChunk(int forStartPos)
    {
        RunPhaseInfo firstRPI = (RunPhaseInfo)list[0];

        if (!firstRPI.IsContact())
        {
            forStartPos++;
        }

        //i will be tf, i-1 will be tc
        int i;

        for (i = forStartPos + 1; i < list.Count; i += 2)
        {
            RunPhaseInfo tcRPI = (RunPhaseInfo)list[i - 1];
            RunPhaseInfo tfRPI = (RunPhaseInfo)list[i];

            LogB.Information(string.Format("at findTfPosOfChunk: i:{0}, tc:{1}, tf:{2}",
                                           i, tcRPI, tfRPI));
            if (tcRPI.Duration + tfRPI.Duration > checkTime)
            {
                LogB.Information("YES!");
                return(i);
            }
        }

        //we are supposed to not arrive here
        return(forStartPos);
    }
예제 #2
0
    /*
     * "Message oneTCAfterTheTf"
     * if in first track there's only one TC, take care because maybe it has been after the TF
     * it can happen because tc will be lower than the margin: 300 ms (checktime) + 1.5 * checktime
     * so first will be the TF, then waiting margin... but TC happens, and then track is processed, track should not include this tf
     */
    private bool oneTCAfterTheTf()
    {
        if (list.Count - startPos != 2)
        {
            return(false);
        }

        RunPhaseInfo first  = (RunPhaseInfo)list[0];
        RunPhaseInfo second = (RunPhaseInfo)list[1];

        //check if firt is TF and second TC
        if (!first.IsContact() && second.IsContact())
        {
            return(true);
        }

        return(false);
    }
예제 #3
0
    private int findTracksInThisChunk(int forStartPos)
    {
        int          tracks   = 0;
        RunPhaseInfo firstRPI = (RunPhaseInfo)list[0];

        if (!firstRPI.IsContact())
        {
            forStartPos++;
        }

        //i will be tf, i-1 will be tc
        for (int i = forStartPos + 1; i < list.Count; i += 2)
        {
            RunPhaseInfo tcRPI = (RunPhaseInfo)list[i - 1];
            RunPhaseInfo tfRPI = (RunPhaseInfo)list[i];

            if (tcRPI.Duration + tfRPI.Duration > checkTime)
            {
                tracks++;
            }
        }

        return(tracks);
    }
예제 #4
0
    public int GetPosOfBiggestTC(bool started)
    {
        LogB.Information(string.Format("startPos at GetPosOfBiggestTC: {0}, started: {1}", startPos, started));
        TrackDoneHasToBeCalledAgain = false;

        //Read below message: "Message oneTCAfterTheTf"
        if (countTCs() == 1 && oneTCAfterTheTf())
        {
            return(startPos + 1);
        }

        double max            = 0;
        int    posBiggest     = 0;
        double lastTcDuration = 0;

        /*
         * first time we need to know if first TC is greater than the others
         * but once started, we care for endings of each track,
         * do not use the first value because it's the TC of previous track
         */
        int forStartPos;

        if (started)
        {
            forStartPos = startPos + 1;
        }
        else
        {
            forStartPos = startPos;
        }

        LogB.Information("forStartPos A: " + forStartPos.ToString());

        int tracks = findTracksInThisChunk(forStartPos);

        LogB.Information("findTracksInThisChunk tracks: " + tracks.ToString());

        //on track starts, maybe there are some tc+tf pairs before the big tf
        //A is the track start
        //B is the big tf, we should find biggest tc after this tf
        // A   __   ___B                      __  ___
        if (tracks >= 1)
        {
            forStartPos = findTfPosOfChunk(forStartPos);
            //note forStartPos has changed and following findTfPosOfChunk will start from this tf
        }

        LogB.Information("forStartPos B: " + forStartPos.ToString());

        //this will be the pos of the tf of second Track if exists
        int forEnds = list.Count;

        if (tracks >= 2)
        {
            forEnds = findTfPosOfChunk(forStartPos);
            TrackDoneHasToBeCalledAgain = true;
        }

        LogB.Information("forEnds: " + forEnds.ToString());

        for (int pos = forStartPos; pos < forEnds; pos++)
        {
            RunPhaseInfo rpi = (RunPhaseInfo)list[pos];

            LogB.Information("rpi: " + rpi.ToString());

            /*
             * record tc duration as lastTcDuration and add to tf duration to see if is greater than checktime
             * this allows to return biggest_tc of one track without messing with next track that maybe is captured
             * this happens because double contacts is eg: 300 and trackDone is calle at 300 * 1,5
             * But then trackDone has to be called again!
             */
            if (rpi.IsContact())
            {
                lastTcDuration = rpi.Duration;
            }

            //record posBiggest position
            if (rpi.IsContact() && rpi.Duration > max)
            {
                max        = rpi.Duration;
                posBiggest = pos;
            }
        }

        return(posBiggest);
    }