Add Ok parsing to speedup response processing from @ jamespearson04 suggestion

This commit is contained in:
Luc
2023-10-03 13:13:34 +08:00
parent 66435e7261
commit 37932f057c
23 changed files with 505 additions and 416 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

805
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,7 @@ import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import { eventsList, variablesList } from "."
import {
isOk,
isStatus,
getStatus,
isStates,
@@ -97,8 +98,9 @@ const TargetContextProvider = ({ children }) => {
//sensors
//status
if (type === "stream") {
//status
if (isStatus(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isStatus(data)) {//status
const response = getStatus(data)
//For Pn we need to keep the last value to keep trace the pin is detected or not,
//so we can display the pin icon when disabled even no data is received

View File

@@ -26,6 +26,15 @@ import { gcode_parser_modes } from "./gcode_parser_modes"
let wpos = []
let mpos = []
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str=="ok") {
return true
}
return false
}
////////////////////////////////////////////////////////
//
// Status format is : <...>
@@ -380,6 +389,7 @@ const getStreamingStatus = (str) => {
return { status: res.data }
}
export {
isOk,
isStatus,
getStatus,
isStates,

View File

@@ -28,6 +28,7 @@ import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import { eventsList, variablesList } from "."
import {
isOk,
isStatus,
getStatus,
isStates,
@@ -114,8 +115,9 @@ const TargetContextProvider = ({ children }) => {
}
}
if (type === "stream") {
//status
if (isStatus(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isStatus(data)) {//status
const response = getStatus(data)
//For Pn we need to keep the last value to keep trace the pin is detected or not,
//so we can display the pin icon when disabled even no data is received

View File

@@ -26,6 +26,16 @@ import { gcode_parser_modes } from "./gcode_parser_modes"
let wpos = []
let mpos = []
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str=="ok") {
return true
}
return false
}
////////////////////////////////////////////////////////
//
// Status format is : <...>
@@ -395,6 +405,7 @@ const getStreamingStatus = (str) => {
return { status: res.data }
}
export {
isOk,
isStatus,
getStatus,
isStates,

View File

@@ -28,6 +28,7 @@ import { useDatasContext } from "../../../contexts"
import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import {
isOk,
isTemperatures,
getTemperatures,
isPositions,
@@ -169,7 +170,9 @@ const TargetContextProvider = ({ children }) => {
//sensors
if (type === "stream") {
if (isTemperatures(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isTemperatures(data)) {
const t = getTemperatures(data)
setTemperatures(t)
add2TemperaturesList({ temperatures: t, time: new Date() })

View File

@@ -20,6 +20,16 @@
import { h } from "preact"
import { useSettingsContextFn } from "../../../contexts"
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok") && !str.startsWith("ok T:")) {
return true
}
return false
}
////////////////////////////////////////////////////////
//
//Temperatures
@@ -300,6 +310,7 @@ const getSensor = (str) => {
}
export {
isOk,
isTemperatures,
getTemperatures,
isPositions,

View File

@@ -28,6 +28,7 @@ import { useDatasContext } from "../../../contexts"
import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import {
isOk,
isTemperatures,
getTemperatures,
isPositions,
@@ -171,7 +172,9 @@ const TargetContextProvider = ({ children }) => {
//sensors
if (type === "stream") {
if (isTemperatures(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isTemperatures(data)) {
const t = getTemperatures(data)
setTemperatures(t)
add2TemperaturesList({ temperatures: t, time: new Date() })

View File

@@ -20,6 +20,18 @@
import { h } from "preact"
import { useSettingsContextFn } from "../../../contexts"
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok") && !str.startsWith("ok T:")) {
return true
}
return false
}
////////////////////////////////////////////////////////
//
//Temperatures
@@ -337,6 +349,7 @@ const getSensor = (str) => {
}
export {
isOk,
isTemperatures,
getTemperatures,
isPositions,

View File

@@ -28,6 +28,7 @@ import { useDatasContext } from "../../../contexts"
import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import {
isOk,
isTemperatures,
getTemperatures,
isPositions,
@@ -152,7 +153,9 @@ const TargetContextProvider = ({ children }) => {
const dispatchInternally = (type, data) => {
processor.handle(type, data)
if (type === "stream") {
if (isTemperatures(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isTemperatures(data)) {
const t = getTemperatures(data)
setTemperatures(t)
add2TemperaturesList({ temperatures: t, time: new Date() })

View File

@@ -20,6 +20,16 @@
import { h } from "preact"
import { useSettingsContextFn } from "../../../contexts"
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok")) {
return true
}
return false
}
////////////////////////////////////////////////////////
//
//Temperatures
@@ -335,6 +345,7 @@ const getSensor = (str) => {
}
export {
isOk,
isTemperatures,
getTemperatures,
isPositions,

View File

@@ -28,6 +28,7 @@ import { useDatasContext } from "../../../contexts"
import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import {
isOk,
isTemperatures,
getTemperatures,
isPositions,
@@ -153,7 +154,9 @@ const TargetContextProvider = ({ children }) => {
//sensors
if (type === "stream") {
if (isTemperatures(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isTemperatures(data)) {
const t = getTemperatures(data)
setTemperatures(t)
add2TemperaturesList({ temperatures: t, time: new Date() })

View File

@@ -20,6 +20,16 @@
import { h } from "preact"
import { useSettingsContextFn } from "../../../contexts"
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok")) {
return true
}
return false
}
////////////////////////////////////////////////////////
//
//Temperatures
@@ -268,6 +278,7 @@ const getSensor = (str) => {
}
export {
isOk,
isTemperatures,
getTemperatures,
isPositions,

View File

@@ -28,6 +28,7 @@ import { processor } from "./processor"
import { isVerboseOnly } from "./stream"
import { eventsList, variablesList } from "."
import {
isOk,
isStatus,
getStatus,
isStates,
@@ -96,8 +97,9 @@ const TargetContextProvider = ({ children }) => {
//sensors
//status
if (type === "stream") {
//status
if (isStatus(data)) {
if (isOk(data)) {
//just ignore this one so we can continue
} else if (isStatus(data)) {//status
const response = getStatus(data)
//For Pn we need to keep the last value to keep trace the pin is detected or not,
//so we can display the pin icon when disabled even no data is received

View File

@@ -26,6 +26,16 @@ import { gcode_parser_modes } from "./gcode_parser_modes"
let wpos = []
let mpos = []
////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str=="ok") {
return true
}
return false
}
////////////////////////////////////////////////////////
//
// Status format is : <...>
@@ -380,6 +390,7 @@ const getStreamingStatus = (str) => {
return { status: res.data }
}
export {
isOk,
isStatus,
getStatus,
isStates,