Help modify Download Scheduler
Forum » Forum / My Book World Edition (white light) » Help modify Download Scheduler
Started by: melzaprmelzapr
On: 1246463885|%e %b %Y, %H:%M %Z|agohover
Number of posts: 6
rss icon RSS: New posts
Summary:
My idea is to modify the Scheduler I need to set it every 1 hours instead of 3 hours as the default.
Help modify Download Scheduler
melzaprmelzapr 1246463885|%e %b %Y, %H:%M %Z|agohover

I changed the file dn_settings.php :

#!/usr/bin/php
<?php
 
/**
 * @version $Id: dn_settings.php,v 1.1.2.9.2.4 2008/12/01 05:56:21 jason Exp $
 * @author Wiley Li <wileyli@wistron.com.tw>
 * @copyright Copyright (c) 2004 Wistron Corporation.
 */
$tabidx = 2;
require_once('guiconfig.inc');
require_once('ctcsconfig.inc');
require_once('dn_settings.inc');
require_once('dn_extra.inc');
require_once('dn_sq_ctrl.inc'); 
 
redirect_error_page(); // checking
is_btadmin();
 
$help_anchor = $htmlObj->Help('downloader', 'settings');
 
//-----------------------------------------------------------------------
$weeks = array('Sunday', 'Monday', 'Tuesday', 'Wednesday',
               'Thursday', 'Friday', 'Saturday');
 
$hours = array('00:00 - 01:00', '01:00 - 02:00', '02:00 - 03:00',
               '03:00 - 04:00', '04:00 - 05:00', '05:00 - 06:00',
               '06:00 - 07:00', '07:00 - 08:00',
               '08:00 - 09:00', '09:00 - 10:00', '10:00 - 11:00',
               '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00',
               '14:00 - 15:00', '15:00 - 16:00',
               '16:00 - 17:00', '17:00 - 18:00', '18:00 - 19:00',
               '19:00 - 20:00', '20:00 - 21:00', '21:00 - 22:00',
               '22:00 - 23:00', '23:00 - 00:00');
 
$len_weeks = count($weeks);
$len_hours = count($hours);
 
$odd_row_color  = '4A7CB3';
$even_row_color = '336699';
//-----------------------------------------------------------------------

and the file dn_sq_ctrl.inc

<?php
/**
 * @version $Id: dn_sq_ctrl.inc,v 1.1.2.10.2.5 2009/03/12 08:59:27 jason Exp $
 * @author Wiley Li <wiley_li@wistron.com.tw>
 * @copyright Copyright (c) 2004 Wistron Corporation.
 */
require_once('ctcsconfig.inc');
require_once('dn_extra.inc');
require_once('dn_podcast_extra.inc');
require_once('xml.inc');
require_once('wget.inc');
// ----------------------------------------------------------------
define('__debug__', false);
define('__debug_s__', false); // accelerate testing efficency by reduce the range of period time
define('__debug_tformat__', 'Y/m/d H:i:s');
define('_SELF_RESTART_FFLAG_', '/etc/.sc_restart_yourself');
// ----------------------------------------------------------------
$quiet = false;
// ----------------------------------------------------------------
function _d($msg){
  global $quiet;
 
  if(__debug__&&$msg&&!$quiet){
    echo '['.date(__debug_tformat__).'] '.$msg."\n";
  }
}
// ----------------------------------------------------------------
function do_quiet($q){
  global $quiet;
  $quiet = $q;
}
// ----------------------------------------------------------------
// numeric representation of the day of the week
// 0 (for Sunday) through 6 (for Saturday)
function curr_week_i() {
  if(!__debug_s__){ return date('w'); }
  else {
    // __debug_s__ is TRUE, it will do as following below
    // accelerate testing efficency by reduce the range of period time
    //     Sunday: 00,07,14,21
    //     Monday: 01,08,15,22
    //    Tuesday: 02,09,16,23
    //  Wednesday: 03,10,17
    //   Thursday: 04,11,18
    //     Friday: 05,12,19
    //   Saturday: 06,13,20
    return (date('H')%7);
  }
}
// ----------------------------------------------------------------
// the hours section
// 0: '00:00 - 00:59', 1: '01:00 - 01:59', 2: '02:00 - 02:59',
// 3: '03:00 - 03:59', 4: '04:00 - 04:59', 5: '05:00 - 05:59',
// 6: '06:00 - 06:59', 7: '07:00 - 07:59',
// 8: '08:00 - 08:59', 9: '09:00 - 09:59', 10: '10:00 - 10:59',
// 11: '11:00 - 11:59', 12: '12:00 - 12:59', 13: '13:00 - 13:59',
// 14: '14:00 - 14:59', 15: '15:00 - 15:59',
// 16: '16:00 - 16:59', 17: '17:00 - 17:59', 18: '18:00 - 18:59',
// 19: '19:00 - 19:59', 20: '20:00 - 20:59', 21: '21:00 - 21:59',
// 22: '22:00 - 22:59', 23: '23:00 - 23:59'
 
