77 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-01-31 14:35:16 +08:00
import {string2Bytes,Array2Byte} from '../../../common/utils/tools'
import {testMarkRules} from '../dataTest/index'
//获取本地扣分项
export const getTestMarkRules = () =>{
testMarkRules.map((mark:any) => {
return {
itemno:mark.itemno*1,
markcatalog:mark.markcatalog,
markshow:mark.markshow,
markreal:mark.markreal*1,
markserial:mark.markserial,
kfxh:mark.kfxh
}
})
}
2024-01-05 11:11:15 +08:00
// 中心信号转换
export const getTranslateSignals = (tempItems) => {
const len = Math.floor(tempItems.length / 8);
const arr = [];
for(let i = 0;i < len;i++){
const temp = tempItems.slice( i*8 , (i+1)*8 );
arr.push(temp.join(''));
}
const temp = arr.map(numStr => parseInt(numStr,2))
return temp.map(item => string2Bytes(item , 8)[0])
}
// 当前考车行驶状态转换
export function getCarStatus(status: -1 | 0 | 1):string {
switch (status){
case -1:return '后退'
case 0:return '停车'
case 1:return '前进'
default :return ''
}
}
// 当前考车中心状态转换
2024-01-31 14:35:16 +08:00
export function getCarStatusType(carzt){
2024-01-05 11:11:15 +08:00
switch (carzt){
case -1:return [1,0]
case 0: return [0,0]
case 1: return [0,1]
}
}
// 中心实时项目状态转换
2024-01-31 14:35:16 +08:00
export function getCenterProjectStatus(status){
2024-01-05 11:11:15 +08:00
switch (status){
//不考
case 0:return '00'
//未考
case 1:return '01'
//已考
case 2:return '10'
}
2024-01-31 14:35:16 +08:00
}
export function sendBlue(){
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
const arrBlueBuffer= Array2Byte(arrBlue).buffer
globalThis.lightLineUdp.send(arrBlueBuffer);
}
export function sendGreen(){
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
const arrGreenBuffer= Array2Byte(arrGreen).buffer
globalThis.lightLineUdp.send(arrGreenBuffer);
}
export function sendRed(){
const arrRed= [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
const arrRedBuffer= Array2Byte(arrRed).buffer
globalThis.lightLineUdp.send(arrRedBuffer);
2024-01-05 11:11:15 +08:00
}