Skip to Content
It is currently October 22nd, 2014, 10:45 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: February 2nd, 2013, 8:54 am 
Offline
Junior User
Junior User

Joined: January 17th, 2013, 12:22 pm
Posts: 37
Is it necessary to STOP one PAL script before executing another? Using ES to start first PAL, then at specified ES day/time, I'm starting a new PAL script. Does the second PAL script override the first, or should the second PAL script have a first lines that clears the queue and stops the first PAL script? If so, how does that look?
TIA,
John


Top
 Profile  
 
PostPosted: February 2nd, 2013, 9:07 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 5911
Location: Aachen (Germany)
Neither nor.
PAL scripts run independently but in parallel.
Start PAL A that adds a song to the queue every even hour.
Start PAL B that adds a song to the queue evry odd hour.
They don't override one another, but you will see a song in the Queue every hour (even from A, odd from B)

If you need to stop a PAL, you either have to do that by hand or you need to make sure the PAL ends by itself at the time you want it.
There is no way to automatically stop a PAL from outside.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Problems/Questions | Sourcecode


Top
 Profile  
 
PostPosted: February 2nd, 2013, 9:10 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 9986
Location: Denver, CO
..What he said said, however it is possible for one PAL to write a "flag" to the database and have another PAL check it it and then act accordingly upon the results like stopping itself..

_________________
- Rob Oyler
- Spacial Volunteer Support (SVS)
Smooth Contemporary Jazz Channel:
Image


Top
 Profile  
 
PostPosted: February 2nd, 2013, 9:15 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 5911
Location: Aachen (Germany)
Even though this will get very off-topic now:
Writing flags to the database is a bad idea, because of the overhead.
Slightly more efficient would be using files (2 commands vs at least 5).
And the most efficient: PAL.WaitForEvent('A'); and WebToStr('http://127.0.0.1:1221/event/A');

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Problems/Questions | Sourcecode


Top
 Profile  
 
PostPosted: February 2nd, 2013, 9:33 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 9986
Location: Denver, CO
there's always more than one way to skin the proverbial cat. :)

_________________
- Rob Oyler
- Spacial Volunteer Support (SVS)
Smooth Contemporary Jazz Channel:
Image


Top
 Profile  
 
PostPosted: June 6th, 2013, 8:35 am 
Offline
Senior User
Senior User

Joined: May 28th, 2012, 6:56 pm
Posts: 219
Could we implement a script that ends the PAL script event by executing it through the ES? I'm still having a difficult time stopping my TOH at a specified 2hr time block on M-F and then on Saturday by integrating the following commands in my existing TOH script:

Code:
while not
((Now >= T['01:00:00']) and (Now <= T['02:59:59'])) or
      ((Now >= T['21:00:00']) and (Now <= T['22:59:59'])) do
begin

/// following rest of your script

end; //to end it all


Code:
while not
(DayOfWeek(Now) = Sunday) do
begin

/// following rest of your script

end; //to end it all


Top
 Profile  
 
PostPosted: June 6th, 2013, 9:44 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 5911
Location: Aachen (Germany)
The only way to stop a PAL is by a mechanism called polling.
That means you can have a PAL (let's call it the controller PAL) that tells another PAL to stop.
The other PAL (let's call it the receiver PAL) will however not react to commands from the controller immediately. Instead it will check in regular intervals whether a command to stop is present and will stop then. But between these intervals the receiver will simply continue doing it's job.

Here's an example:
controller.pal
Code:
VAR commandqueue : String = 'C:\commandqueue.txt';
StrToFile(commandqueue, 'STOP');


receiver.pal
Code:
VAR commandqueue : String = 'C:\commandqueue.txt';

// Check if we need to stop
WHILE (NOT FileExists(commandqueue)) OR (NOT FileToStr(commandqueue) = 'STOP') DO
BEGIN
  // Add 3 files to queue
  Queue.AddFile('C:\Users\Public\Music\Sample Music\Kalimba.mp3', ipBottom);
  Queue.AddFile('C:\Users\Public\Music\Sample Music\Maid with the Flaxen Hair.mp3', ipBottom);
  Queue.AddFile('C:\Users\Public\Music\Sample Music\Sleep Away.mp3', ipBottom);
  // Wait til 3 tracks played
  PAL.WaitForPlayCount(3);
  // Now check again if we need to stop or if we can repeat this
END;

DeleteFile(commandqueue);

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Problems/Questions | Sourcecode


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group