function curr_hours_section_i(){
 
  if(!__debug_s__){
    switch (date('H')){
      case '00': return 0;
      case '01': return 1;
      case '02': return 2;
      case '03': return 3;
      case '04': return 4;
      case '05': return 5;
      case '06': return 6;
      case '07': return 7;
      case '08': return 8;
      case '09': return 9;
      case '10': return 10;
      case '11': return 11;
      case '12': return 12;
      case '13': return 13;
      case '14': return 14;
      case '15': return 15;
      case '16': return 16;
      case '17': return 17;
      case '18': return 18;
      case '19': return 19;
      case '20': return 20;
      case '21': return 21;
      case '22': return 22;
      case '23': return 23;  
    }
  } else {
    // __debug_s__ is TRUE, it will do as following below
    // accelerate testing efficency by reduce the range of period time
    $_debug_v=date('i'); // by minute for index
    if($_debug_v>=0  && $_debug_v<=7) { return 0; }
    if($_debug_v>=8  && $_debug_v<=15){ return 1; }
    if($_debug_v>=16 && $_debug_v<=23){ return 2; }
    if($_debug_v>=24 && $_debug_v<=31){ return 3; }
    if($_debug_v>=32 && $_debug_v<=39){ return 4; }
    if($_debug_v>=40 && $_debug_v<=47){ return 5; }
    if($_debug_v>=48 && $_debug_v<=55){ return 6; }
    if($_debug_v>=56 && $_debug_v<=59){ return 7; }
  }
 
  return false;
}
// ----------------------------------------------------------------
function curr_time_in_schedule($schedule_table){
  if(__debug_s__){
    $week_str = array('Sunday','Monday','Tuesday','Wednesday',
                      'Thursday','Friday','Saturday');
    $hour_str = array('00:00 - 00:59', '01:00 - 01:59', '02:00 - 02:59',
                      '03:00 - 03:59', '04:00 - 04:59', '05:00 - 05:59',
                      '06:00 - 06:59', '07:00 - 07:59',
                      '08:00 - 08:59', '09:00 - 09:59', '10:00 - 10:59',
                      '11:00 - 11:59', '12:00 - 12:59', '13:00 - 13:59',
                      '14:00 - 14:59', '15:00 - 15:59',
                      '16:00 - 16:59', '17:00 - 17:59', '18:00 - 18:59',
                      '19:00 - 19:59', '20:00 - 20:59', '21:00 - 21:59',
                      '22:00 - 22:59', '23:00 - 23:59');              
    _d('=================================================');
    _d('================== debug is ON ==================');
    _d('(current time simulate to '.$hour_str[curr_hours_section_i()].', '.
       $week_str[curr_week_i()]).')';
    _d('=================================================');
  }
  return $schedule_table[curr_week_i()][curr_hours_section_i()];
}

the matrix created it correctly, viewing the table in the scheduler page is correct but the scheduler not work and the downloads not start in automatic.

unfold Help modify Download Scheduler by melzaprmelzapr, 1246463885|%e %b %Y, %H:%M %Z|agohover
Re: Help modify Download Scheduler
david_tre07david_tre07 1246491352|%e %b %Y, %H:%M %Z|agohover

Check in the file dn_sq_ctrl.inc in the line 317 there is 10800 (3 hours * 60 minutes * 60 seconds)
I think if you change it to 3600 it will solve your problem…

When It run well, please post the patch:
cd /proto/SxM_webui
diff -Nur ctcs.old ctcs> change_to_hour.patch

unfold Re: Help modify Download Scheduler by david_tre07david_tre07, 1246491352|%e %b %Y, %H:%M %Z|agohover
Re: Help modify Download Scheduler
melzaprmelzapr 1246563170|%e %b %Y, %H:%M %Z|agohover

