Skip to content

Commit

Permalink
Rework project structure in to common Maven structure. Combine Java e…
Browse files Browse the repository at this point in the history
…xamples in to project.
  • Loading branch information
StanAccy committed Jan 16, 2014
1 parent f25c69e commit 9da574a
Show file tree
Hide file tree
Showing 198 changed files with 3,015 additions and 719 deletions.
6 changes: 0 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties

This file was deleted.

File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions jformica-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.cowboycoders</groupId>
<artifactId>jformica-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>jformica-core</artifactId>
<packaging>jar</packaging>
<name>jformica-core</name>

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>

<dependency>
<groupId>net.vidageek</groupId>
<artifactId>mirror</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>

</project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions jformica-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.cowboycoders</groupId>
<artifactId>jformica-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>jformica-java</artifactId>
<packaging>jar</packaging>
<name>jformica-java</name>

<dependencies>
<dependency>
<groupId>org.cowboycoders</groupId>
<artifactId>jformica-usb</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.cowboycoders.ant.examples;

import org.cowboycoders.ant.NetworkKey;

public class NetworkKeys {

public static final NetworkKey ANT_SPORT = new NetworkKey (0xB9,0xA5,0x21,0xFB,0xBD,0x72,0xC3,0x45);
public static final NetworkKey ANT_PUBLIC = new NetworkKey (0,0,0,0,0,0,0,0);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.cowboycoders.ant.examples;

import java.util.concurrent.TimeUnit;

import org.cowboycoders.ant.Channel;
import org.cowboycoders.ant.ChannelId;
import org.cowboycoders.ant.events.MessageCondition;
import org.cowboycoders.ant.events.MessageConditionFactory;
import org.cowboycoders.ant.messages.commands.ChannelRequestMessage;
import org.cowboycoders.ant.messages.commands.ChannelRequestMessage.Request;
import org.cowboycoders.ant.messages.responses.ChannelIdResponse;

/**
* Contains some example utility functions
* @author will
*
*/
public class Utils {

public static void printChannelConfig(Channel channel) {

// build request
ChannelRequestMessage msg = new ChannelRequestMessage(channel.getNumber(),Request.CHANNEL_ID);

// response should be an instance of ChannelIdResponse
MessageCondition condition = MessageConditionFactory.newInstanceOfCondition(ChannelIdResponse.class);

try {

// send request (blocks until reply received or timeout expired)
ChannelIdResponse response = (ChannelIdResponse) channel.sendAndWaitForMessage(
msg, condition, 5L, TimeUnit.SECONDS, null);

System.out.println();
System.out.println("Device configuration: ");
System.out.println("deviceID: " + response.getDeviceNumber());
System.out.println("deviceType: " + response.getDeviceType());
System.out.println("transmissionType: " + response.getTransmissionType());
System.out.println("pairing flag set: " + response.isPairingFlagSet());
System.out.println();

} catch (Exception e) {
// not critical, so just print error
e.printStackTrace();
}
}

/**
* Requests a channels current channelId
* @param channel
* @return
*/
public static ChannelId requestChannelId(Channel channel) {
// build request
ChannelRequestMessage msg = new ChannelRequestMessage(channel.getNumber(),Request.CHANNEL_ID);

// response should be an instance of ChannelIdResponse
MessageCondition condition = MessageConditionFactory.newInstanceOfCondition(ChannelIdResponse.class);

try {

// send request (blocks until reply received or timeout expired)
ChannelIdResponse response = (ChannelIdResponse) channel.sendAndWaitForMessage(
msg, condition, 5L, TimeUnit.SECONDS, null);

return response.getChannelId();

} catch (Exception e) {
// not critical, so just print error
e.printStackTrace();
}

return null;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.cowboycoders.ant.examples.api;

import org.cowboycoders.ant.Node;
import org.cowboycoders.ant.interfaces.AntTransceiver;
import org.cowboycoders.ant.messages.responses.Capability;

public class Capabilities {

public static void main(String[] args) {
AntTransceiver antchip = new AntTransceiver(0);
Node node = new Node(antchip);

node.start();

for (Capability c : node.getCapabiltites()) {
System.out.println(c);
}

node.stop();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.cowboycoders.ant.examples.api;

import org.cowboycoders.ant.Node;
import org.cowboycoders.ant.interfaces.AntDeviceId;
import org.cowboycoders.ant.interfaces.AntTransceiver;
import org.cowboycoders.ant.messages.responses.Capability;

public class ChooseUsbDevice {

public static void main(String [] args) {

// Uncomment one of the following:

// choose first ANTUSB_2 device
AntTransceiver antchip = new AntTransceiver(AntDeviceId.ANTUSB_2,0);

// choose first ANTUSB_M device
//AntTransceiver antchip = new AntTransceiver(AntDeviceId.ANTUSB_M,0);

// search for all known devices and select first device found
//AntTransceiver antchip = new AntTransceiver(0);

Node node = new Node(antchip);

node.start();

for (Capability c : node.getCapabiltites()) {
System.out.println(c);
}

node.stop();
}



}
Loading

0 comments on commit 9da574a

Please sign in to comment.