Contribution: IR iTach full JS

240 views
Skip to first unread message

Guillaume Vigneron

unread,
Dec 25, 2013, 8:22:28 AM12/25/13
to comman...@googlegroups.com
Hi all,
I just finished writing a module and would like to share it with you. Comments and recommendations are more than welcome!

The purpose of this GUI is to send commands and macro to an iTach (Global Cache). It's entirely done in javascript, which allows the following process:
-the command is sent to the iTach
-iTach reply if error or OK
-if any error the command is sent again
-if OK then the next command of the macro -if any- is sent.

Macros here are not CF macros but simply a list of command within the javascript call. The number of IR commands you want to include in your macro is unlimited.
Compare to a regular CF macro, this module:
1. allows you sending the macro without setting any delay between two commands
2. makes sure every command is properly sent and accepted by the iTach

-------------------------------------
-------------------------------------

To send an IR command, the javascript call looks like:
send("device_name","command_name");
or for a list of commands (macro):
send("device_name1","command_name1","device_name2","command_name2","device_name3","command_name3");

Hope you'll like it :)

Merry christmas,
Guillaume

IR_iTach.gui.zip

Barry Gordon

unread,
Dec 25, 2013, 9:15:14 AM12/25/13
to comman...@googlegroups.com
Where is the JavaScript code?  All I see is the GUI in the zip archive. 

As a suggestion make the argument to the send function an array of objects where each object has 2 properties, "deviceName" and "commandName"



Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<IR_iTach.gui.zip>

Guillaume Vigneron

unread,
Dec 26, 2013, 1:48:10 PM12/26/13
to comman...@googlegroups.com
Hi Barry,
Strange, I'll upload the JS when I'll be back home... Regarding your suggestion, I think that's what I did :)


Envoyé de mon iPhone
You received this message because you are subscribed to a topic in the Google Groups "CommandFusion Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commandfusion/9jowmWL9nPY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commandfusio...@googlegroups.com.

Barry Gordon

unread,
Dec 26, 2013, 1:56:54 PM12/26/13
to comman...@googlegroups.com

I'll know better when I see the code ;-). 

Guillaume Vigneron

unread,
Dec 26, 2013, 4:03:33 PM12/26/13
to comman...@googlegroups.com
Hehe :)

Here is the JS alone. As you know already, I am a pure beginner with javascript, so I'll appreciate if you see any point that could/should be written better.

Thanks
main.js

Guillaume Vigneron

unread,
Dec 26, 2013, 4:43:34 PM12/26/13
to comman...@googlegroups.com
FYI, I plan to add the possibility of entering manual delays for macros (like we can do via GuiDesigner).

Barry Gordon

unread,
Dec 26, 2013, 4:55:53 PM12/26/13
to comman...@googlegroups.com
Manual delays should never be necessary. Intercom and timing, delays, should be set by altering the final off time of the last IR burst. The iTach should not respond with the completion feedback until that time when the final off transmission time has completed

Sent from my iPad

On Dec 26, 2013, at 4:43 PM, Guillaume Vigneron <vef...@gmail.com> wrote:

FYI, I plan to add the possibility of entering manual delays for macros (like we can do via GuiDesigner).

--

Guillaume Vigneron

unread,
Dec 26, 2013, 4:59:38 PM12/26/13
to comman...@googlegroups.com
That's also what I thought Barry, but it can be useful with some devices. For example, with my TV (ordinary 55" Samsung), I use macros to select the channels (channel 52 is 5+2+ok), and if I don't set any delay between the commands, the iTach will go two fast for the TV to accept every digit.

Well..actually I pass these commands through TCP for this TV :) :)

Barry Gordon

unread,
Dec 26, 2013, 5:17:00 PM12/26/13
to comman...@googlegroups.com
I don't understand. Are you sending the commands to the Samsung via IR or TCP? 

If sending TCP based commands then there should not be any requirement for delays unless Samsung has screwed up their logic.  

With the iTach, increasing the last off time of an IR sequence should be the same as inserting a delay providing you are properly handling the feedback. The iTach should not send the feedback completion until the last off time has elapsed.

