Please login or register.

Login with username, password and session length

Author Topic: Any java sample codes for CM15A interface?  (Read 17393 times)

kan chu

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
Any java sample codes for CM15A interface?
« on: June 11, 2005, 08:46:01 AM »

I looked into ActiveHome SDK and only found
Javascript sample codes. How do I program
CM15A interface directly from standalone
Java application? Any Java sample codes?
Logged

jeremy

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Re: Any java sample codes for CM15A interface?
« Reply #1 on: June 22, 2005, 10:41:26 PM »

I am looking for the same thing as I'd like
to write a number of pieces of functionality
as a package so that I can use a number of
administrative tools that I've built in Java
to run the various hardware.  I have taken VB
or C++ code in the past and built them as COM
objects that are then called from within a
Java class, but that requires you to use the
MS JVM (BAD IDEA).  Where there's a will ...
there's a way.
Logged

alex

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 16
Re: Any java sample codes for CM15A interface?
« Reply #2 on: October 28, 2005, 03:11:14 PM »

threr is a way to control ActiveHome Pro
from a Java program using the SDK. this is
what i use right now. it has it's drawbacks,
though. the main one is it will only work on
Windows unless you can create a version of
the ahcmd sample program that will work with
another operating system. theo ther drawback
is that with this way you can only CONTROL
modules, you can't detect when any commands
are sent from other controllers or remotes.

the way i use to control ActiveHome Pro from
my Java programs is fairly simple once i
figured it out.

first, make sure that ahcmd.exe is on your
path.

then use this class to control the modules.
i'm going to send it in another message.

let me find the java file...
Logged

alex

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 16
Re: Any java sample codes for CM15A interface?
« Reply #3 on: October 28, 2005, 03:14:36 PM »

public class X10Controller
{
public void on(char houseCode, int
unitCode)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " on");
}

public void off(char houseCode, int
unitCode)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " off");
}

public void dim(char houseCode, int
unitCode, int percent)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " dim " + percent);
}

public void bright(char houseCode, int
unitCode, int percent)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " bright " + percent);
}

private void runCommand(String command)
throws RuntimeException
{
try
{
Runtime.getRuntime().exec
(command).waitFor();
}
catch (Exception e)
{
throw new RuntimeException
("problems occured while controlling the X10
module.", e);
}
}
}
Logged

alex

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 16
Re: Any java sample codes for CM15A interface?
« Reply #4 on: October 28, 2005, 03:20:22 PM »

Jeremy:

i figured out another way that you can also
watch for remote control presses and
releases via Java but i don't know enough
about C++ to do it. what you do is change
the ahcview example that comes with the
ActiveHome Pro SDK so that it prints it's
info to standard out and then you can call
it via Runtime.getRuntime().exec() and then
get the InputStream from the process and
read lines from it using a
java.io.BufferedReader. then just parse each
line using a java.util.StringTokenizer and
you can figure out what command was sent. if
you do change ahcview, could you post the
new .cpp and .h files here? if you do,
thanks so much. i posted something about
that on the regular X10 forums under
Automation and haven't got any replies but
Halloween is coming up and i need this
before then.
Logged

biojae

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 2
Re: Any java sample codes for CM15A interface?
« Reply #5 on: July 03, 2008, 08:57:53 PM »

I looked into ActiveHome SDK and only found
Javascript sample codes. How do I program
CM15A interface directly from standalone
Java application? Any Java sample codes?

i have been working on one, over on the SUN java forums, but I havent been able to get the Libusb part working, yet ???, heres a link to the forum topic
http://forum.java.sun.com/thread.jspa?threadID=5256058

EDIT:: Note that this does NOT use the sdk
Logged
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.