IO Status Monitor Module
MODULE_NAME='IOStatusModule'(DEV dvIO, DEV tp_IO[])
/*
pass in an EXB device, or the IO/Relay port from a master
and an array of touchpanels (ports)
*/
DEFINE_CONSTANT
INTEGER STATUS[] = {11,12,13,14,15,16,17,18} //shows I/O status. feedback only.
INTEGER CHANNELS[] = {1,2,3,4,5,6,7,8} //the I/O channels
INTEGER BTNS_ON[] = {21,22,23,24,25,26,27,28} // turn on a channel
INTEGER BTNS_OFF[] = {31,32,33,34,35,36,37,38} //turn off a channel
DEFINE_EVENT
BUTTON_EVENT[tp_IO, BTNS_ON]
{
PUSH:{
ON[dvIO, CHANNELS[GET_LAST(BTNS_ON)]]
}
}
BUTTON_EVENT[tp_IO, BTNS_OFF]
{
PUSH:{
OFF[dvIO, CHANNELS[GET_LAST(BTNS_OFF)]]
}
}
CHANNEL_EVENT[dvIO, CHANNELS]
{
ON:{
ON[tp_IO, STATUS[GET_LAST(CHANNELS)]]
}
OFF:{
OFF[tp_IO, STATUS[GET_LAST(CHANNELS)]]
}
}
gist of main
DEFINE_DEVICE//IO
dvREL8_1 = 12001:1:0 //exb-rel8
dvIOMaster_1 = 5001:4:0 //ni-700
dvTP1REL8_1 = 11001:61:0 ; dvTP2REL8_1 = 11002:61:0 ; dvTP3REL8_1 = 11003:61:0
dvTP1IOMaster_1 = 11001:66:0 ; dvTP2IOMaster_1 = 11002:66:0 ; dvTP3IOMaster_1 = 11003:66:0
DEFINE_CONSTANT
DEV dv_TPs_REL8_1[] = {dvTP1REL8_1,dvTP2REL8_1,dvTP3REL8_1}
DEV dv_TPs_IOMaster_1[] = {dvTP1IOMaster_1,dvTP2IOMaster_1,dvTP3IOMaster_1}
DEFINE_MODULE'IOStatusModule' mdldvREL8_1(dvREL8_1, dv_TPs_REL8_1)
DEFINE_MODULE'IOStatusModule' mdldvIOMaster_1(dvIOMaster_1, dv_TPs_IOMaster_1)
Might throw in some diagnostics window messages. Mostly this is just a way to have a panel page for ringing stuff out and seeing what's going on with your IO, without having to muck with your main program logic.
0
Comments
This is something I'd probably just do in diagnostics/notifications and not even bother with code myself. But thanks.