Sent from my iPad

On Dec 26, 2013, at 4:59 PM, Guillaume Vigneron <vef...@gmail.com> wrote:

That's also what I thought Barry, but it can be useful with some devices. For example, with my TV (ordinary 55" Samsung), I use macros to select the channels (channel 52 is 5+2+ok), and if I don't set any delay between the commands, the iTach will go two fast for the TV to accept every digit.

Well..actually I pass these commands through TCP for this TV :) :)

--

Guillaume Vigneron

unread,
Dec 26, 2013, 5:43:37 PM12/26/13
to comman...@googlegroups.com
For that TV, I don't use the iTach, but that was an example of a situation where delays can be useful, and yes I need delays with this TV. (obviously Samsung does not queue TCP commands...).

In case someone want to use that, attach is the script with possible delays. Sending an IR macro can be done as follow:
1. IR.send("device_name1","command_name1","device_name2","command_name2");
2. IR.send(1500,"device_name1","command_name1","device_name2","command_name2");   if a delay of 1.5sec is needed before first command
3. IR.send("device_name1","command_name1",1500,"device_name2","command_name2");   if a delay of 1.5sec is needed between two commands

Useful or useless...it's there. Hopefully the result is not too "heavy" to treat (it makes quite a lot of conditional in a single function).

main.js

Guillaume Vigneron

unread,
Dec 26, 2013, 5:50:35 PM12/26/13
to comman...@googlegroups.com
Barry, could you please explain me that particular point? (last off time) Where do you configure this in the IR command?
Thanks :)

PS: The way it's done in my script, the next command won't be sent as long as the feedback is not received and confirmed OK, so I should be able to use this "last off time".

Barry Gordon

unread,
Dec 26, 2013, 8:22:54 PM12/26/13
to comman...@googlegroups.com

If you look at a typical IR stream that is sent to the iTach, it consists of certain control fields then a bunch of timing values (pairs of numbers).  The pairs are commonly called burst pairs. The first of the pair is the time for the IR flasher to be on, and the second of the pair is the time for it to be off,  ergo the last number, the second of the last pair,  should be the last off time.  The iTach will be kept busy for this long after sending the last on time.  If for example the off time should be 600 microseconds, then anything larger than that will keep the iTach busy but actually doing nothing as the IR flasher is off during this time.

 

The time values are not in microseconds, but rather ticks of the IR clock IIRC, that is the period of the IR frequency.

 

Check the Global cache web site for their API document which describes all of this

 

From: comman...@googlegroups.com [mailto:comman...@googlegroups.com] On Behalf Of Guillaume Vigneron
Sent: Thursday, December 26, 2013 5:51 PM
To: comman...@googlegroups.com
Subject: Re: Contribution: IR iTach full JS

 

Barry, could you please explain me that particular point? (last off time) Where do you configure this in the IR command?

--

Guillaume Vigneron

unread,
Dec 27, 2013, 2:50:45 AM12/27/13
to comman...@googlegroups.com
OK, got it! It's really nice to get such detailed explanations, thanks Barry. I have the GC API documentation, I'll read it again.

So if I understand well, this off time is defined by the manufacturer of the equipment so we receive it when scanning the IR codes of a remote...but in certain cases we probably have to increase it if we want to make sure the device will treat every single commands that is sent in a macro. Cool... :)

Jarrod Bell

unread,
Dec 27, 2013, 5:16:10 AM12/27/13
to comman...@googlegroups.com
There are of course times when using the IR off timing method is not acceptable, so it makes sense to use delays between commands like normal macros.
For example - one IR output is stacked with 2 emitter heads directed at two different AV products. You might want to tell both units to power up and go to a specific input - but if you use the IR timing method, then it locks you from sending another IR command until the long off timing is complete.

Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


On 27/12/13 6:50 PM, Guillaume Vigneron wrote:
OK, got it! It's really nice to get such detailed explanations, thanks Barry. I have the GC API documentation, I'll read it again.

