|
@@ -132,10 +132,35 @@ function init() {
|
|
|
})
|
|
|
// 新策略-返回机器人状态
|
|
|
app.get('/predictorState', (req, res) => {
|
|
|
+ // const param = req.query;
|
|
|
+ // logger.info(JSON.stringify(param));
|
|
|
+ // let data = robot.predictorState(param)
|
|
|
+ // res.send(data);
|
|
|
+
|
|
|
const param = req.query;
|
|
|
- logger.info(JSON.stringify(param));
|
|
|
- let data = robot.predictorState(param)
|
|
|
- res.send(data);
|
|
|
+ const id = param.id
|
|
|
+
|
|
|
+ var port = -1;
|
|
|
+ robot.appMap.forEach((value, key) => {
|
|
|
+ // logger.info(JSON.stringify(value))
|
|
|
+ if (value.id + "" === id + "") {
|
|
|
+ port = value.port
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ var accUrl = "http://127.0.0.1:" + port
|
|
|
+ var config = getRustConfig()
|
|
|
+ logger.info(`#####################开始:`)
|
|
|
+ http.request_get(`${accUrl}/predictor_state`, {...config.headers})
|
|
|
+ .then((data) => {
|
|
|
+ logger.info(`#####################返回数据:`,data)
|
|
|
+ res.send({'code': 200, 'data': data, "message": "SUCCESS"});
|
|
|
+ }).catch((error) => {
|
|
|
+ // 处理可能发生的错误
|
|
|
+ logger.info(`#####################汇报:获取状态请求失败: ${error.message}`)
|
|
|
+ res.send({'code': -1, 'data': null, "message": `获取状态请求失败${error.message}`});
|
|
|
+ });
|
|
|
+ logger.info(`#####################最后:`)
|
|
|
})
|
|
|
// 使服务器监听特定端口
|
|
|
app.listen(port, () => {
|