I tried to change from 10800 to 3600 but unfortunately still not working…..
everything seems ok but the scheduler automatically does not work.

The matrix is correct because if I put the flag in the time course and save the settings, the download go

I think there is still a problem on the scan scheduler but I can not understand where and how files search.

We need the help of some one who knows of this programming language.

unfold Re: Help modify Download Scheduler by melzaprmelzapr, 1246563170|%e %b %Y, %H:%M %Z|agohover
Re: Help modify Download Scheduler
david_tre07david_tre07 1246573643|%e %b %Y, %H:%M %Z|agohover

Did you reboot the disk ?
;)

unfold Re: Help modify Download Scheduler by david_tre07david_tre07, 1246573643|%e %b %Y, %H:%M %Z|agohover
Re: Help modify Download Scheduler
david_tre07david_tre07 1246659349|%e %b %Y, %H:%M %Z|agohover

In file file dn_sq_ctrl.inc replace:

function next_wakeup_seconds($hours_section_i){                    
  return mktime($hours_section_i*3+3,0,0,date('n'),date('j'),date('Y'))-time();
}

With:

function next_wakeup_seconds($hours_section_i){                    
  return mktime($hours_section_i*1+1,0,0,date('n'),date('j'),date('Y'))-time();
}

I hope It will work !
unfold Re: Help modify Download Scheduler by david_tre07david_tre07, 1246659349|%e %b %Y, %H:%M %Z|agohover
Re: Help modify Download Scheduler
david_tre07david_tre07 1246660083|%e %b %Y, %H:%M %Z|agohover

Here the patch, I hope it will work:

diff -Nur ./dn_settings.php ../ctcs.old/dn_settings.php
--- ./dn_settings.php   2009-07-03 00:06:01.000000000 +0200
+++ ../ctcs.old/dn_settings.php 2009-07-02 23:13:10.000000000 +0200
@@ -22,14 +22,9 @@
 $weeks = array('Sunday', 'Monday', 'Tuesday', 'Wednesday',
                'Thursday', 'Friday', 'Saturday');

-$hours = array('00:00 - 01:00', '01:00 - 02:00', '02:00 - 03:00',
-               '03:00 - 04:00', '04:00 - 05:00', '05:00 - 06:00',
-               '06:00 - 07:00', '07:00 - 08:00', '08:00 - 09:00',
-               '09:00 - 10:00', '10:00 - 11:00', '11:00 - 12:00',
-               '12:00 - 13:00', '13:00 - 14:00', '14:00 - 15:00',
-               '15:00 - 16:00', '16:00 - 17:00', '17:00 - 18:00',
-               '18:00 - 19:00', '19:00 - 20:00', '20:00 - 21:00',
-               '21:00 - 22:00', '22:00 - 23:00', '23:00 - 00:00');
+$hours = array('00:00 - 03:00', '03:00 - 06:00', '06:00 - 09:00',
+               '09:00 - 12:00', '12:00 - 15:00', '15:00 - 18:00',
+               '18:00 - 21:00', '21:00 - 00:00');

 $len_weeks = count($weeks);
 $len_hours = count($hours);
diff -Nur ./dn_sq_ctrl.inc ../ctcs.old/dn_sq_ctrl.inc
--- ./dn_sq_ctrl.inc    2009-07-04 00:19:21.000000000 +0200
+++ ../ctcs.old/dn_sq_ctrl.inc  2009-07-02 23:13:10.000000000 +0200
@@ -49,14 +49,34 @@
 }
 // ----------------------------------------------------------------
 // the hours section