So if I understand well, this off time is defined by the manufacturer of the equipment so we receive it when scanning the IR codes of a remote...but in certain cases we probably have to increase it if we want to make sure the device will treat every single commands that is sent in a macro. Cool... :)

Barry Gordon

unread,
Dec 27, 2013, 6:18:15 AM12/27/13
to comman...@googlegroups.com
IMHO I agree that in the case you mention it might be more optimal to use a delay. However setting the IR timing correctly will result in an added delay in that specific case that is in the millisecond range. Hardly noticeable.  The assumption is that t he iTach does not return IR complete until the full final off time has run out and not when it starts or partially completes the off time transmission.

The more interesting case would be if there were multiple iTachs being used in the scenario you describe and you wanted to overlap their operation. Can you even run to TCP control stacks at the same time for transmission?

Guillaumer, on remotecentral.com there is a paper on IR for the Pronto PRO that I wrote many years ago. It should be on my web site but the link is broken.  I will fix that today. You might want to read it.  It describes IR format, Pronto HEX, in great detail and IR in general as a protocol.




Sent from my iPad

On Dec 27, 2013, at 5:16 AM, Jarrod Bell <jar...@commandfusion.com> wrote:

There are of course times when using the IR off timing method is not acceptable, so it makes sense to use delays between commands like normal macros.
For example - one IR output is stacked with 2 emitter heads directed at two different AV products. You might want to tell both units to power up and go to a specific input - but if you use the IR timing method, then it locks you from sending another IR command until the long off timing is complete.

Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


On 27/12/13 6:50 PM, Guillaumer Vigneron wrote:

Jarrod Bell

unread,
Dec 27, 2013, 6:23:49 AM12/27/13
to comman...@googlegroups.com
To be honest, I think that's just over-complicating things. A simple delay between command sends is usually enough, and taking the extra step to wait for a successful transmission ACK reply (without messing with IR timing at the signal level) is all that's required.

If the timing is all handled in macro delays (rather than IR code timing) then it works across all use cases.


Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


Barry Gordon

unread,
Dec 27, 2013, 6:27:31 AM12/27/13
to comman...@googlegroups.com
Guillaumer, the IR docs are on my web site. Look for the link named "Global Cache IR Explorer" and download the useful IR docs.

Sent from my iPad

Barry Gordon

unread,
Dec 27, 2013, 6:31:19 AM12/27/13
to comman...@googlegroups.com
On this one we will just have to disagree. I have used both methods successfully. I believe the use of the "correct" timing is the simpler case as it is just setting a different value as opposed to adding a process step. 

Sent from my iPad

Jarrod Bell

unread,
Dec 27, 2013, 6:40:51 AM12/27/13
to comman...@googlegroups.com
All I am saying is the IR code timing does not work for all use cases, such as the case I suggested earlier. Blocking transmission of further IR codes, simply to delay the next signal, gets in the way of macros controlling multiple devices.
For simple things like channel changing with multiple digit IR codes, adjusting the actual IR signal timing makes more sense, but for traditional macros involving multiple devices it does not make sense at all.

So I would rather one method to handle both scenarios than extra code to handle them separately (and combining the methods...it gets even messier!)

One thing I'm not sure on - does the iTach unit allow sending different commands out of multiple IR ports simultaneously? Or do you have to wait for each IR code to complete before being able to send a command to another port?
If it forces a wait, then that's another reason to avoid IR timing delays.


Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


Guillaume Vigneron

unread,
Dec 27, 2013, 7:13:57 AM12/27/13
to comman...@googlegroups.com, jar...@commandfusion.com
A lot of information in here, nice, and thanks for the documentation Barry, I'll look at it. :)

Jarrod, as I can observe, and especially if you want to use the feedback, the iTach just send the commands one by one through the different ports.

The last version of the JS I uploaded include manual delays in between commands, It's fairly easy to modify by those who would like to apply this delay on the command itself...and everybody is happy then :) (I guess people who would think about this process would not even need my script!)


Les Bridges

unread,
Dec 29, 2013, 5:29:30 AM12/29/13
to comman...@googlegroups.com
Guillaume, thank you for your Script.

