数据立方体模拟
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

119 lines
2.8 KiB

import { useStore } from 'vuex';
import { warning } from '@/config/element';
const store = useStore();
export const fddFreqs = [
[
//B38/41
[37750, 38249],
[39650, 41589],
],
[
//B39/34
[38250, 38649],
[36200, 36349],
],
[
//B40
[38650, 39649],
],
];
export function repeat(arr) {
arr = JSON.parse(JSON.stringify(arr));
arr.sort();
for (let i = 1; i < arr.length; i++) {
if (arr[i - 1] == arr[i]) {
return true;
}
}
return false;
}
export function getIndex(freq) {
freq = parseInt(freq);
for (let i = 0; i < fddFreqs.length; i++) {
for (let j = 0; j < fddFreqs[i].length; j++) {
const arr = fddFreqs[i][j];
if (arr[0] <= freq && freq <= arr[1]) {
return i;
}
}
}
return -1;
}
export function getUsedFreqs(device) {
const arr: number[] = [];
store.state.devCode.forEach((item) => {
if (item.deviceId != device.deviceId && item.sModType == 'TDD') {
const freqs = [item.devFreq].concat(item.defaultFreq.split(','));
for (let i = 0; i < freqs.length; i++) {
const freq = freqs[i];
const index = getIndex(freq);
if (index > -1) {
arr.push(index);
}
}
}
});
return arr;
}
export function enable(device, freq) {
let enable = false;
freq = parseInt(freq);
const freqs = device.uarfcnband.split(',');
for (let i = 0; i < freqs.length; i++) {
const arr = freqs[i].split('-');
if (freq >= parseInt(arr[0]) && freq <= parseInt(arr[1])) {
enable = true;
break;
}
}
return enable;
}
export function checkFreq(device, freq) {
if (!enable(device, freq)) {
warning('配置的频点不在可配范围内,请确认后重新配置');
return false;
}
if (device.sModType != 'TDD') {
return true;
}
const arr = getUsedFreqs(device);
const index = getIndex(freq);
if (index > -1 && arr.indexOf(index) > -1) {
warning('频点不能配置在其他TDD模块已配置频段内');
return false;
}
return true;
}
export function checkFreqs(device, freqs) {
if (repeat(freqs)) {
warning('轮询频点不可重复,请确认后重新配置');
return false;
}
const arr = getUsedFreqs(device);
for (let i = 0; i < freqs.length; i++) {
if (!enable(device, freqs[i])) {
warning('第' + (i + 1) + '个轮询频点不在可配范围内,请确认后重新配置');
return false;
}
const index = getIndex(freqs[i]);
if (index > -1 && arr.indexOf(index) > -1) {
warning('第' + (i + 1) + '个轮询频点不能配置在其他TDD模块已配置频段内');
return false;
}
}
return true;
}
export function checkCycle(device) {
if (device.freqSwitchCycle < 10 || device.freqSwitchCycle > 120) {
warning('轮询周期必须为10-120之间的整数!');
return false;
}
return true;
}