PDA

View Full Version : IGOR-SFH56 plugin - COM port switching from within Girder



Lupus
September 7th, 2004, 02:31 PM
Hi there!

This is my first post in this forum, though I've had some experience with Girder, and I did read the FAQ and forum posts before asking this question :wink:


I'm using two IGOR - type IR receivers, both connected to COM ports (COM1 and 2). They work fine, I've managed to come up with quite a nice GML that does it's job well.

What I'm trying two achieve is to be able to switch between those two ports using Girder - I have the receivers set in two seperate rooms, and I'd like to use just my remote to change "zones" :)

I've come up with a part of the answer - a LUA script, using Girder-specific, Windows-registry manipulation functions :wink: - Reg[Get/Set]StringValue().
heres the code:


r,x = RegGetStringValue("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName");
if ( r == 0 ) then
if (x == "COM1") then
RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName","COM2");
else
RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName","COM1");
end
end



As you can see the thing is pretty simple (getting the revelation of using the registry wasn't :oops: :wink:)


What I have a problem with is:

how do I get the plugin (IgorPlug.dll) to be reloaded - or more exactly, to get it to re-read it's setting (something that is done when you press OK after doing SETTINGS on it)
(of course as a Girder action - or anything that can be done by Girder :) ).

I've tried capturing messages etc., but it proved fruitless.

Any help and/or advice is most welcome :D

(PS. I'm using Girder 3.2.9 with IgorPlug v1.11)

Promixis
September 7th, 2004, 02:40 PM
Maybe try the lua commands

Disableplugin (number)
Unloadplugin (number)
Loadplugin (number)
Enableplugin (number)

Lupus
September 7th, 2004, 03:39 PM
How do I use them exactly?

I mean - I've tried them (just raw, in a seperate script, like:


Unloadplugin(207);


but I get:


error: attempt to call global `Unloadplugin' (a nil value)
stack traceback:
1: main of string "?" at line 1


Should I include some modules or sth, and how?

(if this works, I'm gonna be a happy man :) )

Promixis
September 7th, 2004, 04:14 PM
Oppps....


You need

UnloadPlugin (207)


ie capitalize the P.

BTW, I think you might version 3.3.3 for this to work. Can't remember if these commands work in 3.2.9

Lupus
September 8th, 2004, 10:24 AM
:D
I had tried the UloadPlugin() - just forgot to mention.
But - the second advice was crucial. :)

Method of switching between COM ports in Igor SFH-56 plugin through Girder (Lua script)



local IgorDevNum = 207 -- IgorPlug.dll device number

-- check the current port setting
r,x = RegGetStringValue("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName");

if ( r == 0 ) then -- if reading is successful

if (x == "COM1") then -- is COM1 the current port?
-- is COM1 - change to COM2
RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName","COM2");

else -- is COM2 - change to COM1
RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Girder3\\HardPlugins\\Igor SFH-56 device","ComName","COM1");
end

end

-- reload Igor plugin - re-read the setting ("apply")
UnloadPlugin(IgorDevNum)
LoadPlugin(IgorDevNum)



Code works with Girder 3.3.1+ - I haven't check the 3.3.0 ver.

Unfortunately, it doesn't work with 3.2.9 :(

If anyone knows how to implement the Un/LoadPlugin() functions in pre 3.3 ver, that'd be nice to know :)


Hope it's gonna be useful to somebdy:)

vynce
September 8th, 2004, 05:37 PM
There are "Enable Device" and "Disable Device" commands on the Girder Tab. Put the device number in the large box. They should work the same way as the Lua functions - just stick them in a multigroup after your Lua script.

Lupus
September 8th, 2004, 06:56 PM
I'm afraid that no, they don't :(

Using them was the first thing I've tried :D


The difference is that Enable/Disable Device does just that (turns event generating on and off)- and we need to RELOAD the device driver (that is, re-read the settings from the registry).

But thanks for the response :)

vynce
September 8th, 2004, 07:49 PM
Doh :oops:

I used those commands for reinitializing my UIRT when it stopped responding. I guess it works differently from Igor's plugin.