这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bundles/binding/org.openhab.binding.upb/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java/"/>
<classpathentry kind="src" path="src/main/resources/"/>
<classpathentry exported="true" kind="lib" path="lib/nrjavaserial-3.11.0.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
39 changes: 39 additions & 0 deletions bundles/binding/org.openhab.binding.upb/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.upb</name>
<comment>This is the UPB binding of the open Home Automation Bus (openHAB)</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
31 changes: 31 additions & 0 deletions bundles/binding/org.openhab.binding.upb/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Manifest-Version: 1.0
Private-Package: org.openhab.binding.upb.internal
Ignore-Package: org.openhab.binding.upb.internal
Bundle-License: http://www.eclipse.org/legal/epl-v10.html
Bundle-Name: openHAB UPB Binding
Bundle-SymbolicName: org.openhab.binding.upb
Bundle-Vendor: openHAB.org
Bundle-Version: 1.9.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Description: This is the UPB binding of the open Home Aut
omation Bus (openHAB)
Import-Package:
org.apache.commons.lang,
org.openhab.core.binding,
org.openhab.core.events,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.types,
org.openhab.model.item.binding,
org.osgi.framework,
org.osgi.service.cm,
org.osgi.service.component,
org.osgi.service.event,
org.slf4j
Export-Package: org.openhab.binding.upb
Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: ., lib/nrjavaserial-3.11.0.jar
Bundle-ActivationPolicy: lazy
31 changes: 31 additions & 0 deletions bundles/binding/org.openhab.binding.upb/OSGI-INF/binding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2010-2016, openHAB.org and others.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0"
activate="activate" modified="modified" deactivate="deactivate"
name="org.openhab.binding.upb.binding" immediate="true"
configuration-pid="org.openhab.upb" configuration-policy="optional">
<implementation class="org.openhab.binding.upb.internal.UPBBinding" />

<service>
<provide interface="org.osgi.service.event.EventHandler" />
</service>

<property name="event.topics" type="String" value="openhab/command/*" />

<reference bind="setEventPublisher" cardinality="1..1"
interface="org.openhab.core.events.EventPublisher" name="EventPublisher"
policy="dynamic" unbind="unsetEventPublisher" />
<reference bind="addBindingProvider" cardinality="1..n"
interface="org.openhab.binding.upb.UPBBindingProvider" name="upbBindingProvider"
policy="dynamic" unbind="removeBindingProvider" />

</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2010-2016, openHAB.org and others.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.openhab.binding.upb.genericbindingprovider">
<implementation class="org.openhab.binding.upb.internal.UPBGenericBindingProvider"/>

<service>
<provide interface="org.openhab.model.item.binding.BindingConfigReader"/>
<provide interface="org.openhab.binding.upb.UPBBindingProvider"/>
</service>

</scr:component>
7 changes: 7 additions & 0 deletions bundles/binding/org.openhab.binding.upb/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/main/java/,\
src/main/resources/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
lib/nrjavaserial-3.11.0.jar
output.. = target/classes/
Binary file not shown.
35 changes: 35 additions & 0 deletions bundles/binding/org.openhab.binding.upb/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">

<parent>
<groupId>org.openhab.bundles</groupId>
<artifactId>binding</artifactId>
<version>1.9.0-SNAPSHOT</version>
</parent>

<properties>
<bundle.symbolicName>org.openhab.binding.upb</bundle.symbolicName>
<bundle.namespace>org.openhab.binding.upb</bundle.namespace>
<deb.name>openhab-addon-binding-upb</deb.name>
<deb.description>${project.name}</deb.description>
</properties>

<modelVersion>4.0.0</modelVersion>
<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.upb</artifactId>

<name>openHAB UPB Binding</name>

<packaging>eclipse-plugin</packaging>

<build>
<plugins>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2016, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.binding.upb;

import org.openhab.binding.upb.internal.UPBBindingConfig;
import org.openhab.core.binding.BindingProvider;

