Skip to content

Package: DeviceAssetChannel

DeviceAssetChannel

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.management.asset;
14:
15: import java.util.Date;
16:
17: /**
18: * {@link DeviceAssetChannel} definition.
19: * <p>
20: * This entity is used to get information about channels installed in the device.
21: *
22: * @since 1.0.0
23: */
24: public interface DeviceAssetChannel {
25:
26: /**
27: * Gets the name.
28: *
29: * @return The name.
30: * @since 1.0.0
31: */
32: String getName();
33:
34: /**
35: * Gets the name.
36: *
37: * @param name The name.
38: * @since 1.0.0
39: */
40: void setName(String name);
41:
42: /**
43: * Gets the {@link Class} type.
44: * <p>
45: * This is the {@link Class} of the {@link #getValue()}.
46: *
47: * @return The channel value type.
48: * @since 1.0.0
49: */
50: Class<?> getType();
51:
52: /**
53: * Sets the {@link Class} type.
54: * This type must be coherent with the value given to {@link #setValue(Object)}.
55: * If not, errors will occur during the interaction with the device.
56: *
57: * @param type The {@link Class} type.
58: * @since 1.0.0
59: */
60: void setType(Class<?> type);
61:
62: /**
63: * Gets the {@link DeviceAssetChannelMode}.
64: *
65: * @return The {@link DeviceAssetChannelMode}.
66: * @since 1.0.0
67: */
68: DeviceAssetChannelMode getMode();
69:
70: /**
71: * Sets the {@link DeviceAssetChannelMode}.
72: *
73: * @param deviceAssetChannelMode The {@link DeviceAssetChannelMode}.
74: * @since 1.0.0
75: */
76: void setMode(DeviceAssetChannelMode deviceAssetChannelMode);
77:
78: /**
79: * Gets the value channel.
80: * <p>
81: * Depending on the {@link DeviceAssetChannelMode} this can be a value {@link DeviceAssetChannelMode#READ} from the channel or
82: * to {@link DeviceAssetChannelMode#WRITE} into the channel.
83: * This is mutually exclusive with {@link #getError()}
84: *
85: * @return The value channel.
86: * @since 1.0.0
87: */
88: Object getValue();
89:
90: /**
91: * Sets the value channel.
92: * <p>
93: * Depending on the {@link DeviceAssetChannelMode} this can be a value {@link DeviceAssetChannelMode#READ} from the channel or
94: * to {@link DeviceAssetChannelMode#WRITE} into the channel.
95: *
96: * @param value The value channel.
97: * @since 1.0.0
98: */
99: void setValue(Object value);
100:
101: /**
102: * Gets the error message.
103: * <p>
104: * When reading from or writing to a channel, if any error occurs it will be reported here.
105: * This is mutually exclusive with {@link #getValue()}
106: *
107: * @return The error message, if error has occurred.
108: * @since 1.0.0
109: */
110: String getError();
111:
112: /**
113: * Sets the error message.
114: * <p>
115: * This must be set if error has occurred during reading from/wrtiting to
116: *
117: * @param error The error message.
118: */
119: void setError(String error);
120:
121: /**
122: * Gets the {@link Date} of the time when the value was read from the channel.
123: *
124: * @return The {@link Date} of the time when the value was read from the channel.
125: * @since 1.0.0
126: */
127: Date getTimestamp();
128:
129: /**
130: * Sets the {@link Date} of the time when the value was read from the channel.
131: *
132: * @param timestamp The {@link Date} of the time when the value was read from the channel.
133: * @since 1.0.0
134: */
135: void setTimestamp(Date timestamp);
136: }