1
#ifndef FABATHOMEPRINTER_H
2
#define FABATHOMEPRINTER_H
10
class FabAtHomePrinter
12
//CONSTANTS/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14
byte X_Y_Z_GROUP_ADDRESS;
15
unsigned int NUM_MODULES, BAUD_RATE;
16
unsigned int COM_PORT;
17
double PLATFORM_DELTA;
18
double PRINT_ACCELERATION; //The acceleration that is used while printing. The unit of PRINT_ACCELERATION is U/(second^2).
19
double OLD_MSPS; //Magic constant from line 58 of FabAtHomeParameters.h in model 1 code. Used to calculate values for pushout and suckback.
20
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23
map<string, Motor, LessThanString> motors; //A map from motor names to motors.
24
map<string, MaterialCalibration, LessThanString> materialCalibrations; //A map from material calibration names to material calibrations.
25
bool pausePrintFlag, cancelPrintFlag, redoPathFlag, printing, initialized, paused;
27
//Any \ in filePath must be escaped with \
28
//Returns: "" iff successful or an error message.
29
string loadConfigFile(string filePath);
31
//Switch printer to path mode.
32
//Returns: True iff successful.
33
bool initializePathMode(void);
36
//The bay will execute pushout, standard flow, and suckback iff flowDuringPath is true.
37
//A call to this function returns when movement has finished.
38
void executePath(const Path& path, Bay* bay, const bool flowDuringPath);
41
//The bay will execute pushout, standard flow, and suckback iff flowDuringPath is true.
42
//A call to this function returns when all points are in the path point buffer.
43
void executePoints(const vector<Point>& points, Bay* bay, const bool flowDuringPath, double pushoutDistance, double pushoutVelocity, double standardDistance, double standardVelocity, double suckbackDistance, double suckbackVelocity, const Point& suckbackPoint);
45
//Move all points from segment list to path point buffer. Physical movement begins as soon as a point is in the path point buffer.
46
//The bay will execute pushout, standard flow, and suckback iff flowDuringPath is true.
47
void downloadSegmentList(Bay* bay, bool startFlow, bool startSuckback, double pushoutDistance, double pushoutVelocity, double standardDistance, double standardVelocity, double suckbackDistance, double suckbackVelocity, const Point& suckbackPoint);
49
//Clears the segment list and then tries to add points into the segment list starting from startIndex.
50
//Segment list has size 1000 but this function does not necessarily fill it completely.
51
//Returns: The last index of points that was added to the segment list or -1 if points is empty.
52
int fillSegmentList(const vector<Point>& points, const int startIndex);
54
//Returns: A bay that has the material calibration loaded or NULL if no such bay exists.
55
Bay* findBay(MaterialCalibration*);
57
void executePausePath(const Point&);
58
void executeSetupPath(const Point&, const Point&, const double&);
60
string loadMaterialCalibration(TiXmlNode*);
61
string loadPath(TiXmlNode*);
63
//The copy constructor. Private to prevent printer from being copied.
64
FabAtHomePrinter(const FabAtHomePrinter&);
66
//The copy assignment operator. Private to prevent printer from being copied.
67
FabAtHomePrinter& operator=(const FabAtHomePrinter&);
70
map<string, Axis, LessThanString> axes; //A map from axis names to axes.
73
FabAtHomePrinter(void);
75
//Inserts into result the names of all material calibrations that are currently loaded.
76
void loadedMaterialCalibrations(vector<string>& result);
78
//Returns: The number of paths currently loaded.
79
int numLoadedPaths(void);
81
//Returns: The number of bays currently loaded.
82
int numLoadedBays(void);
84
//Returns: True iff printer is printing.
85
bool isPrinting(void);
87
//Returns: True iff printer is paused.
90
//Pause print after the current path finishes.
91
//Requires: isPrinting()
92
void pausePrint(void);
94
//Cancel print after the current path finishes.
95
//Requires: isPrinting()
96
void cancelPrint(void);
98
//Redo the current path after the current path finishes.
99
//Requires: isPrinting()
102
//Any \ in filePath must be escaped with \
103
//Load a file specifying material configurations and paths.
104
//Returns: "" iff successful or an error message.
105
string loadFabFile(string filePath);
107
//Initialize the printer.
108
//Returns: "" if successful or an error message if failed.
109
string initialize(const string& configFilePath);
111
//Equip a bay with a material calibration or unequip the bay if the material calibration is "".
112
//Requires: !isPrinting() || isPaused() and the bay and material calibration have been loaded.
113
void equipBay(const string& bayName, const string& materialCalibrationName);
115
//Execute all paths which are currently loaded.
116
//A call to this function returns when the print has finished.
117
//If fabricationThread != NULL, messages will periodically be stored in displayText
118
//describing what the printer is currently doing and progress will be reported to fabricationThread when the message changes.
119
//void print(System::ComponentModel::BackgroundWorker* fabricationThread, string& displayText);
121
//Perform clean up when done using printer.
122
//Returns: True iff successful.
126
~FabAtHomePrinter(void);
129
#endif //ndef FABATHOMEPRINTER_H