44 lines
983 B
TypeScript
44 lines
983 B
TypeScript
|
|
|
||
|
|
// 中心信号转换
|
||
|
|
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 ''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 当前考车中心状态转换
|
||
|
|
export function getCarStatusType (carzt){
|
||
|
|
switch (carzt){
|
||
|
|
case -1:return [1,0]
|
||
|
|
case 0: return [0,0]
|
||
|
|
case 1: return [0,1]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// 中心实时项目状态转换
|
||
|
|
export function getCenterProjectStatus = (status) => {
|
||
|
|
switch (status){
|
||
|
|
//不考
|
||
|
|
case 0:return '00'
|
||
|
|
//未考
|
||
|
|
case 1:return '01'
|
||
|
|
//已考
|
||
|
|
case 2:return '10'
|
||
|
|
}
|
||
|
|
}
|