@@ -32,6 +32,7 @@ You should have received a copy of the GNU Lesser General Public
3232using Google . Protobuf . Collections ;
3333using OVFDefinition ;
3434using System . Diagnostics ;
35+ using GCodeReaderWriter . Commands ;
3536
3637namespace OpenVectorFormat . GCodeReaderWriter
3738{
@@ -288,21 +289,28 @@ void ProcessMovementCmd(MovementCommand movementCmd)
288289
289290 void UpdateLineSequence ( LinearInterpolationCmd linearCmd )
290291 {
291- // Update speed first to check if marking params changed and new vector block is needed
292- UpdateSpeed ( linearCmd . isOperation , linearCmd . feedRate ) ;
292+ // Check if linearCmd is a jump command and create new vector block if true
293+ if ( ! linearCmd . isOperation )
294+ {
295+ var lastJumpSpeed = currentMP . JumpSpeedInMmS ;
296+ NewVectorBlock ( ) ;
297+ currentMP . JumpSpeedInMmS = linearCmd . feedRate ?? lastJumpSpeed ;
298+ }
293299
300+ // Update or create new LineSequenceParaAdapt
294301 if ( _currentVB . LineSequenceParaAdapt == null )
295302 {
296- _currentVB . LineSequenceParaAdapt = new VectorBlock . Types . LineSequenceParaAdapt
297- {
298- } ;
303+ _currentVB . LineSequenceParaAdapt = new VectorBlock . Types . LineSequenceParaAdapt ( ) ;
304+ _currentVB . LineSequenceParaAdapt . Parameter . Add ( VectorBlock . Types . LineSequenceParaAdapt . Types . AdaptedParameter . LaserSpeedInMmPerS ) ;
299305 }
300306 _currentVB . LineSequenceParaAdapt . PointsWithParas . Add ( absolutePositioning
301307 ? ( linearCmd . xPosition ?? position . X ) // Use absolute x-positioning
302308 : ( position . X + ( linearCmd . xPosition ?? 0 ) ) ) ; // Use relative xpositioning
303309 _currentVB . LineSequenceParaAdapt . PointsWithParas . Add ( absolutePositioning
304310 ? ( linearCmd . yPosition ?? position . Y ) // Use absolute y-positioning
305311 : ( position . Y + ( linearCmd . yPosition ?? 0 ) ) ) ; // Use relative y-positioning
312+ _currentVB . LineSequenceParaAdapt . PointsWithParas . Add ( linearCmd . feedRate // Use feedrate from command
313+ ?? _currentVB . LineSequenceParaAdapt . PointsWithParas [ _currentVB . LineSequenceParaAdapt . PointsWithParas . Count - 3 ] ) ; // Use last saved speed if command does not define a new feedrate
306314 }
307315
308316 void UpdateArc ( CircularInterpolationCmd circularCmd )
@@ -346,33 +354,6 @@ void UpdateArc(CircularInterpolationCmd circularCmd)
346354 _currentVB . Arcs . Centers . Add ( position . X + circularCmd . xCenterRel ?? position . X ) ;
347355 _currentVB . Arcs . Centers . Add ( position . Y + circularCmd . yCenterRel ?? position . Y ) ;
348356 }
349-
350- void UpdateSpeed ( bool isOperation , float ? newSpeed )
351- {
352- // Check if machine movement is travel or operation move and assign speed accordingly
353- if ( isOperation )
354- {
355- if ( newSpeed != null && currentMP . LaserSpeedInMmPerS != newSpeed )
356- {
357- if ( currentMP . LaserSpeedInMmPerS != 0 && ! VBlocked )
358- {
359- NewVectorBlock ( ) ;
360- }
361- currentMP . LaserSpeedInMmPerS = ( float ) newSpeed ;
362- }
363- }
364- else
365- {
366- if ( newSpeed != null && currentMP . JumpSpeedInMmS != newSpeed )
367- {
368- if ( currentMP . JumpSpeedInMmS != 0 && ! VBlocked )
369- {
370- NewVectorBlock ( ) ;
371- }
372- currentMP . JumpSpeedInMmS = ( float ) newSpeed ;
373- }
374- }
375- }
376357 }
377358
378359 void ProcessPauseCmd ( PauseCommand pauseCmd )
@@ -416,6 +397,33 @@ void ProcessMiscCmd(MiscCommand miscCmd)
416397
417398 }
418399
400+ void UpdateSpeed ( bool isOperation , float ? newSpeed )
401+ {
402+ // Check if machine movement is travel or operation move and assign speed accordingly
403+ if ( isOperation )
404+ {
405+ if ( newSpeed != null && currentMP . LaserSpeedInMmPerS != newSpeed )
406+ {
407+ if ( currentMP . LaserSpeedInMmPerS != 0 && ! VBlocked )
408+ {
409+ NewVectorBlock ( ) ;
410+ }
411+ currentMP . LaserSpeedInMmPerS = ( float ) newSpeed ;
412+ }
413+ }
414+ else
415+ {
416+ if ( newSpeed != null && currentMP . JumpSpeedInMmS != newSpeed )
417+ {
418+ if ( currentMP . JumpSpeedInMmS != 0 && ! VBlocked )
419+ {
420+ NewVectorBlock ( ) ;
421+ }
422+ currentMP . JumpSpeedInMmS = ( float ) newSpeed ;
423+ }
424+ }
425+ }
426+
419427 void UpdatePosition ( MovementCommand movementCmd )
420428 {
421429 /* Update position with coordinates given in movement command.
0 commit comments