Home AMX User Forum AMXForums Archive Threads AMX Hardware

Cpu Usage

Hi,

Has Anyone noticed a bug in the latest firmware (3.41.422) that if you use the command "Cpu Usage" in a telnet session it will almost always be around 70%-98%? no matter the code size...
as far as i remember the old firmware, if you typed that command it will halt the session for 30 seconds and give you a normal resualt.

Thanks,
Ronen Katz

Comments

  • Not seeing that. I am getting numbers in the neighborhood of 1% on my system that has no events being triggered.
  • jazzwyldjazzwyld Posts: 199
    Ronen wrote: »
    Hi,

    Has Anyone noticed a bug in the latest firmware (3.41.422) that if you use the command "Cpu Usage" in a telnet session it will almost always be around 70%-98%? no matter the code size...
    as far as i remember the old firmware, if you typed that command it will halt the session for 30 seconds and give you a normal resualt.

    Thanks,
    Ronen Katz

    Mine is at 99.97, that may be a tad high.
  • DHawthorneDHawthorne Posts: 4,584
    I wonder if Duet is involved with those high numbers ...
  • ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    I wonder if Duet is involved with those high numbers ...

    ***oooh snap***
  • What does your mainline (DEFINE PROGRAM section) look like? I always strive to have zero lines of code in mine and make as much as possible event driven. This minimizes CPU usage and keeps the system as quiet as possible.

    It is true (has been discussed in this forum) that mainline will not execute (well, once per second) if a value in mainline does not change. For example, [myTP,channel]= thisValue will not generate an event to myTP until thisValue changes. If no value changes then mainline won't even execute. It monitors the values and only executes if one of those changes. But, if you are using a loop it totally changes the dynamics of what we are talking about. Example:

    for (i = 1; i <= numBtns; i++)
    {
    [myTP,channel] = thisValue
    }

    At first glance we'd think an event would only be generated to myTP if thisValue changed, right? But if you think about it i is changing every single time through mainline. So mainline never stops executing. This will raise your CPU usage very high because you are making the system do something all the time. It never stops.
  • Darkman88Darkman88 Posts: 45
    Ronen wrote: »
    Hi,

    Has Anyone noticed a bug in the latest firmware (3.41.422) that if you use the command "Cpu Usage" in a telnet session it will almost always be around 70%-98%? no matter the code size...
    as far as i remember the old firmware, if you typed that command it will halt the session for 30 seconds and give you a normal resualt.

    Thanks,
    Ronen Katz

    I've had the same problem when I use NetLink Studio 3.0 to make connection via telnet, try with the windows cmd interfaces or via some windows utility like Hercules (http://www.hw-group.com/products/hercules/index_en.html).
    And let me know the result.

    Bye Kman88
  • I am also having this very same issue. I *almost* always do feedback in timelines. Most of my modules have their own TLs and my main source has one that is also shared by all of my include files if they need it. There are 2 files that I have a total of 6 lines of code in define_program quite simply because I got lazy and did not add in a timeline for feedback. I cannot imagine that simple button/channel ties in define_program are causing huge cpu usage numbers. I am also a little confused about the 30 second average and max numbers compared to the first value returned:


    cpu usage
    CPU usage = 37.82% (30 sec. average = 85.35%, 30 sec. max = 96.79%)


    I poll for memory and cpu status every minute or so on all of my new systems on campus so I can get a better idea of how efficient my program is running. By the looks of the above #'s, it appears both decent and bad. Does anyone have an idea why there is such a disparity between the 37% and the 30 second average of 85%? To be honest, I have only started polling the master for cpu usage with the latest version of firmware (.422) so I cannot attest to previous versions. If I have 60 or so masters across campus maxing out all the time, you can easily see the potential for some issues. The program itself is pretty simple, no duet stuff, my own modules, 200k~ish file size, etc. The only events that run constantly are my button feedback timelines, periodic telnet sessions to the master and my status timelines that, if flagged, report to our management software.

    What's has been odd to me is that the above numbers were pulled from my home system. They are virtually identical to any master at work. Two completely different systems with only 1 common include file. This issue sounds pretty much exactly like the original poster's issue.

    One of my goals, given time this week, is to call AMX and see if this is something to be concerned with or if I am misinterpreting this stuff. Has anyone noticed anything like this that can shed some light?
  • tracktoys, the problem is not the program mainline just because of that:

    1) I've tried to connecting with the telnet application included in NetLinx Studio 3.0 whit the just cleared Netlinx Master and I've got the same Issue an Hight value of Avarange and an Hight Value of CPU Usage.

    2) If I tried to connect to the Netlinx Master whit the normal telnet (Using the windows command line) I havent got problem.

    So I thing that the issue will be in the NetLinx Studio 3.0 and not in the firmware.

    Your value is not the same of mine so I think that yours will be caused by a huge use of the CPU just because in the moment you have done the check you where use 37.82% of CPU and in the last 30 sec you have used 96.79% of CPU so I think It's OK.

    Did you tried with the telnet app in NS3 or with the windows command line???

    Bye Kman88
  • Just tried it and getting the same thing on both CLI and NS3.0. At what point should the processor's "idle" be considered too high?
  • jweatherjweather Posts: 320
    tracktoys wrote: »
    Does anyone have an idea why there is such a disparity between the 37% and the 30 second average of 85%?

    It's a 30-second rolling average. If you sampled the CPU usage thirty times, once per second (although I don't know if this is actually the interval it uses), it's saying the max usage was 96.79%, the average of the 30 samples was 85.35%, and the last value sampled was 37%. The 30-second average is more useful, being a "smoothed" value, rather than just looking at a single point in time.
  • That seems like it could be accurate.

    Now I have to isolate why the hell the 30 second average is so high. Does anyone think there could be potential long-term effects to the master? I don't want to be running a stress test on my equipment if I don't have to. I will gladly rethink my timeline/feedback approaches if necessary.
  • I just sent a completely blank file to my master and it still reads:

    CPU usage = 64.13% (30 sec. average = 65.99%, 30 sec. max = 78.09%)

    These numbers will only vary +/- 4%, no matter what. Something other than code has to be causing this.
  • ericmedleyericmedley Posts: 4,177
    tracktoys wrote: »
    I just sent a completely blank file to my master and it still reads:

    CPU usage = 64.13% (30 sec. average = 65.99%, 30 sec. max = 78.09%)

    These numbers will only vary +/- 4%, no matter what. Something other than code has to be causing this.

    hmmm.. you might try doing a clean disk command and make sure that everything is completely cleared out. But you may be chasing a ghost here.

    It reminds me of the new Windows 7 CPU rating system. I've gotten many calls saying, "why is my bad-a$$ cpu only rating a 1.2???
  • tracktoys wrote: »
    I just sent a completely blank file to my master and it still reads:

    CPU usage = 64.13% (30 sec. average = 65.99%, 30 sec. max = 78.09%)

    These numbers will only vary +/- 4%, no matter what. Something other than code has to be causing this.

    I've done the same with a clean disk command and I've got:

    CPU usage = 90.99% (30 sec. average = 90.99%, 30 sec. max = 90.99%)

    I would belive there is something in the new firmware tht cause this when connecting via telnet By NS3, when I'm connected via window command line telnet I havent got problem.
  • ericmedleyericmedley Posts: 4,177
    Darkman88 wrote: »
    I've done the same with a clean disk command and I've got:

    CPU usage = 90.99% (30 sec. average = 90.99%, 30 sec. max = 90.99%)

    I would belive there is something in the new firmware tht cause this when connecting via telnet By NS3, when I'm connected via window command line telnet I havent got problem.

    are you running any duet modules? Or for that matter any modules that you didn't write yourself?
  • ericmedley wrote: »
    are you running any duet modules? Or for that matter any modules that you didn't write yourself?

    I cant run any module duet or not duet If I have done a clean disk before.
    So no I didnt run anythink.

    Kman88
  • PhreaKPhreaK Posts: 966
    Hmmm... interesting because I ran across this http://www.amxforums.com/showthread.php?t=6389
  • roognationroognation Posts: 138
    CPU USAGE Tips
    rgelling wrote: »
    What does your mainline (DEFINE PROGRAM section) look like? I always strive to have zero lines of code in mine and make as much as possible event driven. This minimizes CPU usage and keeps the system as quiet as possible.

    It is true (has been discussed in this forum) that mainline will not execute (well, once per second) if a value in mainline does not change. For example, [myTP,channel]= thisValue will not generate an event to myTP until thisValue changes. If no value changes then mainline won't even execute. It monitors the values and only executes if one of those changes. But, if you are using a loop it totally changes the dynamics of what we are talking about. Example:

    for (i = 1; i <= numBtns; i++)
    {
    [myTP,channel] = thisValue
    }

    At first glance we'd think an event would only be generated to myTP if thisValue changed, right? But if you think about it i is changing every single time through mainline. So mainline never stops executing. This will raise your CPU usage very high because you are making the system do something all the time. It never stops.

    Any tips for reducing the CPU USAGE when evaluating time? I was surprised when I put this in:
    if (  (time == '03:00:00') && (!nvRolloverDAY)  )		// Rollover Time: DAY
        {
    	wait 20	// wait 2 seconds to allow lockout
    	{
    		nvRolloverDAY = 1
    		// do stuff
    	}
        }
    
    and got about 51 % CPU USAGE (30 sec avg). When I commented the above out, the CPU USAGE went to zero. Using this:
    wait 10
    {
        if (  (time == '03:00:00') && (!nvRolloverDAY)  )		// Rollover Time: DAY
        {
    	wait 20	// wait 2 seconds to allow lockout
    	{
    	    nvRolloverDAY = 1		// Rollover DAY in progress
    	    // do stuff
    	}
        }
    }
    
    allowed my CPU USAGE to also go to zero.
  • viningvining Posts: 4,368
    I don't think there's any code put in define program that shouldn't be behind a wait. A simple wait 1 would be fast enough for anything I can think of.

    Here's a copy of the .axi file I use for time and date stuff and I think it's as processor friendly as you can get. Of course I could be wrong. The function call in def program is commented out since I usually have a timeline to call it somewhere else in my code. There's some useful stuff in this file which I would imagine others would benefit from. There's empty function already set up for running seconds, minute, hourly, daily , etc events so it pretty much plug and play and then drop it what you want in the appropriate function call and your good to go. It will even determine the major holidays for you.
    PROGRAM_NAME='VAV_Date_&_Time'
    
    DEFINE_CONSTANT //DST                           <<<*************************  CHANGE SETTING PER JOB *********************************>>>
    //Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn.[1] 
    //Starting in 2007, Daylight Saving Time (DTS) has been extended by one month. Therefore, the start date of DTS in the United States has been
    //changed to the 2nd Sunday in March and the end date of DTS has been changed to the 1st Sunday in November
    
    //If Daylight Savings Time is currently being observed (between spring and fall), set this item to "1". If Daylight Savings Time
    //is not currently being observed (between fall and spring) or is not observed in your geographic location, set this item to "0".
    //This item is used to correctly calculate the times for sunrise and sunset.
    
    INTEGER DST_OBSERVED		= 1 ;  		//1 for yes and 0 for no 
    INTEGER DST_OFFSET		= 1 ;  		//number of hours time is offset 
    INTEGER DST_BEGIN_MONTH		= 3 ;  		//March (months 1-12 January to December)
    INTEGER DST_END_MONTH		= 11 ; 		//November (months 1-12 January to December)
    INTEGER DST_BEGIN_DAY		= 1 ;  		//Sunday (day of week 1-7 Sunday to Saturday)
    INTEGER DST_END_DAY		= 1 ;  		//Sunday (day of week 1-7 Sunday to Saturday)
    INTEGER DST_BEGINDAY_OCCURANCE	= 2 ;  		//Number of occurances of that day in that month (2nd Sunday)
    INTEGER DST_ENDDAY_OCCURANCE	= 1 ;  		//Number of occurances of that day in that month (1st Sunday)
    CHAR DST_BEGIN_TIME[]		= '02:00:00' ;	//Time change occurs 
    CHAR DST_END_TIME[]		= '02:00:00' ;	//Time change occurs 
    
    DEFINE_CONSTANT //ASTRO_CLOCK LAT/LONG          <<<*************************  CHANGE SETTING PER JOB *********************************>>>
    
    INTEGER CLKMGR_DST		= 1 ;     	//1 for ON and 0 for OFF
    INTEGER CLKMGR_DST_OFFSET_HR	= 1 ;     	//1 for 1 hour
    INTEGER CLKMGR_DST_OFFSET_MIN	= 0 ;     	//0 for 0 minutes
    INTEGER CLKMGR_DST_OFFSET_SEC	= 0 ;     	//0 for 0 seconds
    INTEGER CLKMGR_RESYNC_PERIOD	= 240 ;     	//in minutes 480 = 8 hours, choices: 5 min, 15 min, 2 hour, 4 hours & (8 hours?)
    					        //the web interface doesn't show an 8 hour option but the keyword example only shows
    					        //an hour hour example. So I choose the highest the web gui lists 4 hours/240 minutes. 
    
    DOUBLE CLKMGR_LAT		= -73.42 ;	//Longitude - Longitude in Degrees.Fraction of Degrees. West longitudes must be negative.
    DOUBLE CLKMGR_LONG		= 41.98 ; 	//Latitude - Latitude in Degrees.Fraction of Degrees. South latitudes must be negative 
    DOUBLE CLKMGR_OFF_FROM_GMT	= -5.0 ;  	//HoursFromGMT - Number of hours from GMT. Hours West of GMT can be entered as 
    
    CHAR CLKMGR_TIME_ZONE[]		= 'UTC-05:00' ;	//Input string must have the correct format: UTC[+|-]HH:MM
    CHAR CLKMGR_ACTIVESERVER[] 	= '132.163.4.101' ; 
    
    DEFINE_CONSTANT //TIME CONSTANTS Days of Week & Month of Year
    
    SUNDAY        	= 1 ;
    MONDAY        	= 2 ;
    TUESDAY       	= 3 ;
    WEDNESDAY     	= 4 ;
    THURSDAY      	= 5 ;
    FRIDAY        	= 6 ;
    SATURDAY      	= 7 ;
    
    JANUARY		= 1 ;
    FEBRUARY	= 2 ;
    MARCH		= 3 ;
    APRIL		= 4 ;
    MAY		= 5 ;
    JUNE		= 6 ;
    JULY 		= 7 ;
    AUGUST		= 8 ;
    SEPTEMBER	= 9 ;
    OCTOBER		= 10 ;
    NOVEMBER	= 11 ;
    DECEMBER	= 12 ;
    
    FIRST           = 1 ;
    SECOND          = 2 ;
    THIRD           = 3 ;
    FOURTH          = 4 ;
    FIFTH           = 5 ;
    
    EXPIRES_IN_SECONDS      	= 10 ; 
    
    LONG NUM_SECONDS_DAY	    	= 86400 ;
    CHAR DAY_OF_WEEK_ABREV[7][3]   = {'SUN','MON','TUE','WED','THU','FRI','SAT'}
    CHAR DAY_OF_WEEK_FULL[7][9]    = {'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'}
    
    CHAR MONTH_OF_YR_ABREV[12][3]   = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'} ; 
    CHAR MONTH_OF_YR_FULL[12][9]    = {'January','February','March','April','May','June','July','August','September','October','November','December'} ; 
    CHAR DAYS_MONTHs[12]        	= {31   ,28   ,31   ,30   ,31   ,30   ,31   ,31   ,30   ,31   ,30   ,31} ;
    CHAR DAYS_LEAPMONTHs[12]    	= {31   ,29   ,31   ,30   ,31   ,30   ,31   ,31   ,30   ,31   ,30   ,31} ;
    
    DEFINE_CONSTANT //UI FEEDBACK EVENTS
    
    FB_TIME_TIME       	= 1 ;
    FB_TIME_SUNRISE		= 2 ;
    FB_TIME_SUNSET		= 3 ;
    FB_TIME_DST		= 4 ;
    FB_TIME_HOLIDAY		= 5 ;
    
    DEFINE_TYPE     //TIME STUFF
    
    STRUCTURE _sMyTime
    
         {
         INTEGER 	nYear ;
         INTEGER 	nMonth ;
         INTEGER 	n24Hour ;
         INTEGER 	n12Hour ;
         INTEGER 	nMinute ;
         INTEGER 	nSecond ;
         INTEGER 	nDayOfMonth ;
         INTEGER 	nDayOfWeek ;
         INTEGER  	nDayOccurance[7] ;
         LONG	nTime ;
         CHAR	c24Time[8] ;
         CHAR	c12Time[8] ;
         INTEGER 	nWeekOfMonth ;
         INTEGER 	nPlusDays ;
         INTEGER 	nDaytime ;
         INTEGER    nTimePM_flag ;
         LONG     	nSunriseTime ;
         LONG     	nSunSetTime ;
         CHAR 	cSunrise[10] ;
         CHAR 	cSunset[10] ;
         INTEGER 	nSunset24Hour ;
         INTEGER 	nSunset12Hour ;
         INTEGER 	nSunsetMinute ;
         INTEGER 	nSunsetSecond ;
         INTEGER 	nSunriseHour ;
         INTEGER 	nSunriseMinute ;
         INTEGER 	nSunriseSecond ;
         CHAR     	cHoliday[24] ;
         CHAR     	cDay[3] ;
         CHAR     	cDate[8] ;
         CHAR 	cWebCurDateTime[29] ;
         CHAR 	cWebExpDateTime[29] ;
         }
         
    DEFINE_TYPE     //DST
    
    STRUCTURE _sMyDST
    
         {
         INTEGER nDST_Active ;
         INTEGER nOffset ;
         INTEGER nObserved ;
         INTEGER nBEG_Month ;
         INTEGER nEND_Month ;
         INTEGER nBEG_Day ;
         INTEGER nEND_Day ;
         INTEGER nBEG_DAY_Occurance ;
         INTEGER nEND_DAY_Occurance ;
         }
    
    DEFINE_TYPE     //CLKMGR_TIMEOFFSET_STRUCT FROM NETLINX.AXI FOR REFERNCE ONLY
    
    (*    
    STRUCTURE CLKMGR_TIMEOFFSET_STRUCT
         
         {
         INTEGER     HOURS;
         INTEGER     MINUTES;
         INTEGER     SECONDS;
         }
    *)
    
    DEFINE_VARIABLE //STRUCTURES
    
    PERSISTENT _sMyTime sMyTime ;
    VOLATILE   _sMyDST sMyDST ;
    
    VOLATILE INTEGER nTimeWait_Force = 1 ; //forces refresh of everything at startup
    VOLATILE INTEGER nTime_DeBug = 1 ;
    
    DEFINE_FUNCTION LONG fnConv_24HrTimeToSeconds(CHAR iTime[])
    
         {
         RETURN ((((ATOI(REMOVE_STRING(iTime,"':'",1)) * 60) + ATOI(REMOVE_STRING(iTime,"':'",1))) * 60) + ATOI(iTime)) ;
         }
         
    DEFINE_FUNCTION CHAR[8] fnConv_SecondsTo24HrTime(LONG iTimeInSeconds)
    
         {
         RETURN   "right_string("'0',ITOA(iTimeInSeconds / 3600)",2),':',
    		    right_string("'0',ITOA((iTimeInSeconds &#37; 3600) / 60)",2),':',
    			 right_string("'0',ITOA((iTimeInSeconds % 3600) % 60)",2)" ;
         }
         
    DEFINE_FUNCTION CHAR[30] fnDo_24hrTimeAddition(CHAR iLDate[],CHAR i24HourTime[],LONG iSecondsAdded)     
         
         {
         STACK_VAR INTEGER nYear ;       //change to all stack_var's
         STACK_VAR INTEGER nMonth ;
         STACK_VAR INTEGER nLeap ;
         STACK_VAR CHAR c24HrTime[8] ;
         STACK_VAR CHAR cNewDate[10] ;
         STACK_VAR LONG nDay ;
         STACK_VAR LONG nDaysOver ;
         STACK_VAR LONG nSecondsRemain ;
         STACK_VAR LONG nTotalTimeSeconds ;
         
         nTotalTimeSeconds = fnConv_24HrTimeToSeconds(i24HourTime) + iSecondsAdded ;
         nMonth = atoi("REMOVE_STRING(iLDATE,"'/'",1)") ;
         nDay   = atoi("REMOVE_STRING(iLDATE,"'/'",1)") ;
         nYear  = atoi("iLDATE") ;
         
         if(nTotalTimeSeconds > NUM_SECONDS_DAY)
    	  {
    	  STACK_VAR INTEGER i ;
    	  
    	  nDaysOver = nTotalTimeSeconds / NUM_SECONDS_DAY ;
    	  nSecondsRemain = nTotalTimeSeconds % NUM_SECONDS_DAY ;
    	  if(!(nYear % 4))//http://en.wikipedia.org/wiki/Leap_year
    	       {
    	       nLeap = 1 ;
    	       if(!(nYear % 100))//double check these rules?????? 
    		    {
    		    if(nYear % 400)
    			 {
    			 nLeap = 0 ;
    			 }
    		    }
    	       }
    	  if(nLeap)
    	       {
    	       if((nDaysOver + nDay) > DAYS_LEAPMONTHs[nMonth])
    		    {
    		    nDaysOver = nDaysOver - (DAYS_LEAPMONTHs[nMonth] - nDay) ;
    		    nMonth++ ;
    		    
    		    for(nMonth = nMonth ; nDaysOver > DAYS_LEAPMONTHs[nMonth] ; nMonth++)
    			 {
    			 nDaysOver = (nDaysOver - DAYS_LEAPMONTHs[nMonth]) ;
    			 if(nMonth == 12)
    			      {
    			      nMonth = 1 ;
    			      nYear ++ ;
    			      }
    			 }
    		    nDay = nDaysOver ;
    		    }
    	       else
    		    {
    		    nDay = nDaysOver + nDay ;
    		    }
    	       }
    	  else
    	       {
    	       if((nDaysOver + nDay) > DAYS_MONTHs[nMonth])
    		    {
    		    nDaysOver = nDaysOver - (DAYS_MONTHs[nMonth] - nDay) ;
    		    nMonth++ ;
    		    
    		   for(nMonth = nMonth ; nDaysOver > DAYS_MONTHs[nMonth] ; nMonth++)
    			 {
    			 nDaysOver = (nDaysOver - DAYS_MONTHs[nMonth]) ;
    			 if(nMonth == 12)
    			      {
    			      nMonth = 1 ;
    			      nYear ++ ;
    			      }
    			 }
    		    nDay = nDaysOver ;
    		    }
    	       else
    		    {
    		    nDay = nDaysOver + nDay ;
    		    }
    	       }
    	  c24HrTime = fnConv_SecondsTo24HrTime(nSecondsRemain) ; 
    	  }
         else
    	  {
    	  c24HrTime = fnConv_SecondsTo24HrTime(nTotalTimeSeconds) ;
    	  }
         cNewDate = "right_string("'0',ITOA(nMonth)",2),'/',right_string("'0',ITOA(nDay)",2),'/',right_string("'0',ITOA(nYear)",2)" ;
    	   
         RETURN "DAY_OF_WEEK_ABREV[TYPE_CAST(DAY_OF_WEEK(cNewDate))],', ',itoa(nDay),' ',MONTH_OF_YR_ABREV[nMonth],' ',itoa(nYear),' ',c24HrTime" ;
         }
         
    DEFINE_FUNCTION fnFB_Time(INTEGER iUI_Indx,INTEGER iEvent) //<< SET VT ADDRESS CHANNELS  CHANGE SETTING PER JOB **********************>>>
    
         {
         SWITCH(iEvent)
    	  {
    	  CASE FB_TIME_TIME:
    	       {
    	       //panels can handle time on their own 
    	       }
    	  CASE FB_TIME_SUNRISE:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,1,"'Sunrise at ',itoa(sMyTime.nSunriseHour),':',itoa(sMyTime.nSunriseMinute),' AM'") ;
    	       }
    	  CASE FB_TIME_SUNSET:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,2,"'Sunset at ',itoa(sMyTime.nSunset12Hour),':',itoa(sMyTime.nSunsetMinute),' PM'") ;
    	       }
    	  CASE FB_TIME_DST:
    	       {
    	       if(sMyDST.nDST_Active)
    		    {
    		    //fnFB_TimeSend_VT(iUI_Indx,??,"'DST: IN EFFECT'") ; 
    		    }
    	       else
    		    {
    		    //fnFB_TimeSend_VT(iUI_Indx,??,"'DST: NOT IN EFFECT'") ; 
    		    }
    	       }
    	  CASE FB_TIME_HOLIDAY:
    	       {
    	       fnFB_TimeSend_VT(iUI_Indx,4,"sMyTime.cHoliday") ;
    	       }
    	  }
         }
         
    DEFINE_FUNCTION fnFB_TimeSend_VT(INTEGER iUI_Indx,INTEGER iCHAN,CHAR iStrMSG[500]) 
         
         {
         STACK_VAR INTEGER n ;
         STACK_VAR INTEGER nTPCount ; 
         STACK_VAR INTEGER nLoopStart ; 
         
         if(iUI_Indx)
    	  {
    	  nTPCount = iUI_Indx ;
    	  nLoopStart = iUI_Indx ;
    	  }
         else
    	  {
    	  nTPCount = NUM_UIs_IN_SYSTEM ;
    	  nLoopStart = 1 ;
    	  }
    	  
         //fnTime_DeBug("'SEND_VT: ',iStrMSG,' :DEBUG <',itoa(__LINE__),'>'") ;
         
         for(n = nLoopStart ; n <= nTPCount ; n++)
    	  {
    	  if(nUI_ActiveArry[n])//update if active (for time being online is enough)
    	       {
    	       SWITCH(nUI_TypeArry[n])
    		    {
    		    CASE UI_TYPE_G4:
    		    CASE UI_TYPE_R4:
    		    CASE UI_TYPE_MIO_DMS:
    		    (* no need for uni strings!!!
    			 {
    			 STACK_VAR WIDECHAR cSTRING1[500] ;
    			 STACK_VAR CHAR cSTRING2[500] ;
    			 
    			 cSTRING1 = WC_DECODE(iStrMSG,WC_FORMAT_UTF8,1) ; 
    			 cSTRING2 = WC_ENCODE(cSTRING1,WC_FORMAT_TP,1) ;
    			 //fnTime_DeBug("'^UNI- TP INDX: ',itoa(n),', CHNL: ',itoa(iCHAN),' :DEBUG <',ITOA(__LINE__),'>'") ;
    			 SEND_COMMAND dvUI_Arry[n], "'^UNI-',itoa(iCHAN),',0,',cSTRING2" ; 
    			 }
    		    *)
    		    CASE UI_TYPE_G3:
    		    CASE UI_TYPE_iPHONE://uni not supported yet		
    		    CASE UI_TYPE_iPAD:		
    		    CASE UI_TYPE_iTOUCH:	
    			 {
    			 //fnTime_DeBug("'^TXT- TP INDX: ',itoa(n),', CHNL: ',itoa(iCHAN),' :DEBUG <',ITOA(__LINE__),'>'") ;
    			 SEND_COMMAND dvUI_Arry[n], "'TEXT',itoa(iCHAN),'-',iStrMSG" ; 
    			 }
    		    CASE UI_TYPE_METKP:
    		    CASE UI_TYPE_UNKNOWN:
    		    CASE UI_TYPE_VIRTUAL:
    			 {
    			 //DO NOTHING
    			 }
    		    }
    	       }
    	  }
    	  
         RETURN ;
         }
    
    DEFINE_FUNCTION fnTime_DeBug(CHAR iStr[])
    
         {
         if(nTime_DeBug)
    	  {
    	  STACK_VAR CHAR cCopyStr[1024] ;
    	  STACK_VAR INTEGER nLineCount ;
    	  
    	  cCopyStr = iStr ;
    	  
    	  nLineCount ++ ;
    	  WHILE(length_string(cCopyStr) > 100)
    	       {
    	       SEND_STRING 0,"'TIME DEBUG (',itoa(nLineCount),'): ',get_buffer_string(cCopyStr,80)" ;
    	       nLineCount ++ ;
    	       }
    	  if(length_string(cCopyStr))
    	       {
    	       SEND_STRING 0,"'TIME DEBUG (',itoa(nLineCount),'): ',cCopyStr" ;
    	       }
    	  }
         
         RETURN ;
         } 
         
    DEFINE_FUNCTION fnGet_DST_State() 
         
         {//don't care about the hour of day it actually occurs!
         fnTime_DeBug("'fnCheckDST_Rule(): Checking DST State :DEBUG <',ITOA(__LINE__),'>'") ;
         SELECT
    	  {
    	  ACTIVE(sMyTime.nMonth < DST_BEGIN_MONTH && sMyTime.nMonth > DST_END_MONTH):
    	       {//quick elimination
    	       sMyDST.nDST_Active = 0 ;
    	       }
    	  ACTIVE(sMyTime.nMonth > DST_BEGIN_MONTH && sMyTime.nMonth < DST_END_MONTH):
    	       {//quick elimination
    	       sMyDST.nDST_Active = 1 ;
    	       }
    	  ACTIVE(sMyTime.nMonth == DST_BEGIN_MONTH): 
    	       {
    	       if(sMyTime.nDayOccurance[sMyDST.nBEG_Day] >= sMyDST.nBEG_DAY_Occurance)
    		    {
    		    sMyDST.nDST_Active = 1 ;
    		    }
    	       else
    		    {
    		    sMyDST.nDST_Active = 0 ;
    		    }
    	       }
    	  ACTIVE(sMyTime.nMonth == DST_END_MONTH): 
    	       {
    	       if(sMyTime.nDayOccurance[sMyDST.nEND_Day] >= sMyDST.nEND_DAY_Occurance)
    		    {
    		    sMyDST.nDST_Active = 0 ;
    		    }
    	       else
    		    {
    		    sMyDST.nDST_Active = 1 ;
    		    }
    	       }
    	  ACTIVE(TRUE):
    	       {
    	       fnTime_DeBug("'fnCheckDST_Rule(): DST Check Error! :DEBUG <',ITOA(__LINE__),'>'") ;
    	       
    	       RETURN ;
    	       }
    	  } 
         if(sMyDST.nDST_Active)
    	  {
    	  fnTime_DeBug("'fnCheckDST_Rule(): DST is Active! :DEBUG <',ITOA(__LINE__),'>'") ;
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnCheckDST_Rule(): DST is In-Active! :DEBUG <',ITOA(__LINE__),'>'") ;
    	  }
    	  
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_DST) ;
    	  
         RETURN ;
         }
         
    DEFINE_FUNCTION fnGet_AstroClock()
    
         {
         LOCAL_VAR INTEGER nTimeMngr_SyncPeriod ;//local just in case I want to view/testing, just get rid of these and the calls that use them
         LOCAL_VAR SINTEGER nTimeMngr_Result ;
         LOCAL_VAR INTEGER nTimeMngr_DST ;
         LOCAL_VAR CHAR cTimeMngr_TmZn[6] ;
         
         fnTime_DeBug("'fnAstro_Clock(): Running ArtoClock! :DEBUG <',ITOA(__LINE__),'>'") ;
         
         nTimeMngr_SyncPeriod = CLKMGR_GET_RESYNC_PERIOD() ;
         cTimeMngr_TmZn = CLKMGR_GET_TIMEZONE() ;
         nTimeMngr_DST = CLKMGR_IS_DAYLIGHTSAVINGS_ON() ;
         
         if(sMyDST.nObserved)
    	  {
    	  fnGet_DST_State() ;
    	  }
         
         //SINTEGER ASTRO_CLOCK(DOUBLE Longitude,DOUBLE Latitude,DOUBLE HoursFromGMT,CHAR[] Date,CHAR[] Sunrise,CHAR[] Sunset)
         nTimeMngr_Result = ASTRO_CLOCK(CLKMGR_LAT,CLKMGR_LONG,CLKMGR_OFF_FROM_GMT,LDATE,sMyTime.cSunrise,sMyTime.cSunset) ;
             
         fnTime_DeBug("'fnAstro_Clock(): Sunset Time = ',sMyTime.cSunset,' :DEBUG <',ITOA(__LINE__),'>'") ;
         sMyTime.nSunset24Hour = atoi(left_string(sMyTime.cSunset,2)) ;
         sMyTime.nSunsetMinute = atoi(mid_string(sMyTime.cSunset,4,2)) ;
         sMyTime.nSunsetSecond = atoi(right_string(sMyTime.cSunset,2)) ;
         sMyTime.nSunsetTime   =  ((((sMyTime.nSunset24Hour * 60) + sMyTime.nSunsetMinute) * 60) + sMyTime.nSunsetSecond) ;
         if(sMyTime.nSunset24Hour >= 12)
              {
    	  sMyTime.nSunset12Hour = sMyTime.nSunset24Hour - 12 ;
    	  }
         else//yeah, I know!
    	  {
    	  sMyTime.nSunset12Hour = sMyTime.nSunset24Hour ;
    	  }
         fnTime_DeBug("'fnAstro_Clock(): Sunrise Time = ',sMyTime.cSunrise,' :DEBUG <',ITOA(__LINE__),'>'") ;
         sMyTime.nSunriseHour   = atoi(left_string(sMyTime.cSunrise,2)) ;
         sMyTime.nSunriseMinute = atoi(mid_string(sMyTime.cSunrise,4,2)) ;
         sMyTime.nSunriseSecond = atoi(right_string(sMyTime.cSunrise,2)) ;
         sMyTime.nSunriseTime   = ((((sMyTime.nSunriseHour * 60) + sMyTime.nSunriseMinute) * 60) + sMyTime.nSunriseSecond) ;
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_SUNRISE) ;
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_SUNSET) ;
         }
         
    DEFINE_FUNCTION fnGet_DayOccurrences()
    
         {
         if(sMyTime.nDayOfWeek && sMyTime.nDayOfMonth)
    	  {
    	  STACK_VAR INTEGER i ;
    	  STACK_VAR INTEGER nD_O_W ;
    	  
    	  sMyTime.nWeekOfMonth = sMyTime.nDayOfMonth / 7 ;
    	  sMyTime.nPlusDays  = sMyTime.nDayOfMonth % 7 ;
    	  
    	  for(i = 1 ; i <= 7 ; i ++)//first erase stored values 
    	       {
    	       sMyTime.nDayOccurance[i] = 0 ;
    	       }
    	
    	  nD_O_W = sMyTime.nDayOfWeek ;
    	  sMyTime.nDayOccurance[nD_O_W] ++ ;
    	  
    	  for(i = sMyTime.nDayOfMonth ; i > 1 ; i --)
    	       {
    	       if(nD_O_W > 1) 
    		    {
    		    nD_O_W --  ;
    		    }		    
    	       else 
    		    {
    		    nD_O_W = 7 ;
    		    }
    	       sMyTime.nDayOccurance[nD_O_W] ++ ;
    	       }
    	  fnTime_DeBug("'fnFindDayOccurences(): The First Day of the Month= ',DAY_OF_WEEK_ABREV[nD_O_W],' (',itoa(nD_O_W),') :DEBUG <',ITOA(__LINE__),'>'") ;
    	  fnTime_DeBug("'fnFindDayOccurences(): Weeks= ',itoa(sMyTime.nWeekOfMonth),', Days= ',itoa(sMyTime.nPlusDays),
    			 ', Day= ',itoa((sMyTime.nWeekOfMonth * 7) + sMyTime.nPlusDays),' of ',MONTH_OF_YR_ABREV[sMyTime.nMonth],' :DEBUG <',ITOA(__LINE__),'>'") ;
    
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnFindDayOccurences(): Error! No Value in sMyTime.nDayOfWeek or sMyTime.nDayOfMonth :DEBUG <',ITOA(__LINE__),'>'") ;
    	  }
         }
         
    DEFINE_FUNCTION fnGet_Holiday()
    
         {
         sMyTime.cHoliday = '' ;
         
         SWITCH(sMyTime.nMonth)
    	  {
    	  CASE JANUARY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = 'New Years Day' ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'M.L.King',39,'s Birthday'" ;
    			 }
    		    }
    	       }
    	  CASE FEBRUARY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 2):
    			 {
    			 sMyTime.cHoliday = 'Ground Hog Day' ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Valentine',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 22):
    			 {
    			 sMyTime.cHoliday = "'G. Washington',39,'s Birthday'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'President',39,'s Day'" ;
    			 }
    		    }
    	       }
    	  CASE MARCH:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 9):
    			 {
    			 sMyTime.cHoliday = "'Employee Appreciation Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 17):
    			 {
    			 sMyTime.cHoliday = "'ST Patrick',39,'s Day'" ;
    			 }
    		    }
    	       //EASTER?
    	       }
    	  CASE APRIL:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = "'April Fool',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Valentine',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == THIRD && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = "'Patriot',39,'s Day'" ;
    			 }
    		    }
    	       }
    	  CASE MAY:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOccurance[SUNDAY] == SECOND && sMyTime.nDayOfWeek == SUNDAY):
    			 {
    			 sMyTime.cHoliday = "'Mother',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[SATURDAY] == THIRD && sMyTime.nDayOfWeek == SATURDAY):
    			 {
    			 sMyTime.cHoliday = "'Armed Forces Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == FOURTH && sMyTime.nDayOfMonth > 24 && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = 'Memorial Day' ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[MONDAY] == FIFTH && sMyTime.nDayOfWeek == MONDAY):
    			 {
    			 sMyTime.cHoliday = 'Memorial Day' ;
    			 }
    		    }
    	       }
    	  CASE JUNE:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 14):
    			 {
    			 sMyTime.cHoliday = "'Flag Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 21):
    			 {
    			 sMyTime.cHoliday = "'Summer Solstice'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[SUNDAY] == THIRD && sMyTime.nDayOfWeek == SUNDAY):
    			 {
    			 sMyTime.cHoliday = "'Father',39,'s Day'" ;
    			 } 
    		    }
    	       }
    	  CASE JULY:
    	       {
    	       if(sMyTime.nDayOfMonth == 4)
    		    {
    		    sMyTime.cHoliday = 'Independence Day' ;
    		    }
    	       }
    	  CASE AUGUST:
    	       {
    	       if(sMyTime.nDayOccurance[SUNDAY] == FIRST && sMyTime.nDayOfWeek == SUNDAY)
    		    {
    		    sMyTime.cHoliday = "'Friendship Day'" ;
    		    } 
    	       }
    	  CASE SEPTEMBER:
    	       {
    	       if(sMyTime.nDayOccurance[MONDAY] == FIRST && sMyTime.nDayOfWeek == MONDAY)
    		    {
    		    sMyTime.cHoliday = 'Labor Day' ;
    		    }
    	       }
    	  CASE OCTOBER:
    	       {
    	       if(sMyTime.nDayOfMonth == 31)
    		    {
    		    sMyTime.cHoliday = 'Halloween' ;
    		    }
    	       }
    	  CASE NOVEMBER:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth == 1):
    			 {
    			 sMyTime.cHoliday = "'All Saint',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 11):
    			 {
    			 sMyTime.cHoliday = "'Veteran',39,'s Day'" ;
    			 }
    		    ACTIVE(sMyTime.nDayOccurance[THURSDAY] == FOURTH && sMyTime.nDayOfWeek == THURSDAY):
    			 {
    			 sMyTime.cHoliday = 'Thanksgiving Day' ;
    			 }
    		    }
    	       }
    	  CASE DECEMBER:
    	       {
    	       SELECT
    		    {
    		    ACTIVE(sMyTime.nDayOfMonth >= 1 && sMyTime.nDayOfMonth <= 23):
    			 {
    			 sMyTime.cHoliday = "ITOA(25 - sMyTime.nDayOfMonth),' days to Christmas'" ;
    			 }
    		    (*
    		    ACTIVE(nMY_DayOfMonth == 21):
    			 {
    			 cHoliday = 'Winter Solstice' ;
    			 }
    		    *)
    		    ACTIVE(sMyTime.nDayOfMonth == 24):
    			 {
    			 sMyTime.cHoliday = 'Christmas Eve' ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 25):
    			 {
    			 sMyTime.cHoliday = 'Christmas Day' ;
    			 }
    		    ACTIVE(sMyTime.nDayOfMonth == 31):
    			 {
    			 sMyTime.cHoliday = "'New Year',39,'s Eve'" ;
    			 }
    		    }
    	       }
    	  }
         if(length_string(sMyTime.cHoliday))
    	  {
    	  sMyTime.cHoliday = "'"',sMyTime.cHoliday,'"'" ;
    	  fnTime_DeBug("'fnFindHolidays(): Today is ',sMyTime.cHoliday,' :DEBUG <',ITOA(__LINE__),'>'") ;
    	  }
         else
    	  {
    	  fnTime_DeBug("'fnFindHolidays(): Today is not a "supported" holiday! :DEBUG <',ITOA(__LINE__),'>'") ;
    	  }
    	  
         fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_HOLIDAY) ;
         
         RETURN ;
         }
         
    DEFINE_FUNCTION fnGet_WebDATE_TIME()
    
         {
         sMyTime.cWebCurDateTime = "fnDo_24hrTimeAddition(LDate,TIME,0),' EST'" ;
         sMyTime.cWebExpDateTime = "fnDo_24hrTimeAddition(LDate,TIME,EXPIRES_IN_SECONDS),' EST'" ;
        
         RETURN ;
         }
         
    DEFINE_FUNCTION fnRun_D_O_W_Events(INTEGER iDayOfWeek)   //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER cCopyDOW ;
         
         cCopyDOW  = iDayOfWeek ;
         //SELECT ACTIVE or SWITCH CASE to do something
         }     
         
    DEFINE_FUNCTION fnRun_D_O_M_Events(INTEGER iDayOfMonth)  //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {//uncomment call in fnUpdate_Time()
         STACK_VAR INTEGER cCopyDOM ;
         
         cCopyDOM  = iDayOfMonth ;
         //SELECT ACTIVE or SWITCH CASE to do something
         }
         
    DEFINE_FUNCTION fnRun_DailyEvents()                      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         //fnDailyEmailTest() ;
         fnGet_Holiday() ;
         fnGet_AstroClock() ;
         //SELECT ACTIVE or SWITCH CASE to do something
         }
         
    DEFINE_FUNCTION fnRun_HourEvents(INTEGER iHour)          //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER cCopyHour ;
         
         cCopyHour  = iHour ;
         //SELECT ACTIVE or SWITCH CASE to do something
         }
    
    DEFINE_FUNCTION fnRun_MinuteEvents(INTEGER iMinute)      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {
         STACK_VAR INTEGER cCopyMinute ;
         
         cCopyMinute  = iMinute ;
         
         //SELECT ACTIVE or SWITCH CASE to do something
         } 
    
    DEFINE_FUNCTION fnRun_SecondEvents(INTEGER iSecond)      //<<**************  CHANGE SETTING PER JOB **********************************>>>
    
         {//uncomment call in fnUpdate_Time()
         STACK_VAR INTEGER cCopySecond ;
         
         cCopySecond  = iSecond ;
         //SELECT ACTIVE or SWITCH CASE to do something
         }
         
    DEFINE_FUNCTION fnRun_StartUpCode() 
    
         {
         LOCAL_VAR CLKMGR_TIMEOFFSET_STRUCT sMyCLKMGR_TIMEOFFSET ;
         
         fnTime_DeBug("'fnRunStartUpCode(): Run Start Up! :DEBUG <',ITOA(__LINE__),'>'") ;
         nTimeWait_Force = 1 ;
         
         sMyDST.nObserved = DST_OBSERVED ;
         
         if(sMyDST.nObserved)
    	  {
    	  sMyDST.nOffset	= DST_OFFSET ;
    	  sMyDST.nBEG_Month	= DST_BEGIN_MONTH ;
    	  sMyDST.nEND_Month     = DST_END_MONTH ;
    	  sMyDST.nBEG_Day       = DST_BEGIN_DAY ;
    	  sMyDST.nEND_Day 	= DST_END_DAY ;
    	  sMyDST.nBEG_DAY_Occurance = DST_BEGINDAY_OCCURANCE ;
    	  sMyDST.nEND_DAY_Occurance = DST_ENDDAY_OCCURANCE ;
    	  }     
         
         WAIT 300//3000
    	  {
    	  fnTime_DeBug("'fnRunStartUpCode(): Run Start Up Wait items! :DEBUG <',ITOA(__LINE__),'>'") ;
    	  CLKMGR_SET_CLK_SOURCE(CLKMGR_MODE_NETWORK) ; // or CLKMGR_MODE_STANDALONE
    	  CLKMGR_SET_ACTIVE_TIMESERVER (CLKMGR_ACTIVESERVER) ;
    	  CLKMGR_SET_TIMEZONE(CLKMGR_TIME_ZONE) ;
    	  CLKMGR_SET_DAYLIGHTSAVINGS_MODE(TRUE) ;
    	  CLKMGR_SET_START_DAYLIGHTSAVINGS_RULE("'occurrence:',itoa(DST_BEGINDAY_OCCURANCE),',',itoa(DST_BEGIN_DAY),',',itoa(DST_BEGIN_MONTH),',',DST_BEGIN_TIME" ) ;
    	  CLKMGR_SET_END_DAYLIGHTSAVINGS_RULE("'occurrence:',itoa(DST_ENDDAY_OCCURANCE),',',itoa(DST_END_DAY),',',itoa(DST_END_MONTH),',',DST_END_TIME" ) ;
    	  CLKMGR_SET_RESYNC_PERIOD(CLKMGR_RESYNC_PERIOD) ;
    	  
    	  sMyCLKMGR_TIMEOFFSET.HOURS   = CLKMGR_DST_OFFSET_HR ;
    	  sMyCLKMGR_TIMEOFFSET.MINUTES = CLKMGR_DST_OFFSET_MIN ;
    	  sMyCLKMGR_TIMEOFFSET.SECONDS = CLKMGR_DST_OFFSET_SEC ;
    	  CLKMGR_SET_DAYLIGHTSAVINGS_OFFSET(sMyCLKMGR_TIMEOFFSET) ;
    	  
    	  nTimeWait_Force = 2 ;
    	  fnUpdate_Time() ;
    	  }
         }
         
    DEFINE_FUNCTION fnUpdate_Time()
         
         {
         if(nTimeWait_Force != 1)
    	  {
    	  if(sMyTime.nSecond != TYPE_CAST(TIME_TO_SECOND(TIME)) || nTimeWait_Force)
    	       {
    	       sMyTime.nSecond = TYPE_CAST(TIME_TO_SECOND(TIME)) ;
    	       if(sMyTime.nMinute != TYPE_CAST(TIME_TO_MINUTE(TIME)) || nTimeWait_Force)
    		    {
    		    sMyTime.nMinute = TYPE_CAST(TIME_TO_MINUTE(TIME)) ;
    		    if(sMyTime.n24Hour != TYPE_CAST(TIME_TO_HOUR(TIME)) || nTimeWait_Force)
    			 {
    			 sMyTime.n24Hour = TYPE_CAST(TIME_TO_HOUR(TIME)) ;
    			 if(sMyTime.n24Hour >= 12)
    			      {
    			      sMyTime.nTimePM_flag = 1 ;
    			      sMyTime.n12Hour = sMyTime.n24Hour - 12 ;
    			      }
    			 else
    			      {
    			      sMyTime.nTimePM_flag = 0 ;
    			      sMyTime.n12Hour = sMyTime.n24Hour ;
    			      }
    			 if(sMyTime.nDayOfMonth != TYPE_CAST(DATE_TO_DAY(LDATE)) || nTimeWait_Force)
    			      {
    			      sMyTime.nDayOfMonth = TYPE_CAST(DATE_TO_DAY(LDATE)) ;
    			      sMyTime.nDayOfWeek = TYPE_CAST(DAY_OF_WEEK(LDATE)) ;
    			      if(sMyTime.nMonth != TYPE_CAST(DATE_TO_MONTH(LDATE)))//no force here.  would erase stored values.
    				   {
    				   sMyTime.nMonth = TYPE_CAST(DATE_TO_MONTH(LDATE)) ;
    				   if(sMyTime.nYear != TYPE_CAST(DATE_TO_YEAR(LDATE)))
    					{
    					sMyTime.nYear = TYPE_CAST(DATE_TO_YEAR(LDATE)) ;
    					}
    				   }
    			      if(sMyTime.cDay != Day || nTimeWait_Force)
    				   {
    				   sMyTime.cDay = Day ;
    				   if (sMyTime.cDate != Date)
    					{
    					sMyTime.cDate = Date ;
    					}
    				   }
    			      fnGet_DayOccurrences() ;
    			      fnRun_D_O_W_Events(sMyTime.nDayOfWeek) ;
    			      fnRun_D_O_M_Events(sMyTime.nDayOfMonth) ;
    			      fnRun_DailyEvents() ;
    			      }
    			 fnRun_HourEvents(sMyTime.n24Hour) ;
    			 }
    		    sMyTime.nTime = (((sMyTime.n24Hour * 60) + sMyTime.nMinute) * 60) ;
    		    if(sMyTime.nTime >= sMyTime.nSunriseTime && sMyTime.nTime < sMyTime.nSunsetTime)
    			 {
    			 sMyTime.nDaytime = 1 ;
    			 }
    		    else
    			 {
    			 sMyTime.nDaytime = 0 ;
    			 }			 
    		    fnRun_MinuteEvents(sMyTime.nMinute) ;
    		    }
    	       sMyTime.c24Time = TIME ;
    	       sMyTime.c12Time = "itoa(sMyTime.n12Hour),':',itoa(sMyTime.nMinute),':',itoa(sMyTime.nSecond)" ;
    	       fnRun_SecondEvents(sMyTime.nSecond) ;
    	       //fnFB_Time(UI_UPDATE_ACTIVE,FB_TIME_TIME) ; //IF ANYTHING NEEDS TIME UPDATES
    	       }
    	  nTimeWait_Force  = 0 ;
    	  }
         }          
    DEFINE_START    //RUN START UP CODE
         
    fnRun_StartUpCode() ;
         
    DEFINE_PROGRAM  //CALL fnUpdate_Time() if you don't have a timeline elsewhere to call it every second
    (*
    WAIT 10
         {
         fnUpdate_Time() ;
         }
    *)
    
  • John NagyJohn Nagy Posts: 1,742
    Must be enabled to use CPU USAGE

    This from our head of engineering, CJ Butcher:

    The CPU USAGE command only gives valid number after the usage system is started with the “reboot heap watch” command in TELNET. Otherwise it will always give the same numbers which are a snap shot taken at boot time. This mode is turned off at next normal reboot.

    The numbers are obviously going to vary based on what your system is currently doing. If you run the CPU USAGE command several time you’ll see the numbers fluctuate. Having a max of 99% is not uncommon. You average of 60% is pretty normal.

    Here is what my test processor happened to be at when I looked: (System was handling some traffic but not much.)
    CPU usage = 9.71% (30 sec. average = 51.85%, 30 sec. max = 99.96%)

    Here are my numbers during a reboot:
    CPU usage = 96.61% (30 sec. average = 21.10%, 30 sec. max = 96.61%)
  • Darkman88Darkman88 Posts: 45
    John Nagy wrote: »
    This from our head of engineering, CJ Butcher:

    The CPU USAGE command only gives valid number after the usage system is started with the “reboot heap watch” command in TELNET. Otherwise it will always give the same numbers which are a snap shot taken at boot time. This mode is turned off at next normal reboot.

    The numbers are obviously going to vary based on what your system is currently doing. If you run the CPU USAGE command several time you’ll see the numbers fluctuate. Having a max of 99% is not uncommon. You average of 60% is pretty normal.

    Here is what my test processor happened to be at when I looked: (System was handling some traffic but not much.)
    CPU usage = 9.71% (30 sec. average = 51.85%, 30 sec. max = 99.96%)

    Here are my numbers during a reboot:
    CPU usage = 96.61% (30 sec. average = 21.10%, 30 sec. max = 96.61%)


    I Undersending it in reboot phase.

    But if I've done a clean disk befor and I connected with the normal widows telnet the CPU Usage is at 0%
    But if I connected with NetLinx Studio 3 utility the CPU Usage is always at 99% I think that is a bug in NetlixStudio 3.0

    Kman88
  • Darkman88Darkman88 Posts: 45
    I Attach two different screenshot in the first you will se a netlink telnet and you can see the Telenet service that consume so much CPU.
    In the second Screenshot you can see the standard windows telnet that not consume CPU.

    The prohram is the same planck program in the two cases
Sign In or Register to comment.