Best practice question (migrate from ni to nx)
Hi,
I'm currently updating an ni system to a nx-4200. I have 2 questions regarding code structure.
I presume the ni program was originally an accent because a lot of work were done in define program ( feedback, serial parsing) and no define_function only define_call.
1). I'm creating ? timeline_event to provide feedback. It is better to use everything in the timeline_event with a timeline. S?quence or create a function feedback() and recall it inside the timeline. Prior i was using my feedback() in define_program but with the nx serie is no more recommand?s to use
2) do i still using define_call or replace them with define_fonction.
Thanks for your input.
I'm currently updating an ni system to a nx-4200. I have 2 questions regarding code structure.
I presume the ni program was originally an accent because a lot of work were done in define program ( feedback, serial parsing) and no define_function only define_call.
1). I'm creating ? timeline_event to provide feedback. It is better to use everything in the timeline_event with a timeline. S?quence or create a function feedback() and recall it inside the timeline. Prior i was using my feedback() in define_program but with the nx serie is no more recommand?s to use
2) do i still using define_call or replace them with define_fonction.
Thanks for your input.
0
Comments
I actually don't use define_call myself as it's left over from olden days of yore... But I think it still works just fine in the NX series procs.
You also might want to take a look at the modules being used. There may be newer ones.
Button_Event[dvTP, BTN_DEVICE1_POWER] { Push: SendDevice1PowerOn() } Timeline_Event[TL_FEEDBACK] { [dvTP, BTN_DEVICE1_POWER] = nDevice1PowerOn } Button_Event[dvTP, BTN_DEVICE2_POWER] { Push: SendDevice2PowerOn() } Timeline_Event[TL_FEEDBACK] { [dvTP, BTN_DEVICE2_POWER] = nDevice2PowerOn }For the TP Feedback, it will be better to have a timeline_event for everyTP who will be activate if the tp goes online.
GregG approach for timeline is very easy to read, button_event follow by timeline_event.
Nope, they work the same. Here's a little test program to illustrate.
PROGRAM_NAME='test' DEFINE_DEVICE vdv_MyDevice = 34001:01:1 define_function fn_My_Function(){ stack_var integer fun_loop; for(fun_loop=5;fun_loop;fun_loop--){ send_string 0," 'fun_loop=',itoa(fun_loop)" }// for send_string 0, 'Fun_Step_2'; send_string 0, 'Fun_Step_3'; } // def_fun define_call 'My_Call'{ stack_var integer call_loop; for(call_loop=5;call_loop;call_loop--){ send_string 0," 'call_loop=',itoa(call_loop)"; } // for send_string 0, 'Call_Step_2'; send_string 0, 'Call_Step_3'; } // def_call DEFINE_EVENT button_event[vdv_MyDevice,1]{ push:{ send_string 0, 'Before the Call'; call 'My_Call' send_string 0, 'After the Call'; } } //b_e button_event[vdv_MyDevice,2]{ push:{ send_string 0, 'Before the Function'; fn_My_Function(); send_string 0, 'After the Function'; } } //b_eand the result
the function
Here again, netlinx is not multi-thread.
so what I do I update my buttons in these events, which will make the button state changes only when the device send a notification about that, which make very sense, why should I keep updating the touch panel every one second, personally I treat this as overload on the master and network
I hope that this could help
I love the organization of doing it that way. Is there any real-world drawback to having it spread out everywhere like that?
However, I also don't do very much feedback in timelines of any sort, due to the performance effects of constantly updating feedback for things that have not changed.