How to connect whit Webservice in InterfaceKit from SBC2?

Supporting Java SE version 7 and up
pauloww
Phidgetly
Posts: 20
Joined: Tue Mar 01, 2011 12:29 pm
Location: BR
Contact:

How to connect whit Webservice in InterfaceKit from SBC2?

Postby pauloww » Wed May 18, 2011 7:18 pm

Hello,


My question is how to connect and control the InterfaceKit SBC2 via Webservice from Java.

Example: To connect and control the InterfaceKit 0/0/4 connected directly to my computer, I use the following code:

Code: Select all

...
   try{
            ik = new InterfaceKitPhidget();
            ik.open(sn);
            ik.waitForAttachment();
            ik.setOutputState(0, true);
            ik.close();
        }
        catch(PhidgetException pe){
            System.err.println(pe);
        }
...


How would it be to connect the IK SBC2 of 8/8/8?
I tried to start:

Code: Select all

...
            dic = new Dictionary();
            dic.open("192.168.2.100", 5001, "");
...



But I do not know how to command...

Thanks!

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: How to connect whit Webservice in InterfaceKit from SBC2

Postby erik » Thu May 19, 2011 8:52 am

Take a look at the overloaded methods for open(). The code will not be very different from the code for the 0/0/4 to be able to open the 8/8/8 on the SBC2.

Code: Select all

...
   try{
            ik = new InterfaceKitPhidget();
            ik.open(sn, "192.168.2.100", 5001);
            ik.waitForAttachment();
            ik.setOutputState(0, true);
            ik.close();
        }
        catch(PhidgetException pe){
            System.err.println(pe);
        }
...


This will open the InterfaceKit with the specified serial number at the specified IP address for the SBC2. You can also use the open method that uses the ServerID as an input parameter if the IP address of the SBC2 is going to change.

pauloww
Phidgetly
Posts: 20
Joined: Tue Mar 01, 2011 12:29 pm
Location: BR
Contact:

Re: How to connect whit Webservice in InterfaceKit from SBC2

Postby pauloww » Thu May 19, 2011 11:18 am

Thanks Erik!

Another question,
How I do operate independently relays Dual Relay Board (3051) linked to IK 8/8/8 (SBC2)?

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: How to connect whit Webservice in InterfaceKit from SBC2

Postby erik » Thu May 19, 2011 1:35 pm

Plug in the sensor cable from the 3051 to the SBC2.
Attach the control terminals to the Digital Output on the SBC2. Depending on which Digital Output it is connected to,

Code: Select all

ik.setOutputState(0, true); //relay connected to digital output 0 will be enabled
ik.setOutputState(1, true);//relay connected to digital output 1 will be enabled


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest