Netlinx SFX (Episode 1: Hartbeat or stroke?)
wengerp
Posts: 29
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
0
Comments
should be;
LONG _HB_TIMEARRAY[] = { 10000 }
Patrick