Im extremely new to Java Script and hoping you could tell me where i would place the IR call send("device_name","command_name");. Is it in on the button itself if so how does it know which iTach to use. If its under system manager do you create another Command with the script attached. Do you have to call the script name anywhere? As is say i'm extremely new to this. I do have all my Global Cache Commands ready.

2. Could I use the Join 501 as a flashing icon for communications?

Guillaume Vigneron

unread,
Dec 29, 2013, 5:53:03 AM12/29/13
to comman...@googlegroups.com

Hi "Les Bridges",
did you download the GUI example on the first post of this thread? (IR_iTach.gui.zip) That should help you understanding how it works. As you can see on this example, when using Javascript you must define the JS file => in GUIdesigner, right click on your project => Script manager... => Add script

Yes, the function send("device_name","command_name"); must be written directly on the button in the field "Javascript". If needed, you could as well create a command in the system manager that would fire this javascript function. In this case, just create a system like on the screen shot attached and create your commands in it.

This script does not search for iTach(s) present on your network, it assume you have only one, this one exist in the system manager and is called "iTach" in you GUI (even without any command in it, just the feedback command). I could prepare a script defining 2 or 3 iTach devices but I can't really test it as I have only one iTach at home...
Screen Shot 2013-12-29 at 11.47.44.png

Guillaume Vigneron

unread,
Dec 29, 2013, 6:06:50 AM12/29/13
to comman...@googlegroups.com
Attached is a new script that "should" work with three different iTach devices ( i can't test it). Please try it with my example GUI, just create two new iTach devices called "iTach2" and "iTach3", remember to create the feedback command like as it is done with the first iTach device (the feedback command names must be "iTach_Feedback2" and "iTach_Feedback3"). Of course, you have to enter the IP addresses of your iTachs for the three devices.

When populating the list of IR commands in the script, you can decide if your device (TV, amplifier...or whatsoever) is controlled by "iTach", "iTach2" or "iTach3" and on which IR port.

Please let me know if this works.

main.js

Guillaume Vigneron

unread,
Dec 29, 2013, 6:17:41 AM12/29/13
to comman...@googlegroups.com
I've just uploaded the GUI with three itach configured. To test it, just change the IP adresses of the three iTach in the system manager in GUIDesigner. Then edit the script (main.JS) and insert you IR commands instead of mine, with the devices name you want to use (TV, amplifier...etc), the command name you want to use (HDMI_input1, Power_ON...), and the correct configuration for each device to control:
GCDEVICE: "iTach" (or iTach2 or iTach3)
Port:"1" (or 2 or 3)

Finally setup your commands in the buttons already presents on the portrait page of this GUI.
iPhone IR - iTach feedback.rar

Les Bridges

unread,
Dec 30, 2013, 4:41:32 AM12/30/13
to comman...@googlegroups.com
Thank you so much for your help, I am looking at this now and it seems great,

I will give you more feed back once I have tested more,

Some more quick questions 

1. Do I use the 501 link in the iTach feed back in the example you kindly supplied?
2. When I try and open the main.js in the script manager i always get the error "CF" is undefined, do I have to install a module to windows or something? I obviously can open and edit externally to the program but I would have thought I could do both.
3. Can i produce a green beacon when all the iTachs are connected an orange one if one or more are not connected an red if none are connected, is this again done from port 501?

I really do appreciate this advice.

Guillaume Vigneron

unread,
Dec 30, 2013, 5:04:44 AM12/30/13
to comman...@googlegroups.com
Please see my answers below:

1. Do I use the 501 link in the iTach feed back in the example you kindly supplied?
=> The digital join 501 will just turn red as long as the feedback reply an error

2. When I try and open the main.js in the script manager i always get the error "CF" is undefined, do I have to install a module to windows or something? I obviously can open and edit externally to the program but I would have thought I could do both.
=> I never edit my script from GuiDesigner. I just open them with my text editor ("Sublime Text" on mac, but you may find better tools).

3. Can i produce a green beacon when all the iTachs are connected an orange one if one or more are not connected and red if none are connected, is this again done from port 501?
=>You need to create a new javascript function for that. Something simple would be 3 different beacons (green, orange and red) with a different digital join attached to each. If they all answer to ping => green is ON, if they all fail to ping => red is ON, else=> orange is ON.

Guillaume Vigneron

unread,
Dec 30, 2013, 7:33:14 AM12/30/13
to comman...@googlegroups.com
Just made some changes in my script and GUI for you, you'll find this attached to this message.

Edit the script with your own setup:
-IR commands (like before)
-iTach devices configuration (just below the IR commands)

It should be fairly easy, everything is explained in the script.


The result will be:
-one status led (Green/Red) for each of the three iTach devices
-a global-status led (green/orange/red) as explained in previous post.

Please test and let me know.
Guillaume
iPhone IR - iTach feedback.rar

Les Bridges

unread,
Dec 31, 2013, 7:30:24 AM12/31/13
to comman...@googlegroups.com
Thanks again Guillaume

If I wanted to say use a join from Room selection that links to say a Power Button, would I use this same script to achieve this?

So say 

join 1001 Lounge Room Uses LoungeSamsungTV Power Command, LoungeBose Power Command
join 1002 Master Bedroom Uses MasterBed SamsungTV Power Command, Lounge Power Command
join 1003 Swimming Pool Uses SwimmingPool Sony TV Power Command
join 1004 Guest Bedroom Uses GuestBed LG TV Power Command

My only thought is some rooms use Bose Sound Systems so would the join call a macro of commands within the script.

Thank you in advance,

Guillaume Vigneron

unread,
Dec 31, 2013, 7:44:24 AM12/31/13
to comman...@googlegroups.com
I think you will have to put your hands in the dirt and start writing your own script. :) For "basic" things like we do here, it's actually not that hard.

