langjie-m-play 0.0.3 → 0.0.5
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.
|
@@ -49,11 +49,13 @@ export declare enum JsonRpcMethodEnum {
|
|
|
49
49
|
CALL_ATS_START = "R_CALL_PACK.atsStart",
|
|
50
50
|
CALL_ATS_TERMINATE = "R_CALL_PACK.atsTerminate",
|
|
51
51
|
CALL_ATS_SET_PARAM = "R_CALL_PACK.atsSetParam",
|
|
52
|
+
CALL_ATS_GET_PARAM = "R_CALL_PACK.atsGetParam",
|
|
52
53
|
CALL_ATS_PUSH_BUTTON = "R_CALL_PACK.atsPushButton",
|
|
53
54
|
REPLY_ATS_LOAD = "R_REPLY_PACK.atsLoad",
|
|
54
55
|
REPLY_ATS_START = "R_REPLY_PACK.atsStart",
|
|
55
56
|
REPLY_ATS_TERMINATE = "R_REPLY_PACK.atsTerminate",
|
|
56
57
|
REPLY_ATS_SET_PARAM = "R_REPLY_PACK.atsSetParam",
|
|
58
|
+
REPLY_ATS_GET_PARAM = "R_REPLY_PACK.atsGetParam",
|
|
57
59
|
REPLY_ATS_PUSH_BUTTON = "R_REPLY_PACK.atsPushButton",
|
|
58
60
|
CALL_SUBSCRIBE_FOR_DATA_GRAM = "R_CALL_PACK.subscribeForDatagram",
|
|
59
61
|
REPLY_SUBSCRIBE_FOR_DATA_GRAM = "R_REPLY_PACK.subscribeForDatagram",
|
|
@@ -54,11 +54,13 @@ var JsonRpcMethodEnum;
|
|
|
54
54
|
JsonRpcMethodEnum["CALL_ATS_START"] = "R_CALL_PACK.atsStart";
|
|
55
55
|
JsonRpcMethodEnum["CALL_ATS_TERMINATE"] = "R_CALL_PACK.atsTerminate";
|
|
56
56
|
JsonRpcMethodEnum["CALL_ATS_SET_PARAM"] = "R_CALL_PACK.atsSetParam";
|
|
57
|
+
JsonRpcMethodEnum["CALL_ATS_GET_PARAM"] = "R_CALL_PACK.atsGetParam";
|
|
57
58
|
JsonRpcMethodEnum["CALL_ATS_PUSH_BUTTON"] = "R_CALL_PACK.atsPushButton";
|
|
58
59
|
JsonRpcMethodEnum["REPLY_ATS_LOAD"] = "R_REPLY_PACK.atsLoad";
|
|
59
60
|
JsonRpcMethodEnum["REPLY_ATS_START"] = "R_REPLY_PACK.atsStart";
|
|
60
61
|
JsonRpcMethodEnum["REPLY_ATS_TERMINATE"] = "R_REPLY_PACK.atsTerminate";
|
|
61
62
|
JsonRpcMethodEnum["REPLY_ATS_SET_PARAM"] = "R_REPLY_PACK.atsSetParam";
|
|
63
|
+
JsonRpcMethodEnum["REPLY_ATS_GET_PARAM"] = "R_REPLY_PACK.atsGetParam";
|
|
62
64
|
JsonRpcMethodEnum["REPLY_ATS_PUSH_BUTTON"] = "R_REPLY_PACK.atsPushButton";
|
|
63
65
|
JsonRpcMethodEnum["CALL_SUBSCRIBE_FOR_DATA_GRAM"] = "R_CALL_PACK.subscribeForDatagram";
|
|
64
66
|
JsonRpcMethodEnum["REPLY_SUBSCRIBE_FOR_DATA_GRAM"] = "R_REPLY_PACK.subscribeForDatagram";
|
package/package.json
CHANGED
package/service/GtcClient.d.ts
CHANGED
|
@@ -246,4 +246,13 @@ export declare class GtcClient {
|
|
|
246
246
|
* @param values 参数values
|
|
247
247
|
*/
|
|
248
248
|
static atsSetParam(slaveInstId: string | null, serviceType: ServiceTypeEnum, ctrlIndex: number, atsHandle: number, keys: string[], values: Array<string | number>): Promise<null>;
|
|
249
|
+
/**
|
|
250
|
+
* 获取ats参数
|
|
251
|
+
*
|
|
252
|
+
* @param slaveInstId 从机id
|
|
253
|
+
* @param serviceType 服务类型
|
|
254
|
+
* @param ctrlIndex 卡索引
|
|
255
|
+
* @param atsHandle ats句柄
|
|
256
|
+
*/
|
|
257
|
+
static atsGetParam<K extends string, V>(slaveInstId: string | null, serviceType: ServiceTypeEnum, ctrlIndex: number, atsHandle: number): Promise<Record<K, V>>;
|
|
249
258
|
}
|
package/service/GtcClient.js
CHANGED
|
@@ -469,5 +469,22 @@ class GtcClient {
|
|
|
469
469
|
return GtcServiceFactory_1.default.getGtcService().call(request);
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* 获取ats参数
|
|
474
|
+
*
|
|
475
|
+
* @param slaveInstId 从机id
|
|
476
|
+
* @param serviceType 服务类型
|
|
477
|
+
* @param ctrlIndex 卡索引
|
|
478
|
+
* @param atsHandle ats句柄
|
|
479
|
+
*/
|
|
480
|
+
static atsGetParam(slaveInstId, serviceType, ctrlIndex, atsHandle) {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
+
const request = GtcClient.generateRequest(JsonRpcMethodEnum_1.JsonRpcMethodEnum.CALL_ATS_GET_PARAM, slaveInstId);
|
|
483
|
+
request.params[JsonRpcConstant_1.JsonRpcConstant.SERVICE_TYPE] = serviceType;
|
|
484
|
+
request.params[JsonRpcConstant_1.JsonRpcConstant.CTRL_INDEX] = ctrlIndex;
|
|
485
|
+
request.params[JsonRpcConstant_1.JsonRpcConstant.ATS_HANDLE] = atsHandle;
|
|
486
|
+
return GtcServiceFactory_1.default.getGtcService().call(request);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
472
489
|
}
|
|
473
490
|
exports.GtcClient = GtcClient;
|
package/service/MPlay.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare class MPlay {
|
|
|
5
5
|
private readonly ctrlIndex;
|
|
6
6
|
private dataGramCallBack;
|
|
7
7
|
private atsHandleNameMap;
|
|
8
|
+
private atsStartedMark;
|
|
8
9
|
/**
|
|
9
10
|
* Connect to the MPlay server.
|
|
10
11
|
*
|
|
@@ -50,4 +51,17 @@ export declare class MPlay {
|
|
|
50
51
|
* @param buttonName The name of the button to trigger.
|
|
51
52
|
*/
|
|
52
53
|
pushButton(atsHandle: number, buttonName: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the parameter of the ATS script by ATS handle.
|
|
56
|
+
*
|
|
57
|
+
* @param atsHandle The handle of the ATS script.
|
|
58
|
+
*/
|
|
59
|
+
atsGetParam(atsHandle: number): Promise<Record<string, number>>;
|
|
60
|
+
/**
|
|
61
|
+
* Set the parameter of the ATS script by ATS handle.
|
|
62
|
+
*
|
|
63
|
+
* @param atsHandle The handle of the ATS script.
|
|
64
|
+
* @param param The parameter to set.
|
|
65
|
+
*/
|
|
66
|
+
atsSetParam(atsHandle: number, param: Record<string, number>): Promise<void>;
|
|
53
67
|
}
|
package/service/MPlay.js
CHANGED
|
@@ -36,6 +36,7 @@ class MPlay {
|
|
|
36
36
|
constructor(instId, serviceType, ctrlIndex) {
|
|
37
37
|
this.ctrlIndex = 0;
|
|
38
38
|
this.atsHandleNameMap = {};
|
|
39
|
+
this.atsStartedMark = {};
|
|
39
40
|
if (instId) {
|
|
40
41
|
this.instId = instId;
|
|
41
42
|
}
|
|
@@ -120,6 +121,7 @@ class MPlay {
|
|
|
120
121
|
if (atsHandle === 0) {
|
|
121
122
|
throw new Error("Failed to load ATS script");
|
|
122
123
|
}
|
|
124
|
+
this.atsStartedMark[atsHandle] = false;
|
|
123
125
|
this.atsHandleNameMap[atsHandle] = atsScriptName;
|
|
124
126
|
return atsHandle;
|
|
125
127
|
});
|
|
@@ -137,6 +139,7 @@ class MPlay {
|
|
|
137
139
|
yield GtcClient_1.GtcClient.atsStart(this.instId, this.serviceType, this.ctrlIndex, atsHandle, this.atsHandleNameMap[atsHandle]);
|
|
138
140
|
yield atsStartSynchronizer.waitAll();
|
|
139
141
|
PubSubUtil_1.PubSubUtil.unsubscribe(SubKeyEnum_1.SubKeyEnum.ATS_START_OK, atsHandle.toString());
|
|
142
|
+
this.atsStartedMark[atsHandle] = true;
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
@@ -148,10 +151,39 @@ class MPlay {
|
|
|
148
151
|
pushButton(atsHandle, buttonName) {
|
|
149
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
153
|
if (!this.atsHandleNameMap[atsHandle]) {
|
|
151
|
-
throw new Error("Please
|
|
154
|
+
throw new Error("Please load ATS script first");
|
|
155
|
+
}
|
|
156
|
+
if (!this.atsStartedMark[atsHandle]) {
|
|
157
|
+
yield this.start(atsHandle);
|
|
152
158
|
}
|
|
153
159
|
yield GtcClient_1.GtcClient.atsPushButton(this.instId, this.serviceType, this.ctrlIndex, atsHandle, buttonName);
|
|
154
160
|
});
|
|
155
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Get the parameter of the ATS script by ATS handle.
|
|
164
|
+
*
|
|
165
|
+
* @param atsHandle The handle of the ATS script.
|
|
166
|
+
*/
|
|
167
|
+
atsGetParam(atsHandle) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
return yield GtcClient_1.GtcClient.atsGetParam(this.instId, this.serviceType, this.ctrlIndex, atsHandle);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Set the parameter of the ATS script by ATS handle.
|
|
174
|
+
*
|
|
175
|
+
* @param atsHandle The handle of the ATS script.
|
|
176
|
+
* @param param The parameter to set.
|
|
177
|
+
*/
|
|
178
|
+
atsSetParam(atsHandle, param) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const keys = Object.keys(param);
|
|
181
|
+
const values = [];
|
|
182
|
+
for (const key in param) {
|
|
183
|
+
values.push(param[key]);
|
|
184
|
+
}
|
|
185
|
+
yield GtcClient_1.GtcClient.atsSetParam(this.instId, this.serviceType, this.ctrlIndex, atsHandle, keys, values);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
156
188
|
}
|
|
157
189
|
exports.MPlay = MPlay;
|