Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Intermittent delays in BT communication

Community Beginner ,
Mar 15, 2014 Mar 15, 2014

Hi,

I've posted this in general discussions but no luck, I was told I might get better help here so here goes:

I'm playing with a bridgetalk script to pass just one argument back and forth between PS and AI all run from Bridge, this in the future will be a key driver to the main script, I have all the components of PS scripts and AI scripts ready, now working on the workflow order. Due to asynchronous behavior I have to do it in this manner. Basically Bridge selects multiple folders containing multiple files and based on the type sends it either to AI or PS for processing then comes back goes to the next file and so on. I want it to process only one file at a time, raise the counter by one return it as a result and onResult continue on with a main function.

The script I'm testing does it until the counter =10

Here it is:

It all works fine, but WHY am I getting time delays so different to each other. One time script will take 3 seconds, other times over a minute and it's not even performing any tasks in AI or PS:

here's my results:

Start

Got  0 from PS, passing it to AI

Result: undefined

Got  1 from AI, passing it to PS

Got  2 from PS, passing it to AI

Got  3 from AI, passing it to PS

Got  4 from PS, passing it to AI

Got  5 from AI, passing it to PS

Got  6 from PS, passing it to AI

Got  7 from AI, passing it to PS

Got  8 from PS, passing it to AI

Got  9 from AI, passing it to PS

Done

10 documents opened in 3.50 seconds

Start

Got  0 from PS, passing it to AI

Result: undefined

Got  1 from AI, passing it to PS

Got  2 from PS, passing it to AI

Got  3 from AI, passing it to PS

Got  4 from PS, passing it to AI

Got  5 from AI, passing it to PS

Got  6 from PS, passing it to AI

Got  7 from AI, passing it to PS

Got  8 from PS, passing it to AI

Got  9 from AI, passing it to PS

Done

10 documents opened in 101.85 seconds

the code is as follows:

////////////////////////////////

#target bridge;

$.hiresTimer; // start timer

$.writeln("Start");

var counter = 0;

function lastFunction(counter){

if(counter>=10){

    var time = $.hiresTimer/1000000;

     $.writeln("Done");

     $.writeln(counter+" documents opened in " + time.toFixed(2) + " seconds" );

    }else{

        $.writeln( "Got  " + counter +" from PS, passing it to AI");

         infoFromPS(counter);

        }

    }

lastFunction(counter);

function infoFromPS(counter) {

        var bt = new BridgeTalk();

        bt.target = "Illustrator";

      

        bt.body = "ai("+counter+");";

        bt.body += ai.toString();

      

        bt.onResult = function( msg ) {

         //   BridgeTalk.bringToFront("bridge");

                var myResult = msg.body;

              

                doSomethingNow( myResult );

        }

        bt.send();

        }

       

        function ai(counter){

          

        counter ++;

        return counter;

        }

        function doSomethingNow( counter ) {

                $.writeln( "Got  " + counter +" from AI, passing it to PS");

                infoFromAI(counter);

        }

        function infoFromAI(counter) {

           

                var bt = new BridgeTalk();

                bt.target = "Photoshop";

              

                bt.body = "ps("+counter+");";

                bt.body += ps.toString();

              

         //     $.writeln(bt.body);

                bt.onResult = function( msg ) {

                 //   BridgeTalk.bringToFront("bridge");

                        var myResult2 = msg.body;

                     

                        lastFunction(myResult2);

                      

                }

                bt.send();

        }

        function ps(counter){

          

        counter ++;

        return counter;

        }

In functions ai() and ps() I will be passing a lot of code that's why I do it as a function and pass it to BTalk this way.

Any Ideas?

I have changed a few things and number of callbacks to 20 and this is what I get:

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.19 s

Got  2 from PS, passing it to AI - 0.20 s

Got  3 from AI, passing it to PS - 0.60 s

Got  4 from PS, passing it to AI - 0.10 s

Got  5 from AI, passing it to PS - 0.60 s

Got  6 from PS, passing it to AI - 0.10 s

