Browse Source

first commit

webconsole 6 years ago
commit
18ad331d00

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.env
+composer.lock
+vendor/
+.data/

+ 15 - 0
Home/Lib/Action/IndexAction.class.php

@@ -0,0 +1,15 @@
+<?php
+
+
+
+class IndexAction extends Action {
+			
+
+
+ 
+	public  function index(  ){
+		echo 'hello world';
+	}
+	
+
+}

+ 181 - 0
Home/Lib/Class/Jytgps.php

@@ -0,0 +1,181 @@
+<?php
+namespace Jiaruan;
+
+class Jytgps {
+			
+
+
+ 
+	public static function str2bin( $text ){
+		if (!is_string($text)) 
+			return null;
+		$arr = explode(' ',$text);
+		$bin = '';
+		foreach($arr as $hex){
+			if(strlen($hex) == 2){
+				$bin .= chr( hexdec($hex) );
+			}
+		}
+		return $bin;
+	}
+	
+ 
+	public static function input( $buffer, $connection ){
+		$end = substr($buffer,-1);
+		if($end != '#'){
+			return 0;
+		}
+		return strlen($buffer);
+	}
+	
+ 
+	public static function encode( $value ){
+		echo 'encode:'.PHP_EOL;
+		var_dump($value);
+		
+		return $value['head_char'].$value['identify'].$value['version'].'Y'.$value['function_code'].$value['function_keyword'].$value['end_char'];
+		
+	}
+	
+ 
+	public static function decode( $buffer ){
+		$length = strlen($buffer);
+		$data = array();
+		$data['head_char'] = substr($buffer,0,1);
+		$data['identify'] = substr($buffer,1,2);
+		$data['version'] = substr($buffer,3,2);
+		$data['replay'] = substr($buffer,5,1);
+		$index = strpos($buffer,',')+1;
+		$data['device_id'] = substr($buffer,6,$index-1-6);
+		$re = substr($buffer,$index,1);
+		if($re == 'Y'){
+			$data['function_code'] = substr($buffer,$index+1,1);
+			$data['function_keyword'] = substr($buffer,$index+2,1);
+			$data['end_char'] = substr($buffer,$index+3,1);
+		}else{
+			$data['function_code'] = substr($buffer,$index,1);
+			$data['function_keyword'] = substr($buffer,$index+1,1);
+			$order_data = substr($buffer,$index+2,$length-1);
+			$data['order_data'] = $order_data;
+			$data['end_char'] = substr($buffer,-1);
+			//解析指令数据
+			/*
+			function_code(终端--功能类指令): A-上传状态类信息  B-上传定位类信息
+			function_keyword(功能项):
+			*/
+			$data['method'] = 'method000'.$data['function_code'];
+			$data['packet'] = $buffer;
+			if($data['function_code'] == 'B'&& $data['function_keyword'] == 'A'){
+				
+				$orders = explode('&',$order_data);
+				foreach ($orders as $order) {
+					if($order){
+						$code = substr($order,0,1);
+						//解析定位数据
+						if($code=='A'){
+							//A0732142233550011405829060520190600
+							//时分秒
+							$times = substr($order,1,2).':'.substr($order,3,2).':'.substr($order,5,2); 
+							//定位纠偏  纠偏公式   abcde.fghi    abc+de/60+fghi/600000
+							$lat1 = substr($order,7,4);
+							$lat2 = substr($order,11,4);
+							$lat_a = floor($lat1/100);
+							$lat_b = (($lat1 - $lat_a*100).'.'.$lat2 )/60;
+							$lat = $lat_a + $lat_b;
+		
+							$lng1 = substr($order,15,5);
+							$lng2 = substr($order,20,4);
+							$lng_a = floor($lng1/100);
+							$lng_b = (($lng1 - $lng_a*100).'.'.$lng2 )/60;
+							$lng = $lng_a + $lng_b;
+							$data['lat'] = $lat;
+							$data['lng'] = $lng;
+							/*
+								$lat_0 =  substr($order,7,4).'.'.substr($order,11,4);
+								$lng_0 =  substr($order,15,5).'.'.substr($order,20,4);
+								$data['lat_0'] = $lat_0;
+								$data['lng_0'] = $lng_0;
+								*/
+							$f = ord(substr($order,24,1));
+							$data['f'] = $f;
+							$data['type'] = 1;//1-表示取GPS坐标数据,2-表示取基站坐标
+							switch ($f) {
+								case 48://0x0011 0000 西经、南纬、定位
+								$data['ew']='W';
+								$data['ns']='S';
+								$data['location']=true;
+								break;
+								case 49://0x0011 0001 西经、南纬、非定位
+								$data['ew']='W';
+								$data['ns']='S';
+								$data['location']=false;
+								break;
+								case 50://0x0011 0010 西经、北纬、定位
+								$data['ew']='W';
+								$data['ns']='N';
+								$data['location']=true;
+								break;
+								case 51://0x0011 0011 西经、北纬、非定位
+								$data['ew']='W';
+								$data['ns']='N';
+								$data['location']=false;
+								break;
+								case 52://0x0011 0100 东经、南纬、定位
+								$data['ew']='E';
+								$data['ns']='S';
+								$data['location']=true;
+								break;
+								case 53://0x0011 0101东经、南纬、非定位
+								$data['ew']='E';
+								$data['ns']='S';
+								$data['location']=false;
+								break;
+								case 54://0x0011 0110东经、北纬、定位
+								$data['ew']='E';
+								$data['ns']='N';
+								$data['location']=true;
+								break;
+								case 55://0x0011 0111 东经、北纬、非定位
+								$data['ew']='E';
+								$data['ns']='N';
+								$data['location']=false;
+								break;
+								case 63://0x0011 1111 表示设备直接调用第三方的基站位置解析接口成经纬度信息上传,该标志位用来区分正常的GPS 定位经纬度信息
+								$data['ew']=null;
+								$data['ns']=null;
+								$data['type']=2;
+								break;
+		
+								default:
+								break;
+							}
+		
+							$data['speed'] = substr($order,25,2);
+							$data['direction'] = substr($order,27,2);
+							$dates = '20'.substr($order,33,2).'-'.substr($order,31,2).'-'.substr($order,29,2); //年月日
+							$data['device_time'] = $dates.' '.$times;
+						}
+					}
+				}
+				
+		
+			}
+		}
+		
+		return $data;
+	}
+	
+ 
+	public static function bin2str( $hex, $space ){
+		$data = unpack("C*chars",$hex);
+		$bin = '';
+		foreach($data as $key=>$value){
+			$bin .= sprintf('%02X',$value);
+			if($space)
+				$bin .= ' ';
+		}
+		return trim($bin);
+	}
+	
+
+}

