I got my USB-UIRT on Saturday and wasted no time putting together a web based software that I can run on any computer on the internet. For now I have a monitor and mouse behind my couch but I will be buying a touch screen soon. I did the whole thing in .net and it works very well. I have attached a component diagram and a screen shot of the interface. Most of the time was spent collecting the graphics/icons, that and training all the IR codes. I wrote about 2,000 lines of code to make it all work.
Components controlled
Click to view attachment
Interface
Click to view attachment
I am having trouble getting receive events working over RS232 from the projector. I can send commands just fine. Projector control is a mixture of IR for toggle commands and RS232 for specific settings like aspect ratio. The source switching is beautiful and it allows me to change audio, video, aspect ratio and overscan in one click. To do that with the remotes required 4 different remotes and muliple button pushes on one of them. The channel macros are nice also. I mad a list of my favorite channels as number enums.
CODE
/// <summary>
/// A list of Channels
/// </summary>
public enum Channel
{
Discovery=776,
FOX=708,
NFL=777,
ABC=710,
NBC=713,
CBS=706,
AandE=771,
HBO=750,
ESPN=772,
ESPN2=778,
NESN=733,
TNT=764,
}
/// A list of Channels
/// </summary>
public enum Channel
{
Discovery=776,
FOX=708,
NFL=777,
ABC=710,
NBC=713,
CBS=706,
AandE=771,
HBO=750,
ESPN=772,
ESPN2=778,
NESN=733,
TNT=764,
}
The string for a channel can be sent from the JavaScript links on the page via AJAX and then parsed using the following code.
CODE
/// <summary>
/// Takes a channel name and sends the commands to change to that channel
/// </summary>
/// <param name="strChannel">Channel Name</param>
[AjaxPro.AjaxMethod]
public static void ChannelCommmand(string strChannel)
{
Controller uirt = new Controller();
// make str into enum type
Channel channel = (Channel)Enum.Parse(typeof(Channel), strChannel);
// get the channel # via cast
int channelNumber = (int)channel;
// pop it into a char array
char[] digits = channelNumber.ToString().ToCharArray();
// loop through each char of the channel
foreach (char digit in digits)
{
// get the index of the number in the static array
int codeIndex = Convert.ToInt32(digit.ToString());
// transmit the propper code using the index
uirt.Transmit(ControlCodes.SA8300HD.Number[codeIndex]);
}
// transmit an accept code for immediate results
uirt.Transmit(ControlCodes.SA8300HD.Button_Select);
}
/// Takes a channel name and sends the commands to change to that channel
/// </summary>
/// <param name="strChannel">Channel Name</param>
[AjaxPro.AjaxMethod]
public static void ChannelCommmand(string strChannel)
{
Controller uirt = new Controller();
// make str into enum type
Channel channel = (Channel)Enum.Parse(typeof(Channel), strChannel);
// get the channel # via cast
int channelNumber = (int)channel;
// pop it into a char array
char[] digits = channelNumber.ToString().ToCharArray();
// loop through each char of the channel
foreach (char digit in digits)
{
// get the index of the number in the static array
int codeIndex = Convert.ToInt32(digit.ToString());
// transmit the propper code using the index
uirt.Transmit(ControlCodes.SA8300HD.Number[codeIndex]);
}
// transmit an accept code for immediate results
uirt.Transmit(ControlCodes.SA8300HD.Button_Select);
}
I am excited to get an X10 firecracker to control the lights in the living room and around the house. I would rather get RadioRA but it is just too expesive at the moment. The RS232 for RadioRA costs ~$700 and the x10 Firecracker cost ~$40. I guess I will just have to wait for my raise / bonus to get RadioRA. Anyway the X10 firecracker is apparently really easy to control via RS232 which is super easy to do in .NET, check out how easy it is to send a command to the InFocus projector
CODE
SerialPort sp5000 = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
// Open the sp5000 for communications
sp5000.Open();
sp5000.Write(ControlCodes.InfocusSP5000.RS232.OverscanOff);
sp5000.Close();
// Open the sp5000 for communications
sp5000.Open();
sp5000.Write(ControlCodes.InfocusSP5000.RS232.OverscanOff);
sp5000.Close();
Part of the solution I have right now has some sample code for the firecracker based on .NET 1.1, I am going to use the enums and such from it but I will probably just use the SerialPort class from .NET 2.0 as I have done with the SP5000.
Doing this project makes me want all my devices to have RS232 control.
Other thoughts:
The web app runs off my main media server / router computer on Windows Server 2003. I have a HTPC running XP pro and I want to be able to send it generic commands for power dvd like play pause etc. I am trying to figure out exactly how to do this. One thought I had is a windows service or web service on the XP machine to receive the commands and invoke/marshall them on the xp client machine. The other thought is some sort of hardware / software solution like make some custom serial to ps2 cable and send commands directly to the ps2 port. I don't know if option 2 is possible or pratical but I am thinking that option 1 is better. The problem with option one is I don't know how to marshal a generic command like 'Play' from .net. I found an article on code project about controlling specific apps like windows media player but I want it to be a generic command almost as if a keyboard button had been pressed on the client machine. Any ideas?
