Netlinx SFX (Episode 1: Hartbeat or stroke?)
wengerp
Junior Member
Recently I was about to implement a simple hartbeat timeline as I usually do it. However, for some reason this time it didn't work out as expected. I took me quite some time to find the error in the code. That's why I added this error to my personal "hall of fame" of Netllinx unexpected behaviors (I call it "special effects" hence the titel "SFX"). Since maybe others may struggle as well, I'm proud to present you my newest SFX-member:
simplified code sample:
expected result:
real result:
So, what's wrong with this code? The first correct answer earns prise and honor (sorry: no free NI or something.... ;-)
Patrick
simplified code sample:
PROGRAM_NAME='NI-SFX'
DEFINE_CONSTANT
INTEGER _HB_TIMELINE = 1
INTEGER _HB_TIMEARRAY[] = { 10000 }
DEFINE_VARIABLE
volatile long _HB_COUNT = 0
DEFINE_START
IF(!(TIMELINE_ACTIVE(_HB_TIMELINE)))
{
SEND_STRING 0, "'starting HB_TIMELINE (ID ',itoa(_HB_TIMELINE),')'"
TIMELINE_CREATE(_HB_TIMELINE,_HB_TIMEARRAY,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
}
DEFINE_EVENT
TIMELINE_EVENT[_HB_TIMELINE]
{
SEND_STRING 0, "'HB count=',itoa(_HB_COUNT)"
_HB_COUNT = 0
}
DEFINE_PROGRAM
_HB_COUNT++
expected result:
... Line 26 (10:42:07):: CIpInterpreter::Run - Execute Startup Code Line 27 (10:42:08):: starting HB_TIMELINE (ID 1) ... Line 49 (10:42:18):: HB count=190291 Line 50 (10:42:28):: HB count=193749 Line 51 (10:42:38):: HB count=193674 Line 52 (10:42:48):: HB count=193626 Line 53 (10:42:58):: HB count=193685 ...
real result:
... Line 23 (10:42:07):: CIpInterpreter::Run - Execute Startup Code Line 24 (10:46:56):: starting HB_TIMELINE (ID 1) Line 25 (10:46:56):: CIpTimeline::Create - Error 2 ...
So, what's wrong with this code? The first correct answer earns prise and honor (sorry: no free NI or something.... ;-)
Patrick
Comments
-
INTEGER _HB_TIMEARRAY[] = { 10000 }
should be;
LONG _HB_TIMEARRAY[] = { 10000 } -
Wow, that was fast. It took me definitely longer to figure it out. Congrats!
Patrick -
BTW: wouldn't this be worth a compiler warning?
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