Milliseconds
JOHNBONZ
Junior Member
I am trying to get Netlinx to show milliseconds like you would in Java:
Java:
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis());
Result:
Calender - Time in milliseconds : 1421893256000
Does anyone know how to do so? I tried in Timeline event
Netlinx:
TimeLine= TL_ET
long lRunTime;
lRunTime = TIMELINE_GET(TL_ET)
send_string 0,"lRunTime=',ITOA(lRunTime)";
Result:
lRunTime=6
returns single digit -- I want milliseconds - anyone know how to do this?
Java:
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis());
Result:
Calender - Time in milliseconds : 1421893256000
Does anyone know how to do so? I tried in Timeline event
Netlinx:
TimeLine= TL_ET
long lRunTime;
lRunTime = TIMELINE_GET(TL_ET)
send_string 0,"lRunTime=',ITOA(lRunTime)";
Result:
lRunTime=6
returns single digit -- I want milliseconds - anyone know how to do this?
Comments
-
yeah, the example of this in the help isn't very helpful, is it...
Have your tried FTOA? Another thought might be to load the value into a global variable and look at it in debug and see what the value(s) is/are.
-
If you go into Telnet and set Msg=ON, and then do some displays, it shows milliseconds in the telnet window - Great!! But I want to be able to show that in the netlinx code itself. To me getting milliseconds is fundamental programming in any language - I am surprised the folks at AMX do not give you a way to achieve this
TELNET WINDOW
>msg on (in Bold is the millisencds)
(0001284161) INSIDE lRunTime=6
(0001284162)
(0001284163) LOOP MAIN TIMELINE TL_ET
(0001284163)
(0001284164) EVENT INDEX I=1
(0001284165) LOOP nProcessSceneET=0
-
If you go into Telnet and set Msg=ON, and then do some displays, it shows milliseconds in the telnet window - Great!! But I want to be able to show that in the netlinx code itself. To me getting milliseconds is fundamental programming in any language - I am surprised the folks at AMX do not give you a way to achieve this
TELNET WINDOW
>msg on (in Bold is the millisencds)
(0001284161) INSIDE lRunTime=6
(0001284162)
(0001284163) LOOP MAIN TIMELINE TL_ET
(0001284163)
(0001284164) EVENT INDEX I=1
(0001284165) LOOP nProcessSceneET=0
I guess I'm confused. I do code math and so forth on "right of the decimal point" all the time. You use FLOAT variables.
You can do things like
IF(fMy_Float_Number=0.003){//do something}
Here's the text from the help file:
FLOAT defines an intrinsic data type representing a 64-bit signed floating-point value. It is used to store small real numbers with 5 digits of precision.- Data Type: Floating Point
- Sign: Signed
- Size: 64-bit
- Range: ?1.17549E-38 to ?3.40282E+38
- Sample of Stored Values: 1.2345, 123.4512345e5, -16.3231415
-
John what i do when using the TIMELINE_GET function is use it at the top and bottom of my timeline (or whatever fashion works in your code) and subtract the first from the last.
STACK_VAR LONG lStart STACK_VAR LONG lEnd STACK_VAR LONG lTime lStart = TIMELINE_GET( TL_WHATEVER ) ...lots of code..... lEnd = TIMEINE_GET( TL_WHATEVER ) lTime = lEnd - lStart SEND_STRING 0,"'Result: ',ITOA( lTime ),'ms'"
EDIT: I just realized you are referring to actual time and not time elapsed, sorry this wont work for you. -
What I am saying I want the system to supply me with milliseconds. Once I have the value I can parse it out, store it, use float to display it etc. But the issue is system doesn't supply me with this info like I can retrieve in Java. Not sure why as operating system use milliseconds. I think the AMX engineers should allow us to access system time in milliseconds since it is behind the scenes it is already using it.
Matt in your example, wouldn't it be nice to call a function, and at the top of function display start time, then at the end display how long process or function took to run in milliseconds. The example below does this but in 1/10 of a second so the values maybe the same if process takes less than 1/10 of a second
FUNCTION.....
"'START SORT CURRENT TIME =',ITOA(GET_TIMER)";
.
.
.
.
"'END SORT CURRENT TIME =',ITOA(GET_TIMER)";
-
You might have to telnet into the master and get use the terminal commands to get milliseconds.
-
The timeline_get command is returning milliseconds, but it's millisecond since you started the time line. I think this code example is doing what you're looking for. Sample output is below too.
PROGRAM_NAME='test' DEFINE_DEVICE dvtp = 10001:1:0 DEFINE_CONSTANT TL_ET = 1 DEFINE_VARIABLE LONG day_in_milli[] = {86400000} long check[3] DEFINE_EVENT button_event[dvtp,1]{ push:{ if(!timeline_active(tl_et)){ TIMELINE_CREATE(TL_ET,day_in_milli,length_array(day_in_milli),TIMELINE_RELATIVE,timeline_repeat) } check[1] = TIMELINE_GET(TL_ET) send_string 0,"'0 sec: lRunTime=',ITOA(check[1])"; wait 10 { //wait 1 sec check[2] = TIMELINE_GET(TL_ET) send_string 0,"'1 sec: lRunTime=',ITOA(check[2])"; } wait 100 { //wait 10 sec check[3] = TIMELINE_GET(TL_ET) send_string 0,"'10 sec: lRunTime=',ITOA(check[3])"; send_string 0,"'1 - 0: ',itoa(check[2] - check[1])" send_string 0,"'10 - 0: ',itoa(check[3] - check[1])" send_string 0,"'10 - 1: ',itoa(check[3] - check[2])" } } } DEFINE_PROGRAM
Line 1 (09:27:21):: 0 sec: lRunTime=0
Line 2 (09:27:21):: Memory Available = 208615600 <23704>
Line 3 (09:27:22):: 1 sec: lRunTime=1001
Line 4 (09:27:31):: 10 sec: lRunTime=9998
Line 5 (09:27:31):: 1 - 0: 1001
Line 6 (09:27:31):: 10 - 0: 9998
Line 7 (09:27:31):: 10 - 1: 8997
Line 8 (09:28:14):: 0 sec: lRunTime=53600
Line 9 (09:28:15):: 1 sec: lRunTime=54599
Line 10 (09:28:24):: 10 sec: lRunTime=63596
Line 11 (09:28:24):: 1 - 0: 999
Line 12 (09:28:24):: 10 - 0: 9996
Line 13 (09:28:24):: 10 - 1: 8997
Line 14 (09:30:29):: 0 sec: lRunTime=188016
Line 15 (09:30:30):: 1 sec: lRunTime=189020
Line 16 (09:30:39):: 10 sec: lRunTime=198017
Line 17 (09:30:39):: 1 - 0: 1004
Line 18 (09:30:39):: 10 - 0: 10001
Line 19 (09:30:39):: 10 - 1: 8997
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums