Skip to content

Commit

Permalink
Laser material testing (#2548)
Browse files Browse the repository at this point in the history
* Update build-on-create-release.yml

* Update build-on-create-release.yml

* Feature: Support material test

Support material test

* Feature: Support material test

not support auto delete

* Feature: Support material test

fix cannot genarate gcode bug

* Feature: Support material test

fix cannot genarate gcode bug

* Feature: Support material test

new alpha version

* Feature: Support material test

update nightly build relaese id

* Fix: Nightly build fix

Nightly build fix

* Update build-on-pull-request.yml

* Fix: Nightly build fix

Nightly build fix

* Fix: Rollback workflow

Rollback workflow

* Fix: Rollback workflow

Rollback workflow

* Fix: Remove excess logs

Remove excess logs
  • Loading branch information
leo-songye-li authored Dec 16, 2024
1 parent f166ded commit 609ecf4
Show file tree
Hide file tree
Showing 23 changed files with 460 additions and 42 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/build-on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ jobs:
with:
node-version: 16

- name: install
run: |
npm install -g npm@^9
npm install
- name: build
run: npm run build

- name: Init Props
run: |
$PRODUCT_NAME="Snapmaker Luban"
Expand All @@ -45,13 +52,6 @@ jobs:
$RELEASE="$PACKAGE_NAME-$PACKAGE_VERSION"
echo "SM_RELEASE=$RELEASE" >> $env:GITHUB_ENV
- name: install
run: |
npm install -g npm@^9
npm install
- name: build
run: npm run build

# ----------------------------------------------------------------
# Build Windows x64
# ----------------------------------------------------------------
Expand All @@ -70,6 +70,7 @@ jobs:
- name: Deploy Windows release
uses: WebFreak001/[email protected]
with:
overwrite: true
upload_url: https://uploads.github.com/repos/Snapmaker/Luban/releases/180614211/assets{?name,label}
release_id: 180614211
asset_path: ${{ github.workspace }}/output/${{ env.SM_RELEASE }}-win-x64.exe
Expand All @@ -95,7 +96,7 @@ jobs:
run: git submodule update --init --recursive

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v2
with:
python-version: 3.11

Expand All @@ -108,6 +109,14 @@ jobs:
with:
node-version: 16

# install setuptools to reintroduce distutils missing in Python 3.12
# https://github.com/nodejs/node-gyp/issues/2869
- run: pip install setuptools
- run: npm install -g npm@^9
- run: npm install

- run: npm run build

- name: Init Props
run: |
PRODUCT_NAME="Snapmaker Luban"
Expand All @@ -116,13 +125,6 @@ jobs:
RELEASE=${PACKAGE_NAME}-${PACKAGE_VERSION}
echo "SM_RELEASE=$RELEASE" >> $GITHUB_ENV
# install setuptools to reintroduce distutils missing in Python 3.12
# https://github.com/nodejs/node-gyp/issues/2869
- run: pip install setuptools
- run: npm install -g npm@^9
- run: npm install

- run: npm run build
# ----------------------------------------------------------------
# Build macOS x64 & arm64
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snapmaker-luban",
"version": "4.15.0-alph.1",
"version": "4.15.0-alpha.2",
"description": "A web-based interface for Snapmaker 3-in-1 3D Printer",
"homepage": "https://github.com/Snapmaker/Luban",
"author": "Snapmaker Software Team",
Expand Down
106 changes: 106 additions & 0 deletions src/app/flux/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,112 @@ export const actions = {
dispatch(actions.resetProcessState(headType));
},

createElementAndGenToolPath: (headType, params) => async (dispatch, getState) => {
const { modelGroup, SVGActions, toolPathGroup, coordinateMode, coordinateSize, materials } = getState()[headType];
const { rectRows, speedMin, speedMax, rectHeight, rectCols, powerMin, powerMax, rectWidth } = params;
const origin: Origin = getState()[headType].origin;

const gap = 5;
const headGap = 10;
const maxWidth = (rectCols * (gap + rectWidth)) + rectHeight + (gap + rectHeight);
const maxHeight = (rectRows + 3) * rectHeight + rectRows * gap + headGap;
const position = {
// TODO 画图在中心位计算坐标 坐标为可能有偏差,具体待验证
x: coordinateMode.setting.sizeMultiplyFactor.x * coordinateSize.x / 2 + (coordinateSize.x * 2 - maxWidth) / 2 + rectWidth,
y: -coordinateMode.setting.sizeMultiplyFactor.y * coordinateSize.y / 2 + ((maxHeight - headGap) / 2 - rectHeight * 1.5 + coordinateSize.y)
};
// 越界判断,判断pass跟speed 最大高度
// 当前只支持工作原点为中心
if (maxWidth > coordinateSize.x || maxHeight > coordinateSize.y) {
log.error(`越界,xWidth:${maxWidth},y:${maxHeight}`);
return;
}

const toolPathBase = {
speed: (speedMax - speedMin) / ((rectRows - 1) || 1),
power: (powerMax - powerMin) / ((rectCols - 1) || 1),
};

const wordSpeed = (speedMax - speedMin) / 2 + speedMin;
const wordPower = (powerMax - powerMin) / 2 + powerMin;
const createElement = async (text, x, y, w, h, workspeed, fixedPower, needRote) => {
const curX = position.x + x;
const curY = position.y + y;
let svg;
if (text) {
svg = await SVGActions.svgContentGroup.addSVGElement({
element: 'text',
attr: {
x: curX,
y: curY,
'font-size': 24,
'font-family': 'Arial Black',
style: 'Regular',
alignment: 'left',
textContent: text,
width: w,
height: h,
}
});
} else {
svg = await SVGActions.svgContentGroup.addSVGElement({
element: 'rect',
attr: {
x: curX,
y: curY,
fill: '#ffffff',
'fill-opacity': '0',
opacity: '1',
stroke: '#000000',
'stroke-width': '0.2756410256410256',
width: w,
height: h,
}
});
}
const newSVGModel = await SVGActions.createModelFromElement(svg);
const textElement = document.getElementById(svg.id);
await SVGActions.resizeElementsImmediately([textElement], { newWidth: w, newHeight: h });
if (needRote) {
await SVGActions.rotateElementsImmediately([textElement], { newAngle: -90 });
}
modelGroup.selectedModelArray.push(newSVGModel);
const toolPath = toolPathGroup.createToolPath({ materials, origin });
toolPath.gcodeConfig.workSpeed = workspeed;
toolPath.gcodeConfig.fixedPower = fixedPower;
toolPath.gcodeConfig.constantPowerMode = true;
toolPath.gcodeConfig.auxiliaryAirPump = true;
toolPath.gcodeConfig.halfDiodeMode = false;
if (toolPathGroup.getToolPath(toolPath.id)) {
toolPathGroup.updateToolPath(toolPath.id, toolPath, { materials, origin });
} else {
toolPathGroup.saveToolPath(toolPath, { materials, origin }, false);
}
modelGroup.selectedModelArray = [];
};
await createElement('Passes', rectCols / 2 * (gap + rectWidth), -rectRows * (gap + rectHeight) - headGap, 20, rectHeight, wordSpeed, wordPower, false);
await createElement('Power(%)', rectCols / 2 * (gap + rectWidth) + rectHeight, 2 * rectHeight, 25, rectHeight, wordSpeed, wordPower, false);
await createElement('Speed(mm/m)', -rectWidth - rectHeight / 2, -rectRows / 2 * (gap + rectHeight), 30, rectHeight, wordSpeed, wordPower, true);
let x = 0;
let y = 0;
for (let i = 0; i < rectCols; i++) {
x += gap + rectWidth;
await createElement(`${Math.round(powerMin + i * toolPathBase.power)}`, x + rectWidth / 2, rectHeight / 2, rectHeight, rectWidth, wordSpeed, wordPower, false);
y = 0;
for (let j = 0; j < rectRows; j++) {
y -= gap + rectHeight;
if (i === 0) {
await createElement(`${Math.round(speedMin + j * toolPathBase.speed)}`, x - rectWidth, y + rectHeight / 2, rectWidth, rectHeight, wordSpeed, wordPower, true);
}
await createElement(null, x, y, rectWidth, rectHeight, speedMin + j * toolPathBase.speed,
powerMin + i * toolPathBase.power, false);
}
}

dispatch(projectActions.autoSaveEnvironment(headType));
dispatch(baseActions.render(headType));
},

selectAllElements: headType => async (dispatch, getState) => {
const { SVGActions, SVGCanvasMode, SVGCanvasExt, materials } = getState()[headType];
if (SVGCanvasMode === 'draw' || SVGCanvasExt.elem) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/cs/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Materiálový test",
"key-Laser/MainToolBar-MaterialTesting": "Materiálový test",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Řádky",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Počet řádků",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Sloupce",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/de/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Einblenden",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Umwandlung",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Materialtest",
"key-Laser/MainToolBar-MaterialTesting": "Materialtest",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Reihen",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Reihenzahl",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Spalten",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/en/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Unhide",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Transformation",
"manualModeDesc": "manualModeDesc",
"key_ui-views-MaterialTestModal-FormComponent-title": "Material Test",
"key-Laser/MainToolBar-MaterialTesting": "Material Test",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Rows",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Row Count",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Columns",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/es/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Mostrar",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Transformación",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Prueba de Material",
"key-Laser/MainToolBar-MaterialTesting": "Prueba de Material",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Filas",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Cantidad de Filas",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Columnas",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/fr/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Démasquer",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Transformation",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Test de Matériau",
"key-Laser/MainToolBar-MaterialTesting": "Test de Matériau",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Lignes",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Nombre de Lignes",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Colonnes",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/hu/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Anyagvizsgálat",
"key-Laser/MainToolBar-MaterialTesting": "Anyagvizsgálat",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Sorok",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Sorok száma",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Oszlopok",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/it/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Scopri",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Trasformazione",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Test del Materiale",
"key-Laser/MainToolBar-MaterialTesting": "Test del Materiale",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Righe",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Conteggio Righe",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Colonne",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/ja/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "表示",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "変換",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "材料テスト",
"key-Laser/MainToolBar-MaterialTesting": "材料テスト",
"key_ui-views-MaterialTestModal-FormComponent-rows": "行",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "行数",
"key_ui-views-MaterialTestModal-FormComponent-columns": "列",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/ko/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "숨김 해제",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "변형",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "재료 테스트",
"key-Laser/MainToolBar-MaterialTesting": "재료 테스트",
"key_ui-views-MaterialTestModal-FormComponent-rows": "행",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "행 수",
"key_ui-views-MaterialTestModal-FormComponent-columns": "열",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/pt-br/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Teste de Material",
"key-Laser/MainToolBar-MaterialTesting": "Teste de Material",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Linhas",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Contagem de Linhas",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Colunas",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/ru/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Unhide",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Transformation",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Материальный тест",
"key-Laser/MainToolBar-MaterialTesting": "Материальный тест",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Ряды",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Количество рядов",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Столбцы",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/uk/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "Показати",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "Трансформація",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "Матеріальний тест",
"key-Laser/MainToolBar-MaterialTesting": "Матеріальний тест",
"key_ui-views-MaterialTestModal-FormComponent-rows": "Ряди",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "Кількість рядів",
"key_ui-views-MaterialTestModal-FormComponent-columns": "Стовпці",
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/i18n/zh-CN/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@
"key_menu_Unhide": "取消隐藏",
"key_ui/widgets/CNCPath/CNCPath_Transformation": "变换",
"manualModeDesc": "",
"key_ui-views-MaterialTestModal-FormComponent-title": "材料测试",
"key-Laser/MainToolBar-MaterialTesting": "材料测试",
"key_ui-views-MaterialTestModal-FormComponent-rows": "行",
"key_ui-views-MaterialTestModal-FormComponent-rowCount": "行数",
"key_ui-views-MaterialTestModal-FormComponent-columns": "列",
Expand Down
21 changes: 11 additions & 10 deletions src/app/ui/pages/CncLaserShared/MainToolBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import SelectCaptureMode, { MODE_THICKNESS_COMPENSATION } from '../../widgets/La
import LaserSetBackground from '../../widgets/LaserSetBackground';
import { L20WLaserToolModule, L2WLaserToolModule, L40WLaserToolModule } from '../../../machines/snapmaker-2-toolheads';

function useRenderMainToolBar({ headType, setShowHomePage, setShowJobType, setShowWorkspace,
function useRenderMainToolBar({ headType, setShowHomePage, setShowJobType, setShowMaterialTesting, setShowWorkspace,
onChangeSVGClippingMode,
// onChangeMaterialTestMode,
onChangeABPositionMode }) {
Expand Down Expand Up @@ -422,15 +422,15 @@ function useRenderMainToolBar({ headType, setShowHomePage, setShowJobType, setSh
});
}
// TODO
// leftItems.push({
// title: i18n._('key_ui-views-MaterialTestModal-FormComponent-title'),
// type: 'button',
// disabled: isOnABPosition,
// name: 'MaterialTest',
// action: () => {
// dispatch(onChangeMaterialTestMode);
// }
// });
leftItems.push({
title: i18n._('key-Laser/MainToolBar-MaterialTesting'),
type: 'button',
disabled: isOnABPosition,
name: 'MaterialTesting',
action: () => {
setShowMaterialTesting(true);
}
});
}

// CNC specific tools
Expand Down Expand Up @@ -644,6 +644,7 @@ useRenderMainToolBar.propTypes = {
headType: PropTypes.string.isRequired,
setShowHomePage: PropTypes.func,
setShowJobType: PropTypes.func,
setShowMaterialTesting: PropTypes.func,
setShowWorkspace: PropTypes.func
};

Expand Down
Loading

0 comments on commit 609ecf4

Please sign in to comment.