How i can set the auto print symenteneously 3-4 prints on epson tm-m30 printer

342 Views Asked by At

How I can set the auto print symenteneously 3-4 prints on Epson TM-m30 printer. Here is my code please check and provide the solution. if I remove the time delay this code will break and if I set the time delay then it's working...!!

It's continuously connect & disconnect the printer. this is the common process for the do connection and print the receipt.

1) initializing

2) connecting

3) printing

4) disconnecting & clear buffer

I have noticed that one printer can't connect with multiple Ipads or multiple devices, And our requirement is that we have to connect with multiple devices.

So, is there any way to set a queue to manage multiple requests?

NSArray *arr=[[NSArray alloc]initWithObjects:@"1",@"2", nil];
                    [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)
                    {
                        if (idx==0)
                        {
                            [self runPrintReceiptSequence];
                        }
                        else
                        {
                            [self performSelector:@selector(runPrintReceiptSequence) withObject:nil afterDelay:1.5];
                        }
                    }];

        - (BOOL)runPrintReceiptSequence
        {
            _textWarnings.text = @"";

            if (![self initializeObject]) {
                return NO;
            }

            if (![self createReceiptData]) {
                [self finalizeObject];
                return NO;
            }

            if (![self printData]) {
                [self finalizeObject];
                return NO;
            }

            return YES;
        }

    - (void) onPtrReceive:(Epos2Printer *)printerObj code:(int)code status:(Epos2PrinterStatusInfo *)status printJobId:(NSString *)printJobId
    {
        [ShowMsg showResult:code errMsg:[self makeErrorMessage:status]];

        [self dispPrinterWarnings:status];
        [self updateButtonState:YES];

        [self performSelectorInBackground:@selector(disconnectPrinter) withObject:nil];
    }
1

There are 1 best solutions below

1
k.bour On

I fix this issue by a queue that regulates the execution of operations using the NSOperationQueue with maxConcurrentOperationCount = 1.

but this solution make a delay between printing operations. so now, I search solution to print (multiple) without any delay. Any suggestions ? Regards.