In your case, I would probably script the following (linked to the room selection buttons):
-when select room X, join A=1, join B=0, join C=0
-when select room Y, join A=0, join B=1, join C=0
-when select room Z, join A=0, join B=0, join C=1

To turn on a TV, you would send something like IR.send("TV","Switch_ON");

Back in the javascript, within the IR.send function (you may want create a new function for that)=>
if join A=1 then TV="TV_LG"
if join B=1 then TV="TV_SONY"
if join C=1 then TV="TV_SAMSUNG"

To start with javascript, I would recommend you to write just the function(s) you need to test in an empty main.JS file and try every function one by one, sending the result to the log via CF.log("whatever_you_want_to_display").

Guillaume Vigneron

unread,
Dec 31, 2013, 7:47:58 AM12/31/13
to comman...@googlegroups.com
In my project, for most of the pages I open (room selection is a typical case), the button fires a javascript function like select_room("living_room");

From there, I can trigger exactly what I want to happen when I select a room: changing joins value, launching other functions, starting equipment...etc

Guillaume Vigneron

unread,
Dec 31, 2013, 7:57:01 AM12/31/13
to comman...@googlegroups.com
I am just thinking that, and it will answer your last question, you could create some sort of "master table". A function that would define the different variables (device name and command name) regarding the selected room.
If you keep the previous part with the digital joins to 1 or 0 regarding which room is selected, then this function would look like:
if join A=1 {
var TV="TV_SONY"
var AMPLI="BOSE_SYSTEM" }

if join B=1 {
var TV="TV_LG"
var AMPLI="BOSE_SYSTEM" }

if join C=1 {
var TV="TV_SAMSUNG"
var AMPLI="ONKYO" }

else {
serial join x="No room selected"} (serial join x could be a text displayed on your screen)

This function would be started just after the room selection.
Do you understand the process?

Les Bridges

unread,
Dec 31, 2013, 8:56:54 AM12/31/13
to comman...@googlegroups.com
I do see what you are saying, as you say I will need to get involved learning more which I am more than willing to do. I will learn the scripts and let you know how I go.

Thanks again and all the best for the New Year,,

Guillaume Vigneron

unread,
Dec 31, 2013, 3:01:53 PM12/31/13
to comman...@googlegroups.com
Great, I hope all of this will help you. ;)

Happy new year!
Reply all
Reply to author
Forward
0 new messages