增加node节点状态类型转发至MES接口&relay_device_status模 式,控制是否转发

This commit is contained in:
wu
2022-08-31 17:51:14 +08:00
parent e7ce0403f1
commit d169ba986d
3 changed files with 76 additions and 7 deletions

View File

@@ -9,13 +9,14 @@ require_once __DIR__ . '/vendor/autoload.php';
use EdgeManager\EDataCapture\{ EDataCapture, ENodeConfigure };
use EdgeManager\EController\{ EConfigure, ECommand };
$options = getopt('h::', ['no_dup_code', 'server_name:', 'port::', 'user:', 'password:', 'help::']);
$options = getopt('h::', ['no_dup_code', 'relay_device_status', 'server_name:', 'port::', 'user:', 'password:', 'help::']);
if (array_key_exists('h', $options) or array_key_exists('help', $options)) {
print_r(
"EdgeManager使用说明
--no_dup_code 禁止code在不同的working subclass间复用
--relay_device_status 不判断是否是设备状态并转发到MES接口
--server_name pg实例的FQDN
--user pg实例的用户名
--port pg实例的端口号
@@ -156,7 +157,7 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) {
}
}
} else if ($post -> action === 'set_node_data') {
$data_capture = new EDataCapture($dbconn, no_dup_code: $options['no_dup_code'] ?? true, post: $post);
$data_capture = new EDataCapture($dbconn, no_dup_code: $options['no_dup_code'] ?? true, relay_device_status: $options['relay_device_status'] ?? true, post: $post);
if ($data_capture -> check_res === 'WRONG_WORKING_SUBCLASS') {
$response = new Response(200, [
'Content-Type' => 'application/json;charset=utf-8',
@@ -406,6 +407,17 @@ $consumer -> onMessage = function(TcpConnection $connection, $task_data) {
'code' => 0,
'msg' => 'Success'
)));
} else if ($task_data -> action === 'set_device_status') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://8.sctmes.com:22347');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($task_data) );
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
curl_close($ch);
}
};