A random Programming Example -- DSS Music Channels
John Gonzales
Posts: 609
I wanted to start some posts showing actual use of some of the Netlinx programming language. I figure this might help some folks out that are trying to learn the language. Hopefully there will be additional responses that show other ways of accomplishing the same task, to further the learning experience and spark conversation regarding programming techniques.
Following is a random example of how to select Favorite Music Channels on a DSS receiver. There are several ways to do this, feel free to post other ways, or shortcuts.
Main Keywords used:
Send_Command
XCH
XCHM
ITOA
button.input.channel
DATA_EVENT
Online:
TP Setup:
The touchpanel would have a page that has individual buttons labelled with the Music Station, e.g. "The 40's, The 50's, etc...". The buttons would be assigned a Channel Code in TPD4 that is the same as the station number, e.g. "The 40's" is channel 801 on DirecTV, so you would assign the Channel Code as 801 when you design the Touchpanel page. If there are future changes to the channel lineup on the satellite TV service provider, you can adjust the channel codes on the touchpanel which will affect the button.input.channel that is sent through the XCH command.
--John
Following is a random example of how to select Favorite Music Channels on a DSS receiver. There are several ways to do this, feel free to post other ways, or shortcuts.
Main Keywords used:
Send_Command
XCH
XCHM
ITOA
button.input.channel
DATA_EVENT
Online:
TP Setup:
The touchpanel would have a page that has individual buttons labelled with the Music Station, e.g. "The 40's, The 50's, etc...". The buttons would be assigned a Channel Code in TPD4 that is the same as the station number, e.g. "The 40's" is channel 801 on DirecTV, so you would assign the Channel Code as 801 when you design the Touchpanel page. If there are future changes to the channel lineup on the satellite TV service provider, you can adjust the channel codes on the touchpanel which will affect the button.input.channel that is sent through the XCH command.
DEFINE_DEVICE (*ACTUAL DEVICES*) dvDSS=5001:1:0 //SONY HD DSS Receiver (*TOUCHPANEL PAGES*) tpDSS=10001:1:0 //DSS Page on Touchpanel DEFINE_VARIABLE INTEGER MUSIC_FAVORITE_CHAN[] = {800,801,802,803,804,805,806,807,808,809, 810,811,812,813,814,815,816,817,818,819, 820,821,822,823,824,825,826,827,828,829, 830,831,832,833,834,835,836,837,838,839, 840,841,842,843,844,845,846,847,848,849, 850,851,852,853,854,855,856,857,858,859, 860,861,862,863,864,865,866,867,868,869, 870,871,872,873,874,875,876,877,878,879} DEFINE_EVENT DATA_EVENT[dvDSS] { ONLINE: { SEND_COMMAND dvDSS, 'XCHM-1' } } BUTTON_EVENT[tpDSS,MUSIC_FAVORITE_CHAN] //Button Press - Favorite Music Channel { PUSH: { SEND_COMMAND dvDSS,"'XCH ',ITOA(Button.Input.Channel)" } }
--John
0
Comments
Keyword Discussion:
Send_Command - used to send a command to a port on the Netlinx. The device would be connected to the Netlinx port via IR, RS-232, Contact Closure, etc... This is one of the basics of sending commands to a device.
XCH - Transmit the selected channel IR codes in the format/pattern set by the 'XCHM' send command.
XCHM - Sets the pattern for the IR commands sent by 'XCH'. See Sofware History for an explanation of the Modes and Syntax.
ITOA - Converts an integer to an ASCII value.
button.input.channel - This is a button object or information that gets stored when a button is pressed. When a button is pressed, information about the button is stored in several variables which you can access. Button.input.channel will be the value of the channel code of the button that was pressed.
DATA_EVENT - This is an event handler. When Netlinx detects that an event occurs, it will look for an event handler to tell it what to do. In the programming example above it looks for an Online event to happen. When the Online event happens for dvDSS it executes the code after the Online:. Another event would be when a button is pressed on an attached Touchpanel... that would be a BUTTON_EVENT
--John
I somewhat do the same thing as John, except I don't use an array for the channels. I also tend to stay away from the XCH command, so I use the little routine that was shared under another thread. I'll make all the DSS (or cable) channels a specific port on the panel, and code it like so.
This will call the routine when ANY button that is on port 2 of the touch panel is pressed, and send the button number to the routine.
Just a little short cut. This way, I don't have to type up an array for which channels I use, and also if the client wants channels changed, I don't need to do anything with code. It's a simple change in the TP file, and the processor doesn't need to be reloaded with a channel number change.
My new and improved fusion powered NI-3905 has built-in Ultra extended HD TiVo DSS/MAX Mark VI content server with 500 terabyte removeable USB HD, 10kW/channel Dolby 11.1 GPS surround sound, and advanced ESP processor with alpha wave discriminator. They have also manangerd to reduce the size to a single rack space and dropped the price to $295. MSP.
Excuse me? How does defining a button with a higher number than the last undefined button burden memory and resources??? I think you are confused with declaring master port devices.
Fixed it