+// 0: '00:00 - 02:59', 1: '03:00 - 05:59', 2: '06:00 - 08:59',
+// 3: '09:00 - 11:59', 4: '12:00 - 14:59', 5: '15:00 - 17:59',
+// 6: '18:00 - 20:59', 7: '21:00 - 23:59'
 function curr_hours_section_i(){

   if(!__debug_s__){
-    return (date('H'));
+    switch (date('H')){
+      case '00': case '01': case '02': return 0;
+      case '03': case '04': case '05': return 1;
+      case '06': case '07': case '08': return 2;
+      case '09': case '10': case '11': return 3;
diff -Nur ./dn_settings.php ../ctcs.old/dn_settings.php
--- ./dn_settings.php   2009-07-03 00:06:01.000000000 +0200                                                                    
+++ ../ctcs.old/dn_settings.php 2009-07-02 23:13:10.000000000 +0200                                                            
@@ -22,14 +22,9 @@                                                                                                             
-      case '06': case '07': case '08': return 2;                                                                              
-      case '09': case '10': case '11': return 3;                                                                              
-      case '12': case '13': case '14': return 4;                                                                              
-      case '15': case '16': case '17': return 5;                                                                              
-      case '18': case '19': case '20': return 6;                                                                              
-      case '21': case '22': case '23': return 7;                                                                              
-    }                                                                                                                         
+    return (date('H'));                                                                                                       
   } else {                                                                                                                    
     // __debug_s__ is TRUE, it will do as following below          
     // accelerate testing efficency by reduce the range of period time
-    $_debug_v=date('i'); // by minute for index                       
-    if($_debug_v>=0  && $_debug_v<=7) { return 0; }                   
-    if($_debug_v>=8  && $_debug_v<=15){ return 1; }                   
-    if($_debug_v>=16 && $_debug_v<=23){ return 2; }                   
-    if($_debug_v>=24 && $_debug_v<=31){ return 3; }                   
-    if($_debug_v>=32 && $_debug_v<=39){ return 4; }                   
-    if($_debug_v>=40 && $_debug_v<=47){ return 5; }                   
-    if($_debug_v>=48 && $_debug_v<=55){ return 6; }                   
-    if($_debug_v>=56 && $_debug_v<=59){ return 7; }                   
+    return (round(date('i')/2.5));                                 
   }                                                                   

   return false;                                                       
@@ -86,9 +66,14 @@                                                     
   if(__debug_s__){                                                    
     $week_str = array('Sunday','Monday','Tuesday','Wednesday',        
                       'Thursday','Friday','Saturday');                
-    $hour_str = array('00:00 - 02:59', '03:00 - 05:59', '06:00 - 08:59',
-                      '09:00 - 11:59', '12:00 - 14:59', '15:00 - 17:59',
-                      '18:00 - 20:59', '21:00 - 23:59');                
+    $hour_str = array('00:00 - 00:59', '01:00 - 01:59', '02:00 - 02:59',
+                      '03:00 - 03:59', '04:00 - 04:59', '05:00 - 05:59',
+                      '06:00 - 06:59', '07:00 - 07:59', '08:00 - 08:59',
+                      '09:00 - 09:59', '10:00 - 10:59', '11:00 - 11:59',
+                      '12:00 - 12:59', '13:00 - 13:59', '14:00 - 14:59',
+                      '15:00 - 15:59', '16:00 - 16:59', '17:00 - 17:59',
+                      '18:00 - 18:59', '19:00 - 19:59', '20:00 - 20:59',
+                      '21:00 - 21:59', '22:00 - 22:59', '23:00 - 23:59');
     _d('=================================================');             
     _d('================== debug is ON ==================');             
     _d('(current time simulate to '.$hour_str[curr_hours_section_i()].', '.
@@ -99,13 +84,13 @@                                                         
 }                                                                          
 // ----------------------------------------------------------------        
 function next_wakeup_seconds($hours_section_i){                            
-  return mktime($hours_section_i*3+3,0,0,date('n'),date('j'),date('Y'))-time();
+  return mktime($hours_section_i*1+1,0,0,date('n'),date('j'),date('Y'))-time();
 }                                                                              
 // ----------------------------------------------------------------            
 function num_of_not_schedule_in_continuous($hours_section_i,$schedule_table){  
   $num = 0;                                                                    
   $today_schedule_ary = $schedule_table[curr_week_i()];                        
-  for($i=$hours_section_i+1;$i<=7;$i++){                                       
+  for($i=$hours_section_i+1;$i<=23;$i++){                                      
     if(!$today_schedule_ary[$i]) { $num++; }                                   
     else break;                                                                
   }                                                                            
@@ -314,7 +299,7 @@                                                             
   // *********************************************                             
   if(!__debug_s__){                                                            
     $sleep_time = next_wakeup_seconds(curr_hours_section_i()) +                
-                  num_of_not_schedule_in_continuous(curr_hours_section_i(),$schedule)*10800;
+                  num_of_not_schedule_in_continuous(curr_hours_section_i(),$schedule)*3600; 
   } else {                                                                                  
     _d('sleep time is the fixed value with 60 seconds.');                                   
     $sleep_time = 60;
unfold Re: Help modify Download Scheduler by david_tre07david_tre07, 1246660083|%e %b %Y, %H:%M %Z|agohover
New post
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License