优化转发mes的device_code接口代码
This commit is contained in:
@@ -13,6 +13,13 @@ class EDataCapture {
|
||||
protected $working_subclass = NULL,
|
||||
protected $code_type = [],
|
||||
protected $data = [],
|
||||
protected $status = array(
|
||||
1 => 'IDLE',
|
||||
2 => 'RUN',
|
||||
3 => 'FINISH',
|
||||
4 => 'TROUBLE',
|
||||
5 => 'PAUSE',
|
||||
6 => 'OFFLINE')
|
||||
) {
|
||||
if (!is_null($this -> post)) {
|
||||
if(isset($this -> post -> param -> working_subclass)){
|
||||
@@ -60,8 +67,7 @@ class EDataCapture {
|
||||
return;
|
||||
}
|
||||
if($this -> relay_device_status && $code_type[$row -> code]['category'] === 'DEVICE_STATUS'){
|
||||
$status = array(1 => 'IDLE', 2 => 'RUN', 3 => 'FINISH', 4 => 'TROUBLE', 5 => 'PAUSE', 6 => 'OFFLINE');
|
||||
if(!is_int($row -> value) && !in_array($row -> value , $status)){
|
||||
if(!is_int($row -> value) && !in_array($row -> value , $this->status)){
|
||||
$this -> check_res = 'MISMATCH_TYPE';
|
||||
return;
|
||||
}
|
||||
@@ -69,12 +75,12 @@ class EDataCapture {
|
||||
'action' => 'set_device_status',
|
||||
'param' => array(
|
||||
"device_code" => $row -> parent_device_code,
|
||||
"status" => is_int($row -> value) ? $status[$row -> value] : $row -> value,
|
||||
"status" => is_int($row -> value) ? $this->status[$row -> value] : $row -> value,
|
||||
"errcode" => $row -> errcode ?? NULL,
|
||||
"msg" => $row -> msg ?? NULL,
|
||||
),
|
||||
);
|
||||
$task_connection = new AsyncTcpConnection('Text://127.0.0.1:19998');
|
||||
$task_connection = new AsyncTcpConnection('Text://127.0.0.1:1888');
|
||||
|
||||
$task_connection -> send(json_encode($task_data));
|
||||
$task_connection -> onMessage = function(AsyncTcpConnection $task_connection, $task_result){
|
||||
|
||||
Reference in New Issue
Block a user