Got  7 from AI, passing it to PS - 0.70 s

Got  8 from PS, passing it to AI - 0.10 s

Got  9 from AI, passing it to PS - 0.60 s

Got  10 from PS, passing it to AI - 0.20 s

Got  11 from AI, passing it to PS - 0.60 s

Got  12 from PS, passing it to AI - 0.20 s

Got  13 from AI, passing it to PS - 0.50 s

Got  14 from PS, passing it to AI - 0.10 s

Got  15 from AI, passing it to PS - 0.70 s

Got  16 from PS, passing it to AI - 0.10 s

Got  17 from AI, passing it to PS - 0.60 s

Got  18 from PS, passing it to AI - 0.20 s

Got  19 from AI, passing it to PS - 0.60 s

Done! 20 documents opened in 7.09 seconds

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.16 s

Got  2 from PS, passing it to AI - 0.10 s

Got  3 from AI, passing it to PS - 0.60 s

Got  4 from PS, passing it to AI - 9.10 s

Got  5 from AI, passing it to PS - 1.40 s

Got  6 from PS, passing it to AI - 0.30 s

Got  7 from AI, passing it to PS - 0.40 s

Got  8 from PS, passing it to AI - 0.20 s

Got  9 from AI, passing it to PS - 0.60 s

Got  10 from PS, passing it to AI - 0.20 s

Got  11 from AI, passing it to PS - 0.50 s

Got  12 from PS, passing it to AI - 0.20 s

Got  13 from AI, passing it to PS - 0.60 s

Got  14 from PS, passing it to AI - 0.60 s

Got  15 from AI, passing it to PS - 0.60 s

Got  16 from PS, passing it to AI - 0.10 s

Got  17 from AI, passing it to PS - 0.70 s

Got  18 from PS, passing it to AI - 10.00 s

Got  19 from AI, passing it to PS - 3.60 s

Done! 20 documents opened in 30.26 seconds

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.21 s

Got  2 from PS, passing it to AI - 0.17 s

Got  3 from AI, passing it to PS - 0.60 s

Got  4 from PS, passing it to AI - 10.00 s

Got  5 from AI, passing it to PS - 10.00 s

Got  6 from PS, passing it to AI - 30.20 s

Got  7 from AI, passing it to PS - 2.39 s

Got  8 from PS, passing it to AI - 10.09 s

Got  9 from AI, passing it to PS - 10.02 s

Got  10 from PS, passing it to AI - 10.18 s

Got  11 from AI, passing it to PS - 10.06 s

Got  12 from PS, passing it to AI - 10.06 s

Got  13 from AI, passing it to PS - 10.17 s

Got  14 from PS, passing it to AI - 20.13 s

Got  15 from AI, passing it to PS - 10.07 s

Got  16 from PS, passing it to AI - 20.11 s

Got  17 from AI, passing it to PS - 20.22 s

Got  18 from PS, passing it to AI - 10.10 s

Got  19 from AI, passing it to PS - 10.10 s

Done! 20 documents opened in 214.92 seconds

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 9.90 s

Got  2 from PS, passing it to AI - 10.10 s

Got  3 from AI, passing it to PS - 6.20 s

Got  4 from PS, passing it to AI - 1.00 s

Got  5 from AI, passing it to PS - 3.10 s

Got  6 from PS, passing it to AI - 1.90 s

Got  7 from AI, passing it to PS - 10.00 s

Got  8 from PS, passing it to AI - 10.10 s

Got  9 from AI, passing it to PS - 9.98 s

Got  10 from PS, passing it to AI - 20.12 s

Got  11 from AI, passing it to PS - 8.91 s

Got  12 from PS, passing it to AI - 10.09 s

Got  13 from AI, passing it to PS - 1.39 s

Got  14 from PS, passing it to AI - 0.12 s

Got  15 from AI, passing it to PS - 0.60 s

Got  16 from PS, passing it to AI - 0.20 s

Got  17 from AI, passing it to PS - 4.18 s

Got  18 from PS, passing it to AI - 0.12 s

