Skip to content

Commit

Permalink
Fix some glitches and typos
Browse files Browse the repository at this point in the history
Comment several console.log to clean console output
  • Loading branch information
luc-github committed Apr 7, 2024
1 parent 76f590a commit 1794682
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 61 deletions.
4 changes: 2 additions & 2 deletions src/components/Helpers/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { compareStrings } from './strings'

//sort files alphabeticaly then folders alphabeticaly
const sortedFilesList = (filesList, alphabeticaly) => {
console.log('Sorting files list', alphabeticaly)
//console.log('Sorting files list', alphabeticaly)
if (typeof filesList == 'undefined') return []
if (typeof alphabeticaly == 'undefined') {
alphabeticaly = true
}
if (alphabeticaly) {
console.log('Sorting alphabetically')
//console.log('Sorting alphabetically')
filesList.sort(function (a, b) {
return compareStrings(a.name, b.name)
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modal/logginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ const showLogin = () => {
if (val) passwordValue.current = val.trim()
}
const clickLogin = () => {
console.log(
/* console.log(
"login :",
loginValue.current,
" password:",
passwordValue.current
)
)*/
useUiContextFn.haptic()
const formData = new FormData()
formData.append("SUBMIT", "YES")
Expand Down
16 changes: 5 additions & 11 deletions src/components/Panels/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const TimeControl = ({ label, time }) => {
time.hour = time.hour ? time.hour.toString() : '0'
time.min = time.min ? time.min.toString() : '0'
time.sec = time.sec ? time.sec.toString() : '0'
if (time.day == 'Infinity') return null
return (
<div class="extra-control-value flex-row-between">
<div class="m-1">{T(label)}:</div>
Expand Down Expand Up @@ -70,6 +71,10 @@ const TimeControl = ({ label, time }) => {
const StatusControls = () => {
const { streamStatus, status } = useTargetContext()
if (!useUiContextFn.getValue('showstatuspanel')) return null
console.log("streamStatus")
console.log(streamStatus)
console.log( "status")
console.log( status)
return (
<Fragment>
{streamStatus &&
Expand Down Expand Up @@ -154,17 +159,6 @@ const StatusControls = () => {
</div>
</div>
)}
{status.state && status.state.length > 0 && (
<div class="status-ctrls">
<div
class="status-control mt-1 tooltip tooltip-bottom"
data-tooltip={T('P67')}
>
<div class="status-control-header">{T('P67')}</div>
<div class="status-control-value">{status.state}</div>
</div>
</div>
)}
</Fragment>
)
}
Expand Down
14 changes: 7 additions & 7 deletions src/contexts/DatasContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const DatasContextProvider = ({ children }) => {
}

const addTerminalContent = (element) => {
console.log(element)
console.log(
'isVerbose',
terminalBuffer.current.length,
'Quiet',
terminalBufferQuiet.current.length
)
//console.log(element)
//console.log(
// 'isVerbose',
// terminalBuffer.current.length,
// 'Quiet',
// terminalBufferQuiet.current.length
//)
const newData = {}
newData.verbose = limitArr(
[...terminalBuffer.current, element],
Expand Down
2 changes: 1 addition & 1 deletion src/targets/CNC/Controls/QuickStopButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const QuickStopButton = () => {
const cmds = useUiContextFn.getValue("emergencystop").split(";")
cmds.forEach((cmd) => {
SendCommand(cmd)
console.log(cmd)
// console.log(cmd)
})
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/targets/CNC/GRBL/Controls/BackgroundContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BackgroundContainer = () => {
const { alarmCode, errorCode, status } = useTargetContext()
const { toasts } = useUiContext()
useEffect(() => {
console.log(status)
//console.log(status)

if (alarmCode != 0 || errorCode != 0) {
toasts.addToast({
Expand Down
2 changes: 1 addition & 1 deletion src/targets/FLASH-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const commands = {
(path == '/' ? '' : '/') +
filename
).replaceAll('//', '/')
console.log('Upath:', upath)
//console.log('Upath:', upath)
return {
type: 'url',
url: upath,
Expand Down
2 changes: 1 addition & 1 deletion src/targets/Printer3D/Marlin/FLASH-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const commands = {
(path == '/' ? '' : '/') +
filename
).replaceAll('//', '/')
console.log('Upath:', upath)
//console.log('Upath:', upath)
return {
type: 'url',
url: upath,
Expand Down
2 changes: 1 addition & 1 deletion src/targets/Printer3D/Marlin/SD-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const commands = {
}
},
filterResult: (data, path) => {
console.log(data)
//console.log(data)
const res = {}
res.files = sortedFilesList(filterResultFiles(data.files, path), false)
res.status = formatStatus(data.status)
Expand Down
3 changes: 2 additions & 1 deletion src/targets/Printer3D/Marlin/TargetContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const TargetContextProvider = ({ children }) => {
if (type === 'response') {
//check if the response is a command answer
if (data[0] === '{') {
console.log('response', data)
if (isStreamingStatus(data)) {
setStatus({ printState: null })
const preStatus = getStreamingStatus(data)
Expand Down Expand Up @@ -415,7 +416,7 @@ const TargetContextProvider = ({ children }) => {
fanSpeed: {
current: fanSpeed,
set: (index, value) => {
console.log('set fan speed', index, '=', value)
//console.log('set fan speed', index, '=', value)
fansSpeed[index] = value
setFanSpeed(fanSpeed)
},
Expand Down
69 changes: 43 additions & 26 deletions src/targets/Printer3D/Marlin/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
License along with This code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
import { h } from "preact"
import { useSettingsContextFn } from "../../../contexts"

import { h } from 'preact'
import { useSettingsContextFn } from '../../../contexts'

////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok") && !str.startsWith("ok T:")) {
if (str.startsWith('ok') && !str.startsWith('ok T:')) {
return true
}
return false
}


////////////////////////////////////////////////////////
//
//Temperatures
Expand All @@ -49,7 +47,7 @@ const isTemperatures = (str) => {
}

const getTemperatures = (str) => {
const isMKS = useSettingsContextFn.getValue("SerialProtocol") == "MKS"
const isMKS = useSettingsContextFn.getValue('SerialProtocol') == 'MKS'
let result = null
const response = {
T: [], //0->8 T0->T8 Extruders
Expand All @@ -71,7 +69,7 @@ const getTemperatures = (str) => {
while ((result = regex_search.exec(str)) !== null) {
//MKS always have T0,T1,B even no second extruder is present neither bed
if (!(isMKS && parseFloat(result[3]) == 0))
response[result[1]][result[2] == "" ? 0 : result[2]] = {
response[result[1]][result[2] == '' ? 0 : result[2]] = {
value: result[3],
target: result[4],
}
Expand Down Expand Up @@ -109,7 +107,8 @@ const isPrintStatus = (str) => {
let result = null
const reg_search1 = /(Not\sSD\sprinting|Done\sprinting\sfile)/
const reg_search2 = /SD\sprinting\sbyte\s([0-9]*)\/([0-9]*)/
const reg_search3 =/echo:\sM73\sProgress:\s+([0-9.]*)%;\sTime\sleft:\s([0-9]*)m;\sChange:\s([0-9]*)m;/
const reg_search3 =
/echo:\sM73\sProgress:\s+([0-9.]*)%;\sTime\sleft:\s([0-9]*)m;\sChange:\s([0-9]*)m;/
if ((result = reg_search1.exec(str)) !== null) {
return true
}
Expand All @@ -119,7 +118,7 @@ const isPrintStatus = (str) => {
if ((result = reg_search3.exec(str)) !== null) {
return true
}
if (str.startsWith("echo:Print time:")) {
if (str.startsWith('echo:Print time:')) {
return true
}
return false
Expand All @@ -129,17 +128,18 @@ const getPrintStatus = (str) => {
let result = null
const reg_search1 = /(Not\sSD\sprinting|Done\sprinting\sfile)/
const reg_search2 = /SD\sprinting\sbyte\s([0-9]*)\/([0-9]*)/
const reg_search3 =/echo:\sM73\sProgress:\s+([0-9.]*)%;\sTime\sleft:\s([0-9]*)m;\sChange:\s([0-9]*)m;/
const reg_search3 =
/echo:\sM73\sProgress:\s+([0-9.]*)%;\sTime\sleft:\s([0-9]*)m;\sChange:\s([0-9]*)m;/
if ((result = reg_search1.exec(str)) !== null) {
return {
status: result[1],
printing: false,
progress: result[1].startsWith("Done") ? 100 : 0,
progress: result[1].startsWith('Done') ? 100 : 0,
}
}
if ((result = reg_search2.exec(str)) !== null) {
return {
status: "Printing",
status: 'Printing',
printing: true,
progress: (
(100 * parseFloat(result[1])) /
Expand All @@ -150,12 +150,17 @@ const getPrintStatus = (str) => {
if ((result = reg_search3.exec(str)) !== null) {
let progress = parseFloat(result[1])
return {
status: (progress === 100) ? "Done" : ((progress === 0) ? "Not printing" : `Printing: ${result[2]}m remaining`),
printing: (!(progress === 100 || progress === 0)),
status:
progress === 100
? 'Done'
: progress === 0
? 'Not printing'
: `Printing: ${result[2]}m remaining`,
printing: !(progress === 100 || progress === 0),
progress: progress.toFixed(2),
}
}
if (str.startsWith("echo:Print time:")) {
if (str.startsWith('echo:Print time:')) {
const regex_search =
/echo:Print time:\s((?<year>[0-9]*)y\s)*((?<day>[0-9]*)d\s)*((?<hour>[0-9]*)h\s)*((?<min>[0-9]*)m\s)*((?<sec>[0-9]*)s)/
result = regex_search.exec(str)
Expand All @@ -171,7 +176,7 @@ const getPrintStatus = (str) => {
}, {})
return { time: printTime, printing: isprinting }
}
return { status: "Unknown", printing: false, progress: 0 }
return { status: 'Unknown', printing: false, progress: 0 }
}

////////////////////////////////////////////////////////
Expand All @@ -193,7 +198,7 @@ const getPrintFileName = (str) => {
if ((result = reg_search1.exec(str)) !== null) {
return result[1]
}
return "Unknown"
return 'Unknown'
}

////////////////////////////////////////////////////////
Expand Down Expand Up @@ -222,7 +227,7 @@ const getStatus = (str) => {
if ((result = reg_search2.exec(str)) !== null) {
return result[1]
}
return "Unknown"
return 'Unknown'
}

////////////////////////////////////////////////////////
Expand Down Expand Up @@ -263,7 +268,10 @@ const getFanSpeed = (str) => {
let result = null
const reg_search1 = /M106\sP([0-9]+)\sS([0-9]+)/
if ((result = reg_search1.exec(str)) !== null) {
return { index: parseInt(result[1]), value: (result[2]/255.0 * 100.0).toFixed(2) }
return {
index: parseInt(result[1]),
value: ((result[2] / 255.0) * 100.0).toFixed(2),
}
}
return null
}
Expand Down Expand Up @@ -298,7 +306,7 @@ const getFeedRate = (str) => {
//...
const isPrinterCapability = (str) => {
const reg_search1 = /^Cap:([^:]+):[0-1]$/
if (str.startsWith("FIRMWARE_NAME:") || reg_search1.test(str)) {
if (str.startsWith('FIRMWARE_NAME:') || reg_search1.test(str)) {
return true
}
return false
Expand All @@ -310,7 +318,7 @@ const getPrinterCapability = (str) => {
const reg_search1 = /^Cap:(?<item>[^:]+):(?<value>[0-1])$/
const reg_search2 =
/^FIRMWARE_NAME:(?<firmware_name>[^\(]+)\s\((?<firmware_date>[^\)]*)\)\sSOURCE_CODE_URL:(?<source_code_url>.+?(?=\sPROTOCOL_VERSION))\sPROTOCOL_VERSION:(?<protocol_version>.+?(?=\sMACHINE_TYPE))\sMACHINE_TYPE:(?<machine_type>.+?(?=\sEXTRUDER_COUNT))\sEXTRUDER_COUNT:(?<extruder_count>.+?(?=\sUUID))\sUUID:(?<uuid>.+)/
if (str.startsWith("FIRMWARE_NAME:")) {
if (str.startsWith('FIRMWARE_NAME:')) {
if ((result = reg_search2.exec(str)) !== null) {
Object.keys(result.groups).forEach((key) => {
res.push({
Expand All @@ -320,8 +328,8 @@ const getPrinterCapability = (str) => {
})
} else {
res.push({
name: "FIRMWARE_NAME",
value: str.split(":")[1].split(" "),
name: 'FIRMWARE_NAME',
value: str.split(':')[1].split(' '),
})
}
} else if ((result = reg_search1.exec(str)) !== null) {
Expand All @@ -334,12 +342,12 @@ const getPrinterCapability = (str) => {
//
//Sensor
const isSensor = (str) => {
return str.startsWith("SENSOR:")
return str.startsWith('SENSOR:')
}

const getSensor = (str) => {
const result = []
const data = " " + str.substring(7)
const data = ' ' + str.substring(7)
let res = null
const reg_search = /\s(?<value>[^\[]+)\[(?<unit>[^\]]+)\]/g
while ((res = reg_search.exec(data))) {
Expand All @@ -352,16 +360,25 @@ const getSensor = (str) => {
//
// Streaming status
const isStreamingStatus = (str) => {
console.log('isStreamingStatus', str)
try {
const res = JSON.parse(str)
if (res.cmd == "701" && typeof res.data != "undefined") return true
if (res.cmd == '701' && typeof res.data != 'undefined') {
return true
} else {
console.log('isStreamingStatus is not streamining status', str)
return false
}
} catch (e) {
console.log('isStreamingStatus is not streamining status because parsing error', e)
return false
}
}

const getStreamingStatus = (str) => {
console.log('getStreamingStatus', str)
const res = JSON.parse(str)
console.log('getStreamingStatus', res)
if (res.data.status) return res.data
return { status: res.data }
}
Expand Down
4 changes: 2 additions & 2 deletions src/targets/Printer3D/Smoothieware/MachineSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const MachineSettings = () => {
configSelected ? "configset" : "overrideset",
entry
)
console.log(cmd)
//console.log(cmd)
createNewRequest(
espHttpURL("command", { cmd }),
{ method: "GET", id: "saveMachineSetting" },
Expand Down Expand Up @@ -162,7 +162,7 @@ const MachineSettings = () => {
}

const saveSettings = () => {
console.log("Save settings")
//console.log("Save settings")
machineSettings.totalToSave = 0
machineSettings.toSave = []
const settings = configSelected
Expand Down
2 changes: 1 addition & 1 deletion src/targets/Printer3D/Smoothieware/SD-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const capabilities = {

const commands = {
list: (path, filename) => {
console.log("path: ", path)
//console.log("path: ", path)
const spath = (path + (path == '/' ? '' : '/')).replaceAll('//', '/')
const cmd = "echo BeginFiles;"+useUiContextFn.getValue('sdlistcmd').replace("#",spath).replaceAll('//', '/')+";echo EndFiles"
return {
Expand Down
Loading

0 comments on commit 1794682

Please sign in to comment.