almost done.
This commit is contained in:
@@ -12,11 +12,13 @@ const validationMessages = {
|
||||
pointedLoad: 'مقدار بار متمرکز را وارد کنید',
|
||||
distributedLoad: 'مقدار بار گسترده را وارد کنید',
|
||||
bearingBarThickness: 'ضخامت تسمه باربر را وارد کنید',
|
||||
crossBarThickness: 'ضخامت تسمه رابط را وارد کنید',
|
||||
bearingBarPitch: 'گام تسمه باربر را انتخاب کنید',
|
||||
bearingBarPitch_not_ok: 'مقدار گام تسمه باربر صحیح نیست',
|
||||
crossBarPitch: 'گام تسمه رابط را تنخاب کنید',
|
||||
crossBarPitch_not_ok: 'مقدار گام تسمه رابط صحیح نیست',
|
||||
bearingBarHeight: 'ارتفاع تسمه باربر را انتخاب کنید',
|
||||
crossBarHeight: 'ارتفاع تسمه رابط را وارد کنید',
|
||||
bearingBarHeight_not_ok: 'مقدار ارتفاع تسمه باربر صحیح نیست',
|
||||
clearSpan: 'مقدار دهنه را وارد کنید',
|
||||
sigma_ok: 'تنش مجاز',
|
||||
@@ -34,11 +36,13 @@ const validationMessages = {
|
||||
pointedLoad: 'Enter the amount of pointed load',
|
||||
distributedLoad: 'Enter the amount of distributed load',
|
||||
bearingBarThickness: 'Enter bearing bar thickness',
|
||||
crossBarThickness: 'Enter cross bar thickness',
|
||||
bearingBarPitch: 'Select bearing bar pitch',
|
||||
bearingBarPitch_not_ok: 'Bearing bar pitch value is incorrect',
|
||||
crossBarPitch: 'Select cross bar pitch',
|
||||
crossBarPitch_not_ok: 'Cross bar pitch value is incorrect',
|
||||
bearingBarHeight: 'Select bearing bar height',
|
||||
crossBarHeight: 'Enter cross bar height',
|
||||
bearingBarHeight_not_ok: 'Bearing bar height is incorrect',
|
||||
clearSpan: 'Enter clear span',
|
||||
sigma_ok: 'Tension OK',
|
||||
@@ -213,7 +217,33 @@ module.exports.calculate = [
|
||||
.bail()
|
||||
.isNumeric().withMessage((value, {req}) => {
|
||||
return v_m[req.body.locale].format.number
|
||||
}),
|
||||
|
||||
|
||||
//////////////////////////// cross bar height and thickness
|
||||
body('crossBarThickness')
|
||||
.custom((value, {req}) => {
|
||||
if (req.body.gratingType === 'pressured' && !value) return Promise.reject(validationMessages[req.body.locale].crossBarThickness)
|
||||
else return true
|
||||
})
|
||||
.bail()
|
||||
.if((value, {req}) => req.body.gratingType === 'pressured')
|
||||
.isNumeric().withMessage((value, {req}) => {
|
||||
return v_m[req.body.locale].format.number
|
||||
}),
|
||||
|
||||
body('crossBarHeight')
|
||||
.custom((value, {req}) => {
|
||||
if (req.body.gratingType === 'pressured' && !value) return Promise.reject(validationMessages[req.body.locale].crossBarHeight)
|
||||
else return true
|
||||
})
|
||||
.bail()
|
||||
.if((value, {req}) => req.body.gratingType === 'pressured')
|
||||
.isNumeric().withMessage((value, {req}) => {
|
||||
return v_m[req.body.locale].format.number
|
||||
})
|
||||
|
||||
|
||||
],
|
||||
(req, res) => {
|
||||
const errors = validationResult(req)
|
||||
@@ -225,7 +255,9 @@ module.exports.calculate = [
|
||||
let vehicleClass = req.body.vehicleClass
|
||||
|
||||
let bearingBarHeight = req.body.bearingBarHeight
|
||||
let crossBarHeight = req.body.crossBarHeight
|
||||
let bearingBarThickness = req.body.bearingBarThickness
|
||||
let crossBarThickness = req.body.crossBarThickness
|
||||
let bearingBarPitch = req.body.bearingBarPitch
|
||||
let crossBarPitch = req.body.crossBarPitch
|
||||
let clearSpan = req.body.clearSpan
|
||||
@@ -284,6 +316,220 @@ module.exports.calculate = [
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
///////// grating weight
|
||||
const gratingLength = 1000
|
||||
const gratingWidth = 1000
|
||||
const frameThickness = 5
|
||||
const forgeCrossBarThickness = 6
|
||||
|
||||
///////////////// api
|
||||
|
||||
|
||||
function forgeWeight() {
|
||||
// formula variables
|
||||
const B2 = gratingLength
|
||||
const B3 = gratingWidth
|
||||
const B4 = bearingBarHeight
|
||||
const B5 = bearingBarThickness
|
||||
const B6 = forgeCrossBarThickness
|
||||
const B7 = bearingBarPitch
|
||||
const B8 = crossBarPitch
|
||||
const B9 = frameThickness
|
||||
//
|
||||
const E2 = B2 - 2 * B9
|
||||
const E3 = B3
|
||||
const E4 = B2 - 2 * B9
|
||||
const E5 = B3
|
||||
//
|
||||
const H2 = 0
|
||||
const H3 = 2
|
||||
const H4 = E5 / B7 + 1
|
||||
const H5 = E4 / B8 - 1
|
||||
const H6 = E4 * B4 * B5 / 1000000 * 7.85 * H4
|
||||
const H7 = (E5 / 1000) * B6 * B6 * 7.85 / 1000 * H5
|
||||
const H8 = E2 * B9 * B4 / 1000000 * H2 * 7.85 + E3 * B4 * B9 / 1000000 * 7.85 * H3
|
||||
const H9 = (1750 * (25.25 / (B4 * B5)))
|
||||
|
||||
//
|
||||
const E6 = H6 + H7 + H8
|
||||
//
|
||||
const K2 = E2 * (2 * (B4 + B5)) * H2 / 1000000
|
||||
const K3 = E3 * (2 * (B4 + B5)) * H3 / 1000000
|
||||
const K4 = E4 * (2 * (B4 + B5)) * H4 / 1000000
|
||||
const K5 = E5 * B6 * B6 * H5 / 1000000
|
||||
const K6 = K2 + K5
|
||||
const K7 = 80
|
||||
const K8 = K6 * K7 / 1000000 * 7140
|
||||
const K9 = K8 / E6 * 100
|
||||
//
|
||||
const E7 = K9 / 100 * E6
|
||||
const E8 = E6 + E7
|
||||
//
|
||||
const H10 = E8 / ((B2 * B3) / 1000000)
|
||||
|
||||
return {
|
||||
normal: Number(E6.toFixed(2)),
|
||||
galvanized: Number(E8.toFixed(2))
|
||||
}
|
||||
}
|
||||
|
||||
// function forgeWeight_rounded() {
|
||||
// // formula variables
|
||||
// const B2 = gratingLength
|
||||
// const B3 = gratingWidth
|
||||
// const B4 = bearingBarHeight
|
||||
// const B5 = bearingBarThickness
|
||||
// const B6 = forgeCrossBarThickness
|
||||
// const B7 = bearingBarPitch
|
||||
// const B8 = crossBarPitch
|
||||
// const B9 = frameThickness
|
||||
// //
|
||||
// const E2 = Math.round(B2 - 2 * B9)
|
||||
// const E3 = B3
|
||||
// const E4 = Math.round(B2 - 2 * B9)
|
||||
// const E5 = B3
|
||||
// //
|
||||
// const H2 = 0
|
||||
// const H3 = 2
|
||||
// const H4 = Math.round(E5 / B7 + 1)
|
||||
// const H5 = Math.round(E4 / B8 - 1)
|
||||
// const H6 = Number((E4 * B4 * B5 / 1000000 * 7.85 * H4).toFixed(2))
|
||||
// const H7 = Number(((E5 / 1000) * B6 * B6 * 7.85 / 1000 * H5).toFixed(2))
|
||||
// const H8 = Number((E2 * B9 * B4 / 1000000 * H2 * 7.85 + E3 * B4 * B9 / 1000000 * 7.85 * H3).toFixed(2))
|
||||
// const H9 = Math.round((1750 * (25.25 / (B4 * B5))))
|
||||
//
|
||||
// //
|
||||
// const E6 = Number((H6 + H7 + H8).toFixed(2))
|
||||
// //
|
||||
// const K2 = Number((E2 * (2 * (B4 + B5)) * H2 / 1000000).toFixed(2))
|
||||
// const K3 = Number((E3 * (2 * (B4 + B5)) * H3 / 1000000).toFixed(2))
|
||||
// const K4 = Number((E4 * (2 * (B4 + B5)) * H4 / 1000000).toFixed(2))
|
||||
// const K5 = Number((E5 * B6 * B6 * H5 / 1000000).toFixed(2))
|
||||
// const K6 = Number((K2 + K5).toFixed(2))
|
||||
// const K7 = 80
|
||||
// const K8 = Number((K6 * K7 / 1000000 * 7140).toFixed(2))
|
||||
// const K9 = Number((K8 / E6 * 100).toFixed(2))
|
||||
// //
|
||||
// const E7 = Number((K9 / 100 * E6).toFixed(2))
|
||||
// const E8 = Number((E6 + E7).toFixed(2))
|
||||
// //
|
||||
// const H10 = Number((E8 / ((B2 * B3) / 1000000)).toFixed(2))
|
||||
//
|
||||
// ///////// debug variables
|
||||
// // B
|
||||
// console.log('************ B Column ************')
|
||||
// console.log('B2 = ', B2)
|
||||
// console.log('B3 = ', B3)
|
||||
// console.log('B4 = ', B4)
|
||||
// console.log('B5 = ', B5)
|
||||
// console.log('B6 = ', B6)
|
||||
// console.log('B7 = ', B7)
|
||||
// console.log('B8 = ', B8)
|
||||
// console.log('B9 = ', B9)
|
||||
// // E
|
||||
// console.log('************ E Column ************')
|
||||
// console.log('E2 = ', E2)
|
||||
// console.log('E3 = ', E3)
|
||||
// console.log('E4 = ', E4)
|
||||
// console.log('E5 = ', E5)
|
||||
// console.log('E6 = ', E6)
|
||||
// console.log('E7 = ', E7)
|
||||
// console.log('E8 = ', E8)
|
||||
// // H
|
||||
// console.log('************ H Column ************')
|
||||
// console.log('H2 = ', H2)
|
||||
// console.log('H3 = ', H3)
|
||||
// console.log('H4 = ', H4)
|
||||
// console.log('H5 = ', H5)
|
||||
// console.log('H6 = ', H6)
|
||||
// console.log('H7 = ', H7)
|
||||
// console.log('H8 = ', H8)
|
||||
// console.log('H9 = ', H9)
|
||||
// console.log('H10 = ', H10)
|
||||
// // K
|
||||
// console.log('************ K Column ************')
|
||||
// console.log('K2 = ', K2)
|
||||
// console.log('K3 = ', K3)
|
||||
// console.log('K4 = ', K4)
|
||||
// console.log('K5 = ', K5)
|
||||
// console.log('K6 = ', K6)
|
||||
// console.log('K7 = ', K7)
|
||||
// console.log('K8 = ', K8)
|
||||
// console.log('K9 = ', K9)
|
||||
// // check H6
|
||||
// return E8
|
||||
// }
|
||||
|
||||
function pressuredWeight() {
|
||||
// formula variables
|
||||
const B15 = gratingLength
|
||||
const B16 = gratingWidth
|
||||
const B17 = bearingBarHeight
|
||||
const B18 = bearingBarThickness
|
||||
const B19 = crossBarHeight
|
||||
const B20 = crossBarThickness
|
||||
const B21 = bearingBarPitch
|
||||
const B22 = crossBarPitch
|
||||
const B23 = frameThickness
|
||||
//
|
||||
const E15 = B15 - 2
|
||||
const E16 = B16 - 2 * B23 - 2
|
||||
const E17 = B15 - 2 * B23 - 2
|
||||
const E18 = B16 - 2 * B23 - 2
|
||||
//
|
||||
const H17 = E18 / B21 - 1
|
||||
const H18 = E17 / B22 - 1
|
||||
const H20 = E18 * B19 * B20 / 1000000 * 7.85 * H18
|
||||
//
|
||||
const H15 = 2
|
||||
const H16 = 2
|
||||
const H19 = E17 * B17 * B18 / 1000000 * 7.85 * H17
|
||||
const H21 = E15 * B23 * B17 / 1000000 * H15 * 7.85 + E16 * B17 * B23 / 1000000 * 7.85 * H16
|
||||
const H22 = H19 + H21
|
||||
//
|
||||
const E19 = H19 + H20 + H21 - ((H17 - 1) * (H18 - 1) * B18 * B19 * B20) * 7.85 / 1000000
|
||||
//
|
||||
const H23 = (H22 - E19) * 100 / E19
|
||||
//
|
||||
const K15 = E15 * (2 * (B17 + B18)) * H15 / 1000000
|
||||
const K16 = E16 * (2 * (B17 + B18)) * H16 / 1000000
|
||||
const K17 = E17 * (2 * (B17 + B18)) * H17 / 1000000
|
||||
const K18 = E18 * (2 * (B19 + B20)) * H18 / 1000000
|
||||
const K19 = K15 + K18
|
||||
const K20 = 80
|
||||
const K21 = K19 * K20 / 1000000 * 7140
|
||||
const K22 = K21 / E19 * 100
|
||||
//
|
||||
const E20 = K22 / 100 * E19
|
||||
// const E21=E19+E20-E22
|
||||
const E21 = E19 + E20
|
||||
const L25 = B15
|
||||
const L26 = B16
|
||||
//
|
||||
const K25 = L25 - 4 - 2 * B23 - B20
|
||||
const K26 = L26 - 4 - 2 * B23 - B18
|
||||
//
|
||||
|
||||
// console.log('H15 ' + H15)
|
||||
// console.log('H16 ' + H16)
|
||||
// console.log('H17 ' + H17)
|
||||
// console.log('H18 ' + H18)
|
||||
// console.log('H19 ' + H19)
|
||||
// console.log('H20 ' + H20)
|
||||
// console.log('H21 ' + H21)
|
||||
// console.log('H22 ' + H22)
|
||||
// console.log('H23 ' + H23)
|
||||
|
||||
|
||||
// console.log('answer ' + H18)
|
||||
|
||||
return {
|
||||
normal: Number(E19.toFixed(2)),
|
||||
galvanized: Number(E21.toFixed(2))
|
||||
}
|
||||
}
|
||||
|
||||
///////// pointed load
|
||||
function pointedLoad() {
|
||||
// static variables
|
||||
@@ -546,12 +792,14 @@ module.exports.calculate = [
|
||||
// console.log('sigma =' + sigma)
|
||||
// console.log('L =' + L())
|
||||
// console.log('D =' + D)
|
||||
|
||||
//////////////////////////////////////////////////////////////// calculate result
|
||||
const result = {
|
||||
sigma: null,
|
||||
sigmaStatus: null,
|
||||
deflection: null,
|
||||
deflectionStatus: null
|
||||
deflectionStatus: null,
|
||||
gratingWeight: forge ? forgeWeight() : pressuredWeight()
|
||||
}
|
||||
if (sigma < 235) {
|
||||
result.sigma = validationMessages[locale].sigma_ok
|
||||
@@ -598,7 +846,8 @@ module.exports.calculate = [
|
||||
sigma: null,
|
||||
sigmaStatus: null,
|
||||
deflection: null,
|
||||
deflectionStatus: null
|
||||
deflectionStatus: null,
|
||||
gratingWeight: forge ? forgeWeight() : pressuredWeight()
|
||||
}
|
||||
if (sigma < 235) {
|
||||
result.sigma = validationMessages[locale].sigma_ok
|
||||
@@ -635,26 +884,26 @@ module.exports.getRelativeValues = [
|
||||
[
|
||||
body('gratingType')
|
||||
.notEmpty().withMessage((value, {req}) => {
|
||||
return validationMessages[req.body.locale].gratingType
|
||||
return validationMessages['fa'].gratingType
|
||||
})
|
||||
.bail()
|
||||
.custom((value, {req}) => {
|
||||
if (value === 'forge' || value === 'pressured') return true
|
||||
else Promise.reject(validationMessages[req.body.locale].gratingType_not_supported)
|
||||
else Promise.reject(validationMessages['fa'].gratingType_not_supported)
|
||||
}),
|
||||
|
||||
body('crossBarPitch')
|
||||
.notEmpty().withMessage((value, {req}) => {
|
||||
return validationMessages[req.body.locale].crossBarPitch
|
||||
return validationMessages['fa'].crossBarPitch
|
||||
})
|
||||
.bail()
|
||||
.custom((value, {req}) => {
|
||||
if (req.body.gratingType === 'forge') {
|
||||
if (values.crossBarPitch_forge.includes(Number(value))) return true
|
||||
else return Promise.reject(validationMessages[req.body.locale].crossBarPitch_not_ok)
|
||||
else return Promise.reject(validationMessages['fa'].crossBarPitch_not_ok)
|
||||
} else {
|
||||
if (values.crossBarPitch_pressured.includes(Number(value))) return true
|
||||
else return Promise.reject(validationMessages[req.body.locale].crossBarPitch_not_ok)
|
||||
else return Promise.reject(validationMessages['fa'].crossBarPitch_not_ok)
|
||||
}
|
||||
})
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user