Got  19 from AI, passing it to PS - 0.50 s

Done! 20 documents opened in 108.61 seconds

I'm puzzled really, it's running on a reasonably quick i7.

after the restart of Bridge I get:

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.80 s

Got  2 from PS, passing it to AI - 0.20 s

Got  3 from AI, passing it to PS - 0.60 s

Got  4 from PS, passing it to AI - 0.20 s

Got  5 from AI, passing it to PS - 0.50 s

Got  6 from PS, passing it to AI - 0.20 s

Got  7 from AI, passing it to PS - 0.60 s

Got  8 from PS, passing it to AI - 0.20 s

Got  9 from AI, passing it to PS - 0.50 s

Got  10 from PS, passing it to AI - 0.30 s

Got  11 from AI, passing it to PS - 0.40 s

Got  12 from PS, passing it to AI - 0.20 s

Got  13 from AI, passing it to PS - 0.60 s

Got  14 from PS, passing it to AI - 0.20 s

Got  15 from AI, passing it to PS - 0.50 s

Got  16 from PS, passing it to AI - 0.20 s

Got  17 from AI, passing it to PS - 0.60 s

Got  18 from PS, passing it to AI - 0.10 s

Got  19 from AI, passing it to PS - 0.60 s

Done! 20 documents opened in 7.7 seconds

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.40 s

Got  2 from PS, passing it to AI - 0.20 s

Got  3 from AI, passing it to PS - 0.60 s

Got  4 from PS, passing it to AI - 0.10 s

Got  5 from AI, passing it to PS - 0.60 s

Got  6 from PS, passing it to AI - 0.30 s

Got  7 from AI, passing it to PS - 0.50 s

Got  8 from PS, passing it to AI - 0.10 s

Got  9 from AI, passing it to PS - 0.60 s

Got  10 from PS, passing it to AI - 0.20 s

Got  11 from AI, passing it to PS - 0.60 s

Got  12 from PS, passing it to AI - 0.30 s

Got  13 from AI, passing it to PS - 0.40 s

Got  14 from PS, passing it to AI - 0.30 s

Got  15 from AI, passing it to PS - 0.50 s

Got  16 from PS, passing it to AI - 0.10 s

Got  17 from AI, passing it to PS - 0.60 s

Got  18 from PS, passing it to AI - 0.10 s

Got  19 from AI, passing it to PS - 0.70 s

Done! 20 documents opened in 7.4 seconds

Start

Got  0 from PS, passing it to AI - 0.00 s

Result: undefined

Got  1 from AI, passing it to PS - 0.60 s

Got  2 from PS, passing it to AI - 0.30 s

Got  3 from AI, passing it to PS - 0.50 s

Got  4 from PS, passing it to AI - 0.10 s

Got  5 from AI, passing it to PS - 0.60 s

Got  6 from PS, passing it to AI - 0.20 s

Got  7 from AI, passing it to PS - 0.60 s

Got  8 from PS, passing it to AI - 0.30 s

Got  9 from AI, passing it to PS - 0.40 s

Got  10 from PS, passing it to AI - 0.20 s

Got  11 from AI, passing it to PS - 0.60 s

Got  12 from PS, passing it to AI - 0.30 s

Got  13 from AI, passing it to PS - 0.40 s

Got  14 from PS, passing it to AI - 0.20 s

Got  15 from AI, passing it to PS - 0.60 s

Got  16 from PS, passing it to AI - 0.20 s

Got  17 from AI, passing it to PS - 0.50 s

Got  18 from PS, passing it to AI - 0.20 s

Got  19 from AI, passing it to PS - 0.60 s

Done! 20 documents opened in 7.6 seconds

Do I need a cleanup code of some sort?

TOPICS
Scripting
532
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 07, 2014 Apr 07, 2014
LATEST

What happens if you just use Photoshop or just use AI. I am wondering if this makes a difference trying to traffic between both. The other thing I notice is that if i am looking at a large number of photos at the same time there is a longer lag in the time it takes to get to photoshop. Once I am there photoshop rolls fine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines