public class SoundSystem
extends java.lang.Object
import static com.github.niqdev.openwebnet.OpenWebNet.defaultGateway;
OpenWebNet client = OpenWebNet.newClient(defaultGateway("IP_ADDRESS"));
// requests status amplifier 51
client
.send(SoundSystem.requestStatus("51", SoundSystem.Type.AMPLIFIER_P2P))
.map(SoundSystem.handleStatus(() -> System.out.println("ON"), () -> System.out.println("OFF")))
.subscribe(System.out::println);
// turns group 5 on
client
.send(SoundSystem.requestTurnOn("5", SoundSystem.Type.AMPLIFIER_GROUP, SoundSystem.Source.STEREO_CHANNEL))
.map(SoundSystem.handleResponse(() -> System.out.println("success"), () -> System.out.println("fail")))
.subscribe(System.out::println);
// turn volume up of amplifier 51
client
.send(SoundSystem.requestVolumeUp("51", SoundSystem.Type.AMPLIFIER_P2P))
.map(SoundSystem.handleResponse(() -> System.out.println("success"), () -> System.out.println("fail")))
.subscribe(System.out::println);
// change station of source 103
client
.send(SoundSystem.requestStationUp("103", SoundSystem.Type.SOURCE_P2P))
.map(SoundSystem.handleResponse(() -> System.out.println("success"), () -> System.out.println("fail")))
.subscribe(System.out::println);
Modifier and Type | Class and Description |
---|---|
static class |
SoundSystem.Source
Sound System source.
|
static class |
SoundSystem.Type
Sound System type: amplifier or source.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
FORMAT_BUS |
protected static java.lang.String |
FORMAT_DIMENSION |
protected static java.lang.String |
FORMAT_PREFIX_DIMENSION |
protected static java.lang.String |
FORMAT_PREFIX_DIMENSION_WHO |
protected static java.lang.String |
FORMAT_PREFIX_REQUEST_WHO |
protected static java.lang.String |
FORMAT_PREFIX_RESPONSE |
protected static java.lang.String |
FORMAT_PREFIX_STATUS_WHO |
protected static java.lang.String |
FORMAT_REQUEST |
protected static java.lang.String |
FORMAT_STATUS |
static java.lang.String |
NO_BUS |
static java.lang.String |
WHERE_GENERAL_VALUE |
protected static int |
WHERE_MAX_VALUE |
protected static int |
WHERE_MIN_VALUE |
ACK, FRAME_END, FRAME_START, NACK
Modifier | Constructor and Description |
---|---|
protected |
SoundSystem(java.lang.String value) |
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
buildWhereValue(java.lang.String where,
SoundSystem.Type type) |
protected static java.lang.String |
checkBus(java.lang.String bus) |
protected static int |
checkIsInteger(java.lang.String value) |
protected static void |
checkRange(java.lang.Integer from,
java.lang.Integer to,
java.lang.Integer value) |
java.lang.String |
getValue()
Raw message value.
|
static rx.functions.Func1<OpenSession,OpenSession> |
handleResponse(rx.functions.Action0 onSuccess,
rx.functions.Action0 onFail)
|
protected static rx.functions.Func1<OpenSession,OpenSession> |
handleResponse(rx.functions.Action0 onSuccess,
rx.functions.Action0 onFail,
int who) |
static rx.functions.Func1<OpenSession,OpenSession> |
handleStatus(rx.functions.Action0 onStatus,
rx.functions.Action0 offStatus)
Handle response from
requestStatus(String, Type) . |
protected static boolean |
isInRange(java.lang.Integer from,
java.lang.Integer to,
java.lang.Integer value) |
protected static java.lang.Boolean |
isValidBus(java.lang.String bus) |
protected static void |
isValidPrefixType(OpenMessage request,
java.lang.String format,
int who) |
static SoundSystem |
requestStationDown(java.lang.String where,
SoundSystem.Type type)
OpenWebNet message request to change Source Station DOWN
with value *16*6101*WHERE##.
|
static SoundSystem |
requestStationUp(java.lang.String where,
SoundSystem.Type type)
OpenWebNet message request to change Source Station UP
with value *16*6001*WHERE##.
|
static SoundSystem |
requestStatus(java.lang.String where,
SoundSystem.Type type)
OpenWebNet message request Amplifier/Source status with value *#16*WHERE*5##.
|
static SoundSystem |
requestTurnOff(java.lang.String where,
SoundSystem.Type type,
SoundSystem.Source source)
OpenWebNet message request to turn Amplifier/Source OFF
with value *16*10*WHERE## or *16*13*WHERE##.
|
static SoundSystem |
requestTurnOn(java.lang.String where,
SoundSystem.Type type,
SoundSystem.Source source)
OpenWebNet message request to turn Amplifier/Source ON
with value *16*0*WHERE## or *16*3*WHERE##.
|
static SoundSystem |
requestVolumeDown(java.lang.String where,
SoundSystem.Type type)
OpenWebNet message request to turn Amplifier Volume DOWN
by step with value *16*1102*WHERE##.
|
static SoundSystem |
requestVolumeUp(java.lang.String where,
SoundSystem.Type type)
OpenWebNet message request to turn Amplifier Volume UP
by step with value *16*1002*WHERE##.
|
protected static final java.lang.String FORMAT_PREFIX_REQUEST_WHO
protected static final java.lang.String FORMAT_PREFIX_DIMENSION_WHO
protected static final java.lang.String FORMAT_PREFIX_STATUS_WHO
protected static final java.lang.String FORMAT_REQUEST
protected static final java.lang.String FORMAT_DIMENSION
protected static final java.lang.String FORMAT_STATUS
protected static final java.lang.String FORMAT_PREFIX_RESPONSE
protected static final java.lang.String FORMAT_PREFIX_DIMENSION
protected static final java.lang.String FORMAT_BUS
protected static final int WHERE_MIN_VALUE
protected static final int WHERE_MAX_VALUE
public static final java.lang.String WHERE_GENERAL_VALUE
public static final java.lang.String NO_BUS
public static SoundSystem requestTurnOn(java.lang.String where, SoundSystem.Type type, SoundSystem.Source source)
where
- Valuetype
- Type SoundSystem.Type
source
- Source SoundSystem.Source
public static SoundSystem requestTurnOff(java.lang.String where, SoundSystem.Type type, SoundSystem.Source source)
where
- Valuetype
- Type SoundSystem.Type
source
- Source SoundSystem.Source
public static rx.functions.Func1<OpenSession,OpenSession> handleResponse(rx.functions.Action0 onSuccess, rx.functions.Action0 onFail)
requestTurnOn(String, Type, Source)
- requestTurnOff(String, Type, Source)
- requestVolumeUp(String, Type)
- requestVolumeDown(String, Type)
- requestStationUp(String, Type)
- requestStationDown(String, Type)
onSuccess
- invoked if the request has been successfully receivedonFail
- invoked otherwiseObservable<OpenSession>
public static SoundSystem requestStatus(java.lang.String where, SoundSystem.Type type)
where
- Valuetype
- Type SoundSystem.Type
public static rx.functions.Func1<OpenSession,OpenSession> handleStatus(rx.functions.Action0 onStatus, rx.functions.Action0 offStatus)
requestStatus(String, Type)
.
NOTE: this is a best effort
onStatus
- invoked if Amplifier/Source is onoffStatus
- invoked if Amplifier/Source is offObservable<OpenSession>
protected static java.lang.String buildWhereValue(java.lang.String where, SoundSystem.Type type)
public static SoundSystem requestVolumeUp(java.lang.String where, SoundSystem.Type type)
where
- Valuetype
- Type SoundSystem.Type
public static SoundSystem requestVolumeDown(java.lang.String where, SoundSystem.Type type)
where
- Valuetype
- Type SoundSystem.Type
public static SoundSystem requestStationUp(java.lang.String where, SoundSystem.Type type)
where
- Valuetype
- Type SoundSystem.Type
public static SoundSystem requestStationDown(java.lang.String where, SoundSystem.Type type)
where
- Valuetype
- Type SoundSystem.Type
public java.lang.String getValue()
OpenMessage
getValue
in interface OpenMessage
protected static void checkRange(java.lang.Integer from, java.lang.Integer to, java.lang.Integer value)
protected static boolean isInRange(java.lang.Integer from, java.lang.Integer to, java.lang.Integer value)
protected static int checkIsInteger(java.lang.String value)
protected static void isValidPrefixType(OpenMessage request, java.lang.String format, int who)
protected static rx.functions.Func1<OpenSession,OpenSession> handleResponse(rx.functions.Action0 onSuccess, rx.functions.Action0 onFail, int who)
protected static java.lang.String checkBus(java.lang.String bus)
protected static java.lang.Boolean isValidBus(java.lang.String bus)