aes70 1.3.3 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +46 -0
- package/dist/AES70.es5.js +1 -1
- package/package.json +9 -3
- package/src/OCP1/encode_message.js +3 -6
- package/src/OCP1/message_generator.js +21 -21
- package/src/OCP1.js +162 -0
- package/src/controller/ControlClasses/OcaFilterFIR.d.ts +5 -0
- package/src/controller/ControlClasses/OcaFilterFIR.js +9 -1
- package/src/controller/ControlClasses/OcaLibrary.d.ts +3 -1
- package/src/controller/ControlClasses/OcaLibrary.js +3 -1
- package/src/controller/ControlClasses/OcaPowerManager.d.ts +5 -0
- package/src/controller/ControlClasses/OcaPowerManager.js +9 -1
- package/src/controller/ControlClasses/OcaPowerSupply.d.ts +10 -0
- package/src/controller/ControlClasses/OcaPowerSupply.js +20 -2
- package/src/controller/ControlClasses/OcaSensor.d.ts +5 -0
- package/src/controller/ControlClasses/OcaSensor.js +9 -1
- package/src/controller/ControlClasses.d.ts +0 -1
- package/src/controller/arguments.d.ts +1 -2
- package/src/controller/client_connection.d.ts +1 -1
- package/src/controller/client_connection.js +56 -32
- package/src/controller/event.js +4 -1
- package/src/controller/make_control_class.js +24 -4
- package/src/controller/remote_device.d.ts +1 -1
- package/src/controller/remote_device.js +48 -24
- package/src/controller/udp_connection.js +22 -20
- package/src/controller/websocket_connection.js +3 -1
- package/src/controller/websocket_connection_node.js +3 -1
- package/tests/device/locking.js +2 -1
- package/tests/device/method_callback.js +24 -0
- package/tests/device/test.js +11 -4
- package/tests/device.js +15 -2
- package/bin/connectMany.js +0 -64
- package/src/OCP1/.keepalive.js.swo +0 -0
- package/src/OCP1/OcaClassID.js +0 -16
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
encodeMessageTo,
|
|
3
|
-
messageHeaderSize,
|
|
4
|
-
} from './encode_message.js';
|
|
1
|
+
import { encodeMessageTo, messageHeaderSize } from './encode_message.js';
|
|
5
2
|
|
|
6
3
|
const pduTypeKeepAlive = 4;
|
|
7
4
|
|
|
8
5
|
export class MessageGenerator {
|
|
9
6
|
constructor(batchSize, resultCallback) {
|
|
10
|
-
if (!(batchSize <= 0xffffffff))
|
|
11
|
-
throw new TypeError('Invalid batch size.');
|
|
7
|
+
if (!(batchSize <= 0xffffffff)) throw new TypeError('Invalid batch size.');
|
|
12
8
|
this._pdus = [];
|
|
13
9
|
this._batchSize = batchSize;
|
|
14
10
|
this._resultCallback = resultCallback;
|
|
@@ -19,7 +15,7 @@ export class MessageGenerator {
|
|
|
19
15
|
this._flushCb = () => {
|
|
20
16
|
this._flushScheduled = false;
|
|
21
17
|
if (this._pdus === null) return;
|
|
22
|
-
this.flush();
|
|
18
|
+
this.flush();
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
|
|
@@ -29,13 +25,13 @@ export class MessageGenerator {
|
|
|
29
25
|
const messageType = pdu.messageType;
|
|
30
26
|
|
|
31
27
|
// Can we add to the current message?
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const combine =
|
|
29
|
+
this._lastMessageType === messageType &&
|
|
30
|
+
messageType !== pduTypeKeepAlive &&
|
|
31
|
+
this._currentCount < 0xffff;
|
|
35
32
|
let additionalSize = encodedLength;
|
|
36
33
|
|
|
37
|
-
if (!combine)
|
|
38
|
-
additionalSize += messageHeaderSize;
|
|
34
|
+
if (!combine) additionalSize += messageHeaderSize;
|
|
39
35
|
|
|
40
36
|
// The resulting buffer would become too large, we flush now.
|
|
41
37
|
if (currentSize && currentSize + additionalSize > this._batchSize) {
|
|
@@ -47,7 +43,7 @@ export class MessageGenerator {
|
|
|
47
43
|
this._currentSize += additionalSize;
|
|
48
44
|
|
|
49
45
|
if (combine) {
|
|
50
|
-
this._currentCount
|
|
46
|
+
this._currentCount++;
|
|
51
47
|
} else {
|
|
52
48
|
this._currentCount = 1;
|
|
53
49
|
}
|
|
@@ -65,14 +61,15 @@ export class MessageGenerator {
|
|
|
65
61
|
scheduleFlush() {
|
|
66
62
|
if (this._flushScheduled) return;
|
|
67
63
|
this._flushScheduled = true;
|
|
68
|
-
Promise.resolve()
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
Promise.resolve()
|
|
65
|
+
.then(this._flushCb)
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
console.error(err);
|
|
68
|
+
});
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
flush() {
|
|
74
|
-
if (!this._currentSize)
|
|
75
|
-
return;
|
|
72
|
+
if (!this._currentSize) return;
|
|
76
73
|
|
|
77
74
|
const pdus = this._pdus;
|
|
78
75
|
|
|
@@ -85,9 +82,12 @@ export class MessageGenerator {
|
|
|
85
82
|
const pdu = pdus[i];
|
|
86
83
|
const messageType = pdu.messageType;
|
|
87
84
|
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
if (
|
|
86
|
+
i === length - 1 ||
|
|
87
|
+
i + 1 - from === 0xffff ||
|
|
88
|
+
messageType === pduTypeKeepAlive ||
|
|
89
|
+
messageType !== pdus[i + 1].messageType
|
|
90
|
+
) {
|
|
91
91
|
pos = encodeMessageTo(dst, pos, pdus, from, i + 1);
|
|
92
92
|
from = i + 1;
|
|
93
93
|
}
|
package/src/OCP1.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export { Bitset16 } from './OCP1/Bitset16.js'
|
|
2
|
+
export { Bitset8 } from './OCP1/Bitset8.js'
|
|
3
|
+
export { Enum } from './OCP1/Enum.js'
|
|
4
|
+
export { Enum16 } from './OCP1/Enum16.js'
|
|
5
|
+
export { Enum8 } from './OCP1/Enum8.js'
|
|
6
|
+
export { OcaApplicationNetworkCommand } from './OCP1/OcaApplicationNetworkCommand.js'
|
|
7
|
+
export { OcaApplicationNetworkState } from './OCP1/OcaApplicationNetworkState.js'
|
|
8
|
+
export { OcaBaseDataType } from './OCP1/OcaBaseDataType.js'
|
|
9
|
+
export { OcaBitSet16 } from './OCP1/OcaBitSet16.js'
|
|
10
|
+
export { OcaBitstring } from './OCP1/OcaBitstring.js'
|
|
11
|
+
export { OcaBlob } from './OCP1/OcaBlob.js'
|
|
12
|
+
export { OcaBlobFixedLen } from './OCP1/OcaBlobFixedLen.js'
|
|
13
|
+
export { OcaBlockMember } from './OCP1/OcaBlockMember.js'
|
|
14
|
+
export { OcaBoolean } from './OCP1/OcaBoolean.js'
|
|
15
|
+
export { OcaClassAuthorityID } from './OCP1/OcaClassAuthorityID.js'
|
|
16
|
+
export { OcaClassIdentification } from './OCP1/OcaClassIdentification.js'
|
|
17
|
+
export { OcaClassicalFilterShape } from './OCP1/OcaClassicalFilterShape.js'
|
|
18
|
+
export { OcaComponent } from './OCP1/OcaComponent.js'
|
|
19
|
+
export { OcaDBr } from './OCP1/OcaDBr.js'
|
|
20
|
+
export { OcaDelayUnit } from './OCP1/OcaDelayUnit.js'
|
|
21
|
+
export { OcaDelayValue } from './OCP1/OcaDelayValue.js'
|
|
22
|
+
export { OcaDeviceState } from './OCP1/OcaDeviceState.js'
|
|
23
|
+
export { OcaDynamicsFunction } from './OCP1/OcaDynamicsFunction.js'
|
|
24
|
+
export { OcaEnumItem } from './OCP1/OcaEnumItem.js'
|
|
25
|
+
export { OcaEnumItem16 } from './OCP1/OcaEnumItem16.js'
|
|
26
|
+
export { OcaEvent } from './OCP1/OcaEvent.js'
|
|
27
|
+
export { OcaEventID } from './OCP1/OcaEventID.js'
|
|
28
|
+
export { OcaFilterPassband } from './OCP1/OcaFilterPassband.js'
|
|
29
|
+
export { OcaFloat32 } from './OCP1/OcaFloat32.js'
|
|
30
|
+
export { OcaFloat64 } from './OCP1/OcaFloat64.js'
|
|
31
|
+
export { OcaGlobalTypeIdentifier } from './OCP1/OcaGlobalTypeIdentifier.js'
|
|
32
|
+
export { OcaGrouperCitizen } from './OCP1/OcaGrouperCitizen.js'
|
|
33
|
+
export { OcaGrouperEnrollment } from './OCP1/OcaGrouperEnrollment.js'
|
|
34
|
+
export { OcaGrouperGroup } from './OCP1/OcaGrouperGroup.js'
|
|
35
|
+
export { OcaGrouperMode } from './OCP1/OcaGrouperMode.js'
|
|
36
|
+
export { OcaGrouperStatusChangeEventData } from './OCP1/OcaGrouperStatusChangeEventData.js'
|
|
37
|
+
export { OcaGrouperStatusChangeType } from './OCP1/OcaGrouperStatusChangeType.js'
|
|
38
|
+
export { OcaImpedance } from './OCP1/OcaImpedance.js'
|
|
39
|
+
export { OcaInt16 } from './OCP1/OcaInt16.js'
|
|
40
|
+
export { OcaInt32 } from './OCP1/OcaInt32.js'
|
|
41
|
+
export { OcaInt64 } from './OCP1/OcaInt64.js'
|
|
42
|
+
export { OcaInt8 } from './OCP1/OcaInt8.js'
|
|
43
|
+
export { OcaLevelDetectionLaw } from './OCP1/OcaLevelDetectionLaw.js'
|
|
44
|
+
export { OcaLevelMeterLaw } from './OCP1/OcaLevelMeterLaw.js'
|
|
45
|
+
export { OcaLibAccess } from './OCP1/OcaLibAccess.js'
|
|
46
|
+
export { OcaLibParamSetAssignment } from './OCP1/OcaLibParamSetAssignment.js'
|
|
47
|
+
export { OcaLibVol } from './OCP1/OcaLibVol.js'
|
|
48
|
+
export { OcaLibVolChangedEventData } from './OCP1/OcaLibVolChangedEventData.js'
|
|
49
|
+
export { OcaLibVolData_ParamSet } from './OCP1/OcaLibVolData_ParamSet.js'
|
|
50
|
+
export { OcaLibVolIdentifier } from './OCP1/OcaLibVolIdentifier.js'
|
|
51
|
+
export { OcaLibVolMetadata } from './OCP1/OcaLibVolMetadata.js'
|
|
52
|
+
export { OcaLibVolStandardTypeID } from './OCP1/OcaLibVolStandardTypeID.js'
|
|
53
|
+
export { OcaLibVolType } from './OCP1/OcaLibVolType.js'
|
|
54
|
+
export { OcaLibraryIdentifier } from './OCP1/OcaLibraryIdentifier.js'
|
|
55
|
+
export { OcaList } from './OCP1/OcaList.js'
|
|
56
|
+
export { OcaList2D } from './OCP1/OcaList2D.js'
|
|
57
|
+
export { OcaManagerDescriptor } from './OCP1/OcaManagerDescriptor.js'
|
|
58
|
+
export { OcaMap } from './OCP1/OcaMap.js'
|
|
59
|
+
export { OcaMediaClockAvailability } from './OCP1/OcaMediaClockAvailability.js'
|
|
60
|
+
export { OcaMediaClockLockState } from './OCP1/OcaMediaClockLockState.js'
|
|
61
|
+
export { OcaMediaClockRate } from './OCP1/OcaMediaClockRate.js'
|
|
62
|
+
export { OcaMediaClockType } from './OCP1/OcaMediaClockType.js'
|
|
63
|
+
export { OcaMediaCoding } from './OCP1/OcaMediaCoding.js'
|
|
64
|
+
export { OcaMediaConnection } from './OCP1/OcaMediaConnection.js'
|
|
65
|
+
export { OcaMediaConnectorCommand } from './OCP1/OcaMediaConnectorCommand.js'
|
|
66
|
+
export { OcaMediaConnectorElement } from './OCP1/OcaMediaConnectorElement.js'
|
|
67
|
+
export { OcaMediaConnectorState } from './OCP1/OcaMediaConnectorState.js'
|
|
68
|
+
export { OcaMediaConnectorStatus } from './OCP1/OcaMediaConnectorStatus.js'
|
|
69
|
+
export { OcaMediaConnectorStatusChangedEventData } from './OCP1/OcaMediaConnectorStatusChangedEventData.js'
|
|
70
|
+
export { OcaMediaSinkConnector } from './OCP1/OcaMediaSinkConnector.js'
|
|
71
|
+
export { OcaMediaSinkConnectorChangedEventData } from './OCP1/OcaMediaSinkConnectorChangedEventData.js'
|
|
72
|
+
export { OcaMediaSourceConnector } from './OCP1/OcaMediaSourceConnector.js'
|
|
73
|
+
export { OcaMediaSourceConnectorChangedEventData } from './OCP1/OcaMediaSourceConnectorChangedEventData.js'
|
|
74
|
+
export { OcaMediaStreamCastMode } from './OCP1/OcaMediaStreamCastMode.js'
|
|
75
|
+
export { OcaMethod } from './OCP1/OcaMethod.js'
|
|
76
|
+
export { OcaMethodID } from './OCP1/OcaMethodID.js'
|
|
77
|
+
export { OcaModelDescription } from './OCP1/OcaModelDescription.js'
|
|
78
|
+
export { OcaModelGUID } from './OCP1/OcaModelGUID.js'
|
|
79
|
+
export { OcaMultiMap } from './OCP1/OcaMultiMap.js'
|
|
80
|
+
export { OcaMuteState } from './OCP1/OcaMuteState.js'
|
|
81
|
+
export { OcaNetworkControlProtocol } from './OCP1/OcaNetworkControlProtocol.js'
|
|
82
|
+
export { OcaNetworkLinkType } from './OCP1/OcaNetworkLinkType.js'
|
|
83
|
+
export { OcaNetworkMediaProtocol } from './OCP1/OcaNetworkMediaProtocol.js'
|
|
84
|
+
export { OcaNetworkMediaSourceOrSink } from './OCP1/OcaNetworkMediaSourceOrSink.js'
|
|
85
|
+
export { OcaNetworkSignalChannelStatus } from './OCP1/OcaNetworkSignalChannelStatus.js'
|
|
86
|
+
export { OcaNetworkStatistics } from './OCP1/OcaNetworkStatistics.js'
|
|
87
|
+
export { OcaNetworkStatus } from './OCP1/OcaNetworkStatus.js'
|
|
88
|
+
export { OcaNetworkSystemInterfaceDescriptor } from './OCP1/OcaNetworkSystemInterfaceDescriptor.js'
|
|
89
|
+
export { OcaNetworkSystemInterfaceID } from './OCP1/OcaNetworkSystemInterfaceID.js'
|
|
90
|
+
export { OcaNotificationDeliveryMode } from './OCP1/OcaNotificationDeliveryMode.js'
|
|
91
|
+
export { OcaOPath } from './OCP1/OcaOPath.js'
|
|
92
|
+
export { OcaObjectIdentification } from './OCP1/OcaObjectIdentification.js'
|
|
93
|
+
export { OcaObjectListEventData } from './OCP1/OcaObjectListEventData.js'
|
|
94
|
+
export { OcaObjectSearchResult } from './OCP1/OcaObjectSearchResult.js'
|
|
95
|
+
export { OcaObjectSearchResultFlags } from './OCP1/OcaObjectSearchResultFlags.js'
|
|
96
|
+
export { OcaObservationEventData } from './OCP1/OcaObservationEventData.js'
|
|
97
|
+
export { OcaObservationListEventData } from './OCP1/OcaObservationListEventData.js'
|
|
98
|
+
export { OcaObserverState } from './OCP1/OcaObserverState.js'
|
|
99
|
+
export { OcaParametricEQShape } from './OCP1/OcaParametricEQShape.js'
|
|
100
|
+
export { OcaPilotToneDetectorSpec } from './OCP1/OcaPilotToneDetectorSpec.js'
|
|
101
|
+
export { OcaPolarityState } from './OCP1/OcaPolarityState.js'
|
|
102
|
+
export { OcaPort } from './OCP1/OcaPort.js'
|
|
103
|
+
export { OcaPortID } from './OCP1/OcaPortID.js'
|
|
104
|
+
export { OcaPortMode } from './OCP1/OcaPortMode.js'
|
|
105
|
+
export { OcaPositionCoordinateSystem } from './OCP1/OcaPositionCoordinateSystem.js'
|
|
106
|
+
export { OcaPositionDescriptor } from './OCP1/OcaPositionDescriptor.js'
|
|
107
|
+
export { OcaPowerState } from './OCP1/OcaPowerState.js'
|
|
108
|
+
export { OcaPowerSupplyLocation } from './OCP1/OcaPowerSupplyLocation.js'
|
|
109
|
+
export { OcaPowerSupplyState } from './OCP1/OcaPowerSupplyState.js'
|
|
110
|
+
export { OcaPowerSupplyType } from './OCP1/OcaPowerSupplyType.js'
|
|
111
|
+
export { OcaPresentationUnit } from './OCP1/OcaPresentationUnit.js'
|
|
112
|
+
export { OcaProperty } from './OCP1/OcaProperty.js'
|
|
113
|
+
export { OcaPropertyChangeType } from './OCP1/OcaPropertyChangeType.js'
|
|
114
|
+
export { OcaPropertyChangedEventData } from './OCP1/OcaPropertyChangedEventData.js'
|
|
115
|
+
export { OcaPropertyDescriptor } from './OCP1/OcaPropertyDescriptor.js'
|
|
116
|
+
export { OcaPropertyID } from './OCP1/OcaPropertyID.js'
|
|
117
|
+
export { OcaProtoObjectIdentification } from './OCP1/OcaProtoObjectIdentification.js'
|
|
118
|
+
export { OcaProtoPort } from './OCP1/OcaProtoPort.js'
|
|
119
|
+
export { OcaProtoPortID } from './OCP1/OcaProtoPortID.js'
|
|
120
|
+
export { OcaProtoSignalPath } from './OCP1/OcaProtoSignalPath.js'
|
|
121
|
+
export { OcaRamperCommand } from './OCP1/OcaRamperCommand.js'
|
|
122
|
+
export { OcaRamperInterpolationLaw } from './OCP1/OcaRamperInterpolationLaw.js'
|
|
123
|
+
export { OcaRamperState } from './OCP1/OcaRamperState.js'
|
|
124
|
+
export { OcaRelationalOperator } from './OCP1/OcaRelationalOperator.js'
|
|
125
|
+
export { OcaResetCause } from './OCP1/OcaResetCause.js'
|
|
126
|
+
export { OcaSensorReadingState } from './OCP1/OcaSensorReadingState.js'
|
|
127
|
+
export { OcaSignalPath } from './OCP1/OcaSignalPath.js'
|
|
128
|
+
export { OcaStatus } from './OCP1/OcaStatus.js'
|
|
129
|
+
export { OcaStream } from './OCP1/OcaStream.js'
|
|
130
|
+
export { OcaStreamConnectorIdentification } from './OCP1/OcaStreamConnectorIdentification.js'
|
|
131
|
+
export { OcaStreamConnectorStatus } from './OCP1/OcaStreamConnectorStatus.js'
|
|
132
|
+
export { OcaStreamStatus } from './OCP1/OcaStreamStatus.js'
|
|
133
|
+
export { OcaStreamType } from './OCP1/OcaStreamType.js'
|
|
134
|
+
export { OcaString } from './OCP1/OcaString.js'
|
|
135
|
+
export { OcaStringComparisonType } from './OCP1/OcaStringComparisonType.js'
|
|
136
|
+
export { OcaSubscriptionManagerState } from './OCP1/OcaSubscriptionManagerState.js'
|
|
137
|
+
export { OcaSweepType } from './OCP1/OcaSweepType.js'
|
|
138
|
+
export { OcaTask } from './OCP1/OcaTask.js'
|
|
139
|
+
export { OcaTaskCommand } from './OCP1/OcaTaskCommand.js'
|
|
140
|
+
export { OcaTaskManagerState } from './OCP1/OcaTaskManagerState.js'
|
|
141
|
+
export { OcaTaskState } from './OCP1/OcaTaskState.js'
|
|
142
|
+
export { OcaTaskStateChangedEventData } from './OCP1/OcaTaskStateChangedEventData.js'
|
|
143
|
+
export { OcaTaskStatus } from './OCP1/OcaTaskStatus.js'
|
|
144
|
+
export { OcaTimeMode } from './OCP1/OcaTimeMode.js'
|
|
145
|
+
export { OcaTimePTP } from './OCP1/OcaTimePTP.js'
|
|
146
|
+
export { OcaTimeProtocol } from './OCP1/OcaTimeProtocol.js'
|
|
147
|
+
export { OcaTimeReferenceType } from './OCP1/OcaTimeReferenceType.js'
|
|
148
|
+
export { OcaTimeSourceAvailability } from './OCP1/OcaTimeSourceAvailability.js'
|
|
149
|
+
export { OcaTimeSourceSyncStatus } from './OCP1/OcaTimeSourceSyncStatus.js'
|
|
150
|
+
export { OcaTransferFunction } from './OCP1/OcaTransferFunction.js'
|
|
151
|
+
export { OcaUint16 } from './OCP1/OcaUint16.js'
|
|
152
|
+
export { OcaUint32 } from './OCP1/OcaUint32.js'
|
|
153
|
+
export { OcaUint64 } from './OCP1/OcaUint64.js'
|
|
154
|
+
export { OcaUint8 } from './OCP1/OcaUint8.js'
|
|
155
|
+
export { OcaUnitOfMeasure } from './OCP1/OcaUnitOfMeasure.js'
|
|
156
|
+
export { OcaVersion } from './OCP1/OcaVersion.js'
|
|
157
|
+
export { OcaWaveformType } from './OCP1/OcaWaveformType.js'
|
|
158
|
+
export { Rest } from './OCP1/Rest.js'
|
|
159
|
+
export { RestWithOffset } from './OCP1/RestWithOffset.js'
|
|
160
|
+
export { String16 } from './OCP1/String16.js'
|
|
161
|
+
export { Struct } from './OCP1/Struct.js'
|
|
162
|
+
export { Tuple } from './OCP1/Tuple.js'
|
|
@@ -10,6 +10,11 @@ import { PropertyEvent } from '../property_event';
|
|
|
10
10
|
* @class OcaFilterFIR
|
|
11
11
|
*/
|
|
12
12
|
export declare class OcaFilterFIR extends OcaActuator {
|
|
13
|
+
/**
|
|
14
|
+
* This event is emitted whenever Length changes.
|
|
15
|
+
*/
|
|
16
|
+
OnLengthChanged: PropertyEvent<number>;
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* This event is emitted whenever Coefficients changes.
|
|
15
20
|
*/
|
|
@@ -23,7 +23,7 @@ export const OcaFilterFIR = make_control_class(
|
|
|
23
23
|
['SetSampleRate', 4, 5, [OcaFloat32], []],
|
|
24
24
|
],
|
|
25
25
|
[
|
|
26
|
-
['Length', [OcaUint32], 4, 1,
|
|
26
|
+
['Length', [OcaUint32], 4, 1, false, false, null],
|
|
27
27
|
['Coefficients', [OcaList(OcaFloat32)], 4, 2, false, false, null],
|
|
28
28
|
['SampleRate', [OcaFloat32], 4, 3, false, false, null],
|
|
29
29
|
],
|
|
@@ -75,6 +75,14 @@ export const OcaFilterFIR = make_control_class(
|
|
|
75
75
|
*
|
|
76
76
|
* @returns {Promise<void>}
|
|
77
77
|
*/
|
|
78
|
+
/**
|
|
79
|
+
* This event is emitted when the property Length changes in the remote object.
|
|
80
|
+
* The property ``Length`` is described in the AES70 standard as follows.
|
|
81
|
+
* Length of the filter, in samples. Readonly. Value is set when
|
|
82
|
+
* SetCoefficients(...) method executes.
|
|
83
|
+
*
|
|
84
|
+
* @member {PropertyEvent<number>} OcaFilterFIR#OnLengthChanged
|
|
85
|
+
*/
|
|
78
86
|
/**
|
|
79
87
|
* This event is emitted when the property Coefficients changes in the remote object.
|
|
80
88
|
* The property ``Coefficients`` is described in the AES70 standard as follows.
|
|
@@ -77,10 +77,12 @@ export declare class OcaLibrary extends OcaAgent {
|
|
|
77
77
|
* Retrieves a library volume. The return value indicates whether the volume was successfully retrieved. Changed in version 2 because the definition of OcaLibVolMetaData, which is part of OcaLibVol, has changed.
|
|
78
78
|
*
|
|
79
79
|
* @method OcaLibrary#GetVolume
|
|
80
|
+
* @param {number} ID
|
|
81
|
+
*
|
|
80
82
|
* @returns {Promise<OcaLibVol>}
|
|
81
83
|
* A promise which resolves to a single value of type :class:`OcaLibVol`.
|
|
82
84
|
*/
|
|
83
|
-
GetVolume(): Promise<OcaLibVol>;
|
|
85
|
+
GetVolume(ID: number): Promise<OcaLibVol>;
|
|
84
86
|
|
|
85
87
|
/**
|
|
86
88
|
* Gets the count of volumes in this library. The return value indicates whether the count was successfully retrieved.
|
|
@@ -23,7 +23,7 @@ export const OcaLibrary = make_control_class(
|
|
|
23
23
|
['AddVolume', 3, 1, [OcaLibVol], [OcaUint32]],
|
|
24
24
|
['ReplaceVolume', 3, 2, [OcaUint32, OcaLibVol], []],
|
|
25
25
|
['DeleteVolume', 3, 3, [OcaUint32], []],
|
|
26
|
-
['GetVolume', 3, 4, [], [OcaLibVol]],
|
|
26
|
+
['GetVolume', 3, 4, [OcaUint32], [OcaLibVol]],
|
|
27
27
|
['GetVolumeCount', 3, 5, [], [OcaUint16]],
|
|
28
28
|
['GetVolumes', 3, 6, [], [OcaMap(OcaUint32, OcaLibVol)]],
|
|
29
29
|
['GetAccess', 3, 7, [], [OcaLibAccess]],
|
|
@@ -68,6 +68,8 @@ export const OcaLibrary = make_control_class(
|
|
|
68
68
|
* Retrieves a library volume. The return value indicates whether the volume was successfully retrieved. Changed in version 2 because the definition of OcaLibVolMetaData, which is part of OcaLibVol, has changed.
|
|
69
69
|
*
|
|
70
70
|
* @method OcaLibrary#GetVolume
|
|
71
|
+
* @param {number} ID
|
|
72
|
+
*
|
|
71
73
|
* @returns {Promise<OcaLibVol>}
|
|
72
74
|
* A promise which resolves to a single value of type :class:`OcaLibVol`.
|
|
73
75
|
*/
|
|
@@ -37,6 +37,11 @@ export declare class OcaPowerManager extends OcaManager {
|
|
|
37
37
|
*/
|
|
38
38
|
OnAutoStateChanged: PropertyEvent<boolean>;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* This event is emitted whenever TargetState changes.
|
|
42
|
+
*/
|
|
43
|
+
OnTargetStateChanged: PropertyEvent<OcaPowerState>;
|
|
44
|
+
|
|
40
45
|
constructor(objectNumber: number, device: RemoteDevice);
|
|
41
46
|
|
|
42
47
|
/**
|
|
@@ -35,7 +35,7 @@ export const OcaPowerManager = make_control_class(
|
|
|
35
35
|
['PowerSupplies', [OcaList(OcaUint32)], 3, 2, false, false, null],
|
|
36
36
|
['ActivePowerSupplies', [OcaList(OcaUint32)], 3, 3, false, false, null],
|
|
37
37
|
['AutoState', [OcaBoolean], 3, 4, false, false, null],
|
|
38
|
-
['TargetState', [OcaPowerState], 3, 5,
|
|
38
|
+
['TargetState', [OcaPowerState], 3, 5, false, false, null],
|
|
39
39
|
],
|
|
40
40
|
[]
|
|
41
41
|
);
|
|
@@ -117,3 +117,11 @@ export const OcaPowerManager = make_control_class(
|
|
|
117
117
|
*
|
|
118
118
|
* @member {PropertyEvent<boolean>} OcaPowerManager#OnAutoStateChanged
|
|
119
119
|
*/
|
|
120
|
+
/**
|
|
121
|
+
* This event is emitted when the property TargetState changes in the remote object.
|
|
122
|
+
* The property ``TargetState`` is described in the AES70 standard as follows.
|
|
123
|
+
* Power state to which the device is transitioning. If no transition is
|
|
124
|
+
* in progress, has value None. Readonly.
|
|
125
|
+
*
|
|
126
|
+
* @member {PropertyEvent<OcaPowerState>} OcaPowerManager#OnTargetStateChanged
|
|
127
|
+
*/
|
|
@@ -33,6 +33,16 @@ export declare class OcaPowerSupply extends OcaAgent {
|
|
|
33
33
|
*/
|
|
34
34
|
OnChargingChanged: PropertyEvent<boolean>;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* This event is emitted whenever LoadFractionAvailable changes.
|
|
38
|
+
*/
|
|
39
|
+
OnLoadFractionAvailableChanged: PropertyEvent<number>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* This event is emitted whenever StorageFractionAvailable changes.
|
|
43
|
+
*/
|
|
44
|
+
OnStorageFractionAvailableChanged: PropertyEvent<number>;
|
|
45
|
+
|
|
36
46
|
constructor(objectNumber: number, device: RemoteDevice);
|
|
37
47
|
|
|
38
48
|
/**
|
|
@@ -33,8 +33,8 @@ export const OcaPowerSupply = make_control_class(
|
|
|
33
33
|
['ModelInfo', [OcaString], 3, 2, false, false, null],
|
|
34
34
|
['State', [OcaPowerSupplyState], 3, 3, false, false, null],
|
|
35
35
|
['Charging', [OcaBoolean], 3, 4, false, false, null],
|
|
36
|
-
['LoadFractionAvailable', [OcaFloat32], 3, 5,
|
|
37
|
-
['StorageFractionAvailable', [OcaFloat32], 3, 6,
|
|
36
|
+
['LoadFractionAvailable', [OcaFloat32], 3, 5, false, false, null],
|
|
37
|
+
['StorageFractionAvailable', [OcaFloat32], 3, 6, false, false, null],
|
|
38
38
|
['Location', [OcaPowerSupplyLocation], 3, 7, true, false, null],
|
|
39
39
|
],
|
|
40
40
|
[]
|
|
@@ -126,3 +126,21 @@ export const OcaPowerSupply = make_control_class(
|
|
|
126
126
|
*
|
|
127
127
|
* @member {PropertyEvent<boolean>} OcaPowerSupply#OnChargingChanged
|
|
128
128
|
*/
|
|
129
|
+
/**
|
|
130
|
+
* This event is emitted when the property LoadFractionAvailable changes in the remote object.
|
|
131
|
+
* The property ``LoadFractionAvailable`` is described in the AES70 standard as follows.
|
|
132
|
+
* Fraction of power supply's load capacity that is currently not being
|
|
133
|
+
* used. Readonly. Normal value range 0...1. A negative value indicates
|
|
134
|
+
* this data is not available.
|
|
135
|
+
*
|
|
136
|
+
* @member {PropertyEvent<number>} OcaPowerSupply#OnLoadFractionAvailableChanged
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* This event is emitted when the property StorageFractionAvailable changes in the remote object.
|
|
140
|
+
* The property ``StorageFractionAvailable`` is described in the AES70 standard as follows.
|
|
141
|
+
* Fraction of power supply's energy storage that remains available. For
|
|
142
|
+
* battery supplies. Readonly. Normal value range 0...1. A negative value
|
|
143
|
+
* indicates this data is not available.
|
|
144
|
+
*
|
|
145
|
+
* @member {PropertyEvent<number>} OcaPowerSupply#OnStorageFractionAvailableChanged
|
|
146
|
+
*/
|
|
@@ -10,6 +10,11 @@ import { OcaSensorReadingState } from '../../types/OcaSensorReadingState';
|
|
|
10
10
|
* @class OcaSensor
|
|
11
11
|
*/
|
|
12
12
|
export declare class OcaSensor extends OcaWorker {
|
|
13
|
+
/**
|
|
14
|
+
* This event is emitted whenever ReadingState changes.
|
|
15
|
+
*/
|
|
16
|
+
OnReadingStateChanged: PropertyEvent<OcaSensorReadingState>;
|
|
17
|
+
|
|
13
18
|
constructor(objectNumber: number, device: RemoteDevice);
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -14,7 +14,7 @@ export const OcaSensor = make_control_class(
|
|
|
14
14
|
2,
|
|
15
15
|
OcaWorker,
|
|
16
16
|
[['GetReadingState', 3, 1, [], [OcaSensorReadingState]]],
|
|
17
|
-
[['ReadingState', [OcaSensorReadingState], 3, 1, false,
|
|
17
|
+
[['ReadingState', [OcaSensorReadingState], 3, 1, false, false, null]],
|
|
18
18
|
[]
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -25,3 +25,11 @@ export const OcaSensor = make_control_class(
|
|
|
25
25
|
* @returns {Promise<OcaSensorReadingState>}
|
|
26
26
|
* A promise which resolves to a single value of type :class:`OcaSensorReadingState`.
|
|
27
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* This event is emitted when the property ReadingState changes in the remote object.
|
|
30
|
+
* The property ``ReadingState`` is described in the AES70 standard as follows.
|
|
31
|
+
* Enum that describes whether current reading value is valid and if not,
|
|
32
|
+
* why not. Readonly.
|
|
33
|
+
*
|
|
34
|
+
* @member {PropertyEvent<OcaSensorReadingState>} OcaSensor#OnReadingStateChanged
|
|
35
|
+
*/
|
|
@@ -7,11 +7,10 @@ export declare class Arguments<ArgumentTypes extends unknown[]> {
|
|
|
7
7
|
*/
|
|
8
8
|
readonly values: ArgumentTypes;
|
|
9
9
|
|
|
10
|
-
constructor(values: ArgumentTypes)
|
|
10
|
+
constructor(values: ArgumentTypes);
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The number of elements.
|
|
14
14
|
*/
|
|
15
15
|
get length(): number;
|
|
16
|
-
|
|
17
16
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RemoteError } from './remote_error.js';
|
|
2
2
|
import { Connection } from '../connection.js';
|
|
3
3
|
import { Response } from '../OCP1/response.js';
|
|
4
|
-
import { encodeMessage } from '../OCP1/encode_message.js';
|
|
5
4
|
import { KeepAlive } from '../OCP1/keepalive.js';
|
|
6
5
|
import { Notification } from '../OCP1/notification.js';
|
|
7
6
|
import { Arguments } from './arguments.js';
|
|
@@ -52,6 +51,13 @@ class PendingCommand {
|
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
function eventToKey(event) {
|
|
55
|
+
const ono = event.EmitterONo;
|
|
56
|
+
const id = event.EventID;
|
|
57
|
+
|
|
58
|
+
return [ono, id.DefLevel, id.EventIndex].join(',');
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
/**
|
|
56
62
|
* Connection base class for clients (aka controllers).
|
|
57
63
|
*
|
|
@@ -63,12 +69,12 @@ export class ClientConnection extends Connection {
|
|
|
63
69
|
super(options);
|
|
64
70
|
this._pendingCommands = new Map();
|
|
65
71
|
this._nextCommandHandle = 0;
|
|
66
|
-
this.
|
|
72
|
+
this._subscribers = new Map();
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
cleanup() {
|
|
70
76
|
super.cleanup();
|
|
71
|
-
this.
|
|
77
|
+
this._subscribers = null;
|
|
72
78
|
|
|
73
79
|
const pendingCommands = this._pendingCommands;
|
|
74
80
|
this._pendingCommands = null;
|
|
@@ -78,23 +84,22 @@ export class ClientConnection extends Connection {
|
|
|
78
84
|
});
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
DefLevel: 1,
|
|
89
|
-
MethodIndex: 1,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
87
|
+
_addSubscriber(event, callback) {
|
|
88
|
+
const key = eventToKey(event);
|
|
89
|
+
const subscribers = this._subscribers;
|
|
90
|
+
|
|
91
|
+
if (subscribers.has(key)) throw new Error('Subscriber already exists.');
|
|
92
|
+
|
|
93
|
+
subscribers.set(key, callback);
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
_removeSubscriber(event) {
|
|
97
|
+
const key = eventToKey(event);
|
|
98
|
+
const subscribers = this._subscribers;
|
|
99
|
+
|
|
100
|
+
if (!subscribers.has(key)) throw new Error('Unknown subscriber.');
|
|
101
|
+
|
|
102
|
+
subscribers.delete(key);
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
_getNextCommandHandle() {
|
|
@@ -107,34 +112,50 @@ export class ClientConnection extends Connection {
|
|
|
107
112
|
|
|
108
113
|
do {
|
|
109
114
|
handle = this._nextCommandHandle;
|
|
110
|
-
this._nextCommandHandle = (handle + 1)|0;
|
|
115
|
+
this._nextCommandHandle = (handle + 1) | 0;
|
|
111
116
|
} while (pendingCommands.has(handle));
|
|
112
117
|
|
|
113
118
|
return handle;
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
return
|
|
121
|
+
_estimate_next_tx_time() {
|
|
122
|
+
return this._now();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
send_command(command, returnTypes, callback) {
|
|
126
|
+
const executor = (resolve, reject) => {
|
|
118
127
|
const handle = this._getNextCommandHandle();
|
|
119
128
|
|
|
120
|
-
command.handle = handle
|
|
129
|
+
command.handle = handle;
|
|
121
130
|
|
|
122
131
|
const pendingCommand = new PendingCommand(
|
|
123
|
-
resolve,
|
|
132
|
+
resolve,
|
|
133
|
+
reject,
|
|
134
|
+
returnTypes,
|
|
135
|
+
command
|
|
136
|
+
);
|
|
124
137
|
|
|
125
138
|
this._pendingCommands.set(handle, pendingCommand);
|
|
126
139
|
|
|
127
|
-
pendingCommand.lastSent = this.
|
|
140
|
+
pendingCommand.lastSent = this._estimate_next_tx_time();
|
|
128
141
|
this.send(command);
|
|
129
|
-
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
if (callback) {
|
|
145
|
+
executor(
|
|
146
|
+
(result) => callback(true, result),
|
|
147
|
+
(error) => callback(false, error)
|
|
148
|
+
);
|
|
149
|
+
} else {
|
|
150
|
+
return new Promise(executor);
|
|
151
|
+
}
|
|
130
152
|
}
|
|
131
153
|
|
|
132
154
|
_removePendingCommand(handle) {
|
|
133
155
|
const pendingCommands = this._pendingCommands;
|
|
134
156
|
const pendingCommand = pendingCommands.get(handle);
|
|
135
157
|
|
|
136
|
-
if (!pendingCommand)
|
|
137
|
-
return null;
|
|
158
|
+
if (!pendingCommand) return null;
|
|
138
159
|
|
|
139
160
|
pendingCommands.delete(handle);
|
|
140
161
|
|
|
@@ -144,8 +165,7 @@ export class ClientConnection extends Connection {
|
|
|
144
165
|
incoming(pdus) {
|
|
145
166
|
for (let i = 0; i < pdus.length; i++) {
|
|
146
167
|
// Connection may have been closed while receiving a command
|
|
147
|
-
if (this._pendingCommands === null)
|
|
148
|
-
{
|
|
168
|
+
if (this._pendingCommands === null) {
|
|
149
169
|
return;
|
|
150
170
|
}
|
|
151
171
|
|
|
@@ -165,12 +185,16 @@ export class ClientConnection extends Connection {
|
|
|
165
185
|
|
|
166
186
|
pendingCommand.response(o);
|
|
167
187
|
} else if (o instanceof Notification) {
|
|
168
|
-
const subscribers = this.
|
|
169
|
-
|
|
188
|
+
const subscribers = this._subscribers;
|
|
189
|
+
const key = eventToKey(o.event);
|
|
190
|
+
|
|
191
|
+
const cb = subscribers.get(key);
|
|
192
|
+
|
|
193
|
+
if (!cb) {
|
|
170
194
|
// NOTE: this is legal
|
|
171
195
|
continue;
|
|
172
196
|
}
|
|
173
|
-
|
|
197
|
+
cb(o);
|
|
174
198
|
} else if (o instanceof KeepAlive) {
|
|
175
199
|
if (!(o.time > 0)) {
|
|
176
200
|
throw new Error('Bad keepalive timeout.');
|
package/src/controller/event.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BaseEvent } from './base_event.js';
|
|
2
2
|
import { error } from '../log.js';
|
|
3
3
|
|
|
4
|
+
const emptyBuffer = new ArrayBuffer();
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Class used to represent all events specified by the OCA standard.
|
|
6
8
|
*
|
|
@@ -13,7 +15,8 @@ export class Event extends BaseEvent {
|
|
|
13
15
|
if (!this.handlers.size) return;
|
|
14
16
|
|
|
15
17
|
const args = new Array(argumentTypes.length);
|
|
16
|
-
|
|
18
|
+
// Events without arguments have parameters = null
|
|
19
|
+
const data = new DataView(notification.parameters || emptyBuffer);
|
|
17
20
|
|
|
18
21
|
for (let pos = 0, i = 0; i < argumentTypes.length; i++) {
|
|
19
22
|
let tmp;
|