Browse Source

对接血氧

master
lijunjie 3 years ago
parent
commit
6d8426eff0
  1. 41
      app/Http/Controllers/IndexController.php
  2. 21
      public/.htaccess
  3. 15
      public/script/http/index.js

41
app/Http/Controllers/IndexController.php

@ -34,13 +34,18 @@ class IndexController extends BaseController
if(!empty($data)){ if(!empty($data)){
$pelmaArr = str_split($data[0], 2); $pelmaArr = str_split($data[0], 2);
$vague = 2;
//格式化成二维数组 //格式化成二维数组
for ($i = 0; $i < 1024; $i++){ for ($i = 0; $i < 1024; $i++){
$datas2[intval($i / 32)][$i % 32] = hexdec($pelmaArr[$i]); $datas2[intval($i / 32)][$i % 32] = hexdec($pelmaArr[$i]);
} }
$vague = 0;
if ($vague > 0){
//模糊扩大
foreach ($datas2 as $key1 => $data){ foreach ($datas2 as $key1 => $data){
foreach ($data as $key2 => $datum){ foreach ($data as $key2 => $datum){
if (isset($datas2[$key1][$key2 - 1])){ if (isset($datas2[$key1][$key2 - 1])){
@ -72,6 +77,22 @@ class IndexController extends BaseController
} }
$key3 = $key3 + ($vague + 1); $key3 = $key3 + ($vague + 1);
} }
} else {
$chunk2 = $datas2;
// //直接扩大
// $expansion = 3;
// foreach ($datas2 as $key1 => $data){
// foreach ($data as $key2 => $datum){
// for ($i = 0; $i < $expansion; $i++) {
// for ($j = 0; $j < $expansion; $j++) {
// $chunk2[$key1 * $expansion + $i][$key2 * $expansion + $j] = $datum;
// }
// }
// }
// }
}
$chunk3 = []; $chunk3 = [];
foreach ($chunk2 as $key1 => $value) { foreach ($chunk2 as $key1 => $value) {
@ -79,7 +100,7 @@ class IndexController extends BaseController
$chunk3[] = [ $chunk3[] = [
$key2, $key2,
$key1, $key1,
$value2 / 10, $value2,
]; ];
} }
} }
@ -96,13 +117,18 @@ class IndexController extends BaseController
$foot_data = Redis::ZREVRANGEBYSCORE($foot_key, $timer_shaft, $timer_shaft - 60); $foot_data = Redis::ZREVRANGEBYSCORE($foot_key, $timer_shaft, $timer_shaft - 60);
} }
$foot = [];
if (!empty($foot_data)){ if (!empty($foot_data)){
$foot = $foot_data; $foot_data = $foot_data[0];
for ($i = 0; $i < strlen($foot_data) / 2; $i++) {
$foot[] = hexdec(substr($foot_data, $i * 2, 2));
}
} }
return [ return [
'pressure' => $chunk3 ?? '', 'pressure' => $chunk3 ?? '',
'foot' => [36.2, 80, 36.1, 75, 35.9, 79, 36.3, 80] 'foot' => $foot
// 'foot' => [36.2, 80, 36.1, 75, 35.9, 79, 36.3, 80]
]; ];
} }
@ -116,16 +142,17 @@ class IndexController extends BaseController
$time = time(); $time = time();
// echo Cache::get('pelma'); // echo Cache::get('pelma');
Log::info($req);
if ($req['type'] == 1){ if ($req['type'] == "0001"){
$pelma_key = "pelma:" . $req['device']; $pelma_key = "pelma:" . hexdec($req['device']);
//按时间添加 //按时间添加
Redis::zadd($pelma_key, $time, $req['send_data']); Redis::zadd($pelma_key, $time, $req['send_data']);
//删除过期 //删除过期
Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120)); Redis::ZREMRANGEBYSCORE($pelma_key, 0, ($time - 120));
} elseif ($req['type'] == 2) { } elseif ($req['type'] == "0002") {
$pelma_key = "foot"; $pelma_key = "foot";
//按时间添加 //按时间添加

21
public/.htaccess

@ -1,21 +0,0 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

15
public/script/http/index.js

@ -86,10 +86,10 @@ function pressure(dom, item) {
function generateData(theta, min, max) { function generateData(theta, min, max) {
let data = []; let data = [];
for (let i = 0; i <= 100; i++) { for (let i = 0; i <= 33; i++) {
xData.push(i); xData.push(i);
} }
for (let j = 0; j < 100; j++) { for (let j = 0; j < 33; j++) {
yData.push(j); yData.push(j);
} }
return data; return data;
@ -118,10 +118,15 @@ function pressure(dom, item) {
var mytime = myDate.toLocaleTimeString(); var mytime = myDate.toLocaleTimeString();
let original = mytime + ' '; let original = mytime + ' ';
pressure.forEach((elem, index) => { pressure.forEach((elem, index) => {
if (index > 600) { // if (index > 600) {
// // console.log(index)
//
// original += Math.trunc(elem[2] * 100) + ' '
// }
if (index > 300) {
// console.log(index) // console.log(index)
original += Math.trunc(elem[2] * 100) + ' ' original += Math.trunc(elem[2]) + ' '
} }
}) })
@ -161,7 +166,7 @@ function pressure(dom, item) {
visualMap: { visualMap: {
show: false, show: false,
min: 0, min: 0,
max: 30, max: 255,
calculable: true, calculable: true,
realtime: false, realtime: false,
inRange: { inRange: {

Loading…
Cancel
Save