+ 0 - 0
changelog.md


+ 13 - 0
composer.json

@@ -0,0 +1,13 @@
+{
+    "name": "rlfd/proto",
+    "type": "library",
+	"repositories": [
+		{ "type": "composer", "url": "http://satis.jrcad.com/" }
+    ],
+    "require": {
+        "php": ">=5.6.0"
+    },
+	"config": {
+		"secure-http": false
+	}
+}

BIN
doc/AM-3云平台通讯协议_1015(嘉为GPS).docx


BIN
doc/Tracker 标准车载定位器通讯协议V2.0.1.0815(简易通GPS).docx


BIN
doc/任联基站RFID数据上报协议 V1.0.doc


BIN
doc/任联基站管理接口文档2.2.doc


BIN
doc/猎狐基站协议F6(宁波新然).docx


BIN
doc/猎狐基站接入协议(433+920).docx


BIN
doc/简易通GPS定位管理方案.pdf


+ 7 - 0
index.php

@@ -0,0 +1,7 @@
+<?php
+define('SCRIPT_FILENAME', __FILE__);
+define('SOLUTION_PATH',__DIR__ .'/');
+define('ENTRY_PATH',__DIR__ .'/');
+require __DIR__ . '/stub.php';
+require 'vendor/autoload.php';
+require 'vendor/elvisszhang/php-tp313/ThinkPHP.php';

+ 9 - 0
stub.php

@@ -0,0 +1,9 @@
+<?php
+//插件或者工程ID
+define('APP_ID','b4b2acadb2a1a6a66fc0bde8cf292073');
+//插件前缀
+define('APP_PREFIX','txxy');
+//插件版本
+define('APP_VERSION','1.2.8');
+//入口文件路径
+define('APP_FILENAME', __FILE__);