Commit 528d0460 authored by 高晓帆's avatar 高晓帆

change:softDrivingPattern

parent 38b61aba
cmake_minimum_required(VERSION 3.5)
project (TruckMonitorView)
set (CMAKE_CXX_STANDARD 11)
# Version.
set (MAJOR_VERSION "1")
set (MINOR_VERSION "1")
set (PATCH_VERSION "3")
# Import cmake modules.
list (APPEND CMAKE_MODULE_PATH "$ENV{HT_BUILDSYS_CMAKE_MODULES}")
include (HtCMakePub)
install_system_packages (
PACKAGES "nodejs"
)
add_custom_command (
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/dist"
COMMAND "npm" "install" "--force"
COMMAND "npm" "run" "build"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
add_custom_target ("${PROJECT_NAME}" ALL
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/dist"
)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist"
DESTINATION "/var/www/${PROJECT_NAME}"
)
# Pack.
set (CPACK_PACKAGE_NAME "ht-${PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set (CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set (CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set (CPACK_PACKAGE_CONTACT "Fan Jianping <jianping.fan@waytous.com>, Li Lingyan <lingyan.li@waytous.com>, Gao Xiaofan <xiaofan.gao@waytous.com>")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION "webtruckview. Branch: ${GIT_BRANCH}. Commit: ${GIT_LAST_COMMIT}.")
include(HtCMakeDeb)
cmake_minimum_required(VERSION 3.5)
project (TruckMonitorView)
set (CMAKE_CXX_STANDARD 11)
# Version.
set (MAJOR_VERSION "2")
set (MINOR_VERSION "1")
set (PATCH_VERSION "1")
# Import cmake modules.
list (APPEND CMAKE_MODULE_PATH "$ENV{HT_BUILDSYS_CMAKE_MODULES}")
include (HtCMakePub)
install_system_packages (
PACKAGES "nodejs"
)
add_custom_command (
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/dist"
COMMAND "npm" "install" "--force"
COMMAND "npm" "run" "build"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
add_custom_target ("${PROJECT_NAME}" ALL
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/dist"
)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist"
DESTINATION "/var/www/${PROJECT_NAME}"
)
# Pack.
set (CPACK_PACKAGE_NAME "ht-${PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set (CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set (CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set (CPACK_PACKAGE_CONTACT "Fan Jianping <jianping.fan@waytous.com>, Li Lingyan <lingyan.li@waytous.com>, Gao Xiaofan <xiaofan.gao@waytous.com>")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION "webtruckview. Branch: ${GIT_BRANCH}. Commit: ${GIT_LAST_COMMIT}.")
include(HtCMakeDeb)
{
"SERVICE_IP": "172.16.0.153:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.130:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.130:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.130:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.104:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.104:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.104:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.130:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.104:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.104:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "126.0.0.34:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "126.0.0.34:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "126.0.0.34:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "126.0.0.34:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.6.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.6.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "localhost:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:5173:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:5173:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:5173:11311",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:5173:51002",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:5173:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.20.20.11:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.20.20.15:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.20.20.15:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:45005",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:45005",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:11311",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "127.0.0.1:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.20.10.11:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.20.10.11:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.118:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
{
"SERVICE_IP": "172.16.0.114:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -146,6 +146,7 @@ export default class Socket {
}
this.timeoutTimer = setInterval(() => {
if (this.timeoutCount > NETWORK_COUNT) {
writeLog('WARNING', `网络异常,请检测网络!连接超时${this.timeoutCount}s`)
this.stateStore.dealNetworkTip({ type: true, count: this.timeoutCount })
}
this.timeoutCount++
......@@ -421,9 +422,10 @@ export default class Socket {
switch (type) {
// 车辆状态信息
case '/vehicle/statusinfo':
const { pattern, connStatus } = msg
const { pattern, softDrivingPattern, connStatus } = msg
this.stateStore.setData('wifi', connStatus)
this.vehicleStore.setData('pattern', pattern)
this.vehicleStore.setData('softDrivingPattern', softDrivingPattern)
this.vehicleStore.setData(name, msg)
break
// 车辆故障码信息
......
const VEHICLE_IMAGE = {
1: 'exca_planform',
20: 'exca_planform',
21: 'exca_planform',
2: 'dumpMachine',
30: 'dumpMachine',
31: 'dumpMachine',
3: 'manCar',
40: 'manCar',
41: 'wateringCar',
42: 'manCar',
43: 'grader'
}
function dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
const { enable, data } = safe
if (!enable) return
const safeType = [1, 20, 21].includes(vehicleType) ? 'circle' : 'rectangle'
const dealedData = []
for (let i = 0; i < data.length; i++) {
let item = data[i]
if (safeType === 'rectangle') {
let [lngs, lats] = item
let datas = []
lngs.forEach((item, index) => datas.push([lats[index], item]))
dealedData.push(datas)
}
}
safe = Object.assign({}, safe, {
dealedData,
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return safe
}
function dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
let {enable, data} = safe
let {enable: preEnable, data: preData} = preSafe
if (enable === preEnable && enable === false) return
if (enable === false) return safe
if (data.length !== preData.length) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
let isDiff = false
for (let i = 0; i < data.length; i++) {
let item = data[i]
let preItem = preData[i]
if (item.toString() != preItem.toString()) {
isDiff = true
break
}
}
if (isDiff) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude) {
if (!traj) return
let { trajPath, radius } = traj
// if ((!trajPath || !trajPath.length) && ![1, 20, 21].includes(vehicleType) && !radius) return
if([1, 20, 21].includes(vehicleType) && radius) return
if (![1, 20, 21].includes(vehicleType)) {
if(!trajPath || !trajPath.length) return;
let datas = []
trajPath.forEach(item => {
let [lon, lat] = item
datas.push([lat, lon])
})
traj['dealedData'] = datas
}
traj = Object.assign({}, traj, {
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return traj
}
function dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic) {
let {radius, trajPath} = traj
let {radius: preRadius, trajPath: preTrajPath} = preTraj
// if (preRadius === radius && radius === 0) return
if (!preTrajPath) return
if (preTrajPath.length === trajPath.length && trajPath.length === 0) return
if ([1, 20, 21].includes(vehicleType)) {
if (preBasic.vehicleLatitude == vehicleLatitude && preBasic.vehicleLongtitude == vehicleLongtitude && preRadius == radius) return
return traj
}
if (trajPath.toString() == preTrajPath.toString()) return
return dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealDiffBasic(preBasic, basic, deviceId) {
let {vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
if (vehicleID === deviceId) return false
let isSame = vehicleType === preBasic.vehicleType
&& vehicleLoad === preBasic.vehicleLoad
&& vehicleLatitude === preBasic.vehicleLatitude
&& vehicleLongtitude === preBasic.vehicleLongtitude
&& vehicleHeading === preBasic.vehicleHeading
return isSame
}
self.onmessage = function({data}) {
let gps = 4, currentBasic = null
try {
const {type, msg, deviceId, pre} = data
let safeObj = {}, trajObj = {}, vehicles = []
for (let i = 0; i < msg.length; i++) {
let item = msg[i]
const { basic, safe, traj } = item
const { vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
let image = null
if ([0, 11, 10, 15].includes(vehicleType)) {
image = vehicleLoad > 10 ? 'heavyTruck1' : 'emptyTruck1'
} else {
image = VEHICLE_IMAGE[vehicleType]
}
basic['image'] = image
let preVehicle = pre.find(p => p.basic.vehicleID === vehicleID)
let isSame = false, safeResult, trajResult
if (preVehicle) {
let {basic: preBasic, safe: preSafe, traj: preTraj} = preVehicle
safeResult = dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude,)
trajResult = dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic)
isSame = dealDiffBasic(preBasic, basic, deviceId)
} else {
safeResult = dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
trajResult = dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
isSame = false
}
if (safeResult) safeObj[vehicleID] = safeResult
if (trajResult) trajObj[vehicleID] = trajResult
if (!isSame) vehicles.push(basic)
if (vehicleID === deviceId) {
gps = basic.gps
currentBasic = basic
}
}
self.postMessage({type, vehicles, safeObj, trajObj, gps, currentBasic})
data = null
currentBasic = null
safeObj = {}
trajObj = {}
vehicles = []
} catch(err) {
console.log(err)
}
}
\ No newline at end of file
const VEHICLE_IMAGE = {
1: 'exca_planform',
20: 'exca_planform',
21: 'exca_planform',
2: 'dumpMachine',
30: 'dumpMachine',
31: 'dumpMachine',
3: 'manCar',
40: 'manCar',
41: 'wateringCar',
42: 'manCar',
43: 'grader'
}
function dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
const { enable, data } = safe
if (!enable) return
const safeType = [1, 20, 21].includes(vehicleType) ? 'circle' : 'rectangle'
const dealedData = []
for (let i = 0; i < data.length; i++) {
let item = data[i]
if (safeType === 'rectangle') {
let [lngs, lats] = item
let datas = []
lngs.forEach((item, index) => datas.push([lats[index], item]))
dealedData.push(datas)
}
}
safe = Object.assign({}, safe, {
dealedData,
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return safe
}
function dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
let {enable, data} = safe
let {enable: preEnable, data: preData} = preSafe
if (enable === preEnable && enable === false) return
if (enable === false) return safe
if (data.length !== preData.length) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
let isDiff = false
for (let i = 0; i < data.length; i++) {
let item = data[i]
let preItem = preData[i]
if (item.toString() != preItem.toString()) {
isDiff = true
break
}
}
if (isDiff) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude) {
if (!traj) return
let { trajPath, radius } = traj
// if ((!trajPath || !trajPath.length) && ![1, 20, 21].includes(vehicleType) && !radius) return
if([1, 20, 21].includes(vehicleType) && radius) return
if (![1, 20, 21].includes(vehicleType)) {
if(!trajPath || !trajPath.length) return;
let datas = []
trajPath.forEach(item => {
let [lon, lat] = item
datas.push([lat, lon])
})
traj['dealedData'] = datas
}
traj = Object.assign({}, traj, {
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return traj
}
function dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic) {
let {radius, trajPath} = traj
let {radius: preRadius, trajPath: preTrajPath} = preTraj
// if (preRadius === radius && radius === 0) return
// if (!preTrajPath) return
// if (preTrajPath.length === trajPath.length && trajPath.length === 0) return
if ([1, 20, 21].includes(vehicleType)) {
if (preBasic.vehicleLatitude == vehicleLatitude && preBasic.vehicleLongtitude == vehicleLongtitude && preRadius == radius) return
return traj
}
if (trajPath.toString() == preTrajPath.toString()) return
return dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealDiffBasic(preBasic, basic, deviceId) {
let {vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
if (vehicleID === deviceId) return false
let isSame = vehicleType === preBasic.vehicleType
&& vehicleLoad === preBasic.vehicleLoad
&& vehicleLatitude === preBasic.vehicleLatitude
&& vehicleLongtitude === preBasic.vehicleLongtitude
&& vehicleHeading === preBasic.vehicleHeading
return isSame
}
self.onmessage = function({data}) {
let gps = 4, currentBasic = null
try {
const {type, msg, deviceId, pre} = data
let safeObj = {}, trajObj = {}, vehicles = []
for (let i = 0; i < msg.length; i++) {
let item = msg[i]
const { basic, safe, traj } = item
const { vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
let image = null
if ([0, 11, 10, 15].includes(vehicleType)) {
image = vehicleLoad > 10 ? 'heavyTruck1' : 'emptyTruck1'
} else {
image = VEHICLE_IMAGE[vehicleType]
}
basic['image'] = image
let preVehicle = pre.find(p => p.basic.vehicleID === vehicleID)
let isSame = false, safeResult, trajResult
if (preVehicle) {
let {basic: preBasic, safe: preSafe, traj: preTraj} = preVehicle
safeResult = dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude,)
trajResult = dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic)
isSame = dealDiffBasic(preBasic, basic, deviceId)
} else {
safeResult = dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
trajResult = dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
isSame = false
}
if (safeResult) safeObj[vehicleID] = safeResult
if (trajResult) trajObj[vehicleID] = trajResult
if (!isSame) vehicles.push(basic)
if (vehicleID === deviceId) {
gps = basic.gps
currentBasic = basic
}
}
self.postMessage({type, vehicles, safeObj, trajObj, gps, currentBasic})
data = null
currentBasic = null
safeObj = {}
trajObj = {}
vehicles = []
} catch(err) {
console.log(err)
}
}
\ No newline at end of file
const VEHICLE_IMAGE = {
1: 'exca_planform',
20: 'exca_planform',
21: 'exca_planform',
2: 'dumpMachine',
30: 'dumpMachine',
31: 'dumpMachine',
3: 'manCar',
40: 'manCar',
41: 'wateringCar',
42: 'manCar',
43: 'grader'
}
function dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
const { enable, data } = safe
if (!enable) return
const safeType = [1, 20, 21].includes(vehicleType) ? 'circle' : 'rectangle'
const dealedData = []
for (let i = 0; i < data.length; i++) {
let item = data[i]
if (safeType === 'rectangle') {
let [lngs, lats] = item
let datas = []
lngs.forEach((item, index) => datas.push([lats[index], item]))
dealedData.push(datas)
}
}
safe = Object.assign({}, safe, {
dealedData,
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return safe
}
function dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
let {enable, data} = safe
let {enable: preEnable, data: preData} = preSafe
if (enable === preEnable && enable === false) return
if (enable === false) return safe
if (data.length !== preData.length) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
let isDiff = false
for (let i = 0; i < data.length; i++) {
let item = data[i]
let preItem = preData[i]
if (item.toString() != preItem.toString()) {
isDiff = true
break
}
}
if (isDiff) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude) {
if (!traj) return
let { trajPath, radius } = traj
// if ((!trajPath || !trajPath.length) && ![1, 20, 21].includes(vehicleType) && !radius) return
if([1, 20, 21].includes(vehicleType) && radius) return
if (![1, 20, 21].includes(vehicleType)) {
if(!trajPath || !trajPath.length) return;
let datas = []
trajPath.forEach(item => {
let [lon, lat] = item
datas.push([lat, lon])
})
traj['dealedData'] = datas
}
traj = Object.assign({}, traj, {
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return traj
}
function dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic) {
let {radius, trajPath} = traj
let {radius: preRadius, trajPath: preTrajPath} = preTraj
// if (preRadius === radius && radius === 0) return
if (!preTrajPath) return
if (preTrajPath.length === trajPath.length && trajPath.length === 0) return
if ([1, 20, 21].includes(vehicleType)) {
if (preBasic.vehicleLatitude == vehicleLatitude && preBasic.vehicleLongtitude == vehicleLongtitude && preRadius == radius) return
return traj
}
if (trajPath.toString() == preTrajPath.toString()) return
return dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealDiffBasic(preBasic, basic, deviceId) {
let {vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
if (vehicleID === deviceId) return false
let isSame = vehicleType === preBasic.vehicleType
&& vehicleLoad === preBasic.vehicleLoad
&& vehicleLatitude === preBasic.vehicleLatitude
&& vehicleLongtitude === preBasic.vehicleLongtitude
&& vehicleHeading === preBasic.vehicleHeading
return isSame
}
self.onmessage = function({data}) {
let gps = 4, currentBasic = null
try {
const {type, msg, deviceId, pre} = data
let safeObj = {}, trajObj = {}, vehicles = []
for (let i = 0; i < msg.length; i++) {
let item = msg[i]
const { basic, safe, traj } = item
const { vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
let image = null
if ([0, 11, 10, 15].includes(vehicleType)) {
image = vehicleLoad > 10 ? 'heavyTruck1' : 'emptyTruck1'
} else {
image = VEHICLE_IMAGE[vehicleType]
}
basic['image'] = image
let preVehicle = pre.find(p => p.basic.vehicleID === vehicleID)
let isSame = false, safeResult, trajResult
if (preVehicle) {
let {basic: preBasic, safe: preSafe, traj: preTraj} = preVehicle
safeResult = dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude,)
trajResult = dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic)
isSame = dealDiffBasic(preBasic, basic, deviceId)
} else {
safeResult = dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
trajResult = dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
isSame = false
}
if (safeResult) safeObj[vehicleID] = safeResult
if (trajResult) trajObj[vehicleID] = trajResult
if (!isSame) vehicles.push(basic)
if (vehicleID === deviceId) {
gps = basic.gps
currentBasic = basic
}
}
self.postMessage({type, vehicles, safeObj, trajObj, gps, currentBasic})
data = null
currentBasic = null
safeObj = {}
trajObj = {}
vehicles = []
} catch(err) {
console.log(err)
}
}
\ No newline at end of file
const VEHICLE_IMAGE = {
1: 'exca_planform',
20: 'exca_planform',
21: 'dianchan_planform',
2: 'dumpMachine',
30: 'dumpMachine',
31: 'dumpMachine',
3: 'manCar',
40: 'manCar',
41: 'wateringCar',
42: 'manCar',
43: 'grader'
}
function dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
const { enable, data } = safe
if (!enable) return
const safeType = [1, 20, 21].includes(vehicleType) ? 'circle' : 'rectangle'
const dealedData = []
for (let i = 0; i < data.length; i++) {
let item = data[i]
if (safeType === 'rectangle') {
let [lngs, lats] = item
let datas = []
lngs.forEach((item, index) => datas.push([lats[index], item]))
dealedData.push(datas)
}
}
safe = Object.assign({}, safe, {
dealedData,
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return safe
}
function dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
let {enable, data} = safe
let {enable: preEnable, data: preData} = preSafe
if (enable === preEnable && enable === false) return
if (enable === false) return safe
if (data.length !== preData.length) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
let isDiff = false
for (let i = 0; i < data.length; i++) {
let item = data[i]
let preItem = preData[i]
if (item.toString() != preItem.toString()) {
isDiff = true
break
}
}
if (isDiff) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude) {
if (!traj) return
let { trajPath, radius } = traj
// if ((!trajPath || !trajPath.length) && ![1, 20, 21].includes(vehicleType) && !radius) return
if([1, 20, 21].includes(vehicleType) && radius) return
if (![1, 20, 21].includes(vehicleType)) {
if(!trajPath || !trajPath.length) return;
let datas = []
trajPath.forEach(item => {
let [lon, lat] = item
datas.push([lat, lon])
})
traj['dealedData'] = datas
}
traj = Object.assign({}, traj, {
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return traj
}
function dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic) {
let {radius, trajPath} = traj
let {radius: preRadius, trajPath: preTrajPath} = preTraj
// if (preRadius === radius && radius === 0) return
if (!preTrajPath) return
if (preTrajPath.length === trajPath.length && trajPath.length === 0) return
if ([1, 20, 21].includes(vehicleType)) {
if (preBasic.vehicleLatitude == vehicleLatitude && preBasic.vehicleLongtitude == vehicleLongtitude && preRadius == radius) return
return traj
}
if (trajPath.toString() == preTrajPath.toString()) return
return dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealDiffBasic(preBasic, basic, deviceId) {
let {vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
if (vehicleID === deviceId) return false
let isSame = vehicleType === preBasic.vehicleType
&& vehicleLoad === preBasic.vehicleLoad
&& vehicleLatitude === preBasic.vehicleLatitude
&& vehicleLongtitude === preBasic.vehicleLongtitude
&& vehicleHeading === preBasic.vehicleHeading
return isSame
}
self.onmessage = function({data}) {
let gps = 4, currentBasic = null
try {
const {type, msg, deviceId, pre} = data
let safeObj = {}, trajObj = {}, vehicles = []
for (let i = 0; i < msg.length; i++) {
let item = msg[i]
const { basic, safe, traj } = item
const { vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
let image = null
if ([0, 11, 10, 15].includes(vehicleType)) {
image = vehicleLoad > 10 ? 'heavyTruck1' : 'emptyTruck1'
} else {
image = VEHICLE_IMAGE[vehicleType]
}
basic['image'] = image
let preVehicle = pre.find(p => p.basic.vehicleID === vehicleID)
let isSame = false, safeResult, trajResult
if (preVehicle) {
let {basic: preBasic, safe: preSafe, traj: preTraj} = preVehicle
safeResult = dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude,)
trajResult = dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic)
isSame = dealDiffBasic(preBasic, basic, deviceId)
} else {
safeResult = dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
trajResult = dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
isSame = false
}
if (safeResult) safeObj[vehicleID] = safeResult
if (trajResult) trajObj[vehicleID] = trajResult
if (!isSame) vehicles.push(basic)
if (vehicleID === deviceId) {
gps = basic.gps
currentBasic = basic
}
}
self.postMessage({type, vehicles, safeObj, trajObj, gps, currentBasic})
data = null
currentBasic = null
safeObj = {}
trajObj = {}
vehicles = []
} catch(err) {
console.log(err)
}
}
\ No newline at end of file
import axios from 'axios';
let loginForm=JSON.parse(window.localStorage.getItem(`${location.host}loginForm`))
const writeLog=(type,data)=>{
let log=type+' '+new Date().format('yyyy-MM-dd hh:mm:ss')+' '+loginForm.number+' '+location.host+' '+data
axios.post("//"+document.location.logServe+"/ht/api/web/log/upload",{log:log}).then(res=>{
if(res.code!=0){
console.log('writeLog',res.msg)
}
}).catch(err=>{
console.log('writeLog',err)
})
}
export default writeLog
\ No newline at end of file
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import IndexRoot from './js/IndexRoot.js'
import ViewUIPlus from 'view-ui-plus'
import 'leaflet/dist/leaflet.css'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import './assets/main.css'
window.state = null
/**
* usage:
* let x = new Date()
* x.format('yyyy-MM-dd hh:mm:ss')
*
* @method format
*
* @param {[type]} format [description]
*
* @return {[type]} [description]
*/
Date.prototype.format = function (format) { // eslint-disable-line
let o = {
'M+': this.getMonth() + 1, // month
'd+': this.getDate(), // day
'h+': this.getHours(), // hour
'm+': this.getMinutes(), // minute
's+': this.getSeconds(), // second
'q+': Math.floor((this.getMonth() + 3) / 3), // quarter
'S': this.getMilliseconds() // millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return format
}
const pinia = createPinia()
const app = createApp(App)
let $indexRoot = new IndexRoot()
app.config.globalProperties.$indexRoot = $indexRoot
app.use(router)
.use(ViewUIPlus)
.use(pinia)
function getSysConfig() {
return new Promise((resolve, reject) => {
axios.get('/config.json').then((result) => {
let config = result.data
resolve(config)
}).catch((error) => {
console.log(error)
reject()
})
})
}
async function init() {
const {SERVICE_IP, MAP_CENTER} = await getSysConfig()
document.location.serviceIP = SERVICE_IP
document.location.mapCenter = MAP_CENTER
}
init().then(() => app.mount('#app'))
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import IndexRoot from './js/IndexRoot.js'
import writeLog from './js/writeLog.js'
import ViewUIPlus from 'view-ui-plus'
import 'leaflet/dist/leaflet.css'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import './assets/main.css'
window.state = null
/**
* usage:
* let x = new Date()
* x.format('yyyy-MM-dd hh:mm:ss')
*
* @method format
*
* @param {[type]} format [description]
*
* @return {[type]} [description]
*/
Date.prototype.format = function (format) { // eslint-disable-line
let o = {
'M+': this.getMonth() + 1, // month
'd+': this.getDate(), // day
'h+': this.getHours(), // hour
'm+': this.getMinutes(), // minute
's+': this.getSeconds(), // second
'q+': Math.floor((this.getMonth() + 3) / 3), // quarter
'S': this.getMilliseconds() // millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return format
}
const pinia = createPinia()
const app = createApp(App)
let $indexRoot = new IndexRoot()
app.config.globalProperties.$indexRoot = $indexRoot
window.onerror=(message, source, lineno, colno, error)=>{
var data = {
message: message,
source: source,
lineno: lineno,
colno: colno,
error: error
};
writeLog('ERROR', JSON.stringify(data))
}
app.use(router)
.use(ViewUIPlus)
.use(pinia)
function getSysConfig() {
return new Promise((resolve, reject) => {
axios.get('/config.json').then((result) => {
let config = result.data
resolve(config)
}).catch((error) => {
console.log(error)
reject()
})
})
}
async function init() {
const {SERVICE_IP, MAP_CENTER} = await getSysConfig()
document.location.serviceIP = SERVICE_IP
document.location.mapCenter = MAP_CENTER
}
init().then(() => app.mount('#app'))
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment