當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gcode.Block類代碼示例

本文整理匯總了Golang中github.com/joushou/gocnc/gcode.Block的典型用法代碼示例。如果您正苦於以下問題:Golang Block類的具體用法?Golang Block怎麽用?Golang Block使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Block類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: setMoveMode

func (vm *Machine) setMoveMode(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("motionGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("motionGroup", w)
			}

			switch w.Command {
			case 0:
				vm.State.MoveMode = MoveModeRapid
			case 1:
				vm.State.MoveMode = MoveModeLinear
			case 2:
				vm.State.MoveMode = MoveModeCWArc
			case 3:
				vm.State.MoveMode = MoveModeCCWArc
			case 80:
				vm.State.MoveMode = MoveModeNone
			default:
				unknownCommand("motionGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:27,代碼來源:main.go

示例2: setCoolant

func (vm *Machine) setCoolant(stmt *gcode.Block) {
	// TODO Handle M7 and M8 on same line
	if w, err := stmt.GetModalGroup("coolantGroup"); err == nil {
		if w != nil {
			if w.Address != 'M' {
				unknownCommand("coolantGroup", w)
			}

			switch w.Command {
			case 7:
				vm.State.MistCoolant = true
			case 8:
				vm.State.FloodCoolant = true
			case 9:
				vm.State.MistCoolant = false
				vm.State.FloodCoolant = false
			default:
				unknownCommand("coolantGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:25,代碼來源:main.go

示例3: feedRateMode

func (vm *Machine) feedRateMode(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("feedRateModeGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("feedRateModeGroup", w)
			}

			oldMode := vm.State.FeedMode
			switch w.Command {
			case 93:
				vm.State.FeedMode = FeedModeInvTime
			case 94:
				vm.State.FeedMode = FeedModeUnitsMin
			case 95:
				vm.State.FeedMode = FeedModeUnitsRev
			default:
				unknownCommand("feedRateModeGroup", w)
			}
			if vm.State.FeedMode != oldMode {
				// Ensure that feedrate is cleared
				vm.State.Feedrate = 0
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}

}
開發者ID:raylee,項目名稱:gocnc,代碼行數:29,代碼來源:main.go

示例4: postCheck

func (vm *Machine) postCheck(stmt *gcode.Block) {
	for _, w := range stmt.Nodes {
		if _, ok := w.(*gcode.Word); ok {
			panic(fmt.Sprintf("Unsupported commands left in block: %s", stmt.Export(-1)))
		}
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:7,代碼來源:main.go

示例5: setSpindle

func (vm *Machine) setSpindle(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("spindleGroup"); err == nil {
		if w != nil {
			if w.Address != 'M' {
				unknownCommand("spindleGroup", w)
			}

			switch w.Command {
			case 3:
				vm.State.SpindleEnabled = true
				vm.State.SpindleClockwise = true
			case 4:
				vm.State.SpindleEnabled = true
				vm.State.SpindleClockwise = false
			case 5:
				vm.State.SpindleEnabled = false
			default:
				unknownCommand("spindleGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}

}
開發者ID:raylee,項目名稱:gocnc,代碼行數:26,代碼來源:main.go

示例6: lineNumber

func (vm *Machine) lineNumber(stmt *gcode.Block) {
	if stmt.Length() > 0 {
		if w, ok := stmt.Nodes[0].(*gcode.Word); ok {
			if w.Address == 'N' {
				// We just ignore and consume the line number
				stmt.Remove(w)
			}
		}
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:10,代碼來源:main.go

示例7: feedRate

func (vm *Machine) feedRate(stmt *gcode.Block) {
	if val, err := stmt.GetWord('F'); err == nil {
		if vm.Imperial {
			val *= 25.4
		}
		vm.State.Feedrate = val
		stmt.RemoveAddress('F')
	} else if vm.State.FeedMode == FeedModeInvTime {
		vm.State.Feedrate = -1
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:11,代碼來源:main.go

示例8: setCoordinateSystem

func (vm *Machine) setCoordinateSystem(stmt *gcode.Block) {
	// TODO Implement coordinate system offsets!
	if w, err := stmt.GetModalGroup("coordinateSystemGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("coordinateSystemGroup", w)
			}

			if vm.State.CutterCompensation != CutCompModeNone {
				invalidCommand("coordinateSystemGroup", "coordinate system select", "Coordinate system change attempted with cutter compensation enabled")
			}

			switch w.Command {
			case 54:
				vm.CoordinateSystem.SelectCoordinateSystem(1)
			case 55:
				vm.CoordinateSystem.SelectCoordinateSystem(2)
			case 56:
				vm.CoordinateSystem.SelectCoordinateSystem(3)
			case 57:
				vm.CoordinateSystem.SelectCoordinateSystem(4)
			case 58:
				vm.CoordinateSystem.SelectCoordinateSystem(5)
			case 59:
				vm.CoordinateSystem.SelectCoordinateSystem(6)
			case 59.1:
				vm.CoordinateSystem.SelectCoordinateSystem(7)
			case 59.2:
				vm.CoordinateSystem.SelectCoordinateSystem(8)
			case 59.3:
				vm.CoordinateSystem.SelectCoordinateSystem(9)
			default:
				unknownCommand("coordinateSystemGroup", w)
			}

			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:41,代碼來源:main.go

示例9: setUnits

func (vm *Machine) setUnits(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("unitsGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("unitsGroup", w)
			}

			switch w.Command {
			case 20:
				vm.Imperial = true
			case 21:
				vm.Imperial = false
			default:
				unknownCommand("unitsGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:21,代碼來源:main.go

示例10: setArcDistanceMode

func (vm *Machine) setArcDistanceMode(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("arcDistanceModeGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("arcDistanceModeGroup", w)
			}

			switch w.Command {
			case 90.1:
				vm.AbsoluteArc = true
			case 91.1:
				vm.AbsoluteArc = false
			default:
				unknownCommand("arcDistanceModeGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:21,代碼來源:main.go

示例11: setStop

func (vm *Machine) setStop(stmt *gcode.Block) {
	// TODO implement
	if w, err := stmt.GetModalGroup("stoppingGroup"); err == nil {
		if w != nil {
			if w.Address != 'M' {
				unknownCommand("stoppingGroup", w)
			}

			switch w.Command {
			case 2:
				vm.Completed = true
			case 30:
				vm.Completed = true
			default:
				unknownCommand("stoppingGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:22,代碼來源:main.go

示例12: setPlane

func (vm *Machine) setPlane(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("planeSelectionGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("planeSelectionGroup", w)
			}

			switch w.Command {
			case 17:
				vm.MovePlane = PlaneXY
			case 18:
				vm.MovePlane = PlaneXZ
			case 19:
				vm.MovePlane = PlaneYZ
			default:
				unknownCommand("planeSelectionGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:23,代碼來源:main.go

示例13: toolChange

func (vm *Machine) toolChange(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("toolChangeGroup"); err == nil {
		if w != nil {
			if w.Address != 'M' {
				unknownCommand("toolChangeGroup", w)
			}

			switch w.Command {
			case 6:
				if vm.NextTool == -1 {
					panic("Toolchange attempted without a defined tool")
				}
				vm.State.Tool = vm.NextTool
			default:
				unknownCommand("toolChangeGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}

}
開發者ID:raylee,項目名稱:gocnc,代碼行數:23,代碼來源:main.go

示例14: setCutterCompensation

func (vm *Machine) setCutterCompensation(stmt *gcode.Block) {
	if w, err := stmt.GetModalGroup("cutterCompensationModeGroup"); err == nil {
		if w != nil {
			if w.Address != 'G' {
				unknownCommand("cutterCompensationModeGroup", w)
			}

			switch w.Command {
			case 40:
				vm.State.CutterCompensation = CutCompModeNone
			case 41:
				vm.State.CutterCompensation = CutCompModeOuter
			case 42:
				vm.State.CutterCompensation = CutCompModeInner
			default:
				unknownCommand("cutterCompensationModeGroup", w)
			}
			stmt.Remove(w)
		}
	} else {
		propagate(err)
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:23,代碼來源:main.go

示例15: performMove

func (vm *Machine) performMove(stmt *gcode.Block) {
	if !stmt.IncludesOneOf('X', 'Y', 'Z') {
		// Nothing to do
		return
	}

	s := vm.State

	if s.FeedMode == FeedModeInvTime && s.Feedrate == -1 && s.MoveMode != MoveModeRapid {
		invalidCommand("motionGroup", "rapid", "Non-rapid inverse time feed mode move attempted without a set feedrate")
	}

	if vm.CoordinateSystem.OverrideActive() {
		if s.CutterCompensation != CutCompModeNone {
			invalidCommand("motionGroup", "move", "Coordinate override attempted with cutter compensation enabled")
		}

		if s.MoveMode == MoveModeCWArc || s.MoveMode == MoveModeCCWArc {
			invalidCommand("motionGroup", "arc", "Coordinate override attempted for arc")
		}
	}

	if s.MoveMode == MoveModeCWArc || s.MoveMode == MoveModeCCWArc {
		// Arc
		newX, newY, newZ, newI, newJ, newK := vm.calcPos(*stmt)
		vm.arc(newX, newY, newZ, newI, newJ, newK, stmt.GetWordDefault('P', 1))
		stmt.RemoveAddress('X', 'Y', 'Z', 'I', 'J', 'K', 'P')

	} else if s.MoveMode == MoveModeLinear || s.MoveMode == MoveModeRapid {
		// Line
		newX, newY, newZ, _, _, _ := vm.calcPos(*stmt)
		vm.move(newX, newY, newZ)
		stmt.RemoveAddress('X', 'Y', 'Z')

	} else {
		invalidCommand("motionGroup", "move", fmt.Sprintf("Move attempted without an active move mode [%s]", stmt.Export(-1)))
	}
}
開發者ID:raylee,項目名稱:gocnc,代碼行數:38,代碼來源:main.go


注:本文中的github.com/joushou/gocnc/gcode.Block類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。