Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GCodeQueue.h « GCodes « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f29090e0a5d0c9557dadb813cfa3987fa8ecaa69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * GCodeQueue.h
 *
 *  Created on: 22 Jun 2016
 *      Author: Christian
 */
#ifndef GCODEQUEUE_H
#define GCODEQUEUE_H

#include "RepRapFirmware.h"
#include "GCodeInput.h"

class QueuedCode;

const size_t BufferSizePerQueueItem = SHORT_GCODE_LENGTH;

class GCodeQueue : public GCodeInput
{
public:
	GCodeQueue() noexcept;

	void Reset() noexcept override;										// Clean all the cached data from this input
	bool FillBuffer(GCodeBuffer *gb) noexcept override;					// If there is another move to execute at this time, fill a buffer
	size_t BytesCached() const noexcept override;						// How many bytes have been cached?

	bool QueueCode(GCodeBuffer &gb, uint32_t scheduleAt) noexcept;		// Queue a G-code
	void PurgeEntries() noexcept;										// Remove stored codes when a print is being paused
	void Clear() noexcept;												// Clean up all the stored codes
	bool IsIdle() const noexcept;										// Return true if there is nothing to do

	void Diagnostics(MessageType mtype) noexcept;

	static bool ShouldQueueCode(GCodeBuffer &gb) THROWS(GCodeException);	// Return true if this code should be queued

private:
	QueuedCode *freeItems;
	QueuedCode *queuedItems;
};

class QueuedCode
{
public:
	friend class GCodeQueue;

	QueuedCode(QueuedCode *n) noexcept : next(n), dataLength(0) { }
	QueuedCode *Next() const noexcept { return next; }

private:
	QueuedCode *next;

#if HAS_LINUX_INTERFACE
	bool isBinary;
	alignas(4) char data[BufferSizePerQueueItem];
#else
	char data[BufferSizePerQueueItem];
#endif
	size_t dataLength;

	uint32_t executeAtMove;

	void AssignFrom(GCodeBuffer &gb) noexcept;
	void AssignTo(GCodeBuffer *gb) noexcept;
};

#endif