/**
* Interface for the {@link BindingProvider} for the UPB binding.
*
* @author cvanorman
* @since 1.9.0
*/
public interface UPBBindingProvider extends BindingProvider {

/**
* Gets the configuration of an item.
*
* @param itemName
* the name of the item.
* @return the {@link UPBBindingConfig} for the given item or null if one
* does not exist.
*/
UPBBindingConfig getConfig(String itemName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/**
* Copyright (c) 2010-2016, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.binding.upb.internal;

/**
* Model for the first two bytes of UPB messages.
*
* @author cvanorman
* @since 1.9.0
*/
public class ControlWord {

private static final int TRANSMIT_COUNT_SHIFT = 2;
private static final int TRANSMIT_COUNT_MASK = 0b00001100;
private static final int TRANSMIT_SEQUENCE_MASK = 0b00000011;
private static final int ACK_PULSE_MASK = 0b00010000;
private static final int ID_PULSE_MASK = 0b00100000;
private static final int ACK_MESSAGE_MASK = 0b01000000;
private static final int REPEATER_COUNT_SHIFT = 5;
private static final int REPEATER_COUNT_MASK = 0b01100000;
private static final int PACKET_LENGTH_MASK = 0b00011111;
private static final int LINK_MASK = 0b10000000;

private byte one = 0;
private byte two = 0;

/**
* Sets the two bytes of the control word.
*
* @param one
* the first byte.
* @param two
* the second byte.
*/
public void setBytes(byte one, byte two) {
this.one = one;
this.two = two;
}

/**
* @return the two bytes of the control word.
*/
public byte[] getBytes() {
return new byte[] { two, one };
}

/**
* @return the link
*/
public boolean isLink() {
return (two & LINK_MASK) > 0;
}

/**
* @param link
* the link to set
*/
public void setLink(boolean link) {
two = (byte) (link ? two | LINK_MASK : two & ~LINK_MASK);
}

/**
* @return the repeaterCount
*/
public int getRepeaterCount() {
return (two & REPEATER_COUNT_MASK) >> REPEATER_COUNT_SHIFT;
}

/**
* @param repeaterCount
* the repeaterCount to set
*/
public void setRepeaterCount(int repeaterCount) {
two = (byte) (two | (repeaterCount << REPEATER_COUNT_SHIFT));
}

/**
* @return the packetLength
*/
public int getPacketLength() {
return two & PACKET_LENGTH_MASK;
}

/**
* @param packetLength
* the packetLength to set
*/
public void setPacketLength(int packetLength) {
two = (byte) (two | packetLength);
}

/**
* @return the transmitCount
*/
public int getTransmitCount() {
return (one & TRANSMIT_COUNT_MASK) >> TRANSMIT_COUNT_SHIFT;
}

/**
* @param transmitCount
* the transmitCount to set
*/
public void setTransmitCount(int transmitCount) {
one = (byte) (one | (transmitCount << TRANSMIT_COUNT_SHIFT));
}

/**
* @return the transmitSequence
*/
public int getTransmitSequence() {
return one & TRANSMIT_SEQUENCE_MASK;
}

/**
* @param transmitSequence
* the transmitSequence to set
*/
public void setTransmitSequence(int transmitSequence) {
one = (byte) (one | transmitSequence);
}

/**
* @return the ackPulse
*/
public boolean isAckPulse() {
return (one & ACK_PULSE_MASK) > 0;
}

/**
* @param ackPulse
* the ackPulse to set
*/
public void setAckPulse(boolean ackPulse) {
one = (byte) (ackPulse ? one | ACK_PULSE_MASK : one & ~ACK_PULSE_MASK);
}

/**
* @return the idPulse
*/
public boolean isIdPulse() {
return (one & ID_PULSE_MASK) > 0;
}

/**
* @param idPulse
* the idPulse to set
*/
public void setIdPulse(boolean idPulse) {
one = (byte) (idPulse ? one | ID_PULSE_MASK : one & ~ID_PULSE_MASK);
}

/**
* @return the ackMessage
*/
public boolean isAckMessage() {
return (one & ACK_MESSAGE_MASK) > 0;
}

/**
* @param ackMessage
* the ackMessage to set
*/
public void setAckMessage(boolean ackMessage) {
one = (byte) (ackMessage ? one | ACK_MESSAGE_MASK : one & ~ACK_MESSAGE_MASK);
}
}
Loading