void grblComm_StatusUpdate(object sender, GrblStatus status) { if (InvokeRequired) { GrblStatus statCopy = status.Clone(); BeginInvoke(new MethodInvoker(() => { grblComm_StatusUpdate(sender, statCopy); })); return; } Vector3 headpos = new Vector3(status.axisPos[0], status.axisPos[1], status.axisPos[2]); visualizerWinMain.SetMillheadPos(headpos); if (status.lineNumber > 0) { gcodeMainViewer.SetSelectedLine(status.lineNumber - 1, true); } toolStripEstop.Checked = status.state == GrblStatus.MachineState.Alarm; statusView.SetAxisValues(status.axisPos); statusView.SetAlarms(status.alarms); statusView.SetFeedSpindle(status.feedRate, status.spindleRpm); statusView.SetHomeState(status.homeStatus); if (status.gStateChange) { mdiCtrl.SetGcodeParserStatus(status.gState); } toolStripProgressBuff.Value1 = status.uartBuffer; toolStripProgressBuff.Value2 = status.planBuffer; visualizerOverlay.Update(status); }
public void Update(GrblStatus status) { if (status.gState == null) { return; } if (CopyCoords(status.workingCoords) || lastCoordCode != status.CurrentCoordSystem || lastTool != Global.ginterp.currentTool) { lastCoordCode = status.CurrentCoordSystem; lastTool = Global.ginterp.currentTool; using (Graphics g = viswin.GetOverlayGraphics()) { g.Clear(Color.Transparent); g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; cury = curx = 10; PrintLine(g, "WCO active: " + lastCoordCode + ", T" + lastTool.ToString()); for (int i = 0; i < lastCoords.Length; i++) { PrintLine(g, "WCO " + Utils.GetAxisLetter(i) + ": " + lastCoords[i].ToString("0.000")); } } viswin.UpdateOverlay(); } }
public GrblStatus Clone() { GrblStatus clone = new GrblStatus(); for (int i = 0; i < axisPos.Length; i++) { clone.axisPos[i] = axisPos[i]; } for (int i = 0; i < axisPos.Length; i++) { clone.workingCoords[i] = workingCoords[i]; } clone.state = state; clone.feedRate = feedRate; clone.spindleRpm = spindleRpm; clone.dataValid = dataValid; clone.alarms = alarms; clone.homeStatus = homeStatus; clone.planBuffer = planBuffer; clone.uartBuffer = uartBuffer; clone.lineNumber = lineNumber; clone.alarmCode = alarmCode; clone.gState = gState; clone.gStateChange = gStateChange; return(clone); }
public GrblComm() { portNames = null; scanPortIx = -1; activePort = null; portOpened = false; port = new SerialPort(); readLine = new StringBuilder(); grblStatus = new GrblStatus(); grblConfig = new GrblConfig(); gcodeConfig = new GCodeConfig(); port.DataReceived += port_DataReceived; standardMsgQueue = new List <string>(); urgentMsgQueue = new List <string>(); commandBatch = new List <string>(); ReadErrorCodes(); scanCount = 0; Global.grblStatus = grblStatus; Global.grblConfig = grblConfig; }
public void Update(GrblStatus status) { if (status.gState == null) { return; } if (CopyCoords(status.workingCoords) || lastCoordCode != status.CurrentCoordSystem) { lastCoordCode = status.CurrentCoordSystem; using (Graphics g = viswin.GetOverlayGraphics()) { g.Clear(Color.Transparent); g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; for (int i = 0; i < lastCoords.Length; i++) { string str = lastCoordCode + " " + Utils.GetAxisLetter(i) + ": " + lastCoords[i].ToString("0.000"); g.DrawString(str, font, Brushes.Black, 10, i * 15 + 10); } } viswin.UpdateOverlay(); } }