Merge branch 'master' into dev

This commit is contained in:
goodmice 2021-10-14 13:00:53 +05:00
commit c50cb29b33

View File

@ -179,14 +179,22 @@ export default function TelemetryView({idWell}) {
const options = timePeriodCollection.map((line) => <Option key={line.value}>{line.label}</Option>)
const handleData = (state) => (data) => {
if (data && state) {
const handleDataSaub = (data) => {
if (data) {
data.forEach((_, idx) => {
if (data[idx].rotorSpeed < 1)
data[idx].rotorSpeed = 0;
if (data[idx].rotorTorque < 1)
data[idx].rotorTorque = 0;
data[idx].blockSpeed = Math.abs(data[idx].blockSpeed)
})
state(data)
setDataSaub(data)
}
}
const handleDataSpin = (data) => {
if (data) {
setDataSpin(data)
}
}
@ -195,14 +203,14 @@ export default function TelemetryView({idWell}) {
async () => {
const dataSaub = await TelemetryDataSaubService.getData(idWell, null, chartInterval)
const dataSpin = await TelemetryDataSpinService.getData(idWell, null, chartInterval)
handleData(setDataSaub)(dataSaub)
handleData(setDataSpin)(dataSpin)
handleDataSaub(dataSaub)
handleDataSpin(dataSpin)
},
setShowLoader,
`Не удалось получить данные по скважине "${idWell}"`,
)
const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleData(setDataSaub))
const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleData(setDataSpin))
const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleDataSaub)
const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleDataSpin)
return () => {
unsubscribeSaub()
unsubscribeSpin()