Skip to content

Commit

Permalink
feat(error code): add some error codes about EtherNet/IP
Browse files Browse the repository at this point in the history
  • Loading branch information
orangegzx authored and Kinplemelon committed Nov 29, 2022
1 parent b502f7d commit ec0242e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/i18n/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,17 @@ export default {
zh: 'Opcua tag 不可写',
en: 'Opcua tag is not writable',
},
// 10701 - 10744
10701: {
zh: 'EtherNet/IP 错误',
en: 'EtherNet/IP error',
},
10798: {
zh: 'EtherNet/IP 数据类型不匹配',
en: 'EtherNet/IP data type mismatch',
},
10799: {
zh: 'EtherNet/IP 未注册session',
en: 'EtherNet/IP no session',
},
}
5 changes: 4 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const ERROR_CODE_ARR = [
2207, 2208, 2209, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 3000,
3001, 3002, 3003, 3004, 3007, 3008, 3009, 3010, 3011, 3012, 10101, 10103, 10105, 10106, 10107, 10110, 10150, 10151,
10200, 10400, 10500, 10501, 10502, 10503, 10504, 10505, 10506, 10507, 10508, 10509, 10510, 10511, 10512, 10513, 10514,
10515, 10516, 10517, 10001, 10002, 10003, 10004, 10005,
10515, 10516, 10517, 10001, 10002, 10003, 10004, 10005, 10701, 10702, 10703, 10704, 10705, 10706, 10707, 10708, 10709,
10710, 10711, 10712, 10713, 10714, 10715, 10716, 10717, 10718, 10719, 10720, 10721, 10722, 10723, 10724, 10725, 10726,
10727, 10728, 10729, 10730, 10731, 10732, 10733, 10734, 10735, 10736, 10737, 10738, 10739, 10740, 10741, 10742, 10743,
10744, 10744, 10798, 10799,
]

export const FILLER_IN_TAG_ATTR = ' '
Expand Down
11 changes: 10 additions & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ export const matchObjShape = (obj: Record<string, any>, templateObj: Record<stri

export const getErrorMsg = (errorCode: number): string => {
const hasErrorMsg = ERROR_CODE_ARR.includes(errorCode)
return hasErrorMsg ? i18n.global.t(`error.${errorCode}`) : 'unknown'
if (!hasErrorMsg) {
return 'unknown'
}

// 10701 - 10744
if (errorCode >= 10701 && errorCode <= 10744) {
return i18n.global.t(`error.10701`)
}

return i18n.global.t(`error.${errorCode}`)
}

export const exportExcelData = (content: Array<any>, fileName: string) => {
Expand Down

0 comments on commit ec0242e

Please sign in to comment.