Ios 提高核心图的性能

Ios 提高核心图的性能,ios,xcode,ipad,plot,core-plot,Ios,Xcode,Ipad,Plot,Core Plot,我正在使用CorePlot库绘制实时心电图。当它在iPad air中使用时,性能还可以。但是当我使用iPad mini尝试时,绘制延迟。我已经使用了collapseLayer,也使用了。这并没有解决我的问题。有人能为此提出新的解决方案吗 我的代码如下: -(void)newData:(NSTimer *)theTimer { for (int i =0;i<plotcount;i++){ if([Qrrch0 count]>0 || [Qrrch1 cou

我正在使用CorePlot库绘制实时心电图。当它在iPad air中使用时,性能还可以。但是当我使用iPad mini尝试时,绘制延迟。我已经使用了collapseLayer,也使用了。这并没有解决我的问题。有人能为此提出新的解决方案吗

我的代码如下:

-(void)newData:(NSTimer *)theTimer
{

    for (int i =0;i<plotcount;i++){

        if([Qrrch0 count]>0 || [Qrrch1 count]>0 || [Qrrch2 count]>0 || [Qrrch3 count]>0 || [Qrrspo2 count]>0 ){

            if(g1==1 && thePlot){

                currentIndex ++;
            }
            if(g2==1 && thePlot1){
                currentIndex1 ++;
            }
            if(g3==1 && thePlot2){
                currentIndex2 ++;
            }
            if(g4==1 && thePlot3){
                currentIndex3 ++;
            }
            if(spo2==1 && thePlot4){
                currentIndex4 ++;
            }

            if(arrayIndex>=kchannel1-1)
            {
                arrayIndex=0;
            }

            if(arrayIndex1>=kchannel2-1)
            {
                arrayIndex1=0;
            }
            if(arrayIndex>=kchannel1-1)
            {
                arrayIndex=0;
            }
            if(arrayIndex2>=kchannel3-1)
            {
                arrayIndex2=0;
            }

            if(arrayIndex3>=kchannel4-1)
            {
                arrayIndex3=0;
            }

            if(arrayIndex4>=kchannel5-1)
            {
                arrayIndex4=0;
            }




            if(g1==1 && thePlot){
                 currentIndex5++;
                if(currentIndex5>=kchannel1)
                {
                    if(arrayIndex==0)
                    {
                        [thePlot reloadDataInIndexRange:NSMakeRange(arrayIndex, arrayIndex)];
                    }else{
                  [thePlot deleteDataInIndexRange:NSMakeRange(arrayIndex, 1)];


                    }
                }
                if([Qrrch0 count]!=0)
                {

                    arrPlot[arrayIndex]=[[Qrrch0 objectAtIndex:0] integerValue];

                    lastPlot0=[Qrrch0 objectAtIndex:0];

                }else{
                    arrPlot[arrayIndex]=[lastPlot0 integerValue];

                }
                   arrayIndex++;
            }
            if(g2==1 && thePlot1){
                currentIndex6++;
                if(currentIndex6>=kchannel2)
                {
                    if(arrayIndex1==0)
                    {
                        [thePlot1 reloadDataInIndexRange:NSMakeRange(arrayIndex1, arrayIndex1)];
                    }else{
                        [thePlot1 deleteDataInIndexRange:NSMakeRange(arrayIndex1, 1)];
                    }

                }
                if([Qrrch1 count]!=0)
                {


                    arrPlot1[arrayIndex1]=[[Qrrch1 objectAtIndex:0] integerValue];

                    lastPlot1=[Qrrch1 objectAtIndex:0];

                }else{
                    arrPlot1[arrayIndex1]=[lastPlot1 integerValue];

                }
                arrayIndex1++;

            }
            if(g3==1 && thePlot2){
                currentIndex7++;

                if(currentIndex7>=kchannel3)
                {
                    if(arrayIndex2==0)
                    {
                        [thePlot2 reloadDataInIndexRange:NSMakeRange(arrayIndex2, arrayIndex2)];
                    }else{
                        [thePlot2 deleteDataInIndexRange:NSMakeRange(arrayIndex2, 1)];
                    }

                }
                if([Qrrch2 count]!=0)
                {

                    arrPlot2[arrayIndex2]=[[Qrrch2 objectAtIndex:0] integerValue];
                    lastPlot2=[Qrrch2 objectAtIndex:0];

                }else{
                    arrPlot2[arrayIndex2]=[lastPlot2 integerValue];
                                   }
                   arrayIndex2++;
            }
            if(g4==1 && thePlot3){
                currentIndex8++;

                if(currentIndex8>=kchannel4)
                {
                    if(arrayIndex3==0)
                    {
                        [thePlot3 reloadDataInIndexRange:NSMakeRange(arrayIndex3, arrayIndex3)];
                    }else{
                        [thePlot3 deleteDataInIndexRange:NSMakeRange(arrayIndex3, 1)];
                    }

                }

                if([Qrrch3 count]!=0)
                {

                    arrPlot3[arrayIndex3]=[[Qrrch3 objectAtIndex:0] integerValue];
                    lastPlot3=[Qrrch3 objectAtIndex:0];

                }else{
                    arrPlot3[arrayIndex3]=[lastPlot3 integerValue];
                                   }
                arrayIndex3++;
            }
            if(spo2==1 && thePlot4){
                 currentIndex9++;
                if(currentIndex9>=kchannel5)
                {
                    if(arrayIndex4==0)
                    {
                        [thePlot4 reloadDataInIndexRange:NSMakeRange(arrayIndex4, arrayIndex4)];
                    }else{
                        [thePlot4 deleteDataInIndexRange:NSMakeRange(arrayIndex4, 1)];
                    }

                }
                if([Qrrspo2 count]!=0)
                {

                    arrPlot4[arrayIndex4]=[[Qrrspo2 objectAtIndex:0] integerValue];

                    lastPlot4=[Qrrspo2 objectAtIndex:0];

                }else{
                    arrPlot4[arrayIndex4]=[lastPlot4 integerValue];


                }
                arrayIndex4++;
            }

            if(g1==1 && thePlot){
                if([Qrrch0 count]!=0)
                {
                    [Qrrch0 removeObjectAtIndex:0];
                }
                if(currentIndex>=kchannel1)
                {
                currentIndex=1;
                                     }
                   [thePlot   insertDataAtIndex:currentIndex-1 numberOfRecords:1];
            }
            if(g2==1 && thePlot1){
                if([Qrrch1 count]!=0)
                {
                    [Qrrch1 removeObjectAtIndex:0];
                }

                if(currentIndex1>=kchannel2)
                {
                    currentIndex1=1;

                }
                    [thePlot1   insertDataAtIndex:currentIndex1-1 numberOfRecords:1];
                }
            if(g3==1 && thePlot2){

                if([Qrrch2 count]!=0)
                {
                    [Qrrch2 removeObjectAtIndex:0];
                }
                if(currentIndex2>=kchannel3)
                {
                    currentIndex2=1;
            }
                    [thePlot2   insertDataAtIndex:currentIndex2-1 numberOfRecords:1];
            }

            if(g4==1 && thePlot3){
                if([Qrrch3 count]!=0)
                {
                    [Qrrch3 removeObjectAtIndex:0];
                }
                if(currentIndex3>=kchannel4)
                {
                    currentIndex3=1;
                }
                [thePlot3   insertDataAtIndex:currentIndex3-1 numberOfRecords:1];

            }

            if(spo2==1 && thePlot4){
                if([Qrrspo2 count]!=0)
                {
                    [Qrrspo2 removeObjectAtIndex:0];
                }
                if(currentIndex4>=kchannel5)
                {
                    currentIndex4=1;
                }
                [thePlot4   insertDataAtIndex:currentIndex4-1 numberOfRecords:1];

            }

                   }
        else
        {

            [self datacha];


        }
    }

}


-(void) datacha{
    NSArray *array;
    if([FinalArray count]>0){

        if(g1==1 && thePlot){
            array = [[NSArray alloc] initWithArray:[FinalArray objectAtIndex:0]];
            [Qrrch0 addObjectsFromArray:array];
        }
        if(g1==1 && thePlot){
            [FinalArray removeObjectAtIndex:0];
        }
    }
    if([FinalArray1 count]>0){
        if(g2==1 && thePlot1){
            array = [[NSArray alloc] initWithArray:[FinalArray1 objectAtIndex:0]];
            [Qrrch1 addObjectsFromArray:array];
        }
        if(g2==1 && thePlot1){
            [FinalArray1 removeObjectAtIndex:0];
        }
    }
    if([FinalArray2 count]>0){
        if(g3==1 && thePlot2){

            array = [[NSArray alloc] initWithArray:[FinalArray2 objectAtIndex:0]];
            [Qrrch2 addObjectsFromArray:array];
        }
        if(g3==1 && thePlot2){
            [FinalArray2 removeObjectAtIndex:0];
        }
    } if([FinalArray3 count]>0){
        if(g4==1 && thePlot3){
            array = [[NSArray alloc] initWithArray:[FinalArray3 objectAtIndex:0]];
            [Qrrch3 addObjectsFromArray:array];
        }
        if(g4==1 && thePlot3){
            [FinalArray3 removeObjectAtIndex:0];
        }
    }
    if([FinalArray4 count]>0){
        if(spo2==1 && thePlot4){
            array = [[NSArray alloc] initWithArray:[FinalArray4 objectAtIndex:0]];
            [Qrrspo2 addObjectsFromArray:array];
        }
        if(spo2==1 && thePlot4){
            [FinalArray4 removeObjectAtIndex:0];
        }
    }
}

#pragma mark -
#pragma mark Plot Data Source Methods


-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{

    if(plot == thePlot)
    {
        if(currentIndex5>=kchannel1)
        {
            return kchannel1;
        }else{
        return currentIndex5;
        }
    }

    if(plot == thePlot1)
    {
        if(currentIndex6>=kchannel2)
        {
            return kchannel2;
        }else{
            return currentIndex6;
        }
    }

    if(plot == thePlot2)
    {
        if(currentIndex7>=kchannel3)
        {
            return kchannel3;
        }else{
            return currentIndex7;
        }
    }

    if(plot == thePlot3)
    {
        if(currentIndex8>=kchannel4)
        {
            return kchannel4;
        }else{
            return currentIndex8;
        }
    }

    if(plot == thePlot4)
    {
        if(currentIndex9>=kchannel5)
        {
            return kchannel5;
        }else{
            return currentIndex9;
        }
    }

    return 0;
}



-(double)doubleForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx{

    double num;

    NSString *textval = [NSString stringWithFormat:@"%d", countofpktloss];
    self.losscount.text = textval;

    switch ( fieldEnum ) {

        case CPTScatterPlotFieldX:
            if(plot == thePlot){
                num =currentIndex;
            }
                        else if(plot == thePlot1)
                        {

                            num = currentIndex1;

                        }
                        else if(plot == thePlot2)
                        {

                            num = currentIndex2;

                        }
                        else if(plot == thePlot3)
                        {

                            num = currentIndex3;

                        }

                        else if(plot == thePlot4)
                        {

                            num = currentIndex4;

                        }

            break;

        case CPTScatterPlotFieldY:
            if(plot == thePlot){

                num =arrPlot[idx];

            }

                        else
                    if(plot == thePlot1){

                        num =arrPlot1[idx];


                        }
                        else if(plot == thePlot2){

                            num =arrPlot2[idx];


                        }
                        else if(plot == thePlot3)
                        {
                            num =arrPlot3[idx];


                        }

                        else if(plot == thePlot4)
                        {
                             num =arrPlot4[idx];

                        }

            break;

        default:
            break;

    }

    return num;
}
-(void)新数据:(NSTimer*)计时器
{
对于(int i=0;i0 | | |[Qrrch1计数]>0 | |[Qrrch2计数]>0 | |[Qrrch3计数]>0 | |[Qrrspo2计数]>0){
如果(g1==1&&T批){
currentIndex++;
}
如果(g2==1&&1){
currentIndex1++;
}
如果(g3==1&&2){
currentIndex2++;
}
如果(g4==1&&3){
currentIndex3++;
}
如果(spo2==1&&thePlot4){
currentIndex4++;
}
if(阵列索引>=kchannel1-1)
{
arrayIndex=0;
}
if(阵列索引1>=kchannel2-1)
{
arrayIndex1=0;
}
if(阵列索引>=kchannel1-1)
{
arrayIndex=0;
}
if(阵列索引2>=kchannel3-1)
{
arrayIndex2=0;
}
if(阵列索引3>=kchannel4-1)
{
arrayIndex3=0;
}
如果(阵列索引4>=kchannel5-1)
{
arrayIndex4=0;
}
如果(g1==1&&T批){
currentIndex5++;
如果(currentIndex5>=kchannel1)
{
如果(arrayIndex==0)
{
[索引范围中的批重新加载数据:NSMakeRange(arrayIndex,arrayIndex)];
}否则{
[Plot deleteDataInIndexRange:NSMakeRange(arrayIndex,1)];
}
}
如果([Qrrch0计数]!=0)
{
arrPlot[arrayIndex]=[[Qrrch0对象索引:0]整数值];
lastPlot0=[Qrrch0对象索引:0];
}否则{
arrPlot[arrayIndex]=[lastPlot0 integerValue];
}
arrayIndex++;
}
如果(g2==1&&1){
currentIndex6++;
如果(currentIndex6>=kchannel2)
{
if(arrayIndex1==0)
{
[Plot1重新加载IndexRange中的数据:NSMakeRange(arrayIndex1,arrayIndex1)];
}否则{
[Plot1 deleteDataInIndexRange:NSMakeRange(arrayIndex1,1)];
}
}
如果([Qrrch1计数]!=0)
{
arrPlot1[arrayIndex1]=[[Qrrch1 objectAtIndex:0]整数值];
lastPlot1=[Qrrch1对象索引:0];
}否则{
arrPlot1[arrayIndex1]=[lastPlot1 integerValue];
}
arrayIndex1++;
}
如果(g3==1&&2){
currentIndex7++;
如果(currentIndex7>=kchannel3)
{
如果(arrayIndex2==0)
{
[Plot2在索引范围中重新加载数据:NSMakeRange(arrayIndex2,arrayIndex2)];
}否则{
[Plot2 deleteDataInIndexRange:NSMakeRange(arrayIndex2,1)];
}
}
如果([Qrrch2计数]!=0)
{
arrPlot2[arrayIndex2]=[[Qrrch2 objectAtIndex:0]整数值];
lastPlot2=[Qrrch2对象索引:0];
}否则{
arrPlot2[arrayIndex2]=[lastPlot2 integerValue];
}
arrayIndex2++;
}
如果(g4==1&&3){
currentIndex8++;
如果(currentIndex8>=kchannel4)
{
if(arrayIndex3==0)
{
[Lot3在索引范围中重新加载数据:NSMakeRange(ArrayIndex 3,ArrayIndex 3)];
}否则{
[Plot3 deleteDataInIndexRange:NSMakeRange(arrayIndex3,1)];
}
}
如果([Qrrch3计数]!=0)
{
arrPlot3[arrayIndex3]=[[qrch3 objectAtIndex:0]integerValue];
lastPlot3=[Qrrch3对象索引:0];
}否则{
arrPlot3[arrayIndex3]=[lastPlot3 integerValue];
}
arrayIndex3++;
}
如果(spo2==1&&thePlot4){
currentIndex9++;
如果(currentIndex9>=kChannel 5)
{
if(arrayIndex4==0)
{
[Plot4重新加载IndexRange中的数据:NSMakeRange(arrayIndex4,arrayIndex4)];
}否则{
[Plot4 deleteDataInIndexRange:NSMakeRange(arrayIndex4,1)];
}
}
如果([Qrrspo2计数]!=0)
{
arrPlot4[arrayIndex4]=[[Qrrspo2对象索引:0]整数值];
lastPlot4=[Qrrspo2对象索引:0];
}否则{
arrPlot4[arrayIndex4]=[lastPlot4 integerValue];
}
arrayIndex4++;
}
如果(g1==1&&T批){
如果([Qrrch0计数]!=0)
{
[Qrrch0移除对象索引:0];
}
如果(currentIndex>=kchannel1)
{
currentIndex=1;
}
[批次插入数据索引:currentIndex-1记录数:1];
}
如果(g2==1&&1){
如果([Qrrc